diff options
| author | Stenzek <stenzek@gmail.com> | 2017-09-19 21:11:33 +1000 |
|---|---|---|
| committer | Stenzek <stenzek@gmail.com> | 2018-03-14 02:48:53 +1000 |
| commit | db810956ec74b094c006cddf6854d626e0991221 (patch) | |
| tree | 13f8e424f58b29b4f90c01444a3fe924e2badaad /Source/Core/VideoBackends/Vulkan/VulkanContext.cpp | |
| parent | f7ff634e4fa8353b968c310a94958741e8bb61cd (diff) | |
Vulkan: Provide a more accurate method of detecting drivers/vendors
This is needed to differentiate between the open-source Mesa drivers and
their binary counterparts for Intel and AMD.
Diffstat (limited to 'Source/Core/VideoBackends/Vulkan/VulkanContext.cpp')
| -rw-r--r-- | Source/Core/VideoBackends/Vulkan/VulkanContext.cpp | 84 |
1 files changed, 79 insertions, 5 deletions
diff --git a/Source/Core/VideoBackends/Vulkan/VulkanContext.cpp b/Source/Core/VideoBackends/Vulkan/VulkanContext.cpp index f9c254a04d..495bdaf519 100644 --- a/Source/Core/VideoBackends/Vulkan/VulkanContext.cpp +++ b/Source/Core/VideoBackends/Vulkan/VulkanContext.cpp @@ -352,11 +352,7 @@ std::unique_ptr<VulkanContext> VulkanContext::Create(VkInstance instance, VkPhys std::unique_ptr<VulkanContext> context = std::make_unique<VulkanContext>(instance, gpu); // Initialize DriverDetails so that we can check for bugs to disable features if needed. - DriverDetails::Init(DriverDetails::API_VULKAN, - DriverDetails::TranslatePCIVendorID(context->m_device_properties.vendorID), - DriverDetails::DRIVER_UNKNOWN, - static_cast<double>(context->m_device_properties.driverVersion), - DriverDetails::Family::UNKNOWN); + context->InitDriverDetails(); // Enable debug reports if the "Host GPU" log category is enabled. if (enable_debug_reports) @@ -761,4 +757,82 @@ u32 VulkanContext::GetReadbackMemoryType(u32 bits, bool* is_coherent, bool* is_c return type_index; } + +void VulkanContext::InitDriverDetails() +{ + DriverDetails::Vendor vendor; + DriverDetails::Driver driver; + + // String comparisons aren't ideal, but there doesn't seem to be any other way to tell + // which vendor a driver is for. These names are based on the reports submitted to + // vulkan.gpuinfo.org, as of 19/09/2017. + std::string device_name = m_device_properties.deviceName; + u32 vendor_id = m_device_properties.vendorID; + if (vendor_id == 0x10DE) + { + // Currently, there is only the official NV binary driver. + // "NVIDIA" does not appear in the device name. + vendor = DriverDetails::VENDOR_NVIDIA; + driver = DriverDetails::DRIVER_NVIDIA; + } + else if (vendor_id == 0x1002 || vendor_id == 0x1022 || + device_name.find("AMD") != std::string::npos) + { + // RADV always advertises its name in the device string. + // If not RADV, assume the AMD binary driver. + if (device_name.find("RADV") != std::string::npos) + { + vendor = DriverDetails::VENDOR_MESA; + driver = DriverDetails::DRIVER_R600; + } + else + { + vendor = DriverDetails::VENDOR_ATI; + driver = DriverDetails::DRIVER_ATI; + } + } + else if (vendor_id == 0x8086 || vendor_id == 0x8087 || + device_name.find("Intel") != std::string::npos) + { +// Apart from the driver version, Intel does not appear to provide a way to +// differentiate between anv and the binary driver (Skylake+). Assume to be +// using anv if we not running on Windows. +#ifdef WIN32 + vendor = DriverDetails::VENDOR_INTEL; + driver = DriverDetails::DRIVER_INTEL; +#else + vendor = DriverDetails::VENDOR_MESA; + driver = DriverDetails::DRIVER_I965; +#endif + } + else if (vendor_id == 0x5143 || device_name.find("Adreno") != std::string::npos) + { + // Currently only the Qualcomm binary driver exists for Adreno. + vendor = DriverDetails::VENDOR_QUALCOMM; + driver = DriverDetails::DRIVER_QUALCOMM; + } + else if (vendor_id == 0x13B6 || device_name.find("Mali") != std::string::npos) + { + // Currently only the ARM binary driver exists for Mali. + vendor = DriverDetails::VENDOR_ARM; + driver = DriverDetails::DRIVER_ARM; + } + else if (vendor_id == 0x1010 || device_name.find("PowerVR") != std::string::npos) + { + // Currently only the binary driver exists for PowerVR. + vendor = DriverDetails::VENDOR_IMGTEC; + driver = DriverDetails::DRIVER_IMGTEC; + } + else + { + WARN_LOG(VIDEO, "Unknown Vulkan driver vendor, please report it to us."); + WARN_LOG(VIDEO, "Vendor ID: 0x%X, Device Name: %s", vendor_id, device_name.c_str()); + vendor = DriverDetails::VENDOR_UNKNOWN; + driver = DriverDetails::DRIVER_UNKNOWN; + } + + DriverDetails::Init(DriverDetails::API_VULKAN, vendor, driver, + static_cast<double>(m_device_properties.driverVersion), + DriverDetails::Family::UNKNOWN); +} } |
