Direct3d9 interop (clCreateFromD3D9VolumeTextureNV)

I’m experiencing problems with the Direct3d9 interop functionality in OpenCL SDK release 3.0. OpenCL works flawlessly when accessing buffers from host memory, but I get a crash when trying to access Direct3d 3d textures directly from OpenCL. I use clGetDeviceIDsFromD3D9NV to create the OpenCL context, so that should not be the issue.


#include <cl/cl_d3d9_ext.h>

clCreateFromD3D9VolumeTextureNV_fn clCreateFromD3D9VolumeTextureNV = (clCreateFromD3D9VolumeTextureNV_fn)clGetExtensionFunctionAd
dress(“clCreateFromD3D9VolumeTextureNV”);
cl_int err = 0;
cl_mem in_buf = clCreateFromD3D9VolumeTextureNV(cl_context, CL_MEM_READ_ONLY, d3d_3d_tex, 0, &err);

Exception when calling clCreateFromD3D9VolumeTextureNV:
Unhandled exception at 0x0cb4aca4 in GPVFramework.exe: 0xC0000005: Access violation reading location 0x00000018.

Have anyone been able to successfully utilize the d3d9 bindings?

Thanks in advance,
Fredrik Orderud

Solution:
You need to make sure that the OpenCL context is configured for Direct3D integration.

// create a OpenCL context with Direct3D9 integration:
cl_context_properties properties[3];
properties[0] = (cl_context_properties)CL_CONTEXT_D3D9_DEVICE_NV;
properties[1] = (cl_context_properties)d3d_device;               
properties[2] = (cl_context_properties)0;
context = clCreateContext(properties, 1, &ocl_device, NULL, NULL, &result);