O'Reilly logo

OpenGL Programming Guide: The Official Guide to Learning OpenGL, Version 4.3, Eighth Edition by Bill M. Licea-Kane, John M. Kessenich, Graham Sellers, Dave Shreiner

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Image Qualifiers and Barriers

The techniques outlined above work well when compilers don’t perform overly aggressive optimizations on your shaders. However, under certain circumstances, the compiler might change the order or frequency of image loads or stores, and may eliminate them altogether if it believes they are redundant. For example, consider the simple example loop in Example 11.15.

Example 11.15. Basic Spin-Loop Waiting on Memory

#version 420 core// Image that we’ll read from in the looplayout (r32ui} uniform uimageBuffer my_image;void waitForImageToBeNonZero(){    uint val;    do     {        // (Re-)read from the image at a fixed location.        val = imageLoad(my_image, 0).x;        // Loop until the ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required