15bd8deadSopenharmony_ciName 25bd8deadSopenharmony_ci 35bd8deadSopenharmony_ci IMG_bindless_texture 45bd8deadSopenharmony_ci 55bd8deadSopenharmony_ciName Strings 65bd8deadSopenharmony_ci 75bd8deadSopenharmony_ci GL_IMG_bindless_texture 85bd8deadSopenharmony_ci 95bd8deadSopenharmony_ciContact 105bd8deadSopenharmony_ci 115bd8deadSopenharmony_ci Tobias Hector (tobias.hector 'at' imgtec.com) 125bd8deadSopenharmony_ci 135bd8deadSopenharmony_ciContributors 145bd8deadSopenharmony_ci 155bd8deadSopenharmony_ci Contributors to the original ARB_bindless_texture 165bd8deadSopenharmony_ci 175bd8deadSopenharmony_ciNotice 185bd8deadSopenharmony_ci 195bd8deadSopenharmony_ci Copyright (c) 2013 The Khronos Group Inc. Copyright terms at 205bd8deadSopenharmony_ci http://www.khronos.org/registry/speccopyright.html 215bd8deadSopenharmony_ci 225bd8deadSopenharmony_ciStatus 235bd8deadSopenharmony_ci 245bd8deadSopenharmony_ci Draft 255bd8deadSopenharmony_ci 265bd8deadSopenharmony_ciVersion 275bd8deadSopenharmony_ci 285bd8deadSopenharmony_ci Last Modified Date: May 23, 2016 295bd8deadSopenharmony_ci Author Revision: 4 305bd8deadSopenharmony_ci 315bd8deadSopenharmony_ciNumber 325bd8deadSopenharmony_ci 335bd8deadSopenharmony_ci OpenGL ES Extension #270 345bd8deadSopenharmony_ci 355bd8deadSopenharmony_ciDependencies 365bd8deadSopenharmony_ci 375bd8deadSopenharmony_ci OpenGL ES 3.1 is required. 385bd8deadSopenharmony_ci 395bd8deadSopenharmony_ci This extension is written against the OpenGL ES Shading Language 405bd8deadSopenharmony_ci specification, Language Version 3.10, Document Revision 3 and the 415bd8deadSopenharmony_ci OpenGL ES 3.1 API specification. 425bd8deadSopenharmony_ci 435bd8deadSopenharmony_ci This extension interacts with EXT/OES_gpu_shader5. 445bd8deadSopenharmony_ci 455bd8deadSopenharmony_ci This extension interacts with EXT/OES_texture_buffer and EXT_buffer_storage. 465bd8deadSopenharmony_ci 475bd8deadSopenharmony_ci This extension interacts with OpenGL ES 3.2 485bd8deadSopenharmony_ci 495bd8deadSopenharmony_ciOverview 505bd8deadSopenharmony_ci 515bd8deadSopenharmony_ci This extension allows OpenGL ES applications to access texture objects in 525bd8deadSopenharmony_ci shaders without first binding each texture to one of a limited number of 535bd8deadSopenharmony_ci texture image units. Using this extension, an application can query a 545bd8deadSopenharmony_ci 64-bit unsigned integer texture handle for each texture that it wants to 555bd8deadSopenharmony_ci access and then use that handle directly in GLSL ES. This extensions 565bd8deadSopenharmony_ci significantly reduces the amount of API and internal GL driver overhead 575bd8deadSopenharmony_ci needed to manage resource bindings. 585bd8deadSopenharmony_ci 595bd8deadSopenharmony_ci This extension adds no new data types to GLSL. Instead, it uses existing 605bd8deadSopenharmony_ci sampler data types and allows them to be populated with texture handles. 615bd8deadSopenharmony_ci This extension also permits sampler types to be used as uniform block 625bd8deadSopenharmony_ci members as well as default uniforms. Additionally, new APIs are provided to 635bd8deadSopenharmony_ci load values for sampler uniforms with 64-bit handle inputs. The use of 645bd8deadSopenharmony_ci existing integer-based Uniform* APIs is still permitted, in which case the 655bd8deadSopenharmony_ci integer specified will identify a texture image. For samplers with values 665bd8deadSopenharmony_ci specified as texture image units, the GL implementation will translate the 675bd8deadSopenharmony_ci unit number to an internal handle as required. 685bd8deadSopenharmony_ci 695bd8deadSopenharmony_ciNew Procedures and Functions 705bd8deadSopenharmony_ci 715bd8deadSopenharmony_ci uint64 GetTextureHandleIMG(uint texture); 725bd8deadSopenharmony_ci uint64 GetTextureSamplerHandleIMG(uint texture, uint sampler); 735bd8deadSopenharmony_ci 745bd8deadSopenharmony_ci void UniformHandleui64IMG(int location, uint64 value); 755bd8deadSopenharmony_ci void UniformHandleui64vIMG(int location, sizei count, const uint64 *value); 765bd8deadSopenharmony_ci 775bd8deadSopenharmony_ci void ProgramUniformHandleui64IMG(uint program, int location, 785bd8deadSopenharmony_ci uint64 value); 795bd8deadSopenharmony_ci void ProgramUniformHandleui64vIMG(uint program, int location, 805bd8deadSopenharmony_ci sizei count, const uint64 *values); 815bd8deadSopenharmony_ci 825bd8deadSopenharmony_ciNew Tokens 835bd8deadSopenharmony_ci 845bd8deadSopenharmony_ci None 855bd8deadSopenharmony_ci 865bd8deadSopenharmony_ciAdditions to Chapter 5 of the OpenGL ES 3.1 API Specification, "Shared Objects 875bd8deadSopenharmony_ciand Multiple Contexts" 885bd8deadSopenharmony_ci 895bd8deadSopenharmony_ci Insert a new section 5.4, "Object use by GPU Handles" 905bd8deadSopenharmony_ci 915bd8deadSopenharmony_ci GPU handles to objects are valid in all contexts in the share group that 925bd8deadSopenharmony_ci the originating object belongs to, irrespective of whether the object 935bd8deadSopenharmony_ci itself is shared. If the originating object for a handle is deleted or 945bd8deadSopenharmony_ci becomes otherwise invalid, the handle becomes immediately invalid in all 955bd8deadSopenharmony_ci contexts. Using an invalid handle can lead to undefined results, 965bd8deadSopenharmony_ci including program termination. 975bd8deadSopenharmony_ci 985bd8deadSopenharmony_ciAdditions to Chapter 7 of the OpenGL ES 3.1 API Specification, "Variables and 995bd8deadSopenharmony_ciTypes" 1005bd8deadSopenharmony_ci 1015bd8deadSopenharmony_ci Add the following sentence to Section 7.6, Uniform Variables, immediately 1025bd8deadSopenharmony_ci before the error block on page 97: 1035bd8deadSopenharmony_ci 1045bd8deadSopenharmony_ci A sampler uniform will consume no more than 2 components. 1055bd8deadSopenharmony_ci 1065bd8deadSopenharmony_ci Add the following commands to the list of Uniform* functions in section 1075bd8deadSopenharmony_ci 7.6.1, Loading Uniform Variables in the Default Uniform Block: 1085bd8deadSopenharmony_ci 1095bd8deadSopenharmony_ci void UniformHandleui64IMG(int location, uint64 value); 1105bd8deadSopenharmony_ci void UniformHandleui64vIMG(int location, sizei count, 1115bd8deadSopenharmony_ci const uint64 *value); 1125bd8deadSopenharmony_ci 1135bd8deadSopenharmony_ci Delete the sentence "Only the Uniform1i{v} commands can be used to load 1145bd8deadSopenharmony_ci sampler values (see section 7.9)", and add the following paragraph: 1155bd8deadSopenharmony_ci 1165bd8deadSopenharmony_ci The UniformHandleui64{v}IMG commands will load <count> 64-bit unsigned 1175bd8deadSopenharmony_ci integer handles into a uniform location corresponding to sampler types. 1185bd8deadSopenharmony_ci Only the UniformHandleui64{v}IMG and Uniform1i{v} commands can be used 1195bd8deadSopenharmony_ci to load sampler values (see section 7.9). 1205bd8deadSopenharmony_ci 1215bd8deadSopenharmony_ci Add the following error condition to the list of errors for Uniform* 1225bd8deadSopenharmony_ci functions: 1235bd8deadSopenharmony_ci 1245bd8deadSopenharmony_ci An INVALID_OPERATION error is generated if the UniformHandleui64{v}IMG 1255bd8deadSopenharmony_ci commands are used on a sampler variable with the "bound_sampler" layout 1265bd8deadSopenharmony_ci qualifier (see the Language specification, section 4.4.5bindless). 1275bd8deadSopenharmony_ci 1285bd8deadSopenharmony_ci Add the following commands to the list of ProgramUniform* functions in 1295bd8deadSopenharmony_ci section 7.6.1, Loading Uniform Variables in the Default Uniform Block: 1305bd8deadSopenharmony_ci 1315bd8deadSopenharmony_ci void ProgramUniformHandleui64IMG(uint program, int location, 1325bd8deadSopenharmony_ci uint64 value); 1335bd8deadSopenharmony_ci void ProgramUniformHandleui64vIMG(uint program, int location, 1345bd8deadSopenharmony_ci sizei count, const uint64 *values); 1355bd8deadSopenharmony_ci 1365bd8deadSopenharmony_ci Edit section 7.6.2.1, "Uniform Buffer Object Storage", to add the following 1375bd8deadSopenharmony_ci rules for sampler types to the list at the beginning of p105: 1385bd8deadSopenharmony_ci 1395bd8deadSopenharmony_ci * Members of sampler types are extracted from a buffer object by 1405bd8deadSopenharmony_ci reading a single 64-bit value at the specified offset. 1415bd8deadSopenharmony_ci 1425bd8deadSopenharmony_ci Replace Section 7.9, Samplers, with the following, adding the ability to use 1435bd8deadSopenharmony_ci samplers in new places as well as describing the behavior of the new 1445bd8deadSopenharmony_ci UniformHandleui64{v}IMG APIs: 1455bd8deadSopenharmony_ci 1465bd8deadSopenharmony_ci Samplers are special data types used by the OpenGL ES Shading Language to 1475bd8deadSopenharmony_ci identify the texture object used for each texture lookup. Sampler 1485bd8deadSopenharmony_ci variables may be used as uniforms in the default block or in user-defined 1495bd8deadSopenharmony_ci blocks. 1505bd8deadSopenharmony_ci 1515bd8deadSopenharmony_ci When used as uniforms in the default block, the value of sampler 1525bd8deadSopenharmony_ci variables may be specified with either Uniform1i{v} or 1535bd8deadSopenharmony_ci UniformHandleui64{v}IMG. If a sampler uniform value is specified by 1545bd8deadSopenharmony_ci Uniform1i{v}, the value passed to Uniform1i{v} indicates a texture image 1555bd8deadSopenharmony_ci unit that will be accessed, and the value must be in the range from zero 1565bd8deadSopenharmony_ci to the implementation-dependent maximum supported number of texture image 1575bd8deadSopenharmony_ci units. If a sampler uniform value is specified by UniformHandleui64{v}IMG, 1585bd8deadSopenharmony_ci the value passed to UniformHandleui64{v}IMG directly specifies a texture 1595bd8deadSopenharmony_ci object by handle, as defined in Section 8.2bindless (Bindless Textures). 1605bd8deadSopenharmony_ci When a program is linked, all sampler uniforms are initialized to zero and 1615bd8deadSopenharmony_ci considered to be references to texture image units. When used as uniform 1625bd8deadSopenharmony_ci block members, the value of the sampler is a 64-bit unsigned integer handle 1635bd8deadSopenharmony_ci and never refers to a texture image unit. 1645bd8deadSopenharmony_ci 1655bd8deadSopenharmony_ci When the value of a sampler indicates a texture image unit, the type of 1665bd8deadSopenharmony_ci the sampler identifies the target on the texture image unit. The texture 1675bd8deadSopenharmony_ci object bound to that texture image unit's target is used for any texture 1685bd8deadSopenharmony_ci accesses using that sampler. For example, a variable of type sampler2D 1695bd8deadSopenharmony_ci selects the target TEXTURE_2D on its texture image unit. Binding of 1705bd8deadSopenharmony_ci texture objects to targets is done as usual with BindTexture. Selecting 1715bd8deadSopenharmony_ci the texture image unit to bind to is done as usual with ActiveTexture. 1725bd8deadSopenharmony_ci 1735bd8deadSopenharmony_ci When the value of a sampler indicates a texture handle, the target of the 1745bd8deadSopenharmony_ci texture referred to by the handle must match the type of the sampler. For 1755bd8deadSopenharmony_ci example, a variable of type sampler2D must be used in conjunction with a 1765bd8deadSopenharmony_ci handle of a texture of target TEXTURE_2D. If the value of a sampler 1775bd8deadSopenharmony_ci variable is not a valid texture handle, the results of using that sampler 1785bd8deadSopenharmony_ci during shader execution are undefined and may lead to program termination. 1795bd8deadSopenharmony_ci If the value of a sampler variable is a valid handle of a texture with a 1805bd8deadSopenharmony_ci target different from the variable type, the results of using that handle 1815bd8deadSopenharmony_ci are undefined but may not include program termination. 1825bd8deadSopenharmony_ci 1835bd8deadSopenharmony_ci Sampler uniforms specified using handles do not count as using any texture 1845bd8deadSopenharmony_ci image unit, even if a texture referred to by a handle is currently bound to 1855bd8deadSopenharmony_ci one or more texture image units. 1865bd8deadSopenharmony_ci 1875bd8deadSopenharmony_ci Errors 1885bd8deadSopenharmony_ci 1895bd8deadSopenharmony_ci The error INVALID_VALUE is generated if a Uniform1i{v} call is used to 1905bd8deadSopenharmony_ci set a sampler uniform to a value less than zero or greater than or 1915bd8deadSopenharmony_ci equal to the value of MAX_TEXTURE_IMAGE_UNITS. 1925bd8deadSopenharmony_ci 1935bd8deadSopenharmony_ci It is not allowed to have uniform variables of different sampler types 1945bd8deadSopenharmony_ci pointing to the same texture image unit within a program object. This 1955bd8deadSopenharmony_ci situation can only be detected at the next rendering command issued, 1965bd8deadSopenharmony_ci and an INVALID_OPERATION error will then be generated. 1975bd8deadSopenharmony_ci 1985bd8deadSopenharmony_ci Active samplers are those samplers actually being used in a program 1995bd8deadSopenharmony_ci object. When a program is linked by LinkProgram, the GL determines 2005bd8deadSopenharmony_ci whether each sampler is active or not. There is no limit on the number of 2015bd8deadSopenharmony_ci active sampler variables that may be used by a program or by any 2025bd8deadSopenharmony_ci particular shader. However, restrictions on the use of texture image 2035bd8deadSopenharmony_ci units imposes an effective limit on the number of non-handle sampler 2045bd8deadSopenharmony_ci uniforms. Active samplers used uniforms in the default uniform block are 2055bd8deadSopenharmony_ci counted toward implementation-dependent limits on the total number of 2065bd8deadSopenharmony_ci uniform components supported by the program. Each active sampler variable 2075bd8deadSopenharmony_ci may count as two components against such limits. 2085bd8deadSopenharmony_ci 2095bd8deadSopenharmony_ciAdditions to Chapter 8 of the OpenGL ES 3.1 API Specification, "Textures and 2105bd8deadSopenharmony_ciSamplers" 2115bd8deadSopenharmony_ci 2125bd8deadSopenharmony_ci Insert a new section 8.2bindless, Bindless Textures, after Section 8.2, 2135bd8deadSopenharmony_ci Sampler Objects: 2145bd8deadSopenharmony_ci 2155bd8deadSopenharmony_ci The previous sections describe mechanisms to make texture and sampler 2165bd8deadSopenharmony_ci objects available to shaders or fixed-function fragment processing by 2175bd8deadSopenharmony_ci binding the objects to texture image units. Additionally, texture objects 2185bd8deadSopenharmony_ci may be accessed by shader using texture handles, which are 64-bit unsigned 2195bd8deadSopenharmony_ci integers identifying the state of a texture and/or sampler object. The 2205bd8deadSopenharmony_ci handle zero is reserved and will never be assigned to a valid texture 2215bd8deadSopenharmony_ci handle. To obtain a texture handle, use the commands: 2225bd8deadSopenharmony_ci 2235bd8deadSopenharmony_ci uint64 GetTextureHandleIMG(uint texture); 2245bd8deadSopenharmony_ci uint64 GetTextureSamplerHandleIMG(uint texture, uint sampler); 2255bd8deadSopenharmony_ci 2265bd8deadSopenharmony_ci GetTextureHandleIMG will create a texture handle using the current state of 2275bd8deadSopenharmony_ci the texture named <texture>, including any embedded sampler state. 2285bd8deadSopenharmony_ci GetTextureSamplerHandleIMG will create a texture handle using the current 2295bd8deadSopenharmony_ci non-sampler state from the texture named <texture> and the sampler state 2305bd8deadSopenharmony_ci from the sampler object <sampler>. In both cases, a 64-bit unsigned 2315bd8deadSopenharmony_ci integer handle is returned. If an error occurs, a handle of zero is 2325bd8deadSopenharmony_ci returned. 2335bd8deadSopenharmony_ci 2345bd8deadSopenharmony_ci The handle for each texture or texture/sampler pair is unique; the same 2355bd8deadSopenharmony_ci handle will be returned if GetTextureHandleIMG is called multiple times 2365bd8deadSopenharmony_ci for the same texture or if GetTextureSamplerHandleIMG is called multiple 2375bd8deadSopenharmony_ci times for the same texture/sampler pair. 2385bd8deadSopenharmony_ci 2395bd8deadSopenharmony_ci When a texture object is referenced by one or more texture handles, the 2405bd8deadSopenharmony_ci texture parameters of the object (Section 8.9) may not be changed. The 2415bd8deadSopenharmony_ci contents of the images in a texture object may still be updated via commands 2425bd8deadSopenharmony_ci such as TexSubImage*, CopyTexSubImage*, and CompressedTexSubImage*, and by 2435bd8deadSopenharmony_ci rendering to a framebuffer object, even if the texture object is referenced 2445bd8deadSopenharmony_ci by one or more texture handles. However, once a handle references a texture 2455bd8deadSopenharmony_ci object, texel updates via API commands are no longer implicitly 2465bd8deadSopenharmony_ci synchronised by the API. Updates to the texture will become visible to the 2475bd8deadSopenharmony_ci server after an unspecified period of time, and may occur during other 2485bd8deadSopenharmony_ci server operations - though they are guaranteed to be visible to subsequently 2495bd8deadSopenharmony_ci issued GL commands with no further action. Applications are responsible for 2505bd8deadSopenharmony_ci synchronizing access, to ensure operations have completed in the desired 2515bd8deadSopenharmony_ci order - for instance by using FenceSync (see Chapter 4 - Event Model). 2525bd8deadSopenharmony_ci 2535bd8deadSopenharmony_ci [[ If EXT/OES_texture_buffer or OpenGL ES 3.2, and EXT_buffer_storage are supported ]] 2545bd8deadSopenharmony_ci If the texture object is a buffer texture, the contents of the buffer object 2555bd8deadSopenharmony_ci may still be updated by using MapBuffer* commands with the 2565bd8deadSopenharmony_ci MAP_PERSISTENT_BIT_EXT, or via the texture update commands in the same way 2575bd8deadSopenharmony_ci as other bindless textures, even if the buffer is bound to a texture while 2585bd8deadSopenharmony_ci that buffer texture object is referenced by one or more texture handles. 2595bd8deadSopenharmony_ci 2605bd8deadSopenharmony_ci When a sampler object is referenced by one or more texture handles, the 2615bd8deadSopenharmony_ci sampler parameters of the object may not be changed. 2625bd8deadSopenharmony_ci 2635bd8deadSopenharmony_ci Errors 2645bd8deadSopenharmony_ci 2655bd8deadSopenharmony_ci An INVALID_VALUE error is generated if <texture> is zero or is not the 2665bd8deadSopenharmony_ci name of an existing texture object or if <sampler> is zero or is not the 2675bd8deadSopenharmony_ci name of an existing sampler object. 2685bd8deadSopenharmony_ci 2695bd8deadSopenharmony_ci [[ If EXT/OES_texture_buffer or OpenGL ES 3.2, and EXT_buffer_storage are supported ]] 2705bd8deadSopenharmony_ci An INVALID_OPERATION error is generated if the value of <texture>'s 2715bd8deadSopenharmony_ci TEXTURE_IMMUTABLE_FORMAT is FALSE (section 8.17), or if <texture> is 2725bd8deadSopenharmony_ci a texture buffer and the values of the backing buffer's BUFFER_- 2735bd8deadSopenharmony_ci IMMUTABLE_STORAGE_EXT is FALSE, BUFFER_ACCESS_FLAGS includes 2745bd8deadSopenharmony_ci DYNAMIC_STORAGE_BIT or does not include MAP_PERSISTENT_BIT_EXT. 2755bd8deadSopenharmony_ci [[ Else ]] 2765bd8deadSopenharmony_ci An INVALID_OPERATION error is generated if the value of <texture>'s 2775bd8deadSopenharmony_ci TEXTURE_IMMUTABLE_FORMAT is FALSE (section 8.17). 2785bd8deadSopenharmony_ci 2795bd8deadSopenharmony_ci [[ If EXT/OES_texture_border_clamp or OpenGL ES 3.2 are supported ]] 2805bd8deadSopenharmony_ci An INVALID_OPERATION error is generated if the border color (taken from 2815bd8deadSopenharmony_ci the embedded sampler for GetTextureHandleIMG or from the <sampler> for 2825bd8deadSopenharmony_ci GetTextureSamplerHandleIMG) is not one of the following allowed values. 2835bd8deadSopenharmony_ci If the texture's base internal format is signed or unsigned integer, 2845bd8deadSopenharmony_ci allowed values are (0,0,0,0), (0,0,0,1), (1,1,1,0), and (1,1,1,1). If 2855bd8deadSopenharmony_ci the base internal format is not integer, allowed values are 2865bd8deadSopenharmony_ci (0.0,0.0,0.0,0.0), (0.0,0.0,0.0,1.0), (1.0,1.0,1.0,0.0), and 2875bd8deadSopenharmony_ci (1.0,1.0,1.0,1.0). 2885bd8deadSopenharmony_ci 2895bd8deadSopenharmony_ciAdditions to Chapter 11 of the OpenGL ES 3.1 API Specification, "Programmable 2905bd8deadSopenharmony_ciVertex Processing" 2915bd8deadSopenharmony_ci 2925bd8deadSopenharmony_ci Add the following sentence to the end of the paragraph in Section 11.1.3.5, 2935bd8deadSopenharmony_ci Texture Access, beginning "All active shaders combined cannot use more than 2945bd8deadSopenharmony_ci the value of MAX_COMBINED_TEXTURE_IMAGE_UNITS...": 2955bd8deadSopenharmony_ci 2965bd8deadSopenharmony_ci Samplers accessed using texture handles (section 3.9.X) are not counted 2975bd8deadSopenharmony_ci against this limit. 2985bd8deadSopenharmony_ci 2995bd8deadSopenharmony_ciModifications to The OpenGL ES 3.10 Shading Language Specification 3005bd8deadSopenharmony_ci 3015bd8deadSopenharmony_ci Including the following line in a shader can be used to control the 3025bd8deadSopenharmony_ci language features described in this extension: 3035bd8deadSopenharmony_ci 3045bd8deadSopenharmony_ci #extension GL_IMG_bindless_texture : <behavior> 3055bd8deadSopenharmony_ci 3065bd8deadSopenharmony_ci where <behavior> is as specified in section 3.4. 3075bd8deadSopenharmony_ci 3085bd8deadSopenharmony_ci New preprocessor #defines are added to the OpenGL ES Shading Language: 3095bd8deadSopenharmony_ci 3105bd8deadSopenharmony_ci #define GL_IMG_bindless_texture 1 3115bd8deadSopenharmony_ci 3125bd8deadSopenharmony_ci 3135bd8deadSopenharmony_ciAdditions to Chapter 4 of the OpenGL ES 3.1 Language Specification, "Variables 3145bd8deadSopenharmony_ciand Types" 3155bd8deadSopenharmony_ci 3165bd8deadSopenharmony_ci Add the following paragraph to the end of section 4.1.7.1, Samplers: 3175bd8deadSopenharmony_ci 3185bd8deadSopenharmony_ci The OpenGL ES API allows default block sampler uniforms to be assigned 3195bd8deadSopenharmony_ci values referencing either a texture image unit number or a bindless 3205bd8deadSopenharmony_ci texture handle, depending on the API function used. All other sampler 3215bd8deadSopenharmony_ci variables must be assigned a texture handle. A layout qualifier 3225bd8deadSopenharmony_ci specifies which of these is used in the program. 3235bd8deadSopenharmony_ci 3245bd8deadSopenharmony_ci Remove the bullet point "sampler types are not allowed" Section 4.3.7, 3255bd8deadSopenharmony_ci Interface Blocks. 3265bd8deadSopenharmony_ci 3275bd8deadSopenharmony_ci Add the following paragraph to the end of section 4.4.5, "Opaque Uniform 3285bd8deadSopenharmony_ci Layout Qualifiers": 3295bd8deadSopenharmony_ci 3305bd8deadSopenharmony_ci Sampler variables declared in uniform blocks may not be qualified with 3315bd8deadSopenharmony_ci a binding, and a compile-time error will be generated if a shader 3325bd8deadSopenharmony_ci specifies this. 3335bd8deadSopenharmony_ci 3345bd8deadSopenharmony_ci Insert a new section 4.4.5bindless, "Bindless Sampler Layout Qualifiers", 3355bd8deadSopenharmony_ci after section 4.4.5, "Opaque Uniform Layout Qualifiers": 3365bd8deadSopenharmony_ci 3375bd8deadSopenharmony_ci Sampler types accept a uniform layout qualifier identifier controlling 3385bd8deadSopenharmony_ci whether the uniform may be used with a bindless handle: 3395bd8deadSopenharmony_ci 3405bd8deadSopenharmony_ci layout-qualifier-id 3415bd8deadSopenharmony_ci bindless_sampler 3425bd8deadSopenharmony_ci bound_sampler 3435bd8deadSopenharmony_ci 3445bd8deadSopenharmony_ci These modifiers control whether default-block uniforms of the 3455bd8deadSopenharmony_ci corresponding types may have their values set via both UniformHandle* 3465bd8deadSopenharmony_ci and Uniform1i (bindless_sampler) or only via Uniform1i (bound_sampler). 3475bd8deadSopenharmony_ci These layouts may be specified at global scope to control the default 3485bd8deadSopenharmony_ci behavior of uniforms of the corresponding types, e.g. 3495bd8deadSopenharmony_ci 3505bd8deadSopenharmony_ci layout (bindless_sampler) uniform; 3515bd8deadSopenharmony_ci 3525bd8deadSopenharmony_ci They may also be specified on a uniform variable declaration of a 3535bd8deadSopenharmony_ci corresponding type, e.g. 3545bd8deadSopenharmony_ci 3555bd8deadSopenharmony_ci layout (bindless_sampler) uniform sampler2D mySampler; 3565bd8deadSopenharmony_ci 3575bd8deadSopenharmony_ci If both bindless_sampler and bound_sampler are declared at global scope 3585bd8deadSopenharmony_ci in any compilation unit, a link- time error will be generated. If these 3595bd8deadSopenharmony_ci layout qualifiers are applied to other types of default block uniforms, 3605bd8deadSopenharmony_ci a compile-time error will be generated. In the absence of these 3615bd8deadSopenharmony_ci qualifiers, sampler uniforms are considered "bound". Additionally, if 3625bd8deadSopenharmony_ci GL_IMG_bindless_texture is not enabled, these uniforms are considered 3635bd8deadSopenharmony_ci "bound". 3645bd8deadSopenharmony_ci 3655bd8deadSopenharmony_ci Declaring a sampler in the uniform default-block with a binding point 3665bd8deadSopenharmony_ci qualifier implicitly also declares it with "bound_sampler". 3675bd8deadSopenharmony_ci 3685bd8deadSopenharmony_ciErrors 3695bd8deadSopenharmony_ci 3705bd8deadSopenharmony_ci The error INVALID_OPERATION is generated by SamplerParameter* if <sampler> 3715bd8deadSopenharmony_ci identifies a sampler object referenced by one or more texture handles. 3725bd8deadSopenharmony_ci 3735bd8deadSopenharmony_ci The error INVALID_OPERATION is generated by TexParameter* if <target> 3745bd8deadSopenharmony_ci identifies a texture object referenced by one or more texture handles. 3755bd8deadSopenharmony_ci 3765bd8deadSopenharmony_ci 3775bd8deadSopenharmony_ci The error INVALID_OPERATION is generated by {Program}UniformHandleui64{v}IMG 3785bd8deadSopenharmony_ci if the sampler or image uniform being updated has the "bound_sampler" layout 3795bd8deadSopenharmony_ci qualifier, or an explicit binding qualifier. 3805bd8deadSopenharmony_ci 3815bd8deadSopenharmony_ci [[ If EXT/OES_texture_buffer or OpenGL ES 3.2, and EXT_buffer_storage are supported ]] 3825bd8deadSopenharmony_ci The error INVALID_OPERATION is generated by TexBuffer*EXT if <target> 3835bd8deadSopenharmony_ci identifies a texture object referenced by one or more texture handles. 3845bd8deadSopenharmony_ci 3855bd8deadSopenharmony_ci The error INVALID_OPERATION is generated by MapBuffer* if <target> 3865bd8deadSopenharmony_ci identifies a buffer object bound to a texture that is referenced by one or 3875bd8deadSopenharmony_ci more texture handles, and access does not include MAP_PERSISTENT_BIT_EXT. 3885bd8deadSopenharmony_ci 3895bd8deadSopenharmony_ciExamples 3905bd8deadSopenharmony_ci 3915bd8deadSopenharmony_ci To loop through a collection of 256 textures in the OpenGL API using a 3925bd8deadSopenharmony_ci conventional GLSL shader and without calling glBindTexture, one might do: 3935bd8deadSopenharmony_ci 3945bd8deadSopenharmony_ci #define NUM_TEXTURES 256 3955bd8deadSopenharmony_ci GLuint textures[NUM_TEXTURES]; 3965bd8deadSopenharmony_ci GLuint64 texHandles[NUM_TEXTURES]; 3975bd8deadSopenharmony_ci 3985bd8deadSopenharmony_ci // Initialize the texture objects and handles. 3995bd8deadSopenharmony_ci glGenTextures(NUM_TEXTURES, textures); 4005bd8deadSopenharmony_ci for (int i = 0; i < NUM_TEXTURES; i++) { 4015bd8deadSopenharmony_ci 4025bd8deadSopenharmony_ci // Initialize the texture images with glTexStorage. 4035bd8deadSopenharmony_ci // Initialize the texture parameters as required. 4045bd8deadSopenharmony_ci 4055bd8deadSopenharmony_ci // Get a handle for the texture. 4065bd8deadSopenharmony_ci texHandles[i] = glGetTextureHandleIMG(textures[i]); 4075bd8deadSopenharmony_ci 4085bd8deadSopenharmony_ci // At this point, it's no longer possible to modify texture parameters 4095bd8deadSopenharmony_ci // for "textures[i]". However, it's still possible to update texture 4105bd8deadSopenharmony_ci // data via glTexSubImage. 4115bd8deadSopenharmony_ci } 4125bd8deadSopenharmony_ci 4135bd8deadSopenharmony_ci // Compile GLSL shader using sampler uniform <u>. The shader itself 4145bd8deadSopenharmony_ci // needs no special #extension directive as long as <u> is a uniform in 4155bd8deadSopenharmony_ci // the default partition, and doesn't declare an explicit binding point. 4165bd8deadSopenharmony_ci // Link the program, and query the location of <u>, which we will store 4175bd8deadSopenharmony_ci // in <location>. 4185bd8deadSopenharmony_ci 4195bd8deadSopenharmony_ci // Render a little bit using each of the texture handles in turn. 4205bd8deadSopenharmony_ci for (int i = 0; i < NUM_TEXTURES; i++) { 4215bd8deadSopenharmony_ci 4225bd8deadSopenharmony_ci // Update the single sampler uniform <u> to point at "texHandles[i]". 4235bd8deadSopenharmony_ci glUniformHandleui64IMG(location, texHandles[i]); 4245bd8deadSopenharmony_ci 4255bd8deadSopenharmony_ci drawStuff(); 4265bd8deadSopenharmony_ci } 4275bd8deadSopenharmony_ci 4285bd8deadSopenharmony_ci The GLSL portion of this extension removes the restriction that sampler 4295bd8deadSopenharmony_ci variables must be uniforms in the default block. You can store a large 4305bd8deadSopenharmony_ci collection of samplers in a uniform block. 4315bd8deadSopenharmony_ci 4325bd8deadSopenharmony_ci To use a "dictionary" of samplers in a uniform block (in combination with 4335bd8deadSopenharmony_ci either EXT_gpu_shader5, or OpenGL ES 3.2), you could use a shader like: 4345bd8deadSopenharmony_ci 4355bd8deadSopenharmony_ci #version 310 es 4365bd8deadSopenharmony_ci #extension GL_IMG_bindless_texture : require 4375bd8deadSopenharmony_ci #extension GL_EXT_gpu_shader5 : require 4385bd8deadSopenharmony_ci #define NUM_TEXTURES 256 4395bd8deadSopenharmony_ci 4405bd8deadSopenharmony_ci uniform int whichSampler; 4415bd8deadSopenharmony_ci in highp vec2 texCoord; 4425bd8deadSopenharmony_ci out lowp vec4 finalColor; 4435bd8deadSopenharmony_ci 4445bd8deadSopenharmony_ci uniform Samplers { 4455bd8deadSopenharmony_ci sampler2D allTheSamplers[NUM_TEXTURES]; 4465bd8deadSopenharmony_ci }; 4475bd8deadSopenharmony_ci 4485bd8deadSopenharmony_ci void main() 4495bd8deadSopenharmony_ci { 4505bd8deadSopenharmony_ci finalColor = texture(allTheSamplers[whichSampler], texCoord); 4515bd8deadSopenharmony_ci } 4525bd8deadSopenharmony_ci 4535bd8deadSopenharmony_ciNew State 4545bd8deadSopenharmony_ci 4555bd8deadSopenharmony_ci Add new table, Bindless Texture Handles 4565bd8deadSopenharmony_ci 4575bd8deadSopenharmony_ci Initial 4585bd8deadSopenharmony_ci Get Value Type Get Command Value Description Sec. Attribute 4595bd8deadSopenharmony_ci ------------ ---- -------------------- ------- ------------------------- ----------- ------- 4605bd8deadSopenharmony_ci - Z64 GetTextureHandleIMG n/a texture handle 8.2bindless - 4615bd8deadSopenharmony_ci or GetTextureSampler- 4625bd8deadSopenharmony_ci HandleIMG 4635bd8deadSopenharmony_ci - Z+ - n/a texture object used 8.2bindless - 4645bd8deadSopenharmony_ci - Z+ - n/a sampler object used 8.2bindless - 4655bd8deadSopenharmony_ci 4665bd8deadSopenharmony_ciIssues 4675bd8deadSopenharmony_ci 4685bd8deadSopenharmony_ci See original issues in ARB_bindless_texture. 4695bd8deadSopenharmony_ci 4705bd8deadSopenharmony_ci (1) How does IMG_bindless_texture differ from ARB_bindless_texture? 4715bd8deadSopenharmony_ci 4725bd8deadSopenharmony_ci RESOLVED: 4735bd8deadSopenharmony_ci 4745bd8deadSopenharmony_ci - Bindless images are not supported. 4755bd8deadSopenharmony_ci - Bindless samplers are only supported via uniforms/uniform buffers. 4765bd8deadSopenharmony_ci - No constructors between opaque and integer types 4775bd8deadSopenharmony_ci - No residency functions 4785bd8deadSopenharmony_ci - This extension does not add dynamic indexing, as it is introduced by EXT/OES_shader_gpu5 (or OpenGL ES 3.2) 4795bd8deadSopenharmony_ci - Only immutable textures and buffers (for buffer textures) are usable with bindless handles. 4805bd8deadSopenharmony_ci - Texture uploads are considered asynchronous to usage, and must be manually synchronized with fences in order to avoid race conditions 4815bd8deadSopenharmony_ci - For buffer texture objects, the only allowed buffer update mechanism is persistent mapping 4825bd8deadSopenharmony_ci 4835bd8deadSopenharmony_ci (2) Should texture uploads/copies still be allowed? 4845bd8deadSopenharmony_ci 4855bd8deadSopenharmony_ci RESOLVED: 4865bd8deadSopenharmony_ci 4875bd8deadSopenharmony_ci The original ARB_bindless_texture allows texture uploads, with the 4885bd8deadSopenharmony_ci expectation that the commands are still serialized relative to surrounding 4895bd8deadSopenharmony_ci draw calls. 4905bd8deadSopenharmony_ci 4915bd8deadSopenharmony_ci Such an implementation would prove difficult for a tile-based 4925bd8deadSopenharmony_ci architecture; attempting to serialize resource updates between draw calls 4935bd8deadSopenharmony_ci requires significant amounts of additional overhead. Without bindless, 4945bd8deadSopenharmony_ci the driver is able to track resources to make it work as expected - which 4955bd8deadSopenharmony_ci is impossible with bindless textures. 4965bd8deadSopenharmony_ci 4975bd8deadSopenharmony_ci So we've decided to remove this particular requirement, instead 4985bd8deadSopenharmony_ci saying that texture uploads and copies occur asynchronously to other 4995bd8deadSopenharmony_ci commands, and require explicit synchronisation, in order to be 5005bd8deadSopenharmony_ci completed at predictable times. 5015bd8deadSopenharmony_ci 5025bd8deadSopenharmony_ci (2) Should buffer uploads/copies for buffer texture objects still be allowed? 5035bd8deadSopenharmony_ci 5045bd8deadSopenharmony_ci RESOLVED: 5055bd8deadSopenharmony_ci 5065bd8deadSopenharmony_ci Only persistent mapping is allowed. 5075bd8deadSopenharmony_ci 5085bd8deadSopenharmony_ciRevision History 5095bd8deadSopenharmony_ci 5105bd8deadSopenharmony_ci Rev. Date Author Changes 5115bd8deadSopenharmony_ci ---- ---------- -------- ----------------------------------------- 5125bd8deadSopenharmony_ci 1 2015-08-21 thector Initial revision 5135bd8deadSopenharmony_ci 2 2015-08-24 thector Fixed references to "EXT_buffer_storage", added error for TexBuffer*EXT functions 5145bd8deadSopenharmony_ci 3 2015-12-04 thector Texture data uploads are now entirely asynchronous 5155bd8deadSopenharmony_ci 4 2016-05-23 thector Ensured that example in spec is actually compilable 516