The module is what a Vulkan pipeline takes; the OpenGL ES side of it is the backend's, through result.reflect.
in or out without a location takes the first free one after the
given ones, in the order the shader declares them; a matrix takes one per column, an array one per element.
An in or out block takes its location, or each member its own, and the members follow each other from there; a
block with none takes the first free run of its size, and an array of blocks one element after the other.
gl_FragColor and gl_FragData are output location 0. OpenGL ES links a vertex output to a fragment input by name
and Vulkan by location, so a backend matches the two stages' result.reflect lists by name, or keeps their
declarations in the same order: a vertex shader that declares out vec2 uv; out vec4 color; and a fragment shader
that declares in vec4 color; in vec2 uv; give uv locations 0 and 1.GlslcOptions.bind, a function, with bind_user its first
argument. glslc calls it for each sampler, image and block in declaration order, with its kind, name, array size,
whether it is a texel buffer (samplerBuffer, imageBuffer), a block's size, and the set and binding the source
gave (-1 for none), and takes the set and binding it writes. A nonzero answer refuses the shader, and two resources
at one place, or a set or binding past 65535, are errors. Without a map (bind NULL), a resource keeps the set and
binding it gives, and one without a binding takes the first free binding of set 0, in declaration order.gl_DefaultUniformBlock, laid out as std140. It takes the first
free binding of set 0 once every other resource is placed, whether by the source, by glslc or by a binding map;
the map is not asked about it, unless GlslcOptions.map_default is nonzero: then the map places it too, after
the other resources, as a uniform block with an empty name and its size. A program's vertex and fragment stages
each have a default block, and one Vulkan binding has one descriptor for both stages, so a backend puts the two
apart that way. Its entry in result.reflect has an empty name and that set and binding, and each uniform's
entry its offset in it.uniform.member in the module, placed with the shader's other samplers in declaration
order (by the binding map too). Its result.reflect entry, and what the map sees, has the uniform's name and the
member's in member. An array of such structs gives each sampler member's variable that array: mats[2].albedo is
element 2 of the descriptor array mats albedo has. The struct's other members stay in the default uniform
block, laid out without the samplers, and a uniform whose struct holds samplers alone has no member there. A
function parameter of such a struct takes those other members as a value, then a pointer to each sampler.shared and
packed are laid out as std140. A buffer block is a StorageBuffer variable, as SPIR-V 1.3 has them. Their offsets
and strides are glslangValidator's, which the tests check. A bool in a block is a uint there, as Vulkan has no bool
in a block.gl_VertexID and gl_InstanceID are Vulkan's VertexIndex and InstanceIndex: the backend draws with
a first instance of 0, and a vertex index counts from the first vertex as OpenGL ES's does. Fragment shaders have
Vulkan's upper-left origin, so gl_FragCoord is Vulkan's by default. With GlslcOptions.flip_y, a fragment shader
reads gl_FragCoord.y as y * flip.x + flip.y and gl_PointCoord.y as y * flip.z + flip.w, where flip is a
vec4 at offset 0 of a push constant block (gl_ScarletFlip): main's start copies the two inputs into Private
variables that the shader reads. A backend that draws a window with a negative viewport height gives
(-1, height, 1, 0), and (1, 0, -1, 1) for a framebuffer drawn upright, so both read OpenGL ES's values. A texture sampled in a vertex or compute shader without a level reads level 0.lowp and mediump variables, in parameters and loose uniforms are RelaxedPrecision; the results of
operations and the members of structs and blocks are not.Made from docs/layers/gpu/glslc.md at 69237645142c. GPL-3.0-or-later.