mirror of
https://github.com/baldurk/renderdoc.git
synced 2026-05-12 21:10:42 +00:00
DXIL Debugging D3D12APIWrapper
Includes minimum required helper structs/methods in DXILDebug
This commit is contained in:
File diff suppressed because it is too large
Load Diff
@@ -23,3 +23,55 @@
|
||||
******************************************************************************/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "driver/shaders/dxil/dxil_debug.h"
|
||||
#include "d3d12_device.h"
|
||||
#include "d3d12_shaderdebug.h"
|
||||
#include "d3d12_state.h"
|
||||
|
||||
namespace DXILDebug
|
||||
{
|
||||
class Debugger;
|
||||
|
||||
void FetchConstantBufferData(WrappedID3D12Device *device, const DXIL::Program *program,
|
||||
const D3D12RenderState::RootSignature &rootsig,
|
||||
const ShaderReflection &refl, DXILDebug::GlobalState &global,
|
||||
rdcarray<SourceVariableMapping> &sourceVars);
|
||||
|
||||
class D3D12APIWrapper : public DebugAPIWrapper
|
||||
{
|
||||
public:
|
||||
D3D12APIWrapper(WrappedID3D12Device *device, const DXBC::DXBCContainer *dxbcContainer,
|
||||
GlobalState &globalState, uint32_t eventId);
|
||||
~D3D12APIWrapper();
|
||||
|
||||
void FetchSRV(const BindingSlot &slot);
|
||||
void FetchUAV(const BindingSlot &slot);
|
||||
bool CalculateMathIntrinsic(DXIL::DXOp dxOp, const ShaderVariable &input, ShaderVariable &output);
|
||||
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],
|
||||
GatherChannel gatherChannel, DXBC::ShaderType shaderType,
|
||||
uint32_t instructionIdx, const char *opString, ShaderVariable &output);
|
||||
ShaderVariable GetResourceInfo(DXIL::ResourceClass resClass, const DXDebug::BindingSlot &slot,
|
||||
uint32_t mipLevel, const DXBC::ShaderType shaderType, int &dim);
|
||||
ShaderVariable GetSampleInfo(DXIL::ResourceClass resClass, const DXDebug::BindingSlot &slot,
|
||||
const DXBC::ShaderType shaderType, const char *opString);
|
||||
ShaderVariable GetRenderTargetSampleInfo(const DXBC::ShaderType shaderType, const char *opString);
|
||||
bool IsResourceBound(DXIL::ResourceClass resClass, const DXDebug::BindingSlot &slot);
|
||||
|
||||
private:
|
||||
bool IsSRVBound(const BindingSlot &slot);
|
||||
bool IsUAVBound(const BindingSlot &slot);
|
||||
|
||||
WrappedID3D12Device *m_Device;
|
||||
const DXBC::DXBCContainer *m_DXBC;
|
||||
GlobalState &m_GlobalState;
|
||||
DXBC::ShaderType m_ShaderType;
|
||||
const uint32_t m_EventId;
|
||||
bool m_DidReplay = false;
|
||||
};
|
||||
|
||||
};
|
||||
|
||||
@@ -26,6 +26,33 @@
|
||||
|
||||
#include "dxil_debug.h"
|
||||
|
||||
using namespace DXIL;
|
||||
using namespace DXDebug;
|
||||
|
||||
namespace DXILDebug
|
||||
{
|
||||
|
||||
// static helper function
|
||||
rdcstr Debugger::GetResourceReferenceName(const DXIL::Program *program,
|
||||
DXIL::ResourceClass resClass, const BindingSlot &slot)
|
||||
{
|
||||
RDCASSERT(program);
|
||||
for(const ResourceReference &resRef : program->m_ResourceReferences)
|
||||
{
|
||||
if(resRef.resourceBase.resClass != resClass)
|
||||
continue;
|
||||
if(resRef.resourceBase.space != slot.registerSpace)
|
||||
continue;
|
||||
if(resRef.resourceBase.regBase > slot.shaderRegister)
|
||||
continue;
|
||||
if(resRef.resourceBase.regBase + resRef.resourceBase.regCount < slot.shaderRegister)
|
||||
continue;
|
||||
|
||||
return program->GetHandleAlias(resRef.handleID);
|
||||
}
|
||||
RDCERR("Failed to find DXIL %s Resource Space %d Register %d", ToStr(resClass).c_str(),
|
||||
slot.registerSpace, slot.shaderRegister);
|
||||
return "UNKNOWN_RESOURCE_HANDLE";
|
||||
}
|
||||
|
||||
}; // namespace DXILDebug
|
||||
|
||||
@@ -30,32 +30,20 @@
|
||||
|
||||
namespace DXILDebug
|
||||
{
|
||||
typedef rdcstr Id;
|
||||
using namespace DXDebug;
|
||||
|
||||
typedef DXDebug::SampleGatherResourceData SampleGatherResourceData;
|
||||
typedef DXDebug::SampleGatherSamplerData SampleGatherSamplerData;
|
||||
typedef DXDebug::BindingSlot BindingSlot;
|
||||
typedef DXDebug::GatherChannel GatherChannel;
|
||||
typedef DXBCBytecode::SamplerMode SamplerMode;
|
||||
typedef DXBC::InterpolationMode InterpolationMode;
|
||||
|
||||
typedef uint32_t Id;
|
||||
class Debugger;
|
||||
struct GlobalState;
|
||||
struct BindingSlot
|
||||
{
|
||||
BindingSlot() : shaderRegister(UINT32_MAX), registerSpace(UINT32_MAX) {}
|
||||
BindingSlot(uint32_t shaderReg, uint32_t regSpace)
|
||||
: shaderRegister(shaderReg), registerSpace(regSpace)
|
||||
{
|
||||
}
|
||||
BindingSlot(const DXIL::ResourceReference &resRef)
|
||||
: shaderRegister(resRef.resourceBase.regBase), registerSpace(resRef.resourceBase.space)
|
||||
{
|
||||
}
|
||||
|
||||
bool operator<(const BindingSlot &o) const
|
||||
{
|
||||
if(registerSpace != o.registerSpace)
|
||||
return registerSpace < o.registerSpace;
|
||||
return shaderRegister < o.shaderRegister;
|
||||
}
|
||||
|
||||
uint32_t shaderRegister;
|
||||
uint32_t registerSpace;
|
||||
};
|
||||
|
||||
typedef std::map<ShaderBuiltin, ShaderVariable> BuiltinInputs;
|
||||
class DebugAPIWrapper
|
||||
{
|
||||
};
|
||||
@@ -67,12 +55,81 @@ struct ThreadState
|
||||
struct GlobalState
|
||||
{
|
||||
GlobalState() = default;
|
||||
BuiltinInputs builtinInputs;
|
||||
|
||||
struct ViewFmt
|
||||
{
|
||||
int byteWidth = 0;
|
||||
int numComps = 0;
|
||||
CompType fmt = CompType::Typeless;
|
||||
int stride = 0;
|
||||
|
||||
int Stride() const
|
||||
{
|
||||
if(stride != 0)
|
||||
return stride;
|
||||
|
||||
if(byteWidth == 10 || byteWidth == 11)
|
||||
return 4; // 10 10 10 2 or 11 11 10
|
||||
|
||||
return byteWidth * numComps;
|
||||
}
|
||||
};
|
||||
|
||||
struct UAVData
|
||||
{
|
||||
UAVData()
|
||||
: firstElement(0), numElements(0), tex(false), rowPitch(0), depthPitch(0), hiddenCounter(0)
|
||||
{
|
||||
}
|
||||
|
||||
bytebuf data;
|
||||
uint32_t firstElement;
|
||||
uint32_t numElements;
|
||||
|
||||
bool tex;
|
||||
uint32_t rowPitch, depthPitch;
|
||||
|
||||
ViewFmt format;
|
||||
|
||||
uint32_t hiddenCounter;
|
||||
};
|
||||
std::map<BindingSlot, UAVData> uavs;
|
||||
typedef std::map<BindingSlot, UAVData>::const_iterator UAVIterator;
|
||||
|
||||
struct SRVData
|
||||
{
|
||||
SRVData() : firstElement(0), numElements(0) {}
|
||||
bytebuf data;
|
||||
uint32_t firstElement;
|
||||
uint32_t numElements;
|
||||
|
||||
ViewFmt format;
|
||||
};
|
||||
|
||||
std::map<BindingSlot, SRVData> srvs;
|
||||
typedef std::map<BindingSlot, SRVData>::const_iterator SRVIterator;
|
||||
|
||||
// allocated storage for opaque uniform blocks, does not change over the course of debugging
|
||||
rdcarray<ShaderVariable> constantBlocks;
|
||||
|
||||
// workgroup private variables
|
||||
rdcarray<ShaderVariable> workgroups;
|
||||
|
||||
// resources may be read-write but the variable itself doesn't change
|
||||
rdcarray<ShaderVariable> readOnlyResources;
|
||||
rdcarray<ShaderVariable> readWriteResources;
|
||||
rdcarray<ShaderVariable> samplers;
|
||||
// Globals across workgroups including inputs (immutable) and outputs (mutable)
|
||||
rdcarray<ShaderVariable> globals;
|
||||
};
|
||||
|
||||
class Debugger : public DXBCContainerDebugger
|
||||
{
|
||||
public:
|
||||
Debugger() : DXBCContainerDebugger(true){};
|
||||
static rdcstr GetResourceReferenceName(const DXIL::Program *program, DXIL::ResourceClass resClass,
|
||||
const BindingSlot &slot);
|
||||
};
|
||||
|
||||
}; // namespace DXILDebug
|
||||
|
||||
Reference in New Issue
Block a user