Skip to content

Commit

Permalink
Dump root parameters, insted of descriptor heap
Browse files Browse the repository at this point in the history
1. Dumping SetGraphicsRootDescriptorTable or
   SetComputeRootDescriptorTable, instead of descripotr heap, is more
   straightfoward since drawcall use resources that are set by root
   desciptor tables.

2. If the target drawcall is dispatch, dump compute root descriptor
   table. If it's not, dump graphics.

3. Dump more descriptor type: sampler. rtv and dsv shouldn't be bind by
   root descriptor tables.

4. For CBV_SRV_UAV type, resources could be set the same index and the
   same heap of all three cbv, srv, and uav types. It needs root
   parameter types to identify it.

5. CaptureGPUAddrMatchDescriptorHeap find the index of the heap for
   the address of roopt descriptor tables. Use the index to find the
   view in the map in the heap.

   Not using MatchDescriptorCPUGPUHandle and for each to find the view
   any more. MatchDescriptorCPUGPUHandle has a bug to find a wrong view.

6. Similar to No. 5. RelayCPUAddrMatchDescriptorHeap find the index of
   the heap for the address of rtvs and dsv. Use the index to find the
   view in the map in the heap.

7. Skip dump vertices, index, rtv and dsv if the taget drawcall isn't
   draw.
  • Loading branch information
locke-lunarg committed Nov 1, 2024
1 parent efc0a6c commit 4dbf259
Show file tree
Hide file tree
Showing 7 changed files with 1,412 additions and 562 deletions.
10 changes: 10 additions & 0 deletions framework/decode/custom_dx12_replay_commands.h
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,16 @@ struct CustomReplayPostCall<format::ApiCallId::ApiCall_ID3D12Device_CreateConsta
}
};

template <>
struct CustomReplayPostCall<format::ApiCallId::ApiCall_ID3D12Device_CreateSampler>
{
template <typename... Args>
static void Dispatch(Dx12ReplayConsumerBase* replay, Args... args)
{
replay->PostCall_ID3D12Device_CreateSampler(args...);
}
};

template <>
struct CustomReplayPostCall<format::ApiCallId::ApiCall_ID3D12Device_CreateShaderResourceView>
{
Expand Down
305 changes: 274 additions & 31 deletions framework/decode/dx12_browse_consumer.h

Large diffs are not rendered by default.

1,237 changes: 881 additions & 356 deletions framework/decode/dx12_dump_resources.cpp

Large diffs are not rendered by default.

44 changes: 44 additions & 0 deletions framework/decode/dx12_dump_resources.h
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,8 @@ enum class Dx12DumpResourceType : uint32_t
kCbv,
kExecuteIndirectArg,
kExecuteIndirectCount,
kGraphicsRootParameters,
kComputeRootParameters,
};

struct CopyResourceData
Expand Down Expand Up @@ -152,6 +154,17 @@ class Dx12DumpResourcesDelegate
virtual void BeginDumpResources(const std::string& filename, const TrackDumpResources& track_dump_resources) = 0;
virtual void DumpResource(CopyResourceDataPtr resource_data) = 0;
virtual void EndDumpResources() = 0;
virtual void WriteSingleData(const std::vector<std::pair<std::string, int32_t>>& json_path,
const std::string& key,
uint64_t value) = 0;
virtual void WriteSingleData(const std::vector<std::pair<std::string, int32_t>>& json_path,
const uint32_t index,
uint64_t value) = 0;
virtual void WriteSingleData(const std::vector<std::pair<std::string, int32_t>>& json_path,
const std::string& key,
const std::string& value) = 0;
virtual void WriteEmptyNode(const std::vector<std::pair<std::string, int32_t>>& json_path) = 0;
virtual void WriteNote(const std::vector<std::pair<std::string, int32_t>>& json_path, const std::string& value) = 0;
};

class DefaultDx12DumpResourcesDelegate : public Dx12DumpResourcesDelegate
Expand All @@ -163,6 +176,18 @@ class DefaultDx12DumpResourcesDelegate : public Dx12DumpResourcesDelegate
const TrackDumpResources& track_dump_resources) override;
virtual void DumpResource(CopyResourceDataPtr resource_data) override;
virtual void EndDumpResources() override;
virtual void WriteSingleData(const std::vector<std::pair<std::string, int32_t>>& json_path,
const std::string& key,
uint64_t value) override;
virtual void WriteSingleData(const std::vector<std::pair<std::string, int32_t>>& json_path,
const uint32_t index,
uint64_t value) override;
virtual void WriteSingleData(const std::vector<std::pair<std::string, int32_t>>& json_path,
const std::string& key,
const std::string& value) override;
virtual void WriteEmptyNode(const std::vector<std::pair<std::string, int32_t>>& json_path) override;
virtual void WriteNote(const std::vector<std::pair<std::string, int32_t>>& json_path,
const std::string& value) override;

private:
void WriteResource(const CopyResourceDataPtr resource_data);
Expand All @@ -175,7 +200,10 @@ class DefaultDx12DumpResourcesDelegate : public Dx12DumpResourcesDelegate
void WriteBlockStart();
void WriteBlockEnd();

nlohmann::ordered_json* FindDrawCallJsonPath(const std::vector<std::pair<std::string, int32_t>>& json_path);

constexpr const char* NameDrawCall() const { return "draw_call"; }
constexpr const char* NameNotes() const { return "notes"; }

bool WriteBinaryFile(const std::string& filename, const std::vector<uint8_t>& data, uint64_t offset, uint64_t size);

Expand Down Expand Up @@ -247,6 +275,22 @@ class Dx12DumpResources
void FinishDump(DxObjectInfo* queue_object_info);
void CloseDump();

void WriteDescripotTable(DxObjectInfo* queue_object_info,
const std::vector<format::HandleId>& front_command_list_ids,
graphics::dx12::Dx12DumpResourcePos pos,
std::vector<std::pair<std::string, int32_t>> json_path,
const D3D12DescriptorHeapInfo* heap_info,
format::HandleId heap_id,
uint32_t heap_index,
const D3D12_DESCRIPTOR_RANGE1* range);

void WriteRootParameters(DxObjectInfo* queue_object_info,
const std::vector<format::HandleId>& front_command_list_ids,
graphics::dx12::Dx12DumpResourcePos pos,
Dx12DumpResourceType res_type,
const std::vector<format::HandleId>& descriptor_heap_ids,
const std::unordered_map<uint32_t, TrackRootParameter>& root_parameters);

void CopyDrawCallResources(DxObjectInfo* queue_object_info,
const std::vector<format::HandleId>& front_command_list_ids,
graphics::dx12::Dx12DumpResourcePos pos);
Expand Down
56 changes: 35 additions & 21 deletions framework/decode/dx12_object_info.h
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,6 @@ GFXRECON_BEGIN_NAMESPACE(decode)
constexpr size_t kNullCpuAddress = 0;
constexpr uint64_t kNullGpuAddress = 0;

typedef std::array<UINT, D3D12_DESCRIPTOR_HEAP_TYPE_NUM_TYPES> DescriptorIncrements;

enum class DxObjectInfoType : uint32_t
{
kUnused = 0,
Expand Down Expand Up @@ -286,49 +284,66 @@ struct D3D12DeviceInfo : DxObjectExtraInfo
bool is_uma{ false };
};

struct ConstantBufferInfo
// Constant Buffer View, Shader Resource View and Unordered Access View could overrride each other.
// So they should be in the one container.
struct DHConstantBufferViewInfo
{
D3D12_CONSTANT_BUFFER_VIEW_DESC captured_view{};
D3D12_CONSTANT_BUFFER_VIEW_DESC captured_desc{};
bool is_desc_null{ false };
D3D12_CPU_DESCRIPTOR_HANDLE replay_handle{ kNullCpuAddress };
};

struct ShaderResourceInfo
struct DHShaderResourceViewInfo
{
D3D12_SHADER_RESOURCE_VIEW_DESC desc{};
bool is_desc_null{ false };
format::HandleId resource_id{ format::kNullHandleId };
D3D12_SHADER_RESOURCE_VIEW_DESC view{};
bool is_view_null{ false };
D3D12_CPU_DESCRIPTOR_HANDLE replay_handle{ kNullCpuAddress };
std::vector<uint32_t> subresource_indices;
};

struct UnorderedAccessInfo
struct DHUnorderedAccessViewInfo
{
D3D12_UNORDERED_ACCESS_VIEW_DESC desc{};
bool is_desc_null{ false };
format::HandleId resource_id{ format::kNullHandleId };
format::HandleId counter_resource_id{ format::kNullHandleId };
D3D12_UNORDERED_ACCESS_VIEW_DESC view{};
bool is_view_null{ false };
D3D12_CPU_DESCRIPTOR_HANDLE replay_handle{ kNullCpuAddress };
std::vector<uint32_t> subresource_indices;
};

struct RenderTargetInfo
struct DHCbvSrvUavInfo
{
D3D12_DESCRIPTOR_RANGE_TYPE type{};
DHConstantBufferViewInfo cbv;
DHShaderResourceViewInfo srv;
DHUnorderedAccessViewInfo uav;
};

struct DHRenderTargetViewInfo
{
format::HandleId resource_id{ format::kNullHandleId };
D3D12_RENDER_TARGET_VIEW_DESC view{};
bool is_view_null{ false };
D3D12_RENDER_TARGET_VIEW_DESC desc{};
bool is_desc_null{ false };
D3D12_CPU_DESCRIPTOR_HANDLE replay_handle{ kNullCpuAddress };
std::vector<uint32_t> subresource_indices;
};

struct DepthStencilInfo
struct DHDepthStencilViewInfo
{
format::HandleId resource_id{ format::kNullHandleId };
D3D12_DEPTH_STENCIL_VIEW_DESC view{};
bool is_view_null{ false };
D3D12_DEPTH_STENCIL_VIEW_DESC desc{};
bool is_desc_null{ false };
D3D12_CPU_DESCRIPTOR_HANDLE replay_handle{ kNullCpuAddress };
std::vector<uint32_t> subresource_indices;
};

struct DHSamplerInfo
{
D3D12_SAMPLER_DESC desc{};
D3D12_CPU_DESCRIPTOR_HANDLE replay_handle{ kNullCpuAddress };
};

struct D3D12DescriptorHeapInfo : DxObjectExtraInfo
{
static constexpr DxObjectInfoType kType = DxObjectInfoType::kID3D12DescriptorHeapInfo;
Expand All @@ -344,11 +359,10 @@ struct D3D12DescriptorHeapInfo : DxObjectExtraInfo
uint64_t replay_gpu_addr_begin{ kNullGpuAddress };

// Descriptor info maps. Key is descriptor's uint32_t heap index.
std::map<uint32_t, ConstantBufferInfo> constant_buffer_infos;
std::map<uint32_t, ShaderResourceInfo> shader_resource_infos;
std::map<uint32_t, UnorderedAccessInfo> unordered_access_infos;
std::map<uint32_t, RenderTargetInfo> render_target_infos;
std::map<uint32_t, DepthStencilInfo> depth_stencil_infos;
std::map<uint32_t, DHCbvSrvUavInfo> cbv_srv_uav_infos;
std::map<uint32_t, DHRenderTargetViewInfo> rtv_infos;
std::map<uint32_t, DHDepthStencilViewInfo> dsv_infos;
std::map<uint32_t, DHSamplerInfo> sampler_infos;
};

struct D3D12FenceInfo : DxObjectExtraInfo
Expand Down
Loading

0 comments on commit 4dbf259

Please sign in to comment.