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

dx12 dump: Check duplicated notes #1889

Merged
merged 2 commits into from
Nov 27, 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
38 changes: 36 additions & 2 deletions framework/decode/dx12_dump_resources.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1038,7 +1038,7 @@ bool CaptureGPUAddrMatchDescriptorHeap(const D3D12_GPU_DESCRIPTOR_HANDLE capture
auto capture_gpu_addr_end = heap_info.capture_gpu_addr_begin + heap_info.descriptor_count * increment;

bool is_match = true ? (heap_info.capture_gpu_addr_begin <= capture_gpu_addr.ptr &&
capture_gpu_addr.ptr < capture_gpu_addr_end)
capture_gpu_addr.ptr <= capture_gpu_addr_end)
: false;
if (is_match)
{
Expand All @@ -1062,7 +1062,7 @@ bool ReplayCPUAddrMatchDescriptorHeap(const D3D12_CPU_DESCRIPTOR_HANDLE replay_c
auto replay_cpu_addr_end = heap_info.replay_cpu_addr_begin + heap_info.descriptor_count * increment;

bool is_match = true ? (heap_info.replay_cpu_addr_begin <= replay_cpu_addr.ptr &&
replay_cpu_addr.ptr < replay_cpu_addr_end)
replay_cpu_addr.ptr <= replay_cpu_addr_end)
: false;
if (is_match)
{
Expand Down Expand Up @@ -2416,9 +2416,43 @@ void DefaultDx12DumpResourcesDelegate::WriteSingleData(const std::vector<std::pa
util::FieldToJson((*jdata_node)[key], value, json_options_);
}

std::string GetJsonPathString(const std::vector<std::pair<std::string, int32_t>>& json_path)
{
std::string path_string;
for (const auto& path : json_path)
{
path_string += path.first;
path_string += "\\";
path_string += std::to_string(path.second);
path_string += "\\";
}
return path_string;
}

void DefaultDx12DumpResourcesDelegate::WriteNote(const std::vector<std::pair<std::string, int32_t>>& json_path,
const std::string& value)
{
auto path_string = GetJsonPathString(json_path);
auto notes_entry = notes_.find(path_string);
if (notes_entry == notes_.end())
{
std::set<std::string> notes;
notes.insert(value);
notes_[path_string] = notes;
}
else
{
auto note_entry = notes_entry->second.find(value);
if (note_entry == notes_entry->second.end())
{
notes_entry->second.insert(value);
}
else
{
// duplicate note, skip.
return;
}
}
auto* jdata_node = FindDrawCallJsonNode(json_path);
auto& jdata_notes = (*jdata_node)[NameNotes()];
auto size = jdata_notes.size();
Expand Down
4 changes: 4 additions & 0 deletions framework/decode/dx12_dump_resources.h
Original file line number Diff line number Diff line change
Expand Up @@ -246,6 +246,10 @@ class DefaultDx12DumpResourcesDelegate : public Dx12DumpResourcesDelegate
nlohmann::ordered_json draw_call_;
uint32_t num_objects_{ 0 };
uint32_t num_files_{ 0 };

// Record notes to avoid writing deplciate note.
// key: notes path. value: notes
std::unordered_map<std::string, std::set<std::string>> notes_;
};

// TODO: This class copys a lot of code to write json from VulkanExportJsonConsumerBase.
Expand Down