summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorGravatar bunnei2018-03-23 14:58:27 -0400
committerGravatar bunnei2018-03-23 14:58:27 -0400
commitec4e1a3685d458147ac76f4cf53ea86632d0debd (patch)
tree0bdc8e13b56ae88459055360f02b13e943dd6199 /src
parentrenderer_opengl: Use accelerated framebuffer load with LoadFBToScreenInfo. (diff)
downloadyuzu-ec4e1a3685d458147ac76f4cf53ea86632d0debd.tar.gz
yuzu-ec4e1a3685d458147ac76f4cf53ea86632d0debd.tar.xz
yuzu-ec4e1a3685d458147ac76f4cf53ea86632d0debd.zip
renderer_opengl: Better handling of framebuffer transform flags.
Diffstat (limited to 'src')
-rw-r--r--src/core/hle/service/nvdrv/devices/nvdisp_disp0.cpp4
-rw-r--r--src/core/hle/service/nvflinger/buffer_queue.h2
-rw-r--r--src/video_core/gpu.h5
-rw-r--r--src/video_core/renderer_opengl/renderer_opengl.cpp18
4 files changed, 23 insertions, 6 deletions
diff --git a/src/core/hle/service/nvdrv/devices/nvdisp_disp0.cpp b/src/core/hle/service/nvdrv/devices/nvdisp_disp0.cpp
index db030a8e2..f6c2b24a8 100644
--- a/src/core/hle/service/nvdrv/devices/nvdisp_disp0.cpp
+++ b/src/core/hle/service/nvdrv/devices/nvdisp_disp0.cpp
@@ -27,10 +27,8 @@ void nvdisp_disp0::flip(u32 buffer_handle, u32 offset, u32 format, u32 width, u3
27 offset, width, height, stride, format); 27 offset, width, height, stride, format);
28 28
29 using PixelFormat = Tegra::FramebufferConfig::PixelFormat; 29 using PixelFormat = Tegra::FramebufferConfig::PixelFormat;
30 using Flags = NVFlinger::BufferQueue::BufferTransformFlags;
31 const bool flip_vertical = static_cast<u32>(transform) & static_cast<u32>(Flags::FlipV);
32 const Tegra::FramebufferConfig framebuffer{ 30 const Tegra::FramebufferConfig framebuffer{
33 addr, offset, width, height, stride, static_cast<PixelFormat>(format), flip_vertical}; 31 addr, offset, width, height, stride, static_cast<PixelFormat>(format), transform};
34 32
35 Core::System::GetInstance().perf_stats.EndGameFrame(); 33 Core::System::GetInstance().perf_stats.EndGameFrame();
36 34
diff --git a/src/core/hle/service/nvflinger/buffer_queue.h b/src/core/hle/service/nvflinger/buffer_queue.h
index 686eadca7..1de5767cb 100644
--- a/src/core/hle/service/nvflinger/buffer_queue.h
+++ b/src/core/hle/service/nvflinger/buffer_queue.h
@@ -47,6 +47,8 @@ public:
47 ~BufferQueue() = default; 47 ~BufferQueue() = default;
48 48
49 enum class BufferTransformFlags : u32 { 49 enum class BufferTransformFlags : u32 {
50 /// No transform flags are set
51 Unset = 0x00,
50 /// Flip source image horizontally (around the vertical axis) 52 /// Flip source image horizontally (around the vertical axis)
51 FlipH = 0x01, 53 FlipH = 0x01,
52 /// Flip source image vertically (around the horizontal axis) 54 /// Flip source image vertically (around the horizontal axis)
diff --git a/src/video_core/gpu.h b/src/video_core/gpu.h
index f3c5e366a..206b3e05e 100644
--- a/src/video_core/gpu.h
+++ b/src/video_core/gpu.h
@@ -8,6 +8,7 @@
8#include <unordered_map> 8#include <unordered_map>
9#include <vector> 9#include <vector>
10#include "common/common_types.h" 10#include "common/common_types.h"
11#include "core/hle/service/nvflinger/buffer_queue.h"
11#include "video_core/memory_manager.h" 12#include "video_core/memory_manager.h"
12 13
13namespace Tegra { 14namespace Tegra {
@@ -38,7 +39,9 @@ struct FramebufferConfig {
38 u32 height; 39 u32 height;
39 u32 stride; 40 u32 stride;
40 PixelFormat pixel_format; 41 PixelFormat pixel_format;
41 bool flip_vertical; 42
43 using TransformFlags = Service::NVFlinger::BufferQueue::BufferTransformFlags;
44 TransformFlags transform_flags;
42}; 45};
43 46
44namespace Engines { 47namespace Engines {
diff --git a/src/video_core/renderer_opengl/renderer_opengl.cpp b/src/video_core/renderer_opengl/renderer_opengl.cpp
index 047389fee..ef63cbcf0 100644
--- a/src/video_core/renderer_opengl/renderer_opengl.cpp
+++ b/src/video_core/renderer_opengl/renderer_opengl.cpp
@@ -141,6 +141,9 @@ void RendererOpenGL::LoadFBToScreenInfo(const Tegra::FramebufferConfig& framebuf
141 const u32 size_in_bytes{framebuffer.stride * framebuffer.height * bpp}; 141 const u32 size_in_bytes{framebuffer.stride * framebuffer.height * bpp};
142 const VAddr framebuffer_addr{framebuffer.address}; 142 const VAddr framebuffer_addr{framebuffer.address};
143 143
144 // Framebuffer orientation handling
145 framebuffer_transform_flags = framebuffer.transform_flags;
146
144 // Ensure no bad interactions with GL_UNPACK_ALIGNMENT, which by default 147 // Ensure no bad interactions with GL_UNPACK_ALIGNMENT, which by default
145 // only allows rows to have a memory alignement of 4. 148 // only allows rows to have a memory alignement of 4.
146 ASSERT(framebuffer.stride % 4 == 0); 149 ASSERT(framebuffer.stride % 4 == 0);
@@ -292,8 +295,19 @@ void RendererOpenGL::ConfigureFramebufferTexture(TextureInfo& texture,
292void RendererOpenGL::DrawSingleScreen(const ScreenInfo& screen_info, float x, float y, float w, 295void RendererOpenGL::DrawSingleScreen(const ScreenInfo& screen_info, float x, float y, float w,
293 float h) { 296 float h) {
294 const auto& texcoords = screen_info.display_texcoords; 297 const auto& texcoords = screen_info.display_texcoords;
295 const auto& left = framebuffer_flip_vertical ? texcoords.right : texcoords.left; 298 auto left = texcoords.left;
296 const auto& right = framebuffer_flip_vertical ? texcoords.left : texcoords.right; 299 auto right = texcoords.right;
300 if (framebuffer_transform_flags != Tegra::FramebufferConfig::TransformFlags::Unset)
301 if (framebuffer_transform_flags == Tegra::FramebufferConfig::TransformFlags::FlipV) {
302 // Flip the framebuffer vertically
303 left = texcoords.right;
304 right = texcoords.left;
305 } else {
306 // Other transformations are unsupported
307 LOG_CRITICAL(HW_GPU, "unsupported framebuffer_transform_flags=%d",
308 framebuffer_transform_flags);
309 UNIMPLEMENTED();
310 }
297 311
298 std::array<ScreenRectVertex, 4> vertices = {{ 312 std::array<ScreenRectVertex, 4> vertices = {{
299 ScreenRectVertex(x, y, texcoords.top, right), 313 ScreenRectVertex(x, y, texcoords.top, right),