clCreateFromD3D9TextureNV returns incomprehensible error!

Hi. Nice to meet you all.

As ‘http://www.khronos.org/registry/cl/extensions/nv/cl_nv_d3d9_sharing.txt’ says,

‘clCreateFromD3D9TextureNV’ function can returns an error named ‘CL_INVALID_D3D9_RESOURCE_NV’,

if the IDirect3DTexture9 instance isn’t created with D3DPOOL_DEFAULT option, or

specific miplevel is already created, or

the opencl context is different from the one created by another IDirect3DDevice9.

In my code, there’re no above cases.

I created the IDirect3DTexture9 instance with D3DPOOL_DEFAULT option,
there’s no miplevel, and there’s only one IDirect3DDevice9 / OpenCL context instance.

There are 23 cl_mem objects created by clCreateFromD3D9TextureNV when the error is occured.
And GPU memory is used about 480MB, total amount is 1GB.

IDirect3DTexture9 create option:
Using D3DXCreateTexture func
Width: 330 Height: 246
D3DUSAGE_DYNAMIC, D3DFMT_X8R8G8B8, D3DPOOL_DEFAULT
no miplevel

Development environment:
NVIDIA GeForce GTX460 1GB
OpenCL SDK 4.1 (bundled with CUDA SDK 4.1)
VS2010 SP1
DirectX 9.0c (Jun 2010)

Thanks for reading!

Solved!

It was my fault.

I found that I missed removing some other useless cl_mem objects.
So I removed them, then the error is gone.

I guess there’s a bug in the ‘clCreateFromD3D9TextureNV’ function.

It should results another error message such as ‘CL_NOT_ENOUGH_MEM_IN_GPU’,
not ‘CL_INVALID_D3D9_RESOURCE_NV’.