mirror of
https://github.com/MobileGL-Dev/MobileGL
synced 2026-11-29 20:52:16 +09:00
[Fix] (MG_Backend/DirectVulkan): resolve driver properties through the Vulkan instance
This commit is contained in:
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,
|
void ResolveOptionalDeviceExtensions(const Vector<VkExtensionProperties>& availableExtensions,
|
||||||
Vector<const char*>& inOutEnabledExtensions);
|
Vector<const char*>& inOutEnabledExtensions);
|
||||||
static Bool IsNecessaryDeviceExtensionSupported(VkPhysicalDevice device);
|
static Bool IsNecessaryDeviceExtensionSupported(VkPhysicalDevice device);
|
||||||
static Bool GetMoreCapablePhysicalDevice(VkPhysicalDevice newVkDevice, VkSurfaceKHR surface,
|
Bool GetMoreCapablePhysicalDevice(VkPhysicalDevice newVkDevice, VkSurfaceKHR surface,
|
||||||
const PhysicalDevice& compareWithDevice,
|
const PhysicalDevice& compareWithDevice, PhysicalDevice& outBetterDevice,
|
||||||
PhysicalDevice& outBetterDevice, Bool requireHardware);
|
Bool requireHardware);
|
||||||
static constexpr const char* s_validationLayerNames[] = {"VK_LAYER_KHRONOS_validation"};
|
static constexpr const char* s_validationLayerNames[] = {"VK_LAYER_KHRONOS_validation"};
|
||||||
// VK_KHR_image_format_list: lets MUTABLE_FORMAT images declare their exact view-format
|
// VK_KHR_image_format_list: lets MUTABLE_FORMAT images declare their exact view-format
|
||||||
// set so the driver can keep bandwidth compression (see CreateLogicalDeviceAndQueues).
|
// set so the driver can keep bandwidth compression (see CreateLogicalDeviceAndQueues).
|
||||||
|
|||||||
@@ -71,14 +71,18 @@ namespace MobileGL::MG_Backend::DirectVulkan {
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
namespace {
|
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) {
|
if (properties.apiVersion < VK_API_VERSION_1_1 || properties.deviceType == VK_PHYSICAL_DEVICE_TYPE_CPU) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (properties.apiVersion >= VK_API_VERSION_1_2) {
|
if (properties.apiVersion >= VK_API_VERSION_1_2) {
|
||||||
VkPhysicalDeviceDriverProperties driver{VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_DRIVER_PROPERTIES};
|
VkPhysicalDeviceDriverProperties driver{VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_DRIVER_PROPERTIES};
|
||||||
VkPhysicalDeviceProperties2 extended{VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_PROPERTIES_2, &driver};
|
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)
|
if (driver.driverID == VK_DRIVER_ID_GOOGLE_SWIFTSHADER || driver.driverID == VK_DRIVER_ID_MESA_LLVMPIPE)
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@@ -436,7 +440,7 @@ namespace MobileGL::MG_Backend::DirectVulkan {
|
|||||||
VK_VERSION_MINOR(apiVersion), VK_VERSION_PATCH(apiVersion),
|
VK_VERSION_MINOR(apiVersion), VK_VERSION_PATCH(apiVersion),
|
||||||
deviceTypeToStr(deviceProperties.deviceType));
|
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)
|
// Check device extensions (including swapchain extension)
|
||||||
Bool deviceExtSupported = IsNecessaryDeviceExtensionSupported(newVkDevice);
|
Bool deviceExtSupported = IsNecessaryDeviceExtensionSupported(newVkDevice);
|
||||||
|
|||||||
Reference in new issue
Block a user