From 59f30aa83996ee6985fbe96be3601e08f623d3a1 Mon Sep 17 00:00:00 2001 From: Rex Xu Date: Mon, 13 Nov 2023 15:43:58 +0800 Subject: [PATCH] Fix a latent issue of mesh query on Navi2x For such mesh shader: layout(local_size_x=1, local_size_y=1, local_size_z=128) in; layout(triangles, max_vertices=0, max_primitives=0) out; void main() { } It is valid when SetMeshOutputs is missing. We will do dummy export with vertexCount=0 and primitiveCount=0. But the dummy export doesn't write the data to mesh pipeline statistics buffer. The mesh query will fail. On Navi2x, mesh statistics still rely on SW compiler emulation and we must do it by calling collectMeshStatsInfo. --- lgc/patch/MeshTaskShader.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/lgc/patch/MeshTaskShader.cpp b/lgc/patch/MeshTaskShader.cpp index f6c6b24e8c..3a7219bf27 100644 --- a/lgc/patch/MeshTaskShader.cpp +++ b/lgc/patch/MeshTaskShader.cpp @@ -765,6 +765,11 @@ void MeshTaskShader::processMeshShader(Function *entryPoint) { m_builder.SetInsertPoint(dummyAllocReqBlock); m_builder.CreateIntrinsic(Intrinsic::amdgcn_s_sendmsg, {}, {m_builder.getInt32(GsAllocReq), m_builder.getInt32(0)}); + + // We still collect mesh shader statistics in this special case. This is a valid mesh shader usage when the + // primitive/vertex count is not specified by SetMeshOutputs (both are treated as zeros). + collectMeshStatsInfo(entryPoint, m_builder.getInt32(0)); + m_builder.CreateBr(endDummyAllocReqBlock); }