Skip to main content
gamedev.net
🔒 Locked

Drawing with OpenCL

Started by Defeatist Apr 17, 2011 at 12:31 PM 2 replies 4.1k views
Original Post
Defeatist
Defeatist
Hey!

I plan on rewriting my (small) voxel renderer in OpenCL. I have seen several examples where OpenCL and graphics are combined using OpenGL or D3D "interop". I plan on doing everything graphics related in OpenCL and to make things easier I want to use OpenCL only. What is the correct method to draw things to a window? Do I send the results from a single frame back to the host application and then blit it to the screen? Im not looking for window system specific code but examples could still be helpful.
Erik Rufelt
Erik Rufelt
You share a texture with OpenGL or Direct3D, and present that to the window as usual. There should be examples in both the NVidia and ATI SDKs.
Defeatist
Defeatist

You share a texture with OpenGL or Direct3D, and present that to the window as usual. There should be examples in both the NVidia and ATI SDKs.


Do you mean that is the method that will probably faster and more compatible than anything I'd write myself, or are they simply doing something I can't easily replicate? All I need the code to copy the stuff to the screen when all rendering is completed and I don't like relying on a larger library just for that.
SimonForsman
SimonForsman

[quote name='Erik Rufelt' timestamp='1303046734' post='4799465']
You share a texture with OpenGL or Direct3D, and present that to the window as usual. There should be examples in both the NVidia and ATI SDKs.


Do you mean that is the method that will probably faster and more compatible than anything I'd write myself, or are they simply doing something I can't easily replicate? All I need the code to copy the stuff to the screen when all rendering is completed and I don't like relying on a larger library just for that.
[/quote]

Since the OpenCL data normally is stored on the GPU the most performant way to get it to render would be by having OpenGL or D3D render that data directly, copying the data over to RAM will always be slower unless you are rendering to a file, network device or something else that the gpu can't access directly. clEnqueReadBuffer can be used to read the data back to the host application.
[size="1"]I don't suffer from insanity, I'm enjoying every minute of it.
The voices in my head may not be real, but they have some good ideas!

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.