15bd8deadSopenharmony_ciName 25bd8deadSopenharmony_ci 35bd8deadSopenharmony_ci NV_explicit_attrib_location 45bd8deadSopenharmony_ci 55bd8deadSopenharmony_ciName Strings 65bd8deadSopenharmony_ci 75bd8deadSopenharmony_ci GL_NV_explicit_attrib_location 85bd8deadSopenharmony_ci 95bd8deadSopenharmony_ciContributors 105bd8deadSopenharmony_ci 115bd8deadSopenharmony_ci Contributors to ARB_explicit_attrib_location 125bd8deadSopenharmony_ci Mathias Heyer, NVIDIA 135bd8deadSopenharmony_ci 145bd8deadSopenharmony_ciContact 155bd8deadSopenharmony_ci 165bd8deadSopenharmony_ci Greg Roth, NVIDIA (groth 'at' nvidia.com) 175bd8deadSopenharmony_ci 185bd8deadSopenharmony_ciStatus 195bd8deadSopenharmony_ci 205bd8deadSopenharmony_ci Shipping on Tegra 215bd8deadSopenharmony_ci 225bd8deadSopenharmony_ciVersion 235bd8deadSopenharmony_ci 245bd8deadSopenharmony_ci Last Modified Date: September 20, 2013 255bd8deadSopenharmony_ci Revision: 2 265bd8deadSopenharmony_ci 275bd8deadSopenharmony_ciNumber 285bd8deadSopenharmony_ci 295bd8deadSopenharmony_ci OpenGL ES Extension #159 305bd8deadSopenharmony_ci 315bd8deadSopenharmony_ciDependencies 325bd8deadSopenharmony_ci 335bd8deadSopenharmony_ci Requires OpenGL ES 2.0. 345bd8deadSopenharmony_ci 355bd8deadSopenharmony_ci Written based on the wording of the OpenGL ES 2.0.25 Full Specification 365bd8deadSopenharmony_ci (November 2, 2010). 375bd8deadSopenharmony_ci 385bd8deadSopenharmony_ci Written based on the wording of The OpenGL ES Shading Language 1.0.17 395bd8deadSopenharmony_ci Specification (May 12, 2009). 405bd8deadSopenharmony_ci 415bd8deadSopenharmony_ciOverview 425bd8deadSopenharmony_ci 435bd8deadSopenharmony_ci This extension provides a method to pre-assign attribute locations 445bd8deadSopenharmony_ci to named vertex shader inputs. This allows applications to globally 455bd8deadSopenharmony_ci assign a particular semantic meaning, such as diffuse color or 465bd8deadSopenharmony_ci vertex normal, to a particular attribute location without knowing 475bd8deadSopenharmony_ci how that attribute will be named in any particular shader. 485bd8deadSopenharmony_ci 495bd8deadSopenharmony_ciNew Procedures and Functions 505bd8deadSopenharmony_ci 515bd8deadSopenharmony_ci None 525bd8deadSopenharmony_ci 535bd8deadSopenharmony_ciNew Tokens 545bd8deadSopenharmony_ci 555bd8deadSopenharmony_ci None 565bd8deadSopenharmony_ci 575bd8deadSopenharmony_ciAdditions to Chapter 2 of the OpenGL ES 2.0 Specification (OpenGL Operation) 585bd8deadSopenharmony_ci 595bd8deadSopenharmony_ci Section 2.10.4 "Shader Variables", subsection "Vertex Attributes" 605bd8deadSopenharmony_ci 615bd8deadSopenharmony_ci Modify the first paragraph to read: 625bd8deadSopenharmony_ci 635bd8deadSopenharmony_ci "Vertex shaders can define named attribute variables, which are 645bd8deadSopenharmony_ci bound to the generic vertex attributes that are set by 655bd8deadSopenharmony_ci VertexAttrib*. This binding can be specified by the application 665bd8deadSopenharmony_ci before the program is linked, either through BindAttribLocation 675bd8deadSopenharmony_ci (described below) or explicitly within the shader text, or 685bd8deadSopenharmony_ci automatically assigned by the GL when the program is linked." 695bd8deadSopenharmony_ci 705bd8deadSopenharmony_ci Modify the third paragraph describing BindAttribLocation to read: 715bd8deadSopenharmony_ci 725bd8deadSopenharmony_ci "When a program is linked, any active attributes without a binding 735bd8deadSopenharmony_ci specified either through BindAttribLocation or explicitly set within 745bd8deadSopenharmony_ci the shader text will automatically be bound to vertex attributes by 755bd8deadSopenharmony_ci the GL. Such bindings can be queried using the command 765bd8deadSopenharmony_ci GetAttribLocation. LinkProgram will fail if the assigned binding of 775bd8deadSopenharmony_ci an active attribute variable would cause the GL to reference a 785bd8deadSopenharmony_ci nonexistent generic attribute (one greater than or equal to the 795bd8deadSopenharmony_ci value of MAX_VERTEX_ATTRIBS). LinkProgram will fail if the attribute 805bd8deadSopenharmony_ci bindings specified either through BindAttribLocation or explicitly 815bd8deadSopenharmony_ci set within the shader text do not leave enough space to assign a 825bd8deadSopenharmony_ci location for an active matrix attribute, which requires multiple 835bd8deadSopenharmony_ci contiguous generic attributes. If an active attribute has a binding 845bd8deadSopenharmony_ci explicitly set within the shader text and a different binding 855bd8deadSopenharmony_ci assigned by BindAttribLocation, the assignment in the shader text is 865bd8deadSopenharmony_ci used." 875bd8deadSopenharmony_ci 885bd8deadSopenharmony_ciAdditions to OpenGL ES Shading Language 1.00 Specification 895bd8deadSopenharmony_ci 905bd8deadSopenharmony_ci Including the following line in a shader can be used to control 915bd8deadSopenharmony_ci the language feature described in this extension: 925bd8deadSopenharmony_ci 935bd8deadSopenharmony_ci #extension GL_NV_explicit_attrib_location : <behavior> 945bd8deadSopenharmony_ci 955bd8deadSopenharmony_ci where <behavior> is as described in section 3.4. 965bd8deadSopenharmony_ci 975bd8deadSopenharmony_ci A new preprocessor #define is added to the OpenGL ES Shading Language: 985bd8deadSopenharmony_ci 995bd8deadSopenharmony_ci #define GL_NV_explicit_attrib_location 1 1005bd8deadSopenharmony_ci 1015bd8deadSopenharmony_ciSection 4.3.3 "Attribute" 1025bd8deadSopenharmony_ci 1035bd8deadSopenharmony_ci Add new section 4.3.3.1 "Attribute Layout Qualifiers" 1045bd8deadSopenharmony_ci 1055bd8deadSopenharmony_ci "Vertex shaders allow location layout qualifiers on attribute 1065bd8deadSopenharmony_ci variable declarations. They can appear with an individual variable 1075bd8deadSopenharmony_ci declared with an attribute qualifier: 1085bd8deadSopenharmony_ci 1095bd8deadSopenharmony_ci <layout-qualifier> attribute <declaration>; 1105bd8deadSopenharmony_ci 1115bd8deadSopenharmony_ci Layouts qualified declarations can only be made at global scope, 1125bd8deadSopenharmony_ci and only on attribute variable declarations. 1135bd8deadSopenharmony_ci 1145bd8deadSopenharmony_ci <layout-qualifier> expands to: 1155bd8deadSopenharmony_ci 1165bd8deadSopenharmony_ci layout-qualifier : 1175bd8deadSopenharmony_ci layout (<layout-qualifier-id>) 1185bd8deadSopenharmony_ci 1195bd8deadSopenharmony_ci <layout-qualifier-id> : 1205bd8deadSopenharmony_ci location = <integer-constant> 1215bd8deadSopenharmony_ci 1225bd8deadSopenharmony_ci Only one argument is accepted. For example, 1235bd8deadSopenharmony_ci 1245bd8deadSopenharmony_ci layout(location = 3) attribute vec4 normal; 1255bd8deadSopenharmony_ci 1265bd8deadSopenharmony_ci will establish that the vertex shader attribute <normal> is copied 1275bd8deadSopenharmony_ci in from vector location number 3. 1285bd8deadSopenharmony_ci 1295bd8deadSopenharmony_ci If the named vertex shader input has a scalar or vector type, it 1305bd8deadSopenharmony_ci will consume a single location. 1315bd8deadSopenharmony_ci 1325bd8deadSopenharmony_ci If the named vertex shader attribute is a matrix, it will be 1335bd8deadSopenharmony_ci assigned multiple locations starting with the location specified. 1345bd8deadSopenharmony_ci The number of locations assigned for each matrix will be equal to 1355bd8deadSopenharmony_ci the number of columns in the matrix For example, 1365bd8deadSopenharmony_ci 1375bd8deadSopenharmony_ci layout(location = 9) attribute mat4 transform; 1385bd8deadSopenharmony_ci 1395bd8deadSopenharmony_ci will establish that input <transform> is assigned to vector location 1405bd8deadSopenharmony_ci numbers 9-12. 1415bd8deadSopenharmony_ci 1425bd8deadSopenharmony_ci If an attribute variable with no location assigned in the shader 1435bd8deadSopenharmony_ci text has a location specified through the OpenGL ES API, the API- 1445bd8deadSopenharmony_ci assigned location will be used. Otherwise, such variables will be 1455bd8deadSopenharmony_ci assigned a location by the linker. See section 2.10.4 of the OpenGL 1465bd8deadSopenharmony_ci ES Specification for more details. 1475bd8deadSopenharmony_ci 1485bd8deadSopenharmony_ciErrors 1495bd8deadSopenharmony_ci 1505bd8deadSopenharmony_ci None, see issue #1. 1515bd8deadSopenharmony_ci 1525bd8deadSopenharmony_ciNew State 1535bd8deadSopenharmony_ci 1545bd8deadSopenharmony_ci None. 1555bd8deadSopenharmony_ci 1565bd8deadSopenharmony_ciNew Implementation Dependent State 1575bd8deadSopenharmony_ci 1585bd8deadSopenharmony_ci None. 1595bd8deadSopenharmony_ci 1605bd8deadSopenharmony_ciIssues 1615bd8deadSopenharmony_ci 1625bd8deadSopenharmony_ci 1. How should the error be reported when the attribute location 1635bd8deadSopenharmony_ci specified in the shader source is larger than MAX_VERTEX_ATTRIBUTES? 1645bd8deadSopenharmony_ci 1655bd8deadSopenharmony_ci RESOLVED. Generate a link error. The existing spec language already 1665bd8deadSopenharmony_ci covers this case: 1675bd8deadSopenharmony_ci 1685bd8deadSopenharmony_ci "LinkProgram will fail if the assigned binding of an active attribute 1695bd8deadSopenharmony_ci variable would cause the GL to reference a non-existent generic 1705bd8deadSopenharmony_ci attribute (one greater than or equal to MAX_VERTEX_ATTRIBS)." 1715bd8deadSopenharmony_ci 1725bd8deadSopenharmony_ci 2. What happens when the shader text binds an input to a 1735bd8deadSopenharmony_ci particular attribute location and the same attribute location is 1745bd8deadSopenharmony_ci bound to a different attribute via the API? 1755bd8deadSopenharmony_ci 1765bd8deadSopenharmony_ci RESOLVED. The setting in the shader is always used. 1775bd8deadSopenharmony_ci 1785bd8deadSopenharmony_ci 3. Should layout-qualifier-id be index or location? 1795bd8deadSopenharmony_ci 1805bd8deadSopenharmony_ci RESOLVED. location. The API uses both. <index> is used as the 1815bd8deadSopenharmony_ci parameter name to VertexAttribPointer and BindAttribLocation, but 1825bd8deadSopenharmony_ci "location" is used in the name of BindAttribLocation and 1835bd8deadSopenharmony_ci GetAttribLocation. However, there is some expectation that <index> may 1845bd8deadSopenharmony_ci be used for another purpose later. 1855bd8deadSopenharmony_ci 1865bd8deadSopenharmony_ci 4. The GL spec allows BindAttribLocation to be called before attaching 1875bd8deadSopenharmony_ci shaders or linking. If an application does this and specifies a 1885bd8deadSopenharmony_ci layout, which takes precedence? 1895bd8deadSopenharmony_ci 1905bd8deadSopenharmony_ci RESOLVED. The setting the shader is always used. 1915bd8deadSopenharmony_ci 1925bd8deadSopenharmony_ci The three options that were considered: 1935bd8deadSopenharmony_ci 1945bd8deadSopenharmony_ci a. The setting from the API, if specified, always wins. 1955bd8deadSopenharmony_ci 1965bd8deadSopenharmony_ci b. The setting from the shader, if specified, always wins. 1975bd8deadSopenharmony_ci 1985bd8deadSopenharmony_ci c. The setting is order dependent. If the shader is 1995bd8deadSopenharmony_ci attached after the API setting is made, the shader 2005bd8deadSopenharmony_ci layout is used. If the API setting is made after the 2015bd8deadSopenharmony_ci shader is attached, the API setting is used. 2025bd8deadSopenharmony_ci 2035bd8deadSopenharmony_ci 5. What happens if an input or output variable is declared in two 2045bd8deadSopenharmony_ci shader objects with conflicting attribute locations? 2055bd8deadSopenharmony_ci 2065bd8deadSopenharmony_ci RESOLVED. Not relevant to ES. 2075bd8deadSopenharmony_ci 2085bd8deadSopenharmony_ci 6. What happens if an input or output variable is declared in two 2095bd8deadSopenharmony_ci shader objects with an attribute location assigned in one shader but 2105bd8deadSopenharmony_ci not the other. 2115bd8deadSopenharmony_ci 2125bd8deadSopenharmony_ci RESOLVED. Not relevant to ES. 2135bd8deadSopenharmony_ci 2145bd8deadSopenharmony_ci 2155bd8deadSopenharmony_ciRevision History 2165bd8deadSopenharmony_ci 2175bd8deadSopenharmony_ci Rev. Date Author Changes 2185bd8deadSopenharmony_ci ---- ---------- --------- ------------------------------------ 2195bd8deadSopenharmony_ci 2 09/20/2013 dkoch minor edits for publishing 2205bd8deadSopenharmony_ci 1 04/25/2012 groth First revision based on 2215bd8deadSopenharmony_ci ARB_explicit_attrib_location. 222