88#include <cfgmgr32.h>
99#include <ntddvdeo.h>
1010#include <devpkey.h>
11+ #include "util/windows/nt.h"
1112
1213#define FF_EMPTY_GUID_STR L"{00000000-0000-0000-0000-000000000000}"
1314enum { FF_GUID_STRLEN = sizeof (FF_EMPTY_GUID_STR ) / sizeof (wchar_t ) - 1 };
@@ -95,20 +96,8 @@ const char* ffDetectGPUImpl(FF_MAYBE_UNUSED const FFGPUOptions* options, FFlist*
9596 if (gpu -> vendor .chars == FF_GPU_VENDOR_NAME_INTEL )
9697 gpu -> type = gpu -> deviceId == 20 ? FF_GPU_TYPE_INTEGRATED : FF_GPU_TYPE_DISCRETE ;
9798
98- uint64_t dedicatedVideoMemory = 0 ;
99- if (ffRegReadUint64 (hDirectxKey , L"DedicatedVideoMemory" , & dedicatedVideoMemory , NULL ))
100- {
101- if (gpu -> type == FF_GPU_TYPE_UNKNOWN )
102- gpu -> type = dedicatedVideoMemory >= 1024 * 1024 * 1024 ? FF_GPU_TYPE_DISCRETE : FF_GPU_TYPE_INTEGRATED ;
103- }
104-
105- uint64_t dedicatedSystemMemory , sharedSystemMemory ;
106- if (ffRegReadUint64 (hDirectxKey , L"DedicatedSystemMemory" , & dedicatedSystemMemory , NULL ) &&
107- ffRegReadUint64 (hDirectxKey , L"SharedSystemMemory" , & sharedSystemMemory , NULL ))
108- {
109- gpu -> dedicated .total = dedicatedVideoMemory + dedicatedSystemMemory ;
110- gpu -> shared .total = sharedSystemMemory ;
111- }
99+ ffRegReadUint64 (hDirectxKey , L"DedicatedVideoMemory" , & gpu -> dedicated .total , NULL );
100+ ffRegReadUint64 (hDirectxKey , L"DedicatedSystemMemory" , & gpu -> shared .total , NULL );
112101
113102 if (ffRegReadUint64 (hDirectxKey , L"AdapterLuid" , & adapterLuid , NULL ))
114103 {
@@ -135,6 +124,28 @@ const char* ffDetectGPUImpl(FF_MAYBE_UNUSED const FFGPUOptions* options, FFlist*
135124 }
136125 }
137126
127+ if (adapterLuid > 0 )
128+ {
129+ D3DKMT_OPENADAPTERFROMLUID openAdapterFromLuid = { .AdapterLuid = * (LUID * )& adapterLuid };
130+ if (NT_SUCCESS (D3DKMTOpenAdapterFromLuid (& openAdapterFromLuid )))
131+ {
132+ D3DKMT_ADAPTERTYPE adapterType = {};
133+ D3DKMT_QUERYADAPTERINFO queryAdapterInfo = {
134+ .hAdapter = openAdapterFromLuid .hAdapter ,
135+ .Type = KMTQAITYPE_ADAPTERTYPE ,
136+ .pPrivateDriverData = & adapterType ,
137+ .PrivateDriverDataSize = sizeof (adapterType ),
138+ };
139+ if (NT_SUCCESS (D3DKMTQueryAdapterInfo (& queryAdapterInfo )))
140+ {
141+ if (adapterType .HybridDiscrete )
142+ gpu -> type = FF_GPU_TYPE_DISCRETE ;
143+ else if (adapterType .HybridIntegrated )
144+ gpu -> type = FF_GPU_TYPE_INTEGRATED ;
145+ }
146+ }
147+ }
148+
138149 if (gpu -> vendor .length == 0 )
139150 {
140151 bufferLen = sizeof (buffer );
@@ -223,6 +234,8 @@ const char* ffDetectGPUImpl(FF_MAYBE_UNUSED const FFGPUOptions* options, FFlist*
223234 if (CM_Get_DevNode_Registry_PropertyW (devInst , CM_DRP_DEVICEDESC , NULL , buffer , & bufferLen , 0 ) == CR_SUCCESS )
224235 ffStrbufSetWS (& gpu -> name , buffer );
225236 }
237+ if (gpu -> type == FF_GPU_TYPE_UNKNOWN && gpu -> dedicated .total != FF_GPU_VMEM_SIZE_UNSET )
238+ gpu -> type = gpu -> dedicated .total >= 1024 * 1024 * 1024 ? FF_GPU_TYPE_DISCRETE : FF_GPU_TYPE_INTEGRATED ;
226239 }
227240
228241 return NULL ;
0 commit comments