diff options
| author | 2024-01-22 12:40:50 -0500 | |
|---|---|---|
| committer | 2024-02-09 09:20:53 -0500 | |
| commit | 962c82540c304f909957776908aabcd261f2a7ba (patch) | |
| tree | 707ab34565e8309b5ede21acebf36975da7718e7 /src/video_core/host_shaders | |
| parent | nvservices: unmap only on last container free (diff) | |
| download | yuzu-962c82540c304f909957776908aabcd261f2a7ba.tar.gz yuzu-962c82540c304f909957776908aabcd261f2a7ba.tar.xz yuzu-962c82540c304f909957776908aabcd261f2a7ba.zip | |
nvnflinger/gpu: implement blending
Diffstat (limited to 'src/video_core/host_shaders')
12 files changed, 35 insertions, 33 deletions
diff --git a/src/video_core/host_shaders/fidelityfx_fsr.frag b/src/video_core/host_shaders/fidelityfx_fsr.frag index a266e1c4e..54eedb450 100644 --- a/src/video_core/host_shaders/fidelityfx_fsr.frag +++ b/src/video_core/host_shaders/fidelityfx_fsr.frag | |||
| @@ -37,6 +37,7 @@ layout(set=0,binding=0) uniform sampler2D InputTexture; | |||
| 37 | 37 | ||
| 38 | #define A_GPU 1 | 38 | #define A_GPU 1 |
| 39 | #define A_GLSL 1 | 39 | #define A_GLSL 1 |
| 40 | #define FSR_RCAS_PASSTHROUGH_ALPHA 1 | ||
| 40 | 41 | ||
| 41 | #ifndef YUZU_USE_FP16 | 42 | #ifndef YUZU_USE_FP16 |
| 42 | #include "ffx_a.h" | 43 | #include "ffx_a.h" |
| @@ -71,9 +72,7 @@ layout(set=0,binding=0) uniform sampler2D InputTexture; | |||
| 71 | 72 | ||
| 72 | #include "ffx_fsr1.h" | 73 | #include "ffx_fsr1.h" |
| 73 | 74 | ||
| 74 | #if USE_RCAS | 75 | layout (location = 0) in vec2 frag_texcoord; |
| 75 | layout(location = 0) in vec2 frag_texcoord; | ||
| 76 | #endif | ||
| 77 | layout (location = 0) out vec4 frag_color; | 76 | layout (location = 0) out vec4 frag_color; |
| 78 | 77 | ||
| 79 | void CurrFilter(AU2 pos) { | 78 | void CurrFilter(AU2 pos) { |
| @@ -81,22 +80,22 @@ void CurrFilter(AU2 pos) { | |||
| 81 | #ifndef YUZU_USE_FP16 | 80 | #ifndef YUZU_USE_FP16 |
| 82 | AF3 c; | 81 | AF3 c; |
| 83 | FsrEasuF(c, pos, Const0, Const1, Const2, Const3); | 82 | FsrEasuF(c, pos, Const0, Const1, Const2, Const3); |
| 84 | frag_color = AF4(c, 1.0); | 83 | frag_color = AF4(c, texture(InputTexture, frag_texcoord).a); |
| 85 | #else | 84 | #else |
| 86 | AH3 c; | 85 | AH3 c; |
| 87 | FsrEasuH(c, pos, Const0, Const1, Const2, Const3); | 86 | FsrEasuH(c, pos, Const0, Const1, Const2, Const3); |
| 88 | frag_color = AH4(c, 1.0); | 87 | frag_color = AH4(c, texture(InputTexture, frag_texcoord).a); |
| 89 | #endif | 88 | #endif |
| 90 | #endif | 89 | #endif |
| 91 | #if USE_RCAS | 90 | #if USE_RCAS |
| 92 | #ifndef YUZU_USE_FP16 | 91 | #ifndef YUZU_USE_FP16 |
| 93 | AF3 c; | 92 | AF4 c; |
| 94 | FsrRcasF(c.r, c.g, c.b, pos, Const0); | 93 | FsrRcasF(c.r, c.g, c.b, c.a, pos, Const0); |
| 95 | frag_color = AF4(c, 1.0); | 94 | frag_color = c; |
| 96 | #else | 95 | #else |
| 97 | AH3 c; | 96 | AH4 c; |
| 98 | FsrRcasH(c.r, c.g, c.b, pos, Const0); | 97 | FsrRcasH(c.r, c.g, c.b, c.a, pos, Const0); |
| 99 | frag_color = AH4(c, 1.0); | 98 | frag_color = c; |
| 100 | #endif | 99 | #endif |
| 101 | #endif | 100 | #endif |
| 102 | } | 101 | } |
diff --git a/src/video_core/host_shaders/fxaa.frag b/src/video_core/host_shaders/fxaa.frag index 9bffc20d5..192a602c1 100644 --- a/src/video_core/host_shaders/fxaa.frag +++ b/src/video_core/host_shaders/fxaa.frag | |||
| @@ -71,5 +71,5 @@ vec3 FxaaPixelShader(vec4 posPos, sampler2D tex) { | |||
| 71 | } | 71 | } |
| 72 | 72 | ||
| 73 | void main() { | 73 | void main() { |
| 74 | frag_color = vec4(FxaaPixelShader(posPos, input_texture), 1.0); | 74 | frag_color = vec4(FxaaPixelShader(posPos, input_texture), texture(input_texture, posPos.xy).a); |
| 75 | } | 75 | } |
diff --git a/src/video_core/host_shaders/opengl_fidelityfx_fsr.frag b/src/video_core/host_shaders/opengl_fidelityfx_fsr.frag index 16d22f58e..fc47d3810 100644 --- a/src/video_core/host_shaders/opengl_fidelityfx_fsr.frag +++ b/src/video_core/host_shaders/opengl_fidelityfx_fsr.frag | |||
| @@ -31,6 +31,7 @@ layout (location = 0) uniform uvec4 constants[4]; | |||
| 31 | 31 | ||
| 32 | #define A_GPU 1 | 32 | #define A_GPU 1 |
| 33 | #define A_GLSL 1 | 33 | #define A_GLSL 1 |
| 34 | #define FSR_RCAS_PASSTHROUGH_ALPHA 1 | ||
| 34 | 35 | ||
| 35 | #ifdef YUZU_USE_FP16 | 36 | #ifdef YUZU_USE_FP16 |
| 36 | #define A_HALF | 37 | #define A_HALF |
| @@ -67,9 +68,7 @@ layout (location = 0) uniform uvec4 constants[4]; | |||
| 67 | 68 | ||
| 68 | #include "ffx_fsr1.h" | 69 | #include "ffx_fsr1.h" |
| 69 | 70 | ||
| 70 | #if USE_RCAS | 71 | layout (location = 0) in vec2 frag_texcoord; |
| 71 | layout(location = 0) in vec2 frag_texcoord; | ||
| 72 | #endif | ||
| 73 | layout (location = 0) out vec4 frag_color; | 72 | layout (location = 0) out vec4 frag_color; |
| 74 | 73 | ||
| 75 | void CurrFilter(AU2 pos) | 74 | void CurrFilter(AU2 pos) |
| @@ -78,22 +77,22 @@ void CurrFilter(AU2 pos) | |||
| 78 | #ifndef YUZU_USE_FP16 | 77 | #ifndef YUZU_USE_FP16 |
| 79 | AF3 c; | 78 | AF3 c; |
| 80 | FsrEasuF(c, pos, constants[0], constants[1], constants[2], constants[3]); | 79 | FsrEasuF(c, pos, constants[0], constants[1], constants[2], constants[3]); |
| 81 | frag_color = AF4(c, 1.0); | 80 | frag_color = AF4(c, texture(InputTexture, frag_texcoord).a); |
| 82 | #else | 81 | #else |
| 83 | AH3 c; | 82 | AH3 c; |
| 84 | FsrEasuH(c, pos, constants[0], constants[1], constants[2], constants[3]); | 83 | FsrEasuH(c, pos, constants[0], constants[1], constants[2], constants[3]); |
| 85 | frag_color = AH4(c, 1.0); | 84 | frag_color = AH4(c, texture(InputTexture, frag_texcoord).a); |
| 86 | #endif | 85 | #endif |
| 87 | #endif | 86 | #endif |
| 88 | #if USE_RCAS | 87 | #if USE_RCAS |
| 89 | #ifndef YUZU_USE_FP16 | 88 | #ifndef YUZU_USE_FP16 |
| 90 | AF3 c; | 89 | AF4 c; |
| 91 | FsrRcasF(c.r, c.g, c.b, pos, constants[0]); | 90 | FsrRcasF(c.r, c.g, c.b, c.a, pos, constants[0]); |
| 92 | frag_color = AF4(c, 1.0); | 91 | frag_color = c; |
| 93 | #else | 92 | #else |
| 94 | AH3 c; | 93 | AH3 c; |
| 95 | FsrRcasH(c.r, c.g, c.b, pos, constants[0]); | 94 | FsrRcasH(c.r, c.g, c.b, c.a, pos, constants[0]); |
| 96 | frag_color = AH4(c, 1.0); | 95 | frag_color = c; |
| 97 | #endif | 96 | #endif |
| 98 | #endif | 97 | #endif |
| 99 | } | 98 | } |
diff --git a/src/video_core/host_shaders/opengl_present.frag b/src/video_core/host_shaders/opengl_present.frag index 5fd7ad297..096b4e4db 100644 --- a/src/video_core/host_shaders/opengl_present.frag +++ b/src/video_core/host_shaders/opengl_present.frag | |||
| @@ -9,5 +9,5 @@ layout (location = 0) out vec4 color; | |||
| 9 | layout (binding = 0) uniform sampler2D color_texture; | 9 | layout (binding = 0) uniform sampler2D color_texture; |
| 10 | 10 | ||
| 11 | void main() { | 11 | void main() { |
| 12 | color = vec4(texture(color_texture, frag_tex_coord).rgb, 1.0f); | 12 | color = vec4(texture(color_texture, frag_tex_coord)); |
| 13 | } | 13 | } |
diff --git a/src/video_core/host_shaders/present_bicubic.frag b/src/video_core/host_shaders/present_bicubic.frag index c814629cf..a9d9d40a3 100644 --- a/src/video_core/host_shaders/present_bicubic.frag +++ b/src/video_core/host_shaders/present_bicubic.frag | |||
| @@ -52,5 +52,5 @@ vec4 textureBicubic( sampler2D textureSampler, vec2 texCoords ) { | |||
| 52 | } | 52 | } |
| 53 | 53 | ||
| 54 | void main() { | 54 | void main() { |
| 55 | color = vec4(textureBicubic(color_texture, frag_tex_coord).rgb, 1.0f); | 55 | color = textureBicubic(color_texture, frag_tex_coord); |
| 56 | } | 56 | } |
diff --git a/src/video_core/host_shaders/present_gaussian.frag b/src/video_core/host_shaders/present_gaussian.frag index ad9bb76a4..78edeb9b4 100644 --- a/src/video_core/host_shaders/present_gaussian.frag +++ b/src/video_core/host_shaders/present_gaussian.frag | |||
| @@ -46,14 +46,14 @@ vec4 blurDiagonal(sampler2D textureSampler, vec2 coord, vec2 norm) { | |||
| 46 | } | 46 | } |
| 47 | 47 | ||
| 48 | void main() { | 48 | void main() { |
| 49 | vec3 base = texture(color_texture, vec2(frag_tex_coord)).rgb * weight[0]; | 49 | vec4 base = texture(color_texture, vec2(frag_tex_coord)) * weight[0]; |
| 50 | vec2 tex_offset = 1.0f / textureSize(color_texture, 0); | 50 | vec2 tex_offset = 1.0f / textureSize(color_texture, 0); |
| 51 | 51 | ||
| 52 | // TODO(Blinkhawk): This code can be optimized through shader group instructions. | 52 | // TODO(Blinkhawk): This code can be optimized through shader group instructions. |
| 53 | vec3 horizontal = blurHorizontal(color_texture, frag_tex_coord, tex_offset).rgb; | 53 | vec4 horizontal = blurHorizontal(color_texture, frag_tex_coord, tex_offset); |
| 54 | vec3 vertical = blurVertical(color_texture, frag_tex_coord, tex_offset).rgb; | 54 | vec4 vertical = blurVertical(color_texture, frag_tex_coord, tex_offset); |
| 55 | vec3 diagonalA = blurDiagonal(color_texture, frag_tex_coord, tex_offset).rgb; | 55 | vec4 diagonalA = blurDiagonal(color_texture, frag_tex_coord, tex_offset); |
| 56 | vec3 diagonalB = blurDiagonal(color_texture, frag_tex_coord, tex_offset * vec2(1.0, -1.0)).rgb; | 56 | vec4 diagonalB = blurDiagonal(color_texture, frag_tex_coord, tex_offset * vec2(1.0, -1.0)); |
| 57 | vec3 combination = mix(mix(horizontal, vertical, 0.5f), mix(diagonalA, diagonalB, 0.5f), 0.5f); | 57 | vec4 combination = mix(mix(horizontal, vertical, 0.5f), mix(diagonalA, diagonalB, 0.5f), 0.5f); |
| 58 | color = vec4(combination + base, 1.0f); | 58 | color = combination + base; |
| 59 | } | 59 | } |
diff --git a/src/video_core/host_shaders/vulkan_fidelityfx_fsr_easu_fp16.frag b/src/video_core/host_shaders/vulkan_fidelityfx_fsr_easu_fp16.frag index d369bef06..05d033310 100644 --- a/src/video_core/host_shaders/vulkan_fidelityfx_fsr_easu_fp16.frag +++ b/src/video_core/host_shaders/vulkan_fidelityfx_fsr_easu_fp16.frag | |||
| @@ -6,5 +6,6 @@ | |||
| 6 | 6 | ||
| 7 | #define YUZU_USE_FP16 | 7 | #define YUZU_USE_FP16 |
| 8 | #define USE_EASU 1 | 8 | #define USE_EASU 1 |
| 9 | #define VERSION 1 | ||
| 9 | 10 | ||
| 10 | #include "fidelityfx_fsr.frag" | 11 | #include "fidelityfx_fsr.frag" |
diff --git a/src/video_core/host_shaders/vulkan_fidelityfx_fsr_easu_fp32.frag b/src/video_core/host_shaders/vulkan_fidelityfx_fsr_easu_fp32.frag index 6f25ef00f..7ae11dd66 100644 --- a/src/video_core/host_shaders/vulkan_fidelityfx_fsr_easu_fp32.frag +++ b/src/video_core/host_shaders/vulkan_fidelityfx_fsr_easu_fp32.frag | |||
| @@ -5,5 +5,6 @@ | |||
| 5 | #extension GL_GOOGLE_include_directive : enable | 5 | #extension GL_GOOGLE_include_directive : enable |
| 6 | 6 | ||
| 7 | #define USE_EASU 1 | 7 | #define USE_EASU 1 |
| 8 | #define VERSION 1 | ||
| 8 | 9 | ||
| 9 | #include "fidelityfx_fsr.frag" | 10 | #include "fidelityfx_fsr.frag" |
diff --git a/src/video_core/host_shaders/vulkan_fidelityfx_fsr_rcas_fp16.frag b/src/video_core/host_shaders/vulkan_fidelityfx_fsr_rcas_fp16.frag index 0c953a900..c017214a5 100644 --- a/src/video_core/host_shaders/vulkan_fidelityfx_fsr_rcas_fp16.frag +++ b/src/video_core/host_shaders/vulkan_fidelityfx_fsr_rcas_fp16.frag | |||
| @@ -6,5 +6,6 @@ | |||
| 6 | 6 | ||
| 7 | #define YUZU_USE_FP16 | 7 | #define YUZU_USE_FP16 |
| 8 | #define USE_RCAS 1 | 8 | #define USE_RCAS 1 |
| 9 | #define VERSION 1 | ||
| 9 | 10 | ||
| 10 | #include "fidelityfx_fsr.frag" | 11 | #include "fidelityfx_fsr.frag" |
diff --git a/src/video_core/host_shaders/vulkan_fidelityfx_fsr_rcas_fp32.frag b/src/video_core/host_shaders/vulkan_fidelityfx_fsr_rcas_fp32.frag index 02e9a27c6..976825f4b 100644 --- a/src/video_core/host_shaders/vulkan_fidelityfx_fsr_rcas_fp32.frag +++ b/src/video_core/host_shaders/vulkan_fidelityfx_fsr_rcas_fp32.frag | |||
| @@ -5,5 +5,6 @@ | |||
| 5 | #extension GL_GOOGLE_include_directive : enable | 5 | #extension GL_GOOGLE_include_directive : enable |
| 6 | 6 | ||
| 7 | #define USE_RCAS 1 | 7 | #define USE_RCAS 1 |
| 8 | #define VERSION 1 | ||
| 8 | 9 | ||
| 9 | #include "fidelityfx_fsr.frag" | 10 | #include "fidelityfx_fsr.frag" |
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 79ea817c2..cea5dac9d 100644 --- a/src/video_core/host_shaders/vulkan_present_scaleforce_fp16.frag +++ b/src/video_core/host_shaders/vulkan_present_scaleforce_fp16.frag | |||
| @@ -5,7 +5,7 @@ | |||
| 5 | 5 | ||
| 6 | #extension GL_GOOGLE_include_directive : enable | 6 | #extension GL_GOOGLE_include_directive : enable |
| 7 | 7 | ||
| 8 | #define VERSION 1 | 8 | #define VERSION 2 |
| 9 | #define YUZU_USE_FP16 | 9 | #define YUZU_USE_FP16 |
| 10 | 10 | ||
| 11 | #include "opengl_present_scaleforce.frag" | 11 | #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 9605bb58b..10ddf0401 100644 --- a/src/video_core/host_shaders/vulkan_present_scaleforce_fp32.frag +++ b/src/video_core/host_shaders/vulkan_present_scaleforce_fp32.frag | |||
| @@ -5,6 +5,6 @@ | |||
| 5 | 5 | ||
| 6 | #extension GL_GOOGLE_include_directive : enable | 6 | #extension GL_GOOGLE_include_directive : enable |
| 7 | 7 | ||
| 8 | #define VERSION 1 | 8 | #define VERSION 2 |
| 9 | 9 | ||
| 10 | #include "opengl_present_scaleforce.frag" | 10 | #include "opengl_present_scaleforce.frag" |