8
$\begingroup$

So I just recently learned about the Compute Shader and it looks from what I have picked up the same idea as parallel programming you would do with CUDA or OpenCL, but in the shader pipeline.

If I want to draw a million cubes in a scene should I be using one method over the other or both. If both how do you split that up so the GPU isn't trying to parallel compute both the shader and another process at the same time

$\endgroup$
  • 2
    $\begingroup$ Why you want to use GPGPU for drawing million cubes in first place? $\endgroup$ – Derag Jul 28 '16 at 6:39
  • 3
    $\begingroup$ Compute shaders are used for compute workloads, not rendering. The rule of thumb is that if you need rasterization (i.e. processing of triangulated geometry into pixels), you should be using the rendering pipeline; if you simply need to process a large piece of data, you should be using compute. I'm also interested in sound arguments for and against compute shaders and CUDA/OpenCL (with graphics API interop). One that I've heard of is better queueing of compute workloads with the compute-specific API, but I'd like to know more (i.e. how does async compute come into the picture). $\endgroup$ – IneQuation Jul 28 '16 at 10:20
  • $\begingroup$ @Derag Just trying to feed my cube fetish as fast as possible $\endgroup$ – FrickeFresh Jul 28 '16 at 13:44
  • $\begingroup$ If you want to draw a million cubes, use ray-marching :) $\endgroup$ – russ Aug 5 '16 at 17:53
7
$\begingroup$

It's not quite correct, today, to think of compute shaders as being "in the shader pipeline" in the same sense that your vertex and fragment shaders are literally hooked up into a pipeline. Compute shaders are not "hooked up" to anything currently, cannot drive rasterization, or directly consume the outputs of rasterization.

What it allows you to do, though, is consume and produce memory resources also used by draw calls in a relatively efficient way. OpenCL makes this rather difficult (see for example https://software.intel.com/en-us/articles/opencl-and-opengl-interoperability-tutorial). This allows you to efficiently integrate compute passes within your renderer, but it is not integrated into the rendering pipeline

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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