From a5b63f2f268b74af2d979c127c325dd88828cf91 Mon Sep 17 00:00:00 2001 From: Jake Turner Date: Thu, 24 Oct 2024 12:21:19 +0100 Subject: [PATCH] Shader Debug HLSL split debugSampleLodCompare into two variables --- renderdoc/data/hlsl/hlsl_cbuffers.h | 3 ++- renderdoc/data/hlsl/shaderdebug.hlsl | 8 ++++---- renderdoc/driver/d3d11/d3d11_shaderdebug.cpp | 3 ++- renderdoc/driver/d3d12/d3d12_dxil_debug.cpp | 4 ++-- renderdoc/driver/d3d12/d3d12_dxil_debug.h | 4 ++-- renderdoc/driver/d3d12/d3d12_shaderdebug.cpp | 9 +++++---- renderdoc/driver/d3d12/d3d12_shaderdebug.h | 9 +++++---- renderdoc/driver/shaders/dxil/dxil_debug.cpp | 11 +++++++---- renderdoc/driver/shaders/dxil/dxil_debug.h | 2 +- 9 files changed, 30 insertions(+), 23 deletions(-) diff --git a/renderdoc/data/hlsl/hlsl_cbuffers.h b/renderdoc/data/hlsl/hlsl_cbuffers.h index 21a3d71ad..7ee878676 100644 --- a/renderdoc/data/hlsl/hlsl_cbuffers.h +++ b/renderdoc/data/hlsl/hlsl_cbuffers.h @@ -381,7 +381,8 @@ cbuffer DebugSampleOperation REG(b0) int debugSampleGatherChannel; int debugSampleSampleIndex; int debugSampleOperation; - float debugSampleLodCompare; + float debugSampleLod; + float debugSampleCompare; }; #define DEBUG_SAMPLE_MATH_DXBC_RCP 1000 diff --git a/renderdoc/data/hlsl/shaderdebug.hlsl b/renderdoc/data/hlsl/shaderdebug.hlsl index 861cdcac7..782184fc3 100644 --- a/renderdoc/data/hlsl/shaderdebug.hlsl +++ b/renderdoc/data/hlsl/shaderdebug.hlsl @@ -130,8 +130,8 @@ float4 DoFloatOpcode(float4 uv) float4 ddx_ = debugSampleDDX; float4 ddy_ = debugSampleDDY; int4 offsets = debugSampleOffsets; - float lod = debugSampleLodCompare; - float compare = debugSampleLodCompare; + float lod = debugSampleLod; + float compare = debugSampleCompare; if(opcode == DEBUG_SAMPLE_TEX_SAMPLE || opcode == DEBUG_SAMPLE_TEX_SAMPLE_BIAS || opcode == DEBUG_SAMPLE_TEX_SAMPLE_GRAD) @@ -673,7 +673,7 @@ int4 DoIntOpcode(float4 uv) float4 ddx_ = debugSampleDDX; float4 ddy_ = debugSampleDDY; int4 offsets = debugSampleOffsets; - float lod = debugSampleLodCompare; + float lod = debugSampleLod; if(opcode == DEBUG_SAMPLE_TEX_LOAD || opcode == DEBUG_SAMPLE_TEX_LOAD_MS) { @@ -738,7 +738,7 @@ uint4 DoUIntOpcode(float4 uv) float4 ddx_ = debugSampleDDX; float4 ddy_ = debugSampleDDY; int4 offsets = debugSampleOffsets; - float lod = debugSampleLodCompare; + float lod = debugSampleLod; if(opcode == DEBUG_SAMPLE_TEX_LOAD || opcode == DEBUG_SAMPLE_TEX_LOAD_MS) { diff --git a/renderdoc/driver/d3d11/d3d11_shaderdebug.cpp b/renderdoc/driver/d3d11/d3d11_shaderdebug.cpp index bec8743d0..cefeb37bf 100644 --- a/renderdoc/driver/d3d11/d3d11_shaderdebug.cpp +++ b/renderdoc/driver/d3d11/d3d11_shaderdebug.cpp @@ -1175,7 +1175,8 @@ bool D3D11DebugAPIWrapper::CalculateSampleGather( cbufferData.debugSampleGatherChannel = (int)gatherChannel; cbufferData.debugSampleSampleIndex = multisampleIndex; cbufferData.debugSampleOperation = sampleOp; - cbufferData.debugSampleLodCompare = lodOrCompareValue; + cbufferData.debugSampleLod = lodOrCompareValue; + cbufferData.debugSampleCompare = lodOrCompareValue; D3D11RenderStateTracker tracker(m_pDevice->GetImmediateContext()); diff --git a/renderdoc/driver/d3d12/d3d12_dxil_debug.cpp b/renderdoc/driver/d3d12/d3d12_dxil_debug.cpp index 0dab3bddc..1e1af4ac2 100644 --- a/renderdoc/driver/d3d12/d3d12_dxil_debug.cpp +++ b/renderdoc/driver/d3d12/d3d12_dxil_debug.cpp @@ -1110,7 +1110,7 @@ bool D3D12APIWrapper::CalculateMathIntrinsic(DXIL::DXOp dxOp, const ShaderVariab bool D3D12APIWrapper::CalculateSampleGather( DXIL::DXOp dxOp, SampleGatherResourceData resourceData, SampleGatherSamplerData samplerData, const ShaderVariable &uv, const ShaderVariable &ddxCalc, const ShaderVariable &ddyCalc, - const int8_t texelOffsets[3], int multisampleIndex, float lodOrCompareValue, + const int8_t texelOffsets[3], int multisampleIndex, float lodValue, float compareValue, const uint8_t swizzle[4], GatherChannel gatherChannel, DXBC::ShaderType shaderType, uint32_t instructionIdx, const char *opString, ShaderVariable &output) { @@ -1144,7 +1144,7 @@ bool D3D12APIWrapper::CalculateSampleGather( return D3D12ShaderDebug::CalculateSampleGather( true, m_Device, sampleOp, resourceData, samplerData, uv, ddxCalc, ddyCalc, texelOffsets, - multisampleIndex, lodOrCompareValue, swizzle, gatherChannel, shaderType, instructionIdx, + multisampleIndex, lodValue, compareValue, swizzle, gatherChannel, shaderType, instructionIdx, opString, output); } diff --git a/renderdoc/driver/d3d12/d3d12_dxil_debug.h b/renderdoc/driver/d3d12/d3d12_dxil_debug.h index 16945c91a..407362f19 100644 --- a/renderdoc/driver/d3d12/d3d12_dxil_debug.h +++ b/renderdoc/driver/d3d12/d3d12_dxil_debug.h @@ -51,8 +51,8 @@ public: bool CalculateSampleGather(DXIL::DXOp dxOp, SampleGatherResourceData resourceData, SampleGatherSamplerData samplerData, const ShaderVariable &uv, const ShaderVariable &ddxCalc, const ShaderVariable &ddyCalc, - const int8_t texelOffsets[3], int multisampleIndex, - float lodOrCompareValue, const uint8_t swizzle[4], + const int8_t texelOffsets[3], int multisampleIndex, float lodValue, + float compareValue, const uint8_t swizzle[4], GatherChannel gatherChannel, DXBC::ShaderType shaderType, uint32_t instructionIdx, const char *opString, ShaderVariable &output); ShaderVariable GetResourceInfo(DXIL::ResourceClass resClass, const DXDebug::BindingSlot &slot, diff --git a/renderdoc/driver/d3d12/d3d12_shaderdebug.cpp b/renderdoc/driver/d3d12/d3d12_shaderdebug.cpp index 8babb651d..65068f28b 100644 --- a/renderdoc/driver/d3d12/d3d12_shaderdebug.cpp +++ b/renderdoc/driver/d3d12/d3d12_shaderdebug.cpp @@ -165,7 +165,7 @@ bool D3D12ShaderDebug::CalculateSampleGather( bool dxil, WrappedID3D12Device *device, int sampleOp, SampleGatherResourceData resourceData, SampleGatherSamplerData samplerData, const ShaderVariable &uvIn, const ShaderVariable &ddxCalcIn, const ShaderVariable &ddyCalcIn, const int8_t texelOffsets[3], - int multisampleIndex, float lodOrCompareValue, const uint8_t swizzle[4], + int multisampleIndex, float lodValue, float compareValue, const uint8_t swizzle[4], GatherChannel gatherChannel, const DXBC::ShaderType shaderType, uint32_t instruction, const char *opString, ShaderVariable &output) { @@ -280,7 +280,8 @@ bool D3D12ShaderDebug::CalculateSampleGather( cbufferData.debugSampleGatherChannel = (int)gatherChannel; cbufferData.debugSampleSampleIndex = multisampleIndex; cbufferData.debugSampleOperation = sampleOp; - cbufferData.debugSampleLodCompare = lodOrCompareValue; + cbufferData.debugSampleLod = lodValue; + cbufferData.debugSampleCompare = compareValue; D3D12RenderState &rs = device->GetQueue()->GetCommandData()->m_RenderState; D3D12RenderState prevState = rs; @@ -1459,8 +1460,8 @@ bool D3D12DebugAPIWrapper::CalculateSampleGather( return D3D12ShaderDebug::CalculateSampleGather( false, m_pDevice, sampleOp, resourceData, samplerData, uv, ddxCalc, ddyCalc, texelOffsets, - multisampleIndex, lodOrCompareValue, swizzle, gatherChannel, GetShaderType(), m_instruction, - opString, output); + multisampleIndex, lodOrCompareValue, lodOrCompareValue, swizzle, gatherChannel, + GetShaderType(), m_instruction, opString, output); } void GatherConstantBuffers(WrappedID3D12Device *pDevice, const DXBCBytecode::Program &program, diff --git a/renderdoc/driver/d3d12/d3d12_shaderdebug.h b/renderdoc/driver/d3d12/d3d12_shaderdebug.h index 4291acefc..d810ae5dd 100644 --- a/renderdoc/driver/d3d12/d3d12_shaderdebug.h +++ b/renderdoc/driver/d3d12/d3d12_shaderdebug.h @@ -44,10 +44,11 @@ bool CalculateMathIntrinsic(bool dxil, WrappedID3D12Device *device, int mathOp, ShaderVariable &output2); bool CalculateSampleGather(bool dxil, WrappedID3D12Device *device, int sampleOp, - SampleGatherResourceData resourceData, SampleGatherSamplerData samplerData, - const ShaderVariable &uv, const ShaderVariable &ddxCalc, - const ShaderVariable &ddyCalc, const int8_t texelOffsets[3], - int multisampleIndex, float lodOrCompareValue, const uint8_t swizzle[4], + SampleGatherResourceData resourceData, + SampleGatherSamplerData samplerData, const ShaderVariable &uv, + const ShaderVariable &ddxCalc, const ShaderVariable &ddyCalc, + const int8_t texelOffsets[3], int multisampleIndex, float lodValue, + float compareValue, const uint8_t swizzle[4], GatherChannel gatherChannel, const DXBC::ShaderType shaderType, uint32_t instruction, const char *opString, ShaderVariable &output); diff --git a/renderdoc/driver/shaders/dxil/dxil_debug.cpp b/renderdoc/driver/shaders/dxil/dxil_debug.cpp index 820cc5268..c1ad0413b 100644 --- a/renderdoc/driver/shaders/dxil/dxil_debug.cpp +++ b/renderdoc/driver/shaders/dxil/dxil_debug.cpp @@ -3848,7 +3848,8 @@ void ThreadState::PerformGPUResourceOp(const rdcarray &workgroups, ShaderVariable uv; int8_t texelOffsets[3] = {0, 0, 0}; int msIndex = 0; - float lodOrCompareValue = 0.0f; + float lodValue = 0.0f; + float compareValue = 0.0f; SampleGatherSamplerData samplerData = {}; samplerData.mode = SamplerMode::NUM_SAMPLERS; @@ -3902,7 +3903,8 @@ void ThreadState::PerformGPUResourceOp(const rdcarray &workgroups, if(GetShaderVariable(inst.args[10], opCode, dxOpCode, arg)) { RDCASSERTEQUAL(arg.type, VarType::Float); - lodOrCompareValue = arg.value.f32v[0]; + lodValue = arg.value.f32v[0]; + compareValue = arg.value.f32v[0]; } } } @@ -3913,7 +3915,8 @@ void ThreadState::PerformGPUResourceOp(const rdcarray &workgroups, if(GetShaderVariable(inst.args[2], opCode, dxOpCode, arg)) { msIndex = arg.value.u32v[0]; - lodOrCompareValue = arg.value.f32v[0]; + lodValue = arg.value.f32v[0]; + compareValue = arg.value.f32v[0]; } // UV is int data in args 3,4,5 @@ -3975,7 +3978,7 @@ void ThreadState::PerformGPUResourceOp(const rdcarray &workgroups, ShaderVariable data; apiWrapper->CalculateSampleGather(dxOpCode, resourceData, samplerData, uv, ddx, ddy, texelOffsets, - msIndex, lodOrCompareValue, swizzle, gatherChannel, + msIndex, lodValue, compareValue, swizzle, gatherChannel, m_ShaderType, instructionIdx, opString, data); result.value = data.value; diff --git a/renderdoc/driver/shaders/dxil/dxil_debug.h b/renderdoc/driver/shaders/dxil/dxil_debug.h index d5aa87629..dccad71d5 100644 --- a/renderdoc/driver/shaders/dxil/dxil_debug.h +++ b/renderdoc/driver/shaders/dxil/dxil_debug.h @@ -113,7 +113,7 @@ public: SampleGatherSamplerData samplerData, const ShaderVariable &uv, const ShaderVariable &ddxCalc, const ShaderVariable &ddyCalc, const int8_t texelOffsets[3], int multisampleIndex, - float lodOrCompareValue, const uint8_t swizzle[4], + float lodValue, float compareValue, const uint8_t swizzle[4], GatherChannel gatherChannel, DXBC::ShaderType shaderType, uint32_t instructionIdx, const char *opString, ShaderVariable &output) = 0;