diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/video_core/host_shaders/CMakeLists.txt | 1 | ||||
| -rw-r--r-- | src/video_core/host_shaders/convert_abgr8_to_d32f.frag | 18 | ||||
| -rw-r--r-- | src/video_core/renderer_vulkan/blit_image.cpp | 8 | ||||
| -rw-r--r-- | src/video_core/renderer_vulkan/blit_image.h | 4 | ||||
| -rw-r--r-- | src/video_core/renderer_vulkan/vk_texture_cache.cpp | 4 |
5 files changed, 35 insertions, 0 deletions
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 | |||
| 19 | block_linear_unswizzle_2d.comp | 19 | block_linear_unswizzle_2d.comp |
| 20 | block_linear_unswizzle_3d.comp | 20 | block_linear_unswizzle_3d.comp |
| 21 | convert_abgr8_to_d24s8.frag | 21 | convert_abgr8_to_d24s8.frag |
| 22 | convert_abgr8_to_d32f.frag | ||
| 22 | convert_d32f_to_abgr8.frag | 23 | convert_d32f_to_abgr8.frag |
| 23 | convert_d32f_to_bgra8.frag | 24 | convert_d32f_to_bgra8.frag |
| 24 | convert_d24s8_to_abgr8.frag | 25 | 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 @@ | |||
| 1 | // SPDX-FileCopyrightText: Copyright 2023 Your Project | ||
| 2 | // SPDX-License-Identifier: GPL-2.0-or-later | ||
| 3 | |||
| 4 | #version 450 | ||
| 5 | |||
| 6 | layout(binding = 0) uniform sampler2D color_texture; | ||
| 7 | |||
| 8 | void main() { | ||
| 9 | ivec2 coord = ivec2(gl_FragCoord.xy); | ||
| 10 | vec4 color = texelFetch(color_texture, coord, 0).abgr; | ||
| 11 | |||
| 12 | uvec4 bytes = uvec4(color * (exp2(8) - 1.0f)) << uvec4(24, 16, 8, 0); | ||
| 13 | uint depth_unorm = bytes.x | bytes.y | bytes.z | bytes.w; | ||
| 14 | |||
| 15 | float depth_float = uintBitsToFloat(depth_unorm); | ||
| 16 | |||
| 17 | gl_FragDepth = depth_float; | ||
| 18 | } | ||
diff --git a/src/video_core/renderer_vulkan/blit_image.cpp b/src/video_core/renderer_vulkan/blit_image.cpp index 18f51a327..78a60fbe6 100644 --- a/src/video_core/renderer_vulkan/blit_image.cpp +++ b/src/video_core/renderer_vulkan/blit_image.cpp | |||
| @@ -8,6 +8,7 @@ | |||
| 8 | #include "common/settings.h" | 8 | #include "common/settings.h" |
| 9 | #include "video_core/host_shaders/blit_color_float_frag_spv.h" | 9 | #include "video_core/host_shaders/blit_color_float_frag_spv.h" |
| 10 | #include "video_core/host_shaders/convert_abgr8_to_d24s8_frag_spv.h" | 10 | #include "video_core/host_shaders/convert_abgr8_to_d24s8_frag_spv.h" |
| 11 | #include "video_core/host_shaders/convert_abgr8_to_d32f_frag_spv.h" | ||
| 11 | #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" |
| 12 | #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" |
| 13 | #include "video_core/host_shaders/convert_d32f_to_bgra8_frag_spv.h" | 14 | #include "video_core/host_shaders/convert_d32f_to_bgra8_frag_spv.h" |
| @@ -561,6 +562,13 @@ void BlitImageHelper::ConvertABGR8ToD24S8(const Framebuffer* dst_framebuffer, | |||
| 561 | Convert(*convert_abgr8_to_d24s8_pipeline, dst_framebuffer, src_image_view); | 562 | Convert(*convert_abgr8_to_d24s8_pipeline, dst_framebuffer, src_image_view); |
| 562 | } | 563 | } |
| 563 | 564 | ||
| 565 | void BlitImageHelper::ConvertABGR8ToD32F(const Framebuffer* dst_framebuffer, | ||
| 566 | const ImageView& src_image_view) { | ||
| 567 | ConvertPipelineDepthTargetEx(convert_abgr8_to_d32f_pipeline, dst_framebuffer->RenderPass(), | ||
| 568 | convert_abgr8_to_d32f_frag); | ||
| 569 | Convert(*convert_abgr8_to_d32f_pipeline, dst_framebuffer, src_image_view); | ||
| 570 | } | ||
| 571 | |||
| 564 | void BlitImageHelper::ConvertD32FToABGR8(const Framebuffer* dst_framebuffer, | 572 | void BlitImageHelper::ConvertD32FToABGR8(const Framebuffer* dst_framebuffer, |
| 565 | ImageView& src_image_view) { | 573 | ImageView& src_image_view) { |
| 566 | ConvertPipelineColorTargetEx(convert_d32f_to_abgr8_pipeline, dst_framebuffer->RenderPass(), | 574 | ConvertPipelineColorTargetEx(convert_d32f_to_abgr8_pipeline, dst_framebuffer->RenderPass(), |
diff --git a/src/video_core/renderer_vulkan/blit_image.h b/src/video_core/renderer_vulkan/blit_image.h index d083b4680..b3281ff3e 100644 --- a/src/video_core/renderer_vulkan/blit_image.h +++ b/src/video_core/renderer_vulkan/blit_image.h | |||
| @@ -67,6 +67,8 @@ public: | |||
| 67 | 67 | ||
| 68 | void ConvertABGR8ToD24S8(const Framebuffer* dst_framebuffer, const ImageView& src_image_view); | 68 | void ConvertABGR8ToD24S8(const Framebuffer* dst_framebuffer, const ImageView& src_image_view); |
| 69 | 69 | ||
| 70 | void ConvertABGR8ToD32F(const Framebuffer* dst_framebuffer, const ImageView& src_image_view); | ||
| 71 | |||
| 70 | void ConvertD32FToABGR8(const Framebuffer* dst_framebuffer, ImageView& src_image_view); | 72 | void ConvertD32FToABGR8(const Framebuffer* dst_framebuffer, ImageView& src_image_view); |
| 71 | 73 | ||
| 72 | void ConvertD24S8ToABGR8(const Framebuffer* dst_framebuffer, ImageView& src_image_view); | 74 | void ConvertD24S8ToABGR8(const Framebuffer* dst_framebuffer, ImageView& src_image_view); |
| @@ -132,6 +134,7 @@ private: | |||
| 132 | vk::ShaderModule convert_depth_to_float_frag; | 134 | vk::ShaderModule convert_depth_to_float_frag; |
| 133 | vk::ShaderModule convert_float_to_depth_frag; | 135 | vk::ShaderModule convert_float_to_depth_frag; |
| 134 | vk::ShaderModule convert_abgr8_to_d24s8_frag; | 136 | vk::ShaderModule convert_abgr8_to_d24s8_frag; |
| 137 | vk::ShaderModule convert_abgr8_to_d32f_frag; | ||
| 135 | vk::ShaderModule convert_d32f_to_abgr8_frag; | 138 | vk::ShaderModule convert_d32f_to_abgr8_frag; |
| 136 | vk::ShaderModule convert_d24s8_to_abgr8_frag; | 139 | vk::ShaderModule convert_d24s8_to_abgr8_frag; |
| 137 | vk::ShaderModule convert_s8d24_to_abgr8_frag; | 140 | vk::ShaderModule convert_s8d24_to_abgr8_frag; |
| @@ -152,6 +155,7 @@ private: | |||
| 152 | vk::Pipeline convert_d16_to_r16_pipeline; | 155 | vk::Pipeline convert_d16_to_r16_pipeline; |
| 153 | vk::Pipeline convert_r16_to_d16_pipeline; | 156 | vk::Pipeline convert_r16_to_d16_pipeline; |
| 154 | vk::Pipeline convert_abgr8_to_d24s8_pipeline; | 157 | vk::Pipeline convert_abgr8_to_d24s8_pipeline; |
| 158 | vk::Pipeline convert_abgr8_to_d32f_pipeline; | ||
| 155 | vk::Pipeline convert_d32f_to_abgr8_pipeline; | 159 | vk::Pipeline convert_d32f_to_abgr8_pipeline; |
| 156 | vk::Pipeline convert_d24s8_to_abgr8_pipeline; | 160 | vk::Pipeline convert_d24s8_to_abgr8_pipeline; |
| 157 | vk::Pipeline convert_s8d24_to_abgr8_pipeline; | 161 | vk::Pipeline convert_s8d24_to_abgr8_pipeline; |
diff --git a/src/video_core/renderer_vulkan/vk_texture_cache.cpp b/src/video_core/renderer_vulkan/vk_texture_cache.cpp index 3ad144dab..f913a99b9 100644 --- a/src/video_core/renderer_vulkan/vk_texture_cache.cpp +++ b/src/video_core/renderer_vulkan/vk_texture_cache.cpp | |||
| @@ -1236,6 +1236,10 @@ void TextureCacheRuntime::ConvertImage(Framebuffer* dst, ImageView& dst_view, Im | |||
| 1236 | } | 1236 | } |
| 1237 | break; | 1237 | break; |
| 1238 | case PixelFormat::D32_FLOAT: | 1238 | case PixelFormat::D32_FLOAT: |
| 1239 | if (src_view.format == PixelFormat::A8B8G8R8_SRGB || | ||
| 1240 | src_view.format == PixelFormat::B8G8R8A8_SRGB) { | ||
| 1241 | return blit_image_helper.ConvertABGR8ToD32F(dst, src_view); | ||
| 1242 | } | ||
| 1239 | if (src_view.format == PixelFormat::R32_FLOAT) { | 1243 | if (src_view.format == PixelFormat::R32_FLOAT) { |
| 1240 | return blit_image_helper.ConvertR32ToD32(dst, src_view); | 1244 | return blit_image_helper.ConvertR32ToD32(dst, src_view); |
| 1241 | } | 1245 | } |