From f4d3669309bc6a3ee8ad94365b1d83e850f0dded Mon Sep 17 00:00:00 2001 From: danzel Date: Tue, 22 Aug 2017 20:55:24 +1200 Subject: [PATCH] Push a few parts to the base class so they can be reused --- src/video_core/renderer_base.cpp | 12 ++++++++++++ src/video_core/renderer_base.h | 7 ++++++- .../renderer_opengl/renderer_opengl.cpp | 16 +--------------- src/video_core/renderer_opengl/renderer_opengl.h | 8 -------- 4 files changed, 19 insertions(+), 24 deletions(-) diff --git a/src/video_core/renderer_base.cpp b/src/video_core/renderer_base.cpp index f6ece5c4b..ce9955648 100644 --- a/src/video_core/renderer_base.cpp +++ b/src/video_core/renderer_base.cpp @@ -4,6 +4,8 @@ #include #include +#include "core/hw/hw.h" +#include "core/hw/lcd.h" #include "video_core/renderer_base.h" #include "video_core/renderer_opengl/gl_rasterizer.h" #include "video_core/swrasterizer/swrasterizer.h" @@ -21,3 +23,13 @@ void RendererBase::RefreshRasterizerSetting() { } } } + +u32 RendererBase::GetColorFillForFramebuffer(int framebuffer_index) { + // Main LCD (0): 0x1ED02204, Sub LCD (1): 0x1ED02A04 + u32 lcd_color_addr = + (framebuffer_index == 0) ? LCD_REG_INDEX(color_fill_top) : LCD_REG_INDEX(color_fill_bottom); + lcd_color_addr = HW::VADDR_LCD + 4 * lcd_color_addr; + LCD::Regs::ColorFill color_fill = {0}; + LCD::Read(color_fill.raw, lcd_color_addr); + return color_fill.raw; +} diff --git a/src/video_core/renderer_base.h b/src/video_core/renderer_base.h index 589aca857..164ef8f10 100644 --- a/src/video_core/renderer_base.h +++ b/src/video_core/renderer_base.h @@ -24,7 +24,9 @@ public: * Set the emulator window to use for renderer * @param window EmuWindow handle to emulator window to use for rendering */ - virtual void SetWindow(EmuWindow* window) = 0; + void SetWindow(EmuWindow* window) { + render_window = window; + } /// Initialize the renderer virtual bool Init() = 0; @@ -53,6 +55,9 @@ protected: std::unique_ptr rasterizer; f32 m_current_fps = 0.0f; ///< Current framerate, should be set by the renderer int m_current_frame = 0; ///< Current frame, should be set by the renderer + EmuWindow* render_window; ///< Handle to render window + + u32 GetColorFillForFramebuffer(int framebuffer_index); private: bool opengl_rasterizer_active = false; diff --git a/src/video_core/renderer_opengl/renderer_opengl.cpp b/src/video_core/renderer_opengl/renderer_opengl.cpp index 65c18aecc..5479dcfb9 100644 --- a/src/video_core/renderer_opengl/renderer_opengl.cpp +++ b/src/video_core/renderer_opengl/renderer_opengl.cpp @@ -14,7 +14,6 @@ #include "core/core_timing.h" #include "core/frontend/emu_window.h" #include "core/hw/gpu.h" -#include "core/hw/hw.h" #include "core/hw/lcd.h" #include "core/memory.h" #include "core/settings.h" @@ -106,12 +105,7 @@ void RendererOpenGL::SwapBuffers() { for (int i : {0, 1}) { const auto& framebuffer = GPU::g_regs.framebuffer_config[i]; - // Main LCD (0): 0x1ED02204, Sub LCD (1): 0x1ED02A04 - u32 lcd_color_addr = - (i == 0) ? LCD_REG_INDEX(color_fill_top) : LCD_REG_INDEX(color_fill_bottom); - lcd_color_addr = HW::VADDR_LCD + 4 * lcd_color_addr; - LCD::Regs::ColorFill color_fill = {0}; - LCD::Read(color_fill.raw, lcd_color_addr); + LCD::Regs::ColorFill color_fill{GetColorFillForFramebuffer(i)}; if (color_fill.is_enabled) { LoadColorToActiveGLTexture(color_fill.color_r, color_fill.color_g, color_fill.color_b, @@ -410,14 +404,6 @@ void RendererOpenGL::DrawScreens() { /// Updates the framerate void RendererOpenGL::UpdateFramerate() {} -/** - * Set the emulator window to use for renderer - * @param window EmuWindow handle to emulator window to use for rendering - */ -void RendererOpenGL::SetWindow(EmuWindow* window) { - render_window = window; -} - static const char* GetSource(GLenum source) { #define RET(s) \ case GL_DEBUG_SOURCE_##s: \ diff --git a/src/video_core/renderer_opengl/renderer_opengl.h b/src/video_core/renderer_opengl/renderer_opengl.h index 0b4f69e8f..efc7bd86a 100644 --- a/src/video_core/renderer_opengl/renderer_opengl.h +++ b/src/video_core/renderer_opengl/renderer_opengl.h @@ -40,12 +40,6 @@ public: /// Swap buffers (render frame) void SwapBuffers() override; - /** - * Set the emulator window to use for renderer - * @param window EmuWindow handle to emulator window to use for rendering - */ - void SetWindow(EmuWindow* window) override; - /// Initialize the renderer bool Init() override; @@ -66,8 +60,6 @@ private: // Fills active OpenGL texture with the given RGB color. void LoadColorToActiveGLTexture(u8 color_r, u8 color_g, u8 color_b, const TextureInfo& texture); - EmuWindow* render_window; ///< Handle to render window - OpenGLState state; // OpenGL object IDs