DirectX 9 + Multi-GPU


Last week I wrote a raytracer (CUDA SDK 2.1) that run on CUDA device. I exploit the DirectX 9 interoperability (starting from the simpleD3D9Texture sample of the SDK) such that the raytracer store pixels directly into a texture surface. My next step is to distribute this on two (or more) GPUs. Looking at the code and the documentation isn’t clear if I can use the second GPU to render in the same texture. The programming guide say: “A CUDA context may interoperate with only one Direct3D device at a time and the CUDA context and Direct3D device must be created on the same GPU”. So, there is no way to exploit my multiple GPU system when use DirectX 9 interoperability?

Best Regard,

  • AGPX

P.S.: I found a bug in the simpleD3D9Texture code:



	// Create the D3D object.

	if( NULL == ( g_pD3D = Direct3DCreate9( D3D_SDK_VERSION ) ) )

		return E_FAIL;

	// Get primary display identifier


	// Find the first CUDA capable device

	unsigned int adapter;

	for (adapter = 0; adapter < g_pD3D->GetAdapterCount(); adapter++)



		int device;

		g_pD3D->GetAdapterIdentifier(adapter, 0, &adapterId);

		cudaD3D9GetDevice(&device, ident.DeviceName);

		if (cudaSuccess == cudaGetLastError()) break;




The line:

[font=“Courier New”]

cudaD3D9GetDevice(&device, ident.DeviceName);[/font]

make use of the unused variable ident. Instead, that line should be:

[font=“Courier New”]

cudaD3D9GetDevice(&device, adapterId.DeviceName);[/font]

replacing ident with adapterId.