From 9bee6202ab9e7f4fdcf2017c9b30f18501c90312 Mon Sep 17 00:00:00 2001 From: B3n30 Date: Thu, 10 Aug 2017 08:22:20 +0200 Subject: [PATCH] Added batch fix in command_processor; Make it optional --- src/citra/config.cpp | 1 + src/citra/default_ini.h | 4 ++++ src/citra_qt/configuration/config.cpp | 2 ++ src/citra_qt/configuration/configure_graphics.cpp | 2 ++ src/citra_qt/configuration/configure_graphics.ui | 7 +++++++ src/core/settings.cpp | 1 + src/core/settings.h | 1 + src/core/telemetry_session.cpp | 2 ++ src/video_core/command_processor.cpp | 7 +++++++ src/video_core/video_core.cpp | 1 + src/video_core/video_core.h | 1 + 11 files changed, 29 insertions(+) diff --git a/src/citra/config.cpp b/src/citra/config.cpp index 69247b166..d67fa4cce 100644 --- a/src/citra/config.cpp +++ b/src/citra/config.cpp @@ -87,6 +87,7 @@ void Config::ReadValues() { Settings::values.use_vsync = sdl2_config->GetBoolean("Renderer", "use_vsync", false); Settings::values.toggle_framelimit = sdl2_config->GetBoolean("Renderer", "toggle_framelimit", true); + Settings::values.use_batch_fix = sdl2_config->GetBoolean("Renderer", "use_batch_fix", true); Settings::values.bg_red = (float)sdl2_config->GetReal("Renderer", "bg_red", 0.0); Settings::values.bg_green = (float)sdl2_config->GetReal("Renderer", "bg_green", 0.0); diff --git a/src/citra/default_ini.h b/src/citra/default_ini.h index a12498e0f..f0523c6d2 100644 --- a/src/citra/default_ini.h +++ b/src/citra/default_ini.h @@ -109,6 +109,10 @@ custom_bottom_bottom = # 0: Off , 1 (default): On toggle_framelimit = +#Enable batch fix. +# 0: Off , 1 (default): On +use_batch_fix = + # Swaps the prominent screen with the other screen. # For example, if Single Screen is chosen, setting this to 1 will display the bottom screen instead of the top screen. # 0 (default): Top Screen is prominent, 1: Bottom Screen is prominent diff --git a/src/citra_qt/configuration/config.cpp b/src/citra_qt/configuration/config.cpp index 75abb4ce6..93a73cf4a 100644 --- a/src/citra_qt/configuration/config.cpp +++ b/src/citra_qt/configuration/config.cpp @@ -69,6 +69,7 @@ void Config::ReadValues() { Settings::values.resolution_factor = qt_config->value("resolution_factor", 1.0).toFloat(); Settings::values.use_vsync = qt_config->value("use_vsync", false).toBool(); Settings::values.toggle_framelimit = qt_config->value("toggle_framelimit", true).toBool(); + Settings::values.use_batch_fix = qt_config->value("use_batch_fix", true).toBool(); Settings::values.bg_red = qt_config->value("bg_red", 0.0).toFloat(); Settings::values.bg_green = qt_config->value("bg_green", 0.0).toFloat(); @@ -215,6 +216,7 @@ void Config::SaveValues() { qt_config->setValue("resolution_factor", (double)Settings::values.resolution_factor); qt_config->setValue("use_vsync", Settings::values.use_vsync); qt_config->setValue("toggle_framelimit", Settings::values.toggle_framelimit); + qt_config->setValue("use_batch_fix", Settings::values.use_batch_fix); // Cast to double because Qt's written float values are not human-readable qt_config->setValue("bg_red", (double)Settings::values.bg_red); diff --git a/src/citra_qt/configuration/configure_graphics.cpp b/src/citra_qt/configuration/configure_graphics.cpp index b5a5ab1e1..1a89ff04e 100644 --- a/src/citra_qt/configuration/configure_graphics.cpp +++ b/src/citra_qt/configuration/configure_graphics.cpp @@ -97,6 +97,7 @@ void ConfigureGraphics::setConfiguration() { static_cast(FromResolutionFactor(Settings::values.resolution_factor))); ui->toggle_vsync->setChecked(Settings::values.use_vsync); ui->toggle_framelimit->setChecked(Settings::values.toggle_framelimit); + ui->use_batch_fix->setChecked(Settings::values.use_batch_fix); ui->layout_combobox->setCurrentIndex(static_cast(Settings::values.layout_option)); ui->swap_screen->setChecked(Settings::values.swap_screen); } @@ -108,6 +109,7 @@ void ConfigureGraphics::applyConfiguration() { ToResolutionFactor(static_cast(ui->resolution_factor_combobox->currentIndex())); Settings::values.use_vsync = ui->toggle_vsync->isChecked(); Settings::values.toggle_framelimit = ui->toggle_framelimit->isChecked(); + Settings::values.use_batch_fix = ui->use_batch_fix->isChecked(); Settings::values.layout_option = static_cast(ui->layout_combobox->currentIndex()); Settings::values.swap_screen = ui->swap_screen->isChecked(); diff --git a/src/citra_qt/configuration/configure_graphics.ui b/src/citra_qt/configuration/configure_graphics.ui index 228f2a869..626984325 100644 --- a/src/citra_qt/configuration/configure_graphics.ui +++ b/src/citra_qt/configuration/configure_graphics.ui @@ -50,6 +50,13 @@ + + + + Batch Fix + + + diff --git a/src/core/settings.cpp b/src/core/settings.cpp index d4f0429d1..b3c7f1cb9 100644 --- a/src/core/settings.cpp +++ b/src/core/settings.cpp @@ -23,6 +23,7 @@ void Apply() { VideoCore::g_hw_renderer_enabled = values.use_hw_renderer; VideoCore::g_shader_jit_enabled = values.use_shader_jit; VideoCore::g_toggle_framelimit_enabled = values.toggle_framelimit; + VideoCore::g_batch_fix_enabled = values.use_batch_fix; if (VideoCore::g_emu_window) { auto layout = VideoCore::g_emu_window->GetFramebufferLayout(); diff --git a/src/core/settings.h b/src/core/settings.h index ee16bb90a..168715adb 100644 --- a/src/core/settings.h +++ b/src/core/settings.h @@ -95,6 +95,7 @@ struct Values { float resolution_factor; bool use_vsync; bool toggle_framelimit; + bool use_batch_fix; LayoutOption layout_option; bool swap_screen; diff --git a/src/core/telemetry_session.cpp b/src/core/telemetry_session.cpp index 94483f385..ff7fabfe5 100644 --- a/src/core/telemetry_session.cpp +++ b/src/core/telemetry_session.cpp @@ -94,6 +94,8 @@ TelemetrySession::TelemetrySession() { Settings::values.resolution_factor); AddField(Telemetry::FieldType::UserConfig, "Renderer_ToggleFramelimit", Settings::values.toggle_framelimit); + AddField(Telemetry::FieldType::UserConfig, "Renderer_UseBatchFix", + Settings::values.use_batch_fix); AddField(Telemetry::FieldType::UserConfig, "Renderer_UseHwRenderer", Settings::values.use_hw_renderer); AddField(Telemetry::FieldType::UserConfig, "Renderer_UseShaderJit", diff --git a/src/video_core/command_processor.cpp b/src/video_core/command_processor.cpp index f98ca3302..b15125d78 100644 --- a/src/video_core/command_processor.cpp +++ b/src/video_core/command_processor.cpp @@ -398,6 +398,13 @@ static void WritePicaReg(u32 id, u32 value, u32 mask) { range.second, range.first); } + if (VideoCore::g_batch_fix_enabled) { + VideoCore::g_renderer->Rasterizer()->DrawTriangles(); + if (g_debug_context) { + g_debug_context->OnEvent(DebugContext::Event::FinishedPrimitiveBatch, nullptr); + } + } + break; } diff --git a/src/video_core/video_core.cpp b/src/video_core/video_core.cpp index 7186a7652..17ef5948e 100644 --- a/src/video_core/video_core.cpp +++ b/src/video_core/video_core.cpp @@ -21,6 +21,7 @@ std::atomic g_hw_renderer_enabled; std::atomic g_shader_jit_enabled; std::atomic g_vsync_enabled; std::atomic g_toggle_framelimit_enabled; +std::atomic g_batch_fix_enabled; /// Initialize the video core bool Init(EmuWindow* emu_window) { diff --git a/src/video_core/video_core.h b/src/video_core/video_core.h index 94e0867f0..646e1d249 100644 --- a/src/video_core/video_core.h +++ b/src/video_core/video_core.h @@ -23,6 +23,7 @@ extern EmuWindow* g_emu_window; ///< Emu window extern std::atomic g_hw_renderer_enabled; extern std::atomic g_shader_jit_enabled; extern std::atomic g_toggle_framelimit_enabled; +extern std::atomic g_batch_fix_enabled; /// Start the video core void Start();