From cef9a684cd96fd672a72e9a3bde090c35321226f Mon Sep 17 00:00:00 2001 From: Ben Vanik Date: Sun, 22 Mar 2015 08:52:05 -0700 Subject: [PATCH] Primitive reset. --- src/xenia/gpu/gl4/command_processor.cc | 11 ++++++++++- src/xenia/gpu/gl4/command_processor.h | 1 + src/xenia/gpu/trace_viewer_main.cc | 14 +++++++++++++- 3 files changed, 24 insertions(+), 2 deletions(-) diff --git a/src/xenia/gpu/gl4/command_processor.cc b/src/xenia/gpu/gl4/command_processor.cc index 825fcb87e..2017f2849 100644 --- a/src/xenia/gpu/gl4/command_processor.cc +++ b/src/xenia/gpu/gl4/command_processor.cc @@ -1999,6 +1999,8 @@ CommandProcessor::UpdateStatus CommandProcessor::UpdateRasterizerState() { XE_GPU_REG_PA_SC_SCREEN_SCISSOR_TL); dirty |= SetShadowRegister(regs.pa_sc_screen_scissor_br, XE_GPU_REG_PA_SC_SCREEN_SCISSOR_BR); + dirty |= SetShadowRegister(regs.multi_prim_ib_reset_index, + XE_GPU_REG_VGT_MULTI_PRIM_IB_RESET_INDX); if (!dirty) { return UpdateStatus::kCompatible; } @@ -2059,12 +2061,19 @@ CommandProcessor::UpdateStatus CommandProcessor::UpdateRasterizerState() { glPolygonMode(GL_FRONT_AND_BACK, GL_FILL); } - if (regs.pa_su_sc_mode_cntl & (1 << 20)) { + if (regs.pa_su_sc_mode_cntl & (1 << 19)) { glProvokingVertex(GL_LAST_VERTEX_CONVENTION); } else { glProvokingVertex(GL_FIRST_VERTEX_CONVENTION); } + if (regs.pa_su_sc_mode_cntl & (1 << 21)) { + glEnable(GL_PRIMITIVE_RESTART); + } else { + glDisable(GL_PRIMITIVE_RESTART); + } + glPrimitiveRestartIndex(regs.multi_prim_ib_reset_index); + return UpdateStatus::kMismatch; } diff --git a/src/xenia/gpu/gl4/command_processor.h b/src/xenia/gpu/gl4/command_processor.h index 074287117..9f207dcb1 100644 --- a/src/xenia/gpu/gl4/command_processor.h +++ b/src/xenia/gpu/gl4/command_processor.h @@ -323,6 +323,7 @@ class CommandProcessor { uint32_t pa_su_sc_mode_cntl; uint32_t pa_sc_screen_scissor_tl; uint32_t pa_sc_screen_scissor_br; + uint32_t multi_prim_ib_reset_index; UpdateRasterizerStateRegisters() { Reset(); } void Reset() { std::memset(this, 0, sizeof(*this)); } diff --git a/src/xenia/gpu/trace_viewer_main.cc b/src/xenia/gpu/trace_viewer_main.cc index 4baa898db..bacce66ea 100644 --- a/src/xenia/gpu/trace_viewer_main.cc +++ b/src/xenia/gpu/trace_viewer_main.cc @@ -1601,7 +1601,7 @@ void DrawStateUI(xe::ui::MainWindow* window, TracePlayer& player, } else { ImGui::BulletText("Polygon Mode: fill"); } - if (pa_su_sc_mode_cntl & (1 << 20)) { + if (pa_su_sc_mode_cntl & (1 << 19)) { ImGui::BulletText("Provoking Vertex: last"); } else { ImGui::BulletText("Provoking Vertex: first"); @@ -1835,6 +1835,18 @@ void DrawStateUI(xe::ui::MainWindow* window, TracePlayer& player, draw_info.index_buffer_size, kIndexFormatNames[int(draw_info.index_format)], kEndiannessNames[int(draw_info.index_endianness)]); + uint32_t pa_su_sc_mode_cntl = regs[XE_GPU_REG_PA_SU_SC_MODE_CNTL].u32; + if (pa_su_sc_mode_cntl & (1 << 21)) { + uint32_t reset_index = + regs[XE_GPU_REG_VGT_MULTI_PRIM_IB_RESET_INDX].u32; + if (draw_info.index_format == IndexFormat::kInt16) { + ImGui::Text("Reset Index: %.4X", reset_index & 0xFFFF); + } else { + ImGui::Text("Reset Index: %.8X", reset_index); + } + } else { + ImGui::Text("Reset Index: disabled"); + } ImGui::BeginChild("#indices", ImVec2(0, 300)); ImGui::PushStyleVar(ImGuiStyleVar_ItemSpacing, ImVec2(0, 0)); int display_start, display_end;