From 7a986d731b55acd2249d10b2f2264c1f61b69208 Mon Sep 17 00:00:00 2001 From: Squall-Leonhart Date: Sun, 15 Oct 2023 20:43:48 +1100 Subject: Implement missing formats for Bravely Default 2 --- src/video_core/host_shaders/CMakeLists.txt | 1 + src/video_core/host_shaders/convert_d32f_to_bgra8.frag | 15 +++++++++++++++ 2 files changed, 16 insertions(+) create mode 100644 src/video_core/host_shaders/convert_d32f_to_bgra8.frag (limited to 'src/video_core/host_shaders') diff --git a/src/video_core/host_shaders/CMakeLists.txt b/src/video_core/host_shaders/CMakeLists.txt index 8bb429578..cf20f39f0 100644 --- a/src/video_core/host_shaders/CMakeLists.txt +++ b/src/video_core/host_shaders/CMakeLists.txt @@ -20,6 +20,7 @@ set(SHADER_FILES block_linear_unswizzle_3d.comp convert_abgr8_to_d24s8.frag convert_d32f_to_abgr8.frag + convert_d32f_to_bgra8.frag convert_d24s8_to_abgr8.frag convert_depth_to_float.frag convert_float_to_depth.frag diff --git a/src/video_core/host_shaders/convert_d32f_to_bgra8.frag b/src/video_core/host_shaders/convert_d32f_to_bgra8.frag new file mode 100644 index 000000000..c0d8ff36b --- /dev/null +++ b/src/video_core/host_shaders/convert_d32f_to_bgra8.frag @@ -0,0 +1,15 @@ +// SPDX-FileCopyrightText: Copyright 2021 yuzu Emulator Project +// SPDX-License-Identifier: GPL-2.0-or-later + +#version 450 + +layout(binding = 0) uniform sampler2D depth_tex; + +layout(location = 0) out vec4 color; + +void main() { + ivec2 coord = ivec2(gl_FragCoord.xy); + float depth = textureLod(depth_tex, coord, 0).r; + color = vec4(depth, depth, depth, 1.0); + color = color.bgra; // Swap color channels for BGRA format +} \ No newline at end of file -- cgit v1.2.3 From f40f65f5d2123c79ffa4c8587d20dada624b5047 Mon Sep 17 00:00:00 2001 From: Squall-Leonhart Date: Mon, 16 Oct 2023 03:17:53 +1100 Subject: Another missing copy connected to Bravely Default II adds blit_image_helper.ConvertABGR8ToD32F and fragment shader for performing ABGR and BGRA to D32F copies --- src/video_core/host_shaders/CMakeLists.txt | 1 + src/video_core/host_shaders/convert_abgr8_to_d32f.frag | 18 ++++++++++++++++++ 2 files changed, 19 insertions(+) create mode 100644 src/video_core/host_shaders/convert_abgr8_to_d32f.frag (limited to 'src/video_core/host_shaders') diff --git a/src/video_core/host_shaders/CMakeLists.txt b/src/video_core/host_shaders/CMakeLists.txt index cf20f39f0..cff8e38d6 100644 --- a/src/video_core/host_shaders/CMakeLists.txt +++ b/src/video_core/host_shaders/CMakeLists.txt @@ -19,6 +19,7 @@ set(SHADER_FILES block_linear_unswizzle_2d.comp block_linear_unswizzle_3d.comp convert_abgr8_to_d24s8.frag + convert_abgr8_to_d32f.frag convert_d32f_to_abgr8.frag convert_d32f_to_bgra8.frag convert_d24s8_to_abgr8.frag diff --git a/src/video_core/host_shaders/convert_abgr8_to_d32f.frag b/src/video_core/host_shaders/convert_abgr8_to_d32f.frag new file mode 100644 index 000000000..a1880b916 --- /dev/null +++ b/src/video_core/host_shaders/convert_abgr8_to_d32f.frag @@ -0,0 +1,18 @@ +// SPDX-FileCopyrightText: Copyright 2023 Your Project +// SPDX-License-Identifier: GPL-2.0-or-later + +#version 450 + +layout(binding = 0) uniform sampler2D color_texture; + +void main() { + ivec2 coord = ivec2(gl_FragCoord.xy); + vec4 color = texelFetch(color_texture, coord, 0).abgr; + + uvec4 bytes = uvec4(color * (exp2(8) - 1.0f)) << uvec4(24, 16, 8, 0); + uint depth_unorm = bytes.x | bytes.y | bytes.z | bytes.w; + + float depth_float = uintBitsToFloat(depth_unorm); + + gl_FragDepth = depth_float; +} -- cgit v1.2.3 From 12e4757cf394d830aa730523c02639fae87c8f19 Mon Sep 17 00:00:00 2001 From: Squall-Leonhart Date: Mon, 16 Oct 2023 04:20:45 +1100 Subject: use texelfetch instead of texturelod --- src/video_core/host_shaders/convert_d32f_to_abgr8.frag | 2 +- src/video_core/host_shaders/convert_d32f_to_bgra8.frag | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'src/video_core/host_shaders') diff --git a/src/video_core/host_shaders/convert_d32f_to_abgr8.frag b/src/video_core/host_shaders/convert_d32f_to_abgr8.frag index 04cfef8b5..4e5a9f955 100644 --- a/src/video_core/host_shaders/convert_d32f_to_abgr8.frag +++ b/src/video_core/host_shaders/convert_d32f_to_abgr8.frag @@ -9,6 +9,6 @@ layout(location = 0) out vec4 color; void main() { ivec2 coord = ivec2(gl_FragCoord.xy); - float depth = textureLod(depth_tex, coord, 0).r; + float depth = texelFetch(depth_tex, coord, 0).r; color = vec4(depth, depth, depth, 1.0); } diff --git a/src/video_core/host_shaders/convert_d32f_to_bgra8.frag b/src/video_core/host_shaders/convert_d32f_to_bgra8.frag index c0d8ff36b..82dfca739 100644 --- a/src/video_core/host_shaders/convert_d32f_to_bgra8.frag +++ b/src/video_core/host_shaders/convert_d32f_to_bgra8.frag @@ -9,7 +9,7 @@ layout(location = 0) out vec4 color; void main() { ivec2 coord = ivec2(gl_FragCoord.xy); - float depth = textureLod(depth_tex, coord, 0).r; + float depth = texelFetch(depth_tex, coord, 0).r; color = vec4(depth, depth, depth, 1.0); color = color.bgra; // Swap color channels for BGRA format } \ No newline at end of file -- cgit v1.2.3 From 90c56f5dc1cab59adbd446aa77b12e64c6c59474 Mon Sep 17 00:00:00 2001 From: Squall Leonhart Date: Mon, 16 Oct 2023 06:07:26 +1100 Subject: added missing trailing line. --- src/video_core/host_shaders/convert_d32f_to_bgra8.frag | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/video_core/host_shaders') diff --git a/src/video_core/host_shaders/convert_d32f_to_bgra8.frag b/src/video_core/host_shaders/convert_d32f_to_bgra8.frag index 82dfca739..789c3e078 100644 --- a/src/video_core/host_shaders/convert_d32f_to_bgra8.frag +++ b/src/video_core/host_shaders/convert_d32f_to_bgra8.frag @@ -12,4 +12,4 @@ void main() { float depth = texelFetch(depth_tex, coord, 0).r; color = vec4(depth, depth, depth, 1.0); color = color.bgra; // Swap color channels for BGRA format -} \ No newline at end of file +} -- cgit v1.2.3 From 326ebbb2fa87f7e4006e1434649ba1f48b4bebfa Mon Sep 17 00:00:00 2001 From: Squall-Leonhart Date: Tue, 17 Oct 2023 02:38:07 +1100 Subject: Changes based on hardware tests Removes unnecessary d32f to bgra shader and blit functions, update vk_texture_cache to use abgr shader for d32f to BGRA formats updates abgr to d32f shader to comply with hardware tests --- src/video_core/host_shaders/CMakeLists.txt | 1 - src/video_core/host_shaders/convert_abgr8_to_d32f.frag | 9 +++------ src/video_core/host_shaders/convert_d32f_to_bgra8.frag | 15 --------------- 3 files changed, 3 insertions(+), 22 deletions(-) delete mode 100644 src/video_core/host_shaders/convert_d32f_to_bgra8.frag (limited to 'src/video_core/host_shaders') diff --git a/src/video_core/host_shaders/CMakeLists.txt b/src/video_core/host_shaders/CMakeLists.txt index cff8e38d6..cd2549232 100644 --- a/src/video_core/host_shaders/CMakeLists.txt +++ b/src/video_core/host_shaders/CMakeLists.txt @@ -21,7 +21,6 @@ set(SHADER_FILES convert_abgr8_to_d24s8.frag convert_abgr8_to_d32f.frag convert_d32f_to_abgr8.frag - convert_d32f_to_bgra8.frag convert_d24s8_to_abgr8.frag convert_depth_to_float.frag convert_float_to_depth.frag diff --git a/src/video_core/host_shaders/convert_abgr8_to_d32f.frag b/src/video_core/host_shaders/convert_abgr8_to_d32f.frag index a1880b916..095b910c2 100644 --- a/src/video_core/host_shaders/convert_abgr8_to_d32f.frag +++ b/src/video_core/host_shaders/convert_abgr8_to_d32f.frag @@ -1,4 +1,4 @@ -// SPDX-FileCopyrightText: Copyright 2023 Your Project +// SPDX-FileCopyrightText: Copyright 2023 yuzu Emulator Project // SPDX-License-Identifier: GPL-2.0-or-later #version 450 @@ -9,10 +9,7 @@ void main() { ivec2 coord = ivec2(gl_FragCoord.xy); vec4 color = texelFetch(color_texture, coord, 0).abgr; - uvec4 bytes = uvec4(color * (exp2(8) - 1.0f)) << uvec4(24, 16, 8, 0); - uint depth_unorm = bytes.x | bytes.y | bytes.z | bytes.w; + float value = color.a * (color.r + color.g + color.b) / 3.0f; - float depth_float = uintBitsToFloat(depth_unorm); - - gl_FragDepth = depth_float; + gl_FragDepth = value; } diff --git a/src/video_core/host_shaders/convert_d32f_to_bgra8.frag b/src/video_core/host_shaders/convert_d32f_to_bgra8.frag deleted file mode 100644 index 789c3e078..000000000 --- a/src/video_core/host_shaders/convert_d32f_to_bgra8.frag +++ /dev/null @@ -1,15 +0,0 @@ -// SPDX-FileCopyrightText: Copyright 2021 yuzu Emulator Project -// SPDX-License-Identifier: GPL-2.0-or-later - -#version 450 - -layout(binding = 0) uniform sampler2D depth_tex; - -layout(location = 0) out vec4 color; - -void main() { - ivec2 coord = ivec2(gl_FragCoord.xy); - float depth = texelFetch(depth_tex, coord, 0).r; - color = vec4(depth, depth, depth, 1.0); - color = color.bgra; // Swap color channels for BGRA format -} -- cgit v1.2.3