March 2013
Intermediate to advanced
984 pages
26h 18m
English
The shared keyword is used to declare variables in shaders in a similar manner to other keywords such as uniform, in, or out. Some example declarations using the shared keyword are shown in Example 12.6.
Example 12.6. Example of Shared Variable Declarations
// A single shared unsigned integer;shared uint foo;// A shared array of vectorsshared vec4 bar[128];// A shared block of datashared struct baz_struct{ vec4 a_vector; int an_integer; ivec2 an_array_of_integers[27];} baz[42];
When a variable is declared as shared, that means it will be kept in storage that is visible to all of the compute shader invocations in the same local workgroup. When one invocation of the compute shader writes to a ...