Arrays also take up locations based on their array sizes. Structs take up locations based on their member types, in-order. The double and dvec2 types also take one location, while dvec3 and dvec4 take up 2 locations. Scalars and vector types that are not doubles all take up one location. It is a compile/link-time error to have ranges of variables overlap their locations (unless they have different components specifiers and doesn't overlap their component usage). When a type that consumes multiple locations is used, they will consume locations sequentially. Some such types consume multiple locations. Location sizes: Interfaces between programs can be of various types, even user-defined structs and arrays. However, AMD implemented the old behavior for a time, and it is not clear that their implementation was updated to fix this. The spec was changed to fix this, so that linkage would be the same whether separate or together if location indices are specified, they are always used. That is, if you specified location indices, they were effectively ignored unless you were linking a separate program. Note: The ARB_separate_shader_objects extension was released in a form where this kind of layout location linking outside of separate shaders did not work. Input and output#Interface block variables need additional functionality to use these.įor example, given a vertex shader that provides these outputs: This applies to loose input/output variables. This index is provided by location qualifier. This changes the interface matching process a bit, allowing outputs that aren't consumed by the next stage and so forth. However, it is possible to tag variables with an index, such that they correspond by the index instead of by name. This correspondence typically happens the same way as when doing dynamic linkage: inputs and outputs must match by name, type, and qualifiers exactly (with a few exceptions). When dynamically using separate programs, the correspondence between the outputs of one program and the inputs of the next is important. Program separation linkage Program Separation Layout(location = output index, index = dual output index) out vec4 outColor Īgain, this allows one to forgo the use of glBindFragDataLocationIndexed. Similarly, the values in the shader override the values provided by this function.įor dual source blending, the syntax includes a second qualifier: Layout(location = output index) out vec4 outColor Īs with vertex shader inputs, this allows the user to forgo the use of glBindFragDataLocation. This uses the same syntax as vertex shader attributes: This will allocate the attribute indices 2, 3, 4, and 5.įragment shader outputs can specify the buffer index that a particular output writes to. If you try to combine the two and they conflict, the layout qualifier always wins.Īttributes that take up multiple attribute slots will be given a sequential block of that number of attributes in order starting with the given attribute. With this syntax, you can forgo the use of glBindAttribLocation entirely. Layout(location = attribute index) in vec3 position Vertex shader inputs can specify the attribute index that the particular input uses. Depending on the available feature set, these variables can have layout qualifiers that define what resources they use. Shader stage input and output variables define a shader stage's interface. 9.1 Tessellation control output vertex count.When this happens, the last defined value for mutually-exclusive qualifiers or for numeric qualifiers prevails. In OpenGL 4.2 or ARB_shading_language_420pack, a definition can have multiple layout() segments to qualify the definition, and the same qualifier can appear multiple times for the same definition. In these definitions, variable definition will just be in or out. These shader stage options apply to the input of the shader stage or the output. Layout qualifiers are sometimes used to define various options for different shader stages. In the above, value must be an integer literal, unless you are using OpenGL 4.4 or ARB_enhanced_layouts, in which case it may be an Integral Constant Expression (aka: a compile-time constant). Some qualifiers can have values assigned to them, as with qualifier2 in the above example. The qualifiers are order-independent, unless otherwise noted. The qualifier values are specific to a particular use of layouts. Layout( qualifier1, qualifier2 = value. Layout qualifiers affect where the storage for a variable comes from, as well as other user-facing properties of a particular definition.Īll layout qualifiers are defined with a common syntax: A number of OpenGL Shading Language variables and definitions can have layout qualifiers associated with them.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |