vulkan_device: fix missing format in ANV

Currently Mesa's ANV driver does not support
VK_FORMAT_B5G6R5_UNORM_PACK16, implement an alternative for it.
This commit is contained in:
voidanix 2022-02-18 09:44:34 +01:00
parent 2984695265
commit 7712e46d64
No known key found for this signature in database
GPG key ID: 7BFED1BB9BD923C6
3 changed files with 21 additions and 2 deletions

View file

@ -554,10 +554,12 @@ void CopyBufferToImage(vk::CommandBuffer cmdbuf, VkBuffer src_buffer, VkImage im
};
}
[[nodiscard]] bool IsFormatFlipped(PixelFormat format) {
[[nodiscard]] bool IsFormatFlipped(PixelFormat format, bool emulate_bgr565) {
switch (format) {
case PixelFormat::A1B5G5R5_UNORM:
return true;
case PixelFormat::B5G6R5_UNORM:
return emulate_bgr565;
default:
return false;
}
@ -1488,7 +1490,7 @@ ImageView::ImageView(TextureCacheRuntime& runtime, const VideoCommon::ImageViewI
};
if (!info.IsRenderTarget()) {
swizzle = info.Swizzle();
if (IsFormatFlipped(format)) {
if (IsFormatFlipped(format, device->MustEmulateBGR565())) {
std::ranges::transform(swizzle, swizzle.begin(), SwapBlueRed);
}
if ((aspect_mask & (VK_IMAGE_ASPECT_DEPTH_BIT | VK_IMAGE_ASPECT_STENCIL_BIT)) != 0) {