Pass subgroup size separately from workgroup size when beginning debug

* For compute shaders these can be different, in vertex/pixel these are at most
  identical
This commit is contained in:
baldurk
2025-02-10 17:52:30 +00:00
parent c3abc4504c
commit 876b0f8ff7
3 changed files with 22 additions and 16 deletions
+5 -1
View File
@@ -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<SpecConstant> &specInfo,
const std::map<size_t, uint32_t> &instructionLines,
const SPIRVPatchData &patchData, uint32_t activeIndex,
uint32_t workgroupSize);
uint32_t threadsInWorkgroup, uint32_t threadsInSubgroup);
rdcarray<ShaderDebugState> ContinueDebug();
@@ -416,6 +418,7 @@ public:
const rdcarray<Id> &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;
@@ -839,7 +839,7 @@ ShaderDebugTrace *Debugger::BeginDebug(DebugAPIWrapper *api, const ShaderStage s
const rdcarray<SpecConstant> &specInfo,
const std::map<size_t, uint32_t> &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<uint32_t> 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;
+9 -9
View File
@@ -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;