March 2013
Intermediate to advanced
984 pages
26h 18m
English
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 ...
Read now
Unlock full access