Fix sincos output on D3D12 shader debugging

This commit is contained in:
baldurk
2020-05-20 10:51:23 +01:00
parent 8230ad5242
commit 43b6f850d9
4 changed files with 20 additions and 15 deletions
+1 -1
View File
@@ -521,7 +521,7 @@ bool D3D12DebugManager::CreateMathIntrinsicsResources()
D3D12_RESOURCE_DESC rdesc;
ZeroMemory(&rdesc, sizeof(D3D12_RESOURCE_DESC));
rdesc.Dimension = D3D12_RESOURCE_DIMENSION_BUFFER;
rdesc.Width = sizeof(float) * 8; // Output buffer is 2x float4
rdesc.Width = sizeof(Vec4f) * 2; // Output buffer is 2x float4
rdesc.Height = 1;
rdesc.DepthOrArraySize = 1;
rdesc.MipLevels = 1;
+4 -4
View File
@@ -421,7 +421,7 @@ bool D3D12DebugAPIWrapper::CalculateMathIntrinsic(DXBCBytecode::OpcodeType opcod
uavDesc.Format = DXGI_FORMAT_UNKNOWN;
uavDesc.ViewDimension = D3D12_UAV_DIMENSION_BUFFER;
uavDesc.Buffer.NumElements = 2;
uavDesc.Buffer.StructureByteStride = sizeof(float) * 4;
uavDesc.Buffer.StructureByteStride = sizeof(Vec4f);
ID3D12Resource *pResultBuffer = m_pDevice->GetDebugManager()->GetMathIntrinsicsResultBuffer();
D3D12_CPU_DESCRIPTOR_HANDLE uav = m_pDevice->GetDebugManager()->GetCPUHandle(SHADER_DEBUG_UAV);
@@ -452,10 +452,10 @@ bool D3D12DebugAPIWrapper::CalculateMathIntrinsic(DXBCBytecode::OpcodeType opcod
bytebuf results;
m_pDevice->GetDebugManager()->GetBufferData(pResultBuffer, 0, 0, results);
RDCASSERT(results.size() >= sizeof(uint32_t) * 8);
RDCASSERT(results.size() >= sizeof(Vec4f) * 2);
memcpy(output1.value.uv, results.data(), sizeof(uint32_t) * 4);
memcpy(output2.value.uv, results.data() + 4, sizeof(uint32_t) * 4);
memcpy(output1.value.uv, results.data(), sizeof(Vec4f));
memcpy(output2.value.uv, results.data() + sizeof(Vec4f), sizeof(Vec4f));
return true;
}
@@ -592,16 +592,10 @@ float4 main(v2f IN) : SV_Target0
}
if(IN.tri == 67)
{
int zero_i = int(zero);
int posone_i = int(posone);
int negone_i = int(negone);
return float4(float(zero_i/zero_i), float(posone_i/zero_i), float(negone_i/zero_i), 1.0f);
}
if(IN.tri == 68)
{
uint zero_i = uint(zero);
uint posone_i = uint(posone);
return float4(float(zero_i/zero_i), float(posone_i/zero_i), 0.0f, 1.0f);
float val = posone * 1.8631f;
float a = 0.0f, b = 0.0f;
sincos(val, a, b);
return float4(val, a, b, 0.0f);
}
return float4(0.4f, 0.4f, 0.4f, 0.4f);
@@ -97,6 +97,10 @@ v2f main(consts IN, uint tri : SV_InstanceID)
std::string pixel = R"EOSHADER(
// error X3556: integer divides may be much slower, try using uints if possible.
// we want to do this on purpose
#pragma warning( disable : 3556 )
struct InnerStruct
{
float a;
@@ -600,6 +604,13 @@ float4 main(v2f IN) : SV_Target0
float2 pos = GetRenderTargetSamplePosition(0);
return float4(pos, numSamples, 0.0f);
}
if(IN.tri == 67)
{
float val = posone * 1.8631f;
float a = 0.0f, b = 0.0f;
sincos(val, a, b);
return float4(val, a, b, 0.0f);
}
return float4(0.4f, 0.4f, 0.4f, 0.4f);
}