WEBGL_compressed_texture_etc WebGL working group (public_webgl 'at' khronos.org) Jeff Gilbert, Mozilla Members of the WebGL working group 29

This extension exposes the compressed texture formats defined as core in the OpenGL ES 3.0 spec to WebGL. These include the ETC2 and EAC formats, where ETC2 is a superset of ETC1. ETC1 textures can be loaded using the ETC2 token value. All of these formats are in the ETC family.

Browsers should not advertise this extension when the WebGL implementation, or graphics driver, supports these formats by decompressing them.

Compression formats COMPRESSED_R11_EAC, COMPRESSED_SIGNED_R11_EAC, COMPRESSED_RG11_EAC, COMPRESSED_SIGNED_RG11_EAC, COMPRESSED_RGB8_ETC2, COMPRESSED_SRGB8_ETC2, COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2, COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2, COMPRESSED_RGBA8_ETC2_EAC, and COMPRESSED_SRGB8_ALPHA8_ETC2_EAC may be passed to the compressedTexImage2D and compressedTexSubImage2D entry points. In WebGL 2.0, they may also be passed to the compressedTexImage3D and compressedTexSubImage3D entry points with the TEXTURE_2D_ARRAY target. Calling getParameter with the argument COMPRESSED_TEXTURE_FORMATS will include the formats from this specification. For all of the formats, validatedSize (defined for each specific format below) is validated in the following ways:
  • WebGL 1.0 and 2.0: if the variant of compressedTexImage*D or compressedTexSubImage*D taking ArrayBufferView pixels is called, then the byteLength of the view must be equal to validatedSize, or an INVALID_VALUE error is generated.
  • WebGL 2.0: if the variant of compressedTexImage*D or compressedTexSubImage*D taking GLintptr offset is called, and offset + validatedSize is greater than the size of the bound PIXEL_UNPACK_BUFFER, an INVALID_OPERATION error is generated.
COMPRESSED_R11_EAC
COMPRESSED_SIGNED_R11_EAC
COMPRESSED_RGB8_ETC2
COMPRESSED_SRGB8_ETC2
COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2
COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2

validatedSize is computed in the following way:

floor((width + 3) / 4) * floor((height + 3) / 4) * 8
COMPRESSED_RG11_EAC
COMPRESSED_SIGNED_RG11_EAC
COMPRESSED_RGBA8_ETC2_EAC
COMPRESSED_SRGB8_ALPHA8_ETC2_EAC

validatedSize is computed in the following way:

floor((width + 3) / 4) * floor((height + 3) / 4) * 16
[NoInterfaceObject] interface WEBGL_compressed_texture_etc { /* Compressed Texture Formats */ const GLenum COMPRESSED_R11_EAC = 0x9270; const GLenum COMPRESSED_SIGNED_R11_EAC = 0x9271; const GLenum COMPRESSED_RG11_EAC = 0x9272; const GLenum COMPRESSED_SIGNED_RG11_EAC = 0x9273; const GLenum COMPRESSED_RGB8_ETC2 = 0x9274; const GLenum COMPRESSED_SRGB8_ETC2 = 0x9275; const GLenum COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2 = 0x9276; const GLenum COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2 = 0x9277; const GLenum COMPRESSED_RGBA8_ETC2_EAC = 0x9278; const GLenum COMPRESSED_SRGB8_ALPHA8_ETC2_EAC = 0x9279; }; Accepted by the internalformat parameter: COMPRESSED_R11_EAC, COMPRESSED_SIGNED_R11_EAC, COMPRESSED_RG11_EAC, COMPRESSED_SIGNED_RG11_EAC, COMPRESSED_RGB8_ETC2, COMPRESSED_SRGB8_ETC2, COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2, COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2, COMPRESSED_RGBA8_ETC2_EAC or COMPRESSED_SRGB8_ALPHA8_ETC2_EAC
Accepted by the internalformat parameter: COMPRESSED_R11_EAC, COMPRESSED_SIGNED_R11_EAC, COMPRESSED_RG11_EAC, COMPRESSED_SIGNED_RG11_EAC, COMPRESSED_RGB8_ETC2, COMPRESSED_SRGB8_ETC2, COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2, COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2, COMPRESSED_RGBA8_ETC2_EAC or COMPRESSED_SRGB8_ALPHA8_ETC2_EAC
The error INVALID_VALUE is generated by compressedTexImage2D, compressedTexSubImage2D, compressedTexImage3D, and compressedTexSubImage3D if the variant taking ArrayBufferView pixels is called and the size restrictions above are not met. The error INVALID_OPERATION is generated by compressedTexImage2D, compressedTexSubImage2D, compressedTexImage3D, and compressedTexSubImage3D if the variant taking GLintptr offset is called and the size restrictions above are not met. Initial revision. Added NoInterfaceObject extended attribute. COMPRESSED_RGB_ETC2 should be COMPRESSED_RGB8_ETC2. Remove unnecessary language. Moved to draft. Added issue questions. Formalized the newtok and error codes. Renamed to WEBGL_compressed_texture_es3_0. Clarifications to the supported formats on suggestion from Mark Callow. Addressed issues regarding 3D entry points, description of interation with WebGL 2.0, and generation of INVALID_OPERATION and INVALID_VALUE errors. Added note that browsers should not advertise this extension if these compressed texture formats are decompressed. Renamed to WEBGL_compressed_texture_etc after further discussion. Promoted to community approved.