summaryrefslogtreecommitdiff
path: root/src/video_core/renderer_vulkan
diff options
context:
space:
mode:
authorGravatar bunnei2023-06-01 17:57:49 -0700
committerGravatar bunnei2023-06-03 00:06:07 -0700
commit057117f0096a47b07f9070d48a0dbd952ab0522e (patch)
treeb3364fb9ad8e94d16691acc7831d477d975188ff /src/video_core/renderer_vulkan
parentandroid: Enable overlay scale/opacity dialog (diff)
downloadyuzu-057117f0096a47b07f9070d48a0dbd952ab0522e.tar.gz
yuzu-057117f0096a47b07f9070d48a0dbd952ab0522e.tar.xz
yuzu-057117f0096a47b07f9070d48a0dbd952ab0522e.zip
android: Fix presentation layout on foldable and tablet devices.
Diffstat (limited to 'src/video_core/renderer_vulkan')
-rw-r--r--src/video_core/renderer_vulkan/vk_blit_screen.cpp55
1 files changed, 47 insertions, 8 deletions
diff --git a/src/video_core/renderer_vulkan/vk_blit_screen.cpp b/src/video_core/renderer_vulkan/vk_blit_screen.cpp
index e4c581a28..7cdde992b 100644
--- a/src/video_core/renderer_vulkan/vk_blit_screen.cpp
+++ b/src/video_core/renderer_vulkan/vk_blit_screen.cpp
@@ -37,6 +37,10 @@
37#include "video_core/vulkan_common/vulkan_memory_allocator.h" 37#include "video_core/vulkan_common/vulkan_memory_allocator.h"
38#include "video_core/vulkan_common/vulkan_wrapper.h" 38#include "video_core/vulkan_common/vulkan_wrapper.h"
39 39
40#ifdef ANDROID
41extern u32 GetAndroidScreenRotation();
42#endif
43
40namespace Vulkan { 44namespace Vulkan {
41 45
42namespace { 46namespace {
@@ -74,23 +78,58 @@ struct ScreenRectVertex {
74 } 78 }
75}; 79};
76 80
77constexpr std::array<f32, 4 * 4> MakeOrthographicMatrix(f32 width, f32 height) {
78 // clang-format off
79#ifdef ANDROID 81#ifdef ANDROID
80 // Android renders in portrait, so rotate the matrix. 82
81 return { 0.f, 2.f / width, 0.f, 0.f, 83std::array<f32, 4 * 4> MakeOrthographicMatrix(f32 width, f32 height) {
82 -2.f / height, 0.f, 0.f, 0.f, 84 constexpr u32 ROTATION_0 = 0;
83 0.f, 0.f, 1.f, 0.f, 85 constexpr u32 ROTATION_90 = 1;
84 1.f, -1.f, 0.f, 1.f}; 86 constexpr u32 ROTATION_180 = 2;
87 constexpr u32 ROTATION_270 = 3;
88
89 // clang-format off
90 switch (GetAndroidScreenRotation()) {
91 case ROTATION_0:
92 // Desktop
93 return { 2.f / width, 0.f, 0.f, 0.f,
94 0.f, 2.f / height, 0.f, 0.f,
95 0.f, 0.f, 1.f, 0.f,
96 -1.f, -1.f, 0.f, 1.f};
97 case ROTATION_180:
98 // Reverse desktop
99 return {-2.f / width, 0.f, 0.f, 0.f,
100 0.f, -2.f / height, 0.f, 0.f,
101 0.f, 0.f, 1.f, 0.f,
102 1.f, 1.f, 0.f, 1.f};
103 case ROTATION_270:
104 // Reverse landscape
105 return { 0.f, -2.f / width, 0.f, 0.f,
106 2.f / height, 0.f, 0.f, 0.f,
107 0.f, 0.f, 1.f, 0.f,
108 -1.f, 1.f, 0.f, 1.f};
109 case ROTATION_90:
110 default:
111 // Landscape
112 return { 0.f, 2.f / width, 0.f, 0.f,
113 -2.f / height, 0.f, 0.f, 0.f,
114 0.f, 0.f, 1.f, 0.f,
115 1.f, -1.f, 0.f, 1.f};
116 }
117 // clang-format on
118}
119
85#else 120#else
121
122std::array<f32, 4 * 4> MakeOrthographicMatrix(f32 width, f32 height) {
123 // clang-format off
86 return { 2.f / width, 0.f, 0.f, 0.f, 124 return { 2.f / width, 0.f, 0.f, 0.f,
87 0.f, 2.f / height, 0.f, 0.f, 125 0.f, 2.f / height, 0.f, 0.f,
88 0.f, 0.f, 1.f, 0.f, 126 0.f, 0.f, 1.f, 0.f,
89 -1.f, -1.f, 0.f, 1.f}; 127 -1.f, -1.f, 0.f, 1.f};
90#endif // ANDROID
91 // clang-format on 128 // clang-format on
92} 129}
93 130
131#endif
132
94u32 GetBytesPerPixel(const Tegra::FramebufferConfig& framebuffer) { 133u32 GetBytesPerPixel(const Tegra::FramebufferConfig& framebuffer) {
95 using namespace VideoCore::Surface; 134 using namespace VideoCore::Surface;
96 return BytesPerBlock(PixelFormatFromGPUPixelFormat(framebuffer.pixel_format)); 135 return BytesPerBlock(PixelFormatFromGPUPixelFormat(framebuffer.pixel_format));