summaryrefslogtreecommitdiff
path: root/src/video_core/host_shaders
diff options
context:
space:
mode:
authorGravatar Fernando Sahmkow2021-11-19 03:17:02 +0100
committerGravatar Fernando Sahmkow2021-11-19 03:17:02 +0100
commit2ec7fcecb7d1f0bc8f943a3f7cb4d2e215bc4e76 (patch)
tree2da420f9cf192bb7601e46748715d5a6a97052ef /src/video_core/host_shaders
parentMerge pull request #7349 from ameerj/ogl-convert-image (diff)
downloadyuzu-2ec7fcecb7d1f0bc8f943a3f7cb4d2e215bc4e76.tar.gz
yuzu-2ec7fcecb7d1f0bc8f943a3f7cb4d2e215bc4e76.tar.xz
yuzu-2ec7fcecb7d1f0bc8f943a3f7cb4d2e215bc4e76.zip
Vulkan: implement D24S8 <-> RGBA8 convertions.
Diffstat (limited to 'src/video_core/host_shaders')
-rw-r--r--src/video_core/host_shaders/CMakeLists.txt2
-rw-r--r--src/video_core/host_shaders/convert_abgr8_to_d24s8.frag17
-rw-r--r--src/video_core/host_shaders/convert_d24s8_to_abgr8.frag21
3 files changed, 40 insertions, 0 deletions
diff --git a/src/video_core/host_shaders/CMakeLists.txt b/src/video_core/host_shaders/CMakeLists.txt
index d779a967a..fd3e41434 100644
--- a/src/video_core/host_shaders/CMakeLists.txt
+++ b/src/video_core/host_shaders/CMakeLists.txt
@@ -10,6 +10,8 @@ set(SHADER_FILES
10 astc_decoder.comp 10 astc_decoder.comp
11 block_linear_unswizzle_2d.comp 11 block_linear_unswizzle_2d.comp
12 block_linear_unswizzle_3d.comp 12 block_linear_unswizzle_3d.comp
13 convert_abgr8_to_d24s8.frag
14 convert_d24s8_to_abgr8.frag
13 convert_depth_to_float.frag 15 convert_depth_to_float.frag
14 convert_float_to_depth.frag 16 convert_float_to_depth.frag
15 full_screen_triangle.vert 17 full_screen_triangle.vert
diff --git a/src/video_core/host_shaders/convert_abgr8_to_d24s8.frag b/src/video_core/host_shaders/convert_abgr8_to_d24s8.frag
new file mode 100644
index 000000000..f7657e50a
--- /dev/null
+++ b/src/video_core/host_shaders/convert_abgr8_to_d24s8.frag
@@ -0,0 +1,17 @@
1// Copyright 2021 yuzu Emulator Project
2// Licensed under GPLv2 or any later version
3// Refer to the license.txt file included.
4
5#version 450
6// #extension GL_ARB_shader_stencil_export : require
7
8layout(binding = 0) uniform sampler2D color_texture;
9
10void main() {
11 ivec2 coord = ivec2(gl_FragCoord.xy);
12 uvec4 color = uvec4(texelFetch(color_texture, coord, 0).rgba * (exp2(8) - 1.0f));
13 uint depth_unorm = (color.r << 16) | (color.g << 8) | color.b;
14
15 gl_FragDepth = float(depth_unorm) / (exp2(24.0) - 1.0f);
16 // gl_FragStencilRefARB = int(color.a);
17}
diff --git a/src/video_core/host_shaders/convert_d24s8_to_abgr8.frag b/src/video_core/host_shaders/convert_d24s8_to_abgr8.frag
new file mode 100644
index 000000000..ff3bf8209
--- /dev/null
+++ b/src/video_core/host_shaders/convert_d24s8_to_abgr8.frag
@@ -0,0 +1,21 @@
1// Copyright 2021 yuzu Emulator Project
2// Licensed under GPLv2 or any later version
3// Refer to the license.txt file included.
4
5#version 450
6
7layout(binding = 0) uniform sampler2D depth_tex;
8layout(binding = 1) uniform isampler2D stencil_tex;
9
10layout(location = 0) out vec4 color;
11
12void main() {
13 ivec2 coord = ivec2(gl_FragCoord.xy);
14 uint depth = uint(textureLod(depth_tex, coord, 0).r * (exp2(24.0) - 1.0f));
15 uint stencil = uint(textureLod(stencil_tex, coord, 0).r);
16
17 color.r = float(depth >> 16) / (exp2(8) - 1.0);
18 color.g = float((depth >> 8) & 0x00FF) / (exp2(8) - 1.0);
19 color.b = float(depth & 0x00FF) / (exp2(8) - 1.0);
20 color.a = float(stencil) / (exp2(8) - 1.0);
21}