yuzu-emu
/
yuzu
Archived
1
0
Fork 0

FSR: Fix GCC build errors

This commit is contained in:
ameerj 2021-10-23 01:29:44 -04:00 committed by Fernando Sahmkow
parent bb03675485
commit 99124b7261
3 changed files with 50 additions and 43 deletions

View File

@ -468,20 +468,14 @@ void VKBlitScreen::CreateDynamicResources() {
CreateGraphicsPipeline(); CreateGraphicsPipeline();
fsr.reset(); fsr.reset();
if (Settings::values.scaling_filter.GetValue() == Settings::ScalingFilter::Fsr) { if (Settings::values.scaling_filter.GetValue() == Settings::ScalingFilter::Fsr) {
const auto& layout = render_window.GetFramebufferLayout(); CreateFSR();
fsr = std::make_unique<FSR>(
device, memory_allocator, image_count,
VkExtent2D{.width = layout.screen.GetWidth(), .height = layout.screen.GetHeight()});
} }
} }
void VKBlitScreen::RefreshResources(const Tegra::FramebufferConfig& framebuffer) { void VKBlitScreen::RefreshResources(const Tegra::FramebufferConfig& framebuffer) {
if (Settings::values.scaling_filter.GetValue() == Settings::ScalingFilter::Fsr) { if (Settings::values.scaling_filter.GetValue() == Settings::ScalingFilter::Fsr) {
if (!fsr) { if (!fsr) {
const auto& layout = render_window.GetFramebufferLayout(); CreateFSR();
fsr = std::make_unique<FSR>(
device, memory_allocator, image_count,
VkExtent2D{.width = layout.screen.GetWidth(), .height = layout.screen.GetHeight()});
} }
} else { } else {
fsr.reset(); fsr.reset();
@ -1443,6 +1437,15 @@ void VKBlitScreen::SetVertexData(BufferData& data, const Tegra::FramebufferConfi
data.vertices[3] = ScreenRectVertex(x + w, y + h, texcoords.bottom * scale_u, right * scale_v); data.vertices[3] = ScreenRectVertex(x + w, y + h, texcoords.bottom * scale_u, right * scale_v);
} }
void VKBlitScreen::CreateFSR() {
const auto& layout = render_window.GetFramebufferLayout();
const VkExtent2D fsr_size{
.width = layout.screen.GetWidth(),
.height = layout.screen.GetHeight(),
};
fsr = std::make_unique<FSR>(device, memory_allocator, image_count, fsr_size);
}
u64 VKBlitScreen::CalculateBufferSize(const Tegra::FramebufferConfig& framebuffer) const { u64 VKBlitScreen::CalculateBufferSize(const Tegra::FramebufferConfig& framebuffer) const {
return sizeof(BufferData) + GetSizeInBytes(framebuffer) * image_count; return sizeof(BufferData) + GetSizeInBytes(framebuffer) * image_count;
} }

View File

@ -99,6 +99,8 @@ private:
void SetVertexData(BufferData& data, const Tegra::FramebufferConfig& framebuffer, void SetVertexData(BufferData& data, const Tegra::FramebufferConfig& framebuffer,
const Layout::FramebufferLayout layout) const; const Layout::FramebufferLayout layout) const;
void CreateFSR();
u64 CalculateBufferSize(const Tegra::FramebufferConfig& framebuffer) const; u64 CalculateBufferSize(const Tegra::FramebufferConfig& framebuffer) const;
u64 GetRawImageOffset(const Tegra::FramebufferConfig& framebuffer, u64 GetRawImageOffset(const Tegra::FramebufferConfig& framebuffer,
std::size_t image_index) const; std::size_t image_index) const;

View File

@ -2,8 +2,11 @@
// Licensed under GPLv2 or any later version // Licensed under GPLv2 or any later version
// Refer to the license.txt file included. // Refer to the license.txt file included.
#include <cmath>
#include "common/bit_cast.h"
#include "common/common_types.h" #include "common/common_types.h"
#include "common/div_ceil.h" #include "common/div_ceil.h"
#include "video_core/host_shaders/vulkan_fidelityfx_fsr_easu_fp16_comp_spv.h" #include "video_core/host_shaders/vulkan_fidelityfx_fsr_easu_fp16_comp_spv.h"
#include "video_core/host_shaders/vulkan_fidelityfx_fsr_easu_fp32_comp_spv.h" #include "video_core/host_shaders/vulkan_fidelityfx_fsr_easu_fp32_comp_spv.h"
#include "video_core/host_shaders/vulkan_fidelityfx_fsr_rcas_fp16_comp_spv.h" #include "video_core/host_shaders/vulkan_fidelityfx_fsr_rcas_fp16_comp_spv.h"
@ -13,9 +16,11 @@
#include "video_core/renderer_vulkan/vk_shader_util.h" #include "video_core/renderer_vulkan/vk_shader_util.h"
#include "video_core/vulkan_common/vulkan_device.h" #include "video_core/vulkan_common/vulkan_device.h"
namespace Vulkan {
namespace {
// Reimplementations of the constant generating functions in ffx_fsr1.h // Reimplementations of the constant generating functions in ffx_fsr1.h
// GCC generated a lot of warnings when using the official header. // GCC generated a lot of warnings when using the official header.
static u32 AU1_AH1_AF1(f32 f) { u32 AU1_AH1_AF1(f32 f) {
static constexpr u32 base[512]{ static constexpr u32 base[512]{
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
@ -102,59 +107,56 @@ static u32 AU1_AH1_AF1(f32 f) {
0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18,
0x18, 0x18, 0x18, 0x18,
}; };
auto u = std::bit_cast<u32>(f); const u32 u = Common::BitCast<u32>(f);
u32 i = u >> 23; const u32 i = u >> 23;
return base[i] + ((u & 0x7fffff) >> shift[i]); return base[i] + ((u & 0x7fffff) >> shift[i]);
} }
static u32 AU1_AH2_AF2(f32 a[2]) { u32 AU1_AH2_AF2(f32 a[2]) {
return AU1_AH1_AF1(a[0]) + (AU1_AH1_AF1(a[1]) << 16); return AU1_AH1_AF1(a[0]) + (AU1_AH1_AF1(a[1]) << 16);
} }
static void FsrEasuCon(u32 con0[4], u32 con1[4], u32 con2[4], u32 con3[4], void FsrEasuCon(u32 con0[4], u32 con1[4], u32 con2[4], u32 con3[4], f32 inputViewportInPixelsX,
f32 inputViewportInPixelsX, f32 inputViewportInPixelsY, f32 inputViewportInPixelsY, f32 inputSizeInPixelsX, f32 inputSizeInPixelsY,
f32 inputSizeInPixelsX, f32 inputSizeInPixelsY, f32 outputSizeInPixelsX, f32 outputSizeInPixelsX, f32 outputSizeInPixelsY) {
f32 outputSizeInPixelsY) { con0[0] = Common::BitCast<u32>(inputViewportInPixelsX / outputSizeInPixelsX);
con0[0] = std::bit_cast<u32>(inputViewportInPixelsX / outputSizeInPixelsX); con0[1] = Common::BitCast<u32>(inputViewportInPixelsY / outputSizeInPixelsY);
con0[1] = std::bit_cast<u32>(inputViewportInPixelsY / outputSizeInPixelsY); con0[2] = Common::BitCast<u32>(0.5f * inputViewportInPixelsX / outputSizeInPixelsX - 0.5f);
con0[2] = std::bit_cast<u32>(0.5f * inputViewportInPixelsX / outputSizeInPixelsX - 0.5f); con0[3] = Common::BitCast<u32>(0.5f * inputViewportInPixelsY / outputSizeInPixelsY - 0.5f);
con0[3] = std::bit_cast<u32>(0.5f * inputViewportInPixelsY / outputSizeInPixelsY - 0.5f); con1[0] = Common::BitCast<u32>(1.0f / inputSizeInPixelsX);
con1[0] = std::bit_cast<u32>(1.0f / inputSizeInPixelsX); con1[1] = Common::BitCast<u32>(1.0f / inputSizeInPixelsY);
con1[1] = std::bit_cast<u32>(1.0f / inputSizeInPixelsY); con1[2] = Common::BitCast<u32>(1.0f / inputSizeInPixelsX);
con1[2] = std::bit_cast<u32>(1.0f / inputSizeInPixelsX); con1[3] = Common::BitCast<u32>(-1.0f / inputSizeInPixelsY);
con1[3] = std::bit_cast<u32>(-1.0f / inputSizeInPixelsY); con2[0] = Common::BitCast<u32>(-1.0f / inputSizeInPixelsX);
con2[0] = std::bit_cast<u32>(-1.0f / inputSizeInPixelsX); con2[1] = Common::BitCast<u32>(2.0f / inputSizeInPixelsY);
con2[1] = std::bit_cast<u32>(2.0f / inputSizeInPixelsY); con2[2] = Common::BitCast<u32>(1.0f / inputSizeInPixelsX);
con2[2] = std::bit_cast<u32>(1.0f / inputSizeInPixelsX); con2[3] = Common::BitCast<u32>(2.0f / inputSizeInPixelsY);
con2[3] = std::bit_cast<u32>(2.0f / inputSizeInPixelsY); con3[0] = Common::BitCast<u32>(0.0f / inputSizeInPixelsX);
con3[0] = std::bit_cast<u32>(0.0f / inputSizeInPixelsX); con3[1] = Common::BitCast<u32>(4.0f / inputSizeInPixelsY);
con3[1] = std::bit_cast<u32>(4.0f / inputSizeInPixelsY);
con3[2] = con3[3] = 0; con3[2] = con3[3] = 0;
} }
static void FsrEasuConOffset(u32 con0[4], u32 con1[4], u32 con2[4], u32 con3[4], void FsrEasuConOffset(u32 con0[4], u32 con1[4], u32 con2[4], u32 con3[4],
f32 inputViewportInPixelsX, f32 inputViewportInPixelsY, f32 inputViewportInPixelsX, f32 inputViewportInPixelsY,
f32 inputSizeInPixelsX, f32 inputSizeInPixelsY, f32 inputSizeInPixelsX, f32 inputSizeInPixelsY, f32 outputSizeInPixelsX,
f32 outputSizeInPixelsX, f32 outputSizeInPixelsY, f32 outputSizeInPixelsY, f32 inputOffsetInPixelsX, f32 inputOffsetInPixelsY) {
f32 inputOffsetInPixelsX, f32 inputOffsetInPixelsY) {
FsrEasuCon(con0, con1, con2, con3, inputViewportInPixelsX, inputViewportInPixelsY, FsrEasuCon(con0, con1, con2, con3, inputViewportInPixelsX, inputViewportInPixelsY,
inputSizeInPixelsX, inputSizeInPixelsY, outputSizeInPixelsX, outputSizeInPixelsY); inputSizeInPixelsX, inputSizeInPixelsY, outputSizeInPixelsX, outputSizeInPixelsY);
con0[2] = std::bit_cast<u32>(0.5f * inputViewportInPixelsX / outputSizeInPixelsX - 0.5f + con0[2] = Common::BitCast<u32>(0.5f * inputViewportInPixelsX / outputSizeInPixelsX - 0.5f +
inputOffsetInPixelsX); inputOffsetInPixelsX);
con0[3] = std::bit_cast<u32>(0.5f * inputViewportInPixelsY / outputSizeInPixelsY - 0.5f + con0[3] = Common::BitCast<u32>(0.5f * inputViewportInPixelsY / outputSizeInPixelsY - 0.5f +
inputOffsetInPixelsY); inputOffsetInPixelsY);
} }
static void FsrRcasCon(u32* con, f32 sharpness) { void FsrRcasCon(u32* con, f32 sharpness) {
sharpness = std::exp2f(-sharpness); sharpness = std::exp2f(-sharpness);
f32 hSharp[2]{sharpness, sharpness}; f32 hSharp[2]{sharpness, sharpness};
con[0] = std::bit_cast<u32>(sharpness); con[0] = Common::BitCast<u32>(sharpness);
con[1] = AU1_AH2_AF2(hSharp); con[1] = AU1_AH2_AF2(hSharp);
con[2] = 0; con[2] = 0;
con[3] = 0; con[3] = 0;
} }
} // Anonymous namespace
namespace Vulkan {
FSR::FSR(const Device& device_, MemoryAllocator& memory_allocator_, size_t image_count_, FSR::FSR(const Device& device_, MemoryAllocator& memory_allocator_, size_t image_count_,
VkExtent2D output_size_) VkExtent2D output_size_)