A Compute Shader is created just like any other GLSL shader, except thatits type is GL_COMPUTE_SHADER (duh).
If I Know GLSL,What Do I Need to Do Differently to Write a Compute Shader?Not much:1. This will be shown here in the rest of these notes. But, for lighter-weightdata-parallel computing that interacts with graphics I will use Compute Shadersmjb August 11, 2014Oregon State Universit圜omputer Graphicsgraphics, the Shaders.I suspect that a good example of a lighter-weight data-parallel graphics-related application is aparticle system. They just kind of flow inwith the graphics.The bottom line is that I will continue to use OpenCL for the big, bad stuff. Compute Shaders look to be more convenient. It requires a lot of setup (queries, platforms, devices,queues, kernels, etc.). (true? how much?) Using OpenCL is somewhat cumbersome. (true?) This should result in better performance. Im assuming that calls to OpenGL compute shaders are more lightweight than calls to OpenCLkernels are.
There is noneed to acquire and release the context as OpenGL+OpenCL must do. Compute shaders use the same context as does the OpenGL rendering pipeline. Compute Shaders use the GLSL language, something that all OpenGL programmers shouldalready be familiar with (or will be soon). When everyone catches up to OpenGL 4.3, Compute Shaders willjust be there as part of core OpenGL. While this is not a huge deal,it d t k ti does take time and effort.
So, why use Compute Shadersever if youve got OpenCL? Heres what I think: OpenCL requires installing a separate driver and separate libraries. Why Not Just Use OpenCL Instead?OpenCL is great! It does a super job of using the GPU for general-purpose data-parallel computing.And, OpenCL is more feature-rich than OpenGL compute shaders.
OpenGL Compute Shader the Basic IdeaA Shader Program, with only a Compute Shader in itApplication Invokes the Compute Shaderto Modify the OpenGL Buffer DataApplication Invokes OpenGL Renderingwhich Reads the Buffer DataAnother Shader Program, with pipeline rendering in itmjb August 11, 2014Oregon State Universit圜omputer Graphics 3.
How to Use and Teach OpenGL Compute ShadersMike State Universitymjb August 11, 2014Oregon State Universit圜omputer Ģ.