mirror of
https://github.com/baldurk/renderdoc.git
synced 2026-07-21 06:51:35 +00:00
Rename ShaderDebug namespace to DXBCDebug
This commit is contained in:
@@ -40,7 +40,7 @@ class D3D11ResourceManager;
|
||||
|
||||
struct CopyPixelParams;
|
||||
|
||||
namespace ShaderDebug
|
||||
namespace DXBCDebug
|
||||
{
|
||||
struct GlobalState;
|
||||
class State;
|
||||
|
||||
@@ -50,17 +50,17 @@ struct DebugHit
|
||||
uint32_t rawdata; // arbitrary, depending on shader
|
||||
};
|
||||
|
||||
class D3D11DebugAPIWrapper : public ShaderDebug::DebugAPIWrapper
|
||||
class D3D11DebugAPIWrapper : public DXBCDebug::DebugAPIWrapper
|
||||
{
|
||||
public:
|
||||
D3D11DebugAPIWrapper(WrappedID3D11Device *device, DXBC::DXBCContainer *dxbc,
|
||||
ShaderDebug::GlobalState &globalState);
|
||||
DXBCDebug::GlobalState &globalState);
|
||||
|
||||
void SetCurrentInstruction(uint32_t instruction) { m_instruction = instruction; }
|
||||
void AddDebugMessage(MessageCategory c, MessageSeverity sv, MessageSource src, rdcstr d);
|
||||
|
||||
bool FetchSRV(const ShaderDebug::BindingSlot &slot);
|
||||
bool FetchUAV(const ShaderDebug::BindingSlot &slot);
|
||||
bool FetchSRV(const DXBCDebug::BindingSlot &slot);
|
||||
bool FetchUAV(const DXBCDebug::BindingSlot &slot);
|
||||
|
||||
bool CalculateMathIntrinsic(DXBCBytecode::OpcodeType opcode, const ShaderVariable &input,
|
||||
ShaderVariable &output1, ShaderVariable &output2);
|
||||
@@ -72,23 +72,23 @@ public:
|
||||
int &dim);
|
||||
|
||||
bool CalculateSampleGather(DXBCBytecode::OpcodeType opcode,
|
||||
ShaderDebug::SampleGatherResourceData resourceData,
|
||||
ShaderDebug::SampleGatherSamplerData samplerData, ShaderVariable uv,
|
||||
DXBCDebug::SampleGatherResourceData resourceData,
|
||||
DXBCDebug::SampleGatherSamplerData samplerData, ShaderVariable uv,
|
||||
ShaderVariable ddxCalc, ShaderVariable ddyCalc,
|
||||
const int texelOffsets[3], int multisampleIndex, float lodOrCompareValue,
|
||||
const uint8_t swizzle[4], ShaderDebug::GatherChannel gatherChannel,
|
||||
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; }
|
||||
WrappedID3D11Device *m_pDevice;
|
||||
DXBC::DXBCContainer *m_dxbc;
|
||||
ShaderDebug::GlobalState &m_globalState;
|
||||
DXBCDebug::GlobalState &m_globalState;
|
||||
uint32_t m_instruction;
|
||||
};
|
||||
|
||||
D3D11DebugAPIWrapper::D3D11DebugAPIWrapper(WrappedID3D11Device *device, DXBC::DXBCContainer *dxbc,
|
||||
ShaderDebug::GlobalState &globalState)
|
||||
DXBCDebug::GlobalState &globalState)
|
||||
: m_pDevice(device), m_dxbc(dxbc), m_globalState(globalState), m_instruction(0)
|
||||
{
|
||||
}
|
||||
@@ -99,7 +99,7 @@ void D3D11DebugAPIWrapper::AddDebugMessage(MessageCategory c, MessageSeverity sv
|
||||
m_pDevice->AddDebugMessage(c, sv, src, d);
|
||||
}
|
||||
|
||||
bool D3D11DebugAPIWrapper::FetchSRV(const ShaderDebug::BindingSlot &slot)
|
||||
bool D3D11DebugAPIWrapper::FetchSRV(const DXBCDebug::BindingSlot &slot)
|
||||
{
|
||||
RDCASSERT(slot.registerSpace == 0);
|
||||
RDCASSERT(slot.shaderRegister < D3D11_COMMONSHADER_INPUT_RESOURCE_SLOT_COUNT);
|
||||
@@ -122,11 +122,11 @@ bool D3D11DebugAPIWrapper::FetchSRV(const ShaderDebug::BindingSlot &slot)
|
||||
D3D11_SHADER_RESOURCE_VIEW_DESC sdesc;
|
||||
pSRV->GetDesc(&sdesc);
|
||||
|
||||
ShaderDebug::GlobalState::SRVData &srvData = m_globalState.srvs[slot];
|
||||
DXBCDebug::GlobalState::SRVData &srvData = m_globalState.srvs[slot];
|
||||
|
||||
if(sdesc.Format != DXGI_FORMAT_UNKNOWN)
|
||||
{
|
||||
ShaderDebug::FillViewFmt(sdesc.Format, srvData.format);
|
||||
DXBCDebug::FillViewFmt(sdesc.Format, srvData.format);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -142,8 +142,7 @@ bool D3D11DebugAPIWrapper::FetchSRV(const ShaderDebug::BindingSlot &slot)
|
||||
srvData.format.stride = bufdesc.StructureByteStride;
|
||||
|
||||
// if we didn't get a type from the SRV description, try to pull it from the declaration
|
||||
ShaderDebug::LookupSRVFormatFromShaderReflection(*m_dxbc->GetReflection(), slot,
|
||||
srvData.format);
|
||||
DXBCDebug::LookupSRVFormatFromShaderReflection(*m_dxbc->GetReflection(), slot, srvData.format);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -172,7 +171,7 @@ bool D3D11DebugAPIWrapper::FetchSRV(const ShaderDebug::BindingSlot &slot)
|
||||
return true;
|
||||
}
|
||||
|
||||
bool D3D11DebugAPIWrapper::FetchUAV(const ShaderDebug::BindingSlot &slot)
|
||||
bool D3D11DebugAPIWrapper::FetchUAV(const DXBCDebug::BindingSlot &slot)
|
||||
{
|
||||
RDCASSERT(slot.registerSpace == 0);
|
||||
RDCASSERT(slot.shaderRegister < D3D11_1_UAV_SLOT_COUNT);
|
||||
@@ -191,7 +190,7 @@ bool D3D11DebugAPIWrapper::FetchUAV(const ShaderDebug::BindingSlot &slot)
|
||||
ID3D11Resource *res = NULL;
|
||||
pUAV->GetResource(&res);
|
||||
|
||||
ShaderDebug::GlobalState::UAVData &uavData = m_globalState.uavs[slot];
|
||||
DXBCDebug::GlobalState::UAVData &uavData = m_globalState.uavs[slot];
|
||||
uavData.hiddenCounter = m_pDevice->GetDebugManager()->GetStructCount(pUAV);
|
||||
|
||||
D3D11_UNORDERED_ACCESS_VIEW_DESC udesc;
|
||||
@@ -942,10 +941,10 @@ ShaderVariable D3D11DebugAPIWrapper::GetResourceInfo(DXBCBytecode::OperandType t
|
||||
}
|
||||
|
||||
bool D3D11DebugAPIWrapper::CalculateSampleGather(
|
||||
DXBCBytecode::OpcodeType opcode, ShaderDebug::SampleGatherResourceData resourceData,
|
||||
ShaderDebug::SampleGatherSamplerData samplerData, ShaderVariable uv, ShaderVariable ddxCalc,
|
||||
DXBCBytecode::OpcodeType opcode, DXBCDebug::SampleGatherResourceData resourceData,
|
||||
DXBCDebug::SampleGatherSamplerData samplerData, ShaderVariable uv, ShaderVariable ddxCalc,
|
||||
ShaderVariable ddyCalc, const int texelOffsets[3], int multisampleIndex,
|
||||
float lodOrCompareValue, const uint8_t swizzle[4], ShaderDebug::GatherChannel gatherChannel,
|
||||
float lodOrCompareValue, const uint8_t swizzle[4], DXBCDebug::GatherChannel gatherChannel,
|
||||
const char *opString, ShaderVariable &output)
|
||||
{
|
||||
using namespace DXBCBytecode;
|
||||
@@ -1200,10 +1199,10 @@ bool D3D11DebugAPIWrapper::CalculateSampleGather(
|
||||
rdcstr strGatherChannel;
|
||||
switch(gatherChannel)
|
||||
{
|
||||
case ShaderDebug::GatherChannel::Red: strGatherChannel = "Red"; break;
|
||||
case ShaderDebug::GatherChannel::Green: strGatherChannel = "Green"; break;
|
||||
case ShaderDebug::GatherChannel::Blue: strGatherChannel = "Blue"; break;
|
||||
case ShaderDebug::GatherChannel::Alpha: strGatherChannel = "Alpha"; break;
|
||||
case DXBCDebug::GatherChannel::Red: strGatherChannel = "Red"; break;
|
||||
case DXBCDebug::GatherChannel::Green: strGatherChannel = "Green"; break;
|
||||
case DXBCDebug::GatherChannel::Blue: strGatherChannel = "Blue"; break;
|
||||
case DXBCDebug::GatherChannel::Alpha: strGatherChannel = "Alpha"; break;
|
||||
}
|
||||
|
||||
rdcstr vsProgram = "float4 main(uint id : SV_VertexID) : SV_Position {\n";
|
||||
@@ -1708,7 +1707,7 @@ void AddCBuffersToDebugTrace(const DXBCBytecode::Program &program, D3D11DebugMan
|
||||
{
|
||||
if(shader.ConstantBuffers[i])
|
||||
{
|
||||
ShaderDebug::BindingSlot slot(i, 0);
|
||||
DXBCDebug::BindingSlot slot(i, 0);
|
||||
cbufData.clear();
|
||||
debugManager.GetBufferData(shader.ConstantBuffers[i], shader.CBOffsets[i] * sizeof(Vec4f),
|
||||
shader.CBCounts[i] * sizeof(Vec4f), cbufData);
|
||||
@@ -1722,7 +1721,7 @@ ShaderDebugTrace D3D11Replay::DebugVertex(uint32_t eventId, uint32_t vertid, uin
|
||||
uint32_t idx, uint32_t instOffset, uint32_t vertOffset)
|
||||
{
|
||||
using namespace DXBCBytecode;
|
||||
using namespace ShaderDebug;
|
||||
using namespace DXBCDebug;
|
||||
|
||||
D3D11MarkerRegion debugpixRegion(
|
||||
StringFormat::Fmt("DebugVertex @ %u of (%u,%u,%u)", eventId, vertid, instid, idx));
|
||||
@@ -2111,7 +2110,7 @@ ShaderDebugTrace D3D11Replay::DebugPixel(uint32_t eventId, uint32_t x, uint32_t
|
||||
uint32_t primitive)
|
||||
{
|
||||
using namespace DXBCBytecode;
|
||||
using namespace ShaderDebug;
|
||||
using namespace DXBCDebug;
|
||||
|
||||
D3D11MarkerRegion debugpixRegion(
|
||||
StringFormat::Fmt("DebugPixel @ %u of (%u,%u) %u / %u", eventId, x, y, sample, primitive));
|
||||
@@ -2178,9 +2177,9 @@ ShaderDebugTrace D3D11Replay::DebugPixel(uint32_t eventId, uint32_t x, uint32_t
|
||||
rdcstr extractHlsl;
|
||||
int structureStride = 0;
|
||||
|
||||
ShaderDebug::GatherPSInputDataForInitialValues(*dxbc->GetReflection(), *prevdxbc->GetReflection(),
|
||||
initialValues, floatInputs, inputVarNames,
|
||||
extractHlsl, structureStride);
|
||||
DXBCDebug::GatherPSInputDataForInitialValues(*dxbc->GetReflection(), *prevdxbc->GetReflection(),
|
||||
initialValues, floatInputs, inputVarNames,
|
||||
extractHlsl, structureStride);
|
||||
|
||||
uint32_t overdrawLevels = 100; // maximum number of overdraw levels
|
||||
|
||||
@@ -2973,7 +2972,7 @@ ShaderDebugTrace D3D11Replay::DebugThread(uint32_t eventId, const uint32_t group
|
||||
const uint32_t threadid[3])
|
||||
{
|
||||
using namespace DXBCBytecode;
|
||||
using namespace ShaderDebug;
|
||||
using namespace DXBCDebug;
|
||||
|
||||
D3D11MarkerRegion simloop(StringFormat::Fmt("DebugThread @ %u: [%u, %u, %u] (%u, %u, %u)",
|
||||
eventId, groupid[0], groupid[1], groupid[2],
|
||||
|
||||
@@ -38,7 +38,7 @@ namespace DXBC
|
||||
class DXBCContainer;
|
||||
};
|
||||
|
||||
namespace ShaderDebug
|
||||
namespace DXBCDebug
|
||||
{
|
||||
struct GlobalState;
|
||||
class State;
|
||||
|
||||
@@ -61,17 +61,17 @@ static bool IsShaderParameterVisible(DXBC::ShaderType shaderType,
|
||||
return false;
|
||||
}
|
||||
|
||||
class D3D12DebugAPIWrapper : public ShaderDebug::DebugAPIWrapper
|
||||
class D3D12DebugAPIWrapper : public DXBCDebug::DebugAPIWrapper
|
||||
{
|
||||
public:
|
||||
D3D12DebugAPIWrapper(WrappedID3D12Device *device, DXBC::DXBCContainer *dxbc,
|
||||
ShaderDebug::GlobalState &globalState);
|
||||
DXBCDebug::GlobalState &globalState);
|
||||
|
||||
void SetCurrentInstruction(uint32_t instruction) { m_instruction = instruction; }
|
||||
void AddDebugMessage(MessageCategory c, MessageSeverity sv, MessageSource src, rdcstr d);
|
||||
|
||||
bool FetchSRV(const ShaderDebug::BindingSlot &slot);
|
||||
bool FetchUAV(const ShaderDebug::BindingSlot &slot);
|
||||
bool FetchSRV(const DXBCDebug::BindingSlot &slot);
|
||||
bool FetchUAV(const DXBCDebug::BindingSlot &slot);
|
||||
|
||||
bool CalculateMathIntrinsic(DXBCBytecode::OpcodeType opcode, const ShaderVariable &input,
|
||||
ShaderVariable &output1, ShaderVariable &output2);
|
||||
@@ -84,23 +84,23 @@ public:
|
||||
int &dim);
|
||||
|
||||
bool CalculateSampleGather(DXBCBytecode::OpcodeType opcode,
|
||||
ShaderDebug::SampleGatherResourceData resourceData,
|
||||
ShaderDebug::SampleGatherSamplerData samplerData, ShaderVariable uv,
|
||||
DXBCDebug::SampleGatherResourceData resourceData,
|
||||
DXBCDebug::SampleGatherSamplerData samplerData, ShaderVariable uv,
|
||||
ShaderVariable ddxCalc, ShaderVariable ddyCalc,
|
||||
const int texelOffsets[3], int multisampleIndex, float lodOrCompareValue,
|
||||
const uint8_t swizzle[4], ShaderDebug::GatherChannel gatherChannel,
|
||||
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; }
|
||||
WrappedID3D12Device *m_pDevice;
|
||||
DXBC::DXBCContainer *m_dxbc;
|
||||
ShaderDebug::GlobalState &m_globalState;
|
||||
DXBCDebug::GlobalState &m_globalState;
|
||||
uint32_t m_instruction;
|
||||
};
|
||||
|
||||
D3D12DebugAPIWrapper::D3D12DebugAPIWrapper(WrappedID3D12Device *device, DXBC::DXBCContainer *dxbc,
|
||||
ShaderDebug::GlobalState &globalState)
|
||||
DXBCDebug::GlobalState &globalState)
|
||||
: m_pDevice(device), m_dxbc(dxbc), m_globalState(globalState), m_instruction(0)
|
||||
{
|
||||
}
|
||||
@@ -111,7 +111,7 @@ void D3D12DebugAPIWrapper::AddDebugMessage(MessageCategory c, MessageSeverity sv
|
||||
m_pDevice->AddDebugMessage(c, sv, src, d);
|
||||
}
|
||||
|
||||
bool D3D12DebugAPIWrapper::FetchSRV(const ShaderDebug::BindingSlot &slot)
|
||||
bool D3D12DebugAPIWrapper::FetchSRV(const DXBCDebug::BindingSlot &slot)
|
||||
{
|
||||
D3D12RenderState &rs = m_pDevice->GetQueue()->GetCommandData()->m_RenderState;
|
||||
D3D12ResourceManager *rm = m_pDevice->GetResourceManager();
|
||||
@@ -151,11 +151,11 @@ bool D3D12DebugAPIWrapper::FetchSRV(const ShaderDebug::BindingSlot &slot)
|
||||
ID3D12Resource *pResource = rm->GetCurrentAs<ID3D12Resource>(element.id);
|
||||
D3D12_RESOURCE_DESC resDesc = pResource->GetDesc();
|
||||
|
||||
ShaderDebug::GlobalState::SRVData &srvData = m_globalState.srvs[slot];
|
||||
DXBCDebug::GlobalState::SRVData &srvData = m_globalState.srvs[slot];
|
||||
|
||||
// TODO: Root buffers can be 32-bit UINT/SINT/FLOAT. Using UINT for now, but the
|
||||
// resource desc format or the DXBC reflection info might be more correct.
|
||||
ShaderDebug::FillViewFmt(DXGI_FORMAT_R32_UINT, srvData.format);
|
||||
DXBCDebug::FillViewFmt(DXGI_FORMAT_R32_UINT, srvData.format);
|
||||
srvData.firstElement = (uint32_t)(element.offset / sizeof(uint32_t));
|
||||
srvData.numElements = (uint32_t)((resDesc.Width - element.offset) / sizeof(uint32_t));
|
||||
|
||||
@@ -209,14 +209,14 @@ bool D3D12DebugAPIWrapper::FetchSRV(const ShaderDebug::BindingSlot &slot)
|
||||
desc += slot.shaderRegister - range.BaseShaderRegister;
|
||||
if(desc)
|
||||
{
|
||||
ShaderDebug::GlobalState::SRVData &srvData = m_globalState.srvs[slot];
|
||||
DXBCDebug::GlobalState::SRVData &srvData = m_globalState.srvs[slot];
|
||||
ResourceId srvId = desc->GetResResourceId();
|
||||
ID3D12Resource *pResource = rm->GetCurrentAs<ID3D12Resource>(srvId);
|
||||
|
||||
D3D12_SHADER_RESOURCE_VIEW_DESC srvDesc = desc->GetSRV();
|
||||
if(srvDesc.Format != DXGI_FORMAT_UNKNOWN)
|
||||
{
|
||||
ShaderDebug::FillViewFmt(srvDesc.Format, srvData.format);
|
||||
DXBCDebug::FillViewFmt(srvDesc.Format, srvData.format);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -227,8 +227,8 @@ bool D3D12DebugAPIWrapper::FetchSRV(const ShaderDebug::BindingSlot &slot)
|
||||
|
||||
// If we didn't get a type from the SRV description, try to pull it from the
|
||||
// shader reflection info
|
||||
ShaderDebug::LookupSRVFormatFromShaderReflection(*m_dxbc->GetReflection(), slot,
|
||||
srvData.format);
|
||||
DXBCDebug::LookupSRVFormatFromShaderReflection(*m_dxbc->GetReflection(), slot,
|
||||
srvData.format);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -252,7 +252,7 @@ bool D3D12DebugAPIWrapper::FetchSRV(const ShaderDebug::BindingSlot &slot)
|
||||
|
||||
return false;
|
||||
}
|
||||
bool D3D12DebugAPIWrapper::FetchUAV(const ShaderDebug::BindingSlot &slot)
|
||||
bool D3D12DebugAPIWrapper::FetchUAV(const DXBCDebug::BindingSlot &slot)
|
||||
{
|
||||
D3D12RenderState &rs = m_pDevice->GetQueue()->GetCommandData()->m_RenderState;
|
||||
D3D12ResourceManager *rm = m_pDevice->GetResourceManager();
|
||||
@@ -292,11 +292,11 @@ bool D3D12DebugAPIWrapper::FetchUAV(const ShaderDebug::BindingSlot &slot)
|
||||
ID3D12Resource *pResource = rm->GetCurrentAs<ID3D12Resource>(element.id);
|
||||
D3D12_RESOURCE_DESC resDesc = pResource->GetDesc();
|
||||
|
||||
ShaderDebug::GlobalState::UAVData &uavData = m_globalState.uavs[slot];
|
||||
DXBCDebug::GlobalState::UAVData &uavData = m_globalState.uavs[slot];
|
||||
|
||||
// TODO: Root buffers can be 32-bit UINT/SINT/FLOAT. Using UINT for now, but the
|
||||
// resource desc format or the DXBC reflection info might be more correct.
|
||||
ShaderDebug::FillViewFmt(DXGI_FORMAT_R32_UINT, uavData.format);
|
||||
DXBCDebug::FillViewFmt(DXGI_FORMAT_R32_UINT, uavData.format);
|
||||
uavData.firstElement = (uint32_t)(element.offset / sizeof(uint32_t));
|
||||
uavData.numElements = (uint32_t)((resDesc.Width - element.offset) / sizeof(uint32_t));
|
||||
|
||||
@@ -350,7 +350,7 @@ bool D3D12DebugAPIWrapper::FetchUAV(const ShaderDebug::BindingSlot &slot)
|
||||
desc += slot.shaderRegister - range.BaseShaderRegister;
|
||||
if(desc)
|
||||
{
|
||||
ShaderDebug::GlobalState::UAVData &uavData = m_globalState.uavs[slot];
|
||||
DXBCDebug::GlobalState::UAVData &uavData = m_globalState.uavs[slot];
|
||||
ResourceId uavId = desc->GetResResourceId();
|
||||
ID3D12Resource *pResource = rm->GetCurrentAs<ID3D12Resource>(uavId);
|
||||
|
||||
@@ -359,7 +359,7 @@ bool D3D12DebugAPIWrapper::FetchUAV(const ShaderDebug::BindingSlot &slot)
|
||||
D3D12_UNORDERED_ACCESS_VIEW_DESC uavDesc = desc->GetUAV();
|
||||
if(uavDesc.Format != DXGI_FORMAT_UNKNOWN)
|
||||
{
|
||||
ShaderDebug::FillViewFmt(uavDesc.Format, uavData.format);
|
||||
DXBCDebug::FillViewFmt(uavDesc.Format, uavData.format);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -484,10 +484,10 @@ ShaderVariable D3D12DebugAPIWrapper::GetResourceInfo(DXBCBytecode::OperandType t
|
||||
}
|
||||
|
||||
bool D3D12DebugAPIWrapper::CalculateSampleGather(
|
||||
DXBCBytecode::OpcodeType opcode, ShaderDebug::SampleGatherResourceData resourceData,
|
||||
ShaderDebug::SampleGatherSamplerData samplerData, ShaderVariable uv, ShaderVariable ddxCalc,
|
||||
DXBCBytecode::OpcodeType opcode, DXBCDebug::SampleGatherResourceData resourceData,
|
||||
DXBCDebug::SampleGatherSamplerData samplerData, ShaderVariable uv, ShaderVariable ddxCalc,
|
||||
ShaderVariable ddyCalc, const int texelOffsets[3], int multisampleIndex,
|
||||
float lodOrCompareValue, const uint8_t swizzle[4], ShaderDebug::GatherChannel gatherChannel,
|
||||
float lodOrCompareValue, const uint8_t swizzle[4], DXBCDebug::GatherChannel gatherChannel,
|
||||
const char *opString, ShaderVariable &output)
|
||||
{
|
||||
using namespace DXBCBytecode;
|
||||
@@ -745,10 +745,10 @@ bool D3D12DebugAPIWrapper::CalculateSampleGather(
|
||||
rdcstr strGatherChannel;
|
||||
switch(gatherChannel)
|
||||
{
|
||||
case ShaderDebug::GatherChannel::Red: strGatherChannel = "Red"; break;
|
||||
case ShaderDebug::GatherChannel::Green: strGatherChannel = "Green"; break;
|
||||
case ShaderDebug::GatherChannel::Blue: strGatherChannel = "Blue"; break;
|
||||
case ShaderDebug::GatherChannel::Alpha: strGatherChannel = "Alpha"; break;
|
||||
case DXBCDebug::GatherChannel::Red: strGatherChannel = "Red"; break;
|
||||
case DXBCDebug::GatherChannel::Green: strGatherChannel = "Green"; break;
|
||||
case DXBCDebug::GatherChannel::Blue: strGatherChannel = "Blue"; break;
|
||||
case DXBCDebug::GatherChannel::Alpha: strGatherChannel = "Alpha"; break;
|
||||
}
|
||||
|
||||
rdcstr vsProgram = "float4 main(uint id : SV_VertexID) : SV_Position {\n";
|
||||
@@ -1053,8 +1053,8 @@ void GatherConstantBuffers(WrappedID3D12Device *pDevice, const DXBCBytecode::Pro
|
||||
if(rootSigParam.ParameterType == D3D12_ROOT_PARAMETER_TYPE_32BIT_CONSTANTS &&
|
||||
element.type == eRootConst)
|
||||
{
|
||||
ShaderDebug::BindingSlot slot(rootSigParam.Constants.ShaderRegister,
|
||||
rootSigParam.Constants.RegisterSpace);
|
||||
DXBCDebug::BindingSlot slot(rootSigParam.Constants.ShaderRegister,
|
||||
rootSigParam.Constants.RegisterSpace);
|
||||
UINT sizeBytes = sizeof(uint32_t) * RDCMIN(rootSigParam.Constants.Num32BitValues,
|
||||
(UINT)element.constants.size());
|
||||
bytebuf cbufData((const byte *)element.constants.data(), sizeBytes);
|
||||
@@ -1062,8 +1062,8 @@ void GatherConstantBuffers(WrappedID3D12Device *pDevice, const DXBCBytecode::Pro
|
||||
}
|
||||
else if(rootSigParam.ParameterType == D3D12_ROOT_PARAMETER_TYPE_CBV && element.type == eRootCBV)
|
||||
{
|
||||
ShaderDebug::BindingSlot slot(rootSigParam.Descriptor.ShaderRegister,
|
||||
rootSigParam.Descriptor.RegisterSpace);
|
||||
DXBCDebug::BindingSlot slot(rootSigParam.Descriptor.ShaderRegister,
|
||||
rootSigParam.Descriptor.RegisterSpace);
|
||||
ID3D12Resource *cbv = pDevice->GetResourceManager()->GetCurrentAs<ID3D12Resource>(element.id);
|
||||
bytebuf cbufData;
|
||||
pDevice->GetDebugManager()->GetBufferData(cbv, element.offset, 0, cbufData);
|
||||
@@ -1107,7 +1107,7 @@ void GatherConstantBuffers(WrappedID3D12Device *pDevice, const DXBCBytecode::Pro
|
||||
if(range.RangeType != D3D12_DESCRIPTOR_RANGE_TYPE_CBV)
|
||||
continue;
|
||||
|
||||
ShaderDebug::BindingSlot slot(range.BaseShaderRegister, range.RegisterSpace);
|
||||
DXBCDebug::BindingSlot slot(range.BaseShaderRegister, range.RegisterSpace);
|
||||
|
||||
bytebuf cbufData;
|
||||
for(UINT n = 0; n < numDescriptors; ++n, ++slot.shaderRegister)
|
||||
@@ -1156,7 +1156,7 @@ ShaderDebugTrace D3D12Replay::DebugPixel(uint32_t eventId, uint32_t x, uint32_t
|
||||
{
|
||||
using namespace DXBC;
|
||||
using namespace DXBCBytecode;
|
||||
using namespace ShaderDebug;
|
||||
using namespace DXBCDebug;
|
||||
|
||||
D3D12MarkerRegion debugpixRegion(
|
||||
m_pDevice->GetQueue()->GetReal(),
|
||||
@@ -1216,9 +1216,9 @@ ShaderDebugTrace D3D12Replay::DebugPixel(uint32_t eventId, uint32_t x, uint32_t
|
||||
rdcstr extractHlsl;
|
||||
int structureStride = 0;
|
||||
|
||||
ShaderDebug::GatherPSInputDataForInitialValues(*dxbc->GetReflection(), *prevDxbc->GetReflection(),
|
||||
initialValues, floatInputs, inputVarNames,
|
||||
extractHlsl, structureStride);
|
||||
DXBCDebug::GatherPSInputDataForInitialValues(*dxbc->GetReflection(), *prevDxbc->GetReflection(),
|
||||
initialValues, floatInputs, inputVarNames,
|
||||
extractHlsl, structureStride);
|
||||
|
||||
uint32_t overdrawLevels = 100; // maximum number of overdraw levels
|
||||
|
||||
@@ -1823,7 +1823,7 @@ ShaderDebugTrace D3D12Replay::DebugThread(uint32_t eventId, const uint32_t group
|
||||
const uint32_t threadid[3])
|
||||
{
|
||||
using namespace DXBCBytecode;
|
||||
using namespace ShaderDebug;
|
||||
using namespace DXBCDebug;
|
||||
|
||||
D3D12MarkerRegion simloop(
|
||||
m_pDevice->GetQueue()->GetReal(),
|
||||
|
||||
@@ -34,7 +34,7 @@
|
||||
|
||||
using namespace DXBCBytecode;
|
||||
|
||||
namespace ShaderDebug
|
||||
namespace DXBCDebug
|
||||
{
|
||||
static float round_ne(float x)
|
||||
{
|
||||
@@ -2694,7 +2694,7 @@ State State::GetNext(GlobalState &global, DebugAPIWrapper *apiWrapper, State qua
|
||||
|
||||
case OPCODE_IMM_ATOMIC_ALLOC:
|
||||
{
|
||||
ShaderDebug::BindingSlot slot =
|
||||
BindingSlot slot =
|
||||
GetBindingSlotForIdentifier(*program, TYPE_UNORDERED_ACCESS_VIEW, srcOpers[0].value.u.x);
|
||||
GlobalState::UAVIterator uav = global.uavs.find(slot);
|
||||
if(uav == global.uavs.end())
|
||||
@@ -2714,7 +2714,7 @@ State State::GetNext(GlobalState &global, DebugAPIWrapper *apiWrapper, State qua
|
||||
|
||||
case OPCODE_IMM_ATOMIC_CONSUME:
|
||||
{
|
||||
ShaderDebug::BindingSlot slot =
|
||||
BindingSlot slot =
|
||||
GetBindingSlotForIdentifier(*program, TYPE_UNORDERED_ACCESS_VIEW, srcOpers[0].value.u.x);
|
||||
GlobalState::UAVIterator uav = global.uavs.find(slot);
|
||||
if(uav == global.uavs.end())
|
||||
@@ -2841,7 +2841,7 @@ State State::GetNext(GlobalState &global, DebugAPIWrapper *apiWrapper, State qua
|
||||
}
|
||||
else
|
||||
{
|
||||
ShaderDebug::BindingSlot slot =
|
||||
BindingSlot slot =
|
||||
GetBindingSlotForIdentifier(*program, TYPE_UNORDERED_ACCESS_VIEW, resIndex);
|
||||
GlobalState::UAVIterator uav = global.uavs.find(slot);
|
||||
if(uav == global.uavs.end())
|
||||
@@ -3093,7 +3093,7 @@ State State::GetNext(GlobalState &global, DebugAPIWrapper *apiWrapper, State qua
|
||||
}
|
||||
else
|
||||
{
|
||||
ShaderDebug::BindingSlot slot = GetBindingSlotForIdentifier(
|
||||
BindingSlot slot = GetBindingSlotForIdentifier(
|
||||
*program, srv ? TYPE_RESOURCE : TYPE_UNORDERED_ACCESS_VIEW, resIndex);
|
||||
|
||||
if(srv)
|
||||
@@ -3643,8 +3643,8 @@ State State::GetNext(GlobalState &global, DebugAPIWrapper *apiWrapper, State qua
|
||||
int sampleCount = 0;
|
||||
|
||||
// Default assumptions for bindings
|
||||
ShaderDebug::BindingSlot resourceBinding((uint32_t)op.operands[2].indices[0].index, 0);
|
||||
ShaderDebug::BindingSlot samplerBinding(0, 0);
|
||||
BindingSlot resourceBinding((uint32_t)op.operands[2].indices[0].index, 0);
|
||||
BindingSlot samplerBinding(0, 0);
|
||||
|
||||
for(size_t i = 0; i < program->GetNumDeclarations(); i++)
|
||||
{
|
||||
@@ -3654,7 +3654,7 @@ State State::GetNext(GlobalState &global, DebugAPIWrapper *apiWrapper, State qua
|
||||
op.operands[3].indices[0] == decl.operand.indices[0])
|
||||
{
|
||||
samplerMode = decl.samplerMode;
|
||||
samplerBinding = ShaderDebug::GetBindingSlotForDeclaration(*program, decl);
|
||||
samplerBinding = GetBindingSlotForDeclaration(*program, decl);
|
||||
}
|
||||
if(decl.dim == RESOURCE_DIMENSION_BUFFER && op.operation == OPCODE_LD &&
|
||||
decl.declaration == OPCODE_DCL_RESOURCE && decl.operand.type == TYPE_RESOURCE &&
|
||||
@@ -3662,7 +3662,7 @@ State State::GetNext(GlobalState &global, DebugAPIWrapper *apiWrapper, State qua
|
||||
{
|
||||
resourceDim = decl.dim;
|
||||
|
||||
resourceBinding = ShaderDebug::GetBindingSlotForDeclaration(*program, decl);
|
||||
resourceBinding = GetBindingSlotForDeclaration(*program, decl);
|
||||
GlobalState::SRVIterator srv = global.srvs.find(resourceBinding);
|
||||
if(srv == global.srvs.end())
|
||||
{
|
||||
@@ -3721,7 +3721,7 @@ State State::GetNext(GlobalState &global, DebugAPIWrapper *apiWrapper, State qua
|
||||
resourceRetType = decl.resType[0];
|
||||
sampleCount = decl.sampleCount;
|
||||
|
||||
resourceBinding = ShaderDebug::GetBindingSlotForDeclaration(*program, decl);
|
||||
resourceBinding = GetBindingSlotForDeclaration(*program, decl);
|
||||
|
||||
// doesn't seem like these are ever less than four components, even if the texture is
|
||||
// declared <float3> for example.
|
||||
@@ -4089,17 +4089,16 @@ State State::GetNext(GlobalState &global, DebugAPIWrapper *apiWrapper, State qua
|
||||
return s;
|
||||
}
|
||||
|
||||
ShaderDebug::BindingSlot GetBindingSlotForDeclaration(const Program &program,
|
||||
const DXBCBytecode::Declaration &decl)
|
||||
BindingSlot GetBindingSlotForDeclaration(const Program &program, const DXBCBytecode::Declaration &decl)
|
||||
{
|
||||
uint32_t baseRegister = program.IsShaderModel51() ? (uint32_t)decl.operand.indices[1].index
|
||||
: (uint32_t)decl.operand.indices[0].index;
|
||||
|
||||
return ShaderDebug::BindingSlot(baseRegister, decl.space);
|
||||
return BindingSlot(baseRegister, decl.space);
|
||||
}
|
||||
|
||||
ShaderDebug::BindingSlot GetBindingSlotForIdentifier(const Program &program, OperandType declType,
|
||||
uint32_t identifier)
|
||||
BindingSlot GetBindingSlotForIdentifier(const Program &program, OperandType declType,
|
||||
uint32_t identifier)
|
||||
{
|
||||
// A note on matching declarations: with SM 5.0 or lower, the declaration will have a single
|
||||
// operand index, which corresponds to the bound slot (e.g., t0 for a SRV). With SM 5.1, the
|
||||
@@ -4128,7 +4127,7 @@ ShaderDebug::BindingSlot GetBindingSlotForIdentifier(const Program &program, Ope
|
||||
RDCERR("Unable to find matching declaration for identifier %u", identifier);
|
||||
}
|
||||
|
||||
return ShaderDebug::BindingSlot(identifier, 0);
|
||||
return BindingSlot(identifier, 0);
|
||||
}
|
||||
|
||||
void GlobalState::PopulateGroupshared(const DXBCBytecode::Program *pBytecode)
|
||||
@@ -4163,12 +4162,11 @@ void GlobalState::PopulateGroupshared(const DXBCBytecode::Program *pBytecode)
|
||||
}
|
||||
}
|
||||
|
||||
void CreateShaderDebugStateAndTrace(ShaderDebug::State &initialState, ShaderDebugTrace &trace,
|
||||
int quadIdx, DXBC::DXBCContainer *dxbc,
|
||||
const ShaderReflection &refl,
|
||||
void CreateShaderDebugStateAndTrace(State &initialState, ShaderDebugTrace &trace, int quadIdx,
|
||||
DXBC::DXBCContainer *dxbc, const ShaderReflection &refl,
|
||||
const ShaderBindpointMapping &mapping)
|
||||
{
|
||||
initialState = ShaderDebug::State(quadIdx, &trace, dxbc->GetReflection(), dxbc->GetDXBCByteCode());
|
||||
initialState = State(quadIdx, &trace, dxbc->GetReflection(), dxbc->GetDXBCByteCode());
|
||||
|
||||
bool hasSourceMapping = dxbc->GetDebugInfo() && dxbc->GetDebugInfo()->HasSourceMapping();
|
||||
|
||||
@@ -4457,7 +4455,7 @@ void CreateShaderDebugStateAndTrace(ShaderDebug::State &initialState, ShaderDebu
|
||||
|
||||
void AddCBufferToDebugTrace(const DXBCBytecode::Program &program, ShaderDebugTrace &trace,
|
||||
const ShaderReflection &refl, const ShaderBindpointMapping &mapping,
|
||||
const ShaderDebug::BindingSlot &slot, bytebuf &cbufData)
|
||||
const BindingSlot &slot, bytebuf &cbufData)
|
||||
{
|
||||
// Find the identifier
|
||||
size_t numCBs = mapping.constantBlocks.size();
|
||||
@@ -4515,9 +4513,8 @@ bool PromptDebugTimeout(uint32_t cycleCounter)
|
||||
return false;
|
||||
}
|
||||
|
||||
void ApplyDerivatives(ShaderDebug::GlobalState &global, ShaderDebugTrace traces[4], int reg,
|
||||
int element, int numWords, float *data, float signmul, int32_t quadIdxA,
|
||||
int32_t quadIdxB)
|
||||
void ApplyDerivatives(GlobalState &global, ShaderDebugTrace traces[4], int reg, int element,
|
||||
int numWords, float *data, float signmul, int32_t quadIdxA, int32_t quadIdxB)
|
||||
{
|
||||
for(int w = 0; w < numWords; w++)
|
||||
{
|
||||
@@ -4542,7 +4539,7 @@ void ApplyDerivatives(ShaderDebug::GlobalState &global, ShaderDebugTrace traces[
|
||||
}
|
||||
}
|
||||
|
||||
void ApplyAllDerivatives(ShaderDebug::GlobalState &global, ShaderDebugTrace traces[4], int destIdx,
|
||||
void ApplyAllDerivatives(GlobalState &global, ShaderDebugTrace traces[4], int destIdx,
|
||||
const rdcarray<PSInputElement> &initialValues, float *data)
|
||||
{
|
||||
// We make the assumption that the coarse derivatives are generated from (0,0) in the quad, and
|
||||
@@ -4702,8 +4699,7 @@ void FillViewFmt(DXGI_FORMAT format, GlobalState::ViewFmt &viewFmt)
|
||||
}
|
||||
|
||||
void LookupSRVFormatFromShaderReflection(const DXBC::Reflection &reflection,
|
||||
const ShaderDebug::BindingSlot &slot,
|
||||
GlobalState::ViewFmt &viewFmt)
|
||||
const BindingSlot &slot, GlobalState::ViewFmt &viewFmt)
|
||||
{
|
||||
for(const DXBC::ShaderInputBind &bind : reflection.SRVs)
|
||||
{
|
||||
@@ -5042,7 +5038,7 @@ void GatherPSInputDataForInitialValues(const DXBC::Reflection &psDxbc,
|
||||
#include <limits>
|
||||
#include "3rdparty/catch/catch.hpp"
|
||||
|
||||
using namespace ShaderDebug;
|
||||
using namespace DXBCDebug;
|
||||
|
||||
TEST_CASE("DXBC debugging helpers", "[program]")
|
||||
{
|
||||
|
||||
@@ -45,7 +45,7 @@ enum OperandType;
|
||||
class WrappedID3D11Device;
|
||||
enum DXGI_FORMAT;
|
||||
|
||||
namespace ShaderDebug
|
||||
namespace DXBCDebug
|
||||
{
|
||||
struct BindingSlot
|
||||
{
|
||||
@@ -64,11 +64,10 @@ struct BindingSlot
|
||||
uint32_t registerSpace;
|
||||
};
|
||||
|
||||
ShaderDebug::BindingSlot GetBindingSlotForDeclaration(const DXBCBytecode::Program &program,
|
||||
const DXBCBytecode::Declaration &decl);
|
||||
ShaderDebug::BindingSlot GetBindingSlotForIdentifier(const DXBCBytecode::Program &program,
|
||||
DXBCBytecode::OperandType declType,
|
||||
uint32_t identifier);
|
||||
BindingSlot GetBindingSlotForDeclaration(const DXBCBytecode::Program &program,
|
||||
const DXBCBytecode::Declaration &decl);
|
||||
BindingSlot GetBindingSlotForIdentifier(const DXBCBytecode::Program &program,
|
||||
DXBCBytecode::OperandType declType, uint32_t identifier);
|
||||
|
||||
struct GlobalState
|
||||
{
|
||||
@@ -200,11 +199,10 @@ struct PSInputElement
|
||||
bool included;
|
||||
};
|
||||
|
||||
void ApplyDerivatives(ShaderDebug::GlobalState &global, ShaderDebugTrace traces[4], int reg,
|
||||
int element, int numWords, float *data, float signmul, int32_t quadIdxA,
|
||||
int32_t quadIdxB);
|
||||
void ApplyDerivatives(GlobalState &global, ShaderDebugTrace traces[4], int reg, int element,
|
||||
int numWords, float *data, float signmul, int32_t quadIdxA, int32_t quadIdxB);
|
||||
|
||||
void ApplyAllDerivatives(ShaderDebug::GlobalState &global, ShaderDebugTrace traces[4], int destIdx,
|
||||
void ApplyAllDerivatives(GlobalState &global, ShaderDebugTrace traces[4], int destIdx,
|
||||
const rdcarray<PSInputElement> &initialValues, float *data);
|
||||
|
||||
void FlattenSingleVariable(uint32_t byteOffset, const rdcstr &basename, const ShaderVariable &v,
|
||||
@@ -213,8 +211,7 @@ void FlattenSingleVariable(uint32_t byteOffset, const rdcstr &basename, const Sh
|
||||
void FillViewFmt(DXGI_FORMAT format, GlobalState::ViewFmt &viewFmt);
|
||||
|
||||
void LookupSRVFormatFromShaderReflection(const DXBC::Reflection &reflection,
|
||||
const ShaderDebug::BindingSlot &slot,
|
||||
GlobalState::ViewFmt &viewFmt);
|
||||
const BindingSlot &slot, GlobalState::ViewFmt &viewFmt);
|
||||
|
||||
void GatherPSInputDataForInitialValues(const DXBC::Reflection &psDxbc,
|
||||
const DXBC::Reflection &prevStageDxbc,
|
||||
@@ -227,14 +224,14 @@ struct SampleGatherResourceData
|
||||
DXBCBytecode::ResourceDimension dim;
|
||||
DXBC::ResourceRetType retType;
|
||||
int sampleCount;
|
||||
ShaderDebug::BindingSlot binding;
|
||||
BindingSlot binding;
|
||||
};
|
||||
|
||||
struct SampleGatherSamplerData
|
||||
{
|
||||
DXBCBytecode::SamplerMode mode;
|
||||
float bias;
|
||||
ShaderDebug::BindingSlot binding;
|
||||
BindingSlot binding;
|
||||
};
|
||||
|
||||
enum class GatherChannel : uint8_t
|
||||
@@ -254,8 +251,8 @@ public:
|
||||
// During shader debugging, when a new resource is encountered, this will be called to fetch the
|
||||
// data on demand. Return true if the ShaderDebug::GlobalState data for the slot is populated,
|
||||
// return false if the resource cannot be found.
|
||||
virtual bool FetchSRV(const ShaderDebug::BindingSlot &slot) = 0;
|
||||
virtual bool FetchUAV(const ShaderDebug::BindingSlot &slot) = 0;
|
||||
virtual bool FetchSRV(const BindingSlot &slot) = 0;
|
||||
virtual bool FetchUAV(const BindingSlot &slot) = 0;
|
||||
|
||||
virtual bool CalculateMathIntrinsic(DXBCBytecode::OpcodeType opcode, const ShaderVariable &input,
|
||||
ShaderVariable &output1, ShaderVariable &output2) = 0;
|
||||
@@ -357,12 +354,11 @@ private:
|
||||
const ShaderDebugTrace *trace;
|
||||
};
|
||||
|
||||
void CreateShaderDebugStateAndTrace(ShaderDebug::State &initialState, ShaderDebugTrace &trace,
|
||||
int quadIdx, DXBC::DXBCContainer *dxbc,
|
||||
const ShaderReflection &refl,
|
||||
void CreateShaderDebugStateAndTrace(State &initialState, ShaderDebugTrace &trace, int quadIdx,
|
||||
DXBC::DXBCContainer *dxbc, const ShaderReflection &refl,
|
||||
const ShaderBindpointMapping &mapping);
|
||||
void AddCBufferToDebugTrace(const DXBCBytecode::Program &program, ShaderDebugTrace &trace,
|
||||
const ShaderReflection &refl, const ShaderBindpointMapping &mapping,
|
||||
const ShaderDebug::BindingSlot &slot, bytebuf &cbufData);
|
||||
const BindingSlot &slot, bytebuf &cbufData);
|
||||
|
||||
}; // namespace ShaderDebug
|
||||
|
||||
Reference in New Issue
Block a user