Cuda / OpenCL vs Rendered Textures

Started by
3 comments, last by tamato 11 years, 1 month ago

I plan on working on two projects and don't know what the best way to go about it is.

One project would be to do a particle simulation on the gpu, the other a raytracer on a volume of data, of course all in the gpu.

I'm not at all familiar with Cuda or OpenCL other then they are good for this type of work.

What I would like to know is if Cuda or OpenCL is better then just using rendered to textures, why are they better?

Are they faster in some way? Easier to work with? What are the pro's and con's?

Thanks

Advertisement

If you need interaction with a more traditional graphics pipeline, then I wouldn't use either. Both D3D and OpenGL support compute shaders, and generally they are better to work with if you need to use the results of your computation for rendering. I would say a particle simulation falls into this category, since after you simulate them you will probably want to render them as quads. Also using compute shaders leaves the door open for DrawIndirect, which can be really useful for particles. For a raytracer, you probably won't need to interact with a D3D/GL context so CUDA and CL might make more sense. I'm not really experienced with OpenCL so I can't really give you a good comparison against Cuda. In terms of Cuda vs. compute shaders, Cuda is much closer to writing standard C/C++ code.

If you want a basic rundown of how CUDA compares to OpenCL and vice versa, read this: http://streamcomputing.eu/blog/2010-04-22/difference-between-cuda-and-opencl/

I myself am just getting started learning CUDA. Currently, I'm reading the book known as "CUDA C by Example". Like MJP already stated, it's very much like C and I haven't used OpenCL yet either.

I'd say they are both a bit overkill for a simple particle engine (unless you're massively drawing and updating millions of particles like rain or snow). I've seen raytracing done using shaders many times before, so it depends on what scale you're doing it on, I guess. Like I said, I'm still learning this myself. ^^

Shogun.

My first GPU particle system was originally written with a fragment program and an FBO. My second one used a vertex program and the transform feedback buffer.

Nowadays, I have an OpenCL based particle system. I actually don't think it's overkill; using OpenCL makes it (fairly) easy to handle dynamic branching, within reason. At any rate, the OpenCL kernel writes particles' informations directly to a shared VBO. It more portable and robust than either of the previous versions, too.

I eventually gave up on CUDA. Although it has nice primitives and a more expressive language, it is a pain to use compared to OpenCL and it's not cross-platform.

[size="1"]And a Unix user said rm -rf *.* and all was null and void...|There's no place like 127.0.0.1|The Application "Programmer" has unexpectedly quit. An error of type A.M. has occurred.
[size="2"]

For a raytracer, you probably won't need to interact with a D3D/GL context so CUDA and CL might make more sense.


And one last thing. Is there a better way I could have phrased the title to this post? It feels awkward but couldn't come up with anything better.

Is this because everything could be done in CUDA or CL including the visualization?

Thanks to your reply's I'll be looking into compute shaders and drawIndirect, I know next to nothing about these.

If there are any good resources on these I would be really interested in them.

Also, the title to this post feels awkward, but I couldn't come up with anything better. Is there a better way to phrase it?

This topic is closed to new replies.

Advertisement