Add basic driver version parsing for Vulkan

This commit is contained in:
Jupeyy 2022-05-14 14:06:06 +02:00
parent 4268f891fc
commit 77196ed571

View file

@ -3521,6 +3521,41 @@ public:
return STWGraphicGPU::ETWGraphicsGPUType::GRAPHICS_GPU_TYPE_CPU;
}
// from: https://github.com/SaschaWillems/vulkan.gpuinfo.org/blob/5c3986798afc39d736b825bf8a5fbf92b8d9ed49/includes/functions.php#L364
const char *GetDriverVerson(char (&aBuff)[256], uint32_t DriverVersion, uint32_t VendorID)
{
// NVIDIA
if(VendorID == 4318)
{
str_format(aBuff, std::size(aBuff), "%d.%d.%d.%d",
(DriverVersion >> 22) & 0x3ff,
(DriverVersion >> 14) & 0x0ff,
(DriverVersion >> 6) & 0x0ff,
(DriverVersion)&0x003f);
}
#ifdef CONF_FAMILY_WINDOWS
// windows only
else if(VendorID == 0x8086)
{
str_format(aBuff, std::size(aBuff),
"%d.%d",
(DriverVersion >> 14),
(DriverVersion)&0x3fff);
}
#endif
else
{
// Use Vulkan version conventions if vendor mapping is not available
str_format(aBuff, std::size(aBuff),
"%d.%d.%d",
(DriverVersion >> 22),
(DriverVersion >> 12) & 0x3ff,
DriverVersion & 0xfff);
}
return aBuff;
}
bool SelectGPU(char *pRendererName, char *pVendorName, char *pVersionName)
{
uint32_t DevicesCount = 0;
@ -3621,8 +3656,10 @@ public:
pVendorNameStr = "unknown";
break;
}
char aBuff[256];
str_copy(pVendorName, pVendorNameStr, gs_GPUInfoStringSize);
str_format(pVersionName, gs_GPUInfoStringSize, "Vulkan %d.%d.%d", DevAPIMajor, DevAPIMinor, DevAPIPatch);
str_format(pVersionName, gs_GPUInfoStringSize, "Vulkan %d.%d.%d (driver: %s)", DevAPIMajor, DevAPIMinor, DevAPIPatch, GetDriverVerson(aBuff, DeviceProp.driverVersion, DeviceProp.vendorID));
// get important device limits
m_NonCoherentMemAlignment = DeviceProp.limits.nonCoherentAtomSize;