Need a simple D3D example! D3D and CUDA!

Hi everyone!

  • I want to write a simple program which uses CUDA to fill D3D window with blue color! The SDK has “SimpleD3D9” and “SimpleD3D10”, but these two use vertex buffer! So,i changed the code to use back buffer instead !
// Init

IDirectSurface9* pBackBuffer = 0;

// In InitD3D

HRESULT hr = g_pD3DDevice->GetBackBuffer(/*.........*/,&<b>pBackBuffer</b>)

// In runtest

// Register <b>pBackBuffer</b> with CUDA

// In runCUDA

// Map pBackBuffer and get the pointer

// call the kernel

// In kernel

kernel<<32,128>(/*...*/)

__global__ void kernel(unsigned int* pos)

{

// This code is for testing only....

const unsigned int idx = gridDim.x*blockIdx.x + ThreadIdx.x;

pos[idx] = 0xff;

}
  • It works normally (i can see a part of window with blue color)! But if i increase the size of D3D window largar than 512x600 , the kernel dont work at all (i can see black screen only)!

  • So, i switch to D3D10, but… the same with D3D9! Only black screen… !

  • I just want an example which use CUDA to fill the buffer which a specified color! (I dont want to use texture, it is much more slower than using back buffer )

Thank !

(note: These images is for fun only, dont blame me )

Did you check the programming guide & releasenotes? I think that D3D9 supports only vertex buffer. At least it used to support less than OpenGL. I’m not sure about D3D10, I believe more is supported there, but there are surely some limitations, and I never heard about the use of back buffer.

  • Thank for this information! Only vertex buffer… ! I read it, but i can use back buffer… so i just hope… hic…!

  • My program is using back buffer now! It works normally with the size smaller than (512x600 or 640x480)! I’m working with image processing, so, this is really importance! I think that i have to useD3D texture or OpenGL instead

Thank :)!