diff options
| -rw-r--r-- | src/core/hle/service/vi/vi.cpp | 5 | ||||
| -rw-r--r-- | src/video_core/renderer_base.h | 3 | ||||
| -rw-r--r-- | src/video_core/renderer_opengl/renderer_opengl.cpp | 23 | ||||
| -rw-r--r-- | src/video_core/renderer_opengl/renderer_opengl.h | 8 |
4 files changed, 22 insertions, 17 deletions
diff --git a/src/core/hle/service/vi/vi.cpp b/src/core/hle/service/vi/vi.cpp index d3b63949e..b35a7a377 100644 --- a/src/core/hle/service/vi/vi.cpp +++ b/src/core/hle/service/vi/vi.cpp | |||
| @@ -12,6 +12,8 @@ | |||
| 12 | #include "core/hle/service/nvdrv/nvdrv_a.h" | 12 | #include "core/hle/service/nvdrv/nvdrv_a.h" |
| 13 | #include "core/hle/service/vi/vi.h" | 13 | #include "core/hle/service/vi/vi.h" |
| 14 | #include "core/hle/service/vi/vi_m.h" | 14 | #include "core/hle/service/vi/vi_m.h" |
| 15 | #include "video_core/renderer_base.h" | ||
| 16 | #include "video_core/video_core.h" | ||
| 15 | 17 | ||
| 16 | namespace Service { | 18 | namespace Service { |
| 17 | namespace VI { | 19 | namespace VI { |
| @@ -743,7 +745,8 @@ void NVFlinger::Compose() { | |||
| 743 | auto buffer = buffer_queue->AcquireBuffer(); | 745 | auto buffer = buffer_queue->AcquireBuffer(); |
| 744 | 746 | ||
| 745 | if (buffer == boost::none) { | 747 | if (buffer == boost::none) { |
| 746 | // There was no queued buffer to draw. | 748 | // There was no queued buffer to draw, render previous frame |
| 749 | VideoCore::g_renderer->SwapBuffers({}); | ||
| 747 | continue; | 750 | continue; |
| 748 | } | 751 | } |
| 749 | 752 | ||
diff --git a/src/video_core/renderer_base.h b/src/video_core/renderer_base.h index d15db6c8c..28893b181 100644 --- a/src/video_core/renderer_base.h +++ b/src/video_core/renderer_base.h | |||
| @@ -5,6 +5,7 @@ | |||
| 5 | #pragma once | 5 | #pragma once |
| 6 | 6 | ||
| 7 | #include <memory> | 7 | #include <memory> |
| 8 | #include <boost/optional.hpp> | ||
| 8 | #include "common/assert.h" | 9 | #include "common/assert.h" |
| 9 | #include "common/common_types.h" | 10 | #include "common/common_types.h" |
| 10 | 11 | ||
| @@ -47,7 +48,7 @@ public: | |||
| 47 | virtual ~RendererBase() {} | 48 | virtual ~RendererBase() {} |
| 48 | 49 | ||
| 49 | /// Swap buffers (render frame) | 50 | /// Swap buffers (render frame) |
| 50 | virtual void SwapBuffers(const FramebufferInfo& framebuffer_info) = 0; | 51 | virtual void SwapBuffers(boost::optional<const FramebufferInfo&> framebuffer_info) = 0; |
| 51 | 52 | ||
| 52 | /** | 53 | /** |
| 53 | * Set the emulator window to use for renderer | 54 | * Set the emulator window to use for renderer |
diff --git a/src/video_core/renderer_opengl/renderer_opengl.cpp b/src/video_core/renderer_opengl/renderer_opengl.cpp index a5df91604..f1c3ff948 100644 --- a/src/video_core/renderer_opengl/renderer_opengl.cpp +++ b/src/video_core/renderer_opengl/renderer_opengl.cpp | |||
| @@ -4,8 +4,8 @@ | |||
| 4 | 4 | ||
| 5 | #include <algorithm> | 5 | #include <algorithm> |
| 6 | #include <cstddef> | 6 | #include <cstddef> |
| 7 | #include <cstring> | ||
| 8 | #include <cstdlib> | 7 | #include <cstdlib> |
| 8 | #include <cstring> | ||
| 9 | #include <memory> | 9 | #include <memory> |
| 10 | #include <glad/glad.h> | 10 | #include <glad/glad.h> |
| 11 | #include "common/assert.h" | 11 | #include "common/assert.h" |
| @@ -98,20 +98,23 @@ RendererOpenGL::RendererOpenGL() = default; | |||
| 98 | RendererOpenGL::~RendererOpenGL() = default; | 98 | RendererOpenGL::~RendererOpenGL() = default; |
| 99 | 99 | ||
| 100 | /// Swap buffers (render frame) | 100 | /// Swap buffers (render frame) |
| 101 | void RendererOpenGL::SwapBuffers(const FramebufferInfo& framebuffer_info) { | 101 | void RendererOpenGL::SwapBuffers(boost::optional<const FramebufferInfo&> framebuffer_info) { |
| 102 | // Maintain the rasterizer's state as a priority | 102 | // Maintain the rasterizer's state as a priority |
| 103 | OpenGLState prev_state = OpenGLState::GetCurState(); | 103 | OpenGLState prev_state = OpenGLState::GetCurState(); |
| 104 | state.Apply(); | 104 | state.Apply(); |
| 105 | 105 | ||
| 106 | if (screen_info.texture.width != (GLsizei)framebuffer_info.width || | 106 | if (framebuffer_info != boost::none) { |
| 107 | screen_info.texture.height != (GLsizei)framebuffer_info.height || | 107 | // If framebuffer_info is provided, reload it from memory to a texture |
| 108 | screen_info.texture.pixel_format != framebuffer_info.pixel_format) { | 108 | if (screen_info.texture.width != (GLsizei)framebuffer_info->width || |
| 109 | // Reallocate texture if the framebuffer size has changed. | 109 | screen_info.texture.height != (GLsizei)framebuffer_info->height || |
| 110 | // This is expected to not happen very often and hence should not be a | 110 | screen_info.texture.pixel_format != framebuffer_info->pixel_format) { |
| 111 | // performance problem. | 111 | // Reallocate texture if the framebuffer size has changed. |
| 112 | ConfigureFramebufferTexture(screen_info.texture, framebuffer_info); | 112 | // This is expected to not happen very often and hence should not be a |
| 113 | // performance problem. | ||
| 114 | ConfigureFramebufferTexture(screen_info.texture, *framebuffer_info); | ||
| 115 | } | ||
| 116 | LoadFBToScreenInfo(*framebuffer_info, screen_info); | ||
| 113 | } | 117 | } |
| 114 | LoadFBToScreenInfo(framebuffer_info, screen_info); | ||
| 115 | 118 | ||
| 116 | DrawScreens(); | 119 | DrawScreens(); |
| 117 | 120 | ||
diff --git a/src/video_core/renderer_opengl/renderer_opengl.h b/src/video_core/renderer_opengl/renderer_opengl.h index dc21d7a38..2f5e35787 100644 --- a/src/video_core/renderer_opengl/renderer_opengl.h +++ b/src/video_core/renderer_opengl/renderer_opengl.h | |||
| @@ -37,7 +37,7 @@ public: | |||
| 37 | ~RendererOpenGL() override; | 37 | ~RendererOpenGL() override; |
| 38 | 38 | ||
| 39 | /// Swap buffers (render frame) | 39 | /// Swap buffers (render frame) |
| 40 | void SwapBuffers(const FramebufferInfo& framebuffer_info) override; | 40 | void SwapBuffers(boost::optional<const FramebufferInfo&> framebuffer_info) override; |
| 41 | 41 | ||
| 42 | /** | 42 | /** |
| 43 | * Set the emulator window to use for renderer | 43 | * Set the emulator window to use for renderer |
| @@ -53,15 +53,13 @@ public: | |||
| 53 | 53 | ||
| 54 | private: | 54 | private: |
| 55 | void InitOpenGLObjects(); | 55 | void InitOpenGLObjects(); |
| 56 | void ConfigureFramebufferTexture(TextureInfo& texture, | 56 | void ConfigureFramebufferTexture(TextureInfo& texture, const FramebufferInfo& framebuffer_info); |
| 57 | const FramebufferInfo& framebuffer_info); | ||
| 58 | void DrawScreens(); | 57 | void DrawScreens(); |
| 59 | void DrawSingleScreen(const ScreenInfo& screen_info, float x, float y, float w, float h); | 58 | void DrawSingleScreen(const ScreenInfo& screen_info, float x, float y, float w, float h); |
| 60 | void UpdateFramerate(); | 59 | void UpdateFramerate(); |
| 61 | 60 | ||
| 62 | // Loads framebuffer from emulated memory into the display information structure | 61 | // Loads framebuffer from emulated memory into the display information structure |
| 63 | void LoadFBToScreenInfo(const FramebufferInfo& framebuffer_info, | 62 | void LoadFBToScreenInfo(const FramebufferInfo& framebuffer_info, ScreenInfo& screen_info); |
| 64 | ScreenInfo& screen_info); | ||
| 65 | // Fills active OpenGL texture with the given RGB color. | 63 | // Fills active OpenGL texture with the given RGB color. |
| 66 | void LoadColorToActiveGLTexture(u8 color_r, u8 color_g, u8 color_b, const TextureInfo& texture); | 64 | void LoadColorToActiveGLTexture(u8 color_r, u8 color_g, u8 color_b, const TextureInfo& texture); |
| 67 | 65 | ||