VERY experimental Nintendo Switch 2 emulator
C++
Another missing copy connected to Bravely Default II
Squall-Leonhart69ab83ae87cc
diff --git a/src/video_core/host_shaders/CMakeLists.txt b/src/video_core/host_shaders/CMakeLists.txtindex cf20f39f0a..cff8e38d68 100644--- a/src/video_core/host_shaders/CMakeLists.txt+++ b/src/video_core/host_shaders/CMakeLists.txt@@ -19,6 +19,7 @@ set(SHADER_FILESblock_linear_unswizzle_2d.compblock_linear_unswizzle_3d.compconvert_abgr8_to_d24s8.frag+ convert_abgr8_to_d32f.fragconvert_d32f_to_abgr8.fragconvert_d32f_to_bgra8.fragconvert_d24s8_to_abgr8.fragdiff --git a/src/video_core/host_shaders/convert_abgr8_to_d32f.frag b/src/video_core/host_shaders/convert_abgr8_to_d32f.fragnew file mode 100644index 0000000000..a1880b9163--- /dev/null+++ b/src/video_core/host_shaders/convert_abgr8_to_d32f.frag@@ -0,0 +1,18 @@+// SPDX-FileCopyrightText: Copyright 2023 Your Project+// SPDX-License-Identifier: GPL-2.0-or-later++#version 450++layout(binding = 0) uniform sampler2D color_texture;++void main() {+ ivec2 coord = ivec2(gl_FragCoord.xy);+ vec4 color = texelFetch(color_texture, coord, 0).abgr;++ uvec4 bytes = uvec4(color * (exp2(8) - 1.0f)) << uvec4(24, 16, 8, 0);+ uint depth_unorm = bytes.x | bytes.y | bytes.z | bytes.w;++ float depth_float = uintBitsToFloat(depth_unorm);++ gl_FragDepth = depth_float;+}diff --git a/src/video_core/renderer_vulkan/blit_image.cpp b/src/video_core/renderer_vulkan/blit_image.cppindex 18f51a3274..78a60fbe64 100644--- a/src/video_core/renderer_vulkan/blit_image.cpp+++ b/src/video_core/renderer_vulkan/blit_image.cpp@@ -8,6 +8,7 @@#include "common/settings.h"#include "video_core/host_shaders/blit_color_float_frag_spv.h"#include "video_core/host_shaders/convert_abgr8_to_d24s8_frag_spv.h"+#include "video_core/host_shaders/convert_abgr8_to_d32f_frag_spv.h"#include "video_core/host_shaders/convert_d24s8_to_abgr8_frag_spv.h"#include "video_core/host_shaders/convert_d32f_to_abgr8_frag_spv.h"#include "video_core/host_shaders/convert_d32f_to_bgra8_frag_spv.h"@@ -561,6 +562,13 @@ void BlitImageHelper::ConvertABGR8ToD24S8(const Framebuffer* dst_framebuffer,Convert(*convert_abgr8_to_d24s8_pipeline, dst_framebuffer, src_image_view);}+void BlitImageHelper::ConvertABGR8ToD32F(const Framebuffer* dst_framebuffer,+ const ImageView& src_image_view) {+ ConvertPipelineDepthTargetEx(convert_abgr8_to_d32f_pipeline, dst_framebuffer->RenderPass(),+ convert_abgr8_to_d32f_frag);+ Convert(*convert_abgr8_to_d32f_pipeline, dst_framebuffer, src_image_view);+}+void BlitImageHelper::ConvertD32FToABGR8(const Framebuffer* dst_framebuffer,ImageView& src_image_view) {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.hindex d083b46803..b3281ff3ea 100644--- a/src/video_core/renderer_vulkan/blit_image.h+++ b/src/video_core/renderer_vulkan/blit_image.h@@ -67,6 +67,8 @@ public:void ConvertABGR8ToD24S8(const Framebuffer* dst_framebuffer, const ImageView& src_image_view);+ void ConvertABGR8ToD32F(const Framebuffer* dst_framebuffer, const ImageView& src_image_view);+void ConvertD32FToABGR8(const Framebuffer* dst_framebuffer, ImageView& src_image_view);void ConvertD24S8ToABGR8(const Framebuffer* dst_framebuffer, ImageView& src_image_view);@@ -132,6 +134,7 @@ private:vk::ShaderModule convert_depth_to_float_frag;vk::ShaderModule convert_float_to_depth_frag;vk::ShaderModule convert_abgr8_to_d24s8_frag;+ vk::ShaderModule convert_abgr8_to_d32f_frag;vk::ShaderModule convert_d32f_to_abgr8_frag;vk::ShaderModule convert_d24s8_to_abgr8_frag;vk::ShaderModule convert_s8d24_to_abgr8_frag;@@ -152,6 +155,7 @@ private:vk::Pipeline convert_d16_to_r16_pipeline;vk::Pipeline convert_r16_to_d16_pipeline;vk::Pipeline convert_abgr8_to_d24s8_pipeline;+ vk::Pipeline convert_abgr8_to_d32f_pipeline;vk::Pipeline convert_d32f_to_abgr8_pipeline;vk::Pipeline convert_d24s8_to_abgr8_pipeline;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.cppindex 3ad144dab1..f913a99b90 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}break;case PixelFormat::D32_FLOAT:+ if (src_view.format == PixelFormat::A8B8G8R8_SRGB ||+ src_view.format == PixelFormat::B8G8R8A8_SRGB) {+ return blit_image_helper.ConvertABGR8ToD32F(dst, src_view);+ }if (src_view.format == PixelFormat::R32_FLOAT) {return blit_image_helper.ConvertR32ToD32(dst, src_view);}