summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--src/video_core/host_shaders/CMakeLists.txt2
-rw-r--r--src/video_core/host_shaders/convert_d24s8_to_b10g11r11.frag21
-rw-r--r--src/video_core/host_shaders/convert_d24s8_to_r16g16.frag21
-rw-r--r--src/video_core/renderer_vulkan/blit_image.cpp22
-rw-r--r--src/video_core/renderer_vulkan/blit_image.h10
-rw-r--r--src/video_core/renderer_vulkan/vk_texture_cache.cpp10
6 files changed, 86 insertions, 0 deletions
diff --git a/src/video_core/host_shaders/CMakeLists.txt b/src/video_core/host_shaders/CMakeLists.txt
index fd3e41434..87042195a 100644
--- a/src/video_core/host_shaders/CMakeLists.txt
+++ b/src/video_core/host_shaders/CMakeLists.txt
@@ -12,6 +12,8 @@ set(SHADER_FILES
12 block_linear_unswizzle_3d.comp 12 block_linear_unswizzle_3d.comp
13 convert_abgr8_to_d24s8.frag 13 convert_abgr8_to_d24s8.frag
14 convert_d24s8_to_abgr8.frag 14 convert_d24s8_to_abgr8.frag
15 convert_d24s8_to_b10g11r11.frag
16 convert_d24s8_to_r16g16.frag
15 convert_depth_to_float.frag 17 convert_depth_to_float.frag
16 convert_float_to_depth.frag 18 convert_float_to_depth.frag
17 full_screen_triangle.vert 19 full_screen_triangle.vert
diff --git a/src/video_core/host_shaders/convert_d24s8_to_b10g11r11.frag b/src/video_core/host_shaders/convert_d24s8_to_b10g11r11.frag
new file mode 100644
index 000000000..c743d3a13
--- /dev/null
+++ b/src/video_core/host_shaders/convert_d24s8_to_b10g11r11.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.b = float(depth >> 22) / (exp2(10) - 1.0);
18 color.g = float((depth >> 11) & 0x00FF) / (exp2(11) - 1.0);
19 color.r = float(depth & 0x00FF) / (exp2(11) - 1.0);
20 color.a = 1.0f;
21}
diff --git a/src/video_core/host_shaders/convert_d24s8_to_r16g16.frag b/src/video_core/host_shaders/convert_d24s8_to_r16g16.frag
new file mode 100644
index 000000000..2a9443d3d
--- /dev/null
+++ b/src/video_core/host_shaders/convert_d24s8_to_r16g16.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(16) - 1.0);
18 color.g = float((depth >> 16) & 0x00FF) / (exp2(16) - 1.0);
19 color.b = 0.0f;
20 color.a = 1.0f;
21}
diff --git a/src/video_core/renderer_vulkan/blit_image.cpp b/src/video_core/renderer_vulkan/blit_image.cpp
index 01535d0c0..12b28aadd 100644
--- a/src/video_core/renderer_vulkan/blit_image.cpp
+++ b/src/video_core/renderer_vulkan/blit_image.cpp
@@ -6,6 +6,8 @@
6 6
7#include "video_core/host_shaders/convert_abgr8_to_d24s8_frag_spv.h" 7#include "video_core/host_shaders/convert_abgr8_to_d24s8_frag_spv.h"
8#include "video_core/host_shaders/convert_d24s8_to_abgr8_frag_spv.h" 8#include "video_core/host_shaders/convert_d24s8_to_abgr8_frag_spv.h"
9#include "video_core/host_shaders/convert_d24s8_to_b10g11r11_frag_spv.h"
10#include "video_core/host_shaders/convert_d24s8_to_r16g16_frag_spv.h"
9#include "video_core/host_shaders/convert_depth_to_float_frag_spv.h" 11#include "video_core/host_shaders/convert_depth_to_float_frag_spv.h"
10#include "video_core/host_shaders/convert_float_to_depth_frag_spv.h" 12#include "video_core/host_shaders/convert_float_to_depth_frag_spv.h"
11#include "video_core/host_shaders/full_screen_triangle_vert_spv.h" 13#include "video_core/host_shaders/full_screen_triangle_vert_spv.h"
@@ -358,6 +360,8 @@ BlitImageHelper::BlitImageHelper(const Device& device_, VKScheduler& scheduler_,
358 convert_float_to_depth_frag(BuildShader(device, CONVERT_FLOAT_TO_DEPTH_FRAG_SPV)), 360 convert_float_to_depth_frag(BuildShader(device, CONVERT_FLOAT_TO_DEPTH_FRAG_SPV)),
359 convert_abgr8_to_d24s8_frag(BuildShader(device, CONVERT_ABGR8_TO_D24S8_FRAG_SPV)), 361 convert_abgr8_to_d24s8_frag(BuildShader(device, CONVERT_ABGR8_TO_D24S8_FRAG_SPV)),
360 convert_d24s8_to_abgr8_frag(BuildShader(device, CONVERT_D24S8_TO_ABGR8_FRAG_SPV)), 362 convert_d24s8_to_abgr8_frag(BuildShader(device, CONVERT_D24S8_TO_ABGR8_FRAG_SPV)),
363 convert_d24s8_to_b10g11r11_frag(BuildShader(device, CONVERT_D24S8_TO_B10G11R11_FRAG_SPV)),
364 convert_d24s8_to_r16g16_frag(BuildShader(device, CONVERT_D24S8_TO_R16G16_FRAG_SPV)),
361 linear_sampler(device.GetLogical().CreateSampler(SAMPLER_CREATE_INFO<VK_FILTER_LINEAR>)), 365 linear_sampler(device.GetLogical().CreateSampler(SAMPLER_CREATE_INFO<VK_FILTER_LINEAR>)),
362 nearest_sampler(device.GetLogical().CreateSampler(SAMPLER_CREATE_INFO<VK_FILTER_NEAREST>)) { 366 nearest_sampler(device.GetLogical().CreateSampler(SAMPLER_CREATE_INFO<VK_FILTER_NEAREST>)) {
363 if (device.IsExtShaderStencilExportSupported()) { 367 if (device.IsExtShaderStencilExportSupported()) {
@@ -469,6 +473,24 @@ void BlitImageHelper::ConvertD24S8ToABGR8(const Framebuffer* dst_framebuffer,
469 down_shift); 473 down_shift);
470} 474}
471 475
476void BlitImageHelper::ConvertD24S8ToB10G11R11(const Framebuffer* dst_framebuffer,
477 ImageView& src_image_view, u32 up_scale,
478 u32 down_shift) {
479 ConvertPipelineEx(convert_d24s8_to_b10g11r11_pipeline, dst_framebuffer->RenderPass(),
480 convert_d24s8_to_b10g11r11_frag, false);
481 ConvertDepthStencil(*convert_d24s8_to_b10g11r11_pipeline, dst_framebuffer, src_image_view,
482 up_scale, down_shift);
483}
484
485void BlitImageHelper::ConvertD24S8ToR16G16(const Framebuffer* dst_framebuffer,
486 ImageView& src_image_view, u32 up_scale,
487 u32 down_shift) {
488 ConvertPipelineEx(convert_d24s8_to_r16g16_pipeline, dst_framebuffer->RenderPass(),
489 convert_d24s8_to_r16g16_frag, false);
490 ConvertDepthStencil(*convert_d24s8_to_r16g16_pipeline, dst_framebuffer, src_image_view,
491 up_scale, down_shift);
492}
493
472void BlitImageHelper::Convert(VkPipeline pipeline, const Framebuffer* dst_framebuffer, 494void BlitImageHelper::Convert(VkPipeline pipeline, const Framebuffer* dst_framebuffer,
473 const ImageView& src_image_view, u32 up_scale, u32 down_shift) { 495 const ImageView& src_image_view, u32 up_scale, u32 down_shift) {
474 const VkPipelineLayout layout = *one_texture_pipeline_layout; 496 const VkPipelineLayout layout = *one_texture_pipeline_layout;
diff --git a/src/video_core/renderer_vulkan/blit_image.h b/src/video_core/renderer_vulkan/blit_image.h
index f754a7294..10d24c4b7 100644
--- a/src/video_core/renderer_vulkan/blit_image.h
+++ b/src/video_core/renderer_vulkan/blit_image.h
@@ -62,6 +62,12 @@ public:
62 void ConvertD24S8ToABGR8(const Framebuffer* dst_framebuffer, ImageView& src_image_view, 62 void ConvertD24S8ToABGR8(const Framebuffer* dst_framebuffer, ImageView& src_image_view,
63 u32 up_scale, u32 down_shift); 63 u32 up_scale, u32 down_shift);
64 64
65 void ConvertD24S8ToB10G11R11(const Framebuffer* dst_framebuffer, ImageView& src_image_view,
66 u32 up_scale, u32 down_shift);
67
68 void ConvertD24S8ToR16G16(const Framebuffer* dst_framebuffer, ImageView& src_image_view,
69 u32 up_scale, u32 down_shift);
70
65private: 71private:
66 void Convert(VkPipeline pipeline, const Framebuffer* dst_framebuffer, 72 void Convert(VkPipeline pipeline, const Framebuffer* dst_framebuffer,
67 const ImageView& src_image_view, u32 up_scale, u32 down_shift); 73 const ImageView& src_image_view, u32 up_scale, u32 down_shift);
@@ -97,6 +103,8 @@ private:
97 vk::ShaderModule convert_float_to_depth_frag; 103 vk::ShaderModule convert_float_to_depth_frag;
98 vk::ShaderModule convert_abgr8_to_d24s8_frag; 104 vk::ShaderModule convert_abgr8_to_d24s8_frag;
99 vk::ShaderModule convert_d24s8_to_abgr8_frag; 105 vk::ShaderModule convert_d24s8_to_abgr8_frag;
106 vk::ShaderModule convert_d24s8_to_b10g11r11_frag;
107 vk::ShaderModule convert_d24s8_to_r16g16_frag;
100 vk::Sampler linear_sampler; 108 vk::Sampler linear_sampler;
101 vk::Sampler nearest_sampler; 109 vk::Sampler nearest_sampler;
102 110
@@ -110,6 +118,8 @@ private:
110 vk::Pipeline convert_r16_to_d16_pipeline; 118 vk::Pipeline convert_r16_to_d16_pipeline;
111 vk::Pipeline convert_abgr8_to_d24s8_pipeline; 119 vk::Pipeline convert_abgr8_to_d24s8_pipeline;
112 vk::Pipeline convert_d24s8_to_abgr8_pipeline; 120 vk::Pipeline convert_d24s8_to_abgr8_pipeline;
121 vk::Pipeline convert_d24s8_to_b10g11r11_pipeline;
122 vk::Pipeline convert_d24s8_to_r16g16_pipeline;
113}; 123};
114 124
115} // namespace Vulkan 125} // 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 6dfd45f31..fd6064271 100644
--- a/src/video_core/renderer_vulkan/vk_texture_cache.cpp
+++ b/src/video_core/renderer_vulkan/vk_texture_cache.cpp
@@ -887,6 +887,16 @@ void TextureCacheRuntime::ConvertImage(Framebuffer* dst, ImageView& dst_view, Im
887 return blit_image_helper.ConvertD24S8ToABGR8(dst, src_view, up_scale, down_shift); 887 return blit_image_helper.ConvertD24S8ToABGR8(dst, src_view, up_scale, down_shift);
888 } 888 }
889 break; 889 break;
890 case PixelFormat::B10G11R11_FLOAT:
891 if (src_view.format == PixelFormat::S8_UINT_D24_UNORM) {
892 return blit_image_helper.ConvertD24S8ToB10G11R11(dst, src_view, up_scale, down_shift);
893 }
894 break;
895 case PixelFormat::R16G16_UNORM:
896 if (src_view.format == PixelFormat::S8_UINT_D24_UNORM) {
897 return blit_image_helper.ConvertD24S8ToR16G16(dst, src_view, up_scale, down_shift);
898 }
899 break;
890 case PixelFormat::R32_FLOAT: 900 case PixelFormat::R32_FLOAT:
891 if (src_view.format == PixelFormat::D32_FLOAT) { 901 if (src_view.format == PixelFormat::D32_FLOAT) {
892 return blit_image_helper.ConvertD32ToR32(dst, src_view, up_scale, down_shift); 902 return blit_image_helper.ConvertD32ToR32(dst, src_view, up_scale, down_shift);