diff options
author | Rodrigo Locatti <reinuseslisp@airmail.cc> | 2021-04-25 08:14:43 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-04-25 08:14:43 +0200 |
commit | 2ff39f6fdc1be6e1ed83b384bb9773049061e6b9 (patch) | |
tree | 103338558d78b74530df72d70914b40df8a4762f /src | |
parent | Merge pull request #6234 from Morph1984/stub-am (diff) | |
parent | vk_texture_cache: Swap R and B channels of color flipped format (diff) | |
download | yuzu-2ff39f6fdc1be6e1ed83b384bb9773049061e6b9.tar yuzu-2ff39f6fdc1be6e1ed83b384bb9773049061e6b9.tar.gz yuzu-2ff39f6fdc1be6e1ed83b384bb9773049061e6b9.tar.bz2 yuzu-2ff39f6fdc1be6e1ed83b384bb9773049061e6b9.tar.lz yuzu-2ff39f6fdc1be6e1ed83b384bb9773049061e6b9.tar.xz yuzu-2ff39f6fdc1be6e1ed83b384bb9773049061e6b9.tar.zst yuzu-2ff39f6fdc1be6e1ed83b384bb9773049061e6b9.zip |
Diffstat (limited to 'src')
-rw-r--r-- | src/video_core/renderer_vulkan/vk_texture_cache.cpp | 25 |
1 files changed, 24 insertions, 1 deletions
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 100644 --- 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<float, 4>& 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<float, 4>& 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<const VkBufferImageCopy> 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<u32>::max(); u32 max_mip = std::numeric_limits<u32>::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); } |