Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dump root parameters, insted of descriptor heap #1862

Merged
merged 3 commits into from
Nov 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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,749 changes: 1,360 additions & 389 deletions framework/decode/dx12_dump_resources.cpp

Large diffs are not rendered by default.

74 changes: 72 additions & 2 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,28 @@ 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 WriteNote(const std::vector<std::pair<std::string, int32_t>>& json_path, const std::string& value) = 0;
virtual void WriteRootParameterInfo(const std::vector<std::pair<std::string, int32_t>>& json_path,
uint32_t root_parameter_index,
const TrackRootParameter& root_parameter) = 0;
virtual void WriteNotFoundView(const std::vector<std::pair<std::string, int32_t>>& json_path,
format::HandleId heap_id,
uint32_t heap_index) = 0;
virtual void WriteNULLResource(const std::vector<std::pair<std::string, int32_t>>& json_path,
format::HandleId heap_id,
uint32_t heap_index) = 0;
virtual void WriteNULLBufferLocation(const std::vector<std::pair<std::string, int32_t>>& json_path,
format::HandleId heap_id,
uint32_t heap_index) = 0;
};

class DefaultDx12DumpResourcesDelegate : public Dx12DumpResourcesDelegate
Expand All @@ -163,6 +187,29 @@ 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 WriteNote(const std::vector<std::pair<std::string, int32_t>>& json_path,
const std::string& value) override;
virtual void WriteRootParameterInfo(const std::vector<std::pair<std::string, int32_t>>& json_path,
uint32_t root_parameter_index,
const TrackRootParameter& root_parameter) override;
virtual void WriteNotFoundView(const std::vector<std::pair<std::string, int32_t>>& json_path,
format::HandleId heap_id,
uint32_t heap_index) override;
virtual void WriteNULLResource(const std::vector<std::pair<std::string, int32_t>>& json_path,
format::HandleId heap_id,
uint32_t heap_index) override;
virtual void WriteNULLBufferLocation(const std::vector<std::pair<std::string, int32_t>>& json_path,
format::HandleId heap_id,
uint32_t heap_index) override;

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

nlohmann::ordered_json* FindDrawCallJsonNode(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 @@ -241,17 +291,37 @@ class Dx12DumpResources
StructPointerDecoder<Decoded_D3D12_RENDER_PASS_DEPTH_STENCIL_DESC>* pDepthStencil,
D3D12_RENDER_PASS_FLAGS Flags,
uint64_t block_index);
void GetDescriptorSubresourceIndices(DHShaderResourceViewInfo& info, const DxObjectInfo* resource);
void GetDescriptorSubresourceIndices(DHUnorderedAccessViewInfo& info, const DxObjectInfo* resource);
void GetDescriptorSubresourceIndices(DHRenderTargetViewInfo& info, const DxObjectInfo* resource);
void GetDescriptorSubresourceIndices(DHDepthStencilViewInfo& info, const DxObjectInfo* resource);

private:
void StartDump(ID3D12Device* device, const std::string& filename);
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);

void CopyDrawCallResourceByGPUVA(DxObjectInfo* queue_object_info,
bool CopyDrawCallResourceByGPUVA(DxObjectInfo* queue_object_info,
const std::vector<format::HandleId>& front_command_list_ids,
D3D12_GPU_VIRTUAL_ADDRESS capture_source_gpu_va,
uint64_t source_size,
Expand All @@ -261,7 +331,7 @@ class Dx12DumpResources
format::HandleId descriptor_heap_id,
uint32_t descriptor_heap_index);

void CopyDrawCallResourceBySubresource(DxObjectInfo* queue_object_info,
bool CopyDrawCallResourceBySubresource(DxObjectInfo* queue_object_info,
const std::vector<format::HandleId>& front_command_list_ids,
format::HandleId source_resource_id,
uint64_t source_offset,
Expand Down
64 changes: 39 additions & 25 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,47 +284,64 @@ 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
davidd-lunarg marked this conversation as resolved.
Show resolved Hide resolved
{
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;
std::vector<uint32_t> subresource_indices; // Only use for dump resources
};

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;
std::vector<uint32_t> subresource_indices; // Only use for dump resources
};

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

struct RenderTargetInfo
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;
std::vector<uint32_t> subresource_indices; // Only use for dump resources
};

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;
std::vector<uint32_t> subresource_indices; // Only use for dump resources
};

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

struct D3D12DescriptorHeapInfo : DxObjectExtraInfo
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
Loading