From f9c1f24c0c3d2c643e1551a9e0882f0ad28d5065 Mon Sep 17 00:00:00 2001 From: baldurk Date: Wed, 3 Jun 2020 12:08:14 +0100 Subject: [PATCH] DDX/DDY are always float typed --- renderdoc/driver/d3d11/d3d11_shaderdebug.cpp | 28 +++++--------------- renderdoc/driver/d3d12/d3d12_shaderdebug.cpp | 28 +++++--------------- 2 files changed, 14 insertions(+), 42 deletions(-) diff --git a/renderdoc/driver/d3d11/d3d11_shaderdebug.cpp b/renderdoc/driver/d3d11/d3d11_shaderdebug.cpp index ebbcbd915..d7f54f8f9 100644 --- a/renderdoc/driver/d3d11/d3d11_shaderdebug.cpp +++ b/renderdoc/driver/d3d11/d3d11_shaderdebug.cpp @@ -1116,8 +1116,6 @@ bool D3D11DebugAPIWrapper::CalculateSampleGather( }; int texcoordType = 0; - int ddxType = 0; - int ddyType = 0; int texdimOffs = 0; if(opcode == OPCODE_SAMPLE || opcode == OPCODE_SAMPLE_L || opcode == OPCODE_SAMPLE_B || @@ -1126,7 +1124,7 @@ bool D3D11DebugAPIWrapper::CalculateSampleGather( opcode == OPCODE_GATHER4_PO_C || opcode == OPCODE_LOD) { // all floats - texcoordType = ddxType = ddyType = 0; + texcoordType = 0; } else if(opcode == OPCODE_LD) { @@ -1151,7 +1149,7 @@ bool D3D11DebugAPIWrapper::CalculateSampleGather( for(uint32_t i = 0; i < ddxCalc.columns; i++) { - if(ddxType == 0 && (_isnan(ddxCalc.value.fv[i]) || !_finite(ddxCalc.value.fv[i]))) + if(_isnan(ddxCalc.value.fv[i]) || !_finite(ddxCalc.value.fv[i])) { RDCWARN("NaN or Inf in texlookup"); ddxCalc.value.fv[i] = 0.0f; @@ -1162,7 +1160,7 @@ bool D3D11DebugAPIWrapper::CalculateSampleGather( "texture lookup ddx - using 0.0 instead", m_instruction, opString)); } - if(ddyType == 0 && (_isnan(ddyCalc.value.fv[i]) || !_finite(ddyCalc.value.fv[i]))) + if(_isnan(ddyCalc.value.fv[i]) || !_finite(ddyCalc.value.fv[i])) { RDCWARN("NaN or Inf in texlookup"); ddyCalc.value.fv[i] = 0.0f; @@ -1237,23 +1235,11 @@ bool D3D11DebugAPIWrapper::CalculateSampleGather( if(opcode == OPCODE_SAMPLE || opcode == OPCODE_SAMPLE_B || opcode == OPCODE_SAMPLE_D) { - rdcstr ddx; + rdcstr ddx = StringFormat::Fmt(formats[offsetDim + texdimOffs - 1][0], ddxCalc.value.f.x, + ddxCalc.value.f.y, ddxCalc.value.f.z, ddxCalc.value.f.w); - if(ddxType == 0) - ddx = StringFormat::Fmt(formats[offsetDim + texdimOffs - 1][ddxType], ddxCalc.value.f.x, - ddxCalc.value.f.y, ddxCalc.value.f.z, ddxCalc.value.f.w); - else - ddx = StringFormat::Fmt(formats[offsetDim + texdimOffs - 1][ddxType], ddxCalc.value.i.x, - ddxCalc.value.i.y, ddxCalc.value.i.z, ddxCalc.value.i.w); - - rdcstr ddy; - - if(ddyType == 0) - ddy = StringFormat::Fmt(formats[offsetDim + texdimOffs - 1][ddyType], ddyCalc.value.f.x, - ddyCalc.value.f.y, ddyCalc.value.f.z, ddyCalc.value.f.w); - else - ddy = StringFormat::Fmt(formats[offsetDim + texdimOffs - 1][ddyType], ddyCalc.value.i.x, - ddyCalc.value.i.y, ddyCalc.value.i.z, ddyCalc.value.i.w); + rdcstr ddy = StringFormat::Fmt(formats[offsetDim + texdimOffs - 1][0], ddyCalc.value.f.x, + ddyCalc.value.f.y, ddyCalc.value.f.z, ddyCalc.value.f.w); sampleProgram = StringFormat::Fmt("%s : register(t0);\n%s : register(s0);\n\n", textureDecl.c_str(), samplerDecl.c_str()); diff --git a/renderdoc/driver/d3d12/d3d12_shaderdebug.cpp b/renderdoc/driver/d3d12/d3d12_shaderdebug.cpp index f0c717f37..5aeb1c3fc 100644 --- a/renderdoc/driver/d3d12/d3d12_shaderdebug.cpp +++ b/renderdoc/driver/d3d12/d3d12_shaderdebug.cpp @@ -1176,8 +1176,6 @@ bool D3D12DebugAPIWrapper::CalculateSampleGather( }; int texcoordType = 0; - int ddxType = 0; - int ddyType = 0; int texdimOffs = 0; if(opcode == OPCODE_SAMPLE || opcode == OPCODE_SAMPLE_L || opcode == OPCODE_SAMPLE_B || @@ -1186,7 +1184,7 @@ bool D3D12DebugAPIWrapper::CalculateSampleGather( opcode == OPCODE_GATHER4_PO_C || opcode == OPCODE_LOD) { // all floats - texcoordType = ddxType = ddyType = 0; + texcoordType = 0; } else if(opcode == OPCODE_LD) { @@ -1211,7 +1209,7 @@ bool D3D12DebugAPIWrapper::CalculateSampleGather( for(uint32_t i = 0; i < ddxCalc.columns; i++) { - if(ddxType == 0 && (_isnan(ddxCalc.value.fv[i]) || !_finite(ddxCalc.value.fv[i]))) + if(_isnan(ddxCalc.value.fv[i]) || !_finite(ddxCalc.value.fv[i])) { RDCWARN("NaN or Inf in texlookup"); ddxCalc.value.fv[i] = 0.0f; @@ -1222,7 +1220,7 @@ bool D3D12DebugAPIWrapper::CalculateSampleGather( "texture lookup ddx - using 0.0 instead", m_instruction, opString)); } - if(ddyType == 0 && (_isnan(ddyCalc.value.fv[i]) || !_finite(ddyCalc.value.fv[i]))) + if(_isnan(ddyCalc.value.fv[i]) || !_finite(ddyCalc.value.fv[i])) { RDCWARN("NaN or Inf in texlookup"); ddyCalc.value.fv[i] = 0.0f; @@ -1302,23 +1300,11 @@ bool D3D12DebugAPIWrapper::CalculateSampleGather( if(opcode == OPCODE_SAMPLE || opcode == OPCODE_SAMPLE_B || opcode == OPCODE_SAMPLE_D) { - rdcstr ddx; + rdcstr ddx = StringFormat::Fmt(formats[offsetDim + texdimOffs - 1][0], ddxCalc.value.f.x, + ddxCalc.value.f.y, ddxCalc.value.f.z, ddxCalc.value.f.w); - if(ddxType == 0) - ddx = StringFormat::Fmt(formats[offsetDim + texdimOffs - 1][ddxType], ddxCalc.value.f.x, - ddxCalc.value.f.y, ddxCalc.value.f.z, ddxCalc.value.f.w); - else - ddx = StringFormat::Fmt(formats[offsetDim + texdimOffs - 1][ddxType], ddxCalc.value.i.x, - ddxCalc.value.i.y, ddxCalc.value.i.z, ddxCalc.value.i.w); - - rdcstr ddy; - - if(ddyType == 0) - ddy = StringFormat::Fmt(formats[offsetDim + texdimOffs - 1][ddyType], ddyCalc.value.f.x, - ddyCalc.value.f.y, ddyCalc.value.f.z, ddyCalc.value.f.w); - else - ddy = StringFormat::Fmt(formats[offsetDim + texdimOffs - 1][ddyType], ddyCalc.value.i.x, - ddyCalc.value.i.y, ddyCalc.value.i.z, ddyCalc.value.i.w); + rdcstr ddy = StringFormat::Fmt(formats[offsetDim + texdimOffs - 1][0], ddyCalc.value.f.x, + ddyCalc.value.f.y, ddyCalc.value.f.z, ddyCalc.value.f.w); sampleProgram = StringFormat::Fmt("%s : register(%s);\n%s : register(%s);\n\n", textureDecl.c_str(), strResourceBinding.c_str(),