diff options
Diffstat (limited to 'src/video_core/host_shaders')
15 files changed, 73 insertions, 70 deletions
diff --git a/src/video_core/host_shaders/CMakeLists.txt b/src/video_core/host_shaders/CMakeLists.txt index cd2549232..969f21d50 100644 --- a/src/video_core/host_shaders/CMakeLists.txt +++ b/src/video_core/host_shaders/CMakeLists.txt @@ -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 diff --git a/src/video_core/host_shaders/fidelityfx_fsr.comp b/src/video_core/host_shaders/fidelityfx_fsr.frag index f91b1aa9f..a266e1c4e 100644 --- a/src/video_core/host_shaders/fidelityfx_fsr.comp +++ b/src/video_core/host_shaders/fidelityfx_fsr.frag @@ -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 } diff --git a/src/video_core/host_shaders/fxaa.vert b/src/video_core/host_shaders/fxaa.vert index c2717d90d..223ab785e 100644 --- a/src/video_core/host_shaders/fxaa.vert +++ b/src/video_core/host_shaders/fxaa.vert @@ -7,8 +7,8 @@ out gl_PerVertex { vec4 gl_Position; }; -const vec2 vertices[4] = - vec2[4](vec2(-1.0, 1.0), vec2(1.0, 1.0), vec2(-1.0, -1.0), vec2(1.0, -1.0)); +const vec2 vertices[3] = + vec2[3](vec2(-1,-1), vec2(3,-1), vec2(-1, 3)); layout (location = 0) out vec4 posPos; diff --git a/src/video_core/host_shaders/opengl_present_scaleforce.frag b/src/video_core/host_shaders/opengl_present_scaleforce.frag index a780373e3..1598575a1 100644 --- a/src/video_core/host_shaders/opengl_present_scaleforce.frag +++ b/src/video_core/host_shaders/opengl_present_scaleforce.frag @@ -26,21 +26,11 @@ #endif -#ifdef VULKAN - -#define BINDING_COLOR_TEXTURE 1 - -#else // ^^^ Vulkan ^^^ // vvv OpenGL vvv - -#define BINDING_COLOR_TEXTURE 0 - -#endif - layout (location = 0) in vec2 tex_coord; layout (location = 0) out vec4 frag_color; -layout (binding = BINDING_COLOR_TEXTURE) uniform sampler2D input_texture; +layout (binding = 0) uniform sampler2D input_texture; const bool ignore_alpha = true; diff --git a/src/video_core/host_shaders/present_bicubic.frag b/src/video_core/host_shaders/present_bicubic.frag index c57dd2851..c814629cf 100644 --- a/src/video_core/host_shaders/present_bicubic.frag +++ b/src/video_core/host_shaders/present_bicubic.frag @@ -3,22 +3,12 @@ #version 460 core -#ifdef VULKAN - -#define BINDING_COLOR_TEXTURE 1 - -#else // ^^^ Vulkan ^^^ // vvv OpenGL vvv - -#define BINDING_COLOR_TEXTURE 0 - -#endif - layout (location = 0) in vec2 frag_tex_coord; layout (location = 0) out vec4 color; -layout (binding = BINDING_COLOR_TEXTURE) uniform sampler2D color_texture; +layout (binding = 0) uniform sampler2D color_texture; vec4 cubic(float v) { vec4 n = vec4(1.0, 2.0, 3.0, 4.0) - v; diff --git a/src/video_core/host_shaders/present_gaussian.frag b/src/video_core/host_shaders/present_gaussian.frag index 5f54b71b6..ad9bb76a4 100644 --- a/src/video_core/host_shaders/present_gaussian.frag +++ b/src/video_core/host_shaders/present_gaussian.frag @@ -7,21 +7,11 @@ #version 460 core -#ifdef VULKAN - -#define BINDING_COLOR_TEXTURE 1 - -#else // ^^^ Vulkan ^^^ // vvv OpenGL vvv - -#define BINDING_COLOR_TEXTURE 0 - -#endif - layout(location = 0) in vec2 frag_tex_coord; layout(location = 0) out vec4 color; -layout(binding = BINDING_COLOR_TEXTURE) uniform sampler2D color_texture; +layout(binding = 0) uniform sampler2D color_texture; const float offset[3] = float[](0.0, 1.3846153846, 3.2307692308); const float weight[3] = float[](0.2270270270, 0.3162162162, 0.0702702703); diff --git a/src/video_core/host_shaders/vulkan_fidelityfx_fsr.vert b/src/video_core/host_shaders/vulkan_fidelityfx_fsr.vert new file mode 100644 index 000000000..6a87a7cac --- /dev/null +++ b/src/video_core/host_shaders/vulkan_fidelityfx_fsr.vert @@ -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; +} diff --git a/src/video_core/host_shaders/vulkan_fidelityfx_fsr_easu_fp16.comp b/src/video_core/host_shaders/vulkan_fidelityfx_fsr_easu_fp16.frag index 00af13726..d369bef06 100644 --- a/src/video_core/host_shaders/vulkan_fidelityfx_fsr_easu_fp16.comp +++ b/src/video_core/host_shaders/vulkan_fidelityfx_fsr_easu_fp16.frag @@ -7,4 +7,4 @@ #define YUZU_USE_FP16 #define USE_EASU 1 -#include "fidelityfx_fsr.comp" +#include "fidelityfx_fsr.frag" diff --git a/src/video_core/host_shaders/vulkan_fidelityfx_fsr_easu_fp32.comp b/src/video_core/host_shaders/vulkan_fidelityfx_fsr_easu_fp32.frag index 13d783fa8..6f25ef00f 100644 --- a/src/video_core/host_shaders/vulkan_fidelityfx_fsr_easu_fp32.comp +++ b/src/video_core/host_shaders/vulkan_fidelityfx_fsr_easu_fp32.frag @@ -6,4 +6,4 @@ #define USE_EASU 1 -#include "fidelityfx_fsr.comp" +#include "fidelityfx_fsr.frag" diff --git a/src/video_core/host_shaders/vulkan_fidelityfx_fsr_rcas_fp16.comp b/src/video_core/host_shaders/vulkan_fidelityfx_fsr_rcas_fp16.frag index 331549d96..0c953a900 100644 --- a/src/video_core/host_shaders/vulkan_fidelityfx_fsr_rcas_fp16.comp +++ b/src/video_core/host_shaders/vulkan_fidelityfx_fsr_rcas_fp16.frag @@ -7,4 +7,4 @@ #define YUZU_USE_FP16 #define USE_RCAS 1 -#include "fidelityfx_fsr.comp" +#include "fidelityfx_fsr.frag" diff --git a/src/video_core/host_shaders/vulkan_fidelityfx_fsr_rcas_fp32.comp b/src/video_core/host_shaders/vulkan_fidelityfx_fsr_rcas_fp32.frag index 013ca0014..02e9a27c6 100644 --- a/src/video_core/host_shaders/vulkan_fidelityfx_fsr_rcas_fp32.comp +++ b/src/video_core/host_shaders/vulkan_fidelityfx_fsr_rcas_fp32.frag @@ -6,4 +6,4 @@ #define USE_RCAS 1 -#include "fidelityfx_fsr.comp" +#include "fidelityfx_fsr.frag" diff --git a/src/video_core/host_shaders/vulkan_present.frag b/src/video_core/host_shaders/vulkan_present.frag index 97e098ced..adada9411 100644 --- a/src/video_core/host_shaders/vulkan_present.frag +++ b/src/video_core/host_shaders/vulkan_present.frag @@ -7,7 +7,7 @@ layout (location = 0) in vec2 frag_tex_coord; layout (location = 0) out vec4 color; -layout (binding = 1) uniform sampler2D color_texture; +layout (binding = 0) uniform sampler2D color_texture; void main() { color = texture(color_texture, frag_tex_coord); diff --git a/src/video_core/host_shaders/vulkan_present.vert b/src/video_core/host_shaders/vulkan_present.vert index 89dc80468..249c9675a 100644 --- a/src/video_core/host_shaders/vulkan_present.vert +++ b/src/video_core/host_shaders/vulkan_present.vert @@ -3,16 +3,37 @@ #version 460 core -layout (location = 0) in vec2 vert_position; -layout (location = 1) in vec2 vert_tex_coord; - layout (location = 0) out vec2 frag_tex_coord; -layout (set = 0, binding = 0) uniform MatrixBlock { +struct ScreenRectVertex { + vec2 position; + vec2 tex_coord; +}; + +layout (push_constant) uniform PushConstants { mat4 modelview_matrix; + ScreenRectVertex vertices[4]; }; +// Vulkan spec 15.8.1: +// Any member of a push constant block that is declared as an +// array must only be accessed with dynamically uniform indices. +ScreenRectVertex GetVertex(int index) { + switch (index) { + case 0: + default: + return vertices[0]; + case 1: + return vertices[1]; + case 2: + return vertices[2]; + case 3: + return vertices[3]; + } +} + void main() { - gl_Position = modelview_matrix * vec4(vert_position, 0.0, 1.0); - frag_tex_coord = vert_tex_coord; + ScreenRectVertex vertex = GetVertex(gl_VertexIndex); + gl_Position = modelview_matrix * vec4(vertex.position, 0.0, 1.0); + frag_tex_coord = vertex.tex_coord; } diff --git a/src/video_core/host_shaders/vulkan_present_scaleforce_fp16.frag b/src/video_core/host_shaders/vulkan_present_scaleforce_fp16.frag index 3dc9c0df5..79ea817c2 100644 --- a/src/video_core/host_shaders/vulkan_present_scaleforce_fp16.frag +++ b/src/video_core/host_shaders/vulkan_present_scaleforce_fp16.frag @@ -5,6 +5,7 @@ #extension GL_GOOGLE_include_directive : enable +#define VERSION 1 #define YUZU_USE_FP16 #include "opengl_present_scaleforce.frag" diff --git a/src/video_core/host_shaders/vulkan_present_scaleforce_fp32.frag b/src/video_core/host_shaders/vulkan_present_scaleforce_fp32.frag index 77ed07552..9605bb58b 100644 --- a/src/video_core/host_shaders/vulkan_present_scaleforce_fp32.frag +++ b/src/video_core/host_shaders/vulkan_present_scaleforce_fp32.frag @@ -5,4 +5,6 @@ #extension GL_GOOGLE_include_directive : enable +#define VERSION 1 + #include "opengl_present_scaleforce.frag" |