4 Replies Latest reply on Jul 3, 2012 9:40 PM by neverknovvsbestt

    OpenCL DirectX10 Extensions


      I'm relatively new to OpenCL and have been having no troubles with it up until I started to try to use the d3d10 sharing extension. Specifically I can't seem to get anything to compile...


      Here is some info about my setup:

      SDK: AMD APP SDK v2.7

      Graphics Card: ATI Mobility Radeon HD 4500/5100 Series

      IDE: Visual Studio 2010


      When I query the device for extensions here is what it returns:

      "cl_khr_gl_sharing cl_amd_device_attribute_query cl_khr_d3d10_sharing "


      I added this in my header:

      #pragma OPENCL EXTENSION cl_khr_d3d10_sharing : enable

      #include <CL/cl_d3d10.h>


      When I compile my project (which simply references the function clCreateFromD3D10BufferKHR) I get the following output:

      warning C4068: unknown pragma

      error C3861: 'clCreateFromD3D10BufferKHR': identifier not found


      Is there something else I need to do before I can use these extensions?

        • OpenCL DirectX10 Extensions

          #pragma OPENCL EXTENSION go into kernel code. not normal host code.

          1 of 1 people found this helpful
            • Re: OpenCL DirectX10 Extensions

              Thanks nou,


              That solves the pragma warning, but the error still exists. I searched SDK for the d3d function signatures and found that they were wrapped in a define D3DINTEROP (something like that). I tried to simply define that in my build, but it still didn't fix my error.


              I'll keep posting what I find...


              Thanks again.

            • Re: OpenCL DirectX10 Extensions

              So, I think I figured it out...


              I came across the clGetExtensionFunctionAddressForPlatform function when reading through the man pages, and when looking at the cl_d3d10 header, I noticed that its a bunch of type defines for function pointers. Long story short I wrote the following code and was able to successfully call a d3d extension function.


              clCreateFromD3D10BufferKHR_fn function = (clCreateFromD3D10BufferKHR_fn)clGetExtensionFunctionAddressForPlatform(this->platform_id, "clCreateFromD3D10BufferKHR");



                         ID3D10Buffer *resource = 0;

                         cl_int errcode_ret;



                        cl_mem memory = (*function)(







              Now, the error code returns -30 which is CL_INVALID_VALUE, but this makes sense, because the ID3D10Buffer is null. Next I'll try calling it with a properly initialized d3d buffer.


              Is this the proper way to access OpenCl extensions?