@@ -21700,10 +21700,30 @@ void EmitPass::emitsrnd(llvm::GenIntrinsicInst* GII)
21700
21700
}
21701
21701
}
21702
21702
21703
- static LSC_CACHE_OPTS translateLSCCacheControlsEnum(
21704
- LSC_L1_L3_CC l1l3cc, bool isLoad
21705
- )
21703
+ bool EmitPass::isSupportedLSCCacheControlsEnum(LSC_L1_L3_CC l1l3cc, bool isLoad) const
21704
+ {
21705
+ if (isLoad)
21706
+ {
21707
+ switch (l1l3cc)
21708
+ {
21709
+ default: break;
21710
+ case LSC_L1UC_L3CC:
21711
+ case LSC_L1C_L3CC:
21712
+ case LSC_L1IAR_L3IAR:
21713
+ return (m_pCtx->platform.isCoreChildOf(IGFX_XE2_LPG_CORE));
21714
+ }
21715
+ }
21716
+ return true;
21717
+ }
21718
+
21719
+ LSC_CACHE_OPTS EmitPass::translateLSCCacheControlsEnum(
21720
+ LSC_L1_L3_CC l1l3cc, bool isLoad, const Value* warningContextValue) const
21706
21721
{
21722
+ if (!isSupportedLSCCacheControlsEnum(l1l3cc, isLoad)) {
21723
+ m_pCtx->EmitWarning("Unsupported cache controls configuration requested. Applying default configuration.", warningContextValue);
21724
+ l1l3cc = LSC_L1DEF_L3DEF;
21725
+ }
21726
+
21707
21727
LSC_CACHE_OPTS cacheOpts {LSC_CACHING_DEFAULT, LSC_CACHING_DEFAULT};
21708
21728
switch (l1l3cc)
21709
21729
{
@@ -21775,15 +21795,13 @@ LSC_CACHE_OPTS EmitPass::translateLSCCacheControlsFromValue(
21775
21795
{
21776
21796
return translateLSCCacheControlsEnum(
21777
21797
static_cast<LSC_L1_L3_CC>(cast<ConstantInt>(value)->getSExtValue()),
21778
- isLoad
21779
- );
21798
+ isLoad, value);
21780
21799
}
21781
21800
21782
- static Optional<LSC_CACHE_OPTS>
21783
- setCacheOptionsForConstantBufferLoads(Instruction& inst, LSC_L1_L3_CC Ctrl
21784
- )
21801
+ Optional<LSC_CACHE_OPTS>
21802
+ EmitPass::cacheOptionsForConstantBufferLoads(Instruction* inst, LSC_L1_L3_CC Ctrl) const
21785
21803
{
21786
- if (const Value* resourcePointer = GetBufferOperand(& inst))
21804
+ if (const Value* resourcePointer = GetBufferOperand(inst))
21787
21805
{
21788
21806
uint addressSpace = resourcePointer->getType()->getPointerAddressSpace();
21789
21807
BufferType bufferType = GetBufferType(addressSpace);
@@ -21792,37 +21810,34 @@ setCacheOptionsForConstantBufferLoads(Instruction& inst, LSC_L1_L3_CC Ctrl
21792
21810
(bufferType == BINDLESS_CONSTANT_BUFFER) ||
21793
21811
(bufferType == SSH_BINDLESS_CONSTANT_BUFFER))
21794
21812
{
21795
- return translateLSCCacheControlsEnum(Ctrl, true
21796
- );
21813
+ return translateLSCCacheControlsEnum(Ctrl, true, inst);
21797
21814
}
21798
21815
}
21799
21816
return None;
21800
21817
}
21801
21818
21802
21819
Optional<LSC_CACHE_OPTS>
21803
- EmitPass::setCacheOptionsForConstantBufferLoads (Instruction& inst) const
21820
+ EmitPass::cacheOptionsForConstantBufferLoads (Instruction* inst) const
21804
21821
{
21805
21822
Optional<LSC_CACHE_OPTS> cacheOpts;
21806
21823
if (IGC_IS_FLAG_DISABLED(DisableSystemMemoryCachingInGPUForConstantBuffers) &&
21807
21824
m_currShader->m_Platform->isCoreChildOf(IGFX_XE2_LPG_CORE))
21808
21825
{
21809
- if (auto Opts = ::setCacheOptionsForConstantBufferLoads(inst, LSC_L1C_L3CC
21810
- ))
21826
+ if (auto Opts = cacheOptionsForConstantBufferLoads(inst, LSC_L1C_L3CC))
21811
21827
cacheOpts = *Opts;
21812
21828
}
21813
21829
if (m_pCtx->type == ShaderType::RAYTRACING_SHADER &&
21814
21830
IGC_IS_FLAG_ENABLED(ForceRTConstantBufferCacheCtrl))
21815
21831
{
21816
21832
auto Ctrl = (LSC_L1_L3_CC)IGC_GET_FLAG_VALUE(RTConstantBufferCacheCtrl);
21817
- if (auto Opts = ::setCacheOptionsForConstantBufferLoads(inst, Ctrl
21818
- ))
21833
+ if (auto Opts = cacheOptionsForConstantBufferLoads(inst, Ctrl))
21819
21834
cacheOpts = *Opts;
21820
21835
}
21821
21836
return cacheOpts;
21822
21837
}
21823
21838
21824
- static bool tryOverrideCacheOpts(LSC_CACHE_OPTS& cacheOpts, bool isLoad, bool isTGM
21825
- )
21839
+ bool EmitPass:: tryOverrideCacheOpts(LSC_CACHE_OPTS& cacheOpts, bool isLoad, bool isTGM,
21840
+ const Value* warningContextValue) const
21826
21841
{
21827
21842
uint32_t l1l3CacheVal = 0;
21828
21843
@@ -21841,9 +21856,7 @@ static bool tryOverrideCacheOpts(LSC_CACHE_OPTS& cacheOpts, bool isLoad, bool is
21841
21856
21842
21857
if (l1l3CacheVal != 0)
21843
21858
{
21844
- cacheOpts = translateLSCCacheControlsEnum(
21845
- static_cast<LSC_L1_L3_CC>(l1l3CacheVal), isLoad
21846
- );
21859
+ cacheOpts = translateLSCCacheControlsEnum(static_cast<LSC_L1_L3_CC>(l1l3CacheVal), isLoad, warningContextValue);
21847
21860
}
21848
21861
return l1l3CacheVal != 0;
21849
21862
}
@@ -21871,8 +21884,7 @@ LSC_CACHE_OPTS EmitPass::translateLSCCacheControlsFromMetadata(
21871
21884
{
21872
21885
if (m_pCtx->platform.supportsNonDefaultLSCCacheSetting())
21873
21886
{
21874
- if (tryOverrideCacheOpts(cacheOpts, isLoad, isTGM
21875
- ))
21887
+ if (tryOverrideCacheOpts(cacheOpts, isLoad, isTGM, inst))
21876
21888
{
21877
21889
// global override cache settings have highest priority
21878
21890
return cacheOpts;
@@ -21898,14 +21910,12 @@ LSC_CACHE_OPTS EmitPass::translateLSCCacheControlsFromMetadata(
21898
21910
if (isLoad && m_pCtx->getModuleMetaData()->compOpt.LoadCacheDefault != -1)
21899
21911
{ // load
21900
21912
LSC_L1_L3_CC L1L3Val = static_cast<LSC_L1_L3_CC>(m_pCtx->getModuleMetaData()->compOpt.LoadCacheDefault);
21901
- cacheOpts = translateLSCCacheControlsEnum(L1L3Val, true
21902
- );
21913
+ cacheOpts = translateLSCCacheControlsEnum(L1L3Val, true, inst);
21903
21914
}
21904
21915
else if (!isLoad && m_pCtx->getModuleMetaData()->compOpt.StoreCacheDefault != -1)
21905
21916
{ // store
21906
21917
LSC_L1_L3_CC L1L3Val = static_cast<LSC_L1_L3_CC>(m_pCtx->getModuleMetaData()->compOpt.StoreCacheDefault);
21907
- cacheOpts = translateLSCCacheControlsEnum(L1L3Val, false
21908
- );
21918
+ cacheOpts = translateLSCCacheControlsEnum(L1L3Val, false, inst);
21909
21919
}
21910
21920
}
21911
21921
@@ -21928,8 +21938,7 @@ LSC_CACHE_OPTS EmitPass::translateLSCCacheControlsFromMetadata(
21928
21938
}
21929
21939
}
21930
21940
21931
- if (tryOverrideCacheOpts(cacheOpts, isLoad, isTGM
21932
- ))
21941
+ if (tryOverrideCacheOpts(cacheOpts, isLoad, isTGM, inst))
21933
21942
{
21934
21943
// global override cache settings have highest priority
21935
21944
return cacheOpts;
@@ -21960,7 +21969,7 @@ LSC_CACHE_OPTS EmitPass::translateLSCCacheControlsFromMetadata(
21960
21969
21961
21970
if (inst && isLoad)
21962
21971
{
21963
- if (auto Opts = setCacheOptionsForConstantBufferLoads(* inst))
21972
+ if (auto Opts = cacheOptionsForConstantBufferLoads( inst))
21964
21973
cacheOpts = *Opts;
21965
21974
}
21966
21975
@@ -22169,7 +22178,7 @@ void EmitPass::emitLscIntrinsicLoad(llvm::GenIntrinsicInst* inst)
22169
22178
LSC_CACHE_OPTS cacheOpts = translateLSCCacheControlsFromValue(inst->getOperand(4), true);
22170
22179
LSC_DOC_ADDR_SPACE addrSpace = m_pCtx->getUserAddrSpaceMD().Get(inst);
22171
22180
22172
- if (auto Opts = setCacheOptionsForConstantBufferLoads(* inst))
22181
+ if (auto Opts = cacheOptionsForConstantBufferLoads( inst))
22173
22182
cacheOpts = *Opts;
22174
22183
22175
22184
emitLscIntrinsicFragments(m_destination, dataSize, dataElems, immOffset,
@@ -23163,8 +23172,7 @@ LSC_CACHE_OPTS EmitPass::getDefaultRaytracingCachePolicy(bool isLoad) const
23163
23172
LSC_L1IAR_WB_L3C_WB;
23164
23173
}
23165
23174
23166
- return translateLSCCacheControlsEnum(Opts, isLoad
23167
- );
23175
+ return translateLSCCacheControlsEnum(Opts, isLoad, nullptr);
23168
23176
}
23169
23177
23170
23178
void EmitPass::emitAsyncStackID(llvm::GenIntrinsicInst *I)
0 commit comments