mirror of
https://github.com/baldurk/renderdoc.git
synced 2026-09-23 06:05:45 +00:00
D3D12 ShaderDebugging adding helper namespace D3D12ShaderDebug
Added bool D3D12ShaderDebug::CalculateMathIntrinsic(WrappedID3D12Device* device, MathOp mathOp, const ShaderVariable &input, ShaderVariable &output1, ShaderVariable &output2); which is used by DXBC and DXIL ShaderDebugger CalculateMathIntrinsic methods Extended shaderdebug.hlsl math intrinsics to support DXIL math opcodes Use custom math operation values for DXBC and DXIL, not the DXBC OpCode value. Use custom sampler operation values for DXBC and DXIL, not the DXBC OpCode value. This changes DXBCDebug::DebugAPIWrapper, updated D3D11DebugAPIWrapper to match changes to interface and shader math and sample operation values.
This commit is contained in:
@@ -375,25 +375,25 @@ cbuffer DebugSampleOperation REG(b0)
|
||||
float debugSampleLodCompare;
|
||||
};
|
||||
|
||||
#define DEBUG_SAMPLE_MATH_RCP 129
|
||||
#define DEBUG_SAMPLE_MATH_RSQ 68
|
||||
#define DEBUG_SAMPLE_MATH_EXP 25
|
||||
#define DEBUG_SAMPLE_MATH_LOG 47
|
||||
#define DEBUG_SAMPLE_MATH_SINCOS 77
|
||||
#define DEBUG_SAMPLE_MATH_DXBC_RCP 1000
|
||||
#define DEBUG_SAMPLE_MATH_DXBC_RSQ 1001
|
||||
#define DEBUG_SAMPLE_MATH_DXBC_EXP 1002
|
||||
#define DEBUG_SAMPLE_MATH_DXBC_LOG 1003
|
||||
#define DEBUG_SAMPLE_MATH_DXBC_SINCOS 1004
|
||||
|
||||
#define DEBUG_SAMPLE_TEX_SAMPLE 69
|
||||
#define DEBUG_SAMPLE_TEX_SAMPLE_L 72
|
||||
#define DEBUG_SAMPLE_TEX_SAMPLE_B 74
|
||||
#define DEBUG_SAMPLE_TEX_SAMPLE_D 73
|
||||
#define DEBUG_SAMPLE_TEX_SAMPLE_C 70
|
||||
#define DEBUG_SAMPLE_TEX_SAMPLE_C_LZ 71
|
||||
#define DEBUG_SAMPLE_TEX_GATHER4 109
|
||||
#define DEBUG_SAMPLE_TEX_GATHER4_C 126
|
||||
#define DEBUG_SAMPLE_TEX_GATHER4_PO 127
|
||||
#define DEBUG_SAMPLE_TEX_GATHER4_PO_C 128
|
||||
#define DEBUG_SAMPLE_TEX_LOD 108
|
||||
#define DEBUG_SAMPLE_TEX_LD 45
|
||||
#define DEBUG_SAMPLE_TEX_LD_MS 46
|
||||
#define DEBUG_SAMPLE_TEX_SAMPLE 100
|
||||
#define DEBUG_SAMPLE_TEX_SAMPLE_LEVEL 101
|
||||
#define DEBUG_SAMPLE_TEX_SAMPLE_BIAS 102
|
||||
#define DEBUG_SAMPLE_TEX_SAMPLE_GRAD 103
|
||||
#define DEBUG_SAMPLE_TEX_SAMPLE_CMP 104
|
||||
#define DEBUG_SAMPLE_TEX_SAMPLE_CMP_LEVEL_ZERO 105
|
||||
#define DEBUG_SAMPLE_TEX_GATHER4 106
|
||||
#define DEBUG_SAMPLE_TEX_GATHER4_CMP 107
|
||||
#define DEBUG_SAMPLE_TEX_GATHER4_PO 108
|
||||
#define DEBUG_SAMPLE_TEX_GATHER4_PO_CMP 109
|
||||
#define DEBUG_SAMPLE_TEX_LOD 110
|
||||
#define DEBUG_SAMPLE_TEX_LOAD 111
|
||||
#define DEBUG_SAMPLE_TEX_LOAD_MS 112
|
||||
|
||||
#define DEBUG_SAMPLE_TEX1D 1
|
||||
#define DEBUG_SAMPLE_TEX2D 2
|
||||
@@ -407,6 +407,20 @@ cbuffer DebugSampleOperation REG(b0)
|
||||
#define DEBUG_SAMPLE_UINT 4
|
||||
#define DEBUG_SAMPLE_FLOAT 5
|
||||
|
||||
#define DEBUG_SAMPLE_MATH_DXIL_COS 10000
|
||||
#define DEBUG_SAMPLE_MATH_DXIL_SIN 10001
|
||||
#define DEBUG_SAMPLE_MATH_DXIL_TAN 10002
|
||||
#define DEBUG_SAMPLE_MATH_DXIL_ACOS 10003
|
||||
#define DEBUG_SAMPLE_MATH_DXIL_ASIN 10004
|
||||
#define DEBUG_SAMPLE_MATH_DXIL_ATAN 10005
|
||||
#define DEBUG_SAMPLE_MATH_DXIL_HCOS 10006
|
||||
#define DEBUG_SAMPLE_MATH_DXIL_HSIN 10007
|
||||
#define DEBUG_SAMPLE_MATH_DXIL_HTAN 10008
|
||||
#define DEBUG_SAMPLE_MATH_DXIL_EXP 10009
|
||||
#define DEBUG_SAMPLE_MATH_DXIL_LOG 10010
|
||||
#define DEBUG_SAMPLE_MATH_DXIL_SQRT 10011
|
||||
#define DEBUG_SAMPLE_MATH_DXIL_RSQRT 10012
|
||||
|
||||
// some constants available to both C++ and HLSL for configuring display
|
||||
#define CUBEMAP_FACE_RIGHT 0
|
||||
#define CUBEMAP_FACE_LEFT 1
|
||||
|
||||
@@ -36,11 +36,26 @@ RWStructuredBuffer<OutStruct> outBuf : register(u1);
|
||||
[numthreads(1, 1, 1)] void RENDERDOC_DebugMathOp() {
|
||||
switch(mathOp)
|
||||
{
|
||||
case DEBUG_SAMPLE_MATH_RCP: outBuf[0].outf[0] = rcp(mathInVal); break;
|
||||
case DEBUG_SAMPLE_MATH_RSQ: outBuf[0].outf[0] = rsqrt(mathInVal); break;
|
||||
case DEBUG_SAMPLE_MATH_EXP: outBuf[0].outf[0] = exp2(mathInVal); break;
|
||||
case DEBUG_SAMPLE_MATH_LOG: outBuf[0].outf[0] = log2(mathInVal); break;
|
||||
case DEBUG_SAMPLE_MATH_SINCOS: sincos(mathInVal, outBuf[0].outf[0], outBuf[0].outf[1]); break;
|
||||
case DEBUG_SAMPLE_MATH_DXBC_RCP: outBuf[0].outf[0] = rcp(mathInVal); break;
|
||||
case DEBUG_SAMPLE_MATH_DXBC_RSQ: outBuf[0].outf[0] = rsqrt(mathInVal); break;
|
||||
case DEBUG_SAMPLE_MATH_DXBC_EXP: outBuf[0].outf[0] = exp2(mathInVal); break;
|
||||
case DEBUG_SAMPLE_MATH_DXBC_LOG: outBuf[0].outf[0] = log2(mathInVal); break;
|
||||
case DEBUG_SAMPLE_MATH_DXBC_SINCOS:
|
||||
sincos(mathInVal, outBuf[0].outf[0], outBuf[0].outf[1]);
|
||||
break;
|
||||
case DEBUG_SAMPLE_MATH_DXIL_COS: outBuf[0].outf[0] = cos(mathInVal); break;
|
||||
case DEBUG_SAMPLE_MATH_DXIL_SIN: outBuf[0].outf[0] = sin(mathInVal); break;
|
||||
case DEBUG_SAMPLE_MATH_DXIL_TAN: outBuf[0].outf[0] = tan(mathInVal); break;
|
||||
case DEBUG_SAMPLE_MATH_DXIL_ACOS: outBuf[0].outf[0] = acos(mathInVal); break;
|
||||
case DEBUG_SAMPLE_MATH_DXIL_ASIN: outBuf[0].outf[0] = asin(mathInVal); break;
|
||||
case DEBUG_SAMPLE_MATH_DXIL_ATAN: outBuf[0].outf[0] = atan(mathInVal); break;
|
||||
case DEBUG_SAMPLE_MATH_DXIL_HCOS: outBuf[0].outf[0] = cosh(mathInVal); break;
|
||||
case DEBUG_SAMPLE_MATH_DXIL_HSIN: outBuf[0].outf[0] = sinh(mathInVal); break;
|
||||
case DEBUG_SAMPLE_MATH_DXIL_HTAN: outBuf[0].outf[0] = tanh(mathInVal); break;
|
||||
case DEBUG_SAMPLE_MATH_DXIL_EXP: outBuf[0].outf[0] = exp(mathInVal); break;
|
||||
case DEBUG_SAMPLE_MATH_DXIL_LOG: outBuf[0].outf[0] = log(mathInVal); break;
|
||||
case DEBUG_SAMPLE_MATH_DXIL_SQRT: outBuf[0].outf[0] = sqrt(mathInVal); break;
|
||||
case DEBUG_SAMPLE_MATH_DXIL_RSQRT: outBuf[0].outf[0] = rsqrt(mathInVal); break;
|
||||
default: break;
|
||||
}
|
||||
}
|
||||
@@ -112,8 +127,8 @@ float4 DoFloatOpcode(float4 uv)
|
||||
float lod = debugSampleLodCompare;
|
||||
float compare = debugSampleLodCompare;
|
||||
|
||||
if(opcode == DEBUG_SAMPLE_TEX_SAMPLE || opcode == DEBUG_SAMPLE_TEX_SAMPLE_B ||
|
||||
opcode == DEBUG_SAMPLE_TEX_SAMPLE_D)
|
||||
if(opcode == DEBUG_SAMPLE_TEX_SAMPLE || opcode == DEBUG_SAMPLE_TEX_SAMPLE_BIAS ||
|
||||
opcode == DEBUG_SAMPLE_TEX_SAMPLE_GRAD)
|
||||
{
|
||||
switch(debugSampleTexDim)
|
||||
{
|
||||
@@ -160,7 +175,7 @@ float4 DoFloatOpcode(float4 uv)
|
||||
}
|
||||
}
|
||||
}
|
||||
else if(opcode == DEBUG_SAMPLE_TEX_SAMPLE_L)
|
||||
else if(opcode == DEBUG_SAMPLE_TEX_SAMPLE_LEVEL)
|
||||
{
|
||||
switch(debugSampleTexDim)
|
||||
{
|
||||
@@ -203,7 +218,7 @@ float4 DoFloatOpcode(float4 uv)
|
||||
}
|
||||
}
|
||||
}
|
||||
else if(opcode == DEBUG_SAMPLE_TEX_LD || opcode == DEBUG_SAMPLE_TEX_LD_MS)
|
||||
else if(opcode == DEBUG_SAMPLE_TEX_LOAD || opcode == DEBUG_SAMPLE_TEX_LOAD_MS)
|
||||
{
|
||||
switch(debugSampleTexDim)
|
||||
{
|
||||
@@ -248,7 +263,7 @@ float4 DoFloatOpcode(float4 uv)
|
||||
}
|
||||
}
|
||||
}
|
||||
else if(opcode == DEBUG_SAMPLE_TEX_SAMPLE_C)
|
||||
else if(opcode == DEBUG_SAMPLE_TEX_SAMPLE_CMP)
|
||||
{
|
||||
switch(debugSampleTexDim)
|
||||
{
|
||||
@@ -282,7 +297,7 @@ float4 DoFloatOpcode(float4 uv)
|
||||
}
|
||||
}
|
||||
}
|
||||
else if(opcode == DEBUG_SAMPLE_TEX_SAMPLE_C_LZ)
|
||||
else if(opcode == DEBUG_SAMPLE_TEX_SAMPLE_CMP_LEVEL_ZERO)
|
||||
{
|
||||
switch(debugSampleTexDim)
|
||||
{
|
||||
@@ -514,7 +529,7 @@ float4 DoFloatOpcode(float4 uv)
|
||||
}
|
||||
}
|
||||
}
|
||||
else if(opcode == DEBUG_SAMPLE_TEX_GATHER4_C || opcode == DEBUG_SAMPLE_TEX_GATHER4_PO_C)
|
||||
else if(opcode == DEBUG_SAMPLE_TEX_GATHER4_CMP || opcode == DEBUG_SAMPLE_TEX_GATHER4_PO_CMP)
|
||||
{
|
||||
if(debugSampleGatherChannel == 0)
|
||||
{
|
||||
@@ -654,7 +669,7 @@ int4 DoIntOpcode(float4 uv)
|
||||
int4 offsets = debugSampleOffsets;
|
||||
float lod = debugSampleLodCompare;
|
||||
|
||||
if(opcode == DEBUG_SAMPLE_TEX_LD || opcode == DEBUG_SAMPLE_TEX_LD_MS)
|
||||
if(opcode == DEBUG_SAMPLE_TEX_LOAD || opcode == DEBUG_SAMPLE_TEX_LOAD_MS)
|
||||
{
|
||||
switch(debugSampleTexDim)
|
||||
{
|
||||
@@ -719,7 +734,7 @@ uint4 DoUIntOpcode(float4 uv)
|
||||
int4 offsets = debugSampleOffsets;
|
||||
float lod = debugSampleLodCompare;
|
||||
|
||||
if(opcode == DEBUG_SAMPLE_TEX_LD || opcode == DEBUG_SAMPLE_TEX_LD_MS)
|
||||
if(opcode == DEBUG_SAMPLE_TEX_LOAD || opcode == DEBUG_SAMPLE_TEX_LOAD_MS)
|
||||
{
|
||||
switch(debugSampleTexDim)
|
||||
{
|
||||
@@ -779,14 +794,15 @@ void RENDERDOC_DebugSamplePS(in float4 pos : SV_Position, in float4 uv : UVS)
|
||||
{
|
||||
int opcode = debugSampleOperation;
|
||||
|
||||
if(opcode != DEBUG_SAMPLE_TEX_SAMPLE_C && opcode != DEBUG_SAMPLE_TEX_LOD)
|
||||
if(opcode != DEBUG_SAMPLE_TEX_SAMPLE_CMP && opcode != DEBUG_SAMPLE_TEX_LOD)
|
||||
{
|
||||
uv = debugSampleUV;
|
||||
}
|
||||
|
||||
bool forceFloat = (opcode == DEBUG_SAMPLE_TEX_SAMPLE_C || opcode == DEBUG_SAMPLE_TEX_SAMPLE_C_LZ ||
|
||||
opcode == DEBUG_SAMPLE_TEX_GATHER4_C ||
|
||||
opcode == DEBUG_SAMPLE_TEX_GATHER4_PO_C || opcode == DEBUG_SAMPLE_TEX_LOD);
|
||||
bool forceFloat =
|
||||
(opcode == DEBUG_SAMPLE_TEX_SAMPLE_CMP || opcode == DEBUG_SAMPLE_TEX_SAMPLE_CMP_LEVEL_ZERO ||
|
||||
opcode == DEBUG_SAMPLE_TEX_GATHER4_CMP || opcode == DEBUG_SAMPLE_TEX_GATHER4_PO_CMP ||
|
||||
opcode == DEBUG_SAMPLE_TEX_LOD);
|
||||
|
||||
if(!forceFloat && debugSampleRetType == DEBUG_SAMPLE_INT)
|
||||
{
|
||||
|
||||
@@ -77,12 +77,12 @@ public:
|
||||
|
||||
bool CalculateSampleGather(DXBCBytecode::OpcodeType opcode,
|
||||
DXBCDebug::SampleGatherResourceData resourceData,
|
||||
DXBCDebug::SampleGatherSamplerData samplerData, ShaderVariable uv,
|
||||
ShaderVariable ddxCalc, ShaderVariable ddyCalc,
|
||||
const int8_t texelOffsets[3], int multisampleIndex,
|
||||
float lodOrCompareValue, const uint8_t swizzle[4],
|
||||
DXBCDebug::GatherChannel gatherChannel, const char *opString,
|
||||
ShaderVariable &output);
|
||||
DXBCDebug::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], DXBCDebug::GatherChannel gatherChannel,
|
||||
const char *opString, ShaderVariable &output);
|
||||
|
||||
private:
|
||||
DXBC::ShaderType GetShaderType() { return m_dxbc ? m_dxbc->m_Type : DXBC::ShaderType::Pixel; }
|
||||
@@ -1035,42 +1035,41 @@ ShaderVariable D3D11DebugAPIWrapper::GetResourceInfo(DXBCBytecode::OperandType t
|
||||
|
||||
bool D3D11DebugAPIWrapper::CalculateSampleGather(
|
||||
DXBCBytecode::OpcodeType opcode, DXBCDebug::SampleGatherResourceData resourceData,
|
||||
DXBCDebug::SampleGatherSamplerData samplerData, ShaderVariable uv, ShaderVariable ddxCalc,
|
||||
ShaderVariable ddyCalc, const int8_t texelOffsets[3], int multisampleIndex,
|
||||
float lodOrCompareValue, const uint8_t swizzle[4], DXBCDebug::GatherChannel gatherChannel,
|
||||
const char *opString, ShaderVariable &output)
|
||||
DXBCDebug::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],
|
||||
DXBCDebug::GatherChannel gatherChannel, const char *opString, ShaderVariable &output)
|
||||
{
|
||||
using namespace DXBCBytecode;
|
||||
|
||||
RDCCOMPILE_ASSERT((int)DXBCBytecode::OPCODE_SAMPLE == DEBUG_SAMPLE_TEX_SAMPLE,
|
||||
"Opcode enum doesn't match shader define");
|
||||
RDCCOMPILE_ASSERT((int)DXBCBytecode::OPCODE_SAMPLE_L == DEBUG_SAMPLE_TEX_SAMPLE_L,
|
||||
"Opcode enum doesn't match shader define");
|
||||
RDCCOMPILE_ASSERT((int)DXBCBytecode::OPCODE_SAMPLE_B == DEBUG_SAMPLE_TEX_SAMPLE_B,
|
||||
"Opcode enum doesn't match shader define");
|
||||
RDCCOMPILE_ASSERT((int)DXBCBytecode::OPCODE_SAMPLE_C == DEBUG_SAMPLE_TEX_SAMPLE_C,
|
||||
"Opcode enum doesn't match shader define");
|
||||
RDCCOMPILE_ASSERT((int)DXBCBytecode::OPCODE_SAMPLE_D == DEBUG_SAMPLE_TEX_SAMPLE_D,
|
||||
"Opcode enum doesn't match shader define");
|
||||
RDCCOMPILE_ASSERT((int)DXBCBytecode::OPCODE_SAMPLE_C_LZ == DEBUG_SAMPLE_TEX_SAMPLE_C_LZ,
|
||||
"Opcode enum doesn't match shader define");
|
||||
RDCCOMPILE_ASSERT((int)DXBCBytecode::OPCODE_GATHER4 == DEBUG_SAMPLE_TEX_GATHER4,
|
||||
"Opcode enum doesn't match shader define");
|
||||
RDCCOMPILE_ASSERT((int)DXBCBytecode::OPCODE_GATHER4_C == DEBUG_SAMPLE_TEX_GATHER4_C,
|
||||
"Opcode enum doesn't match shader define");
|
||||
RDCCOMPILE_ASSERT((int)DXBCBytecode::OPCODE_GATHER4_PO == DEBUG_SAMPLE_TEX_GATHER4_PO,
|
||||
"Opcode enum doesn't match shader define");
|
||||
RDCCOMPILE_ASSERT((int)DXBCBytecode::OPCODE_GATHER4_PO_C == DEBUG_SAMPLE_TEX_GATHER4_PO_C,
|
||||
"Opcode enum doesn't match shader define");
|
||||
RDCCOMPILE_ASSERT((int)DXBCBytecode::OPCODE_LOD == DEBUG_SAMPLE_TEX_LOD,
|
||||
"Opcode enum doesn't match shader define");
|
||||
RDCCOMPILE_ASSERT((int)DXBCBytecode::OPCODE_LD == DEBUG_SAMPLE_TEX_LD,
|
||||
"Opcode enum doesn't match shader define");
|
||||
RDCCOMPILE_ASSERT((int)DXBCBytecode::OPCODE_LD_MS == DEBUG_SAMPLE_TEX_LD_MS,
|
||||
"Opcode enum doesn't match shader define");
|
||||
int sampleOp;
|
||||
switch(opcode)
|
||||
{
|
||||
case OPCODE_SAMPLE: sampleOp = DEBUG_SAMPLE_TEX_SAMPLE; break;
|
||||
case OPCODE_SAMPLE_L: sampleOp = DEBUG_SAMPLE_TEX_SAMPLE_LEVEL; break;
|
||||
case OPCODE_SAMPLE_B: sampleOp = DEBUG_SAMPLE_TEX_SAMPLE_BIAS; break;
|
||||
case OPCODE_SAMPLE_C: sampleOp = DEBUG_SAMPLE_TEX_SAMPLE_CMP; break;
|
||||
case OPCODE_SAMPLE_D: sampleOp = DEBUG_SAMPLE_TEX_SAMPLE_GRAD; break;
|
||||
case OPCODE_SAMPLE_C_LZ: sampleOp = DEBUG_SAMPLE_TEX_SAMPLE_CMP_LEVEL_ZERO; break;
|
||||
case OPCODE_GATHER4: sampleOp = DEBUG_SAMPLE_TEX_GATHER4; break;
|
||||
case OPCODE_GATHER4_C: sampleOp = DEBUG_SAMPLE_TEX_GATHER4_CMP; break;
|
||||
case OPCODE_GATHER4_PO: sampleOp = DEBUG_SAMPLE_TEX_GATHER4_PO; break;
|
||||
case OPCODE_GATHER4_PO_C: sampleOp = DEBUG_SAMPLE_TEX_GATHER4_PO_CMP; break;
|
||||
case OPCODE_LOD: sampleOp = DEBUG_SAMPLE_TEX_LOD; break;
|
||||
case OPCODE_LD: sampleOp = DEBUG_SAMPLE_TEX_LOAD; break;
|
||||
case OPCODE_LD_MS: sampleOp = DEBUG_SAMPLE_TEX_LOAD_MS; break;
|
||||
default:
|
||||
// To support a new instruction, the shader created in
|
||||
// ShaderDebugging::Init() will need updating
|
||||
RDCERR("Unsupported instruction for CalculateSampleGather: %u", opcode);
|
||||
return false;
|
||||
}
|
||||
|
||||
ShaderDebugging &debugData = m_pDevice->GetReplay()->GetShaderDebuggingData();
|
||||
|
||||
ShaderVariable uv(uvIn);
|
||||
ShaderVariable ddxCalc(ddxCalcIn);
|
||||
ShaderVariable ddyCalc(ddyCalcIn);
|
||||
for(uint32_t i = 0; i < ddxCalc.columns; i++)
|
||||
{
|
||||
if(!RDCISFINITE(ddxCalc.value.f32v[i]))
|
||||
@@ -1174,7 +1173,7 @@ bool D3D11DebugAPIWrapper::CalculateSampleGather(
|
||||
|
||||
cbufferData.debugSampleGatherChannel = (int)gatherChannel;
|
||||
cbufferData.debugSampleSampleIndex = multisampleIndex;
|
||||
cbufferData.debugSampleOperation = (int)opcode;
|
||||
cbufferData.debugSampleOperation = sampleOp;
|
||||
cbufferData.debugSampleLodCompare = lodOrCompareValue;
|
||||
|
||||
D3D11RenderStateTracker tracker(m_pDevice->GetImmediateContext());
|
||||
@@ -1357,16 +1356,20 @@ bool D3D11DebugAPIWrapper::CalculateMathIntrinsic(DXBCBytecode::OpcodeType opcod
|
||||
{
|
||||
D3D11RenderStateTracker tracker(m_pDevice->GetImmediateContext());
|
||||
|
||||
RDCCOMPILE_ASSERT((int)DXBCBytecode::OPCODE_RCP == DEBUG_SAMPLE_MATH_RCP,
|
||||
"Opcode enum doesn't match shader define");
|
||||
RDCCOMPILE_ASSERT((int)DXBCBytecode::OPCODE_RSQ == DEBUG_SAMPLE_MATH_RSQ,
|
||||
"Opcode enum doesn't match shader define");
|
||||
RDCCOMPILE_ASSERT((int)DXBCBytecode::OPCODE_EXP == DEBUG_SAMPLE_MATH_EXP,
|
||||
"Opcode enum doesn't match shader define");
|
||||
RDCCOMPILE_ASSERT((int)DXBCBytecode::OPCODE_LOG == DEBUG_SAMPLE_MATH_LOG,
|
||||
"Opcode enum doesn't match shader define");
|
||||
RDCCOMPILE_ASSERT((int)DXBCBytecode::OPCODE_SINCOS == DEBUG_SAMPLE_MATH_SINCOS,
|
||||
"Opcode enum doesn't match shader define");
|
||||
int mathOp = 0;
|
||||
switch(opcode)
|
||||
{
|
||||
case DXBCBytecode::OPCODE_RCP: mathOp = DEBUG_SAMPLE_MATH_DXBC_RCP; break;
|
||||
case DXBCBytecode::OPCODE_RSQ: mathOp = DEBUG_SAMPLE_MATH_DXBC_RSQ; break;
|
||||
case DXBCBytecode::OPCODE_EXP: mathOp = DEBUG_SAMPLE_MATH_DXBC_EXP; break;
|
||||
case DXBCBytecode::OPCODE_LOG: mathOp = DEBUG_SAMPLE_MATH_DXBC_LOG; break;
|
||||
case DXBCBytecode::OPCODE_SINCOS: mathOp = DEBUG_SAMPLE_MATH_DXBC_SINCOS; break;
|
||||
default:
|
||||
// To support a new instruction, the shader created in
|
||||
// ShaderDebugging::Init() will need updating
|
||||
RDCERR("Unsupported instruction for CalculateMathIntrinsic: %u", opcode);
|
||||
return false;
|
||||
}
|
||||
|
||||
ID3D11DeviceContext *context = NULL;
|
||||
m_pDevice->GetImmediateContext(&context);
|
||||
@@ -1382,7 +1385,7 @@ bool D3D11DebugAPIWrapper::CalculateMathIntrinsic(DXBCBytecode::OpcodeType opcod
|
||||
}
|
||||
|
||||
DebugMathOperation data;
|
||||
data.mathOp = (int)opcode;
|
||||
data.mathOp = mathOp;
|
||||
memcpy(&data.mathInVal, &input.value.u32v[0], sizeof(Vec4f));
|
||||
|
||||
memcpy(mapped.pData, &data, sizeof(data));
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,57 @@
|
||||
/******************************************************************************
|
||||
* The MIT License (MIT)
|
||||
*
|
||||
* Copyright (c) 2024 Baldur Karlsson
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
* THE SOFTWARE.
|
||||
******************************************************************************/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "driver/shaders/dxbc/dxbc_common.h"
|
||||
#include "driver/shaders/dxbc/dxbcdxil_debug.h"
|
||||
#include "d3d12_manager.h"
|
||||
|
||||
namespace D3D12ShaderDebug
|
||||
{
|
||||
using namespace DXBCDXILDebug;
|
||||
|
||||
typedef DXBCDXILDebug::SampleGatherResourceData SampleGatherResourceData;
|
||||
typedef DXBCDXILDebug::SampleGatherSamplerData SampleGatherSamplerData;
|
||||
typedef DXBCDXILDebug::BindingSlot BindingSlot;
|
||||
typedef DXBCDXILDebug::GatherChannel GatherChannel;
|
||||
typedef DXBCBytecode::SamplerMode SamplerMode;
|
||||
|
||||
// Helpers used by DXBC and DXIL debuggers to interact with GPU and resources
|
||||
bool CalculateMathIntrinsic(bool dxil, WrappedID3D12Device *device, int mathOp,
|
||||
const ShaderVariable &input, ShaderVariable &output1,
|
||||
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],
|
||||
GatherChannel gatherChannel, const DXBC::ShaderType shaderType,
|
||||
uint32_t instruction, const char *opString, ShaderVariable &output);
|
||||
|
||||
D3D12Descriptor FindDescriptor(WrappedID3D12Device *device, D3D12_DESCRIPTOR_RANGE_TYPE type,
|
||||
const DXBCDXILDebug::BindingSlot &slot,
|
||||
const DXBC::ShaderType shaderType);
|
||||
};
|
||||
@@ -172,6 +172,7 @@
|
||||
<ClInclude Include="d3d12_rendertext.h" />
|
||||
<ClInclude Include="d3d12_replay.h" />
|
||||
<ClInclude Include="d3d12_resources.h" />
|
||||
<ClInclude Include="d3d12_shaderdebug.h" />
|
||||
<ClInclude Include="d3d12_shader_cache.h" />
|
||||
<ClInclude Include="d3d12_state.h" />
|
||||
<ClInclude Include="precompiled.h" />
|
||||
|
||||
@@ -81,6 +81,9 @@
|
||||
<ClInclude Include="d3d12_dxil_debug.h">
|
||||
<Filter>Util</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="d3d12_shaderdebug.h">
|
||||
<Filter>Replay</Filter>
|
||||
</ClInclude>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="d3d12_common.cpp">
|
||||
|
||||
@@ -29,6 +29,7 @@
|
||||
#include "api/replay/rdcpair.h"
|
||||
#include "api/replay/rdcstr.h"
|
||||
#include "api/replay/shader_types.h"
|
||||
#include "dxbcdxil_debug.h"
|
||||
|
||||
struct DXBCContainerDebugger : public ShaderDebugger
|
||||
{
|
||||
|
||||
@@ -3903,8 +3903,8 @@ void ThreadState::StepNext(ShaderDebugState *state, DebugAPIWrapper *apiWrapper,
|
||||
if(op.operation != OPCODE_LOD && state)
|
||||
state->flags |= ShaderEvents::SampleLoadGather;
|
||||
|
||||
SamplerMode samplerMode = NUM_SAMPLERS;
|
||||
ResourceDimension resourceDim = RESOURCE_DIMENSION_UNKNOWN;
|
||||
DXBCBytecode::SamplerMode samplerMode = NUM_SAMPLERS;
|
||||
DXBCBytecode::ResourceDimension resourceDim = RESOURCE_DIMENSION_UNKNOWN;
|
||||
DXBC::ResourceRetType resourceRetType = DXBC::RETURN_TYPE_UNKNOWN;
|
||||
int sampleCount = 0;
|
||||
|
||||
|
||||
@@ -27,6 +27,7 @@
|
||||
|
||||
#include "common/common.h"
|
||||
#include "dxbc_bytecode.h"
|
||||
#include "dxbcdxil_debug.h"
|
||||
|
||||
namespace DXBC
|
||||
{
|
||||
@@ -47,22 +48,12 @@ enum DXGI_FORMAT;
|
||||
|
||||
namespace DXBCDebug
|
||||
{
|
||||
struct BindingSlot
|
||||
{
|
||||
BindingSlot() : shaderRegister(UINT32_MAX), registerSpace(UINT32_MAX) {}
|
||||
BindingSlot(uint32_t shaderReg, uint32_t regSpace)
|
||||
: shaderRegister(shaderReg), registerSpace(regSpace)
|
||||
{
|
||||
}
|
||||
bool operator<(const BindingSlot &o) const
|
||||
{
|
||||
if(registerSpace != o.registerSpace)
|
||||
return registerSpace < o.registerSpace;
|
||||
return shaderRegister < o.shaderRegister;
|
||||
}
|
||||
uint32_t shaderRegister;
|
||||
uint32_t registerSpace;
|
||||
};
|
||||
using namespace DXBCDXILDebug;
|
||||
|
||||
typedef DXBCDXILDebug::SampleGatherResourceData SampleGatherResourceData;
|
||||
typedef DXBCDXILDebug::SampleGatherSamplerData SampleGatherSamplerData;
|
||||
typedef DXBCDXILDebug::BindingSlot BindingSlot;
|
||||
typedef DXBCDXILDebug::GatherChannel GatherChannel;
|
||||
|
||||
BindingSlot GetBindingSlotForDeclaration(const DXBCBytecode::Program &program,
|
||||
const DXBCBytecode::Declaration &decl);
|
||||
@@ -213,29 +204,6 @@ void GatherPSInputDataForInitialValues(const DXBC::DXBCContainer *dxbc,
|
||||
rdcarray<rdcstr> &floatInputs, rdcarray<rdcstr> &inputVarNames,
|
||||
rdcstr &psInputDefinition, int &structureStride);
|
||||
|
||||
struct SampleGatherResourceData
|
||||
{
|
||||
DXBCBytecode::ResourceDimension dim;
|
||||
DXBC::ResourceRetType retType;
|
||||
int sampleCount;
|
||||
BindingSlot binding;
|
||||
};
|
||||
|
||||
struct SampleGatherSamplerData
|
||||
{
|
||||
DXBCBytecode::SamplerMode mode;
|
||||
float bias;
|
||||
BindingSlot binding;
|
||||
};
|
||||
|
||||
enum class GatherChannel : uint8_t
|
||||
{
|
||||
Red = 0,
|
||||
Green = 1,
|
||||
Blue = 2,
|
||||
Alpha = 3,
|
||||
};
|
||||
|
||||
class DebugAPIWrapper
|
||||
{
|
||||
public:
|
||||
@@ -261,12 +229,12 @@ public:
|
||||
|
||||
virtual bool CalculateSampleGather(DXBCBytecode::OpcodeType opcode,
|
||||
SampleGatherResourceData resourceData,
|
||||
SampleGatherSamplerData samplerData, ShaderVariable uv,
|
||||
ShaderVariable ddxCalc, ShaderVariable ddyCalc,
|
||||
const int8_t texelOffsets[3], int multisampleIndex,
|
||||
float lodOrCompareValue, const uint8_t swizzle[4],
|
||||
GatherChannel gatherChannel, const char *opString,
|
||||
ShaderVariable &output) = 0;
|
||||
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], GatherChannel gatherChannel,
|
||||
const char *opString, ShaderVariable &output) = 0;
|
||||
};
|
||||
|
||||
class ThreadState
|
||||
|
||||
@@ -0,0 +1,84 @@
|
||||
/******************************************************************************
|
||||
* The MIT License (MIT)
|
||||
*
|
||||
* Copyright (c) 2024 Baldur Karlsson
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
* THE SOFTWARE.
|
||||
******************************************************************************/
|
||||
|
||||
#pragma once
|
||||
|
||||
namespace DXBC
|
||||
{
|
||||
enum ResourceRetType;
|
||||
};
|
||||
|
||||
namespace DXBCBytecode
|
||||
{
|
||||
enum ResourceDimension;
|
||||
enum SamplerMode;
|
||||
};
|
||||
|
||||
namespace DXBCDXILDebug
|
||||
{
|
||||
typedef DXBC::ResourceRetType ResourceRetType;
|
||||
typedef DXBCBytecode::ResourceDimension ResourceDimension;
|
||||
typedef DXBCBytecode::SamplerMode SamplerMode;
|
||||
|
||||
enum class GatherChannel : uint8_t
|
||||
{
|
||||
Red = 0,
|
||||
Green = 1,
|
||||
Blue = 2,
|
||||
Alpha = 3,
|
||||
};
|
||||
|
||||
struct BindingSlot
|
||||
{
|
||||
BindingSlot() : shaderRegister(UINT32_MAX), registerSpace(UINT32_MAX) {}
|
||||
BindingSlot(uint32_t shaderReg, uint32_t regSpace)
|
||||
: shaderRegister(shaderReg), registerSpace(regSpace)
|
||||
{
|
||||
}
|
||||
bool operator<(const BindingSlot &o) const
|
||||
{
|
||||
if(registerSpace != o.registerSpace)
|
||||
return registerSpace < o.registerSpace;
|
||||
return shaderRegister < o.shaderRegister;
|
||||
}
|
||||
uint32_t shaderRegister;
|
||||
uint32_t registerSpace;
|
||||
};
|
||||
|
||||
struct SampleGatherResourceData
|
||||
{
|
||||
ResourceDimension dim;
|
||||
ResourceRetType retType;
|
||||
int sampleCount;
|
||||
BindingSlot binding;
|
||||
};
|
||||
|
||||
struct SampleGatherSamplerData
|
||||
{
|
||||
SamplerMode mode;
|
||||
float bias;
|
||||
BindingSlot binding;
|
||||
};
|
||||
|
||||
};
|
||||
@@ -117,6 +117,7 @@
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="dxbcdxil_debug.h" />
|
||||
<ClInclude Include="dxbc_bytecode.h" />
|
||||
<ClInclude Include="dxbc_bytecode_editor.h" />
|
||||
<ClInclude Include="dxbc_bytecode_ops.h" />
|
||||
|
||||
@@ -36,6 +36,7 @@
|
||||
<ClInclude Include="dxbc_bytecode.h" />
|
||||
<ClInclude Include="dxbc_bytecode_ops.h" />
|
||||
<ClInclude Include="dxbc_bytecode_editor.h" />
|
||||
<ClInclude Include="dxbcdxil_debug.h" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Filter Include="PCH">
|
||||
|
||||
Reference in New Issue
Block a user