diff options
| author | 2021-10-23 01:29:44 -0400 | |
|---|---|---|
| committer | 2021-11-16 22:11:33 +0100 | |
| commit | 99124b72618285114ac3ff820732a510bbf7aae4 (patch) | |
| tree | ecfdb064ef50d016d30c8f12343c3c3a6bf3e1c7 /src | |
| parent | Vulkan: Reimplement FSR constant generation functions to avoid GCC warnings (diff) | |
| download | yuzu-99124b72618285114ac3ff820732a510bbf7aae4.tar.gz yuzu-99124b72618285114ac3ff820732a510bbf7aae4.tar.xz yuzu-99124b72618285114ac3ff820732a510bbf7aae4.zip | |
FSR: Fix GCC build errors
Diffstat (limited to 'src')
| -rw-r--r-- | src/video_core/renderer_vulkan/vk_blit_screen.cpp | 19 | ||||
| -rw-r--r-- | src/video_core/renderer_vulkan/vk_blit_screen.h | 2 | ||||
| -rw-r--r-- | src/video_core/renderer_vulkan/vk_fsr.cpp | 72 |
3 files changed, 50 insertions, 43 deletions
diff --git a/src/video_core/renderer_vulkan/vk_blit_screen.cpp b/src/video_core/renderer_vulkan/vk_blit_screen.cpp index 9dfc508bc..1e447e621 100644 --- a/src/video_core/renderer_vulkan/vk_blit_screen.cpp +++ b/src/video_core/renderer_vulkan/vk_blit_screen.cpp | |||
| @@ -468,20 +468,14 @@ void VKBlitScreen::CreateDynamicResources() { | |||
| 468 | CreateGraphicsPipeline(); | 468 | CreateGraphicsPipeline(); |
| 469 | fsr.reset(); | 469 | fsr.reset(); |
| 470 | if (Settings::values.scaling_filter.GetValue() == Settings::ScalingFilter::Fsr) { | 470 | if (Settings::values.scaling_filter.GetValue() == Settings::ScalingFilter::Fsr) { |
| 471 | const auto& layout = render_window.GetFramebufferLayout(); | 471 | CreateFSR(); |
| 472 | fsr = std::make_unique<FSR>( | ||
| 473 | device, memory_allocator, image_count, | ||
| 474 | VkExtent2D{.width = layout.screen.GetWidth(), .height = layout.screen.GetHeight()}); | ||
| 475 | } | 472 | } |
| 476 | } | 473 | } |
| 477 | 474 | ||
| 478 | void VKBlitScreen::RefreshResources(const Tegra::FramebufferConfig& framebuffer) { | 475 | void VKBlitScreen::RefreshResources(const Tegra::FramebufferConfig& framebuffer) { |
| 479 | if (Settings::values.scaling_filter.GetValue() == Settings::ScalingFilter::Fsr) { | 476 | if (Settings::values.scaling_filter.GetValue() == Settings::ScalingFilter::Fsr) { |
| 480 | if (!fsr) { | 477 | if (!fsr) { |
| 481 | const auto& layout = render_window.GetFramebufferLayout(); | 478 | CreateFSR(); |
| 482 | fsr = std::make_unique<FSR>( | ||
| 483 | device, memory_allocator, image_count, | ||
| 484 | VkExtent2D{.width = layout.screen.GetWidth(), .height = layout.screen.GetHeight()}); | ||
| 485 | } | 479 | } |
| 486 | } else { | 480 | } else { |
| 487 | fsr.reset(); | 481 | fsr.reset(); |
| @@ -1443,6 +1437,15 @@ void VKBlitScreen::SetVertexData(BufferData& data, const Tegra::FramebufferConfi | |||
| 1443 | data.vertices[3] = ScreenRectVertex(x + w, y + h, texcoords.bottom * scale_u, right * scale_v); | 1437 | data.vertices[3] = ScreenRectVertex(x + w, y + h, texcoords.bottom * scale_u, right * scale_v); |
| 1444 | } | 1438 | } |
| 1445 | 1439 | ||
| 1440 | void VKBlitScreen::CreateFSR() { | ||
| 1441 | const auto& layout = render_window.GetFramebufferLayout(); | ||
| 1442 | const VkExtent2D fsr_size{ | ||
| 1443 | .width = layout.screen.GetWidth(), | ||
| 1444 | .height = layout.screen.GetHeight(), | ||
| 1445 | }; | ||
| 1446 | fsr = std::make_unique<FSR>(device, memory_allocator, image_count, fsr_size); | ||
| 1447 | } | ||
| 1448 | |||
| 1446 | u64 VKBlitScreen::CalculateBufferSize(const Tegra::FramebufferConfig& framebuffer) const { | 1449 | u64 VKBlitScreen::CalculateBufferSize(const Tegra::FramebufferConfig& framebuffer) const { |
| 1447 | return sizeof(BufferData) + GetSizeInBytes(framebuffer) * image_count; | 1450 | return sizeof(BufferData) + GetSizeInBytes(framebuffer) * image_count; |
| 1448 | } | 1451 | } |
diff --git a/src/video_core/renderer_vulkan/vk_blit_screen.h b/src/video_core/renderer_vulkan/vk_blit_screen.h index ad0cd8ee1..bbca71af3 100644 --- a/src/video_core/renderer_vulkan/vk_blit_screen.h +++ b/src/video_core/renderer_vulkan/vk_blit_screen.h | |||
| @@ -99,6 +99,8 @@ private: | |||
| 99 | void SetVertexData(BufferData& data, const Tegra::FramebufferConfig& framebuffer, | 99 | void SetVertexData(BufferData& data, const Tegra::FramebufferConfig& framebuffer, |
| 100 | const Layout::FramebufferLayout layout) const; | 100 | const Layout::FramebufferLayout layout) const; |
| 101 | 101 | ||
| 102 | void CreateFSR(); | ||
| 103 | |||
| 102 | u64 CalculateBufferSize(const Tegra::FramebufferConfig& framebuffer) const; | 104 | u64 CalculateBufferSize(const Tegra::FramebufferConfig& framebuffer) const; |
| 103 | u64 GetRawImageOffset(const Tegra::FramebufferConfig& framebuffer, | 105 | u64 GetRawImageOffset(const Tegra::FramebufferConfig& framebuffer, |
| 104 | std::size_t image_index) const; | 106 | std::size_t image_index) const; |
diff --git a/src/video_core/renderer_vulkan/vk_fsr.cpp b/src/video_core/renderer_vulkan/vk_fsr.cpp index 2feaa9d37..73629d229 100644 --- a/src/video_core/renderer_vulkan/vk_fsr.cpp +++ b/src/video_core/renderer_vulkan/vk_fsr.cpp | |||
| @@ -2,8 +2,11 @@ | |||
| 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 <cmath> | ||
| 6 | #include "common/bit_cast.h" | ||
| 5 | #include "common/common_types.h" | 7 | #include "common/common_types.h" |
| 6 | #include "common/div_ceil.h" | 8 | #include "common/div_ceil.h" |
| 9 | |||
| 7 | #include "video_core/host_shaders/vulkan_fidelityfx_fsr_easu_fp16_comp_spv.h" | 10 | #include "video_core/host_shaders/vulkan_fidelityfx_fsr_easu_fp16_comp_spv.h" |
| 8 | #include "video_core/host_shaders/vulkan_fidelityfx_fsr_easu_fp32_comp_spv.h" | 11 | #include "video_core/host_shaders/vulkan_fidelityfx_fsr_easu_fp32_comp_spv.h" |
| 9 | #include "video_core/host_shaders/vulkan_fidelityfx_fsr_rcas_fp16_comp_spv.h" | 12 | #include "video_core/host_shaders/vulkan_fidelityfx_fsr_rcas_fp16_comp_spv.h" |
| @@ -13,9 +16,11 @@ | |||
| 13 | #include "video_core/renderer_vulkan/vk_shader_util.h" | 16 | #include "video_core/renderer_vulkan/vk_shader_util.h" |
| 14 | #include "video_core/vulkan_common/vulkan_device.h" | 17 | #include "video_core/vulkan_common/vulkan_device.h" |
| 15 | 18 | ||
| 19 | namespace Vulkan { | ||
| 20 | namespace { | ||
| 16 | // Reimplementations of the constant generating functions in ffx_fsr1.h | 21 | // Reimplementations of the constant generating functions in ffx_fsr1.h |
| 17 | // GCC generated a lot of warnings when using the official header. | 22 | // GCC generated a lot of warnings when using the official header. |
| 18 | static u32 AU1_AH1_AF1(f32 f) { | 23 | u32 AU1_AH1_AF1(f32 f) { |
| 19 | static constexpr u32 base[512]{ | 24 | static constexpr u32 base[512]{ |
| 20 | 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, | 25 | 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, |
| 21 | 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, | 26 | 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, |
| @@ -102,59 +107,56 @@ static u32 AU1_AH1_AF1(f32 f) { | |||
| 102 | 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, | 107 | 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, |
| 103 | 0x18, 0x18, | 108 | 0x18, 0x18, |
| 104 | }; | 109 | }; |
| 105 | auto u = std::bit_cast<u32>(f); | 110 | const u32 u = Common::BitCast<u32>(f); |
| 106 | u32 i = u >> 23; | 111 | const u32 i = u >> 23; |
| 107 | return base[i] + ((u & 0x7fffff) >> shift[i]); | 112 | return base[i] + ((u & 0x7fffff) >> shift[i]); |
| 108 | } | 113 | } |
| 109 | 114 | ||
| 110 | static u32 AU1_AH2_AF2(f32 a[2]) { | 115 | u32 AU1_AH2_AF2(f32 a[2]) { |
| 111 | return AU1_AH1_AF1(a[0]) + (AU1_AH1_AF1(a[1]) << 16); | 116 | return AU1_AH1_AF1(a[0]) + (AU1_AH1_AF1(a[1]) << 16); |
| 112 | } | 117 | } |
| 113 | 118 | ||
| 114 | static void FsrEasuCon(u32 con0[4], u32 con1[4], u32 con2[4], u32 con3[4], | 119 | void FsrEasuCon(u32 con0[4], u32 con1[4], u32 con2[4], u32 con3[4], f32 inputViewportInPixelsX, |
| 115 | f32 inputViewportInPixelsX, f32 inputViewportInPixelsY, | 120 | f32 inputViewportInPixelsY, f32 inputSizeInPixelsX, f32 inputSizeInPixelsY, |
| 116 | f32 inputSizeInPixelsX, f32 inputSizeInPixelsY, f32 outputSizeInPixelsX, | 121 | f32 outputSizeInPixelsX, f32 outputSizeInPixelsY) { |
| 117 | f32 outputSizeInPixelsY) { | 122 | con0[0] = Common::BitCast<u32>(inputViewportInPixelsX / outputSizeInPixelsX); |
| 118 | con0[0] = std::bit_cast<u32>(inputViewportInPixelsX / outputSizeInPixelsX); | 123 | con0[1] = Common::BitCast<u32>(inputViewportInPixelsY / outputSizeInPixelsY); |
| 119 | con0[1] = std::bit_cast<u32>(inputViewportInPixelsY / outputSizeInPixelsY); | 124 | con0[2] = Common::BitCast<u32>(0.5f * inputViewportInPixelsX / outputSizeInPixelsX - 0.5f); |
| 120 | con0[2] = std::bit_cast<u32>(0.5f * inputViewportInPixelsX / outputSizeInPixelsX - 0.5f); | 125 | con0[3] = Common::BitCast<u32>(0.5f * inputViewportInPixelsY / outputSizeInPixelsY - 0.5f); |
| 121 | con0[3] = std::bit_cast<u32>(0.5f * inputViewportInPixelsY / outputSizeInPixelsY - 0.5f); | 126 | con1[0] = Common::BitCast<u32>(1.0f / inputSizeInPixelsX); |
| 122 | con1[0] = std::bit_cast<u32>(1.0f / inputSizeInPixelsX); | 127 | con1[1] = Common::BitCast<u32>(1.0f / inputSizeInPixelsY); |
| 123 | con1[1] = std::bit_cast<u32>(1.0f / inputSizeInPixelsY); | 128 | con1[2] = Common::BitCast<u32>(1.0f / inputSizeInPixelsX); |
| 124 | con1[2] = std::bit_cast<u32>(1.0f / inputSizeInPixelsX); | 129 | con1[3] = Common::BitCast<u32>(-1.0f / inputSizeInPixelsY); |
| 125 | con1[3] = std::bit_cast<u32>(-1.0f / inputSizeInPixelsY); | 130 | con2[0] = Common::BitCast<u32>(-1.0f / inputSizeInPixelsX); |
| 126 | con2[0] = std::bit_cast<u32>(-1.0f / inputSizeInPixelsX); | 131 | con2[1] = Common::BitCast<u32>(2.0f / inputSizeInPixelsY); |
| 127 | con2[1] = std::bit_cast<u32>(2.0f / inputSizeInPixelsY); | 132 | con2[2] = Common::BitCast<u32>(1.0f / inputSizeInPixelsX); |
| 128 | con2[2] = std::bit_cast<u32>(1.0f / inputSizeInPixelsX); | 133 | con2[3] = Common::BitCast<u32>(2.0f / inputSizeInPixelsY); |
| 129 | con2[3] = std::bit_cast<u32>(2.0f / inputSizeInPixelsY); | 134 | con3[0] = Common::BitCast<u32>(0.0f / inputSizeInPixelsX); |
| 130 | con3[0] = std::bit_cast<u32>(0.0f / inputSizeInPixelsX); | 135 | con3[1] = Common::BitCast<u32>(4.0f / inputSizeInPixelsY); |
| 131 | con3[1] = std::bit_cast<u32>(4.0f / inputSizeInPixelsY); | ||
| 132 | con3[2] = con3[3] = 0; | 136 | con3[2] = con3[3] = 0; |
| 133 | } | 137 | } |
| 134 | 138 | ||
| 135 | static void FsrEasuConOffset(u32 con0[4], u32 con1[4], u32 con2[4], u32 con3[4], | 139 | void FsrEasuConOffset(u32 con0[4], u32 con1[4], u32 con2[4], u32 con3[4], |
| 136 | f32 inputViewportInPixelsX, f32 inputViewportInPixelsY, | 140 | f32 inputViewportInPixelsX, f32 inputViewportInPixelsY, |
| 137 | f32 inputSizeInPixelsX, f32 inputSizeInPixelsY, | 141 | f32 inputSizeInPixelsX, f32 inputSizeInPixelsY, f32 outputSizeInPixelsX, |
| 138 | f32 outputSizeInPixelsX, f32 outputSizeInPixelsY, | 142 | f32 outputSizeInPixelsY, f32 inputOffsetInPixelsX, f32 inputOffsetInPixelsY) { |
| 139 | f32 inputOffsetInPixelsX, f32 inputOffsetInPixelsY) { | ||
| 140 | FsrEasuCon(con0, con1, con2, con3, inputViewportInPixelsX, inputViewportInPixelsY, | 143 | FsrEasuCon(con0, con1, con2, con3, inputViewportInPixelsX, inputViewportInPixelsY, |
| 141 | inputSizeInPixelsX, inputSizeInPixelsY, outputSizeInPixelsX, outputSizeInPixelsY); | 144 | inputSizeInPixelsX, inputSizeInPixelsY, outputSizeInPixelsX, outputSizeInPixelsY); |
| 142 | con0[2] = std::bit_cast<u32>(0.5f * inputViewportInPixelsX / outputSizeInPixelsX - 0.5f + | 145 | con0[2] = Common::BitCast<u32>(0.5f * inputViewportInPixelsX / outputSizeInPixelsX - 0.5f + |
| 143 | inputOffsetInPixelsX); | 146 | inputOffsetInPixelsX); |
| 144 | con0[3] = std::bit_cast<u32>(0.5f * inputViewportInPixelsY / outputSizeInPixelsY - 0.5f + | 147 | con0[3] = Common::BitCast<u32>(0.5f * inputViewportInPixelsY / outputSizeInPixelsY - 0.5f + |
| 145 | inputOffsetInPixelsY); | 148 | inputOffsetInPixelsY); |
| 146 | } | 149 | } |
| 147 | 150 | ||
| 148 | static void FsrRcasCon(u32* con, f32 sharpness) { | 151 | void FsrRcasCon(u32* con, f32 sharpness) { |
| 149 | sharpness = std::exp2f(-sharpness); | 152 | sharpness = std::exp2f(-sharpness); |
| 150 | f32 hSharp[2]{sharpness, sharpness}; | 153 | f32 hSharp[2]{sharpness, sharpness}; |
| 151 | con[0] = std::bit_cast<u32>(sharpness); | 154 | con[0] = Common::BitCast<u32>(sharpness); |
| 152 | con[1] = AU1_AH2_AF2(hSharp); | 155 | con[1] = AU1_AH2_AF2(hSharp); |
| 153 | con[2] = 0; | 156 | con[2] = 0; |
| 154 | con[3] = 0; | 157 | con[3] = 0; |
| 155 | } | 158 | } |
| 156 | 159 | } // Anonymous namespace | |
| 157 | namespace Vulkan { | ||
| 158 | 160 | ||
| 159 | FSR::FSR(const Device& device_, MemoryAllocator& memory_allocator_, size_t image_count_, | 161 | FSR::FSR(const Device& device_, MemoryAllocator& memory_allocator_, size_t image_count_, |
| 160 | VkExtent2D output_size_) | 162 | VkExtent2D output_size_) |