Source browser
examples/shaders/rgba_int_image.cpp
Read the complete file below or download its original bytes. Line numbers provide stable links to a declaration or processing step.
File fingerprint
1// Signed integer RGBA images use the same two-port pattern on every profile.
2#ifdef __cplusplus // Expose host declarations only when a C++ compiler reads this shader.
3#include "shdr.h" // Include shdr.h declarations.
4#endif // Finish this conditional compilation branch.
5
6layout(local_size_x = 4, local_size_y = 4, local_size_z = 1) in; // Cover a 4 by 4 group of output coordinates.
7layout(rgba32i, binding = 0) readonly uniform highp iimage2D input_image; // Read the rgba32i image at this image binding.
8layout(rgba32i, binding = 1) writeonly uniform highp iimage2D output_image; // Write the rgba32i image at this image binding.
9
10void main() { // Add deterministic per-channel offsets to one RGBA image pixel.
11 ivec2 position = ivec2(gl_GlobalInvocationID.xy); // Address the pixel assigned to this two-dimensional invocation.
12 ivec2 dimensions = imageSize(input_image); // Read the bound image extent before accessing its pixels.
13 if (position.x >= dimensions.x || position.y >= dimensions.y) // Guard invocations outside the image in the partial final tile.
14 return; // Stop this invocation before performing another resource access.
15 imageStore(output_image, position, imageLoad(input_image, position) + ivec4(-1, -2, -3, -4)); // Store the transformed RGBA pixel in the separate output image.
16} // End this block.