Skip to content

Commit 08fce6e

Browse files
skarczewigcbot
authored andcommitted
Fix Efficient64b stateful surface index folding for sampler feedback
This optimization must not be applied to the paired texture operand of Sampler Feedback messages. The paired texture pointer is placed as a full 64-bit address in the sampler header and must remain intact.
1 parent 98b8ff7 commit 08fce6e

File tree

2 files changed

+9
-8
lines changed

2 files changed

+9
-8
lines changed

IGC/Compiler/CISACodeGen/EmitVISAPass.cpp

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5863,7 +5863,7 @@ void EmitPass::emitLdInstruction(llvm::Instruction *inst) {
58635863
ResourceDescriptor pairedResource =
58645864
samplerLoadIntrinsic->hasPairedTextureArg() &&
58655865
llvm::isa<llvm::UndefValue>(samplerLoadIntrinsic->getPairedTextureValue()) == false
5866-
? GetResourceVariable(samplerLoadIntrinsic->getPairedTextureValue())
5866+
? GetResourceVariable(samplerLoadIntrinsic->getPairedTextureValue(), /*skipStatefulFolding=*/true)
58675867
: ResourceDescriptor();
58685868

58695869
CVariable *offset = ComputeSampleIntOffset(inst, offsetSourceIndex);
@@ -8431,7 +8431,7 @@ void EmitPass::emitSampleInstruction(SampleIntrinsic *inst) {
84318431
[[maybe_unused]] bool isEval = isUsedOnlyByEval(inst);
84328432
ResourceDescriptor pairedResource =
84338433
inst->hasPairedTextureArg() && llvm::isa<llvm::UndefValue>(inst->getPairedTextureValue()) == false
8434-
? GetResourceVariable(inst->getPairedTextureValue())
8434+
? GetResourceVariable(inst->getPairedTextureValue(), /*skipStatefulFolding=*/true)
84358435
: ResourceDescriptor();
84368436

84378437

@@ -8786,9 +8786,10 @@ void EmitPass::emitGather4Instruction(SamplerGatherIntrinsic *inst) {
87868786
ResourceDescriptor resource = GetResourceVariable(textureValue);
87878787

87888788
[[maybe_unused]] bool isEval = isUsedOnlyByEval(inst);
8789-
ResourceDescriptor pairedResource = llvm::isa<llvm::UndefValue>(inst->getPairedTextureValue()) == false
8790-
? GetResourceVariable(inst->getPairedTextureValue())
8791-
: ResourceDescriptor();
8789+
ResourceDescriptor pairedResource =
8790+
llvm::isa<llvm::UndefValue>(inst->getPairedTextureValue()) == false
8791+
? GetResourceVariable(inst->getPairedTextureValue(), /*skipStatefulFolding=*/true)
8792+
: ResourceDescriptor();
87928793

87938794
SamplerDescriptor sampler;
87948795
Value *samplerValue = inst->getSamplerValue();
@@ -20697,7 +20698,7 @@ void EmitPass::emitGetBufferPtr(GenIntrinsicInst *inst) {
2069720698
m_currShader->SetBindingTableEntryCountAndBitmap(directIdx, bufType, 0, bti);
2069820699
}
2069920700

20700-
ResourceDescriptor EmitPass::GetResourceVariable(Value *resourcePtr) {
20701+
ResourceDescriptor EmitPass::GetResourceVariable(Value *resourcePtr, bool skipStatefulFolding) {
2070120702
ResourceDescriptor resource;
2070220703
BufferType bufType = BUFFER_TYPE_UNKNOWN;
2070320704
uint as = 0;
@@ -20721,7 +20722,7 @@ ResourceDescriptor EmitPass::GetResourceVariable(Value *resourcePtr) {
2072120722
if (IsBindless(bufType) || (bufType == RENDER_TARGET && m_currShader->m_Platform->hasEfficient64bEnabled()) ||
2072220723
!directIndexing) {
2072320724
auto SetResource = [&](Value *resourcePtr) {
20724-
if (m_currShader->m_Platform->hasEfficient64bEnabled()) {
20725+
if (!skipStatefulFolding && m_currShader->m_Platform->hasEfficient64bEnabled()) {
2072520726
if (auto SurfaceStateIndex = m_pattern->matchStateIndex(resourcePtr)) {
2072620727
resource.m_resource = GetSymbol(SurfaceStateIndex->first);
2072720728
resource.m_SurfaceStateIndex = SurfaceStateIndex->second;

IGC/Compiler/CISACodeGen/EmitVISAPass.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -707,7 +707,7 @@ class EmitPass : public llvm::FunctionPass {
707707
bool nomask = false);
708708
CVariable *BroadcastAndTruncPointer(CVariable *pVar);
709709
CVariable *IndexableResourceIndex(CVariable *indexVar, uint btiIndex);
710-
ResourceDescriptor GetResourceVariable(llvm::Value *resourcePtr);
710+
ResourceDescriptor GetResourceVariable(llvm::Value *resourcePtr, bool skipStatefulFolding = false);
711711
SamplerDescriptor GetSamplerVariable(llvm::Value *samplerPtr);
712712
CVariable *ComputeSampleIntOffset(llvm::Instruction *sample, uint sourceIndex);
713713
void emitPlnInterpolation(CVariable *bary, CVariable *inputvar);

0 commit comments

Comments
 (0)