mirror of
https://github.com/id-Software/DOOM-3-BFG.git
synced 2025-03-14 22:50:45 +00:00
Add support for Apple GPUs (e.g. M1) and fill-in gfxInfo data for Vulkan renderer
(cherry picked from commit 22f38cef0bbc3997c24990b5ee0f16c05e10de53)
This commit is contained in:
parent
a89dc048e8
commit
1b865406c0
3 changed files with 46 additions and 9 deletions
|
@ -206,6 +206,11 @@ static void R_CheckPortableExtensions()
|
|||
{
|
||||
glConfig.vendor = VENDOR_INTEL;
|
||||
}
|
||||
// SRS - Added support for Apple GPUs
|
||||
else if( idStr::Icmpn( glConfig.renderer_string, "Apple", 5 ) == 0 )
|
||||
{
|
||||
glConfig.vendor = VENDOR_APPLE;
|
||||
}
|
||||
|
||||
// RB: Mesa support
|
||||
if( idStr::Icmpn( glConfig.renderer_string, "Mesa", 4 ) == 0 || idStr::Icmpn( glConfig.renderer_string, "X.org", 5 ) == 0 || idStr::Icmpn( glConfig.renderer_string, "Gallium", 7 ) == 0 ||
|
||||
|
|
|
@ -83,7 +83,8 @@ enum graphicsVendor_t
|
|||
{
|
||||
VENDOR_NVIDIA,
|
||||
VENDOR_AMD,
|
||||
VENDOR_INTEL
|
||||
VENDOR_INTEL,
|
||||
VENDOR_APPLE // SRS - Added support for Apple GPUs
|
||||
};
|
||||
|
||||
// RB: similar to Q3A - allow separate codepaths between OpenGL 3.x, OpenGL ES versions
|
||||
|
|
|
@ -418,6 +418,11 @@ static void EnumeratePhysicalDevices()
|
|||
idLib::Printf( "Found device[%i] Vendor: AMD\n", i );
|
||||
break;
|
||||
|
||||
// SRS - Added support for Apple GPUs
|
||||
case 0x106B:
|
||||
idLib::Printf( "Found device[%i] Vendor: Apple\n", i );
|
||||
break;
|
||||
|
||||
default:
|
||||
idLib::Printf( "Found device[%i] Vendor: Unknown (0x%x)\n", i, gpu.props.vendorID );
|
||||
}
|
||||
|
@ -661,24 +666,49 @@ static void SelectPhysicalDevice()
|
|||
switch( gpu.props.vendorID )
|
||||
{
|
||||
case 0x8086:
|
||||
idLib::Printf( "Device[%i] : Vendor: Intel \n", i );
|
||||
idLib::Printf( "Device[%i] : Vendor: Intel\n", i );
|
||||
glConfig.vendor = VENDOR_INTEL;
|
||||
glConfig.vendor_string = "Intel Inc.";
|
||||
break;
|
||||
|
||||
case 0x10DE:
|
||||
idLib::Printf( "Device[%i] : Vendor: NVIDIA\n", i );
|
||||
glConfig.vendor = VENDOR_NVIDIA;
|
||||
glConfig.vendor_string = "NVIDIA Corporation";
|
||||
break;
|
||||
|
||||
case 0x1002:
|
||||
idLib::Printf( "Device[%i] : Vendor: AMD\n", i );
|
||||
glConfig.vendor = VENDOR_AMD;
|
||||
glConfig.vendor_string = "ATI Technologies Inc.";
|
||||
break;
|
||||
|
||||
// SRS - Added support for Apple GPUs
|
||||
case 0x106B:
|
||||
idLib::Printf( "Found device[%i] Vendor: Apple\n", i );
|
||||
glConfig.vendor = VENDOR_APPLE;
|
||||
glConfig.vendor_string = "Apple";
|
||||
break;
|
||||
|
||||
default:
|
||||
idLib::Printf( "Device[%i] : Vendor: Unknown (0x%x)\n", i, gpu.props.vendorID );
|
||||
}
|
||||
|
||||
glConfig.renderer_string = gpu.props.deviceName;
|
||||
|
||||
static char version_string[24];
|
||||
sprintf( version_string, "Vulkan %i.%i.%i", VK_API_VERSION_MAJOR(gpu.props.apiVersion), VK_API_VERSION_MINOR(gpu.props.apiVersion), VK_API_VERSION_PATCH(gpu.props.apiVersion) );
|
||||
glConfig.version_string = version_string;
|
||||
|
||||
static idStr extensions_string;
|
||||
extensions_string.Clear();
|
||||
for( int i = 0; i < gpu.extensionProps.Num(); i++ )
|
||||
{
|
||||
extensions_string.Append( gpu.extensionProps[i].extensionName );
|
||||
extensions_string.Append( ' ' );
|
||||
}
|
||||
glConfig.extensions_string = extensions_string.c_str();
|
||||
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
@ -1990,7 +2020,14 @@ void idRenderBackend::GL_StartFrame()
|
|||
{
|
||||
vkGetQueryPoolResults( vkcontext.device, queryPool, MRB_GPU_TIME, numQueries,
|
||||
results.ByteSize(), results.Ptr(), sizeof( uint64 ), VK_QUERY_RESULT_64_BIT | VK_QUERY_RESULT_WAIT_BIT );
|
||||
|
||||
#if defined(__APPLE__)
|
||||
// SRS - When using Metal-derived timestamps on OSX, update timestampPeriod every frame based on ongoing calibration within MoltenVK
|
||||
// Only need to do this for non-Apple GPUs, for Apple GPUs timestampPeriod = 1 and ongoing calibration within MoltenVK is skipped
|
||||
if( vkcontext.gpu->props.vendorID != 0x106B )
|
||||
{
|
||||
vkGetPhysicalDeviceProperties( vkcontext.gpu->device, &vkcontext.gpu->props );
|
||||
}
|
||||
#endif
|
||||
const uint64 gpuStart = results[ assignedIndex[ MRB_GPU_TIME * 2 + 0 ] ];
|
||||
const uint64 gpuEnd = results[ assignedIndex[ MRB_GPU_TIME * 2 + 1 ] ];
|
||||
const uint64 tick = ( 1000 * 1000 * 1000 ) / vkcontext.gpu->props.limits.timestampPeriod;
|
||||
|
@ -2000,7 +2037,6 @@ void idRenderBackend::GL_StartFrame()
|
|||
{
|
||||
const uint64 gpuStart = results[ assignedIndex[ MRB_FILL_DEPTH_BUFFER * 2 + 0 ] ];
|
||||
const uint64 gpuEnd = results[ assignedIndex[ MRB_FILL_DEPTH_BUFFER * 2 + 1 ] ];
|
||||
const uint64 tick = ( 1000 * 1000 * 1000 ) / vkcontext.gpu->props.limits.timestampPeriod;
|
||||
pc.gpuDepthMicroSec = ( ( gpuEnd - gpuStart ) * 1000 * 1000 ) / tick;
|
||||
}
|
||||
|
||||
|
@ -2008,7 +2044,6 @@ void idRenderBackend::GL_StartFrame()
|
|||
{
|
||||
const uint64 gpuStart = results[ assignedIndex[ MRB_SSAO_PASS * 2 + 0 ] ];
|
||||
const uint64 gpuEnd = results[ assignedIndex[ MRB_SSAO_PASS * 2 + 1 ] ];
|
||||
const uint64 tick = ( 1000 * 1000 * 1000 ) / vkcontext.gpu->props.limits.timestampPeriod;
|
||||
pc.gpuScreenSpaceAmbientOcclusionMicroSec = ( ( gpuEnd - gpuStart ) * 1000 * 1000 ) / tick;
|
||||
}
|
||||
|
||||
|
@ -2016,7 +2051,6 @@ void idRenderBackend::GL_StartFrame()
|
|||
{
|
||||
const uint64 gpuStart = results[ assignedIndex[ MRB_AMBIENT_PASS * 2 + 0 ] ];
|
||||
const uint64 gpuEnd = results[ assignedIndex[ MRB_AMBIENT_PASS * 2 + 1 ] ];
|
||||
const uint64 tick = ( 1000 * 1000 * 1000 ) / vkcontext.gpu->props.limits.timestampPeriod;
|
||||
pc.gpuAmbientPassMicroSec = ( ( gpuEnd - gpuStart ) * 1000 * 1000 ) / tick;
|
||||
}
|
||||
|
||||
|
@ -2024,7 +2058,6 @@ void idRenderBackend::GL_StartFrame()
|
|||
{
|
||||
const uint64 gpuStart = results[ assignedIndex[ MRB_DRAW_INTERACTIONS * 2 + 0 ] ];
|
||||
const uint64 gpuEnd = results[ assignedIndex[ MRB_DRAW_INTERACTIONS * 2 + 1 ] ];
|
||||
const uint64 tick = ( 1000 * 1000 * 1000 ) / vkcontext.gpu->props.limits.timestampPeriod;
|
||||
pc.gpuInteractionsMicroSec = ( ( gpuEnd - gpuStart ) * 1000 * 1000 ) / tick;
|
||||
}
|
||||
|
||||
|
@ -2032,7 +2065,6 @@ void idRenderBackend::GL_StartFrame()
|
|||
{
|
||||
const uint64 gpuStart = results[ assignedIndex[ MRB_DRAW_SHADER_PASSES * 2 + 0 ] ];
|
||||
const uint64 gpuEnd = results[ assignedIndex[ MRB_DRAW_SHADER_PASSES * 2 + 1 ] ];
|
||||
const uint64 tick = ( 1000 * 1000 * 1000 ) / vkcontext.gpu->props.limits.timestampPeriod;
|
||||
pc.gpuShaderPassMicroSec = ( ( gpuEnd - gpuStart ) * 1000 * 1000 ) / tick;
|
||||
}
|
||||
|
||||
|
@ -2040,7 +2072,6 @@ void idRenderBackend::GL_StartFrame()
|
|||
{
|
||||
const uint64 gpuStart = results[ assignedIndex[ MRB_POSTPROCESS * 2 + 0 ] ];
|
||||
const uint64 gpuEnd = results[ assignedIndex[ MRB_POSTPROCESS * 2 + 1 ] ];
|
||||
const uint64 tick = ( 1000 * 1000 * 1000 ) / vkcontext.gpu->props.limits.timestampPeriod;
|
||||
pc.gpuPostProcessingMicroSec = ( ( gpuEnd - gpuStart ) * 1000 * 1000 ) / tick;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue