summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorGravatar Fernando Sahmkow2021-11-22 00:00:01 +0100
committerGravatar Fernando Sahmkow2021-11-22 00:00:01 +0100
commit853284943901560081f6ff992b6c04b7c33f0d21 (patch)
tree841c26186ab3c572851a612d2fc52407ab797d6f /src
parentVulkanTexturECache: Use reinterpret on D32_S8 formats. (diff)
downloadyuzu-853284943901560081f6ff992b6c04b7c33f0d21.tar.gz
yuzu-853284943901560081f6ff992b6c04b7c33f0d21.tar.xz
yuzu-853284943901560081f6ff992b6c04b7c33f0d21.zip
TextureCache: Simplify blitting of D24S8 formats and fix bugs.
Diffstat (limited to 'src')
-rw-r--r--src/video_core/host_shaders/CMakeLists.txt4
-rw-r--r--src/video_core/host_shaders/convert_b10g11r11_to_d24s8.frag27
-rw-r--r--src/video_core/host_shaders/convert_d24s8_to_b10g11r11.frag32
-rw-r--r--src/video_core/host_shaders/convert_d24s8_to_r16g16.frag22
-rw-r--r--src/video_core/host_shaders/convert_r16g16_to_d24s8.frag19
-rw-r--r--src/video_core/renderer_vulkan/blit_image.cpp98
-rw-r--r--src/video_core/renderer_vulkan/blit_image.h25
-rw-r--r--src/video_core/renderer_vulkan/vk_texture_cache.cpp30
-rw-r--r--src/video_core/renderer_vulkan/vk_texture_cache.h3
-rw-r--r--src/video_core/texture_cache/texture_cache.h8
10 files changed, 73 insertions, 195 deletions
diff --git a/src/video_core/host_shaders/CMakeLists.txt b/src/video_core/host_shaders/CMakeLists.txt
index 1c91999d7..fd3e41434 100644
--- a/src/video_core/host_shaders/CMakeLists.txt
+++ b/src/video_core/host_shaders/CMakeLists.txt
@@ -11,13 +11,9 @@ set(SHADER_FILES
11 block_linear_unswizzle_2d.comp 11 block_linear_unswizzle_2d.comp
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_b10g11r11_to_d24s8.frag
15 convert_d24s8_to_abgr8.frag 14 convert_d24s8_to_abgr8.frag
16 convert_d24s8_to_b10g11r11.frag
17 convert_d24s8_to_r16g16.frag
18 convert_depth_to_float.frag 15 convert_depth_to_float.frag
19 convert_float_to_depth.frag 16 convert_float_to_depth.frag
20 convert_r16g16_to_d24s8.frag
21 full_screen_triangle.vert 17 full_screen_triangle.vert
22 fxaa.frag 18 fxaa.frag
23 fxaa.vert 19 fxaa.vert
diff --git a/src/video_core/host_shaders/convert_b10g11r11_to_d24s8.frag b/src/video_core/host_shaders/convert_b10g11r11_to_d24s8.frag
deleted file mode 100644
index 11bdd861d..000000000
--- a/src/video_core/host_shaders/convert_b10g11r11_to_d24s8.frag
+++ /dev/null
@@ -1,27 +0,0 @@
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
8layout(binding = 0) uniform sampler2D color_texture;
9
10uint conv_from_float(float value_f, uint mantissa_bits) {
11 uint value = floatBitsToInt(value_f);
12 uint exp = (value >> 23) & 0x1Fu;
13 uint mantissa_shift = 32u - mantissa_bits;
14 uint mantissa = (value << 9u) >> mantissa_shift;
15 return (exp << mantissa_bits) | mantissa;
16}
17
18void main() {
19 ivec2 coord = ivec2(gl_FragCoord.xy);
20 vec4 color = texelFetch(color_texture, coord, 0).rgba;
21 uint depth_stencil_unorm = (conv_from_float(color.r, 6u) << 21)
22 | (conv_from_float(color.g, 6u) << 10)
23 | conv_from_float(color.b, 5u);
24
25 gl_FragDepth = float(depth_stencil_unorm & 0x00FFFFFFu) / (exp2(24.0) - 1.0f);
26 gl_FragStencilRefARB = int(depth_stencil_unorm >> 24);
27}
diff --git a/src/video_core/host_shaders/convert_d24s8_to_b10g11r11.frag b/src/video_core/host_shaders/convert_d24s8_to_b10g11r11.frag
deleted file mode 100644
index c2d935fcd..000000000
--- a/src/video_core/host_shaders/convert_d24s8_to_b10g11r11.frag
+++ /dev/null
@@ -1,32 +0,0 @@
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
12float conv_to_float(uint value, uint mantissa_bits) {
13 uint exp = (value >> mantissa_bits) & 0x1Fu;
14 uint mantissa_shift = 32u - mantissa_bits;
15 uint mantissa = (value << mantissa_shift) >> mantissa_shift;
16 return uintBitsToFloat((exp << 23) | (mantissa << (23 - mantissa_bits)));
17}
18
19void main() {
20 ivec2 coord = ivec2(gl_FragCoord.xy);
21 uint depth = uint(textureLod(depth_tex, coord, 0).r * (exp2(32.0) - 1.0f));
22 uint stencil = uint(textureLod(stencil_tex, coord, 0).r);
23 uint depth_stencil = (stencil << 24) | (depth >> 8);
24 uint red_int = (depth_stencil >> 21) & 0x07FF;
25 uint green_int = (depth_stencil >> 10) & 0x07FF;
26 uint blue_int = depth_stencil & 0x03FF;
27
28 color.r = conv_to_float(red_int, 6u);
29 color.g = conv_to_float(green_int, 6u);
30 color.b = conv_to_float(blue_int, 5u);
31 color.a = 1.0f;
32}
diff --git a/src/video_core/host_shaders/convert_d24s8_to_r16g16.frag b/src/video_core/host_shaders/convert_d24s8_to_r16g16.frag
deleted file mode 100644
index c48a7ac66..000000000
--- a/src/video_core/host_shaders/convert_d24s8_to_r16g16.frag
+++ /dev/null
@@ -1,22 +0,0 @@
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(32.0) - 1.0f));
15 uint stencil = uint(textureLod(stencil_tex, coord, 0).r);
16 uint depth_stencil = (stencil << 24) | (depth >> 8);
17
18 color.r = float(depth_stencil & 0x0000FFFFu) / (exp2(16) - 1.0);
19 color.g = float(depth_stencil >> 16) / (exp2(16) - 1.0);
20 color.b = 0.0f;
21 color.a = 1.0f;
22}
diff --git a/src/video_core/host_shaders/convert_r16g16_to_d24s8.frag b/src/video_core/host_shaders/convert_r16g16_to_d24s8.frag
deleted file mode 100644
index beb2d1284..000000000
--- a/src/video_core/host_shaders/convert_r16g16_to_d24s8.frag
+++ /dev/null
@@ -1,19 +0,0 @@
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
8layout(binding = 0) uniform sampler2D color_texture;
9
10void main() {
11 ivec2 coord = ivec2(gl_FragCoord.xy);
12 vec4 color = texelFetch(color_texture, coord, 0).rgba;
13 uvec2 bytes = uvec2(color.rg * (exp2(16) - 1.0f)) << uvec2(0, 16);
14 uint depth_stencil_unorm =
15 uint(color.r * (exp2(16) - 1.0f)) | (uint(color.g * (exp2(16) - 1.0f)) << 16);
16
17 gl_FragDepth = float(depth_stencil_unorm & 0x00FFFFFFu) / (exp2(24.0) - 1.0f);
18 gl_FragStencilRefARB = int(depth_stencil_unorm >> 24);
19}
diff --git a/src/video_core/renderer_vulkan/blit_image.cpp b/src/video_core/renderer_vulkan/blit_image.cpp
index 28b631f73..2e69e270f 100644
--- a/src/video_core/renderer_vulkan/blit_image.cpp
+++ b/src/video_core/renderer_vulkan/blit_image.cpp
@@ -5,13 +5,9 @@
5#include <algorithm> 5#include <algorithm>
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_b10g11r11_to_d24s8_frag_spv.h"
9#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"
10#include "video_core/host_shaders/convert_d24s8_to_b10g11r11_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" 9#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" 10#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"
15#include "video_core/host_shaders/full_screen_triangle_vert_spv.h" 11#include "video_core/host_shaders/full_screen_triangle_vert_spv.h"
16#include "video_core/host_shaders/vulkan_blit_color_float_frag_spv.h" 12#include "video_core/host_shaders/vulkan_blit_color_float_frag_spv.h"
17#include "video_core/host_shaders/vulkan_blit_depth_stencil_frag_spv.h" 13#include "video_core/host_shaders/vulkan_blit_depth_stencil_frag_spv.h"
@@ -361,11 +357,7 @@ BlitImageHelper::BlitImageHelper(const Device& device_, VKScheduler& scheduler_,
361 convert_depth_to_float_frag(BuildShader(device, CONVERT_DEPTH_TO_FLOAT_FRAG_SPV)), 357 convert_depth_to_float_frag(BuildShader(device, CONVERT_DEPTH_TO_FLOAT_FRAG_SPV)),
362 convert_float_to_depth_frag(BuildShader(device, CONVERT_FLOAT_TO_DEPTH_FRAG_SPV)), 358 convert_float_to_depth_frag(BuildShader(device, CONVERT_FLOAT_TO_DEPTH_FRAG_SPV)),
363 convert_abgr8_to_d24s8_frag(BuildShader(device, CONVERT_ABGR8_TO_D24S8_FRAG_SPV)), 359 convert_abgr8_to_d24s8_frag(BuildShader(device, CONVERT_ABGR8_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)),
366 convert_d24s8_to_abgr8_frag(BuildShader(device, CONVERT_D24S8_TO_ABGR8_FRAG_SPV)), 360 convert_d24s8_to_abgr8_frag(BuildShader(device, CONVERT_D24S8_TO_ABGR8_FRAG_SPV)),
367 convert_d24s8_to_b10g11r11_frag(BuildShader(device, CONVERT_D24S8_TO_B10G11R11_FRAG_SPV)),
368 convert_d24s8_to_r16g16_frag(BuildShader(device, CONVERT_D24S8_TO_R16G16_FRAG_SPV)),
369 linear_sampler(device.GetLogical().CreateSampler(SAMPLER_CREATE_INFO<VK_FILTER_LINEAR>)), 361 linear_sampler(device.GetLogical().CreateSampler(SAMPLER_CREATE_INFO<VK_FILTER_LINEAR>)),
370 nearest_sampler(device.GetLogical().CreateSampler(SAMPLER_CREATE_INFO<VK_FILTER_NEAREST>)) { 362 nearest_sampler(device.GetLogical().CreateSampler(SAMPLER_CREATE_INFO<VK_FILTER_NEAREST>)) {
371 if (device.IsExtShaderStencilExportSupported()) { 363 if (device.IsExtShaderStencilExportSupported()) {
@@ -461,30 +453,11 @@ void BlitImageHelper::ConvertR16ToD16(const Framebuffer* dst_framebuffer,
461} 453}
462 454
463void BlitImageHelper::ConvertABGR8ToD24S8(const Framebuffer* dst_framebuffer, 455void BlitImageHelper::ConvertABGR8ToD24S8(const Framebuffer* dst_framebuffer,
464 const ImageView& src_image_view, u32 up_scale, 456 ImageView& src_image_view, u32 up_scale, u32 down_shift) {
465 u32 down_shift) {
466 ConvertPipelineDepthTargetEx(convert_abgr8_to_d24s8_pipeline, dst_framebuffer->RenderPass(), 457 ConvertPipelineDepthTargetEx(convert_abgr8_to_d24s8_pipeline, dst_framebuffer->RenderPass(),
467 convert_abgr8_to_d24s8_frag, true); 458 convert_abgr8_to_d24s8_frag, true);
468 Convert(*convert_abgr8_to_d24s8_pipeline, dst_framebuffer, src_image_view, up_scale, 459 ConvertColor(*convert_abgr8_to_d24s8_pipeline, dst_framebuffer, src_image_view, up_scale,
469 down_shift); 460 down_shift);
470}
471
472void BlitImageHelper::ConvertB10G11R11ToD24S8(const Framebuffer* dst_framebuffer,
473 const ImageView& src_image_view, u32 up_scale,
474 u32 down_shift) {
475 ConvertPipelineDepthTargetEx(convert_b10g11r11_to_d24s8_pipeline, dst_framebuffer->RenderPass(),
476 convert_b10g11r11_to_d24s8_frag, true);
477 Convert(*convert_b10g11r11_to_d24s8_pipeline, dst_framebuffer, src_image_view, up_scale,
478 down_shift);
479}
480
481void 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} 461}
489 462
490void BlitImageHelper::ConvertD24S8ToABGR8(const Framebuffer* dst_framebuffer, 463void BlitImageHelper::ConvertD24S8ToABGR8(const Framebuffer* dst_framebuffer,
@@ -495,24 +468,6 @@ void BlitImageHelper::ConvertD24S8ToABGR8(const Framebuffer* dst_framebuffer,
495 down_shift); 468 down_shift);
496} 469}
497 470
498void BlitImageHelper::ConvertD24S8ToB10G11R11(const Framebuffer* dst_framebuffer,
499 ImageView& src_image_view, u32 up_scale,
500 u32 down_shift) {
501 ConvertPipelineColorTargetEx(convert_d24s8_to_b10g11r11_pipeline, dst_framebuffer->RenderPass(),
502 convert_d24s8_to_b10g11r11_frag, false);
503 ConvertDepthStencil(*convert_d24s8_to_b10g11r11_pipeline, dst_framebuffer, src_image_view,
504 up_scale, down_shift);
505}
506
507void BlitImageHelper::ConvertD24S8ToR16G16(const Framebuffer* dst_framebuffer,
508 ImageView& src_image_view, u32 up_scale,
509 u32 down_shift) {
510 ConvertPipelineColorTargetEx(convert_d24s8_to_r16g16_pipeline, dst_framebuffer->RenderPass(),
511 convert_d24s8_to_r16g16_frag, false);
512 ConvertDepthStencil(*convert_d24s8_to_r16g16_pipeline, dst_framebuffer, src_image_view,
513 up_scale, down_shift);
514}
515
516void BlitImageHelper::Convert(VkPipeline pipeline, const Framebuffer* dst_framebuffer, 471void BlitImageHelper::Convert(VkPipeline pipeline, const Framebuffer* dst_framebuffer,
517 const ImageView& src_image_view, u32 up_scale, u32 down_shift) { 472 const ImageView& src_image_view, u32 up_scale, u32 down_shift) {
518 const VkPipelineLayout layout = *one_texture_pipeline_layout; 473 const VkPipelineLayout layout = *one_texture_pipeline_layout;
@@ -560,6 +515,53 @@ void BlitImageHelper::Convert(VkPipeline pipeline, const Framebuffer* dst_frameb
560 scheduler.InvalidateState(); 515 scheduler.InvalidateState();
561} 516}
562 517
518void BlitImageHelper::ConvertColor(VkPipeline pipeline, const Framebuffer* dst_framebuffer,
519 ImageView& src_image_view, u32 up_scale, u32 down_shift) {
520 const VkPipelineLayout layout = *one_texture_pipeline_layout;
521 const VkImageView src_view = src_image_view.ColorView();
522 const VkSampler sampler = *nearest_sampler;
523 const VkExtent2D extent{
524 .width = std::max((src_image_view.size.width * up_scale) >> down_shift, 1U),
525 .height = std::max((src_image_view.size.height * up_scale) >> down_shift, 1U),
526 };
527 scheduler.RequestRenderpass(dst_framebuffer);
528 scheduler.Record([pipeline, layout, sampler, src_view, extent, up_scale, down_shift,
529 this](vk::CommandBuffer cmdbuf) {
530 const VkOffset2D offset{
531 .x = 0,
532 .y = 0,
533 };
534 const VkViewport viewport{
535 .x = 0.0f,
536 .y = 0.0f,
537 .width = static_cast<float>(extent.width),
538 .height = static_cast<float>(extent.height),
539 .minDepth = 0.0f,
540 .maxDepth = 0.0f,
541 };
542 const VkRect2D scissor{
543 .offset = offset,
544 .extent = extent,
545 };
546 const PushConstants push_constants{
547 .tex_scale = {viewport.width, viewport.height},
548 .tex_offset = {0.0f, 0.0f},
549 };
550 const VkDescriptorSet descriptor_set = one_texture_descriptor_allocator.Commit();
551 UpdateOneTextureDescriptorSet(device, descriptor_set, sampler, src_view);
552
553 // TODO: Barriers
554 cmdbuf.BindPipeline(VK_PIPELINE_BIND_POINT_GRAPHICS, pipeline);
555 cmdbuf.BindDescriptorSets(VK_PIPELINE_BIND_POINT_GRAPHICS, layout, 0, descriptor_set,
556 nullptr);
557 cmdbuf.SetViewport(0, viewport);
558 cmdbuf.SetScissor(0, scissor);
559 cmdbuf.PushConstants(layout, VK_SHADER_STAGE_VERTEX_BIT, push_constants);
560 cmdbuf.Draw(3, 1, 0, 0);
561 });
562 scheduler.InvalidateState();
563}
564
563void BlitImageHelper::ConvertDepthStencil(VkPipeline pipeline, const Framebuffer* dst_framebuffer, 565void BlitImageHelper::ConvertDepthStencil(VkPipeline pipeline, const Framebuffer* dst_framebuffer,
564 ImageView& src_image_view, u32 up_scale, u32 down_shift) { 566 ImageView& src_image_view, u32 up_scale, u32 down_shift) {
565 const VkPipelineLayout layout = *two_textures_pipeline_layout; 567 const VkPipelineLayout layout = *two_textures_pipeline_layout;
diff --git a/src/video_core/renderer_vulkan/blit_image.h b/src/video_core/renderer_vulkan/blit_image.h
index cec095341..0b73cf444 100644
--- a/src/video_core/renderer_vulkan/blit_image.h
+++ b/src/video_core/renderer_vulkan/blit_image.h
@@ -56,28 +56,19 @@ public:
56 void ConvertR16ToD16(const Framebuffer* dst_framebuffer, const ImageView& src_image_view, 56 void ConvertR16ToD16(const Framebuffer* dst_framebuffer, const ImageView& src_image_view,
57 u32 up_scale, u32 down_shift); 57 u32 up_scale, u32 down_shift);
58 58
59 void ConvertABGR8ToD24S8(const Framebuffer* dst_framebuffer, const ImageView& src_image_view, 59 void ConvertABGR8ToD24S8(const Framebuffer* dst_framebuffer, ImageView& src_image_view,
60 u32 up_scale, u32 down_shift); 60 u32 up_scale, u32 down_shift);
61 61
62 void ConvertB10G11R11ToD24S8(const Framebuffer* dst_framebuffer,
63 const ImageView& src_image_view, u32 up_scale, u32 down_shift);
64
65 void ConvertR16G16ToD24S8(const Framebuffer* dst_framebuffer, const ImageView& src_image_view,
66 u32 up_scale, u32 down_shift);
67
68 void ConvertD24S8ToABGR8(const Framebuffer* dst_framebuffer, ImageView& src_image_view, 62 void ConvertD24S8ToABGR8(const Framebuffer* dst_framebuffer, ImageView& src_image_view,
69 u32 up_scale, u32 down_shift); 63 u32 up_scale, u32 down_shift);
70 64
71 void ConvertD24S8ToB10G11R11(const Framebuffer* dst_framebuffer, ImageView& src_image_view,
72 u32 up_scale, u32 down_shift);
73
74 void ConvertD24S8ToR16G16(const Framebuffer* dst_framebuffer, ImageView& src_image_view,
75 u32 up_scale, u32 down_shift);
76
77private: 65private:
78 void Convert(VkPipeline pipeline, const Framebuffer* dst_framebuffer, 66 void Convert(VkPipeline pipeline, const Framebuffer* dst_framebuffer,
79 const ImageView& src_image_view, u32 up_scale, u32 down_shift); 67 const ImageView& src_image_view, u32 up_scale, u32 down_shift);
80 68
69 void ConvertColor(VkPipeline pipeline, const Framebuffer* dst_framebuffer,
70 ImageView& src_image_view, u32 up_scale, u32 down_shift);
71
81 void ConvertDepthStencil(VkPipeline pipeline, const Framebuffer* dst_framebuffer, 72 void ConvertDepthStencil(VkPipeline pipeline, const Framebuffer* dst_framebuffer,
82 ImageView& src_image_view, u32 up_scale, u32 down_shift); 73 ImageView& src_image_view, u32 up_scale, u32 down_shift);
83 74
@@ -111,11 +102,7 @@ private:
111 vk::ShaderModule convert_depth_to_float_frag; 102 vk::ShaderModule convert_depth_to_float_frag;
112 vk::ShaderModule convert_float_to_depth_frag; 103 vk::ShaderModule convert_float_to_depth_frag;
113 vk::ShaderModule convert_abgr8_to_d24s8_frag; 104 vk::ShaderModule convert_abgr8_to_d24s8_frag;
114 vk::ShaderModule convert_b10g11r11_to_d24s8_frag;
115 vk::ShaderModule convert_r16g16_to_d24s8_frag;
116 vk::ShaderModule convert_d24s8_to_abgr8_frag; 105 vk::ShaderModule convert_d24s8_to_abgr8_frag;
117 vk::ShaderModule convert_d24s8_to_b10g11r11_frag;
118 vk::ShaderModule convert_d24s8_to_r16g16_frag;
119 vk::Sampler linear_sampler; 106 vk::Sampler linear_sampler;
120 vk::Sampler nearest_sampler; 107 vk::Sampler nearest_sampler;
121 108
@@ -128,11 +115,7 @@ private:
128 vk::Pipeline convert_d16_to_r16_pipeline; 115 vk::Pipeline convert_d16_to_r16_pipeline;
129 vk::Pipeline convert_r16_to_d16_pipeline; 116 vk::Pipeline convert_r16_to_d16_pipeline;
130 vk::Pipeline convert_abgr8_to_d24s8_pipeline; 117 vk::Pipeline convert_abgr8_to_d24s8_pipeline;
131 vk::Pipeline convert_b10g11r11_to_d24s8_pipeline;
132 vk::Pipeline convert_r16g16_to_d24s8_pipeline;
133 vk::Pipeline convert_d24s8_to_abgr8_pipeline; 118 vk::Pipeline convert_d24s8_to_abgr8_pipeline;
134 vk::Pipeline convert_d24s8_to_b10g11r11_pipeline;
135 vk::Pipeline convert_d24s8_to_r16g16_pipeline;
136}; 119};
137 120
138} // namespace Vulkan 121} // 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 e1ba1bdaf..ef8ae6cb6 100644
--- a/src/video_core/renderer_vulkan/vk_texture_cache.cpp
+++ b/src/video_core/renderer_vulkan/vk_texture_cache.cpp
@@ -1063,21 +1063,10 @@ void TextureCacheRuntime::ConvertImage(Framebuffer* dst, ImageView& dst_view, Im
1063 } 1063 }
1064 break; 1064 break;
1065 case PixelFormat::A8B8G8R8_UNORM: 1065 case PixelFormat::A8B8G8R8_UNORM:
1066 case PixelFormat::B8G8R8A8_UNORM:
1067 if (src_view.format == PixelFormat::S8_UINT_D24_UNORM) { 1066 if (src_view.format == PixelFormat::S8_UINT_D24_UNORM) {
1068 return blit_image_helper.ConvertD24S8ToABGR8(dst, src_view, up_scale, down_shift); 1067 return blit_image_helper.ConvertD24S8ToABGR8(dst, src_view, up_scale, down_shift);
1069 } 1068 }
1070 break; 1069 break;
1071 case PixelFormat::B10G11R11_FLOAT:
1072 if (src_view.format == PixelFormat::S8_UINT_D24_UNORM) {
1073 return blit_image_helper.ConvertD24S8ToB10G11R11(dst, src_view, up_scale, down_shift);
1074 }
1075 break;
1076 case PixelFormat::R16G16_UNORM:
1077 if (src_view.format == PixelFormat::S8_UINT_D24_UNORM) {
1078 return blit_image_helper.ConvertD24S8ToR16G16(dst, src_view, up_scale, down_shift);
1079 }
1080 break;
1081 case PixelFormat::R32_FLOAT: 1070 case PixelFormat::R32_FLOAT:
1082 if (src_view.format == PixelFormat::D32_FLOAT) { 1071 if (src_view.format == PixelFormat::D32_FLOAT) {
1083 return blit_image_helper.ConvertD32ToR32(dst, src_view, up_scale, down_shift); 1072 return blit_image_helper.ConvertD32ToR32(dst, src_view, up_scale, down_shift);
@@ -1089,16 +1078,7 @@ void TextureCacheRuntime::ConvertImage(Framebuffer* dst, ImageView& dst_view, Im
1089 } 1078 }
1090 break; 1079 break;
1091 case PixelFormat::S8_UINT_D24_UNORM: 1080 case PixelFormat::S8_UINT_D24_UNORM:
1092 if (src_view.format == PixelFormat::A8B8G8R8_UNORM || 1081 return blit_image_helper.ConvertABGR8ToD24S8(dst, src_view, up_scale, down_shift);
1093 src_view.format == PixelFormat::B8G8R8A8_UNORM) {
1094 return blit_image_helper.ConvertABGR8ToD24S8(dst, src_view, up_scale, down_shift);
1095 }
1096 if (src_view.format == PixelFormat::B10G11R11_FLOAT) {
1097 return blit_image_helper.ConvertB10G11R11ToD24S8(dst, src_view, up_scale, down_shift);
1098 }
1099 if (src_view.format == PixelFormat::R16G16_UNORM) {
1100 return blit_image_helper.ConvertR16G16ToD24S8(dst, src_view, up_scale, down_shift);
1101 }
1102 break; 1082 break;
1103 case PixelFormat::D32_FLOAT: 1083 case PixelFormat::D32_FLOAT:
1104 if (src_view.format == PixelFormat::R32_FLOAT) { 1084 if (src_view.format == PixelFormat::R32_FLOAT) {
@@ -1595,6 +1575,14 @@ VkImageView ImageView::StencilView() {
1595 return *stencil_view; 1575 return *stencil_view;
1596} 1576}
1597 1577
1578VkImageView ImageView::ColorView() {
1579 if (color_view) {
1580 return *color_view;
1581 }
1582 color_view = MakeView(VK_FORMAT_R8G8B8A8_UNORM, VK_IMAGE_ASPECT_COLOR_BIT);
1583 return *color_view;
1584}
1585
1598VkImageView ImageView::StorageView(Shader::TextureType texture_type, 1586VkImageView ImageView::StorageView(Shader::TextureType texture_type,
1599 Shader::ImageFormat image_format) { 1587 Shader::ImageFormat image_format) {
1600 if (image_format == Shader::ImageFormat::Typeless) { 1588 if (image_format == Shader::ImageFormat::Typeless) {
diff --git a/src/video_core/renderer_vulkan/vk_texture_cache.h b/src/video_core/renderer_vulkan/vk_texture_cache.h
index 44e9dcee4..753e3e8a1 100644
--- a/src/video_core/renderer_vulkan/vk_texture_cache.h
+++ b/src/video_core/renderer_vulkan/vk_texture_cache.h
@@ -184,6 +184,8 @@ public:
184 184
185 [[nodiscard]] VkImageView StencilView(); 185 [[nodiscard]] VkImageView StencilView();
186 186
187 [[nodiscard]] VkImageView ColorView();
188
187 [[nodiscard]] VkImageView StorageView(Shader::TextureType texture_type, 189 [[nodiscard]] VkImageView StorageView(Shader::TextureType texture_type,
188 Shader::ImageFormat image_format); 190 Shader::ImageFormat image_format);
189 191
@@ -224,6 +226,7 @@ private:
224 std::unique_ptr<StorageViews> storage_views; 226 std::unique_ptr<StorageViews> storage_views;
225 vk::ImageView depth_view; 227 vk::ImageView depth_view;
226 vk::ImageView stencil_view; 228 vk::ImageView stencil_view;
229 vk::ImageView color_view;
227 VkImage image_handle = VK_NULL_HANDLE; 230 VkImage image_handle = VK_NULL_HANDLE;
228 VkImageView render_target = VK_NULL_HANDLE; 231 VkImageView render_target = VK_NULL_HANDLE;
229 VkSampleCountFlagBits samples = VK_SAMPLE_COUNT_1_BIT; 232 VkSampleCountFlagBits samples = VK_SAMPLE_COUNT_1_BIT;
diff --git a/src/video_core/texture_cache/texture_cache.h b/src/video_core/texture_cache/texture_cache.h
index 0e4907c53..9548abec8 100644
--- a/src/video_core/texture_cache/texture_cache.h
+++ b/src/video_core/texture_cache/texture_cache.h
@@ -1781,7 +1781,13 @@ void TextureCache<P>::CopyImage(ImageId dst_id, ImageId src_id, std::vector<Imag
1781 const SubresourceExtent src_extent{.levels = 1, .layers = 1}; 1781 const SubresourceExtent src_extent{.levels = 1, .layers = 1};
1782 const SubresourceRange dst_range{.base = dst_base, .extent = dst_extent}; 1782 const SubresourceRange dst_range{.base = dst_base, .extent = dst_extent};
1783 const SubresourceRange src_range{.base = src_base, .extent = src_extent}; 1783 const SubresourceRange src_range{.base = src_base, .extent = src_extent};
1784 const ImageViewInfo dst_view_info(ImageViewType::e2D, dst.info.format, dst_range); 1784 PixelFormat dst_format = dst.info.format;
1785 if (GetFormatType(src.info.format) == SurfaceType::DepthStencil &&
1786 GetFormatType(dst_format) == SurfaceType::ColorTexture &&
1787 BytesPerBlock(dst_format) == 4) {
1788 dst_format = PixelFormat::A8B8G8R8_UNORM;
1789 }
1790 const ImageViewInfo dst_view_info(ImageViewType::e2D, dst_format, dst_range);
1785 const ImageViewInfo src_view_info(ImageViewType::e2D, src.info.format, src_range); 1791 const ImageViewInfo src_view_info(ImageViewType::e2D, src.info.format, src_range);
1786 const auto [dst_framebuffer_id, dst_view_id] = RenderTargetFromImage(dst_id, dst_view_info); 1792 const auto [dst_framebuffer_id, dst_view_id] = RenderTargetFromImage(dst_id, dst_view_info);
1787 Framebuffer* const dst_framebuffer = &slot_framebuffers[dst_framebuffer_id]; 1793 Framebuffer* const dst_framebuffer = &slot_framebuffers[dst_framebuffer_id];