Skip to content

Commit

Permalink
Fix primitiveID
Browse files Browse the repository at this point in the history
Currently we are using vertex0 as provoking vertex to distribute primitive ID,
but when provoking vertex is last, we should use vertex2, at that time,
we will get dirty data, so we need to write correct value for each vertex, this
behavior is consistent with HW.
  • Loading branch information
AMD-dwang authored and amdrexu committed Jan 25, 2022
1 parent 7a81174 commit a8661e1
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion lgc/patch/NggPrimShader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -668,6 +668,10 @@ void NggPrimShader::constructPrimShaderWithoutGs(Module *module) {
// Distribute primitive ID
auto vertexId0 = CreateUBfe(m_nggFactor.primData, 0, 9);
writePerThreadDataToLds(gsPrimitiveId, vertexId0, LdsRegionDistribPrimId);
auto vertexId1 = CreateUBfe(m_nggFactor.primData, 10, 9);
writePerThreadDataToLds(gsPrimitiveId, vertexId1, LdsRegionDistribPrimId);
auto vertexId2 = CreateUBfe(m_nggFactor.primData, 20, 9);
writePerThreadDataToLds(gsPrimitiveId, vertexId2, LdsRegionDistribPrimId);

BranchInst::Create(endWritePrimIdBlock, writePrimIdBlock);
}
Expand Down Expand Up @@ -969,9 +973,12 @@ void NggPrimShader::constructPrimShaderWithoutGs(Module *module) {
// ES_GS_OFFSET01[31:16] = vertexId1 (in dwords)
// ES_GS_OFFSET01[15:0] = vertexId0 (in dwords)

// Use vertex0 as provoking vertex to distribute primitive ID
auto vertexId0 = m_nggFactor.esGsOffset0;
writePerThreadDataToLds(gsPrimitiveId, vertexId0, LdsRegionDistribPrimId);
auto vertexId1 = m_nggFactor.esGsOffset1;
writePerThreadDataToLds(gsPrimitiveId, vertexId1, LdsRegionDistribPrimId);
auto vertexId2 = m_nggFactor.esGsOffset2;
writePerThreadDataToLds(gsPrimitiveId, vertexId2, LdsRegionDistribPrimId);

m_builder->CreateBr(endWritePrimIdBlock);
}
Expand Down

0 comments on commit a8661e1

Please sign in to comment.