From 3373f4b50e09bdeb80d1814d5ea4e664591f833e Mon Sep 17 00:00:00 2001 From: Jake Turner Date: Wed, 26 Jun 2024 08:38:34 +0100 Subject: [PATCH] DXIL Reflection for compute shaders correctly detect threadIdInGroup Searches for "dx.op.threadId" was also incorrectly matching "dx.op.threadIdInGroup" --- .../driver/shaders/dxil/dxil_reflect.cpp | 21 ++++++++++--------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/renderdoc/driver/shaders/dxil/dxil_reflect.cpp b/renderdoc/driver/shaders/dxil/dxil_reflect.cpp index 267803aae..520432749 100644 --- a/renderdoc/driver/shaders/dxil/dxil_reflect.cpp +++ b/renderdoc/driver/shaders/dxil/dxil_reflect.cpp @@ -576,7 +576,17 @@ void Program::FetchComputeProperties(DXBC::Reflection *reflection) { const Function &f = *m_Functions[i]; - if(f.name.beginsWith("dx.op.threadId")) + // Match "dx.op.threadIdGroup" before "dx.op.threadId" + if(f.name.beginsWith("dx.op.threadIdInGroup")) + { + SigParameter param; + param.systemValue = ShaderBuiltin::GroupThreadIndex; + param.compCount = 3; + param.regChannelMask = param.channelUsedMask = 0x7; + param.semanticIdxName = param.semanticName = "threadIdInGroup"; + reflection->InputSig.push_back(param); + } + else if(f.name.beginsWith("dx.op.threadId")) { SigParameter param; param.systemValue = ShaderBuiltin::DispatchThreadIndex; @@ -594,15 +604,6 @@ void Program::FetchComputeProperties(DXBC::Reflection *reflection) param.semanticIdxName = param.semanticName = "groupID"; reflection->InputSig.push_back(param); } - else if(f.name.beginsWith("dx.op.threadIdInGroup")) - { - SigParameter param; - param.systemValue = ShaderBuiltin::GroupThreadIndex; - param.compCount = 3; - param.regChannelMask = param.channelUsedMask = 0x7; - param.semanticIdxName = param.semanticName = "threadIdInGroup"; - reflection->InputSig.push_back(param); - } else if(f.name.beginsWith("dx.op.flattenedThreadIdInGroup")) { SigParameter param;