Push a few parts to the base class so they can be reused

This commit is contained in:
danzel 2017-08-22 20:55:24 +12:00
parent bbfa9d0635
commit f4d3669309
4 changed files with 19 additions and 24 deletions

View File

@ -4,6 +4,8 @@
#include <atomic> #include <atomic>
#include <memory> #include <memory>
#include "core/hw/hw.h"
#include "core/hw/lcd.h"
#include "video_core/renderer_base.h" #include "video_core/renderer_base.h"
#include "video_core/renderer_opengl/gl_rasterizer.h" #include "video_core/renderer_opengl/gl_rasterizer.h"
#include "video_core/swrasterizer/swrasterizer.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;
}

View File

@ -24,7 +24,9 @@ public:
* Set the emulator window to use for renderer * Set the emulator window to use for renderer
* @param window EmuWindow handle to emulator window to use for rendering * @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 /// Initialize the renderer
virtual bool Init() = 0; virtual bool Init() = 0;
@ -53,6 +55,9 @@ protected:
std::unique_ptr<VideoCore::RasterizerInterface> rasterizer; std::unique_ptr<VideoCore::RasterizerInterface> rasterizer;
f32 m_current_fps = 0.0f; ///< Current framerate, should be set by the renderer 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 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: private:
bool opengl_rasterizer_active = false; bool opengl_rasterizer_active = false;

View File

@ -14,7 +14,6 @@
#include "core/core_timing.h" #include "core/core_timing.h"
#include "core/frontend/emu_window.h" #include "core/frontend/emu_window.h"
#include "core/hw/gpu.h" #include "core/hw/gpu.h"
#include "core/hw/hw.h"
#include "core/hw/lcd.h" #include "core/hw/lcd.h"
#include "core/memory.h" #include "core/memory.h"
#include "core/settings.h" #include "core/settings.h"
@ -106,12 +105,7 @@ void RendererOpenGL::SwapBuffers() {
for (int i : {0, 1}) { for (int i : {0, 1}) {
const auto& framebuffer = GPU::g_regs.framebuffer_config[i]; const auto& framebuffer = GPU::g_regs.framebuffer_config[i];
// Main LCD (0): 0x1ED02204, Sub LCD (1): 0x1ED02A04 LCD::Regs::ColorFill color_fill{GetColorFillForFramebuffer(i)};
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);
if (color_fill.is_enabled) { if (color_fill.is_enabled) {
LoadColorToActiveGLTexture(color_fill.color_r, color_fill.color_g, color_fill.color_b, LoadColorToActiveGLTexture(color_fill.color_r, color_fill.color_g, color_fill.color_b,
@ -410,14 +404,6 @@ void RendererOpenGL::DrawScreens() {
/// Updates the framerate /// Updates the framerate
void RendererOpenGL::UpdateFramerate() {} 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) { static const char* GetSource(GLenum source) {
#define RET(s) \ #define RET(s) \
case GL_DEBUG_SOURCE_##s: \ case GL_DEBUG_SOURCE_##s: \

View File

@ -40,12 +40,6 @@ public:
/// Swap buffers (render frame) /// Swap buffers (render frame)
void SwapBuffers() override; 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 /// Initialize the renderer
bool Init() override; bool Init() override;
@ -66,8 +60,6 @@ private:
// Fills active OpenGL texture with the given RGB color. // Fills active OpenGL texture with the given RGB color.
void LoadColorToActiveGLTexture(u8 color_r, u8 color_g, u8 color_b, const TextureInfo& texture); void LoadColorToActiveGLTexture(u8 color_r, u8 color_g, u8 color_b, const TextureInfo& texture);
EmuWindow* render_window; ///< Handle to render window
OpenGLState state; OpenGLState state;
// OpenGL object IDs // OpenGL object IDs