Skip to content

Commit 5be762a

Browse files
committed
Add DXIL Debugger Support for Wave Broadcast Operations
HLSL WaveReadLaneFirst() WaveReadLaneAt() DXIL DXOp::WaveReadLaneAt DXOp::WaveReadLaneFirst
1 parent 214d3f7 commit 5be762a

File tree

2 files changed

+44
-7
lines changed

2 files changed

+44
-7
lines changed

renderdoc/driver/shaders/dxil/dxil_debug.cpp

Lines changed: 39 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3682,6 +3682,45 @@ bool ThreadState::ExecuteInstruction(DebugAPIWrapper *apiWrapper,
36823682
result.value.u32v[0] = (m_WorkgroupIndex == activeLanes[0]) ? 1 : 0;
36833683
break;
36843684
}
3685+
case DXOp::WaveReadLaneAt:
3686+
{
3687+
// WaveReadLaneAt(value,lane)
3688+
ShaderVariable arg;
3689+
RDCASSERT(GetShaderVariable(inst.args[2], opCode, dxOpCode, arg));
3690+
const uint32_t firstLaneInSub = m_WorkgroupIndex - m_SubgroupIdx;
3691+
uint32_t lane = firstLaneInSub + arg.value.u32v[0];
3692+
3693+
if(lane < workgroup.size())
3694+
{
3695+
ShaderVariable var;
3696+
RDCASSERT(workgroup[lane].GetShaderVariable(inst.args[1], opCode, dxOpCode, var));
3697+
result.value = var.value;
3698+
}
3699+
else
3700+
{
3701+
RDCERR("Invalid workgroup lane %u", lane);
3702+
}
3703+
break;
3704+
}
3705+
case DXOp::WaveReadLaneFirst:
3706+
{
3707+
// WaveReadLaneFirst(value)
3708+
// determine active lane indices in our subgroup
3709+
rdcarray<uint32_t> activeLanes;
3710+
GetSubgroupActiveLanes(activeMask, workgroup, activeLanes);
3711+
uint32_t lane = activeLanes[0];
3712+
if(lane < workgroup.size())
3713+
{
3714+
ShaderVariable var;
3715+
RDCASSERT(workgroup[lane].GetShaderVariable(inst.args[1], opCode, dxOpCode, var));
3716+
result.value = var.value;
3717+
}
3718+
else
3719+
{
3720+
RDCERR("Invalid workgroup lane %u", lane);
3721+
}
3722+
break;
3723+
}
36853724
case DXOp::WaveAnyTrue:
36863725
case DXOp::WaveAllTrue:
36873726
case DXOp::WaveActiveBallot:
@@ -4092,8 +4131,6 @@ bool ThreadState::ExecuteInstruction(DebugAPIWrapper *apiWrapper,
40924131

40934132
// Wave Operations
40944133
case DXOp::WaveActiveAllEqual:
4095-
case DXOp::WaveReadLaneAt:
4096-
case DXOp::WaveReadLaneFirst:
40974134
case DXOp::WaveActiveBit:
40984135
case DXOp::WavePrefixOp:
40994136
case DXOp::WaveAllBitCount:

renderdoc/driver/shaders/dxil/dxil_reflect.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1870,13 +1870,15 @@ rdcstr Program::GetDebugStatus()
18701870
"Only supported when debugging pixel shaders dx.op call `%s` %s",
18711871
callFunc->name.c_str(), ToStr(dxOpCode).c_str());
18721872
continue;
1873-
case DXOp::WaveGetLaneCount:
1874-
case DXOp::WaveGetLaneIndex:
18751873
case DXOp::WaveIsFirstLane:
1876-
case DXOp::WaveActiveOp:
1874+
case DXOp::WaveGetLaneIndex:
1875+
case DXOp::WaveGetLaneCount:
18771876
case DXOp::WaveAnyTrue:
18781877
case DXOp::WaveAllTrue:
18791878
case DXOp::WaveActiveBallot:
1879+
case DXOp::WaveReadLaneAt:
1880+
case DXOp::WaveReadLaneFirst:
1881+
case DXOp::WaveActiveOp:
18801882
if(!D3D_Hack_EnableGroups())
18811883
return StringFormat::Fmt("Unsupported dx.op call `%s` %s", callFunc->name.c_str(),
18821884
ToStr(dxOpCode).c_str());
@@ -1902,8 +1904,6 @@ rdcstr Program::GetDebugStatus()
19021904
case DXOp::OutputControlPointID:
19031905
case DXOp::CycleCounterLegacy:
19041906
case DXOp::WaveActiveAllEqual:
1905-
case DXOp::WaveReadLaneAt:
1906-
case DXOp::WaveReadLaneFirst:
19071907
case DXOp::WaveActiveBit:
19081908
case DXOp::WavePrefixOp:
19091909
case DXOp::WaveAllBitCount:

0 commit comments

Comments
 (0)