@@ -21641,10 +21641,30 @@ void EmitPass::emitsrnd(llvm::GenIntrinsicInst* GII)
21641
21641
}
21642
21642
}
21643
21643
21644
- static LSC_CACHE_OPTS translateLSCCacheControlsEnum(
21645
- LSC_L1_L3_CC l1l3cc, bool isLoad
21646
- )
21644
+ bool EmitPass::isSupportedLSCCacheControlsEnum(LSC_L1_L3_CC l1l3cc, bool isLoad) const
21645
+ {
21646
+ if (isLoad)
21647
+ {
21648
+ switch (l1l3cc)
21649
+ {
21650
+ default: break;
21651
+ case LSC_L1UC_L3CC:
21652
+ case LSC_L1C_L3CC:
21653
+ case LSC_L1IAR_L3IAR:
21654
+ return (m_pCtx->platform.isCoreChildOf(IGFX_XE2_LPG_CORE));
21655
+ }
21656
+ }
21657
+ return true;
21658
+ }
21659
+
21660
+ LSC_CACHE_OPTS EmitPass::translateLSCCacheControlsEnum(
21661
+ LSC_L1_L3_CC l1l3cc, bool isLoad, const Value* warningContextValue) const
21647
21662
{
21663
+ if (!isSupportedLSCCacheControlsEnum(l1l3cc, isLoad)) {
21664
+ m_pCtx->EmitWarning("Unsupported cache controls configuration requested. Applying default configuration.", warningContextValue);
21665
+ l1l3cc = LSC_L1DEF_L3DEF;
21666
+ }
21667
+
21648
21668
LSC_CACHE_OPTS cacheOpts {LSC_CACHING_DEFAULT, LSC_CACHING_DEFAULT};
21649
21669
switch (l1l3cc)
21650
21670
{
@@ -21716,15 +21736,13 @@ LSC_CACHE_OPTS EmitPass::translateLSCCacheControlsFromValue(
21716
21736
{
21717
21737
return translateLSCCacheControlsEnum(
21718
21738
static_cast<LSC_L1_L3_CC>(cast<ConstantInt>(value)->getSExtValue()),
21719
- isLoad
21720
- );
21739
+ isLoad, value);
21721
21740
}
21722
21741
21723
- static Optional<LSC_CACHE_OPTS>
21724
- setCacheOptionsForConstantBufferLoads(Instruction& inst, LSC_L1_L3_CC Ctrl
21725
- )
21742
+ Optional<LSC_CACHE_OPTS>
21743
+ EmitPass::cacheOptionsForConstantBufferLoads(Instruction* inst, LSC_L1_L3_CC Ctrl) const
21726
21744
{
21727
- if (const Value* resourcePointer = GetBufferOperand(& inst))
21745
+ if (const Value* resourcePointer = GetBufferOperand(inst))
21728
21746
{
21729
21747
uint addressSpace = resourcePointer->getType()->getPointerAddressSpace();
21730
21748
BufferType bufferType = GetBufferType(addressSpace);
@@ -21733,37 +21751,34 @@ setCacheOptionsForConstantBufferLoads(Instruction& inst, LSC_L1_L3_CC Ctrl
21733
21751
(bufferType == BINDLESS_CONSTANT_BUFFER) ||
21734
21752
(bufferType == SSH_BINDLESS_CONSTANT_BUFFER))
21735
21753
{
21736
- return translateLSCCacheControlsEnum(Ctrl, true
21737
- );
21754
+ return translateLSCCacheControlsEnum(Ctrl, true, inst);
21738
21755
}
21739
21756
}
21740
21757
return None;
21741
21758
}
21742
21759
21743
21760
Optional<LSC_CACHE_OPTS>
21744
- EmitPass::setCacheOptionsForConstantBufferLoads (Instruction& inst) const
21761
+ EmitPass::cacheOptionsForConstantBufferLoads (Instruction* inst) const
21745
21762
{
21746
21763
Optional<LSC_CACHE_OPTS> cacheOpts;
21747
21764
if (IGC_IS_FLAG_DISABLED(DisableSystemMemoryCachingInGPUForConstantBuffers) &&
21748
21765
m_currShader->m_Platform->isCoreChildOf(IGFX_XE2_LPG_CORE))
21749
21766
{
21750
- if (auto Opts = ::setCacheOptionsForConstantBufferLoads(inst, LSC_L1C_L3CC
21751
- ))
21767
+ if (auto Opts = cacheOptionsForConstantBufferLoads(inst, LSC_L1C_L3CC))
21752
21768
cacheOpts = *Opts;
21753
21769
}
21754
21770
if (m_pCtx->type == ShaderType::RAYTRACING_SHADER &&
21755
21771
IGC_IS_FLAG_ENABLED(ForceRTConstantBufferCacheCtrl))
21756
21772
{
21757
21773
auto Ctrl = (LSC_L1_L3_CC)IGC_GET_FLAG_VALUE(RTConstantBufferCacheCtrl);
21758
- if (auto Opts = ::setCacheOptionsForConstantBufferLoads(inst, Ctrl
21759
- ))
21774
+ if (auto Opts = cacheOptionsForConstantBufferLoads(inst, Ctrl))
21760
21775
cacheOpts = *Opts;
21761
21776
}
21762
21777
return cacheOpts;
21763
21778
}
21764
21779
21765
- static bool tryOverrideCacheOpts(LSC_CACHE_OPTS& cacheOpts, bool isLoad, bool isTGM
21766
- )
21780
+ bool EmitPass:: tryOverrideCacheOpts(LSC_CACHE_OPTS& cacheOpts, bool isLoad, bool isTGM,
21781
+ const Value* warningContextValue) const
21767
21782
{
21768
21783
uint32_t l1l3CacheVal = 0;
21769
21784
@@ -21782,9 +21797,7 @@ static bool tryOverrideCacheOpts(LSC_CACHE_OPTS& cacheOpts, bool isLoad, bool is
21782
21797
21783
21798
if (l1l3CacheVal != 0)
21784
21799
{
21785
- cacheOpts = translateLSCCacheControlsEnum(
21786
- static_cast<LSC_L1_L3_CC>(l1l3CacheVal), isLoad
21787
- );
21800
+ cacheOpts = translateLSCCacheControlsEnum(static_cast<LSC_L1_L3_CC>(l1l3CacheVal), isLoad, warningContextValue);
21788
21801
}
21789
21802
return l1l3CacheVal != 0;
21790
21803
}
@@ -21812,8 +21825,7 @@ LSC_CACHE_OPTS EmitPass::translateLSCCacheControlsFromMetadata(
21812
21825
{
21813
21826
if (m_pCtx->platform.supportsNonDefaultLSCCacheSetting())
21814
21827
{
21815
- if (tryOverrideCacheOpts(cacheOpts, isLoad, isTGM
21816
- ))
21828
+ if (tryOverrideCacheOpts(cacheOpts, isLoad, isTGM, inst))
21817
21829
{
21818
21830
// global override cache settings have highest priority
21819
21831
return cacheOpts;
@@ -21839,14 +21851,12 @@ LSC_CACHE_OPTS EmitPass::translateLSCCacheControlsFromMetadata(
21839
21851
if (isLoad && m_pCtx->getModuleMetaData()->compOpt.LoadCacheDefault != -1)
21840
21852
{ // load
21841
21853
LSC_L1_L3_CC L1L3Val = static_cast<LSC_L1_L3_CC>(m_pCtx->getModuleMetaData()->compOpt.LoadCacheDefault);
21842
- cacheOpts = translateLSCCacheControlsEnum(L1L3Val, true
21843
- );
21854
+ cacheOpts = translateLSCCacheControlsEnum(L1L3Val, true, inst);
21844
21855
}
21845
21856
else if (!isLoad && m_pCtx->getModuleMetaData()->compOpt.StoreCacheDefault != -1)
21846
21857
{ // store
21847
21858
LSC_L1_L3_CC L1L3Val = static_cast<LSC_L1_L3_CC>(m_pCtx->getModuleMetaData()->compOpt.StoreCacheDefault);
21848
- cacheOpts = translateLSCCacheControlsEnum(L1L3Val, false
21849
- );
21859
+ cacheOpts = translateLSCCacheControlsEnum(L1L3Val, false, inst);
21850
21860
}
21851
21861
}
21852
21862
@@ -21869,8 +21879,7 @@ LSC_CACHE_OPTS EmitPass::translateLSCCacheControlsFromMetadata(
21869
21879
}
21870
21880
}
21871
21881
21872
- if (tryOverrideCacheOpts(cacheOpts, isLoad, isTGM
21873
- ))
21882
+ if (tryOverrideCacheOpts(cacheOpts, isLoad, isTGM, inst))
21874
21883
{
21875
21884
// global override cache settings have highest priority
21876
21885
return cacheOpts;
@@ -21901,7 +21910,7 @@ LSC_CACHE_OPTS EmitPass::translateLSCCacheControlsFromMetadata(
21901
21910
21902
21911
if (inst && isLoad)
21903
21912
{
21904
- if (auto Opts = setCacheOptionsForConstantBufferLoads(* inst))
21913
+ if (auto Opts = cacheOptionsForConstantBufferLoads( inst))
21905
21914
cacheOpts = *Opts;
21906
21915
}
21907
21916
@@ -22110,7 +22119,7 @@ void EmitPass::emitLscIntrinsicLoad(llvm::GenIntrinsicInst* inst)
22110
22119
LSC_CACHE_OPTS cacheOpts = translateLSCCacheControlsFromValue(inst->getOperand(4), true);
22111
22120
LSC_DOC_ADDR_SPACE addrSpace = m_pCtx->getUserAddrSpaceMD().Get(inst);
22112
22121
22113
- if (auto Opts = setCacheOptionsForConstantBufferLoads(* inst))
22122
+ if (auto Opts = cacheOptionsForConstantBufferLoads( inst))
22114
22123
cacheOpts = *Opts;
22115
22124
22116
22125
emitLscIntrinsicFragments(m_destination, dataSize, dataElems, immOffset,
@@ -23094,8 +23103,7 @@ LSC_CACHE_OPTS EmitPass::getDefaultRaytracingCachePolicy(bool isLoad) const
23094
23103
LSC_L1IAR_WB_L3C_WB;
23095
23104
}
23096
23105
23097
- return translateLSCCacheControlsEnum(Opts, isLoad
23098
- );
23106
+ return translateLSCCacheControlsEnum(Opts, isLoad, nullptr);
23099
23107
}
23100
23108
23101
23109
void EmitPass::emitAsyncStackID(llvm::GenIntrinsicInst *I)
0 commit comments