2
$\begingroup$

So I want to implement a path tracer and I am confused between GPGPU computing or using OpenGL's compute shaders. I've already implemented a raytracer using GL's compute shaders.

What are the main differences between CUDA/OpenCL and CS? And is it possible to see a significant speed up if I prefer one over the other? Some main differences I already know are that using CS will make it vendor independent so I could run it on PCs having Nvidia/Amd GPUs alike. CUDA supports recursion while openCL/opengl CS don't.

What are other significant functionalities that would make a person prefer opencl/cuda over CS?

$\endgroup$

1 Answer 1

4
$\begingroup$

To first clear your confusion around the terms:

GPGPU stands for General Purpose computing on GPUs

CUDA is the specific NVIDIA API to perform GPGPU only on their hardware

OpenGL is a graphics specific API and is vendor independent
OpenCL is a parallel programming compute API and is vendor independent

Compute Shaders are a way to perform general purpose computations within
a rendering system but without being part of a fixed rendering architecture.
They exist for OpenGL (https://www.khronos.org/opengl/wiki/Compute_Shader)
but also for other graphics APIs like DirectX (DirectCompute) etc.

OpenCL is not only built for GPUs and can also be used to write code
for example to run massive parallel computations on supercomputers.

NVIDIA develops their own ray tracer based on CUDA and GPU computing.
The project is called Optix (https://developer.nvidia.com/optix)

To your performance question. It depends, as always on your setup and use case.
Some people did already the effort to measure differences. One paper for example is this: https://arxiv.org/ftp/arxiv/papers/1005/1005.2581.pdf

Another one is this: https://dl.acm.org/citation.cfm?id=2066955

Or one thesis about it: https://liu.diva-portal.org/smash/get/diva2:909410/FULLTEXT01.pdf

In their comparisons did CUDA often show good results. But when they for example used image processing algorithms that can be parallized very efficiently from the GPU then the comparison is nearly worthless compared what you might do in your path tracing code.

If you do not use any "classic" rendering, which you wanna combine your path traced results, I see not why you should use compute shaders for a pure path tracer. If platform independence is important OpenCL might be interesting for you since you then can take the code and run it on a complete other hardware for comparison. If you will stick to NVIDIA GPUs anyways you will likely get better performance using directly CUDA.

$\endgroup$
2
  • $\begingroup$ Even if not using classic rasterization on top of the raytraced image, there's still some nice convenience in having the resulting imagine in an FBO or a texture, provided you don't just want to write it out into an image file you have to display it at some point. Besides that, there's also nice convenience things an inherently graphical task might still profit from, like builtin matrix types or builtin access to the hardware's advanced texture filtering functionality. $\endgroup$ Feb 17, 2018 at 16:26
  • $\begingroup$ I don't have an Nvidia card but AMD one. Thanks for the links helps a bit. But I think compute shader would be better, since I'd have to use OpenGL anyways to output the result to a window. Keeping this question open a little more in case anybody has some more interesting details or first hand experience. $\endgroup$ Feb 18, 2018 at 11:04

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.