15bd8deadSopenharmony_ciName 25bd8deadSopenharmony_ci 35bd8deadSopenharmony_ci ARB_explicit_uniform_location 45bd8deadSopenharmony_ci 55bd8deadSopenharmony_ciName Strings 65bd8deadSopenharmony_ci 75bd8deadSopenharmony_ci GL_ARB_explicit_uniform_location 85bd8deadSopenharmony_ci 95bd8deadSopenharmony_ciContact 105bd8deadSopenharmony_ci 115bd8deadSopenharmony_ci Piers Daniell, NVIDIA (pdaniell 'at' nvidia.com) 125bd8deadSopenharmony_ci 135bd8deadSopenharmony_ciContributors 145bd8deadSopenharmony_ci 155bd8deadSopenharmony_ci Bruce Merry 165bd8deadSopenharmony_ci Christophe Riccio, AMD 175bd8deadSopenharmony_ci Pat Brown, NVIDIA 185bd8deadSopenharmony_ci 195bd8deadSopenharmony_ciNotice 205bd8deadSopenharmony_ci 215bd8deadSopenharmony_ci Copyright (c) 2012-2013 The Khronos Group Inc. Copyright terms at 225bd8deadSopenharmony_ci http://www.khronos.org/registry/speccopyright.html 235bd8deadSopenharmony_ci 245bd8deadSopenharmony_ciSpecification Update Policy 255bd8deadSopenharmony_ci 265bd8deadSopenharmony_ci Khronos-approved extension specifications are updated in response to 275bd8deadSopenharmony_ci issues and bugs prioritized by the Khronos OpenGL Working Group. For 285bd8deadSopenharmony_ci extensions which have been promoted to a core Specification, fixes will 295bd8deadSopenharmony_ci first appear in the latest version of that core Specification, and will 305bd8deadSopenharmony_ci eventually be backported to the extension document. This policy is 315bd8deadSopenharmony_ci described in more detail at 325bd8deadSopenharmony_ci https://www.khronos.org/registry/OpenGL/docs/update_policy.php 335bd8deadSopenharmony_ci 345bd8deadSopenharmony_ciStatus 355bd8deadSopenharmony_ci 365bd8deadSopenharmony_ci Complete. 375bd8deadSopenharmony_ci Approved by the ARB on 2012/06/12. 385bd8deadSopenharmony_ci 395bd8deadSopenharmony_ciVersion 405bd8deadSopenharmony_ci 415bd8deadSopenharmony_ci Last Modified Date: 05/15/2012 425bd8deadSopenharmony_ci Revision: 6 435bd8deadSopenharmony_ci 445bd8deadSopenharmony_ciNumber 455bd8deadSopenharmony_ci 465bd8deadSopenharmony_ci ARB Extension #128 475bd8deadSopenharmony_ci 485bd8deadSopenharmony_ciDependencies 495bd8deadSopenharmony_ci 505bd8deadSopenharmony_ci Requires OpenGL 3.3 or ARB_explicit_attrib_location. 515bd8deadSopenharmony_ci 525bd8deadSopenharmony_ci This extension interacts with ARB_shader_subroutine. 535bd8deadSopenharmony_ci 545bd8deadSopenharmony_ci This extension is written against the OpenGL 4.2 (Compatibility Profile) 555bd8deadSopenharmony_ci and the OpenGL Shading Language 4.20.11 specification. 565bd8deadSopenharmony_ci 575bd8deadSopenharmony_ciOverview 585bd8deadSopenharmony_ci 595bd8deadSopenharmony_ci This extension provides a method to pre-assign uniform locations to 605bd8deadSopenharmony_ci uniform variables in the default uniform block, including subroutine 615bd8deadSopenharmony_ci uniforms. This allows an application to modify the uniform values without 625bd8deadSopenharmony_ci requiring a GL query like GetUniformLocation, GetSubroutineUniformLocation 635bd8deadSopenharmony_ci and GetSubroutineIndex. 645bd8deadSopenharmony_ci 655bd8deadSopenharmony_ciIP Status 665bd8deadSopenharmony_ci 675bd8deadSopenharmony_ci No known IP claims. 685bd8deadSopenharmony_ci 695bd8deadSopenharmony_ciNew Procedures and Functions 705bd8deadSopenharmony_ci 715bd8deadSopenharmony_ci None 725bd8deadSopenharmony_ci 735bd8deadSopenharmony_ciNew Tokens 745bd8deadSopenharmony_ci 755bd8deadSopenharmony_ci Accepted by the <pname> parameter of GetBooleanv, GetIntegerv, 765bd8deadSopenharmony_ci GetFloatv, GetDoublev, and GetInteger64v: 775bd8deadSopenharmony_ci 785bd8deadSopenharmony_ci MAX_UNIFORM_LOCATIONS 0x826E 795bd8deadSopenharmony_ci 805bd8deadSopenharmony_ciAdditions to Chapter 2 of the OpenGL 4.2 Specification (OpenGL Operation) 815bd8deadSopenharmony_ci 825bd8deadSopenharmony_ci Section 2.14.7 "Uniform Variables": 835bd8deadSopenharmony_ci 845bd8deadSopenharmony_ci Modify the third paragraph on page 114 to read: 855bd8deadSopenharmony_ci 865bd8deadSopenharmony_ci "When a program is successfully linked, all active uniforms, except for 875bd8deadSopenharmony_ci atomic counters, belonging to the program object's default uniform block 885bd8deadSopenharmony_ci are initialized as defined by the version of the OpenGL Shading Language 895bd8deadSopenharmony_ci used to compile the program. A successful link will also generate a 905bd8deadSopenharmony_ci location for any active uniform in the default uniform block which don't 915bd8deadSopenharmony_ci already have an explicit location defined in the shader. The generated 925bd8deadSopenharmony_ci locations will never take the location of a uniform with an explicit 935bd8deadSopenharmony_ci location defined in the shader, even if that uniform is determined to 945bd8deadSopenharmony_ci be inactive. The values of active uniforms in the default uniform block 955bd8deadSopenharmony_ci can be changed using this location and the appropriate Uniform* command 965bd8deadSopenharmony_ci (see below). These generated locations are invalidated and new ones 975bd8deadSopenharmony_ci assigned after each successful re-link. The explicitly defined locations 985bd8deadSopenharmony_ci and the generated locations must be in the range of 0 to 995bd8deadSopenharmony_ci MAX_UNIFORM_LOCATIONS minus one." 1005bd8deadSopenharmony_ci 1015bd8deadSopenharmony_ci Section 2.14.8 "Subroutine Uniform Variables": 1025bd8deadSopenharmony_ci 1035bd8deadSopenharmony_ci Modify the last paragraph on page 136 to read: 1045bd8deadSopenharmony_ci 1055bd8deadSopenharmony_ci "The command 1065bd8deadSopenharmony_ci 1075bd8deadSopenharmony_ci int GetSubroutineUniformLocation(uint program, enum shadertype, 1085bd8deadSopenharmony_ci const char *name); 1095bd8deadSopenharmony_ci 1105bd8deadSopenharmony_ci will return the location of the subroutine uniform variable <name> in the 1115bd8deadSopenharmony_ci shader stage of type <shadertype> attached to <program>, with behavior 1125bd8deadSopenharmony_ci otherwise identical to GetUniformLocation. The value -1 will be returned 1135bd8deadSopenharmony_ci if <name> is not the name of an active subroutine uniform. The subroutine 1145bd8deadSopenharmony_ci uniform may have an explicit location specified in the shader. At link 1155bd8deadSopenharmony_ci time, all active subroutine uniforms without an explicit location will be 1165bd8deadSopenharmony_ci assigned a unique location. The value ACTIVE_SUBROUTINE_UNIFORM_LOCATIONS 1175bd8deadSopenharmony_ci is the largest assigned or generated location plus one. An assigned 1185bd8deadSopenharmony_ci location will never take the location of an explicitly assigned location 1195bd8deadSopenharmony_ci in, even if that subroutine uniform is inactive. Between the location 0 1205bd8deadSopenharmony_ci and ACTIVE_SUBROUTINE_UNIFORM_LOCATIONS minus one there may be unused 1215bd8deadSopenharmony_ci locations either because they weren't assigned a subroutine uniform or 1225bd8deadSopenharmony_ci because the subroutine uniform was determined to be inactive by the 1235bd8deadSopenharmony_ci linker. These locations will be ignored when assigning the subroutine 1245bd8deadSopenharmony_ci index as described below. 1255bd8deadSopenharmony_ci 1265bd8deadSopenharmony_ci There is an implementation-dependent limit on the number of active 1275bd8deadSopenharmony_ci subroutine uniform locations in each shader stage; a program will fail 1285bd8deadSopenharmony_ci to link if the number of subroutine uniform locations required is greater 1295bd8deadSopenharmony_ci than the value of MAX_SUBROUTINE_UNIFORM_LOCATIONS or if an explicit 1305bd8deadSopenharmony_ci subroutine uniform location is outside this limit. If <program> has not 1315bd8deadSopenharmony_ci been successfully linked, the error INVALID_OPERATION will be generated. 1325bd8deadSopenharmony_ci For active subroutine uniforms declared as arrays, the declared array 1335bd8deadSopenharmony_ci elements are assigned consecutive locations. 1345bd8deadSopenharmony_ci 1355bd8deadSopenharmony_ci Each function in a shader associated with a subroutine type is considered 1365bd8deadSopenharmony_ci an active subroutine, unless the compiler conclusively determines that 1375bd8deadSopenharmony_ci the function could never be assigned to an active subroutine uniform. 1385bd8deadSopenharmony_ci The subroutine functions can be assigned an explicit index in the shader 1395bd8deadSopenharmony_ci between 0 and MAX_SUBROUTINES minus one. At link time, all active 1405bd8deadSopenharmony_ci subroutines without an explicit index will be assigned an index between 0 1415bd8deadSopenharmony_ci and ACTIVE_SUBROUTINES minus one. An assigned index will never take the 1425bd8deadSopenharmony_ci same index of an explicitly assigned index in the shader, even if that 1435bd8deadSopenharmony_ci subroutine is inactive. Between index 0 and ACTIVE_SUBROUTINES minus one 1445bd8deadSopenharmony_ci there may be unused indices either because they weren't assigned an 1455bd8deadSopenharmony_ci index by the linker or because the subroutine was determined to be 1465bd8deadSopenharmony_ci inactive by the linker. If there are no explicitly defined subroutine 1475bd8deadSopenharmony_ci indices in the shader the implementation must assign indices between 1485bd8deadSopenharmony_ci 0 and ACTIVE_SUBROUTINES minus one with no index unused. It is 1495bd8deadSopenharmony_ci recommended, but not required, the application assigns a range of tightly 1505bd8deadSopenharmony_ci packed indices starting from zero to avoid indices between 0 and 1515bd8deadSopenharmony_ci ACTIVE_SUBROUTINES minus one being unused. 1525bd8deadSopenharmony_ci 1535bd8deadSopenharmony_ci The index can be queried with the command: 1545bd8deadSopenharmony_ci 1555bd8deadSopenharmony_ci uint GetSubroutineIndex(uint program, enum shadertype, 1565bd8deadSopenharmony_ci const char *name); 1575bd8deadSopenharmony_ci 1585bd8deadSopenharmony_ci where name is the null-terminated name of a function in the shader stage 1595bd8deadSopenharmony_ci of type <shadertype> attached to <program>. The value INVALID_INDEX will 1605bd8deadSopenharmony_ci be returned if name is not the name of an active subroutine in the shader 1615bd8deadSopenharmony_ci stage. After the program has been linked, the subroutine index will not 1625bd8deadSopenharmony_ci change unless the program is re-linked." 1635bd8deadSopenharmony_ci 1645bd8deadSopenharmony_ci Modify the second paragraph on page 138 to read: 1655bd8deadSopenharmony_ci 1665bd8deadSopenharmony_ci "The name of an active subroutine can be queried given its subroutine 1675bd8deadSopenharmony_ci index with the command: 1685bd8deadSopenharmony_ci 1695bd8deadSopenharmony_ci void GetActiveSubroutineName(uint program, enum shadertype, uint index, 1705bd8deadSopenharmony_ci sizei bufsize, dizei *length, char *name); 1715bd8deadSopenharmony_ci 1725bd8deadSopenharmony_ci <program> and <shadertype> specify the program and shader stage. <index> 1735bd8deadSopenharmony_ci must be a subroutine index in the range from zero to the value of 1745bd8deadSopenharmony_ci ACTIVE_SUBROUTINES minus one for the shader stage. If <index> is greater 1755bd8deadSopenharmony_ci than or equal to the value of ACTIVE_SUBROUTINES, the error INVALID_VALUE 1765bd8deadSopenharmony_ci is generated. The name of the selected subroutine is returned as a null- 1775bd8deadSopenharmony_ci terminated string in name. The actual number of characters written into 1785bd8deadSopenharmony_ci name, excluding the null terminator, is returned in length. If length is 1795bd8deadSopenharmony_ci NULL, no length is returned. If the index refers to an unused subroutine 1805bd8deadSopenharmony_ci index, the string returned in <name> is an empty string and the length 1815bd8deadSopenharmony_ci returned is zero. ..." 1825bd8deadSopenharmony_ci 1835bd8deadSopenharmony_ci Modify the last paragraph on page 138 to read: 1845bd8deadSopenharmony_ci 1855bd8deadSopenharmony_ci "The command 1865bd8deadSopenharmony_ci 1875bd8deadSopenharmony_ci void UniformSubroutinesuiv(enum shadertype, sizei count, 1885bd8deadSopenharmony_ci const uint *indices); 1895bd8deadSopenharmony_ci 1905bd8deadSopenharmony_ci will load all active subroutine uniforms for shader stage <shadertype> 1915bd8deadSopenharmony_ci with subroutine indices from <indices>, storing <indices>[i] into the 1925bd8deadSopenharmony_ci uniform at location i. Any locations between 0 and 1935bd8deadSopenharmony_ci ACTIVE_SUBROUTINE_UNIFORM_LOCATIONS minus one which are not used will be 1945bd8deadSopenharmony_ci ignored. If <count> is not equal to the value of 1955bd8deadSopenharmony_ci ACTIVE_SUBROUTINE_UNIFORM_LOCATIONS for the program currently in use at 1965bd8deadSopenharmony_ci shader stage <shadertype>, or if the uniform at location i is used and 1975bd8deadSopenharmony_ci the value in <indices>[i] is greater than or equal to the value 1985bd8deadSopenharmony_ci of ACTIVE_SUBROUTINES for the shader stage, the error INVALID_VALUE is 1995bd8deadSopenharmony_ci generated. If the value of <indices>[i] for a used location specifies an 2005bd8deadSopenharmony_ci unused index the error INVALID_VALUE is generated. If, for any subroutine 2015bd8deadSopenharmony_ci index being loaded to a particular uniform location, the function 2025bd8deadSopenharmony_ci corresponding to the subroutine index was not associated (as defined in 2035bd8deadSopenharmony_ci section 6.1.2 of the OpenGL Shading Language Specification) with the type 2045bd8deadSopenharmony_ci of the subroutine variable at that location, then the error 2055bd8deadSopenharmony_ci INVALID_OPERATION is generated. If no program is active, the error 2065bd8deadSopenharmony_ci INVALID_OPERATION is generated." 2075bd8deadSopenharmony_ci 2085bd8deadSopenharmony_ciAdditions to Chapter 6 of the OpenGL 4.2 Specification (OpenGL Operation) 2095bd8deadSopenharmony_ci 2105bd8deadSopenharmony_ci Section 6.1.18 "Shader and Program Queries": 2115bd8deadSopenharmony_ci 2125bd8deadSopenharmony_ci Modify the second paragraph on page 501: 2135bd8deadSopenharmony_ci 2145bd8deadSopenharmony_ci "The command 2155bd8deadSopenharmony_ci 2165bd8deadSopenharmony_ci void GetUniformSubroutineuiv(enum shadertype, int location, uint *params); 2175bd8deadSopenharmony_ci 2185bd8deadSopenharmony_ci returns the value of the subroutine uniform at location <location> for 2195bd8deadSopenharmony_ci shader stage <shadertype> of the current program. If <location> is 2205bd8deadSopenharmony_ci greater than or equal to the value of ACTIVE_SUBROUTINE_UNIFORM_LOCATIONS 2215bd8deadSopenharmony_ci for the shader currently in use at shader stage <shadertype>, the error 2225bd8deadSopenharmony_ci INVALID_VALUE is generated. If <location> represents an unused location, 2235bd8deadSopenharmony_ci the value INVALID_INDEX is returned and no error is generated. If no 2245bd8deadSopenharmony_ci program is active, the error INVALID_OPERATION is generated." 2255bd8deadSopenharmony_ci 2265bd8deadSopenharmony_ciAdditions to the AGL/GLX/WGL Specifications 2275bd8deadSopenharmony_ci 2285bd8deadSopenharmony_ci None. 2295bd8deadSopenharmony_ci 2305bd8deadSopenharmony_ciDependencies on ARB_shader_subroutine 2315bd8deadSopenharmony_ci 2325bd8deadSopenharmony_ci If ARB_shader_subroutine is not supported, remove all references to 2335bd8deadSopenharmony_ci subroutine uniform locations and subroutine indices. 2345bd8deadSopenharmony_ci 2355bd8deadSopenharmony_ciGLX protocol 2365bd8deadSopenharmony_ci 2375bd8deadSopenharmony_ci None 2385bd8deadSopenharmony_ci 2395bd8deadSopenharmony_ciErrors 2405bd8deadSopenharmony_ci 2415bd8deadSopenharmony_ci INVALID_VALUE is generated if an unused index is assigned to an 2425bd8deadSopenharmony_ci active and used subroutine uniform variable by UniformSubroutinesuiv. 2435bd8deadSopenharmony_ci 2445bd8deadSopenharmony_ciNew State 2455bd8deadSopenharmony_ci 2465bd8deadSopenharmony_ci None 2475bd8deadSopenharmony_ci 2485bd8deadSopenharmony_ciNew Implementation Dependent State 2495bd8deadSopenharmony_ci 2505bd8deadSopenharmony_ci Changes to table 6.64, p. 568 (Implementation Dependent Values) 2515bd8deadSopenharmony_ci 2525bd8deadSopenharmony_ci Minimum 2535bd8deadSopenharmony_ci Get Value Type Get Command Value Description Sec. Attribute 2545bd8deadSopenharmony_ci --------- ---- ----------- ------- ----------- ---- --------- 2555bd8deadSopenharmony_ci MAX_UNIFORM_LOCATIONS Z+ GetIntegerv 1024 Maximum number of user- 2.14.7 - 2565bd8deadSopenharmony_ci assignable uniform locations 2575bd8deadSopenharmony_ci 2585bd8deadSopenharmony_ciModifications to The OpenGL Shading Language Specification, Version 4.20.06 2595bd8deadSopenharmony_ci 2605bd8deadSopenharmony_ci Including the following line in a shader can be used to control 2615bd8deadSopenharmony_ci the language feature described in thie extension: 2625bd8deadSopenharmony_ci 2635bd8deadSopenharmony_ci #extension GL_ARB_explicit_uniform_location : <behavior> 2645bd8deadSopenharmony_ci 2655bd8deadSopenharmony_ci where <behavior> is as described in section 3.3. 2665bd8deadSopenharmony_ci 2675bd8deadSopenharmony_ci A new preprocessor #define is added to the OpenGL Shading Language: 2685bd8deadSopenharmony_ci 2695bd8deadSopenharmony_ci #define GL_ARB_explicit_uniform_location 1 2705bd8deadSopenharmony_ci 2715bd8deadSopenharmony_ci Insert a new section called 4.4.3 "Uniform Variable Layout Qualifiers": 2725bd8deadSopenharmony_ci 2735bd8deadSopenharmony_ci "Layout qualifiers can be used for uniform variables and subroutine 2745bd8deadSopenharmony_ci uniforms. The layout qualifier identifiers for uniform variables and 2755bd8deadSopenharmony_ci subroutine uniforms are: 2765bd8deadSopenharmony_ci layout-qualifier-id 2775bd8deadSopenharmony_ci location = integer-constant 2785bd8deadSopenharmony_ci 2795bd8deadSopenharmony_ci The location idenifier can be used with default-block uniform 2805bd8deadSopenharmony_ci variables and subroutine uniforms. The location specifies the 2815bd8deadSopenharmony_ci location by which the OpenGL API can reference the uniform and update its value. 2825bd8deadSopenharmony_ci Individual elements of a uniform array are assigned consecutive locations 2835bd8deadSopenharmony_ci with the first element taking location <location>. No two default-block 2845bd8deadSopenharmony_ci uniform variables in the program can have the same location, even if they 2855bd8deadSopenharmony_ci are unused, otherwise a compiler or linker error will be generated. No two 2865bd8deadSopenharmony_ci subroutine uniform variables can have the same location in the same shader 2875bd8deadSopenharmony_ci stage, otherwise a compiler or linker error will be generated. Valid 2885bd8deadSopenharmony_ci locations for default-block uniform variable locations are in the range of 2895bd8deadSopenharmony_ci 0 to the implementation-defined maximum number of uniform locations. Valid 2905bd8deadSopenharmony_ci locations for subroutine uniforms are in the range of 0 to the 2915bd8deadSopenharmony_ci implementation-defined per-stage maximum number of subroutine uniform 2925bd8deadSopenharmony_ci locations minus one. 2935bd8deadSopenharmony_ci 2945bd8deadSopenharmony_ci Locations can be assigned to default-block uniform arrays and structures. 2955bd8deadSopenharmony_ci The first inner-most scalar, vector or matrix member or element takes the 2965bd8deadSopenharmony_ci specified <location> and the compiler assigns the next inner-most member 2975bd8deadSopenharmony_ci or element the next incremental location value. Each subsequent inner-most 2985bd8deadSopenharmony_ci member or element gets incremental locations for the entire structure or 2995bd8deadSopenharmony_ci array. This rule applies to nested structures and arrays and gives each 3005bd8deadSopenharmony_ci inner-most scalar, vector, or matrix type a unique location. For arrays 3015bd8deadSopenharmony_ci without an explicit size, the size is calculated based on its static 3025bd8deadSopenharmony_ci usage. When the linker generates locations for uniforms without an 3035bd8deadSopenharmony_ci explicit location, it assumes for all uniforms with an explicit location 3045bd8deadSopenharmony_ci all their array elements and structure members are used and the linker 3055bd8deadSopenharmony_ci will not generate a conflicting location, even if that element of member 3065bd8deadSopenharmony_ci is deemed unused." 3075bd8deadSopenharmony_ci 3085bd8deadSopenharmony_ci Insert a new section called 4.4.4 "Subroutine Function Layout Qualifiers": 3095bd8deadSopenharmony_ci 3105bd8deadSopenharmony_ci "Layout qualifiers can be used for subroutine functions. The layout 3115bd8deadSopenharmony_ci qualifier identifiers for subroutine functions are: 3125bd8deadSopenharmony_ci layout-qualifier-id 3135bd8deadSopenharmony_ci index = integer-constant 3145bd8deadSopenharmony_ci 3155bd8deadSopenharmony_ci Each subroutine with an index qualifier in the shader must be given 3165bd8deadSopenharmony_ci a unique index, otherwise a compile or link error will be generated. The 3175bd8deadSopenharmony_ci indices must be in the range of 0 to the implementation defined maximum 3185bd8deadSopenharmony_ci number of subroutines minus one. It's recommended, but not required, that 3195bd8deadSopenharmony_ci the shader assigns a range of tightly packed <index> values starting 3205bd8deadSopenharmony_ci from zero so that the GL subroutine function enumeration API returns a 3215bd8deadSopenharmony_ci non-empty name for all active indices." 3225bd8deadSopenharmony_ci 3235bd8deadSopenharmony_ciIssues 3245bd8deadSopenharmony_ci 3255bd8deadSopenharmony_ci 1) Can the application mix uniforms with explicit locations with 3265bd8deadSopenharmony_ci regular uniforms without explicit locations? 3275bd8deadSopenharmony_ci 3285bd8deadSopenharmony_ci RESOLVED: Yes, uniform locations assigned automatically at link time 3295bd8deadSopenharmony_ci will not alias any uniform with explicit locations, even if those 3305bd8deadSopenharmony_ci uniforms are inactive. 3315bd8deadSopenharmony_ci 3325bd8deadSopenharmony_ci 2) Can the application mix subroutine uniforms with explicit locations 3335bd8deadSopenharmony_ci with subroutine uniforms without explicit locations? Also, can the 3345bd8deadSopenharmony_ci application mix subroutines with explicit indices with subroutines 3355bd8deadSopenharmony_ci without an index specified. 3365bd8deadSopenharmony_ci 3375bd8deadSopenharmony_ci RESOLVED: Yes, any subroutine uniforms without an explicit location 3385bd8deadSopenharmony_ci will be assigned a location between 0 and 3395bd8deadSopenharmony_ci ACTIVE_UNIFORM_SUBROUTINE_LOCATIONS minus 1 with a location that 3405bd8deadSopenharmony_ci has not been used by the shader, regardless of whether it refers 3415bd8deadSopenharmony_ci to a subroutine uniform that is unused. The value of 3425bd8deadSopenharmony_ci ACTIVE_UNIFORM_SUBROUTINE_LOCATIONS is calculated as the max of 3435bd8deadSopenharmony_ci the explicit location and automatically assigned location. If 3445bd8deadSopenharmony_ci there are unused locations between 0 and 3455bd8deadSopenharmony_ci ACTIVE_UNIFORM_SUBROUTINE_LOCATION, these will be ignored by 3465bd8deadSopenharmony_ci UniformSubroutinesiv(). Similarily with the subroutine 3475bd8deadSopenharmony_ci indices, the linker will allocate unused indices to the subroutines 3485bd8deadSopenharmony_ci without an explicit index and the value of ACTIVE_SUBROUTINES 3495bd8deadSopenharmony_ci will be the max of the largest explicit index and the linker 3505bd8deadSopenharmony_ci assigned index. There may be unused indices between 0 and 3515bd8deadSopenharmony_ci ACTIVE_SUBROUTINES minus 1 and UniformSubroutinesiv() will return 3525bd8deadSopenharmony_ci an error if the app attempts to use an unused index with an active 3535bd8deadSopenharmony_ci and used subroutine uniform. 3545bd8deadSopenharmony_ci 3555bd8deadSopenharmony_ci 3) How should an application determine unique default-block uniform 3565bd8deadSopenharmony_ci variable locations? 3575bd8deadSopenharmony_ci 3585bd8deadSopenharmony_ci RESOLVED: Each transparent basic-type uniform variable consumes exactly 3595bd8deadSopenharmony_ci one location, regarless of it's type. Transparent basic-types, as defined 3605bd8deadSopenharmony_ci in section 4.1 are booleans, integers, floats, doubles, vectors and 3615bd8deadSopenharmony_ci matrices. An array of basic-type uniforms consumes consecutive locations, 3625bd8deadSopenharmony_ci incrementing by one for each consecutive element. Structures of 3635bd8deadSopenharmony_ci basic-type uniforms assign consecutive locations to each member 3645bd8deadSopenharmony_ci where the first base member takes the first location. These rules apply 3655bd8deadSopenharmony_ci recursively to nested structures and arrays assigning consecutive 3665bd8deadSopenharmony_ci locations each consecutive basic-type variable. 3675bd8deadSopenharmony_ci 3685bd8deadSopenharmony_ci Any uniform variables without an explicit location assigned will be 3695bd8deadSopenharmony_ci assigned a unique location by the linker. It's implementation defined 3705bd8deadSopenharmony_ci what locations the linker chooses for these variables, the only 3715bd8deadSopenharmony_ci requirement being that these generated locations do not alias any 3725bd8deadSopenharmony_ci explicitly defined locations. 3735bd8deadSopenharmony_ci 3745bd8deadSopenharmony_ci Note that subroutine uniform variables are not in the same namespace 3755bd8deadSopenharmony_ci as default-block uniform variables. Subroutine uniform locations 3765bd8deadSopenharmony_ci are per shader stage rather than per program and they are referenced 3775bd8deadSopenharmony_ci through a different API so can have the same locations as uniform 3785bd8deadSopenharmony_ci variables. 3795bd8deadSopenharmony_ci 3805bd8deadSopenharmony_ci 4) What happens if Uniform* is called with an explicitly defined 3815bd8deadSopenharmony_ci uniform location, but that uniform is deemed inactive by the 3825bd8deadSopenharmony_ci linker? 3835bd8deadSopenharmony_ci 3845bd8deadSopenharmony_ci RESOLVED: The call is ignored for inactive uniform variables and 3855bd8deadSopenharmony_ci no error is generated. Uniforms without an explicit location that 3865bd8deadSopenharmony_ci are determined to be inactive return -1 for the the location when 3875bd8deadSopenharmony_ci GetUniformLocation is queried. Calling Uniform* with a location 3885bd8deadSopenharmony_ci of -1 is also ignored. That behavior isn't changed. 3895bd8deadSopenharmony_ci 3905bd8deadSopenharmony_ci 5) What is the value of ACTIVE_SUBROUTINE_UNIFORM_LOCATIONS after 3915bd8deadSopenharmony_ci successfully compiling and linking a program? 3925bd8deadSopenharmony_ci 3935bd8deadSopenharmony_ci RESOLVED: The value of ACTIVE_SUBROUTINE_UNIFORM_LOCATIONS is 3945bd8deadSopenharmony_ci calculated per shader stage to be the max of the explicitly 3955bd8deadSopenharmony_ci defined subroutine uniform variable locations and the generated 3965bd8deadSopenharmony_ci locations for subroutine uniform variables without a defined 3975bd8deadSopenharmony_ci location. The consequence of this is that there will be some 3985bd8deadSopenharmony_ci locations between 0 and ACTIVE_SUBROUTINE_UNIFORM_LOCATIONS minus one 3995bd8deadSopenharmony_ci that are unused. UniformSubroutinesuiv ignores index entries for 4005bd8deadSopenharmony_ci unused locations. 4015bd8deadSopenharmony_ci 4025bd8deadSopenharmony_ci 6) Does the application need to query ACTIVE_SUBROUTINE_UNIFORM_LOCATIONS 4035bd8deadSopenharmony_ci to figure out the <count> parameter to UniformSubroutine? 4045bd8deadSopenharmony_ci 4055bd8deadSopenharmony_ci RESOLVED: No, it doesn't have to. If the application knows the shader 4065bd8deadSopenharmony_ci source and it only uses explicit subroutine uniform variables locations 4075bd8deadSopenharmony_ci it can figure out ACTIVE_SUBROUTINE_UNIFORM_LOCATIONS by simply taking the 4085bd8deadSopenharmony_ci maximum location defined plus one. If there are generated subroutine 4095bd8deadSopenharmony_ci uniform locations the application will need to query 4105bd8deadSopenharmony_ci ACTIVE_SUBROUTINE_UNIFORM_LOCATIONS like before. 4115bd8deadSopenharmony_ci 4125bd8deadSopenharmony_ci 7) What is the value of ACTIVE_SUBROUTINES after successfully compiling 4135bd8deadSopenharmony_ci and linking a program? 4145bd8deadSopenharmony_ci 4155bd8deadSopenharmony_ci RESOLVED: The value of ACTIVE_SUBROUTINES is calculated per shader 4165bd8deadSopenharmony_ci stage to be the max of the explicitly defined subroutine index 4175bd8deadSopenharmony_ci values and the generated indices for subroutines without a defined 4185bd8deadSopenharmony_ci index. The consequence of this is that there will be some invalid 4195bd8deadSopenharmony_ci indices between 0 and ACTIVE_SUBROUTINES minus one which don't 4205bd8deadSopenharmony_ci reference any subroutine. If GetActiveSubroutineName is called with 4215bd8deadSopenharmony_ci one of these unused indices, no error is generated but the <name> 4225bd8deadSopenharmony_ci returned will be an empty string and the <length> will be zero. 4235bd8deadSopenharmony_ci 4245bd8deadSopenharmony_ci 8) Does the query for ACTIVE_UNIFORMS in the program include inactive 4255bd8deadSopenharmony_ci uniform variables with explicit locations? 4265bd8deadSopenharmony_ci 4275bd8deadSopenharmony_ci RESOLVED: No, only the active default-block uniforms are included in 4285bd8deadSopenharmony_ci this count. It's only the <location> of inactive uniform variables that 4295bd8deadSopenharmony_ci can be used with existing GL fuctions like Uniform*, UniformMatrix*, 4305bd8deadSopenharmony_ci ProgramUniform*, etc. and are ignored. Otherwise these inactive uniforms 4315bd8deadSopenharmony_ci operate like they did before this extension. 4325bd8deadSopenharmony_ci 4335bd8deadSopenharmony_ci 9) Should we introduce the concept of "location" in addition to the 4345bd8deadSopenharmony_ci existing "index" for subroutine functions? This would make it more 4355bd8deadSopenharmony_ci consistent with regular uniforms. You would use the "index" property 4365bd8deadSopenharmony_ci for the purposes of enumerating the enties with GetActiveSubroutineName 4375bd8deadSopenharmony_ci and "location" for the purposes of UniformSubroutinesuiv. This will 4385bd8deadSopenharmony_ci avoid the issue of GetActiveSubroutineName having possibly empty 4395bd8deadSopenharmony_ci strings returned for indices between 0 and ACTIVE_SUBROUTINES-1. 4405bd8deadSopenharmony_ci 4415bd8deadSopenharmony_ci RESOLVED: No, not at this time. The downside of introducing a "location" 4425bd8deadSopenharmony_ci property is that we'll need to introduce a new function called 4435bd8deadSopenharmony_ci GetSubroutineLocation, which would return an "int" where -1 means 4445bd8deadSopenharmony_ci invalid location, and then use these values instead of indexes with 4455bd8deadSopenharmony_ci UniformSubroutinesuiv. Unfortunately, UniformSubroutinesuiv takes 4465bd8deadSopenharmony_ci an array of "uints". Also, it would be quite confusing to have both 4475bd8deadSopenharmony_ci GetSubroutineLocation and GetSubroutineIndex, especially for existing 4485bd8deadSopenharmony_ci apps that already used GetSubroutineIndex. It would be tricky to 4495bd8deadSopenharmony_ci specify which should be used and tricky the support the transition 4505bd8deadSopenharmony_ci of apps between OpenGL 4.2 and OpenGL 4.3 usage. And that complexity 4515bd8deadSopenharmony_ci feels less attractive than the benefit of solving the enumeration 4525bd8deadSopenharmony_ci issue. Apps that tightly pack their index assignments won't have 4535bd8deadSopenharmony_ci a problem so in practice a holey enumeration would be an app choice. 4545bd8deadSopenharmony_ci 4555bd8deadSopenharmony_ciRevision History 4565bd8deadSopenharmony_ci 4575bd8deadSopenharmony_ci Rev. Date Author Changes 4585bd8deadSopenharmony_ci ---- -------- -------- ----------------------------------------------- 4595bd8deadSopenharmony_ci 6 05/15/12 pdaniell Fix the Errors section to match the added 4605bd8deadSopenharmony_ci spec language. 4615bd8deadSopenharmony_ci 4625bd8deadSopenharmony_ci 5 04/26/12 pdaniell Add issue #9 and resolve all issues based on 4635bd8deadSopenharmony_ci Dublin face to face discussion. Minor edits 4645bd8deadSopenharmony_ci based on feedback from criccio. 4655bd8deadSopenharmony_ci 4665bd8deadSopenharmony_ci 4 04/25/12 pdaniell Edits based on feedback from pbrown. 4675bd8deadSopenharmony_ci 4685bd8deadSopenharmony_ci 3 04/24/12 pdaniell Further improvements and clarifications. Add 4695bd8deadSopenharmony_ci MAX_UNIFORM_LOCATIONS. 4705bd8deadSopenharmony_ci 4715bd8deadSopenharmony_ci 2 04/23/12 pdaniell Fixes and improvements based on bmerry's 4725bd8deadSopenharmony_ci feedback and discussions with pbrown. Add 4735bd8deadSopenharmony_ci new issues. 4745bd8deadSopenharmony_ci 4755bd8deadSopenharmony_ci 1 10/26/11 pdaniell Initial version. 476