diff options
| author | 2023-10-17 02:38:07 +1100 | |
|---|---|---|
| committer | 2023-10-17 02:42:40 +1100 | |
| commit | 326ebbb2fa87f7e4006e1434649ba1f48b4bebfa (patch) | |
| tree | 96cf6f308e067b0c4157008ce7a6bca2f7c5bd65 /src | |
| parent | Make Clang happy. (diff) | |
| download | yuzu-326ebbb2fa87f7e4006e1434649ba1f48b4bebfa.tar.gz yuzu-326ebbb2fa87f7e4006e1434649ba1f48b4bebfa.tar.xz yuzu-326ebbb2fa87f7e4006e1434649ba1f48b4bebfa.zip | |
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
Diffstat (limited to 'src')
6 files changed, 5 insertions, 37 deletions
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 | |||
| 21 | convert_abgr8_to_d24s8.frag | 21 | convert_abgr8_to_d24s8.frag |
| 22 | convert_abgr8_to_d32f.frag | 22 | convert_abgr8_to_d32f.frag |
| 23 | convert_d32f_to_abgr8.frag | 23 | convert_d32f_to_abgr8.frag |
| 24 | convert_d32f_to_bgra8.frag | ||
| 25 | convert_d24s8_to_abgr8.frag | 24 | convert_d24s8_to_abgr8.frag |
| 26 | convert_depth_to_float.frag | 25 | convert_depth_to_float.frag |
| 27 | convert_float_to_depth.frag | 26 | 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 @@ | |||
| 1 | // SPDX-FileCopyrightText: Copyright 2023 Your Project | 1 | // SPDX-FileCopyrightText: Copyright 2023 yuzu Emulator Project |
| 2 | // SPDX-License-Identifier: GPL-2.0-or-later | 2 | // SPDX-License-Identifier: GPL-2.0-or-later |
| 3 | 3 | ||
| 4 | #version 450 | 4 | #version 450 |
| @@ -9,10 +9,7 @@ void main() { | |||
| 9 | ivec2 coord = ivec2(gl_FragCoord.xy); | 9 | ivec2 coord = ivec2(gl_FragCoord.xy); |
| 10 | vec4 color = texelFetch(color_texture, coord, 0).abgr; | 10 | vec4 color = texelFetch(color_texture, coord, 0).abgr; |
| 11 | 11 | ||
| 12 | uvec4 bytes = uvec4(color * (exp2(8) - 1.0f)) << uvec4(24, 16, 8, 0); | 12 | float value = color.a * (color.r + color.g + color.b) / 3.0f; |
| 13 | uint depth_unorm = bytes.x | bytes.y | bytes.z | bytes.w; | ||
| 14 | 13 | ||
| 15 | float depth_float = uintBitsToFloat(depth_unorm); | 14 | gl_FragDepth = value; |
| 16 | |||
| 17 | gl_FragDepth = depth_float; | ||
| 18 | } | 15 | } |
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 @@ | |||
| 1 | // SPDX-FileCopyrightText: Copyright 2021 yuzu Emulator Project | ||
| 2 | // SPDX-License-Identifier: GPL-2.0-or-later | ||
| 3 | |||
| 4 | #version 450 | ||
| 5 | |||
| 6 | layout(binding = 0) uniform sampler2D depth_tex; | ||
| 7 | |||
| 8 | layout(location = 0) out vec4 color; | ||
| 9 | |||
| 10 | void main() { | ||
| 11 | ivec2 coord = ivec2(gl_FragCoord.xy); | ||
| 12 | float depth = texelFetch(depth_tex, coord, 0).r; | ||
| 13 | color = vec4(depth, depth, depth, 1.0); | ||
| 14 | color = color.bgra; // Swap color channels for BGRA format | ||
| 15 | } | ||
diff --git a/src/video_core/renderer_vulkan/blit_image.cpp b/src/video_core/renderer_vulkan/blit_image.cpp index 5030dd200..1a40a4d05 100644 --- a/src/video_core/renderer_vulkan/blit_image.cpp +++ b/src/video_core/renderer_vulkan/blit_image.cpp | |||
| @@ -11,7 +11,6 @@ | |||
| 11 | #include "video_core/host_shaders/convert_abgr8_to_d32f_frag_spv.h" | 11 | #include "video_core/host_shaders/convert_abgr8_to_d32f_frag_spv.h" |
| 12 | #include "video_core/host_shaders/convert_d24s8_to_abgr8_frag_spv.h" | 12 | #include "video_core/host_shaders/convert_d24s8_to_abgr8_frag_spv.h" |
| 13 | #include "video_core/host_shaders/convert_d32f_to_abgr8_frag_spv.h" | 13 | #include "video_core/host_shaders/convert_d32f_to_abgr8_frag_spv.h" |
| 14 | #include "video_core/host_shaders/convert_d32f_to_bgra8_frag_spv.h" | ||
| 15 | #include "video_core/host_shaders/convert_depth_to_float_frag_spv.h" | 14 | #include "video_core/host_shaders/convert_depth_to_float_frag_spv.h" |
| 16 | #include "video_core/host_shaders/convert_float_to_depth_frag_spv.h" | 15 | #include "video_core/host_shaders/convert_float_to_depth_frag_spv.h" |
| 17 | #include "video_core/host_shaders/convert_s8d24_to_abgr8_frag_spv.h" | 16 | #include "video_core/host_shaders/convert_s8d24_to_abgr8_frag_spv.h" |
| @@ -440,7 +439,6 @@ BlitImageHelper::BlitImageHelper(const Device& device_, Scheduler& scheduler_, | |||
| 440 | convert_d32f_to_abgr8_frag(BuildShader(device, CONVERT_D32F_TO_ABGR8_FRAG_SPV)), | 439 | convert_d32f_to_abgr8_frag(BuildShader(device, CONVERT_D32F_TO_ABGR8_FRAG_SPV)), |
| 441 | convert_d24s8_to_abgr8_frag(BuildShader(device, CONVERT_D24S8_TO_ABGR8_FRAG_SPV)), | 440 | convert_d24s8_to_abgr8_frag(BuildShader(device, CONVERT_D24S8_TO_ABGR8_FRAG_SPV)), |
| 442 | convert_s8d24_to_abgr8_frag(BuildShader(device, CONVERT_S8D24_TO_ABGR8_FRAG_SPV)), | 441 | convert_s8d24_to_abgr8_frag(BuildShader(device, CONVERT_S8D24_TO_ABGR8_FRAG_SPV)), |
| 443 | convert_d32f_to_bgra8_frag(BuildShader(device, CONVERT_D32F_TO_BGRA8_FRAG_SPV)), | ||
| 444 | linear_sampler(device.GetLogical().CreateSampler(SAMPLER_CREATE_INFO<VK_FILTER_LINEAR>)), | 442 | linear_sampler(device.GetLogical().CreateSampler(SAMPLER_CREATE_INFO<VK_FILTER_LINEAR>)), |
| 445 | nearest_sampler(device.GetLogical().CreateSampler(SAMPLER_CREATE_INFO<VK_FILTER_NEAREST>)) {} | 443 | nearest_sampler(device.GetLogical().CreateSampler(SAMPLER_CREATE_INFO<VK_FILTER_NEAREST>)) {} |
| 446 | 444 | ||
| @@ -591,13 +589,6 @@ void BlitImageHelper::ConvertS8D24ToABGR8(const Framebuffer* dst_framebuffer, | |||
| 591 | ConvertDepthStencil(*convert_s8d24_to_abgr8_pipeline, dst_framebuffer, src_image_view); | 589 | ConvertDepthStencil(*convert_s8d24_to_abgr8_pipeline, dst_framebuffer, src_image_view); |
| 592 | } | 590 | } |
| 593 | 591 | ||
| 594 | void BlitImageHelper::ConvertD32FToBGRA8(const Framebuffer* dst_framebuffer, | ||
| 595 | ImageView& src_image_view) { | ||
| 596 | ConvertPipelineColorTargetEx(convert_d32f_to_bgra8_pipeline, dst_framebuffer->RenderPass(), | ||
| 597 | convert_d32f_to_bgra8_frag); | ||
| 598 | ConvertDepthStencil(*convert_d32f_to_bgra8_pipeline, dst_framebuffer, src_image_view); | ||
| 599 | } | ||
| 600 | |||
| 601 | void BlitImageHelper::ClearColor(const Framebuffer* dst_framebuffer, u8 color_mask, | 592 | void BlitImageHelper::ClearColor(const Framebuffer* dst_framebuffer, u8 color_mask, |
| 602 | const std::array<f32, 4>& clear_color, | 593 | const std::array<f32, 4>& clear_color, |
| 603 | const Region2D& dst_region) { | 594 | const Region2D& dst_region) { |
diff --git a/src/video_core/renderer_vulkan/blit_image.h b/src/video_core/renderer_vulkan/blit_image.h index b3281ff3e..b2104a59e 100644 --- a/src/video_core/renderer_vulkan/blit_image.h +++ b/src/video_core/renderer_vulkan/blit_image.h | |||
| @@ -75,8 +75,6 @@ public: | |||
| 75 | 75 | ||
| 76 | void ConvertS8D24ToABGR8(const Framebuffer* dst_framebuffer, ImageView& src_image_view); | 76 | void ConvertS8D24ToABGR8(const Framebuffer* dst_framebuffer, ImageView& src_image_view); |
| 77 | 77 | ||
| 78 | void ConvertD32FToBGRA8(const Framebuffer* dst_framebuffer, ImageView& src_image_view); | ||
| 79 | |||
| 80 | void ClearColor(const Framebuffer* dst_framebuffer, u8 color_mask, | 78 | void ClearColor(const Framebuffer* dst_framebuffer, u8 color_mask, |
| 81 | const std::array<f32, 4>& clear_color, const Region2D& dst_region); | 79 | const std::array<f32, 4>& clear_color, const Region2D& dst_region); |
| 82 | 80 | ||
| @@ -138,7 +136,6 @@ private: | |||
| 138 | vk::ShaderModule convert_d32f_to_abgr8_frag; | 136 | vk::ShaderModule convert_d32f_to_abgr8_frag; |
| 139 | vk::ShaderModule convert_d24s8_to_abgr8_frag; | 137 | vk::ShaderModule convert_d24s8_to_abgr8_frag; |
| 140 | vk::ShaderModule convert_s8d24_to_abgr8_frag; | 138 | vk::ShaderModule convert_s8d24_to_abgr8_frag; |
| 141 | vk::ShaderModule convert_d32f_to_bgra8_frag; | ||
| 142 | vk::Sampler linear_sampler; | 139 | vk::Sampler linear_sampler; |
| 143 | vk::Sampler nearest_sampler; | 140 | vk::Sampler nearest_sampler; |
| 144 | 141 | ||
| @@ -159,7 +156,6 @@ private: | |||
| 159 | vk::Pipeline convert_d32f_to_abgr8_pipeline; | 156 | vk::Pipeline convert_d32f_to_abgr8_pipeline; |
| 160 | vk::Pipeline convert_d24s8_to_abgr8_pipeline; | 157 | vk::Pipeline convert_d24s8_to_abgr8_pipeline; |
| 161 | vk::Pipeline convert_s8d24_to_abgr8_pipeline; | 158 | vk::Pipeline convert_s8d24_to_abgr8_pipeline; |
| 162 | vk::Pipeline convert_d32f_to_bgra8_pipeline; | ||
| 163 | }; | 159 | }; |
| 164 | 160 | ||
| 165 | } // namespace Vulkan | 161 | } // namespace Vulkan |
diff --git a/src/video_core/renderer_vulkan/vk_texture_cache.cpp b/src/video_core/renderer_vulkan/vk_texture_cache.cpp index a4ee9295f..cdc41816f 100644 --- a/src/video_core/renderer_vulkan/vk_texture_cache.cpp +++ b/src/video_core/renderer_vulkan/vk_texture_cache.cpp | |||
| @@ -1211,12 +1211,12 @@ void TextureCacheRuntime::ConvertImage(Framebuffer* dst, ImageView& dst_view, Im | |||
| 1211 | break; | 1211 | break; |
| 1212 | case PixelFormat::B8G8R8A8_SRGB: | 1212 | case PixelFormat::B8G8R8A8_SRGB: |
| 1213 | if (src_view.format == PixelFormat::D32_FLOAT) { | 1213 | if (src_view.format == PixelFormat::D32_FLOAT) { |
| 1214 | return blit_image_helper.ConvertD32FToBGRA8(dst, src_view); | 1214 | return blit_image_helper.ConvertD32FToABGR8(dst, src_view); |
| 1215 | } | 1215 | } |
| 1216 | break; | 1216 | break; |
| 1217 | case PixelFormat::B8G8R8A8_UNORM: | 1217 | case PixelFormat::B8G8R8A8_UNORM: |
| 1218 | if (src_view.format == PixelFormat::D32_FLOAT) { | 1218 | if (src_view.format == PixelFormat::D32_FLOAT) { |
| 1219 | return blit_image_helper.ConvertD32FToBGRA8(dst, src_view); | 1219 | return blit_image_helper.ConvertD32FToABGR8(dst, src_view); |
| 1220 | } | 1220 | } |
| 1221 | break; | 1221 | break; |
| 1222 | case PixelFormat::R32_FLOAT: | 1222 | case PixelFormat::R32_FLOAT: |