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:
parent
2984695265
commit
7712e46d64
|
@ -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) {
|
switch (format) {
|
||||||
case PixelFormat::A1B5G5R5_UNORM:
|
case PixelFormat::A1B5G5R5_UNORM:
|
||||||
return true;
|
return true;
|
||||||
|
case PixelFormat::B5G6R5_UNORM:
|
||||||
|
return emulate_bgr565;
|
||||||
default:
|
default:
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -1488,7 +1490,7 @@ ImageView::ImageView(TextureCacheRuntime& runtime, const VideoCommon::ImageViewI
|
||||||
};
|
};
|
||||||
if (!info.IsRenderTarget()) {
|
if (!info.IsRenderTarget()) {
|
||||||
swizzle = info.Swizzle();
|
swizzle = info.Swizzle();
|
||||||
if (IsFormatFlipped(format)) {
|
if (IsFormatFlipped(format, device->MustEmulateBGR565())) {
|
||||||
std::ranges::transform(swizzle, swizzle.begin(), SwapBlueRed);
|
std::ranges::transform(swizzle, swizzle.begin(), SwapBlueRed);
|
||||||
}
|
}
|
||||||
if ((aspect_mask & (VK_IMAGE_ASPECT_DEPTH_BIT | VK_IMAGE_ASPECT_STENCIL_BIT)) != 0) {
|
if ((aspect_mask & (VK_IMAGE_ASPECT_DEPTH_BIT | VK_IMAGE_ASPECT_STENCIL_BIT)) != 0) {
|
||||||
|
|
|
@ -39,6 +39,11 @@ constexpr std::array DEPTH16_UNORM_STENCIL8_UINT{
|
||||||
VK_FORMAT_D32_SFLOAT_S8_UINT,
|
VK_FORMAT_D32_SFLOAT_S8_UINT,
|
||||||
VK_FORMAT_UNDEFINED,
|
VK_FORMAT_UNDEFINED,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
constexpr std::array B5G6R5_UNORM_PACK16{
|
||||||
|
VK_FORMAT_R5G6B5_UNORM_PACK16,
|
||||||
|
VK_FORMAT_UNDEFINED,
|
||||||
|
};
|
||||||
} // namespace Alternatives
|
} // namespace Alternatives
|
||||||
|
|
||||||
enum class NvidiaArchitecture {
|
enum class NvidiaArchitecture {
|
||||||
|
@ -87,6 +92,8 @@ constexpr const VkFormat* GetFormatAlternatives(VkFormat format) {
|
||||||
return Alternatives::DEPTH24_UNORM_STENCIL8_UINT.data();
|
return Alternatives::DEPTH24_UNORM_STENCIL8_UINT.data();
|
||||||
case VK_FORMAT_D16_UNORM_S8_UINT:
|
case VK_FORMAT_D16_UNORM_S8_UINT:
|
||||||
return Alternatives::DEPTH16_UNORM_STENCIL8_UINT.data();
|
return Alternatives::DEPTH16_UNORM_STENCIL8_UINT.data();
|
||||||
|
case VK_FORMAT_B5G6R5_UNORM_PACK16:
|
||||||
|
return Alternatives::B5G6R5_UNORM_PACK16.data();
|
||||||
default:
|
default:
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
@ -639,6 +646,7 @@ Device::Device(VkInstance instance_, vk::PhysicalDevice physical_, VkSurfaceKHR
|
||||||
}
|
}
|
||||||
|
|
||||||
const bool is_intel_windows = driver_id == VK_DRIVER_ID_INTEL_PROPRIETARY_WINDOWS;
|
const bool is_intel_windows = driver_id == VK_DRIVER_ID_INTEL_PROPRIETARY_WINDOWS;
|
||||||
|
const bool is_intel_anv = driver_id == VK_DRIVER_ID_INTEL_OPEN_SOURCE_MESA;
|
||||||
if (ext_vertex_input_dynamic_state && is_intel_windows) {
|
if (ext_vertex_input_dynamic_state && is_intel_windows) {
|
||||||
LOG_WARNING(Render_Vulkan, "Blacklisting Intel for VK_EXT_vertex_input_dynamic_state");
|
LOG_WARNING(Render_Vulkan, "Blacklisting Intel for VK_EXT_vertex_input_dynamic_state");
|
||||||
ext_vertex_input_dynamic_state = false;
|
ext_vertex_input_dynamic_state = false;
|
||||||
|
@ -652,6 +660,10 @@ Device::Device(VkInstance instance_, vk::PhysicalDevice physical_, VkSurfaceKHR
|
||||||
LOG_WARNING(Render_Vulkan, "Intel proprietary drivers do not support MSAA image blits");
|
LOG_WARNING(Render_Vulkan, "Intel proprietary drivers do not support MSAA image blits");
|
||||||
cant_blit_msaa = true;
|
cant_blit_msaa = true;
|
||||||
}
|
}
|
||||||
|
if (is_intel_anv) {
|
||||||
|
LOG_WARNING(Render_Vulkan, "ANV driver does not support native BGR format");
|
||||||
|
must_emulate_bgr565 = true;
|
||||||
|
}
|
||||||
|
|
||||||
supports_d24_depth =
|
supports_d24_depth =
|
||||||
IsFormatSupported(VK_FORMAT_D24_UNORM_S8_UINT,
|
IsFormatSupported(VK_FORMAT_D24_UNORM_S8_UINT,
|
||||||
|
|
|
@ -354,6 +354,10 @@ public:
|
||||||
return cant_blit_msaa;
|
return cant_blit_msaa;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool MustEmulateBGR565() const {
|
||||||
|
return must_emulate_bgr565;
|
||||||
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
/// Checks if the physical device is suitable.
|
/// Checks if the physical device is suitable.
|
||||||
void CheckSuitability(bool requires_swapchain) const;
|
void CheckSuitability(bool requires_swapchain) const;
|
||||||
|
@ -448,6 +452,7 @@ private:
|
||||||
bool has_nsight_graphics{}; ///< Has Nsight Graphics attached
|
bool has_nsight_graphics{}; ///< Has Nsight Graphics attached
|
||||||
bool supports_d24_depth{}; ///< Supports D24 depth buffers.
|
bool supports_d24_depth{}; ///< Supports D24 depth buffers.
|
||||||
bool cant_blit_msaa{}; ///< Does not support MSAA<->MSAA blitting.
|
bool cant_blit_msaa{}; ///< Does not support MSAA<->MSAA blitting.
|
||||||
|
bool must_emulate_bgr565{}; ///< Emulates BGR565 by swizzling RGB565 format.
|
||||||
|
|
||||||
// Telemetry parameters
|
// Telemetry parameters
|
||||||
std::string vendor_name; ///< Device's driver name.
|
std::string vendor_name; ///< Device's driver name.
|
||||||
|
|
Reference in New Issue