From f809d2eba84ce3931339b073e22943efcf153068 Mon Sep 17 00:00:00 2001 From: pineappleEA Date: Sun, 25 Apr 2021 09:04:36 +0200 Subject: [PATCH] early-access version 1631 --- README.md | 2 +- .../renderer_vulkan/vk_texture_cache.cpp | 25 ++++++++++++++++++- 2 files changed, 25 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 539489609..2100f4b0c 100755 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@ yuzu emulator early access ============= -This is the source code for early-access 1630. +This is the source code for early-access 1631. ## Legal Notice diff --git a/src/video_core/renderer_vulkan/vk_texture_cache.cpp b/src/video_core/renderer_vulkan/vk_texture_cache.cpp index bc2a53841..017348e05 100755 --- a/src/video_core/renderer_vulkan/vk_texture_cache.cpp +++ b/src/video_core/renderer_vulkan/vk_texture_cache.cpp @@ -417,7 +417,7 @@ constexpr VkBorderColor ConvertBorderColor(const std::array& color) { }; } -[[nodiscard]] constexpr SwizzleSource ConvertGreenRed(SwizzleSource value) { +[[nodiscard]] SwizzleSource ConvertGreenRed(SwizzleSource value) { switch (value) { case SwizzleSource::G: return SwizzleSource::R; @@ -426,6 +426,17 @@ constexpr VkBorderColor ConvertBorderColor(const std::array& color) { } } +[[nodiscard]] SwizzleSource SwapBlueRed(SwizzleSource value) { + switch (value) { + case SwizzleSource::R: + return SwizzleSource::B; + case SwizzleSource::B: + return SwizzleSource::R; + default: + return value; + } +} + void CopyBufferToImage(vk::CommandBuffer cmdbuf, VkBuffer src_buffer, VkImage image, VkImageAspectFlags aspect_mask, bool is_initialized, std::span copies) { @@ -543,6 +554,15 @@ void CopyBufferToImage(vk::CommandBuffer cmdbuf, VkBuffer src_buffer, VkImage im }; } +[[nodiscard]] bool IsFormatFlipped(PixelFormat format) { + switch (format) { + case PixelFormat::A1B5G5R5_UNORM: + return true; + default: + return false; + } +} + struct RangedBarrierRange { u32 min_mip = std::numeric_limits::max(); u32 max_mip = std::numeric_limits::min(); @@ -948,6 +968,9 @@ ImageView::ImageView(TextureCacheRuntime& runtime, const VideoCommon::ImageViewI }; if (!info.IsRenderTarget()) { swizzle = info.Swizzle(); + if (IsFormatFlipped(format)) { + std::ranges::transform(swizzle, swizzle.begin(), SwapBlueRed); + } if ((aspect_mask & (VK_IMAGE_ASPECT_DEPTH_BIT | VK_IMAGE_ASPECT_STENCIL_BIT)) != 0) { std::ranges::transform(swizzle, swizzle.begin(), ConvertGreenRed); }