summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--src/video_core/rasterizer_interface.h4
-rw-r--r--src/video_core/renderer_base.cpp8
-rw-r--r--src/video_core/renderer_base.h3
-rw-r--r--src/video_core/renderer_opengl/gl_rasterizer.cpp7
-rw-r--r--src/video_core/renderer_opengl/gl_rasterizer.h8
-rw-r--r--src/video_core/renderer_opengl/renderer_opengl.cpp21
-rw-r--r--src/video_core/renderer_opengl/renderer_opengl.h4
7 files changed, 25 insertions, 30 deletions
diff --git a/src/video_core/rasterizer_interface.h b/src/video_core/rasterizer_interface.h
index 499e84b89..a4a219d8d 100644
--- a/src/video_core/rasterizer_interface.h
+++ b/src/video_core/rasterizer_interface.h
@@ -8,8 +8,6 @@
8#include "video_core/gpu.h" 8#include "video_core/gpu.h"
9#include "video_core/memory_manager.h" 9#include "video_core/memory_manager.h"
10 10
11struct ScreenInfo;
12
13namespace VideoCore { 11namespace VideoCore {
14 12
15class RasterizerInterface { 13class RasterizerInterface {
@@ -55,7 +53,7 @@ public:
55 53
56 /// Attempt to use a faster method to display the framebuffer to screen 54 /// Attempt to use a faster method to display the framebuffer to screen
57 virtual bool AccelerateDisplay(const Tegra::FramebufferConfig& config, VAddr framebuffer_addr, 55 virtual bool AccelerateDisplay(const Tegra::FramebufferConfig& config, VAddr framebuffer_addr,
58 u32 pixel_stride, ScreenInfo& screen_info) { 56 u32 pixel_stride) {
59 return false; 57 return false;
60 } 58 }
61 59
diff --git a/src/video_core/renderer_base.cpp b/src/video_core/renderer_base.cpp
index afd86a83a..645d1521a 100644
--- a/src/video_core/renderer_base.cpp
+++ b/src/video_core/renderer_base.cpp
@@ -2,7 +2,6 @@
2// Licensed under GPLv2 or any later version 2// Licensed under GPLv2 or any later version
3// Refer to the license.txt file included. 3// Refer to the license.txt file included.
4 4
5#include <memory>
6#include "core/frontend/emu_window.h" 5#include "core/frontend/emu_window.h"
7#include "core/settings.h" 6#include "core/settings.h"
8#include "video_core/renderer_base.h" 7#include "video_core/renderer_base.h"
@@ -17,18 +16,11 @@ RendererBase::RendererBase(Core::Frontend::EmuWindow& window) : render_window{wi
17RendererBase::~RendererBase() = default; 16RendererBase::~RendererBase() = default;
18 17
19void RendererBase::RefreshBaseSettings() { 18void RendererBase::RefreshBaseSettings() {
20 RefreshRasterizerSetting();
21 UpdateCurrentFramebufferLayout(); 19 UpdateCurrentFramebufferLayout();
22 20
23 renderer_settings.use_framelimiter = Settings::values.toggle_framelimit; 21 renderer_settings.use_framelimiter = Settings::values.toggle_framelimit;
24} 22}
25 23
26void RendererBase::RefreshRasterizerSetting() {
27 if (rasterizer == nullptr) {
28 rasterizer = std::make_unique<RasterizerOpenGL>(render_window);
29 }
30}
31
32void RendererBase::UpdateCurrentFramebufferLayout() { 24void RendererBase::UpdateCurrentFramebufferLayout() {
33 const Layout::FramebufferLayout& layout = render_window.GetFramebufferLayout(); 25 const Layout::FramebufferLayout& layout = render_window.GetFramebufferLayout();
34 26
diff --git a/src/video_core/renderer_base.h b/src/video_core/renderer_base.h
index d9f16b8e6..2a357f9d0 100644
--- a/src/video_core/renderer_base.h
+++ b/src/video_core/renderer_base.h
@@ -58,9 +58,6 @@ public:
58 void RefreshBaseSettings(); 58 void RefreshBaseSettings();
59 59
60protected: 60protected:
61 /// Refreshes settings specific to the rasterizer.
62 void RefreshRasterizerSetting();
63
64 Core::Frontend::EmuWindow& render_window; ///< Reference to the render window handle. 61 Core::Frontend::EmuWindow& render_window; ///< Reference to the render window handle.
65 std::unique_ptr<RasterizerInterface> rasterizer; 62 std::unique_ptr<RasterizerInterface> rasterizer;
66 f32 m_current_fps = 0.0f; ///< Current framerate, should be set by the renderer 63 f32 m_current_fps = 0.0f; ///< Current framerate, should be set by the renderer
diff --git a/src/video_core/renderer_opengl/gl_rasterizer.cpp b/src/video_core/renderer_opengl/gl_rasterizer.cpp
index 73c59e5cc..b653bb479 100644
--- a/src/video_core/renderer_opengl/gl_rasterizer.cpp
+++ b/src/video_core/renderer_opengl/gl_rasterizer.cpp
@@ -36,8 +36,8 @@ MICROPROFILE_DEFINE(OpenGL_Drawing, "OpenGL", "Drawing", MP_RGB(128, 128, 192));
36MICROPROFILE_DEFINE(OpenGL_Blits, "OpenGL", "Blits", MP_RGB(100, 100, 255)); 36MICROPROFILE_DEFINE(OpenGL_Blits, "OpenGL", "Blits", MP_RGB(100, 100, 255));
37MICROPROFILE_DEFINE(OpenGL_CacheManagement, "OpenGL", "Cache Mgmt", MP_RGB(100, 255, 100)); 37MICROPROFILE_DEFINE(OpenGL_CacheManagement, "OpenGL", "Cache Mgmt", MP_RGB(100, 255, 100));
38 38
39RasterizerOpenGL::RasterizerOpenGL(Core::Frontend::EmuWindow& window) 39RasterizerOpenGL::RasterizerOpenGL(Core::Frontend::EmuWindow& window, ScreenInfo& info)
40 : emu_window{window}, stream_buffer(GL_ARRAY_BUFFER, STREAM_BUFFER_SIZE) { 40 : emu_window{window}, screen_info{info}, stream_buffer(GL_ARRAY_BUFFER, STREAM_BUFFER_SIZE) {
41 // Create sampler objects 41 // Create sampler objects
42 for (size_t i = 0; i < texture_samplers.size(); ++i) { 42 for (size_t i = 0; i < texture_samplers.size(); ++i) {
43 texture_samplers[i].Create(); 43 texture_samplers[i].Create();
@@ -575,8 +575,7 @@ bool RasterizerOpenGL::AccelerateFill(const void* config) {
575} 575}
576 576
577bool RasterizerOpenGL::AccelerateDisplay(const Tegra::FramebufferConfig& config, 577bool RasterizerOpenGL::AccelerateDisplay(const Tegra::FramebufferConfig& config,
578 VAddr framebuffer_addr, u32 pixel_stride, 578 VAddr framebuffer_addr, u32 pixel_stride) {
579 ScreenInfo& screen_info) {
580 if (!framebuffer_addr) { 579 if (!framebuffer_addr) {
581 return {}; 580 return {};
582 } 581 }
diff --git a/src/video_core/renderer_opengl/gl_rasterizer.h b/src/video_core/renderer_opengl/gl_rasterizer.h
index 4a7c5b923..394fc59f1 100644
--- a/src/video_core/renderer_opengl/gl_rasterizer.h
+++ b/src/video_core/renderer_opengl/gl_rasterizer.h
@@ -30,7 +30,7 @@ class EmuWindow;
30 30
31class RasterizerOpenGL : public VideoCore::RasterizerInterface { 31class RasterizerOpenGL : public VideoCore::RasterizerInterface {
32public: 32public:
33 explicit RasterizerOpenGL(Core::Frontend::EmuWindow& renderer); 33 explicit RasterizerOpenGL(Core::Frontend::EmuWindow& renderer, ScreenInfo& info);
34 ~RasterizerOpenGL() override; 34 ~RasterizerOpenGL() override;
35 35
36 void DrawArrays() override; 36 void DrawArrays() override;
@@ -43,8 +43,8 @@ public:
43 bool AccelerateDisplayTransfer(const void* config) override; 43 bool AccelerateDisplayTransfer(const void* config) override;
44 bool AccelerateTextureCopy(const void* config) override; 44 bool AccelerateTextureCopy(const void* config) override;
45 bool AccelerateFill(const void* config) override; 45 bool AccelerateFill(const void* config) override;
46 bool AccelerateDisplay(const Tegra::FramebufferConfig& framebuffer, VAddr framebuffer_addr, 46 bool AccelerateDisplay(const Tegra::FramebufferConfig& config, VAddr framebuffer_addr,
47 u32 pixel_stride, ScreenInfo& screen_info) override; 47 u32 pixel_stride) override;
48 bool AccelerateDrawBatch(bool is_indexed) override; 48 bool AccelerateDrawBatch(bool is_indexed) override;
49 49
50 /// OpenGL shader generated for a given Maxwell register state 50 /// OpenGL shader generated for a given Maxwell register state
@@ -152,6 +152,8 @@ private:
152 152
153 Core::Frontend::EmuWindow& emu_window; 153 Core::Frontend::EmuWindow& emu_window;
154 154
155 ScreenInfo& screen_info;
156
155 std::unique_ptr<GLShader::ProgramManager> shader_program_manager; 157 std::unique_ptr<GLShader::ProgramManager> shader_program_manager;
156 OGLVertexArray sw_vao; 158 OGLVertexArray sw_vao;
157 OGLVertexArray hw_vao; 159 OGLVertexArray hw_vao;
diff --git a/src/video_core/renderer_opengl/renderer_opengl.cpp b/src/video_core/renderer_opengl/renderer_opengl.cpp
index ba5641438..eef13dddc 100644
--- a/src/video_core/renderer_opengl/renderer_opengl.cpp
+++ b/src/video_core/renderer_opengl/renderer_opengl.cpp
@@ -16,6 +16,7 @@
16#include "core/memory.h" 16#include "core/memory.h"
17#include "core/settings.h" 17#include "core/settings.h"
18#include "core/tracer/recorder.h" 18#include "core/tracer/recorder.h"
19#include "video_core/renderer_opengl/gl_rasterizer.h"
19#include "video_core/renderer_opengl/renderer_opengl.h" 20#include "video_core/renderer_opengl/renderer_opengl.h"
20#include "video_core/utils.h" 21#include "video_core/utils.h"
21 22
@@ -130,7 +131,7 @@ void RendererOpenGL::SwapBuffers(boost::optional<const Tegra::FramebufferConfig&
130 } 131 }
131 132
132 // Load the framebuffer from memory, draw it to the screen, and swap buffers 133 // Load the framebuffer from memory, draw it to the screen, and swap buffers
133 LoadFBToScreenInfo(*framebuffer, screen_info); 134 LoadFBToScreenInfo(*framebuffer);
134 DrawScreen(); 135 DrawScreen();
135 render_window.SwapBuffers(); 136 render_window.SwapBuffers();
136 } 137 }
@@ -142,14 +143,12 @@ void RendererOpenGL::SwapBuffers(boost::optional<const Tegra::FramebufferConfig&
142 143
143 // Restore the rasterizer state 144 // Restore the rasterizer state
144 prev_state.Apply(); 145 prev_state.Apply();
145 RefreshRasterizerSetting();
146} 146}
147 147
148/** 148/**
149 * Loads framebuffer from emulated memory into the active OpenGL texture. 149 * Loads framebuffer from emulated memory into the active OpenGL texture.
150 */ 150 */
151void RendererOpenGL::LoadFBToScreenInfo(const Tegra::FramebufferConfig& framebuffer, 151void RendererOpenGL::LoadFBToScreenInfo(const Tegra::FramebufferConfig& framebuffer) {
152 ScreenInfo& screen_info) {
153 const u32 bytes_per_pixel{Tegra::FramebufferConfig::BytesPerPixel(framebuffer.pixel_format)}; 152 const u32 bytes_per_pixel{Tegra::FramebufferConfig::BytesPerPixel(framebuffer.pixel_format)};
154 const u64 size_in_bytes{framebuffer.stride * framebuffer.height * bytes_per_pixel}; 153 const u64 size_in_bytes{framebuffer.stride * framebuffer.height * bytes_per_pixel};
155 const VAddr framebuffer_addr{framebuffer.address + framebuffer.offset}; 154 const VAddr framebuffer_addr{framebuffer.address + framebuffer.offset};
@@ -162,8 +161,7 @@ void RendererOpenGL::LoadFBToScreenInfo(const Tegra::FramebufferConfig& framebuf
162 // only allows rows to have a memory alignement of 4. 161 // only allows rows to have a memory alignement of 4.
163 ASSERT(framebuffer.stride % 4 == 0); 162 ASSERT(framebuffer.stride % 4 == 0);
164 163
165 if (!rasterizer->AccelerateDisplay(framebuffer, framebuffer_addr, framebuffer.stride, 164 if (!rasterizer->AccelerateDisplay(framebuffer, framebuffer_addr, framebuffer.stride)) {
166 screen_info)) {
167 // Reset the screen info's display texture to its own permanent texture 165 // Reset the screen info's display texture to its own permanent texture
168 screen_info.display_texture = screen_info.texture.resource.handle; 166 screen_info.display_texture = screen_info.texture.resource.handle;
169 167
@@ -276,6 +274,14 @@ void RendererOpenGL::InitOpenGLObjects() {
276 LoadColorToActiveGLTexture(0, 0, 0, 0, screen_info.texture); 274 LoadColorToActiveGLTexture(0, 0, 0, 0, screen_info.texture);
277} 275}
278 276
277void RendererOpenGL::CreateRasterizer() {
278 if (rasterizer) {
279 return;
280 }
281
282 rasterizer = std::make_unique<RasterizerOpenGL>(render_window, screen_info);
283}
284
279void RendererOpenGL::ConfigureFramebufferTexture(TextureInfo& texture, 285void RendererOpenGL::ConfigureFramebufferTexture(TextureInfo& texture,
280 const Tegra::FramebufferConfig& framebuffer) { 286 const Tegra::FramebufferConfig& framebuffer) {
281 287
@@ -463,8 +469,7 @@ bool RendererOpenGL::Init() {
463 } 469 }
464 470
465 InitOpenGLObjects(); 471 InitOpenGLObjects();
466 472 CreateRasterizer();
467 RefreshRasterizerSetting();
468 473
469 return true; 474 return true;
470} 475}
diff --git a/src/video_core/renderer_opengl/renderer_opengl.h b/src/video_core/renderer_opengl/renderer_opengl.h
index a5eab6997..7ae103f04 100644
--- a/src/video_core/renderer_opengl/renderer_opengl.h
+++ b/src/video_core/renderer_opengl/renderer_opengl.h
@@ -59,6 +59,8 @@ public:
59 59
60private: 60private:
61 void InitOpenGLObjects(); 61 void InitOpenGLObjects();
62 void CreateRasterizer();
63
62 void ConfigureFramebufferTexture(TextureInfo& texture, 64 void ConfigureFramebufferTexture(TextureInfo& texture,
63 const Tegra::FramebufferConfig& framebuffer); 65 const Tegra::FramebufferConfig& framebuffer);
64 void DrawScreen(); 66 void DrawScreen();
@@ -66,7 +68,7 @@ private:
66 void UpdateFramerate(); 68 void UpdateFramerate();
67 69
68 // Loads framebuffer from emulated memory into the display information structure 70 // Loads framebuffer from emulated memory into the display information structure
69 void LoadFBToScreenInfo(const Tegra::FramebufferConfig& framebuffer, ScreenInfo& screen_info); 71 void LoadFBToScreenInfo(const Tegra::FramebufferConfig& framebuffer);
70 // Fills active OpenGL texture with the given RGBA color. 72 // Fills active OpenGL texture with the given RGBA color.
71 void LoadColorToActiveGLTexture(u8 color_r, u8 color_g, u8 color_b, u8 color_a, 73 void LoadColorToActiveGLTexture(u8 color_r, u8 color_g, u8 color_b, u8 color_a,
72 const TextureInfo& texture); 74 const TextureInfo& texture);