Skip to content

Commit fccf3c0

Browse files
committed
DXIL Shader Debugger fixes for GPU batching of SampleGather operations
1 parent 80307c9 commit fccf3c0

File tree

4 files changed

+110
-82
lines changed

4 files changed

+110
-82
lines changed

renderdoc/driver/d3d12/d3d12_debug.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -605,7 +605,7 @@ bool D3D12DebugManager::CreateShaderDebugResources()
605605
{
606606
// MathOp is 2, SampleGatherOp is 6
607607
const uint64_t resultMaxElementSize = sizeof(Vec4f) * (2 + 6);
608-
const uint32_t maxQueuedResults = D3D12DebugManager::MAX_SHADER_DEBUG_QUEUED_OPS;
608+
const uint32_t maxQueuedResults = ShaderDebugConstants::MAX_SHADER_DEBUG_QUEUED_OPS;
609609
const uint64_t shaderDebugReadbackSize = resultMaxElementSize * maxQueuedResults;
610610
RDCCOMPILE_ASSERT(shaderDebugReadbackSize < m_ReadbackSize, "Readback buffer is not big enough");
611611

renderdoc/driver/d3d12/d3d12_debug.h

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,13 @@ class DXBCContainer;
4242

4343
#define D3D12_MSAA_SAMPLECOUNT 4
4444

45+
enum ShaderDebugConstants
46+
{
47+
MAX_SHADER_DEBUG_QUEUED_OPS = 128,
48+
COUNT_SRVS_PER_DEBUG = 25,
49+
COUNT_SAMPLERS_PER_DEBUG = 2,
50+
};
51+
4552
// baked indices in descriptor heaps
4653
enum CBVUAVSRVSlot
4754
{
@@ -81,7 +88,8 @@ enum CBVUAVSRVSlot
8188
STENCIL_MSAA_SRV32x,
8289

8390
FIRST_SHADDEBUG_SRV,
84-
LAST_SHADDEBUG_SRV = FIRST_SHADDEBUG_SRV + 25,
91+
LAST_SHADDEBUG_SRV = FIRST_SHADDEBUG_SRV + ShaderDebugConstants::COUNT_SRVS_PER_DEBUG *
92+
ShaderDebugConstants::MAX_SHADER_DEBUG_QUEUED_OPS,
8593

8694
FIRST_PIXELHISTORY_SRV,
8795
LAST_PIXELHISTORY_SRV = FIRST_PIXELHISTORY_SRV + 10,
@@ -116,7 +124,8 @@ enum SamplerSlot
116124
FIRST_SAMP = POINT_SAMP,
117125
LINEAR_SAMP,
118126
SHADDEBUG_SAMPLER0,
119-
SHADDEBUG_SAMPLER1,
127+
LAST_SHADDEBUG_SAMPLER = SHADDEBUG_SAMPLER0 + ShaderDebugConstants::COUNT_SAMPLERS_PER_DEBUG *
128+
ShaderDebugConstants::MAX_SHADER_DEBUG_QUEUED_OPS,
120129
};
121130

122131
enum DSVSlot
@@ -152,11 +161,6 @@ class D3D12DebugManager
152161
D3D12DebugManager(WrappedID3D12Device *wrapper);
153162
~D3D12DebugManager();
154163

155-
enum
156-
{
157-
MAX_SHADER_DEBUG_QUEUED_OPS = 128
158-
};
159-
160164
void GetBufferData(ID3D12Resource *buff, uint64_t offset, uint64_t length, bytebuf &retData);
161165

162166
ID3D12Resource *MakeCBuffer(UINT64 size);

renderdoc/driver/d3d12/d3d12_dxil_debug.cpp

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -575,8 +575,8 @@ D3D12APIWrapper::D3D12APIWrapper(WrappedID3D12Device *device, const DXIL::Progra
575575
m_QueuedMathOpIndex(0),
576576
m_QueuedSampleGatherOpIndex(0),
577577
m_MathOpResultOffset(0),
578-
m_MaxQueuedOps(D3D12DebugManager::MAX_SHADER_DEBUG_QUEUED_OPS),
579-
m_SampleGatherOpResultsStart(D3D12DebugManager::MAX_SHADER_DEBUG_QUEUED_OPS *
578+
m_MaxQueuedOps(ShaderDebugConstants::MAX_SHADER_DEBUG_QUEUED_OPS),
579+
m_SampleGatherOpResultsStart(ShaderDebugConstants::MAX_SHADER_DEBUG_QUEUED_OPS *
580580
m_MathOpResultByteSize)
581581
{
582582
// Create the storage layout for the constant buffers
@@ -1626,8 +1626,13 @@ bool D3D12APIWrapper::QueueMathIntrinsic(DXIL::DXOp dxOp, const ShaderVariable &
16261626
return false;
16271627
}
16281628

1629-
return D3D12ShaderDebug::QueueMathIntrinsic(false, m_Device, cmdList, mathOp, input,
1630-
m_QueuedMathOpIndex++);
1629+
if(D3D12ShaderDebug::QueueMathIntrinsic(false, m_Device, cmdList, mathOp, input,
1630+
m_QueuedMathOpIndex))
1631+
{
1632+
m_QueuedMathOpIndex++;
1633+
return true;
1634+
}
1635+
return false;
16311636
}
16321637

16331638
// Must be called from the replay manager thread (the debugger thread)
@@ -1682,10 +1687,15 @@ bool D3D12APIWrapper::QueueSampleGather(DXIL::DXOp dxOp, SampleGatherResourceDat
16821687

16831688
const char *opString = ToStr(dxOp).c_str();
16841689
uint8_t swizzle[4] = {0, 1, 2, 3};
1685-
return D3D12ShaderDebug::QueueSampleGather(
1686-
true, m_Device, m_QueuedOpCmdList, sampleOp, resourceData, samplerData, uv, ddxCalc, ddyCalc,
1687-
texelOffsets, multisampleIndex, lodValue, compareValue, swizzle, gatherChannel, m_ShaderType,
1688-
instructionIdx, opString, m_QueuedSampleGatherOpIndex++, sampleRetType);
1690+
if(D3D12ShaderDebug::QueueSampleGather(
1691+
true, m_Device, m_QueuedOpCmdList, sampleOp, resourceData, samplerData, uv, ddxCalc,
1692+
ddyCalc, texelOffsets, multisampleIndex, lodValue, compareValue, swizzle, gatherChannel,
1693+
m_ShaderType, instructionIdx, opString, m_QueuedSampleGatherOpIndex, sampleRetType))
1694+
{
1695+
m_QueuedSampleGatherOpIndex++;
1696+
return true;
1697+
}
1698+
return false;
16891699
}
16901700

16911701
// Must be called from the replay manager thread (the debugger thread)

0 commit comments

Comments
 (0)