From ad0b57f4071fb7ec9da764b3905e0bb5e4c5eef2 Mon Sep 17 00:00:00 2001 From: James Rowe Date: Thu, 7 Sep 2017 22:05:42 -0600 Subject: [PATCH 1/2] GPU: Add draw for immediate and batch modes PR #1461 introduced a regression where some games would change configuration even while in the poorly named "drawing" mode, which broke the heuristic citra was using to determine when to draw the batch. This change adds back in a draw call for batching, and also adds in a draw call in immediate mode each time it adds a triangle. --- src/video_core/command_processor.cpp | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/src/video_core/command_processor.cpp b/src/video_core/command_processor.cpp index fb65a3a0a..fff159058 100644 --- a/src/video_core/command_processor.cpp +++ b/src/video_core/command_processor.cpp @@ -243,6 +243,15 @@ static void WritePicaReg(u32 id, u32 value, u32 mask) { ASSERT(!g_state.geometry_pipeline.NeedIndexInput()); g_state.geometry_pipeline.Setup(shader_engine); g_state.geometry_pipeline.SubmitVertex(output); + + // TODO: If drawing after every immediate mode triangle kills performance, + // change it to flush triangles whenever a draing config register changes + // See: https://github.com/citra-emu/citra/pull/2866#issuecomment-327011550 + VideoCore::g_renderer->Rasterizer()->DrawTriangles(); + if (g_debug_context) { + g_debug_context->OnEvent(DebugContext::Event::FinishedPrimitiveBatch, + nullptr); + } } } } @@ -398,6 +407,12 @@ static void WritePicaReg(u32 id, u32 value, u32 mask) { range.second, range.first); } + MICROPROFILE_SCOPE(GPU_Drawing); + VideoCore::g_renderer->Rasterizer()->DrawTriangles(); + if (g_debug_context) { + g_debug_context->OnEvent(DebugContext::Event::FinishedPrimitiveBatch, nullptr); + } + break; } @@ -632,6 +647,6 @@ void ProcessCommandList(const u32* list, u32 size) { } } -} // namespace +} // namespace CommandProcessor -} // namespace +} // namespace Pica From 19d41dcc6e6892125f1123b34db3dc284f04b744 Mon Sep 17 00:00:00 2001 From: James Rowe Date: Sat, 23 Sep 2017 09:28:20 -0600 Subject: [PATCH 2/2] Remove pipeline.gpu_mode and fix minor issues --- src/video_core/command_processor.cpp | 14 ++------------ 1 file changed, 2 insertions(+), 12 deletions(-) diff --git a/src/video_core/command_processor.cpp b/src/video_core/command_processor.cpp index fff159058..3ab4af374 100644 --- a/src/video_core/command_processor.cpp +++ b/src/video_core/command_processor.cpp @@ -245,7 +245,7 @@ static void WritePicaReg(u32 id, u32 value, u32 mask) { g_state.geometry_pipeline.SubmitVertex(output); // TODO: If drawing after every immediate mode triangle kills performance, - // change it to flush triangles whenever a draing config register changes + // change it to flush triangles whenever a drawing config register changes // See: https://github.com/citra-emu/citra/pull/2866#issuecomment-327011550 VideoCore::g_renderer->Rasterizer()->DrawTriangles(); if (g_debug_context) { @@ -259,16 +259,7 @@ static void WritePicaReg(u32 id, u32 value, u32 mask) { } case PICA_REG_INDEX(pipeline.gpu_mode): - if (regs.pipeline.gpu_mode == PipelineRegs::GPUMode::Configuring) { - MICROPROFILE_SCOPE(GPU_Drawing); - - // Draw immediate mode triangles when GPU Mode is set to GPUMode::Configuring - VideoCore::g_renderer->Rasterizer()->DrawTriangles(); - - if (g_debug_context) { - g_debug_context->OnEvent(DebugContext::Event::FinishedPrimitiveBatch, nullptr); - } - } + // This register likely just enables vertex processing and doesn't need any special handling break; case PICA_REG_INDEX_WORKAROUND(pipeline.command_buffer.trigger[0], 0x23c): @@ -407,7 +398,6 @@ static void WritePicaReg(u32 id, u32 value, u32 mask) { range.second, range.first); } - MICROPROFILE_SCOPE(GPU_Drawing); VideoCore::g_renderer->Rasterizer()->DrawTriangles(); if (g_debug_context) { g_debug_context->OnEvent(DebugContext::Event::FinishedPrimitiveBatch, nullptr);