Fallback to RGBA888 for unsupported swapchain formats as opposed to swizzle

This commit is contained in:
Billy Laws 2022-11-06 20:06:20 +00:00
parent e0bc0d3a97
commit c8fc8f84ec
2 changed files with 8 additions and 10 deletions

View File

@ -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); 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}; vk::Format vkFormat{*format};
texture::Format underlyingFormat{format};
if (swapchainFormat != format) { if (swapchainFormat != format) {
auto formats{gpu.vkPhysicalDevice.getSurfaceFormatsKHR(**vkSurface)}; auto formats{gpu.vkPhysicalDevice.getSurfaceFormatsKHR(**vkSurface)};
if (std::find(formats.begin(), formats.end(), vk::SurfaceFormatKHR{vkFormat, vk::ColorSpaceKHR::eSrgbNonlinear}) == formats.end()) 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)); 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}; 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{ vkSwapchain.emplace(gpu.vkDevice, vk::SwapchainCreateInfoKHR{
.surface = **vkSurface, .surface = **vkSurface,
.minImageCount = minImageCount, .minImageCount = minImageCount,
.imageFormat = vkFormat, .imageFormat = *underlyingFormat,
.imageColorSpace = vk::ColorSpaceKHR::eSrgbNonlinear, .imageColorSpace = vk::ColorSpaceKHR::eSrgbNonlinear,
.imageExtent = extent, .imageExtent = extent,
.imageArrayLayers = 1, .imageArrayLayers = 1,
@ -323,7 +326,7 @@ namespace skyline::gpu {
for (size_t index{}; index < vkImages.size(); index++) { for (size_t index{}; index < vkImages.size(); index++) {
auto &slot{images[index]}; auto &slot{images[index]};
slot = std::make_shared<Texture>(*state.gpu, vkImages[index], extent, format, vk::ImageLayout::eUndefined, vk::ImageTiling::eOptimal, vk::ImageCreateFlags{}, presentUsage); slot = std::make_shared<Texture>(*state.gpu, vkImages[index], extent, underlyingFormat, vk::ImageLayout::eUndefined, vk::ImageTiling::eOptimal, vk::ImageCreateFlags{}, presentUsage);
slot->TransitionLayout(vk::ImageLayout::ePresentSrcKHR); slot->TransitionLayout(vk::ImageLayout::ePresentSrcKHR);
} }
for (size_t index{vkImages.size()}; index < MaxSwapchainImageCount; index++) for (size_t index{vkImages.size()}; index < MaxSwapchainImageCount; index++)

View File

@ -84,12 +84,7 @@ namespace skyline::gpu::format {
FORMAT_NORM_INT_FLOAT(R16G16, 32, eR16G16); FORMAT_NORM_INT_FLOAT(R16G16, 32, eR16G16);
FORMAT(B10G11R11Float, 32, eB10G11R11UfloatPack32); FORMAT(B10G11R11Float, 32, eB10G11R11UfloatPack32);
FORMAT_NORM_INT_SRGB(R8G8B8A8, 32, eR8G8B8A8); FORMAT_NORM_INT_SRGB(R8G8B8A8, 32, eR8G8B8A8);
FORMAT_NORM_INT_SRGB(B8G8R8A8, 32, eR8G8B8A8, .swizzleMapping = { FORMAT_NORM_INT_SRGB(B8G8R8A8, 32, eB8G8R8A8);
.r = vk::ComponentSwizzle::eB,
.g = vk::ComponentSwizzle::eG,
.b = vk::ComponentSwizzle::eR,
.a = vk::ComponentSwizzle::eA
}); // Used by SurfaceFlinger
FORMAT_SUFF_NORM_INT(A2B10G10R10, 32, eA2B10G10R10, Pack32); FORMAT_SUFF_NORM_INT(A2B10G10R10, 32, eA2B10G10R10, Pack32);
FORMAT_SUFF_NORM_INT_SRGB(A8B8G8R8, 32, eA8B8G8R8, Pack32); FORMAT_SUFF_NORM_INT_SRGB(A8B8G8R8, 32, eA8B8G8R8, Pack32);
FORMAT(E5B9G9R9Float, 32, eE5B9G9R9UfloatPack32); FORMAT(E5B9G9R9Float, 32, eE5B9G9R9UfloatPack32);