renderer_vulkan: convert FSR to graphics pipeline

This commit is contained in:
Liam
2024-01-15 10:19:02 -05:00
parent b78900e956
commit 2ed9586130
17 changed files with 311 additions and 463 deletions

View File

@ -9,7 +9,7 @@ set(FIDELITYFX_FILES
)
set(GLSL_INCLUDES
fidelityfx_fsr.comp
fidelityfx_fsr.frag
${FIDELITYFX_FILES}
)
@ -56,10 +56,11 @@ set(SHADER_FILES
vulkan_color_clear.frag
vulkan_color_clear.vert
vulkan_depthstencil_clear.frag
vulkan_fidelityfx_fsr_easu_fp16.comp
vulkan_fidelityfx_fsr_easu_fp32.comp
vulkan_fidelityfx_fsr_rcas_fp16.comp
vulkan_fidelityfx_fsr_rcas_fp32.comp
vulkan_fidelityfx_fsr.vert
vulkan_fidelityfx_fsr_easu_fp16.frag
vulkan_fidelityfx_fsr_easu_fp32.frag
vulkan_fidelityfx_fsr_rcas_fp16.frag
vulkan_fidelityfx_fsr_rcas_fp32.frag
vulkan_present.frag
vulkan_present.vert
vulkan_present_scaleforce_fp16.frag

View File

@ -34,7 +34,6 @@ layout( push_constant ) uniform constants {
};
layout(set=0,binding=0) uniform sampler2D InputTexture;
layout(set=0,binding=1,rgba16f) uniform image2D OutputTexture;
#define A_GPU 1
#define A_GLSL 1
@ -72,44 +71,40 @@ layout(set=0,binding=1,rgba16f) uniform image2D OutputTexture;
#include "ffx_fsr1.h"
void CurrFilter(AU2 pos) {
#if USE_BILINEAR
AF2 pp = (AF2(pos) * AF2_AU2(Const0.xy) + AF2_AU2(Const0.zw)) * AF2_AU2(Const1.xy) + AF2(0.5, -0.5) * AF2_AU2(Const1.zw);
imageStore(OutputTexture, ASU2(pos), textureLod(InputTexture, pp, 0.0));
#if USE_RCAS
layout(location = 0) in vec2 frag_texcoord;
#endif
layout (location = 0) out vec4 frag_color;
void CurrFilter(AU2 pos) {
#if USE_EASU
#ifndef YUZU_USE_FP16
AF3 c;
FsrEasuF(c, pos, Const0, Const1, Const2, Const3);
imageStore(OutputTexture, ASU2(pos), AF4(c, 1));
frag_color = AF4(c, 1.0);
#else
AH3 c;
FsrEasuH(c, pos, Const0, Const1, Const2, Const3);
imageStore(OutputTexture, ASU2(pos), AH4(c, 1));
frag_color = AH4(c, 1.0);
#endif
#endif
#if USE_RCAS
#ifndef YUZU_USE_FP16
AF3 c;
FsrRcasF(c.r, c.g, c.b, pos, Const0);
imageStore(OutputTexture, ASU2(pos), AF4(c, 1));
frag_color = AF4(c, 1.0);
#else
AH3 c;
FsrRcasH(c.r, c.g, c.b, pos, Const0);
imageStore(OutputTexture, ASU2(pos), AH4(c, 1));
frag_color = AH4(c, 1.0);
#endif
#endif
}
layout(local_size_x=64) in;
void main() {
// Do remapping of local xy in workgroup for a more PS-like swizzle pattern.
AU2 gxy = ARmp8x8(gl_LocalInvocationID.x) + AU2(gl_WorkGroupID.x << 4u, gl_WorkGroupID.y << 4u);
CurrFilter(gxy);
gxy.x += 8u;
CurrFilter(gxy);
gxy.y += 8u;
CurrFilter(gxy);
gxy.x -= 8u;
CurrFilter(gxy);
#if USE_RCAS
CurrFilter(AU2(frag_texcoord * vec2(textureSize(InputTexture, 0))));
#else
CurrFilter(AU2(gl_FragCoord.xy));
#endif
}

View File

@ -0,0 +1,13 @@
// SPDX-FileCopyrightText: Copyright 2024 yuzu Emulator Project
// SPDX-License-Identifier: GPL-2.0-or-later
#version 450
layout(location = 0) out vec2 texcoord;
void main() {
float x = float((gl_VertexIndex & 1) << 2);
float y = float((gl_VertexIndex & 2) << 1);
gl_Position = vec4(x - 1.0, y - 1.0, 0.0, 1.0);
texcoord = vec2(x, y) / 2.0;
}

View File

@ -7,4 +7,4 @@
#define YUZU_USE_FP16
#define USE_EASU 1
#include "fidelityfx_fsr.comp"
#include "fidelityfx_fsr.frag"

View File

@ -6,4 +6,4 @@
#define USE_EASU 1
#include "fidelityfx_fsr.comp"
#include "fidelityfx_fsr.frag"

View File

@ -7,4 +7,4 @@
#define YUZU_USE_FP16
#define USE_RCAS 1
#include "fidelityfx_fsr.comp"
#include "fidelityfx_fsr.frag"

View File

@ -6,4 +6,4 @@
#define USE_RCAS 1
#include "fidelityfx_fsr.comp"
#include "fidelityfx_fsr.frag"