15bd8deadSopenharmony_ciName 25bd8deadSopenharmony_ci 35bd8deadSopenharmony_ci ARB_get_texture_sub_image 45bd8deadSopenharmony_ci 55bd8deadSopenharmony_ciName Strings 65bd8deadSopenharmony_ci 75bd8deadSopenharmony_ci GL_ARB_get_texture_sub_image 85bd8deadSopenharmony_ci 95bd8deadSopenharmony_ciContact 105bd8deadSopenharmony_ci 115bd8deadSopenharmony_ci Brian Paul, VMware Inc. (brianp 'at' vmware.com) 125bd8deadSopenharmony_ci 135bd8deadSopenharmony_ciContributors 145bd8deadSopenharmony_ci 155bd8deadSopenharmony_ci Brian Paul 165bd8deadSopenharmony_ci Daniel Koch, NVIDIA 175bd8deadSopenharmony_ci 185bd8deadSopenharmony_ciNotice 195bd8deadSopenharmony_ci 205bd8deadSopenharmony_ci Copyright (c) 2014 The Khronos Group Inc. Copyright terms at 215bd8deadSopenharmony_ci http://www.khronos.org/registry/speccopyright.html 225bd8deadSopenharmony_ci 235bd8deadSopenharmony_ciSpecification Update Policy 245bd8deadSopenharmony_ci 255bd8deadSopenharmony_ci Khronos-approved extension specifications are updated in response to 265bd8deadSopenharmony_ci issues and bugs prioritized by the Khronos OpenGL Working Group. For 275bd8deadSopenharmony_ci extensions which have been promoted to a core Specification, fixes will 285bd8deadSopenharmony_ci first appear in the latest version of that core Specification, and will 295bd8deadSopenharmony_ci eventually be backported to the extension document. This policy is 305bd8deadSopenharmony_ci described in more detail at 315bd8deadSopenharmony_ci https://www.khronos.org/registry/OpenGL/docs/update_policy.php 325bd8deadSopenharmony_ci 335bd8deadSopenharmony_ciStatus 345bd8deadSopenharmony_ci 355bd8deadSopenharmony_ci Complete. 365bd8deadSopenharmony_ci Approved by the ARB on June 26, 2014. 375bd8deadSopenharmony_ci Ratified by the Khronos Board of Promoters on August 7, 2014. 385bd8deadSopenharmony_ci 395bd8deadSopenharmony_ciVersion 405bd8deadSopenharmony_ci 415bd8deadSopenharmony_ci Date: June 16, 2014 425bd8deadSopenharmony_ci Revision: 7 435bd8deadSopenharmony_ci 445bd8deadSopenharmony_ciNumber 455bd8deadSopenharmony_ci 465bd8deadSopenharmony_ci ARB Extension #165 475bd8deadSopenharmony_ci 485bd8deadSopenharmony_ciDependencies 495bd8deadSopenharmony_ci 505bd8deadSopenharmony_ci OpenGL 2.0 is required 515bd8deadSopenharmony_ci 525bd8deadSopenharmony_ci The extension is written against the OpenGL 4.4 Specification, Core 535bd8deadSopenharmony_ci Profile, March 19, 2014. 545bd8deadSopenharmony_ci 555bd8deadSopenharmony_ciOverview 565bd8deadSopenharmony_ci 575bd8deadSopenharmony_ci This extension adds a new function to get sub-regions of texture 585bd8deadSopenharmony_ci images. 595bd8deadSopenharmony_ci 605bd8deadSopenharmony_ciIP Status 615bd8deadSopenharmony_ci 625bd8deadSopenharmony_ci No known IP claims. 635bd8deadSopenharmony_ci 645bd8deadSopenharmony_ciNew Procedures and Functions 655bd8deadSopenharmony_ci 665bd8deadSopenharmony_ci void GetTextureSubImage(uint texture, int level, 675bd8deadSopenharmony_ci int xoffset, int yoffset, int zoffset, 685bd8deadSopenharmony_ci sizei width, sizei height, sizei depth, 695bd8deadSopenharmony_ci enum format, enum type, 705bd8deadSopenharmony_ci sizei bufSize, void *pixels); 715bd8deadSopenharmony_ci 725bd8deadSopenharmony_ci void GetCompressedTextureSubImage(uint texture, 735bd8deadSopenharmony_ci int level, int xoffset, 745bd8deadSopenharmony_ci int yoffset, int zoffset, 755bd8deadSopenharmony_ci sizei width, sizei height, 765bd8deadSopenharmony_ci sizei depth, sizei bufSize, 775bd8deadSopenharmony_ci void *pixels); 785bd8deadSopenharmony_ci 795bd8deadSopenharmony_ciNew Types 805bd8deadSopenharmony_ci 815bd8deadSopenharmony_ci None 825bd8deadSopenharmony_ci 835bd8deadSopenharmony_ciNew Tokens 845bd8deadSopenharmony_ci 855bd8deadSopenharmony_ci None 865bd8deadSopenharmony_ci 875bd8deadSopenharmony_ciAdditions to Chapter 8 of the OpenGL 4.4 (Core Profile) Specification (Textures and Samplers) 885bd8deadSopenharmony_ci 895bd8deadSopenharmony_ci Modify section 8.11.4, Texture Image Queries p. 224 905bd8deadSopenharmony_ci 915bd8deadSopenharmony_ci (insert before the discussion of GetCompressedTexImage) 925bd8deadSopenharmony_ci 935bd8deadSopenharmony_ci Sub-regions of a texture image may be obtained from a texture object 945bd8deadSopenharmony_ci with the command 955bd8deadSopenharmony_ci 965bd8deadSopenharmony_ci void GetTextureSubImage(uint texture, int level, 975bd8deadSopenharmony_ci int xoffset, int yoffset, int zoffset, 985bd8deadSopenharmony_ci sizei width, sizei height, sizei depth, 995bd8deadSopenharmony_ci enum format, enum type, 1005bd8deadSopenharmony_ci sizei bufSize, void *pixels); 1015bd8deadSopenharmony_ci 1025bd8deadSopenharmony_ci <texture> is the name of the source texture object. and must not be a 1035bd8deadSopenharmony_ci buffer or multisample texture. The effective <target> parameter is the 1045bd8deadSopenharmony_ci value of TEXTURE_TARGET for texture. <level>, <format>, <type> and 1055bd8deadSopenharmony_ci <pixels> have the same meaning as for GetTexImage. <bufSize> is the size 1065bd8deadSopenharmony_ci of the buffer to receive the retrieved pixel data. 1075bd8deadSopenharmony_ci 1085bd8deadSopenharmony_ci For cube map textures, the behavior is as though GetTextureImage were 1095bd8deadSopenharmony_ci called, but only texels from the requested cube map faces (selected by 1105bd8deadSopenharmony_ci <zoffset> and <depth>, as described below) were returned. 1115bd8deadSopenharmony_ci 1125bd8deadSopenharmony_ci <xoffset>, <yoffset> and <zoffset> values indicate the position of the 1135bd8deadSopenharmony_ci subregion to return. <width>, <height> and <depth> indicate the size of 1145bd8deadSopenharmony_ci the region to return. These parameters have the same meaning as for 1155bd8deadSopenharmony_ci TexSubImage3D, though for one- and two-dimensional textures there are 1165bd8deadSopenharmony_ci extra restrictions, described in the errors section below). 1175bd8deadSopenharmony_ci 1185bd8deadSopenharmony_ci For one-dimensional array textures, <yoffset> is interpreted as the 1195bd8deadSopenharmony_ci first layer to access and <height> is the number of layers to access. 1205bd8deadSopenharmony_ci For two-dimensional array textures, <zoffset> is interpreted as the 1215bd8deadSopenharmony_ci first layer to access and <depth> is the number of layers to access. 1225bd8deadSopenharmony_ci Cube map textures are treated as an array of six slices in the 1235bd8deadSopenharmony_ci z-dimension, where the value of <zoffset> is interpreted as specifying 1245bd8deadSopenharmony_ci the cube map face for the corresponding layer in table 9.2 and <depth> 1255bd8deadSopenharmony_ci is the number of faces to access. For cube map array textures, <zoffset> 1265bd8deadSopenharmony_ci is the first layer-face to access, and <depth> is the number of layer- 1275bd8deadSopenharmony_ci faces to access. Each layer-face is translated into an array layer and a 1285bd8deadSopenharmony_ci cube map face as described for layer-face numbers in section 8.5.3. 1295bd8deadSopenharmony_ci 1305bd8deadSopenharmony_ci Component groups from the specified sub-region are packed and placed 1315bd8deadSopenharmony_ci into memory as described for GetTextureImage, starting with the texel at 1325bd8deadSopenharmony_ci (<xoffset>, <yoffset>, <zoffset>). 1335bd8deadSopenharmony_ci 1345bd8deadSopenharmony_ci Errors 1355bd8deadSopenharmony_ci 1365bd8deadSopenharmony_ci An INVALID_OPERATION error is generated if <texture> is not the name of 1375bd8deadSopenharmony_ci an existing texture object. 1385bd8deadSopenharmony_ci 1395bd8deadSopenharmony_ci An INVALID_OPERATION error is generated if <texture> is the name of a 1405bd8deadSopenharmony_ci buffer or multisample texture. 1415bd8deadSopenharmony_ci 1425bd8deadSopenharmony_ci An INVALID_VALUE error is generated if <xoffset>, <yoffset> or <zoffset> 1435bd8deadSopenharmony_ci are negative. 1445bd8deadSopenharmony_ci 1455bd8deadSopenharmony_ci An INVALID_VALUE error is generated by if <xoffset> + <width> is greater 1465bd8deadSopenharmony_ci than the texture level's width or if <yoffset> + <height> is greater 1475bd8deadSopenharmony_ci than the texture level's height or if <zoffset> + <depth> is greater 1485bd8deadSopenharmony_ci than the texture level's depth. 1495bd8deadSopenharmony_ci 1505bd8deadSopenharmony_ci An INVALID_VALUE error is generated if the effective <target> is 1515bd8deadSopenharmony_ci TEXTURE_1D and either <yoffset> is not zero, or <height> is not one. 1525bd8deadSopenharmony_ci 1535bd8deadSopenharmony_ci An INVALID_VALUE error is generated if the effective <target> is 1545bd8deadSopenharmony_ci TEXTURE_1D, TEXTURE_1D_ARRAY, TEXTURE_2D, or TEXTURE_RECTANGLE and 1555bd8deadSopenharmony_ci either <zoffset> is not zero, or <depth> is not one. 1565bd8deadSopenharmony_ci 1575bd8deadSopenharmony_ci An INVALID_OPERATION error is generated if the buffer size required to 1585bd8deadSopenharmony_ci store the requested data is greater than <bufSize>. 1595bd8deadSopenharmony_ci 1605bd8deadSopenharmony_ci 1615bd8deadSopenharmony_ci (insert after the discussion of GetCompressedTexSubImage and before 1625bd8deadSopenharmony_ci section 8.12 begins) 1635bd8deadSopenharmony_ci 1645bd8deadSopenharmony_ci If the compressed data are arranged into fixed-size blocks of texels, 1655bd8deadSopenharmony_ci the command 1665bd8deadSopenharmony_ci 1675bd8deadSopenharmony_ci void GetCompressedTextureSubImage(uint texture, 1685bd8deadSopenharmony_ci int level, int xoffset, 1695bd8deadSopenharmony_ci int yoffset, int zoffset, 1705bd8deadSopenharmony_ci sizei width, sizei height, 1715bd8deadSopenharmony_ci sizei depth, sizei bufSize, 1725bd8deadSopenharmony_ci void *pixels); 1735bd8deadSopenharmony_ci 1745bd8deadSopenharmony_ci can be used to obtain a sub-region of a compressed texture image instead 1755bd8deadSopenharmony_ci of the whole image. <texture> is the name of the source texture object, 1765bd8deadSopenharmony_ci and must not be a buffer or multisample texture. The effective <target> 1775bd8deadSopenharmony_ci is the value of TEXTURE_TARGET for <texture>. <level> and <pixels> have 1785bd8deadSopenharmony_ci the same meaning as the corresponding arguments CompressedTexSubImage3D. 1795bd8deadSopenharmony_ci <bufSize> indicates the size of the buffer to receive the retrieved 1805bd8deadSopenharmony_ci pixel data. 1815bd8deadSopenharmony_ci 1825bd8deadSopenharmony_ci For cube map textures, the behavior is as though GetCompressedTexImage 1835bd8deadSopenharmony_ci were called once for each requested face (selected by <zoffset> and 1845bd8deadSopenharmony_ci <depth>, as described below) with <target> corresponding to the 1855bd8deadSopenharmony_ci requested texture cube map face as indicated by Table 9.2. <pixels> is 1865bd8deadSopenharmony_ci offset appropriately for each successive image. 1875bd8deadSopenharmony_ci 1885bd8deadSopenharmony_ci <xoffset>, <yoffset> and <zoffset> indicate the position of the 1895bd8deadSopenharmony_ci subregion to return. <width>, <height> and <depth> indicate the size of 1905bd8deadSopenharmony_ci the region to return. These arguments have the same meaning as for 1915bd8deadSopenharmony_ci CompressedTexSubImage3D, though there are extra restrictions, described 1925bd8deadSopenharmony_ci in the errors section below. 1935bd8deadSopenharmony_ci 1945bd8deadSopenharmony_ci The mapping between the <xoffset>, <yoffset>, <zoffset>, <width>, 1955bd8deadSopenharmony_ci <height>, and <depth> parameters and the faces, layers, and layer-faces 1965bd8deadSopenharmony_ci for cube map, array, and cube map array textures is the same as for 1975bd8deadSopenharmony_ci GetTextureSubImage. 1985bd8deadSopenharmony_ci 1995bd8deadSopenharmony_ci The <xoffset>, <yoffset>, <zoffset>, <width>, <height> and <depth> 2005bd8deadSopenharmony_ci values and must be multiples of the values of 2015bd8deadSopenharmony_ci PACK_COMPRESSED_BLOCK_WIDTH, PACK_COMPRESSED_BLOCK_HEIGHT, and 2025bd8deadSopenharmony_ci PACK_COMPRESSED_BLOCK_DEPTH respectively, unless the offset is zero and 2035bd8deadSopenharmony_ci the corresponding size is the same as the texture size in that 2045bd8deadSopenharmony_ci dimension. 2055bd8deadSopenharmony_ci 2065bd8deadSopenharmony_ci Pixel storage modes are treated as for GetCompressedTexSubImage. The 2075bd8deadSopenharmony_ci texel at (<xoffset>, <yoffset>, <zoffset>) will be stored at the 2085bd8deadSopenharmony_ci location indicated by <pixels> and the current pixel packing parameters. 2095bd8deadSopenharmony_ci 2105bd8deadSopenharmony_ci Errors 2115bd8deadSopenharmony_ci 2125bd8deadSopenharmony_ci In addition to the same errors generated by GetTextureSubImage with 2135bd8deadSopenharmony_ci corresponding parameters: 2145bd8deadSopenharmony_ci 2155bd8deadSopenharmony_ci An INVALID_VALUE error is generated if <xoffset>, <yoffset> or <zoffset> 2165bd8deadSopenharmony_ci is not a multiple of the compressed block width, height or depth. 2175bd8deadSopenharmony_ci 2185bd8deadSopenharmony_ci An INVALID_VALUE error is generated if <width>, <height> or <depth> is 2195bd8deadSopenharmony_ci not a multiple of the compressed block width, height or depth 2205bd8deadSopenharmony_ci respectively, unless the offset is zero and the size equals the texture 2215bd8deadSopenharmony_ci image size. 2225bd8deadSopenharmony_ci 2235bd8deadSopenharmony_ciAdditions to the AGL/EGL/GLX/WGL Specifications 2245bd8deadSopenharmony_ci 2255bd8deadSopenharmony_ci None 2265bd8deadSopenharmony_ci 2275bd8deadSopenharmony_ciDependencies on GL and ES profiles, versions, and other extensions 2285bd8deadSopenharmony_ci 2295bd8deadSopenharmony_ci If texture arrays are not supported, ignore references to 2305bd8deadSopenharmony_ci 1D and 2D-array textures 2315bd8deadSopenharmony_ci 2325bd8deadSopenharmony_ci If cube map textures are not supported, ignore references to 2335bd8deadSopenharmony_ci cube map textures. 2345bd8deadSopenharmony_ci 2355bd8deadSopenharmony_ci If cube map arrays texture are not supported, ignore references to 2365bd8deadSopenharmony_ci cube map array textures. 2375bd8deadSopenharmony_ci 2385bd8deadSopenharmony_ci If texture rectangles are not supported, ignore references to 2395bd8deadSopenharmony_ci rectangle textures. 2405bd8deadSopenharmony_ci 2415bd8deadSopenharmony_ci If texture compression is not supported, ignore references to 2425bd8deadSopenharmony_ci GetCompressedTexSubImage. 2435bd8deadSopenharmony_ci 2445bd8deadSopenharmony_ciDependencies on ARB_direct_state_access 2455bd8deadSopenharmony_ci 2465bd8deadSopenharmony_ci If ARB_direct_state_access is not supported, the TEXTURE_TARGET 2475bd8deadSopenharmony_ci is the <target> that <texture> was initially bound with. 2485bd8deadSopenharmony_ci 2495bd8deadSopenharmony_ciNew State 2505bd8deadSopenharmony_ci 2515bd8deadSopenharmony_ci None. 2525bd8deadSopenharmony_ci 2535bd8deadSopenharmony_ciNew Implementation Dependent State 2545bd8deadSopenharmony_ci 2555bd8deadSopenharmony_ci None. 2565bd8deadSopenharmony_ci 2575bd8deadSopenharmony_ciConformance Testing 2585bd8deadSopenharmony_ci 2595bd8deadSopenharmony_ci 1) For each type of texture, create a test texture. Read back the 2605bd8deadSopenharmony_ci whole texture into a buffer with glGet[Compressed]TexImage. Then 2615bd8deadSopenharmony_ci read back the whole texture into a second buffer, but in sub-image 2625bd8deadSopenharmony_ci pieces (ex: 4x4 grid). Then compare the two result buffers - they 2635bd8deadSopenharmony_ci should be identical. 2645bd8deadSopenharmony_ci 2655bd8deadSopenharmony_ciIssues 2665bd8deadSopenharmony_ci 2675bd8deadSopenharmony_ci 1) Why is this extension necessary? 2685bd8deadSopenharmony_ci 2695bd8deadSopenharmony_ci RESOLVED: In some cases one can wrap a texture with an FBO and 2705bd8deadSopenharmony_ci read back sub-regions with glReadPixels. However, that doesn't 2715bd8deadSopenharmony_ci work for all texture formats (esp. compressed textures). 2725bd8deadSopenharmony_ci 2735bd8deadSopenharmony_ci For some textures such as 2D array textures there's no way to obtain 2745bd8deadSopenharmony_ci just one slice of a texture. It's very inefficient to get the whole 2755bd8deadSopenharmony_ci texture when just one slice is needed. 2765bd8deadSopenharmony_ci 2775bd8deadSopenharmony_ci An alternate approach to the problem of reading back sub textures 2785bd8deadSopenharmony_ci is with an extension such as GL_INTEL_map_texture. However, mapping 2795bd8deadSopenharmony_ci textures involves several difficult issues. Extending glGetTexImage 2805bd8deadSopenharmony_ci to handle sub-regions is much simpler. 2815bd8deadSopenharmony_ci 2825bd8deadSopenharmony_ci 2) What is the behavior of these commands if <bufSize> is exceeded 2835bd8deadSopenharmony_ci when a pixel pack buffer object is bound? 2845bd8deadSopenharmony_ci 2855bd8deadSopenharmony_ci DISCUSSION: When client memory is being used, INVALID_OPERATION is 2865bd8deadSopenharmony_ci generated if writing more than <bufSize> bytes is necessary to return 2875bd8deadSopenharmony_ci all the requested data. Similarly, when a PBO is bound, 2885bd8deadSopenharmony_ci INVALID_OPERATION is generated if more than <bufSize> bytes are 2895bd8deadSopenharmony_ci required. Note that it can also be an error if *less* than <bufSize> 2905bd8deadSopenharmony_ci bytes would be required when using a PBO if the space between the 2915bd8deadSopenharmony_ci offset indicated by <pixels> and the end of the buffer is insufficient 2925bd8deadSopenharmony_ci for the requested data. This behavior is inherited from GetTexImage 2935bd8deadSopenharmony_ci and GetCompressedTexImage. 2945bd8deadSopenharmony_ci 2955bd8deadSopenharmony_ci 3) Is the <target> parameter needed? 2965bd8deadSopenharmony_ci 2975bd8deadSopenharmony_ci RESOLVED. No. The target is determined by the texture type. 2985bd8deadSopenharmony_ci For cube map textures the face target is determined by the 2995bd8deadSopenharmony_ci <zoffset> and <depth> parameters by mapping layer numbers to 3005bd8deadSopenharmony_ci cube map texture faces as per Table 9.2. This is consisten 3015bd8deadSopenharmony_ci with the DSA variants of GetTextureImage in ARB_direct_state_access 3025bd8deadSopenharmony_ci which do not include it. 3035bd8deadSopenharmony_ci 3045bd8deadSopenharmony_ciRevision History 3055bd8deadSopenharmony_ci 3065bd8deadSopenharmony_ci Revision 1, 2014/02/03 3075bd8deadSopenharmony_ci - Initial revision 3085bd8deadSopenharmony_ci 3095bd8deadSopenharmony_ci Revision 2, 2014/04/10 3105bd8deadSopenharmony_ci - Converted GetTexSubImage and GetTexCompressedSubImage to 3115bd8deadSopenharmony_ci DSA (Direct State Access) style. 3125bd8deadSopenharmony_ci - Added bufSize parameter, per GL_ARB_robustness convention. 3135bd8deadSopenharmony_ci 3145bd8deadSopenharmony_ci Revision 3, 2014/05/26 - dkoch 3155bd8deadSopenharmony_ci - convert to ARB extension 3165bd8deadSopenharmony_ci - make function naming and parameter lists consistent 3175bd8deadSopenharmony_ci - describe the <bufSize> parameter (issue 2). 3185bd8deadSopenharmony_ci - remove the <target> parameter (issue 3) and fallout. 3195bd8deadSopenharmony_ci - better describe valid texture types and parameter meanings 3205bd8deadSopenharmony_ci for the various texture types. 3215bd8deadSopenharmony_ci 3225bd8deadSopenharmony_ci Revision 4, 2014/05/30 - dkoch 3235bd8deadSopenharmony_ci - describe implied <target> parameter for cube map textures 3245bd8deadSopenharmony_ci - fix remove incorrect <bufSize> language (Bug 12321) 3255bd8deadSopenharmony_ci - Add additional error language 3265bd8deadSopenharmony_ci - improve issues 2 and 3 3275bd8deadSopenharmony_ci 3285bd8deadSopenharmony_ci Revision 5, 2014/06/03 - Jon Leech 3295bd8deadSopenharmony_ci - Use 'pixels' instead of 'img' as formal parameter name for 3305bd8deadSopenharmony_ci consistency with API spec / dsa. 3315bd8deadSopenharmony_ci 3325bd8deadSopenharmony_ci Revision 6, 2014/06/12 - Jon Leech 3335bd8deadSopenharmony_ci - Sync with core API spec language and errors. 3345bd8deadSopenharmony_ci 3355bd8deadSopenharmony_ci Revision 6, 2014/06/16 - Jon Leech 3365bd8deadSopenharmony_ci - Require GetTextureSubImage for cube map textures to respect the 3375bd8deadSopenharmony_ci three-dimensional pixel pack state, by referring to GetTextureImage 3385bd8deadSopenharmony_ci language (Bug 12329). 339