gpu identification with Optimus


We are running into a problem when querying the gpu identifier description on NVidia laptops using Optimus (with DX9 and DX11). [Code pasted at the bottom] The reported string is always the Intel gpu.

Our graphics library is in a separate .dll - the GUI apps make no DirectX calls.

However, if we add a DirectX call in the main GUI app, the snippet below correctly reports the NVidia card.

Is this a known issue? Or is there another way we can query the DirectX gpu information from the dll (e.g. NVidia SDK)?



#include <stdio.h>
#include <d3d9.h>

#pragma comment (lib, "d3d9.lib")

int main()
	IDirect3D9 *d3d9 = Direct3DCreate9(D3D_SDK_VERSION);
	if (!d3d9)
		return 1;

	FILE *fp = fopen("dx9-identify.log", "w");
	if (!fp)
		return 1;

	UINT adapterCount = d3d9->GetAdapterCount();
	printf("Adapter count: %d\n", adapterCount);
	fprintf(fp, "Adapter count: %d\n", adapterCount);

	for (UINT i = 0; i < adapterCount; i++)
		HRESULT hr = d3d9->GetAdapterIdentifier(i, 0, &iden);
		if (SUCCEEDED(hr))
			printf("Identifier desc: %s\n", iden.Description);
			fprintf(fp, "Identifier desc: %s\n", iden.Description);


	return 0;