Interoperability openCL DirectX11

Started by
4 comments, last by unbird 10 years, 10 months ago

Hi,

My problem is at the compilation stage, or even before :

I don't have the functions : clGetDeviceIDsFromD3D11KHR, ...etc in my <CL/cl_d3d11.h>, instead I have this function pointer clGetDeviceIDsFromD3D11KHR_fn.

I have the "cl_khr_d3d11_sharing" strng in my platform extension information.

I tried to add #pragma OPENCL EXTENSION cl_khr_d3d11_sharing : enable, but doesn't work.

So if you have any idea, or if you already used it I am really interested.

Thanks,

Advertisement
Have a look at the OpenCL Programming Guide book samples D3D10 interop (chapter 11) to get the picture. The clGetDeviceIDsFromD3D11KHR_fn is not a function pointer yet, but the type (signature) of your function pointer. Declare one like so

clGetDeviceIDsFromD3D11KHR_fn clGetDeviceIDsFromD3D11KHR = NULL;
To get the function you use clGetExtensionFunctionAddress. The sample uses some macro magic:

#define INITPFN(x) \
    x = (x ## _fn)clGetExtensionFunctionAddress(#x);\
    if(!x) { printf("failed getting %s", #x); }
... to ease the call, so in this case:

INITPFN(clGetDeviceIDsFromD3D11KHR);

Thanks a lot !!

This stuff is amazing, I was simulating 1 million force field particles at 30 FPS, now at more than 400 FPS :)

I was expecting a big gain because of all return tickets I was paying from CPU to GPU, now there is none !

Glad to hear. You got some nice screen shots ?

Out of curiosity: Why not use compute shaders ? Limitations because of D3D10 hardware (cs_4_0) ?

I don't know exactly why I used openCL, I wanted to use this tech like a aim. I was thinking to port my code from openCL to Direct Compute but then I thought it will be easier to integrate the interoperability. And I think there is something really good with openCL, it is scalable even on CPU, so I don't have to do some multi-threading , openCL will do it for me. The other good thing with openCL it is that is portable. I also wanted to integrate my stuff in a friend engine which is in OpenGL on i Platform.

So maybe now you d like to know why I used DirectX11 :) I wanted also used this tech because it was used in my job, and I knew some HLSL.

I don't have any screen shot but I created a Youtube channel : http://www.youtube.com/user/uuuq78/videos

Galaxy is the one I was talking about. In the video description I put the benchmarks in ms. I will update my videos and benchmarks with the interoperability when I will have integrated it correctly.

Videos are even better. Quite some nice GPGPU samples you got there. Congrats.

I just wanted to hear if you had any troubles with compute shaders at all. Because I had half a year ago, so be warned: The compiler sometimes took minutes or crashed. If it compiled, the shader sometimes produced silly results. Then again, I probably did something blatantly wrong design-wise and also still used the June 2010 SDK compiler (which also has troubles with tesselation). If you go compute shader make sure to use the newest one (coming with the Windows 8 Kit).

I was so fed up to give OpenCL a shot. Played with Cloo (I'm using C#) and was positively surprised. Compilation took seconds at most (subsequent compilation even seems to be cached by the NVidia driver), and the results were fine.

Edit: That performance number of your particles is quite impressive. Smells like the interop isn't that bad a staller. Or do you have such a beefy hardware ? wink.png. If you do transliterate that sample to a compute shader, don't forget to post a comparison, please.

This topic is closed to new replies.

Advertisement