Devtools - Inspect regs/User data/Shader disassembly (#1358)

* devtools: pm4 - show markers

* SaveDataDialogLib: fix compile with mingw

* devtools: pm4 - show program state

* devtools: pm4 - show program disassembly

* devtools: pm4 - show frame regs

* devtools: pm4 - show color buffer info as popup

add ux improvements for open new windows with shift+click
better window titles

* imgui: skip all textures to avoid hanging with crash diagnostic enabled

not sure why this happens :c

* devtools: pm4 - show reg depth buffer
This commit is contained in:
Vinicius Rangel 2024-10-13 09:02:22 -03:00 committed by GitHub
parent 8776eba8c8
commit cf2e617f08
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
27 changed files with 4215 additions and 287 deletions

View file

@ -1,13 +1,16 @@
// SPDX-FileCopyrightText: Copyright 2024 shadPS4 Emulator Project
// SPDX-License-Identifier: GPL-2.0-or-later
#include <imgui.h>
#include "common/assert.h"
#include "common/native_clock.h"
#include "common/singleton.h"
#include "debug_state.h"
#include "libraries/kernel/event_queues.h"
#include "devtools/widget/common.h"
#include "libraries/kernel/time_management.h"
#include "libraries/system/msgdialog.h"
#include "video_core/amdgpu/pm4_cmds.h"
using namespace DebugStateType;
@ -95,8 +98,68 @@ void DebugStateImpl::ResumeGuestThreads() {
}
void DebugStateImpl::RequestFrameDump(s32 count) {
ASSERT(!DumpingCurrentFrame());
gnm_frame_dump_request_count = count;
frame_dump_list.clear();
frame_dump_list.resize(count);
waiting_submit_pause = true;
}
void DebugStateImpl::PushQueueDump(QueueDump dump) {
ASSERT(DumpingCurrentFrame());
std::unique_lock lock{frame_dump_list_mutex};
auto& frame = GetFrameDump();
{ // Find draw calls
auto data = std::span{dump.data};
auto initial_data = data.data();
while (!data.empty()) {
const auto* header = reinterpret_cast<const AmdGpu::PM4Type3Header*>(data.data());
const auto type = header->type;
if (type == 2) {
data = data.subspan(1);
} else if (type != 3) {
UNREACHABLE();
}
const AmdGpu::PM4ItOpcode opcode = header->opcode;
if (Core::Devtools::Widget::IsDrawCall(opcode)) {
const auto offset =
reinterpret_cast<uintptr_t>(header) - reinterpret_cast<uintptr_t>(initial_data);
const auto addr = dump.base_addr + offset;
waiting_reg_dumps.emplace(addr, &frame);
waiting_reg_dumps_dbg.emplace(
addr,
fmt::format("#{} h({}) queue {} {} {}",
frame_dump_list.size() - gnm_frame_dump_request_count, addr,
magic_enum::enum_name(dump.type), dump.submit_num, dump.num2));
}
data = data.subspan(header->NumWords() + 1);
}
}
frame.queues.push_back(std::move(dump));
}
void DebugStateImpl::PushRegsDump(uintptr_t base_addr, uintptr_t header_addr,
const AmdGpu::Liverpool::Regs& regs) {
std::scoped_lock lock{frame_dump_list_mutex};
const auto it = waiting_reg_dumps.find(header_addr);
if (it == waiting_reg_dumps.end()) {
return;
}
auto& frame = *it->second;
waiting_reg_dumps.erase(it);
waiting_reg_dumps_dbg.erase(waiting_reg_dumps_dbg.find(header_addr));
auto& dump = frame.regs[header_addr - base_addr];
dump.regs = regs;
for (int i = 0; i < RegDump::MaxShaderStages; i++) {
if (regs.stage_enable.IsStageEnabled(i)) {
auto stage = regs.ProgramForStage(i);
if (stage->address_lo != 0) {
auto code = stage->Code();
dump.stages[i] = ShaderDump{
.user_data = *stage,
.code = std::vector<u32>{code.begin(), code.end()},
};
}
}
}
}