diff --git a/renderdoc/driver/shaders/spirv/spirv_debug.h b/renderdoc/driver/shaders/spirv/spirv_debug.h index 2cd114603..5876b50d6 100644 --- a/renderdoc/driver/shaders/spirv/spirv_debug.h +++ b/renderdoc/driver/shaders/spirv/spirv_debug.h @@ -240,6 +240,8 @@ struct ThreadState uint32_t quadNeighbours[4] = {~0U, ~0U, ~0U, ~0U}; // index in the workgroup uint32_t workgroupIndex = 0; + // index in the subgroup + uint32_t subgroupId = 0; bool helperInvocation = false; bool dead = true; bool elected = false; @@ -377,7 +379,7 @@ public: const rdcstr &entryPoint, const rdcarray &specInfo, const std::map &instructionLines, const SPIRVPatchData &patchData, uint32_t activeIndex, - uint32_t workgroupSize); + uint32_t threadsInWorkgroup, uint32_t threadsInSubgroup); rdcarray ContinueDebug(); @@ -416,6 +418,7 @@ public: const rdcarray &GetLiveGlobals() { return liveGlobals; } ThreadState &GetActiveLane() { return workgroup[activeLaneIndex]; } const ThreadState &GetActiveLane() const { return workgroup[activeLaneIndex]; } + uint32_t GetSubgroupSize() const { return subgroupSize; } private: virtual void PreParse(uint32_t maxId); virtual void PostParse(); @@ -447,6 +450,7 @@ private: Id convergeBlock; uint32_t activeLaneIndex = 0; + uint32_t subgroupSize = 0; ShaderStage stage; int steps = 0; diff --git a/renderdoc/driver/shaders/spirv/spirv_debug_setup.cpp b/renderdoc/driver/shaders/spirv/spirv_debug_setup.cpp index f7d9fe372..ddd74b265 100644 --- a/renderdoc/driver/shaders/spirv/spirv_debug_setup.cpp +++ b/renderdoc/driver/shaders/spirv/spirv_debug_setup.cpp @@ -839,7 +839,7 @@ ShaderDebugTrace *Debugger::BeginDebug(DebugAPIWrapper *api, const ShaderStage s const rdcarray &specInfo, const std::map &instructionLines, const SPIRVPatchData &patchData, uint32_t activeIndex, - uint32_t workgroupSize) + uint32_t threadsInWorkgroup, uint32_t threadsInSubgroup) { Id entryId = entryLookup[ShaderEntryPoint(entryPoint, shaderStage)]; @@ -893,10 +893,11 @@ ShaderDebugTrace *Debugger::BeginDebug(DebugAPIWrapper *api, const ShaderStage s ret->debugger = this; ret->stage = shaderStage; activeLaneIndex = activeIndex; + subgroupSize = threadsInSubgroup; stage = shaderStage; apiWrapper = api; - for(uint32_t i = 0; i < workgroupSize; i++) + for(uint32_t i = 0; i < threadsInWorkgroup; i++) workgroup.push_back(ThreadState(*this, global)); ThreadState &active = GetActiveLane(); @@ -1069,7 +1070,7 @@ ShaderDebugTrace *Debugger::BeginDebug(DebugAPIWrapper *api, const ShaderStage s if(isInput) { - for(laneIndex = 0; laneIndex < workgroupSize; laneIndex++) + for(laneIndex = 0; laneIndex < threadsInWorkgroup; laneIndex++) { // create the opaque storage workgroup[laneIndex].inputs.push_back(var); @@ -1486,7 +1487,7 @@ ShaderDebugTrace *Debugger::BeginDebug(DebugAPIWrapper *api, const ShaderStage s std::sort(liveGlobals.begin(), liveGlobals.end()); - for(uint32_t i = 0; i < workgroupSize; i++) + for(uint32_t i = 0; i < threadsInWorkgroup; i++) { ThreadState &lane = workgroup[i]; lane.workgroupIndex = i; @@ -1505,6 +1506,7 @@ ShaderDebugTrace *Debugger::BeginDebug(DebugAPIWrapper *api, const ShaderStage s lane.quadId = apiWrapper->GetThreadProperty(i, ThreadProperty::QuadId); } + lane.subgroupId = apiWrapper->GetThreadProperty(i, ThreadProperty::SubgroupId); lane.dead = apiWrapper->GetThreadProperty(i, ThreadProperty::Active) == 0; if(patchData.threadScope & ThreadScope::Subgroup) @@ -1518,7 +1520,7 @@ ShaderDebugTrace *Debugger::BeginDebug(DebugAPIWrapper *api, const ShaderStage s // find quad neighbours { rdcarray processedQuads; - for(uint32_t i = 0; i < workgroupSize; i++) + for(uint32_t i = 0; i < threadsInWorkgroup; i++) { uint32_t desiredQuad = workgroup[i].quadId; @@ -1540,7 +1542,7 @@ ShaderDebugTrace *Debugger::BeginDebug(DebugAPIWrapper *api, const ShaderStage s ~0U, ~0U, }; - for(uint32_t j = i + 1, t = 1; j < workgroupSize && t < 4; j++) + for(uint32_t j = i + 1, t = 1; j < threadsInWorkgroup && t < 4; j++) { if(workgroup[j].quadId == desiredQuad) threads[t++] = j; diff --git a/renderdoc/driver/vulkan/vk_shaderdebug.cpp b/renderdoc/driver/vulkan/vk_shaderdebug.cpp index 51ee5d7bd..e4a69a5cc 100644 --- a/renderdoc/driver/vulkan/vk_shaderdebug.cpp +++ b/renderdoc/driver/vulkan/vk_shaderdebug.cpp @@ -5125,7 +5125,7 @@ ShaderDebugTrace *VulkanReplay::DebugVertex(uint32_t eventId, uint32_t vertid, u ShaderDebugTrace *ret = debugger->BeginDebug(apiWrapper, ShaderStage::Vertex, entryPoint, spec, shadRefl.instructionLines, shadRefl.patchData, - winner->laneIndex, numThreads); + winner->laneIndex, numThreads, numThreads); apiWrapper->ResetReplay(); return ret; @@ -5298,9 +5298,9 @@ ShaderDebugTrace *VulkanReplay::DebugVertex(uint32_t eventId, uint32_t vertid, u rdcspv::Debugger *debugger = new rdcspv::Debugger; debugger->Parse(shader.spirv.GetSPIRV()); - ShaderDebugTrace *ret = - debugger->BeginDebug(apiWrapper, ShaderStage::Vertex, entryPoint, spec, - shadRefl.instructionLines, shadRefl.patchData, laneIndex, numThreads); + ShaderDebugTrace *ret = debugger->BeginDebug(apiWrapper, ShaderStage::Vertex, entryPoint, spec, + shadRefl.instructionLines, shadRefl.patchData, + laneIndex, numThreads, numThreads); apiWrapper->ResetReplay(); return ret; @@ -5797,7 +5797,7 @@ ShaderDebugTrace *VulkanReplay::DebugPixel(uint32_t eventId, uint32_t x, uint32_ ret = debugger->BeginDebug(apiWrapper, ShaderStage::Pixel, entryPoint, spec, shadRefl.instructionLines, shadRefl.patchData, winner->laneIndex, - numThreads); + numThreads, numThreads); apiWrapper->ResetReplay(); } else @@ -6189,9 +6189,9 @@ ShaderDebugTrace *VulkanReplay::DebugComputeCommon(ShaderStage stage, uint32_t e } } - ShaderDebugTrace *ret = - debugger->BeginDebug(apiWrapper, stage, entryPoint, spec, shadRefl.instructionLines, - shadRefl.patchData, winner->laneIndex, numThreads); + ShaderDebugTrace *ret = debugger->BeginDebug( + apiWrapper, stage, entryPoint, spec, shadRefl.instructionLines, shadRefl.patchData, + winner->laneIndex, numThreads, winner->subgroupSize); apiWrapper->ResetReplay(); return ret; @@ -6246,7 +6246,7 @@ ShaderDebugTrace *VulkanReplay::DebugComputeCommon(ShaderStage stage, uint32_t e debugger->Parse(shader.spirv.GetSPIRV()); ShaderDebugTrace *ret = debugger->BeginDebug(apiWrapper, stage, entryPoint, spec, shadRefl.instructionLines, - shadRefl.patchData, laneIndex, numThreads); + shadRefl.patchData, laneIndex, numThreads, 1); apiWrapper->ResetReplay(); return ret;