From 106ad597db7e83cfe85ba19f6298bad9eb7ce96d Mon Sep 17 00:00:00 2001 From: Billy Laws Date: Sat, 4 Jun 2022 16:49:26 +0100 Subject: [PATCH] Support BGRA8888 surfaceflinger format A swizzle is applied to R8G8B8A8 to transform it to BGRA since BGRA isn't a commonly supported swapchain format on Android. --- app/src/main/cpp/skyline/gpu/texture/format.h | 5 ++++- .../cpp/skyline/services/hosbinder/GraphicBufferProducer.cpp | 5 +++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/app/src/main/cpp/skyline/gpu/texture/format.h b/app/src/main/cpp/skyline/gpu/texture/format.h index 622132ac..2776b79d 100644 --- a/app/src/main/cpp/skyline/gpu/texture/format.h +++ b/app/src/main/cpp/skyline/gpu/texture/format.h @@ -84,7 +84,10 @@ 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, eB8G8R8A8); + FORMAT_NORM_INT_SRGB(B8G8R8A8, 32, eR8G8B8A8, .swizzleMapping = { + .r = vk::ComponentSwizzle::eB, + .b = vk::ComponentSwizzle::eR + }); // Used by SurfaceFlinger FORMAT_SUFF_NORM_INT(A2B10G10R10, 32, eA2B10G10R10, Pack32); FORMAT_SUFF_NORM_INT_SRGB(A8B8G8R8, 32, eA8B8G8R8, Pack32); FORMAT(E5B9G9R9Float, 32, eE5B9G9R9UfloatPack32); diff --git a/app/src/main/cpp/skyline/services/hosbinder/GraphicBufferProducer.cpp b/app/src/main/cpp/skyline/services/hosbinder/GraphicBufferProducer.cpp index f3068718..c9ead3cd 100644 --- a/app/src/main/cpp/skyline/services/hosbinder/GraphicBufferProducer.cpp +++ b/app/src/main/cpp/skyline/services/hosbinder/GraphicBufferProducer.cpp @@ -306,11 +306,12 @@ namespace skyline::service::hosbinder { case AndroidPixelFormat::RGBX8888: format = gpu::format::R8G8B8A8Unorm; break; - + case AndroidPixelFormat::BGRA8888: + format = gpu::format::B8G8R8A8Unorm; + break; case AndroidPixelFormat::RGB565: format = gpu::format::R5G6B5Unorm; break; - default: throw exception("Unknown format in buffer: '{}' ({})", ToString(handle.format), static_cast(handle.format)); }