Check API version before adding GPU to GPU list

Signed-off-by: Jupeyy <jupjopjap@gmail.com>
This commit is contained in:
Jupeyy 2024-07-21 13:15:42 +02:00
parent cb9521d29f
commit e96275943b
No known key found for this signature in database

View file

@ -3744,36 +3744,41 @@ public:
STWGraphicGpu::ETWGraphicsGpuType GPUType = VKGPUTypeToGraphicsGpuType(DeviceProp.deviceType); STWGraphicGpu::ETWGraphicsGpuType GPUType = VKGPUTypeToGraphicsGpuType(DeviceProp.deviceType);
STWGraphicGpu::STWGraphicGpuItem NewGpu;
str_copy(NewGpu.m_aName, DeviceProp.deviceName);
NewGpu.m_GpuType = GPUType;
m_pGpuList->m_vGpus.push_back(NewGpu);
Index++;
int DevAPIMajor = (int)VK_API_VERSION_MAJOR(DeviceProp.apiVersion); int DevAPIMajor = (int)VK_API_VERSION_MAJOR(DeviceProp.apiVersion);
int DevAPIMinor = (int)VK_API_VERSION_MINOR(DeviceProp.apiVersion); int DevAPIMinor = (int)VK_API_VERSION_MINOR(DeviceProp.apiVersion);
if(GPUType < AutoGpuType && (DevAPIMajor > gs_BackendVulkanMajor || (DevAPIMajor == gs_BackendVulkanMajor && DevAPIMinor >= gs_BackendVulkanMinor))) if(DevAPIMajor > gs_BackendVulkanMajor || (DevAPIMajor == gs_BackendVulkanMajor && DevAPIMinor >= gs_BackendVulkanMinor))
{ {
str_copy(m_pGpuList->m_AutoGpu.m_aName, DeviceProp.deviceName); STWGraphicGpu::STWGraphicGpuItem NewGpu;
m_pGpuList->m_AutoGpu.m_GpuType = GPUType; str_copy(NewGpu.m_aName, DeviceProp.deviceName);
NewGpu.m_GpuType = GPUType;
m_pGpuList->m_vGpus.push_back(NewGpu);
AutoGpuType = GPUType; if(GPUType < AutoGpuType)
} {
str_copy(m_pGpuList->m_AutoGpu.m_aName, DeviceProp.deviceName);
m_pGpuList->m_AutoGpu.m_GpuType = GPUType;
if(((IsAutoGpu && (FoundGpuType > STWGraphicGpu::ETWGraphicsGpuType::GRAPHICS_GPU_TYPE_INTEGRATED && GPUType < FoundGpuType)) || str_comp(DeviceProp.deviceName, g_Config.m_GfxGpuName) == 0) && (DevAPIMajor > gs_BackendVulkanMajor || (DevAPIMajor == gs_BackendVulkanMajor && DevAPIMinor >= gs_BackendVulkanMinor))) AutoGpuType = GPUType;
{ }
FoundDeviceIndex = Index;
FoundGpuType = GPUType; if(((IsAutoGpu && (FoundGpuType > STWGraphicGpu::ETWGraphicsGpuType::GRAPHICS_GPU_TYPE_INTEGRATED && GPUType < FoundGpuType)) || str_comp(DeviceProp.deviceName, g_Config.m_GfxGpuName) == 0) && (DevAPIMajor > gs_BackendVulkanMajor || (DevAPIMajor == gs_BackendVulkanMajor && DevAPIMinor >= gs_BackendVulkanMinor)))
{
FoundDeviceIndex = Index;
FoundGpuType = GPUType;
}
} }
Index++;
} }
if(FoundDeviceIndex == 0) if(m_pGpuList->m_vGpus.empty())
FoundDeviceIndex = 1; {
SetWarning(EGfxWarningType::GFX_WARNING_TYPE_INIT_FAILED_MISSING_INTEGRATED_GPU_DRIVER, "No devices with required vulkan version found.");
return false;
}
{ {
auto &DeviceProp = vDevicePropList[FoundDeviceIndex - 1]; auto &DeviceProp = vDevicePropList[FoundDeviceIndex];
int DevAPIMajor = (int)VK_API_VERSION_MAJOR(DeviceProp.apiVersion); int DevAPIMajor = (int)VK_API_VERSION_MAJOR(DeviceProp.apiVersion);
int DevAPIMinor = (int)VK_API_VERSION_MINOR(DeviceProp.apiVersion); int DevAPIMinor = (int)VK_API_VERSION_MINOR(DeviceProp.apiVersion);
@ -3833,7 +3838,7 @@ public:
} }
} }
VkPhysicalDevice CurDevice = vDeviceList[FoundDeviceIndex - 1]; VkPhysicalDevice CurDevice = vDeviceList[FoundDeviceIndex];
uint32_t FamQueueCount = 0; uint32_t FamQueueCount = 0;
vkGetPhysicalDeviceQueueFamilyProperties(CurDevice, &FamQueueCount, nullptr); vkGetPhysicalDeviceQueueFamilyProperties(CurDevice, &FamQueueCount, nullptr);