Skip to content

Commit 8c774c3

Browse files
mmereckiigcbot
authored andcommitted
Fix Pixel Null Mask mask decoding for uniform sampler loads
Clear unused simd lanes from `Pixel Null Mask`.
1 parent 80a9112 commit 8c774c3

1 file changed

Lines changed: 21 additions & 12 deletions

File tree

IGC/Compiler/CISACodeGen/EmitVISAPass.cpp

Lines changed: 21 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -5963,6 +5963,8 @@ void EmitPass::emitLdInstruction(llvm::Instruction *inst) {
59635963
zeroLOD = true;
59645964
}
59655965

5966+
SIMDMode minSamplerMessageSimdMode = m_currShader->m_Platform->getMinDispatchMode();
5967+
59665968
// create send payload for numSources
59675969
for (uint i = 0; i < numSources; i++) {
59685970
uint index = i;
@@ -5975,11 +5977,11 @@ void EmitPass::emitLdInstruction(llvm::Instruction *inst) {
59755977

59765978
CVariable *src = GetSymbol(inst->getOperand(index));
59775979
if (src->IsUniform()) {
5978-
auto uniformSIMDMode = m_currShader->m_Platform->getMinDispatchMode();
5979-
uint16_t size = m_destination->IsUniform() ? numLanes(uniformSIMDMode) : numLanes(m_currShader->m_SIMDSize);
5980+
uint16_t size =
5981+
m_destination->IsUniform() ? numLanes(minSamplerMessageSimdMode) : numLanes(m_currShader->m_SIMDSize);
59805982
CVariable *newSource =
59815983
m_currShader->GetNewVariable(size, src->GetType(), EALIGN_GRF, m_destination->IsUniform(), src->getName());
5982-
m_encoder->SetUniformSIMDSize(uniformSIMDMode);
5984+
m_encoder->SetUniformSIMDSize(minSamplerMessageSimdMode);
59835985
m_encoder->Copy(newSource, src);
59845986
m_encoder->Push();
59855987
src = newSource;
@@ -5991,11 +5993,9 @@ void EmitPass::emitLdInstruction(llvm::Instruction *inst) {
59915993
// SIMD8 mode. Hence the movs to handle this layout in SIMD8 mode
59925994
bool needPacking = false;
59935995
CVariable *dst = m_destination;
5994-
SIMDMode simdSize = m_currShader->m_SIMDSize;
59955996
{
59965997
if (dst->IsUniform()) {
5997-
simdSize = m_currShader->m_Platform->getMinDispatchMode();
5998-
unsigned short numberOfElement = dst->GetNumberElement() * numLanes(simdSize);
5998+
unsigned short numberOfElement = dst->GetNumberElement() * numLanes(minSamplerMessageSimdMode);
59995999
numberOfElement = CEncoder::GetCISADataTypeSize(dst->GetType()) == 2 ? numberOfElement * 2 : numberOfElement;
60006000
dst = m_currShader->GetNewVariable(numberOfElement, dst->GetType(), EALIGN_GRF, dst->IsUniform(), dst->getName());
60016001
} else {
@@ -6021,7 +6021,7 @@ void EmitPass::emitLdInstruction(llvm::Instruction *inst) {
60216021

60226022
m_encoder->SetPredicate(flag);
60236023
if (m_destination->IsUniform()) {
6024-
m_encoder->SetUniformSIMDSize(m_currShader->m_Platform->getMinDispatchMode());
6024+
m_encoder->SetUniformSIMDSize(minSamplerMessageSimdMode);
60256025
}
60266026

60276027
SamplerLoadIntrinsic *samplerLoadIntrinsic = llvm::cast<llvm::SamplerLoadIntrinsic>(inst);
@@ -6049,12 +6049,19 @@ void EmitPass::emitLdInstruction(llvm::Instruction *inst) {
60496049
if (m_destination->IsUniform()) {
60506050
// if dst is uniform, we simply copy the first lane of each channel
60516051
// (including feedback enable if present) to the packed m_destination.
6052-
// Note that there's no need to handle feedback enable specially
60536052
for (unsigned int i = 0; i < m_destination->GetNumberElement(); i++) {
60546053
m_encoder->SetSrcRegion(0, 0, 1, 0);
60556054
m_encoder->SetSrcSubVar(0, i);
60566055
m_encoder->SetDstSubReg(i);
6057-
m_encoder->Copy(m_destination, dst);
6056+
// Feedback mask is a 32-bit value with `1` for unused SIMD channels.
6057+
if (feedbackEnable && i == (m_destination->GetNumberElement() - 1)) {
6058+
m_encoder->And(
6059+
m_currShader->GetNewAlias(m_destination, GetUnsignedIntegerType(m_destination->GetType()), 0, 0),
6060+
m_currShader->GetNewAlias(dst, GetUnsignedIntegerType(dst->GetType()), 0, 0),
6061+
m_currShader->ImmToVariable(0x1, ISA_TYPE_UW));
6062+
} else {
6063+
m_encoder->Copy(m_destination, dst);
6064+
}
60586065
m_encoder->Push();
60596066
}
60606067
} else {
@@ -15293,9 +15300,9 @@ void EmitPass::emitScalarAtomics(llvm::Instruction *pInst, ResourceDescriptor &r
1529315300
// srcmod on mov
1529415301
if (negateSrc) {
1529515302
m_encoder->SetSrcModifier(0, EMOD_NEG);
15303+
m_encoder->Copy(pFinalAtomicSrcVal, pFinalAtomicSrcVal);
15304+
m_encoder->Push();
1529615305
}
15297-
m_encoder->Copy(pFinalAtomicSrcVal, pFinalAtomicSrcVal);
15298-
m_encoder->Push();
1529915306
}
1530015307
} else if ((op == EOPCODE_AND || op == EOPCODE_OR) && pSrc->IsUniform()) {
1530115308
pFinalAtomicSrcVal = ReAlignUniformVariable(pSrc, EALIGN_GRF);
@@ -25098,7 +25105,9 @@ void EmitPass::emitPostProcessRayQueryReturn(llvm::PostProcessRayQueryReturn *I)
2509825105

2509925106
const uint16_t numElems = (m_currShader->m_SIMDSize == SIMDMode::SIMD32) ? 32 : 16;
2510025107

25101-
rayQueryReturnValue = m_currShader->GetNewAlias(rayQueryReturnValue, VISA_Type::ISA_TYPE_UW, 0, numElems);
25108+
if (!rayQueryReturnValue->IsImmediate()) {
25109+
rayQueryReturnValue = m_currShader->GetNewAlias(rayQueryReturnValue, VISA_Type::ISA_TYPE_UW, 0, numElems);
25110+
}
2510225111

2510325112
m_encoder->Cast(m_destination, rayQueryReturnValue);
2510425113
m_encoder->Push();

0 commit comments

Comments
 (0)