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_r16g16_to_d24s8.frag | 18 | ||||
| -rw-r--r-- | src/video_core/renderer_vulkan/blit_image.cpp | 11 | ||||
| -rw-r--r-- | src/video_core/renderer_vulkan/blit_image.h | 5 | ||||
| -rw-r--r-- | src/video_core/renderer_vulkan/vk_texture_cache.cpp | 3 |
5 files changed, 38 insertions, 0 deletions
diff --git a/src/video_core/host_shaders/CMakeLists.txt b/src/video_core/host_shaders/CMakeLists.txt index a2e046f12..1c91999d7 100644 --- a/src/video_core/host_shaders/CMakeLists.txt +++ b/src/video_core/host_shaders/CMakeLists.txt | |||
| @@ -17,6 +17,7 @@ set(SHADER_FILES | |||
| 17 | convert_d24s8_to_r16g16.frag | 17 | convert_d24s8_to_r16g16.frag |
| 18 | convert_depth_to_float.frag | 18 | convert_depth_to_float.frag |
| 19 | convert_float_to_depth.frag | 19 | convert_float_to_depth.frag |
| 20 | convert_r16g16_to_d24s8.frag | ||
| 20 | full_screen_triangle.vert | 21 | full_screen_triangle.vert |
| 21 | fxaa.frag | 22 | fxaa.frag |
| 22 | fxaa.vert | 23 | fxaa.vert |
diff --git a/src/video_core/host_shaders/convert_r16g16_to_d24s8.frag b/src/video_core/host_shaders/convert_r16g16_to_d24s8.frag new file mode 100644 index 000000000..7b1b914f6 --- /dev/null +++ b/src/video_core/host_shaders/convert_r16g16_to_d24s8.frag | |||
| @@ -0,0 +1,18 @@ | |||
| 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 | |||
| 8 | layout(binding = 0) uniform sampler2D color_texture; | ||
| 9 | |||
| 10 | void main() { | ||
| 11 | ivec2 coord = ivec2(gl_FragCoord.xy); | ||
| 12 | vec4 color = texelFetch(color_texture, coord, 0).rgba; | ||
| 13 | uint depth_stencil_unorm = (uint(color.r * (exp2(16) - 1.0f)) << 16) | ||
| 14 | | (uint(color.g * (exp2(16) - 1.0f)) << 16); | ||
| 15 | |||
| 16 | gl_FragDepth = float(depth_stencil_unorm >> 8) / (exp2(24.0) - 1.0f); | ||
| 17 | // gl_FragStencilRefARB = int(depth_stencil_unorm & 0x00FF); | ||
| 18 | } | ||
diff --git a/src/video_core/renderer_vulkan/blit_image.cpp b/src/video_core/renderer_vulkan/blit_image.cpp index e70459de5..28b631f73 100644 --- a/src/video_core/renderer_vulkan/blit_image.cpp +++ b/src/video_core/renderer_vulkan/blit_image.cpp | |||
| @@ -11,6 +11,7 @@ | |||
| 11 | #include "video_core/host_shaders/convert_d24s8_to_r16g16_frag_spv.h" | 11 | #include "video_core/host_shaders/convert_d24s8_to_r16g16_frag_spv.h" |
| 12 | #include "video_core/host_shaders/convert_depth_to_float_frag_spv.h" | 12 | #include "video_core/host_shaders/convert_depth_to_float_frag_spv.h" |
| 13 | #include "video_core/host_shaders/convert_float_to_depth_frag_spv.h" | 13 | #include "video_core/host_shaders/convert_float_to_depth_frag_spv.h" |
| 14 | #include "video_core/host_shaders/convert_r16g16_to_d24s8_frag_spv.h" | ||
| 14 | #include "video_core/host_shaders/full_screen_triangle_vert_spv.h" | 15 | #include "video_core/host_shaders/full_screen_triangle_vert_spv.h" |
| 15 | #include "video_core/host_shaders/vulkan_blit_color_float_frag_spv.h" | 16 | #include "video_core/host_shaders/vulkan_blit_color_float_frag_spv.h" |
| 16 | #include "video_core/host_shaders/vulkan_blit_depth_stencil_frag_spv.h" | 17 | #include "video_core/host_shaders/vulkan_blit_depth_stencil_frag_spv.h" |
| @@ -361,6 +362,7 @@ BlitImageHelper::BlitImageHelper(const Device& device_, VKScheduler& scheduler_, | |||
| 361 | convert_float_to_depth_frag(BuildShader(device, CONVERT_FLOAT_TO_DEPTH_FRAG_SPV)), | 362 | convert_float_to_depth_frag(BuildShader(device, CONVERT_FLOAT_TO_DEPTH_FRAG_SPV)), |
| 362 | convert_abgr8_to_d24s8_frag(BuildShader(device, CONVERT_ABGR8_TO_D24S8_FRAG_SPV)), | 363 | convert_abgr8_to_d24s8_frag(BuildShader(device, CONVERT_ABGR8_TO_D24S8_FRAG_SPV)), |
| 363 | convert_b10g11r11_to_d24s8_frag(BuildShader(device, CONVERT_B10G11R11_TO_D24S8_FRAG_SPV)), | 364 | convert_b10g11r11_to_d24s8_frag(BuildShader(device, CONVERT_B10G11R11_TO_D24S8_FRAG_SPV)), |
| 365 | convert_r16g16_to_d24s8_frag(BuildShader(device, CONVERT_R16G16_TO_D24S8_FRAG_SPV)), | ||
| 364 | convert_d24s8_to_abgr8_frag(BuildShader(device, CONVERT_D24S8_TO_ABGR8_FRAG_SPV)), | 366 | convert_d24s8_to_abgr8_frag(BuildShader(device, CONVERT_D24S8_TO_ABGR8_FRAG_SPV)), |
| 365 | convert_d24s8_to_b10g11r11_frag(BuildShader(device, CONVERT_D24S8_TO_B10G11R11_FRAG_SPV)), | 367 | convert_d24s8_to_b10g11r11_frag(BuildShader(device, CONVERT_D24S8_TO_B10G11R11_FRAG_SPV)), |
| 366 | convert_d24s8_to_r16g16_frag(BuildShader(device, CONVERT_D24S8_TO_R16G16_FRAG_SPV)), | 368 | convert_d24s8_to_r16g16_frag(BuildShader(device, CONVERT_D24S8_TO_R16G16_FRAG_SPV)), |
| @@ -476,6 +478,15 @@ void BlitImageHelper::ConvertB10G11R11ToD24S8(const Framebuffer* dst_framebuffer | |||
| 476 | down_shift); | 478 | down_shift); |
| 477 | } | 479 | } |
| 478 | 480 | ||
| 481 | void BlitImageHelper::ConvertR16G16ToD24S8(const Framebuffer* dst_framebuffer, | ||
| 482 | const ImageView& src_image_view, u32 up_scale, | ||
| 483 | u32 down_shift) { | ||
| 484 | ConvertPipelineDepthTargetEx(convert_r16g16_to_d24s8_pipeline, dst_framebuffer->RenderPass(), | ||
| 485 | convert_r16g16_to_d24s8_frag, true); | ||
| 486 | Convert(*convert_r16g16_to_d24s8_pipeline, dst_framebuffer, src_image_view, up_scale, | ||
| 487 | down_shift); | ||
| 488 | } | ||
| 489 | |||
| 479 | void BlitImageHelper::ConvertD24S8ToABGR8(const Framebuffer* dst_framebuffer, | 490 | void BlitImageHelper::ConvertD24S8ToABGR8(const Framebuffer* dst_framebuffer, |
| 480 | ImageView& src_image_view, u32 up_scale, u32 down_shift) { | 491 | ImageView& src_image_view, u32 up_scale, u32 down_shift) { |
| 481 | ConvertPipelineColorTargetEx(convert_d24s8_to_abgr8_pipeline, dst_framebuffer->RenderPass(), | 492 | ConvertPipelineColorTargetEx(convert_d24s8_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 607964b5e..cec095341 100644 --- a/src/video_core/renderer_vulkan/blit_image.h +++ b/src/video_core/renderer_vulkan/blit_image.h | |||
| @@ -62,6 +62,9 @@ public: | |||
| 62 | void ConvertB10G11R11ToD24S8(const Framebuffer* dst_framebuffer, | 62 | void ConvertB10G11R11ToD24S8(const Framebuffer* dst_framebuffer, |
| 63 | const ImageView& src_image_view, u32 up_scale, u32 down_shift); | 63 | const ImageView& src_image_view, u32 up_scale, u32 down_shift); |
| 64 | 64 | ||
| 65 | void ConvertR16G16ToD24S8(const Framebuffer* dst_framebuffer, const ImageView& src_image_view, | ||
| 66 | u32 up_scale, u32 down_shift); | ||
| 67 | |||
| 65 | void ConvertD24S8ToABGR8(const Framebuffer* dst_framebuffer, ImageView& src_image_view, | 68 | void ConvertD24S8ToABGR8(const Framebuffer* dst_framebuffer, ImageView& src_image_view, |
| 66 | u32 up_scale, u32 down_shift); | 69 | u32 up_scale, u32 down_shift); |
| 67 | 70 | ||
| @@ -109,6 +112,7 @@ private: | |||
| 109 | vk::ShaderModule convert_float_to_depth_frag; | 112 | vk::ShaderModule convert_float_to_depth_frag; |
| 110 | vk::ShaderModule convert_abgr8_to_d24s8_frag; | 113 | vk::ShaderModule convert_abgr8_to_d24s8_frag; |
| 111 | vk::ShaderModule convert_b10g11r11_to_d24s8_frag; | 114 | vk::ShaderModule convert_b10g11r11_to_d24s8_frag; |
| 115 | vk::ShaderModule convert_r16g16_to_d24s8_frag; | ||
| 112 | vk::ShaderModule convert_d24s8_to_abgr8_frag; | 116 | vk::ShaderModule convert_d24s8_to_abgr8_frag; |
| 113 | vk::ShaderModule convert_d24s8_to_b10g11r11_frag; | 117 | vk::ShaderModule convert_d24s8_to_b10g11r11_frag; |
| 114 | vk::ShaderModule convert_d24s8_to_r16g16_frag; | 118 | vk::ShaderModule convert_d24s8_to_r16g16_frag; |
| @@ -125,6 +129,7 @@ private: | |||
| 125 | vk::Pipeline convert_r16_to_d16_pipeline; | 129 | vk::Pipeline convert_r16_to_d16_pipeline; |
| 126 | vk::Pipeline convert_abgr8_to_d24s8_pipeline; | 130 | vk::Pipeline convert_abgr8_to_d24s8_pipeline; |
| 127 | vk::Pipeline convert_b10g11r11_to_d24s8_pipeline; | 131 | vk::Pipeline convert_b10g11r11_to_d24s8_pipeline; |
| 132 | vk::Pipeline convert_r16g16_to_d24s8_pipeline; | ||
| 128 | vk::Pipeline convert_d24s8_to_abgr8_pipeline; | 133 | vk::Pipeline convert_d24s8_to_abgr8_pipeline; |
| 129 | vk::Pipeline convert_d24s8_to_b10g11r11_pipeline; | 134 | vk::Pipeline convert_d24s8_to_b10g11r11_pipeline; |
| 130 | vk::Pipeline convert_d24s8_to_r16g16_pipeline; | 135 | vk::Pipeline convert_d24s8_to_r16g16_pipeline; |
diff --git a/src/video_core/renderer_vulkan/vk_texture_cache.cpp b/src/video_core/renderer_vulkan/vk_texture_cache.cpp index 28a659c0e..af1a11059 100644 --- a/src/video_core/renderer_vulkan/vk_texture_cache.cpp +++ b/src/video_core/renderer_vulkan/vk_texture_cache.cpp | |||
| @@ -915,6 +915,9 @@ void TextureCacheRuntime::ConvertImage(Framebuffer* dst, ImageView& dst_view, Im | |||
| 915 | if (src_view.format == PixelFormat::B10G11R11_FLOAT) { | 915 | if (src_view.format == PixelFormat::B10G11R11_FLOAT) { |
| 916 | return blit_image_helper.ConvertB10G11R11ToD24S8(dst, src_view, up_scale, down_shift); | 916 | return blit_image_helper.ConvertB10G11R11ToD24S8(dst, src_view, up_scale, down_shift); |
| 917 | } | 917 | } |
| 918 | if (src_view.format == PixelFormat::R16G16_UNORM) { | ||
| 919 | return blit_image_helper.ConvertR16G16ToD24S8(dst, src_view, up_scale, down_shift); | ||
| 920 | } | ||
| 918 | break; | 921 | break; |
| 919 | case PixelFormat::D32_FLOAT: | 922 | case PixelFormat::D32_FLOAT: |
| 920 | if (src_view.format == PixelFormat::R32_FLOAT) { | 923 | if (src_view.format == PixelFormat::R32_FLOAT) { |