Shader Storage Buffer Objects

Reading data from and writing data to memory using image variables works well for simple cases where large arrays of homogeneous data are needed, or where the data is naturally image-based (such as the output of OpenGL rendering or where the shader is writing into an OpenGL texture). However, in some cases, large blocks of structured data may be required. For these use cases, we can use a buffer variable to store the data. Buffer variables are declared in shaders by placing them in an interface block which in turn is declared using the buffer keyword. A simple example is given in Example 11.5.

Example 11.5. Simple Declaration of a Buffer Block

#version 430 core// create a readable-writeable ...

Get OpenGL Programming Guide: The Official Guide to Learning OpenGL, Version 4.3, Eighth Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.