which format supported in clCreateFromD3D10Texture2DKHR?

Hi, All

cl_mem clCreateFromD3D10Texture2DKHR(  cl_context context,  
  cl_mem_flags flags,  
  ID3D10Texture2D *resource,  
  uint subresource,  
  cl_int  *errcode_ret ) 

which type of ID3D10Texture2D can be supported by this function?
I can not find the information in the specification. Only DXGI_FORMAT_R8G8B8A8_UNORM?

I’m also very interested in this.

I’m guessing the format can be any of the DXGI available formats, as long as you receive the correct input from your OCL kernel, i.e. __global char4* inputImage for DXGI_FORMAT_R8G8B8A8_UNORM. Count the bytes (R8 == 8 bits == 1 byte == 1 char) and use OCL input types appropriately.

Can anyone verify this? are there any limitations on texture formats?

After some experimenting, looks like clCreateFromD3D10Texture2DKHR creates an image, so must be accessed using the image sampling built-in functions, and the image formats available can be queried by clGetSupportedImageFormats

http://www.khronos.org/registry/cl/sdk/ … rmats.html

Hi, chai
You may have used clEnqueueReleaseD3D10ObjectsKHR. Does this function cause a GPU memory leak? thank you!

Have used it, but with no memory leaks :P…

I was working off of the SimpleDX10 sample in the ATI Stream SDK, on ATI 5870, and played with another skeleton I was making.

Are you completing all command queues/waiting for events to finish before trying to release the D3D10 objects?

Thanks chai!
I used Nvidia sample and found that even clEnqueueReleaseD3D10ObjectsKHR return 0, the reference count of the surface had not been reduced. maybe I should check ATI sample.

very strange
clGetSupportedImageFormats displays my card support CL_BGRA
But I use DXGI_FORMAT_B8G8R8A8_UNORM texture to clCreateFromD3D10Texture2DKHR, I got an error!

Can you provide more information on the error? I’m playing with CL_RGBA and getting no errors, but also no functionality at this point :P… Trying to run a simple kernel on the swapchain backbuffer, but it doesn’t affect the backbuffer at all…

I mean if you create a texture(its format is DXGI_FORMAT_B8G8R8A8_UNORM). Then use this texture in clCreateFromD3D10Texture2DKHR. I got an error!
maybe you can try this…

Actually, I have a very very urgent question. Whether clEnqueueReleaseD3D10ObjectsKHR cause GPU memory leak?
code]err =clEnqueueReleaseD3D10ObjectsKHR(m_Command_queue, 1, &m_Src_mem, NULL, NULL, NULL);

suppose m_Src_mem share the same memory with textureMem.
before invoking clEnqueueReleaseD3D10ObjectsKHR, we can get the reference count of textureMem(use addref/release). after clEnqueueReleaseD3D10ObjectsKHR, we also get the reference count of textureMem. I found even clEnqueueReleaseD3D10ObjectsKHR return 0. the reference count of textureMem does not reduced!
so what is wrong?

What is the error you are getting and what is the call which returns the error?

I can’t help you with the reference count, but if you have the DirectX debug layer it should provide output for GPU memory leaks pertaining to your D3D texture. Silly question: does the texture reference count increase when you invoke clEnqueueAcquireD3D10ObjectsKHR(…)? You may be seeing just the d3d references to the texture, rather than the d3d+OCL references, in which case releasing objects would not change the count.

If I call clCreateFromD3D10Texture2DKHR using DXGI_FORMAT_B8G8R8A8_UNORM texture, I will get CL_INVALID_D3D10_RESOURCE_KHR.
clEnqueueAcquireD3D10ObjectsKHR will not increase texture reference count.
but clCreateFromD3D10Texture2DKHR will increase the reference count.

clEnqueueAcquireD3D10ObjectsKHR is not supposed to increase the reference count of the objects.

clCreateFromD3D10Texture2DKHR will increase the reference count.
but clEnqueueReleaseD3D10ObjectsKHR can not decrease the reference count!
…what is wrong? how to use clEnqueueReleaseD3D10ObjectsKHR?

There are two different pieces of functionality at play here.

On one hand we have clRetainMemObject()/clReleaseMemObject(), which modifies the reference count of memory objects, in the same way that clRetainContext()/clReleaseContext() modifies the reference count of context objects.

On the other hand we have clEnqueueAcquireXxx()/clEnqueueReleaseXxx(), which the application uses to synchronize between OpenCL and OpenGL/DirectX. These do not affect reference counts.