cancel
Showing results for 
Search instead for 
Did you mean: 

Archives Discussions

Naycon
Journeyman III

Best way to create openGL texture3D from CL buffer?

I realise this turned out to a wall of text, so here's the short question and if you like you can go on and read the details below:

I'd like to know if someone has any suggestion on how copying a openCL buffer into a 3D-texture could and/or should be done? Or maybe even better, how I could write directly to a 3D-texture (although it seem this is an extension to openCL which I guess is not implemented yet).

Details:

I'm currently trying to implement a fluid renderer in openCL&openGL as a project in a course at my university. Now, my problem is how to render the result of my fluid simulations. I've found a nice ray marcher written in GLSL which can render a texture3D for me. The thing is, I cannot figure out how to get my data from a normal openCL buffer over to a 3D-texture I've created using openGL.

I've setup openCL with a openGL context, seem to work just fine. Trying to modify some code I found in the Apple openCL noise example, I create a 3D-texture in openGL, create a cl_mem object from it using clCreateFromGLTexture3D (seem to work fine as long as I bind the texture before doing this) and then I plan to either write directly to this buffer (no idea if this would work) or to have another normal openCL buffer and copy its content to the 3D-texture buffer (this is what is done in the apple examlpe).

However, I cannot try either of the two, because the clEnqueueAcquireGLObjects function causes my program to crash unexpectedly, reporting a search path (something like C:\opencl\runtime\src\, which is not where I've got openCL and Stream installed) ending with cl_gl.cpp:1177: Unimplemented().

Now, does this mean that the clEnqueueAcquireGLObjects method is currently unimplemented when used together with openGL texture3D objects?

I've also tried to create a glBuffer and by using glBindBuffer together with glTexImage3D. When doing this, the clEnqueueAcquireGLObjects method seem to work just fine when I call it with the cl_mem object I created from the glBuffer. However, to get the data from the buffer into a 3D-texture, I thought I could use glBuffer and glTexImage3D together, as the openGL specification says that glTexImage3D should get the data from the glBuffer when it is bound. This does not seem to work, at least my texture is all black when rendered.

 

 

0 Likes
9 Replies
genaganna
Journeyman III

GL interoperability is not supported in beta4

0 Likes
nou
Exemplar

OpenCL OpenGL interoperability is not currently implemented. you must manualy copy data from cl_mem to texture. there is two approach.

create cl_mem with CL_MEM_USE_HOST_PTR and then that pointer pass to glTexImage3D().

or you can create GL pixel buffer object extension and stream texture. search about gl texture stream.

0 Likes
Naycon
Journeyman III

Thank you both for quick answers! So, no openGL-openCL interop means that I cannot use anything in chapter 9.11 and 9.12 of the specification? I assumed that as I could create an openCL context using an openGL context, at least some parts of the interop was implemented. I'm having a hard time understanding what parts of the specification are and are not implemented, but maybe it's to be expected since the drivers are still in beta. 😃

 

Originally posted by: nou OpenCL OpenGL interoperability is not currently implemented. you must manualy copy data from cl_mem to texture. there is two approach.

 

create cl_mem with CL_MEM_USE_HOST_PTR and then that pointer pass to glTexImage3D().

 

or you can create GL pixel buffer object extension and stream texture. search about gl texture stream.

 

I will look into that. What way would be the best if I plan to repeatedly update my simulation? I guess this implies that I have to copy the memory to host (cpu) and then back again to the device (gpu), or is there some way to avoid this?

0 Likes

sharing between opengl and opencl work on MacOS. and i think with nvidia implementation interoperability work too.

you can eliminate only one copy and that is between two location in host ram.

first solution is simplier but if you do not want update then it can lead to performance drop because it will must copy from device after each execution of kernel.i think that second will be better.

0 Likes

Naycon,

From clGetDeviceInfo  you can get to know whether perticular feature is supported or not.

To know GL interoperability is supported or not. see cl_khr_gl_sharing string in  extensions string returned by clGetDeviceInfo with CL_DEVICE_EXTENSIONS.

 

0 Likes

When CL_DEVICE_IMAGE_SUPPORT is "no" (as reported by CLInfo), I assume that means that I can't create images and use samplers.  Is that correct?

If so, does that just mean that it's not ready in the OpenCL implementation as yet, but will be in a future beta drop (or the release)?  Or does it mean that just need to get a better GPU?

0 Likes

yes that is correct.

for the 4000 series is not planned any extensions. but i think that image support will be for 4000 too. but that is only my guess.

0 Likes

Aw man, so the HD4870 will never support the image datatype and samplers?

0 Likes

nooo. i mean for 4870 there is not planned extension like atomic and double support.

but image support should be there in the future. but this information is only my personal opinion i am not related to AMD

0 Likes