Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Are OpenGL shaders compiled on the GPU or the CPU? How does binary output vary by GPU manufacturer?

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?

like image 212
bbosak Avatar asked Aug 27 '11 02:08

bbosak


People also ask

Are shaders compiled on CPU or GPU?

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.

Is OpenGL GPU or CPU?

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.

Does OpenGL compile shaders?

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.

How do shaders work on OpenGL?

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.


1 Answers

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!)

like image 87
bdonlan Avatar answered Oct 15 '22 10:10

bdonlan