summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/video_core/host_shaders/CMakeLists.txt1
-rw-r--r--src/video_core/host_shaders/convert_abgr8_to_d32f.frag15
-rw-r--r--src/video_core/host_shaders/convert_d32f_to_abgr8.frag2
-rw-r--r--src/video_core/renderer_vulkan/blit_image.cpp9
-rw-r--r--src/video_core/renderer_vulkan/blit_image.h4
-rw-r--r--src/video_core/renderer_vulkan/vk_texture_cache.cpp21
6 files changed, 51 insertions, 1 deletions
diff --git a/src/video_core/host_shaders/CMakeLists.txt b/src/video_core/host_shaders/CMakeLists.txt
index 8bb429578..cd2549232 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_d24s8_to_abgr8.frag 24 convert_d24s8_to_abgr8.frag
24 convert_depth_to_float.frag 25 convert_depth_to_float.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..095b910c2
--- /dev/null
+++ b/src/video_core/host_shaders/convert_abgr8_to_d32f.frag
@@ -0,0 +1,15 @@
1// SPDX-FileCopyrightText: Copyright 2023 yuzu Emulator Project
2// SPDX-License-Identifier: GPL-2.0-or-later
3
4#version 450
5
6layout(binding = 0) uniform sampler2D color_texture;
7
8void main() {
9 ivec2 coord = ivec2(gl_FragCoord.xy);
10 vec4 color = texelFetch(color_texture, coord, 0).abgr;
11
12 float value = color.a * (color.r + color.g + color.b) / 3.0f;
13
14 gl_FragDepth = value;
15}
diff --git a/src/video_core/host_shaders/convert_d32f_to_abgr8.frag b/src/video_core/host_shaders/convert_d32f_to_abgr8.frag
index 04cfef8b5..4e5a9f955 100644
--- a/src/video_core/host_shaders/convert_d32f_to_abgr8.frag
+++ b/src/video_core/host_shaders/convert_d32f_to_abgr8.frag
@@ -9,6 +9,6 @@ layout(location = 0) out vec4 color;
9 9
10void main() { 10void main() {
11 ivec2 coord = ivec2(gl_FragCoord.xy); 11 ivec2 coord = ivec2(gl_FragCoord.xy);
12 float depth = textureLod(depth_tex, coord, 0).r; 12 float depth = texelFetch(depth_tex, coord, 0).r;
13 color = vec4(depth, depth, depth, 1.0); 13 color = vec4(depth, depth, depth, 1.0);
14} 14}
diff --git a/src/video_core/renderer_vulkan/blit_image.cpp b/src/video_core/renderer_vulkan/blit_image.cpp
index f01d2394e..c3db09424 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_depth_to_float_frag_spv.h" 14#include "video_core/host_shaders/convert_depth_to_float_frag_spv.h"
@@ -434,6 +435,7 @@ BlitImageHelper::BlitImageHelper(const Device& device_, Scheduler& scheduler_,
434 convert_depth_to_float_frag(BuildShader(device, CONVERT_DEPTH_TO_FLOAT_FRAG_SPV)), 435 convert_depth_to_float_frag(BuildShader(device, CONVERT_DEPTH_TO_FLOAT_FRAG_SPV)),
435 convert_float_to_depth_frag(BuildShader(device, CONVERT_FLOAT_TO_DEPTH_FRAG_SPV)), 436 convert_float_to_depth_frag(BuildShader(device, CONVERT_FLOAT_TO_DEPTH_FRAG_SPV)),
436 convert_abgr8_to_d24s8_frag(BuildShader(device, CONVERT_ABGR8_TO_D24S8_FRAG_SPV)), 437 convert_abgr8_to_d24s8_frag(BuildShader(device, CONVERT_ABGR8_TO_D24S8_FRAG_SPV)),
438 convert_abgr8_to_d32f_frag(BuildShader(device, CONVERT_ABGR8_TO_D32F_FRAG_SPV)),
437 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)),
438 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)),
439 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)),
@@ -559,6 +561,13 @@ void BlitImageHelper::ConvertABGR8ToD24S8(const Framebuffer* dst_framebuffer,
559 Convert(*convert_abgr8_to_d24s8_pipeline, dst_framebuffer, src_image_view); 561 Convert(*convert_abgr8_to_d24s8_pipeline, dst_framebuffer, src_image_view);
560} 562}
561 563
564void BlitImageHelper::ConvertABGR8ToD32F(const Framebuffer* dst_framebuffer,
565 const ImageView& src_image_view) {
566 ConvertPipelineDepthTargetEx(convert_abgr8_to_d32f_pipeline, dst_framebuffer->RenderPass(),
567 convert_abgr8_to_d32f_frag);
568 Convert(*convert_abgr8_to_d32f_pipeline, dst_framebuffer, src_image_view);
569}
570
562void BlitImageHelper::ConvertD32FToABGR8(const Framebuffer* dst_framebuffer, 571void BlitImageHelper::ConvertD32FToABGR8(const Framebuffer* dst_framebuffer,
563 ImageView& src_image_view) { 572 ImageView& src_image_view) {
564 ConvertPipelineColorTargetEx(convert_d32f_to_abgr8_pipeline, dst_framebuffer->RenderPass(), 573 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 a032c71fb..b2104a59e 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);
@@ -130,6 +132,7 @@ private:
130 vk::ShaderModule convert_depth_to_float_frag; 132 vk::ShaderModule convert_depth_to_float_frag;
131 vk::ShaderModule convert_float_to_depth_frag; 133 vk::ShaderModule convert_float_to_depth_frag;
132 vk::ShaderModule convert_abgr8_to_d24s8_frag; 134 vk::ShaderModule convert_abgr8_to_d24s8_frag;
135 vk::ShaderModule convert_abgr8_to_d32f_frag;
133 vk::ShaderModule convert_d32f_to_abgr8_frag; 136 vk::ShaderModule convert_d32f_to_abgr8_frag;
134 vk::ShaderModule convert_d24s8_to_abgr8_frag; 137 vk::ShaderModule convert_d24s8_to_abgr8_frag;
135 vk::ShaderModule convert_s8d24_to_abgr8_frag; 138 vk::ShaderModule convert_s8d24_to_abgr8_frag;
@@ -149,6 +152,7 @@ private:
149 vk::Pipeline convert_d16_to_r16_pipeline; 152 vk::Pipeline convert_d16_to_r16_pipeline;
150 vk::Pipeline convert_r16_to_d16_pipeline; 153 vk::Pipeline convert_r16_to_d16_pipeline;
151 vk::Pipeline convert_abgr8_to_d24s8_pipeline; 154 vk::Pipeline convert_abgr8_to_d24s8_pipeline;
155 vk::Pipeline convert_abgr8_to_d32f_pipeline;
152 vk::Pipeline convert_d32f_to_abgr8_pipeline; 156 vk::Pipeline convert_d32f_to_abgr8_pipeline;
153 vk::Pipeline convert_d24s8_to_abgr8_pipeline; 157 vk::Pipeline convert_d24s8_to_abgr8_pipeline;
154 vk::Pipeline convert_s8d24_to_abgr8_pipeline; 158 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 93773a69f..80efd9517 100644
--- a/src/video_core/renderer_vulkan/vk_texture_cache.cpp
+++ b/src/video_core/renderer_vulkan/vk_texture_cache.cpp
@@ -1194,6 +1194,11 @@ void TextureCacheRuntime::ConvertImage(Framebuffer* dst, ImageView& dst_view, Im
1194 return blit_image_helper.ConvertD16ToR16(dst, src_view); 1194 return blit_image_helper.ConvertD16ToR16(dst, src_view);
1195 } 1195 }
1196 break; 1196 break;
1197 case PixelFormat::A8B8G8R8_SRGB:
1198 if (src_view.format == PixelFormat::D32_FLOAT) {
1199 return blit_image_helper.ConvertD32FToABGR8(dst, src_view);
1200 }
1201 break;
1197 case PixelFormat::A8B8G8R8_UNORM: 1202 case PixelFormat::A8B8G8R8_UNORM:
1198 if (src_view.format == PixelFormat::S8_UINT_D24_UNORM) { 1203 if (src_view.format == PixelFormat::S8_UINT_D24_UNORM) {
1199 return blit_image_helper.ConvertD24S8ToABGR8(dst, src_view); 1204 return blit_image_helper.ConvertD24S8ToABGR8(dst, src_view);
@@ -1205,6 +1210,16 @@ void TextureCacheRuntime::ConvertImage(Framebuffer* dst, ImageView& dst_view, Im
1205 return blit_image_helper.ConvertD32FToABGR8(dst, src_view); 1210 return blit_image_helper.ConvertD32FToABGR8(dst, src_view);
1206 } 1211 }
1207 break; 1212 break;
1213 case PixelFormat::B8G8R8A8_SRGB:
1214 if (src_view.format == PixelFormat::D32_FLOAT) {
1215 return blit_image_helper.ConvertD32FToABGR8(dst, src_view);
1216 }
1217 break;
1218 case PixelFormat::B8G8R8A8_UNORM:
1219 if (src_view.format == PixelFormat::D32_FLOAT) {
1220 return blit_image_helper.ConvertD32FToABGR8(dst, src_view);
1221 }
1222 break;
1208 case PixelFormat::R32_FLOAT: 1223 case PixelFormat::R32_FLOAT:
1209 if (src_view.format == PixelFormat::D32_FLOAT) { 1224 if (src_view.format == PixelFormat::D32_FLOAT) {
1210 return blit_image_helper.ConvertD32ToR32(dst, src_view); 1225 return blit_image_helper.ConvertD32ToR32(dst, src_view);
@@ -1222,6 +1237,12 @@ void TextureCacheRuntime::ConvertImage(Framebuffer* dst, ImageView& dst_view, Im
1222 } 1237 }
1223 break; 1238 break;
1224 case PixelFormat::D32_FLOAT: 1239 case PixelFormat::D32_FLOAT:
1240 if (src_view.format == PixelFormat::A8B8G8R8_UNORM ||
1241 src_view.format == PixelFormat::B8G8R8A8_UNORM ||
1242 src_view.format == PixelFormat::A8B8G8R8_SRGB ||
1243 src_view.format == PixelFormat::B8G8R8A8_SRGB) {
1244 return blit_image_helper.ConvertABGR8ToD32F(dst, src_view);
1245 }
1225 if (src_view.format == PixelFormat::R32_FLOAT) { 1246 if (src_view.format == PixelFormat::R32_FLOAT) {
1226 return blit_image_helper.ConvertR32ToD32(dst, src_view); 1247 return blit_image_helper.ConvertR32ToD32(dst, src_view);
1227 } 1248 }