First; how are OpenGL shaders compiled? Are they compiled on the CPU, or the GPU, or does it vary by implementation? Do different vendors have different binary outputs; if so, is it possible to cross-compile a binary for one GPU type on another GPU? I'm developing a game that I am planning on running on Intel GFX chips, ATI cards, and NVidia cards. I would prefer to ship only the binary parts of the shaders, without having to compile the source on the client computers. Is this possible? How does the process of shader compilation work?
Shaders are usually compiled by the software that runs on your CPU, not on your GPU. Once it's compiled, the shaders RUN on the GPU.
CPU-GPU CooperationThe architecture of OpenGL is based on a client-server model. An application program written to use the OpenGL API is the "client" and runs on the CPU. The implementation of the OpenGL graphics engine (including the GLSL shader programs you will write) is the "server" and runs on the GPU.
Shader Compilation is the term used to describe the process by which OpenGL Shading Language scripts are loaded into OpenGL to be used as shaders. OpenGL has three ways to compile shader text into usable OpenGL objects. All of these forms of compilation produce a Program Object.
A Shader is a user-defined program designed to run on some stage of a graphics processor. Shaders provide the code for certain programmable stages of the rendering pipeline. They can also be used in a slightly more limited form for general, on-GPU computation.
The compilation process is, generally speaking, performed on the CPU. However, the output differs not just by vendor, but also by model. As such, the shaders must be recompiled on the user's machine in order to remain compatible with any model of GPU the user may be using (including models of GPU that may not exist when you're writing your game!)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With