renderer_base: Make creation of the rasterizer, the responsibility of the renderers themselves
Given we use a base-class type within the renderer for the rasterizer (RasterizerInterface), we want to allow renderers to perform more complex initialization if they need to do such a thing. This makes it important to reserve type information. Given the OpenGL renderer is quite simple settings-wise, this is just a simple shuffling of the initialization code. For something like Vulkan however this might involve doing something like: // Initialize and call rasterizer-specific function that requires // the full type of the instance created. auto raster = std::make_unique<VulkanRasterizer>(some, params); raster->CallSomeVulkanRasterizerSpecificFunction(); // Assign to base class variable rasterizer = std::move(raster)
This commit is contained in:
parent
028d90eb79
commit
bc16f7f3cc
|
@ -2,7 +2,6 @@
|
||||||
// Licensed under GPLv2 or any later version
|
// Licensed under GPLv2 or any later version
|
||||||
// Refer to the license.txt file included.
|
// Refer to the license.txt file included.
|
||||||
|
|
||||||
#include <memory>
|
|
||||||
#include "core/frontend/emu_window.h"
|
#include "core/frontend/emu_window.h"
|
||||||
#include "core/settings.h"
|
#include "core/settings.h"
|
||||||
#include "video_core/renderer_base.h"
|
#include "video_core/renderer_base.h"
|
||||||
|
@ -17,18 +16,11 @@ RendererBase::RendererBase(Core::Frontend::EmuWindow& window) : render_window{wi
|
||||||
RendererBase::~RendererBase() = default;
|
RendererBase::~RendererBase() = default;
|
||||||
|
|
||||||
void RendererBase::RefreshBaseSettings() {
|
void RendererBase::RefreshBaseSettings() {
|
||||||
RefreshRasterizerSetting();
|
|
||||||
UpdateCurrentFramebufferLayout();
|
UpdateCurrentFramebufferLayout();
|
||||||
|
|
||||||
renderer_settings.use_framelimiter = Settings::values.toggle_framelimit;
|
renderer_settings.use_framelimiter = Settings::values.toggle_framelimit;
|
||||||
}
|
}
|
||||||
|
|
||||||
void RendererBase::RefreshRasterizerSetting() {
|
|
||||||
if (rasterizer == nullptr) {
|
|
||||||
rasterizer = std::make_unique<RasterizerOpenGL>(render_window);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void RendererBase::UpdateCurrentFramebufferLayout() {
|
void RendererBase::UpdateCurrentFramebufferLayout() {
|
||||||
const Layout::FramebufferLayout& layout = render_window.GetFramebufferLayout();
|
const Layout::FramebufferLayout& layout = render_window.GetFramebufferLayout();
|
||||||
|
|
||||||
|
|
|
@ -58,9 +58,6 @@ public:
|
||||||
void RefreshBaseSettings();
|
void RefreshBaseSettings();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
/// Refreshes settings specific to the rasterizer.
|
|
||||||
void RefreshRasterizerSetting();
|
|
||||||
|
|
||||||
Core::Frontend::EmuWindow& render_window; ///< Reference to the render window handle.
|
Core::Frontend::EmuWindow& render_window; ///< Reference to the render window handle.
|
||||||
std::unique_ptr<RasterizerInterface> rasterizer;
|
std::unique_ptr<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
|
||||||
|
|
|
@ -16,6 +16,7 @@
|
||||||
#include "core/memory.h"
|
#include "core/memory.h"
|
||||||
#include "core/settings.h"
|
#include "core/settings.h"
|
||||||
#include "core/tracer/recorder.h"
|
#include "core/tracer/recorder.h"
|
||||||
|
#include "video_core/renderer_opengl/gl_rasterizer.h"
|
||||||
#include "video_core/renderer_opengl/renderer_opengl.h"
|
#include "video_core/renderer_opengl/renderer_opengl.h"
|
||||||
#include "video_core/utils.h"
|
#include "video_core/utils.h"
|
||||||
|
|
||||||
|
@ -142,7 +143,6 @@ void RendererOpenGL::SwapBuffers(boost::optional<const Tegra::FramebufferConfig&
|
||||||
|
|
||||||
// Restore the rasterizer state
|
// Restore the rasterizer state
|
||||||
prev_state.Apply();
|
prev_state.Apply();
|
||||||
RefreshRasterizerSetting();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -276,6 +276,14 @@ void RendererOpenGL::InitOpenGLObjects() {
|
||||||
LoadColorToActiveGLTexture(0, 0, 0, 0, screen_info.texture);
|
LoadColorToActiveGLTexture(0, 0, 0, 0, screen_info.texture);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void RendererOpenGL::CreateRasterizer() {
|
||||||
|
if (rasterizer) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
rasterizer = std::make_unique<RasterizerOpenGL>(render_window);
|
||||||
|
}
|
||||||
|
|
||||||
void RendererOpenGL::ConfigureFramebufferTexture(TextureInfo& texture,
|
void RendererOpenGL::ConfigureFramebufferTexture(TextureInfo& texture,
|
||||||
const Tegra::FramebufferConfig& framebuffer) {
|
const Tegra::FramebufferConfig& framebuffer) {
|
||||||
|
|
||||||
|
@ -463,8 +471,7 @@ bool RendererOpenGL::Init() {
|
||||||
}
|
}
|
||||||
|
|
||||||
InitOpenGLObjects();
|
InitOpenGLObjects();
|
||||||
|
CreateRasterizer();
|
||||||
RefreshRasterizerSetting();
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -59,6 +59,8 @@ public:
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void InitOpenGLObjects();
|
void InitOpenGLObjects();
|
||||||
|
void CreateRasterizer();
|
||||||
|
|
||||||
void ConfigureFramebufferTexture(TextureInfo& texture,
|
void ConfigureFramebufferTexture(TextureInfo& texture,
|
||||||
const Tegra::FramebufferConfig& framebuffer);
|
const Tegra::FramebufferConfig& framebuffer);
|
||||||
void DrawScreen();
|
void DrawScreen();
|
||||||
|
|
Loading…
Reference in a new issue