15bd8deadSopenharmony_ciName 25bd8deadSopenharmony_ci 35bd8deadSopenharmony_ci ARB_shader_texture_image_samples 45bd8deadSopenharmony_ci 55bd8deadSopenharmony_ciName Strings 65bd8deadSopenharmony_ci 75bd8deadSopenharmony_ci GL_ARB_shader_texture_image_samples 85bd8deadSopenharmony_ci 95bd8deadSopenharmony_ciContact 105bd8deadSopenharmony_ci 115bd8deadSopenharmony_ci Piers Daniell, NVIDIA (pdaniell@nvidia.com) 125bd8deadSopenharmony_ci Mathias Schott, NVIDIA (mschott@nvidia.com) 135bd8deadSopenharmony_ci 145bd8deadSopenharmony_ciContributors 155bd8deadSopenharmony_ci 165bd8deadSopenharmony_ci Tristan Lorach, NVIDIA (tlorach@nvidia.com) 175bd8deadSopenharmony_ci Christophe Riccio, Unity (christophe.riccio@unity3d.com) 185bd8deadSopenharmony_ci Evan Hart, NVIDIA (ehart@nvidia.com) 195bd8deadSopenharmony_ci Jeannot Breton, NVIDIA (jbreton@nvidia.com) 205bd8deadSopenharmony_ci 215bd8deadSopenharmony_ciNotice 225bd8deadSopenharmony_ci 235bd8deadSopenharmony_ci Copyright (c) 2014 The Khronos Group Inc. Copyright terms at 245bd8deadSopenharmony_ci http://www.khronos.org/registry/speccopyright.html 255bd8deadSopenharmony_ci 265bd8deadSopenharmony_ciSpecification Update Policy 275bd8deadSopenharmony_ci 285bd8deadSopenharmony_ci Khronos-approved extension specifications are updated in response to 295bd8deadSopenharmony_ci issues and bugs prioritized by the Khronos OpenGL Working Group. For 305bd8deadSopenharmony_ci extensions which have been promoted to a core Specification, fixes will 315bd8deadSopenharmony_ci first appear in the latest version of that core Specification, and will 325bd8deadSopenharmony_ci eventually be backported to the extension document. This policy is 335bd8deadSopenharmony_ci described in more detail at 345bd8deadSopenharmony_ci https://www.khronos.org/registry/OpenGL/docs/update_policy.php 355bd8deadSopenharmony_ci 365bd8deadSopenharmony_ciStatus 375bd8deadSopenharmony_ci 385bd8deadSopenharmony_ci Complete. 395bd8deadSopenharmony_ci Approved by the ARB on June 26, 2014. 405bd8deadSopenharmony_ci Ratified by the Khronos Board of Promoters on August 7, 2014. 415bd8deadSopenharmony_ci 425bd8deadSopenharmony_ciVersion 435bd8deadSopenharmony_ci 445bd8deadSopenharmony_ci Last Modified Date: May 28, 2014 455bd8deadSopenharmony_ci Revision: 7 465bd8deadSopenharmony_ci 475bd8deadSopenharmony_ciNumber 485bd8deadSopenharmony_ci 495bd8deadSopenharmony_ci ARB Extension #166 505bd8deadSopenharmony_ci 515bd8deadSopenharmony_ciDependencies 525bd8deadSopenharmony_ci 535bd8deadSopenharmony_ci Either GLSL 1.50 or ARB_texture_multisample is required. 545bd8deadSopenharmony_ci 555bd8deadSopenharmony_ci This extension is written against the OpenGL 4.4 specification and 565bd8deadSopenharmony_ci version 4.40 of the OpenGL Shading Language Specification. 575bd8deadSopenharmony_ci 585bd8deadSopenharmony_ci This extension interacts with ARB_shader_image_load_store and GLSL 4.20. 595bd8deadSopenharmony_ci 605bd8deadSopenharmony_ci This extension interacts with NV_gpu_program5, EXT_shader_image_load_store 615bd8deadSopenharmony_ci and NV_texture_multisample. 625bd8deadSopenharmony_ci 635bd8deadSopenharmony_ciOverview 645bd8deadSopenharmony_ci 655bd8deadSopenharmony_ci This extension provides GLSL built-in functions allowing shaders to query 665bd8deadSopenharmony_ci the number of samples of a texture. 675bd8deadSopenharmony_ci 685bd8deadSopenharmony_ciNew Procedures and Functions 695bd8deadSopenharmony_ci 705bd8deadSopenharmony_ci None. 715bd8deadSopenharmony_ci 725bd8deadSopenharmony_ciNew Tokens 735bd8deadSopenharmony_ci 745bd8deadSopenharmony_ci None. 755bd8deadSopenharmony_ci 765bd8deadSopenharmony_ciAdditions to the OpenGL 4.4 (Core Profile) Specification 775bd8deadSopenharmony_ci 785bd8deadSopenharmony_ci None. 795bd8deadSopenharmony_ci 805bd8deadSopenharmony_ciErrors 815bd8deadSopenharmony_ci 825bd8deadSopenharmony_ci None. 835bd8deadSopenharmony_ci 845bd8deadSopenharmony_ciNew State 855bd8deadSopenharmony_ci 865bd8deadSopenharmony_ci None. 875bd8deadSopenharmony_ci 885bd8deadSopenharmony_ciNew Implementation Dependent State 895bd8deadSopenharmony_ci 905bd8deadSopenharmony_ci None. 915bd8deadSopenharmony_ci 925bd8deadSopenharmony_ciModifications to The OpenGL Shading Language Specification, Version 4.40.08 935bd8deadSopenharmony_ci 945bd8deadSopenharmony_ci Including the following line in a shader can be used to control the 955bd8deadSopenharmony_ci language features described in this extension: 965bd8deadSopenharmony_ci 975bd8deadSopenharmony_ci #extension GL_ARB_shader_texture_image_samples 985bd8deadSopenharmony_ci 995bd8deadSopenharmony_ci A new preprocessor #define is added to the OpenGL Shading Language: 1005bd8deadSopenharmony_ci 1015bd8deadSopenharmony_ci #define GL_ARB_shader_texture_image_samples 1 1025bd8deadSopenharmony_ci 1035bd8deadSopenharmony_ci Add to table in section 8.9.1 "Texture Query Functions" 1045bd8deadSopenharmony_ci 1055bd8deadSopenharmony_ci Syntax: 1065bd8deadSopenharmony_ci 1075bd8deadSopenharmony_ci int textureSamples(gsampler2DMS sampler) 1085bd8deadSopenharmony_ci int textureSamples(gsampler2DMSArray sampler) 1095bd8deadSopenharmony_ci 1105bd8deadSopenharmony_ci Description: 1115bd8deadSopenharmony_ci 1125bd8deadSopenharmony_ci Returns the number of samples of the texture or textures bound to 1135bd8deadSopenharmony_ci <sampler>. 1145bd8deadSopenharmony_ci 1155bd8deadSopenharmony_ciAdd to table in section 8.12 "Image Functions" 1165bd8deadSopenharmony_ci 1175bd8deadSopenharmony_ci Syntax: 1185bd8deadSopenharmony_ci 1195bd8deadSopenharmony_ci int imageSamples(gimage2DMS image) 1205bd8deadSopenharmony_ci int imageSamples(gimage2DMSArray image) 1215bd8deadSopenharmony_ci 1225bd8deadSopenharmony_ci Description: 1235bd8deadSopenharmony_ci 1245bd8deadSopenharmony_ci Returns the number of samples of the image or images bound to <image>. 1255bd8deadSopenharmony_ci 1265bd8deadSopenharmony_ciDependencies on ARB_shader_image_load_store and GLSL 4.20. 1275bd8deadSopenharmony_ci 1285bd8deadSopenharmony_ci If neither ARB_shader_image_load_store nor GLSL 4.20 is enabled in the 1295bd8deadSopenharmony_ci shader, then all overloads of imageSamples are removed. 1305bd8deadSopenharmony_ci 1315bd8deadSopenharmony_ciDependencies on NV_gpu_program5, EXT_shader_image_load_store and 1325bd8deadSopenharmony_ciNV_texture_multisample 1335bd8deadSopenharmony_ci 1345bd8deadSopenharmony_ci If NV_gpu_program5, EXT_shader_image_load_store and NV_texture_multisample 1355bd8deadSopenharmony_ci are supported, and "OPTION ARB_shader_texture_image_samples" is specified 1365bd8deadSopenharmony_ci in an assembly program, the following edits are made to extend the assembly 1375bd8deadSopenharmony_ci programming model documented in the NV_gpu_program4 extension and extended 1385bd8deadSopenharmony_ci by NV_gpu_program5, EXT_shader_image_load_store and NV_texture_multisample. 1395bd8deadSopenharmony_ci 1405bd8deadSopenharmony_ci If NV_gpu_program5, EXT_shader_image_load_store or NV_texture_multisample 1415bd8deadSopenharmony_ci are not supported, or if "OPTION ARB_shader_texture_image_samples" is not 1425bd8deadSopenharmony_ci specified in an assembly program, the contents of this dependencies section 1435bd8deadSopenharmony_ci should be ignored. 1445bd8deadSopenharmony_ci 1455bd8deadSopenharmony_ci Section 2.X.2, Program Grammar 1465bd8deadSopenharmony_ci 1475bd8deadSopenharmony_ci (add the following rules to the grammar) 1485bd8deadSopenharmony_ci 1495bd8deadSopenharmony_ci <ImageInstruction> ::= <IMQSop_instruction> 1505bd8deadSopenharmony_ci 1515bd8deadSopenharmony_ci <IMQSop_instruction> ::= <IMQSop> <opModifiers> <instResult> "," 1525bd8deadSopenharmony_ci <imageAccess> 1535bd8deadSopenharmony_ci 1545bd8deadSopenharmony_ci <IMQSop> ::= "IMQS" 1555bd8deadSopenharmony_ci 1565bd8deadSopenharmony_ci <TEXop_instruction> ::= <TXQSop> <opModifiers> <instResult> "," 1575bd8deadSopenharmony_ci <texAccess> 1585bd8deadSopenharmony_ci 1595bd8deadSopenharmony_ci <TXQSop> ::= "TXQS" 1605bd8deadSopenharmony_ci 1615bd8deadSopenharmony_ci 1625bd8deadSopenharmony_ci Modify Section 2.X.4, Program Execution Environment 1635bd8deadSopenharmony_ci 1645bd8deadSopenharmony_ci Instr- Modifiers 1655bd8deadSopenharmony_ci uction V F I C S H D Out Inputs Description 1665bd8deadSopenharmony_ci ------- -- - - - - - - --- -------- -------------------------------- 1675bd8deadSopenharmony_ci IMQS 50 - - - - - S s i image sample query 1685bd8deadSopenharmony_ci TXQS 50 - - - - - S s t texture sample query 1695bd8deadSopenharmony_ci 1705bd8deadSopenharmony_ci (Add to "Section 2.X.6, Program Options" of the NV_gpu_program4 extension, 1715bd8deadSopenharmony_ci as extended by NV_gpu_program5) 1725bd8deadSopenharmony_ci 1735bd8deadSopenharmony_ci + Texture and image sample query (ARB_shader_texture_image_samples) 1745bd8deadSopenharmony_ci 1755bd8deadSopenharmony_ci If a program specifies the "ARB_shader_texture_image_samples" option, it 1765bd8deadSopenharmony_ci may use the instructions TXQS and IMQS. If this option is not specified, 1775bd8deadSopenharmony_ci a program will fail to compile if it uses one of those two instructions. 1785bd8deadSopenharmony_ci 1795bd8deadSopenharmony_ci 1805bd8deadSopenharmony_ci Section 2.X.8.Z, IMQS: Image sample query 1815bd8deadSopenharmony_ci 1825bd8deadSopenharmony_ci The IMQS instruction returns the number of samples of the image unit 1835bd8deadSopenharmony_ci specified by <imageUnit>. Two image targets are supported: 2DMS and 1845bd8deadSopenharmony_ci ARRAY2DMS. If the texture bound to the image unit has a TEXTURE_SAMPLES 1855bd8deadSopenharmony_ci value of 0, the instruction will return 1. IMQS supports no data type 1865bd8deadSopenharmony_ci modifiers; the result scalar is interpreted as a signed integer. IMQS 1875bd8deadSopenharmony_ci supports no storage modifier, since the number of sample is independent of 1885bd8deadSopenharmony_ci the image unit format. 1895bd8deadSopenharmony_ci 1905bd8deadSopenharmony_ci 1915bd8deadSopenharmony_ci Section 2.X.8.Z, TXQS: Texture sample query 1925bd8deadSopenharmony_ci 1935bd8deadSopenharmony_ci The TXQS instruction returns the number of samples of the texture image 1945bd8deadSopenharmony_ci unit specified by <texImageUnit>. Two texture targets are supported: 1955bd8deadSopenharmony_ci 2DMS and ARRAY2DMS. If the texture has a TEXTURE_SAMPLES value of 0, the 1965bd8deadSopenharmony_ci instruction will return 1. TXQS supports no data type modifiers; the 1975bd8deadSopenharmony_ci result scalar is interpreted as a signed integer. 1985bd8deadSopenharmony_ci 1995bd8deadSopenharmony_ci 2005bd8deadSopenharmony_ciConformance Tests 2015bd8deadSopenharmony_ci 2025bd8deadSopenharmony_ci <TBD> 2035bd8deadSopenharmony_ci 2045bd8deadSopenharmony_ciIssues 2055bd8deadSopenharmony_ci 2065bd8deadSopenharmony_ci (1) What should we call this extension? 2075bd8deadSopenharmony_ci 2085bd8deadSopenharmony_ci GL_ARB_shader_image_size added imageSize which apparently was missed 2095bd8deadSopenharmony_ci from GL_ARB_shader_image_load_store 2105bd8deadSopenharmony_ci GL_ARB_texture_multisample had textureSize built in, so no precedence 2115bd8deadSopenharmony_ci 2125bd8deadSopenharmony_ci Ideas: 2135bd8deadSopenharmony_ci * GL_ARB_shader_sample_count_query 2145bd8deadSopenharmony_ci * GL_ARB_shader_samples_query 2155bd8deadSopenharmony_ci * GL_ARB_shader_texture_image_sample_count_query 2165bd8deadSopenharmony_ci * GL_ARB_shader_texture_image_samples 2175bd8deadSopenharmony_ci * GL_ARB_shader_texture_image_size_multisample 2185bd8deadSopenharmony_ci * GL_ARB_shader_texture_image_samples 2195bd8deadSopenharmony_ci * GL_ARB_shader_texture_samples 2205bd8deadSopenharmony_ci 2215bd8deadSopenharmony_ci RESOLVED: ARB_shader_texture_image_samples for now to 2225bd8deadSopenharmony_ci follow the precedent set by GL_ARB_shader_image_size. 2235bd8deadSopenharmony_ci 2245bd8deadSopenharmony_ci Might change depending on what the final resolution is for Issue (2) 2255bd8deadSopenharmony_ci 2265bd8deadSopenharmony_ci (2) How should we expose this? 2275bd8deadSopenharmony_ci 2285bd8deadSopenharmony_ci (A) separate textureSamples/imageSamples functions to query 2295bd8deadSopenharmony_ci just the number of samples 2305bd8deadSopenharmony_ci 2315bd8deadSopenharmony_ci orthogonal to other functions, makes it also easy to add non-awkward 2325bd8deadSopenharmony_ci versions for non MS textures that return 1. 2335bd8deadSopenharmony_ci 2345bd8deadSopenharmony_ci (B) (like that other API): extend textureSize/imageSize to return another 2355bd8deadSopenharmony_ci component in the returned (vec) value 2365bd8deadSopenharmony_ci 2375bd8deadSopenharmony_ci impossible to overload functions based on return type 2385bd8deadSopenharmony_ci 2395bd8deadSopenharmony_ci (C) textureSizeMS/imageSizeMS functions that return the number 2405bd8deadSopenharmony_ci of samples in the last component of the returned (vec) value 2415bd8deadSopenharmony_ci 2425bd8deadSopenharmony_ci Closer to that other API, but ugly and awkward to have non-ms textures 2435bd8deadSopenharmony_ci as arguments for a *SizeMS function. 2445bd8deadSopenharmony_ci 2455bd8deadSopenharmony_ci GL_ARB_texture_multisample Issue (5) suggests A) or (C) as options 2465bd8deadSopenharmony_ci 2475bd8deadSopenharmony_ci RESOLVED: Option A 2485bd8deadSopenharmony_ci 2495bd8deadSopenharmony_ci (3) Do we need overloads for g*Shadow samplers 2505bd8deadSopenharmony_ci 2515bd8deadSopenharmony_ci For consistency with textureSize. 2525bd8deadSopenharmony_ci 2535bd8deadSopenharmony_ci RESOLVED: No, see issue (5). 2545bd8deadSopenharmony_ci 2555bd8deadSopenharmony_ci (4) What other extensions interact with this 2565bd8deadSopenharmony_ci 2575bd8deadSopenharmony_ci NV_gpu_program5, EXT_shader_image_load_store, and NV_texture_multisample. 2585bd8deadSopenharmony_ci 2595bd8deadSopenharmony_ci What's the minimal GL/GLSL version we need to depend on. 2605bd8deadSopenharmony_ci 2615bd8deadSopenharmony_ci RESOLVED: The functionality added by this extension is 2625bd8deadSopenharmony_ci perfectly well defined in any shading language version that 2635bd8deadSopenharmony_ci supports multisample textures. If the shading language, with 2645bd8deadSopenharmony_ci extensions, does not support images, then imageSamples is not 2655bd8deadSopenharmony_ci available. 2665bd8deadSopenharmony_ci 2675bd8deadSopenharmony_ci (5) Do we need overloads for non-MS textures and images 2685bd8deadSopenharmony_ci 2695bd8deadSopenharmony_ci RESOLVED: No, since the always would return 1. If required, users can create 2705bd8deadSopenharmony_ci their own overloads that return 1 for non-MS samplers. 2715bd8deadSopenharmony_ci 2725bd8deadSopenharmony_ci (6) Should we add functions to query the position of a sample 2735bd8deadSopenharmony_ci 2745bd8deadSopenharmony_ci RESOLVED: No because of the complexity and implementation burden 2755bd8deadSopenharmony_ci of supporting queries of multisample texture created with 2765bd8deadSopenharmony_ci fixedsamplelocation as false. In that case each pixel might have 2775bd8deadSopenharmony_ci different sample locations. If the app really needs to know the 2785bd8deadSopenharmony_ci sample location inside the shader it can pass in this data as 2795bd8deadSopenharmony_ci a uniforms initialized from GetMultisamplefv(SAMPLE_POSITION) 2805bd8deadSopenharmony_ci queries. 2815bd8deadSopenharmony_ci 2825bd8deadSopenharmony_ciRevision History 2835bd8deadSopenharmony_ci Revision 8, 2015/09/08 (idr) 2845bd8deadSopenharmony_ci - Add interactions with various GLSL versions and extensions so 2855bd8deadSopenharmony_ci that this extension can be used with any GLSL version. 2865bd8deadSopenharmony_ci 2875bd8deadSopenharmony_ci Revision 7, 2014/05/28 (mschott) 2885bd8deadSopenharmony_ci - Minor cleanups of NV_gpu_program5 dependencies in issue 5 and the introduction 2895bd8deadSopenharmony_ci 2905bd8deadSopenharmony_ci Revision 6, 2014/05/27 (jbreton) 2915bd8deadSopenharmony_ci - Add NV_gpu_program5 dependencies 2925bd8deadSopenharmony_ci 2935bd8deadSopenharmony_ci Revision 5, 2014/04/16 (pdaniell) 2945bd8deadSopenharmony_ci - Removed textureSamplePosition and imageSamplePosition 2955bd8deadSopenharmony_ci - Resolved issue 6 2965bd8deadSopenharmony_ci 2975bd8deadSopenharmony_ci Revision 4, 2014/04/09 (mschott) 2985bd8deadSopenharmony_ci - added textureSamplePosition and imageSamplePosition 2995bd8deadSopenharmony_ci - added issue 6 3005bd8deadSopenharmony_ci 3015bd8deadSopenharmony_ci Revision 3, 2014/03/31 (mschott) 3025bd8deadSopenharmony_ci - removed non-MS overloads 3035bd8deadSopenharmony_ci - added issue 5 3045bd8deadSopenharmony_ci 3055bd8deadSopenharmony_ci Revision 2, 2013/12/13 (mschott) 3065bd8deadSopenharmony_ci - Renamed to GL_ARB_texture_image_samples 3075bd8deadSopenharmony_ci - added shadow sampler overloads 3085bd8deadSopenharmony_ci 3095bd8deadSopenharmony_ci Revision 1, 2013/12/13 (mschott) 3105bd8deadSopenharmony_ci - First draft 311