mirror of
https://github.com/shadps4-emu/shadPS4.git
synced 2025-08-04 08:22:32 +00:00
devtools: pm4 - show reg depth buffer
This commit is contained in:
parent
87ecb87674
commit
395ac5dda9
@ -121,14 +121,7 @@ void DebugStateImpl::PushQueueDump(QueueDump dump) {
|
||||
UNREACHABLE();
|
||||
}
|
||||
const AmdGpu::PM4ItOpcode opcode = header->opcode;
|
||||
switch (opcode) {
|
||||
case AmdGpu::PM4ItOpcode::DrawIndex2:
|
||||
case AmdGpu::PM4ItOpcode::DrawIndexOffset2:
|
||||
case AmdGpu::PM4ItOpcode::DrawIndexAuto:
|
||||
case AmdGpu::PM4ItOpcode::DrawIndirect:
|
||||
case AmdGpu::PM4ItOpcode::DrawIndexIndirect:
|
||||
case AmdGpu::PM4ItOpcode::DispatchDirect:
|
||||
case AmdGpu::PM4ItOpcode::DispatchIndirect: {
|
||||
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;
|
||||
@ -138,9 +131,6 @@ void DebugStateImpl::PushQueueDump(QueueDump dump) {
|
||||
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));
|
||||
} break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
data = data.subspan(header->NumWords() + 1);
|
||||
}
|
||||
|
@ -63,21 +63,6 @@ static HdrType GetNext(HdrType this_pm4, uint32_t n) {
|
||||
return curr_pm4;
|
||||
}
|
||||
|
||||
static bool IsDrawCall(AmdGpu::PM4ItOpcode opcode) {
|
||||
using AmdGpu::PM4ItOpcode;
|
||||
switch (opcode) {
|
||||
case PM4ItOpcode::DispatchDirect:
|
||||
case PM4ItOpcode::DispatchIndirect:
|
||||
case PM4ItOpcode::DrawIndex2:
|
||||
case PM4ItOpcode::DrawIndexAuto:
|
||||
case PM4ItOpcode::DrawIndexOffset2:
|
||||
case PM4ItOpcode::DrawIndexIndirect:
|
||||
return true;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
void ParsePolygonControl(u32 value, bool begin_table) {
|
||||
auto const reg = reinterpret_cast<AmdGpu::Liverpool::PolygonControl const&>(value);
|
||||
|
||||
@ -1302,11 +1287,14 @@ void CmdListViewer::Draw() {
|
||||
if (batch.type == static_cast<AmdGpu::PM4ItOpcode>(0xFF)) {
|
||||
snprintf(batch_hdr, sizeof(batch_hdr), "State batch");
|
||||
} else if (!batch.marker.empty()) {
|
||||
snprintf(batch_hdr, sizeof(batch_hdr), "%08llX: batch-%03d | %s",
|
||||
cmdb_addr + batch.start_addr, batch.id, batch.marker.c_str());
|
||||
snprintf(batch_hdr, sizeof(batch_hdr), "%08llX: batch-%03d %s | %s",
|
||||
cmdb_addr + batch.start_addr, batch.id,
|
||||
Gcn::GetOpCodeName(static_cast<u32>(batch.type)),
|
||||
batch.marker.c_str());
|
||||
} else {
|
||||
snprintf(batch_hdr, sizeof(batch_hdr), "%08llX: batch-%03d",
|
||||
cmdb_addr + batch.start_addr, batch.id);
|
||||
snprintf(batch_hdr, sizeof(batch_hdr), "%08llX: batch-%03d %s",
|
||||
cmdb_addr + batch.start_addr, batch.id,
|
||||
Gcn::GetOpCodeName(static_cast<u32>(batch.type)));
|
||||
}
|
||||
|
||||
if (batch.id == batch_bp) { // highlight batch at breakpoint
|
||||
|
@ -6,6 +6,8 @@
|
||||
#include <string>
|
||||
#include <variant>
|
||||
|
||||
#include <magic_enum.hpp>
|
||||
|
||||
#include "common/types.h"
|
||||
#include "video_core/amdgpu/pm4_opcodes.h"
|
||||
|
||||
@ -55,6 +57,11 @@ void DrawRow(const char* text, const char* fmt, Args... args) {
|
||||
ImGui::TextUnformatted(buf);
|
||||
}
|
||||
|
||||
template <typename T, typename V = u32>
|
||||
void DrawEnumRow(const char* text, T value) {
|
||||
DrawRow(text, "%X (%s)", V(value), magic_enum::enum_name(value).data());
|
||||
}
|
||||
|
||||
template <typename V, typename... Extra>
|
||||
void DrawMultipleRow(const char* text, const char* fmt, V arg, Extra&&... extra_args) {
|
||||
DrawRow(text, fmt, arg);
|
||||
@ -74,4 +81,20 @@ static void DoTooltip(const char* str_id, Args&&... args) {
|
||||
}
|
||||
}
|
||||
|
||||
static bool IsDrawCall(AmdGpu::PM4ItOpcode opcode) {
|
||||
using AmdGpu::PM4ItOpcode;
|
||||
switch (opcode) {
|
||||
case PM4ItOpcode::DrawIndex2:
|
||||
case PM4ItOpcode::DrawIndexOffset2:
|
||||
case PM4ItOpcode::DrawIndexAuto:
|
||||
case PM4ItOpcode::DrawIndirect:
|
||||
case PM4ItOpcode::DrawIndexIndirect:
|
||||
case PM4ItOpcode::DispatchDirect:
|
||||
case PM4ItOpcode::DispatchIndirect:
|
||||
return true;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace Core::Devtools::Widget
|
@ -70,9 +70,9 @@ void RegPopup::DrawColorBuffer(const AmdGpu::Liverpool::ColorBuffer& buffer) {
|
||||
|
||||
auto tiling_mode = buffer.GetTilingMode();
|
||||
auto num_format = buffer.NumFormat();
|
||||
DrawRow("GetTilingMode()", "%X (%s)", tiling_mode, enum_name(tiling_mode).data());
|
||||
DrawRow("IsTiled()", "%X", buffer.IsTiled());
|
||||
DrawRow("NumFormat()", "%X (%s)", num_format, enum_name(num_format).data());
|
||||
DrawEnumRow("GetTilingMode()", tiling_mode);
|
||||
DrawRow("IsTiled()", "%X", buffer.IsTiled());
|
||||
DrawEnumRow("NumFormat()", num_format);
|
||||
|
||||
// clang-format on
|
||||
|
||||
@ -80,6 +80,73 @@ void RegPopup::DrawColorBuffer(const AmdGpu::Liverpool::ColorBuffer& buffer) {
|
||||
}
|
||||
}
|
||||
|
||||
void RegPopup::DrawDepthBuffer(const DepthBuffer& depth_data) {
|
||||
const auto& [depth_buffer, depth_control] = depth_data;
|
||||
|
||||
SeparatorText("Depth buffer");
|
||||
|
||||
if (BeginTable("DEPTH_BUFFER", 2, ImGuiTableFlags_Borders)) {
|
||||
TableNextRow();
|
||||
|
||||
// clang-format off
|
||||
DrawEnumRow("Z_INFO.FORMAT", depth_buffer.z_info.format.Value());
|
||||
DrawMultipleRow(
|
||||
"Z_INFO.NUM_SAMPLES", "%X", depth_buffer.z_info.num_samples,
|
||||
"Z_INFO.TILE_SPLIT", "%X", depth_buffer.z_info.tile_split,
|
||||
"Z_INFO.TILE_MODE_INDEX", "%X", depth_buffer.z_info.tile_mode_index,
|
||||
"Z_INFO.DECOMPRESS_ON_N_ZPLANES", "%X", depth_buffer.z_info.decompress_on_n_zplanes,
|
||||
"Z_INFO.ALLOW_EXPCLEAR", "%X", depth_buffer.z_info.allow_expclear,
|
||||
"Z_INFO.READ_SIZE", "%X", depth_buffer.z_info.read_size,
|
||||
"Z_INFO.TILE_SURFACE_EN", "%X", depth_buffer.z_info.tile_surface_en,
|
||||
"Z_INFO.CLEAR_DISALLOWED", "%X", depth_buffer.z_info.clear_disallowed,
|
||||
"Z_INFO.ZRANGE_PRECISION", "%X", depth_buffer.z_info.zrange_precision
|
||||
);
|
||||
|
||||
DrawEnumRow("STENCIL_INFO.FORMAT", depth_buffer.stencil_info.format.Value());
|
||||
|
||||
DrawMultipleRow(
|
||||
"Z_READ_BASE", "%X", depth_buffer.z_read_base,
|
||||
"STENCIL_READ_BASE", "%X", depth_buffer.stencil_read_base,
|
||||
"Z_WRITE_BASE", "%X", depth_buffer.z_write_base,
|
||||
"STENCIL_WRITE_BASE", "%X", depth_buffer.stencil_write_base,
|
||||
"DEPTH_SIZE.PITCH_TILE_MAX", "%X", depth_buffer.depth_size.pitch_tile_max,
|
||||
"DEPTH_SIZE.HEIGHT_TILE_MAX", "%X", depth_buffer.depth_size.height_tile_max,
|
||||
"DEPTH_SLICE.TILE_MAX", "%X", depth_buffer.depth_slice.tile_max,
|
||||
"Pitch()", "%X", depth_buffer.Pitch(),
|
||||
"Height()", "%X", depth_buffer.Height(),
|
||||
"Address()", "%X", depth_buffer.Address(),
|
||||
"NumSamples()", "%X", depth_buffer.NumSamples(),
|
||||
"NumBits()", "%X", depth_buffer.NumBits(),
|
||||
"GetDepthSliceSize()", "%X", depth_buffer.GetDepthSliceSize()
|
||||
);
|
||||
// clang-format on
|
||||
EndTable();
|
||||
}
|
||||
SeparatorText("Depth control");
|
||||
if (BeginTable("DEPTH_CONTROL", 2, ImGuiTableFlags_Borders)) {
|
||||
TableNextRow();
|
||||
|
||||
// clang-format off
|
||||
DrawMultipleRow(
|
||||
"STENCIL_ENABLE", "%X", depth_control.stencil_enable,
|
||||
"DEPTH_ENABLE", "%X", depth_control.depth_enable,
|
||||
"DEPTH_WRITE_ENABLE", "%X", depth_control.depth_write_enable,
|
||||
"DEPTH_BOUNDS_ENABLE", "%X", depth_control.depth_bounds_enable
|
||||
);
|
||||
DrawEnumRow("DEPTH_FUNC", depth_control.depth_func.Value());
|
||||
DrawRow("BACKFACE_ENABLE", "%X", depth_control.backface_enable);
|
||||
DrawEnumRow("STENCIL_FUNC", depth_control.stencil_ref_func.Value());
|
||||
DrawEnumRow("STENCIL_FUNC_BF", depth_control.stencil_bf_func.Value());
|
||||
DrawMultipleRow(
|
||||
"ENABLE_COLOR_WRITES_ON_DEPTH_FAIL", "%X", depth_control.enable_color_writes_on_depth_fail,
|
||||
"DISABLE_COLOR_WRITES_ON_DEPTH_PASS", "%X", depth_control.disable_color_writes_on_depth_pass
|
||||
);
|
||||
// clang-format on
|
||||
|
||||
EndTable();
|
||||
}
|
||||
}
|
||||
|
||||
RegPopup::RegPopup() {
|
||||
static int unique_id = 0;
|
||||
id = unique_id++;
|
||||
@ -90,6 +157,12 @@ void RegPopup::SetData(AmdGpu::Liverpool::ColorBuffer color_buffer, u32 batch_id
|
||||
this->title = fmt::format("Batch #{} CB #{}", batch_id, cb_id);
|
||||
}
|
||||
|
||||
void RegPopup::SetData(AmdGpu::Liverpool::DepthBuffer depth_buffer,
|
||||
AmdGpu::Liverpool::DepthControl depth_control, u32 batch_id) {
|
||||
this->data = std::make_tuple(depth_buffer, depth_control);
|
||||
this->title = fmt::format("Batch #{} Depth", batch_id);
|
||||
}
|
||||
|
||||
void RegPopup::Draw() {
|
||||
|
||||
char name[128];
|
||||
@ -99,6 +172,8 @@ void RegPopup::Draw() {
|
||||
if (Begin(name, &open, ImGuiWindowFlags_NoSavedSettings)) {
|
||||
if (const auto* buffer = std::get_if<AmdGpu::Liverpool::ColorBuffer>(&data)) {
|
||||
DrawColorBuffer(*buffer);
|
||||
} else if (const auto* depth_data = std::get_if<DepthBuffer>(&data)) {
|
||||
DrawDepthBuffer(*depth_data);
|
||||
}
|
||||
}
|
||||
End();
|
||||
|
@ -13,11 +13,15 @@ namespace Core::Devtools::Widget {
|
||||
class RegPopup {
|
||||
int id;
|
||||
|
||||
std::variant<AmdGpu::Liverpool::ColorBuffer> data;
|
||||
using DepthBuffer = std::tuple<AmdGpu::Liverpool::DepthBuffer, AmdGpu::Liverpool::DepthControl>;
|
||||
|
||||
std::variant<AmdGpu::Liverpool::ColorBuffer, DepthBuffer> data;
|
||||
std::string title{};
|
||||
|
||||
void DrawColorBuffer(const AmdGpu::Liverpool::ColorBuffer& buffer);
|
||||
|
||||
void DrawDepthBuffer(const DepthBuffer& depth_data);
|
||||
|
||||
public:
|
||||
bool open = false;
|
||||
|
||||
@ -25,6 +29,9 @@ public:
|
||||
|
||||
void SetData(AmdGpu::Liverpool::ColorBuffer color_buffer, u32 batch_id, u32 cb_id);
|
||||
|
||||
void SetData(AmdGpu::Liverpool::DepthBuffer depth_buffer,
|
||||
AmdGpu::Liverpool::DepthControl depth_control, u32 batch_id);
|
||||
|
||||
void Draw();
|
||||
};
|
||||
|
||||
|
@ -107,6 +107,26 @@ void RegView::DrawRegs() {
|
||||
auto cc_mode = regs.color_control.mode.Value();
|
||||
DrawRow("Color control", "%X (%s)", cc_mode, enum_name(cc_mode).data());
|
||||
|
||||
const auto open_new_popup = [&](int cb, auto... args) {
|
||||
if (GetIO().KeyShift) {
|
||||
auto& pop = extra_reg_popup.emplace_back();
|
||||
pop.SetData(args...);
|
||||
pop.open = true;
|
||||
} else if (last_selected_cb == cb && default_reg_popup.open) {
|
||||
default_reg_popup.open = false;
|
||||
} else {
|
||||
last_selected_cb = cb;
|
||||
default_reg_popup.SetData(args...);
|
||||
if (!default_reg_popup.open) {
|
||||
default_reg_popup.open = true;
|
||||
auto popup_pos =
|
||||
GetCurrentContext()->LastItemData.Rect.Max + ImVec2(5.0f, 0.0f);
|
||||
SetNextWindowPos(popup_pos, ImGuiCond_Always);
|
||||
default_reg_popup.Draw();
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
for (int cb = 0; cb < AmdGpu::Liverpool::NumColorBuffers; ++cb) {
|
||||
PushID(cb);
|
||||
|
||||
@ -115,45 +135,34 @@ void RegView::DrawRegs() {
|
||||
|
||||
const auto& buffer = regs.color_buffers[cb];
|
||||
|
||||
const auto open_new_popup = [&] {
|
||||
auto& pop = extra_reg_popup.emplace_back();
|
||||
pop.SetData(buffer, batch_id, cb);
|
||||
pop.open = true;
|
||||
};
|
||||
|
||||
Text("Color buffer %d", cb);
|
||||
TableNextColumn();
|
||||
if (!buffer || !regs.color_target_mask.GetMask(cb)) {
|
||||
TextUnformatted("N/A");
|
||||
} else if (last_selected_cb == cb && default_reg_popup.open) {
|
||||
if (SmallButton("x")) {
|
||||
if (GetIO().KeyShift) {
|
||||
open_new_popup();
|
||||
} else {
|
||||
default_reg_popup.open = false;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (SmallButton("->")) {
|
||||
if (GetIO().KeyShift) {
|
||||
open_new_popup();
|
||||
} else {
|
||||
last_selected_cb = cb;
|
||||
default_reg_popup.SetData(buffer, batch_id, cb);
|
||||
if (!default_reg_popup.open) {
|
||||
default_reg_popup.open = true;
|
||||
auto popup_pos =
|
||||
GetCurrentContext()->LastItemData.Rect.Max + ImVec2(5.0f, 0.0f);
|
||||
SetNextWindowPos(popup_pos, ImGuiCond_Always);
|
||||
default_reg_popup.Draw();
|
||||
}
|
||||
}
|
||||
const char* text = last_selected_cb == cb && default_reg_popup.open ? "x" : "->";
|
||||
if (SmallButton(text)) {
|
||||
open_new_popup(cb, buffer, batch_id, cb);
|
||||
}
|
||||
}
|
||||
|
||||
PopID();
|
||||
}
|
||||
|
||||
TableNextRow();
|
||||
TableNextColumn();
|
||||
TextUnformatted("Depth buffer");
|
||||
TableNextColumn();
|
||||
if (regs.depth_buffer.Address() == 0 || !regs.depth_control.depth_enable) {
|
||||
TextUnformatted("N/A");
|
||||
} else {
|
||||
constexpr auto depth_id = 0xF3;
|
||||
const char* text = last_selected_cb == depth_id && default_reg_popup.open ? "x" : "->";
|
||||
if (SmallButton(text)) {
|
||||
open_new_popup(depth_id, regs.depth_buffer, regs.depth_control, batch_id);
|
||||
}
|
||||
}
|
||||
|
||||
EndTable();
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user