Skip to content

Instantly share code, notes, and snippets.

@elsamuko
Created March 4, 2020 12:17
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save elsamuko/d3049d52ca235112c99ac3ee30282846 to your computer and use it in GitHub Desktop.
Save elsamuko/d3049d52ca235112c99ac3ee30282846 to your computer and use it in GitHub Desktop.
Print Direct3D information
#!/usr/bin/env cppsh
#include <cstdio>
#include <windows.h>
#include <d3d9.h>
//! \sa https://github.com/qt/qtbase/blob/dev/src/plugins/platforms/windows/qwindowsopengltester.cpp#L124
void detect() {
typedef IDirect3D9 * ( WINAPI * PtrDirect3DCreate9 )( UINT );
HMODULE d3d9lib = ::LoadLibraryA( "d3d9" );
if( !d3d9lib ) {
return;
}
PtrDirect3DCreate9 direct3DCreate9 = ( PtrDirect3DCreate9 )GetProcAddress( d3d9lib, "Direct3DCreate9" );
if( !direct3DCreate9 ) {
return;
}
IDirect3D9* direct3D9 = direct3DCreate9( D3D_SDK_VERSION );
if( !direct3D9 ) {
return;
}
D3DADAPTER_IDENTIFIER9 adapterIdentifier;
const HRESULT hr = direct3D9->GetAdapterIdentifier( 0, 0, &adapterIdentifier );
direct3D9->Release();
if( SUCCEEDED( hr ) ) {
printf( "+--Direct 3D-----------------------------------\n" );
printf( "| VendorId: 0x%x\n", adapterIdentifier.VendorId );
printf( "| DeviceId: 0x%x\n", adapterIdentifier.DeviceId );
printf( "| Revision: 0x%x\n", adapterIdentifier.Revision );
printf( "| SubSysId: 0x%x\n", adapterIdentifier.SubSysId );
printf( "| Product: %hu\n", HIWORD( adapterIdentifier.DriverVersion.HighPart ) ); // Product
printf( "| Version: %hu\n", LOWORD( adapterIdentifier.DriverVersion.HighPart ) ); // Version
printf( "| Sub version: %hu\n", HIWORD( adapterIdentifier.DriverVersion.LowPart ) ); // Sub version
printf( "| build: %hu\n", LOWORD( adapterIdentifier.DriverVersion.LowPart ) ); // build
printf( "| Driver: %s\n", adapterIdentifier.Driver );
printf( "| Description: %s\n", adapterIdentifier.Description );
printf( "+----------------------------------------------\n" );
}
}
int main() {
detect();
return 0;
}
@elsamuko
Copy link
Author

elsamuko commented Mar 4, 2020

On a real machine:

+--Direct 3D-----------------------------------
| VendorId:    0x10de
| DeviceId:    0x103c
| Revision:    0xa1
| SubSysId:    0x109510de
| Product:     23
| Version:     21
| Sub version: 13
| build:       9125
| Driver:      nvldumdx.dll
| Description: NVIDIA Quadro K5200
+----------------------------------------------

On a VMWare:

+--Direct 3D-----------------------------------
| VendorId:    0x15ad
| DeviceId:    0x405
| Revision:    0x0
| SubSysId:    0x40515ad
| Product:     8
| Version:     16
| Sub version: 7
| build:       0
| Driver:      vm3dum64_loader.dll
| Description: VMware SVGA 3D
+----------------------------------------------

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment