From c8fc8f84ecccbfc991f90f219ba9c628574e6cf2 Mon Sep 17 00:00:00 2001 From: Billy Laws Date: Sun, 6 Nov 2022 20:06:20 +0000 Subject: [PATCH] Fallback to RGBA888 for unsupported swapchain formats as opposed to swizzle --- app/src/main/cpp/skyline/gpu/presentation_engine.cpp | 11 +++++++---- app/src/main/cpp/skyline/gpu/texture/format.h | 7 +------ 2 files changed, 8 insertions(+), 10 deletions(-) diff --git a/app/src/main/cpp/skyline/gpu/presentation_engine.cpp b/app/src/main/cpp/skyline/gpu/presentation_engine.cpp index 78f97397..4541fbc8 100644 --- a/app/src/main/cpp/skyline/gpu/presentation_engine.cpp +++ b/app/src/main/cpp/skyline/gpu/presentation_engine.cpp @@ -288,10 +288,13 @@ namespace skyline::gpu { throw exception("Cannot update swapchain to accomodate image extent: {}x{} ({}x{}-{}x{})", extent.width, extent.height, capabilities.minImageExtent.width, capabilities.minImageExtent.height, capabilities.maxImageExtent.width, capabilities.maxImageExtent.height); vk::Format vkFormat{*format}; + texture::Format underlyingFormat{format}; if (swapchainFormat != format) { auto formats{gpu.vkPhysicalDevice.getSurfaceFormatsKHR(**vkSurface)}; - if (std::find(formats.begin(), formats.end(), vk::SurfaceFormatKHR{vkFormat, vk::ColorSpaceKHR::eSrgbNonlinear}) == formats.end()) - Logger::Warn("Surface doesn't support requested image format '{}' with colorspace '{}'", vk::to_string(vkFormat), vk::to_string(vk::ColorSpaceKHR::eSrgbNonlinear)); + if (std::find(formats.begin(), formats.end(), vk::SurfaceFormatKHR{vkFormat, vk::ColorSpaceKHR::eSrgbNonlinear}) == formats.end()) { + Logger::Debug("Surface doesn't support requested image format '{}' with colorspace '{}'", vk::to_string(vkFormat), vk::to_string(vk::ColorSpaceKHR::eSrgbNonlinear)); + underlyingFormat = format::R8G8B8A8Unorm; + } } constexpr vk::ImageUsageFlags presentUsage{vk::ImageUsageFlagBits::eColorAttachment | vk::ImageUsageFlagBits::eTransferSrc | vk::ImageUsageFlagBits::eTransferDst}; @@ -306,7 +309,7 @@ namespace skyline::gpu { vkSwapchain.emplace(gpu.vkDevice, vk::SwapchainCreateInfoKHR{ .surface = **vkSurface, .minImageCount = minImageCount, - .imageFormat = vkFormat, + .imageFormat = *underlyingFormat, .imageColorSpace = vk::ColorSpaceKHR::eSrgbNonlinear, .imageExtent = extent, .imageArrayLayers = 1, @@ -323,7 +326,7 @@ namespace skyline::gpu { for (size_t index{}; index < vkImages.size(); index++) { auto &slot{images[index]}; - slot = std::make_shared(*state.gpu, vkImages[index], extent, format, vk::ImageLayout::eUndefined, vk::ImageTiling::eOptimal, vk::ImageCreateFlags{}, presentUsage); + slot = std::make_shared(*state.gpu, vkImages[index], extent, underlyingFormat, vk::ImageLayout::eUndefined, vk::ImageTiling::eOptimal, vk::ImageCreateFlags{}, presentUsage); slot->TransitionLayout(vk::ImageLayout::ePresentSrcKHR); } for (size_t index{vkImages.size()}; index < MaxSwapchainImageCount; index++) diff --git a/app/src/main/cpp/skyline/gpu/texture/format.h b/app/src/main/cpp/skyline/gpu/texture/format.h index e37a9601..8b2ef3cb 100644 --- a/app/src/main/cpp/skyline/gpu/texture/format.h +++ b/app/src/main/cpp/skyline/gpu/texture/format.h @@ -84,12 +84,7 @@ namespace skyline::gpu::format { FORMAT_NORM_INT_FLOAT(R16G16, 32, eR16G16); FORMAT(B10G11R11Float, 32, eB10G11R11UfloatPack32); FORMAT_NORM_INT_SRGB(R8G8B8A8, 32, eR8G8B8A8); - FORMAT_NORM_INT_SRGB(B8G8R8A8, 32, eR8G8B8A8, .swizzleMapping = { - .r = vk::ComponentSwizzle::eB, - .g = vk::ComponentSwizzle::eG, - .b = vk::ComponentSwizzle::eR, - .a = vk::ComponentSwizzle::eA - }); // Used by SurfaceFlinger + FORMAT_NORM_INT_SRGB(B8G8R8A8, 32, eB8G8R8A8); FORMAT_SUFF_NORM_INT(A2B10G10R10, 32, eA2B10G10R10, Pack32); FORMAT_SUFF_NORM_INT_SRGB(A8B8G8R8, 32, eA8B8G8R8, Pack32); FORMAT(E5B9G9R9Float, 32, eE5B9G9R9UfloatPack32);