[Fix] (MG_Backend/DirectVulkan): resolve driver properties through the Vulkan instance

This commit is contained in:
BZLZHH committed 2026-11-29 09:43:37 +08:00
1 parent 6ac2bb682a
commit 9560cca571
2 files changed
+10 -6

No files matched your search

@@ -1774,9 +1774,9 @@ namespace MobileGL::MG_Backend::DirectVulkan {
void ResolveOptionalDeviceExtensions(const Vector<VkExtensionProperties>& availableExtensions,
Vector<const char*>& inOutEnabledExtensions);
static Bool IsNecessaryDeviceExtensionSupported(VkPhysicalDevice device);
static Bool GetMoreCapablePhysicalDevice(VkPhysicalDevice newVkDevice, VkSurfaceKHR surface,
const PhysicalDevice& compareWithDevice,
PhysicalDevice& outBetterDevice, Bool requireHardware);
Bool GetMoreCapablePhysicalDevice(VkPhysicalDevice newVkDevice, VkSurfaceKHR surface,
const PhysicalDevice& compareWithDevice, PhysicalDevice& outBetterDevice,
Bool requireHardware);
static constexpr const char* s_validationLayerNames[] = {"VK_LAYER_KHRONOS_validation"};
// VK_KHR_image_format_list: lets MUTABLE_FORMAT images declare their exact view-format
// set so the driver can keep bandwidth compression (see CreateLogicalDeviceAndQueues).
@@ -71,14 +71,18 @@ namespace MobileGL::MG_Backend::DirectVulkan {
#endif
namespace {
Bool IsHardwareDevice(VkPhysicalDevice device, const VkPhysicalDeviceProperties& properties) {
Bool IsHardwareDevice(VkInstance instance, VkPhysicalDevice device,
const VkPhysicalDeviceProperties& properties) {
if (properties.apiVersion < VK_API_VERSION_1_1 || properties.deviceType == VK_PHYSICAL_DEVICE_TYPE_CPU) {
return false;
}
if (properties.apiVersion >= VK_API_VERSION_1_2) {
VkPhysicalDeviceDriverProperties driver{VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_DRIVER_PROPERTIES};
VkPhysicalDeviceProperties2 extended{VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_PROPERTIES_2, &driver};
vkGetPhysicalDeviceProperties2(device, &extended);
const auto getProperties2 = reinterpret_cast<PFN_vkGetPhysicalDeviceProperties2>(
vkGetInstanceProcAddr(instance, "vkGetPhysicalDeviceProperties2"));
if (!getProperties2) return false;
getProperties2(device, &extended);
if (driver.driverID == VK_DRIVER_ID_GOOGLE_SWIFTSHADER || driver.driverID == VK_DRIVER_ID_MESA_LLVMPIPE)
return false;
}
@@ -436,7 +440,7 @@ namespace MobileGL::MG_Backend::DirectVulkan {
VK_VERSION_MINOR(apiVersion), VK_VERSION_PATCH(apiVersion),
deviceTypeToStr(deviceProperties.deviceType));
if (requireHardware && !IsHardwareDevice(newVkDevice, deviceProperties)) return false;
if (requireHardware && !IsHardwareDevice(m_instance, newVkDevice, deviceProperties)) return false;
// Check device extensions (including swapchain extension)
Bool deviceExtSupported = IsNecessaryDeviceExtensionSupported(newVkDevice);