From 6e9256f16db248e27be911faede69ebaa2dc4b83 Mon Sep 17 00:00:00 2001 From: Jeff Gilbert Date: Tue, 3 Aug 2021 12:12:55 -0700 Subject: [PATCH] Spec and test w,h constraints for BPTC, RGTC, and S3TC. (#3304) `w << level` and `h << level` must be multiples of 4. This way, we forbid image allocations that are never valid, such as 1x1 for level 1. (would only be valid with a 2x2 base level, which is forbidden) Resolves #3117. --- .../EXT_texture_compression_bptc/extension.xml | 6 +++--- .../EXT_texture_compression_rgtc/extension.xml | 4 ++-- .../WEBGL_compressed_texture_s3tc/extension.xml | 14 ++++++-------- .../extensions/ext-texture-compression-bptc.html | 12 +++++++++--- .../extensions/ext-texture-compression-rgtc.html | 12 +++++++++--- .../conformance/extensions/s3tc-and-rgtc.html | 15 +++++++++++++++ 6 files changed, 44 insertions(+), 19 deletions(-) diff --git a/extensions/EXT_texture_compression_bptc/extension.xml b/extensions/EXT_texture_compression_bptc/extension.xml index b412ed7ecf..1dfb971600 100644 --- a/extensions/EXT_texture_compression_bptc/extension.xml +++ b/extensions/EXT_texture_compression_bptc/extension.xml @@ -64,7 +64,7 @@
COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT
COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT
-

When level equals zero width and height +

width << level and height << level must be a multiple of 4.

If they are not an INVALID_OPERATION error is generated. @@ -117,8 +117,8 @@ interface EXT_texture_compression_bptc { The error INVALID_OPERATION is generated by compressedTexImage2D and - compressedTexSubImage2D if the level parameter is - 0 and the width or height is not a multiple of 4. + compressedTexSubImage2D if width << level and + height << level are not multiples of 4. diff --git a/extensions/EXT_texture_compression_rgtc/extension.xml b/extensions/EXT_texture_compression_rgtc/extension.xml index df55bc89d9..36e9604ba2 100644 --- a/extensions/EXT_texture_compression_rgtc/extension.xml +++ b/extensions/EXT_texture_compression_rgtc/extension.xml @@ -54,7 +54,7 @@ ceil(width / 4) * ceil(height / 4) * 8

If it is not, an INVALID_VALUE error is generated.

-

When level equals zero width and height +

width << level and height << level must be a multiple of 4.

If they are not an INVALID_OPERATION error is generated. @@ -68,7 +68,7 @@ ceil(width / 4) * ceil(height / 4) * 16

If it is not, an INVALID_VALUE error is generated.

-

When level equals zero width and height +

width << level and height << level must be a multiple of 4.

If they are not an INVALID_OPERATION error is generated. diff --git a/extensions/WEBGL_compressed_texture_s3tc/extension.xml b/extensions/WEBGL_compressed_texture_s3tc/extension.xml index 708112d465..a2627d1c8e 100644 --- a/extensions/WEBGL_compressed_texture_s3tc/extension.xml +++ b/extensions/WEBGL_compressed_texture_s3tc/extension.xml @@ -14,7 +14,7 @@

- This extension exposes the compressed texture formats defined in the + This extension exposes the compressed texture formats defined in the EXT_texture_compression_s3tc OpenGL extension to WebGL.

@@ -53,9 +53,8 @@

If it is not an INVALID_VALUE error is generated.

-

When level equals zero width and height - must be a multiple of 4. When level is greater than 0 width - and height must be 0, 1, 2 or a multiple of 4.

+

width << level and height << level + must be a multiple of 4.

If they are not an INVALID_OPERATION error is generated.

@@ -80,9 +79,8 @@

If it is not an INVALID_VALUE error is generated.

-

When level equals zero width and height - must be a multiple of 4. When level is greater than 0 width - and height must be 0, 1, 2 or a multiple of 4.

+

width << level and height << level + must be a multiple of 4.

If they are not an INVALID_OPERATION error is generated.

@@ -126,7 +124,7 @@ interface WEBGL_compressed_texture_s3tc { Added NoInterfaceObject extended attribute. - Added a note about COMPRESSED_RGB_S3TC_DXT1_EXT support. + Added a note about COMPRESSED_RGB_S3TC_DXT1_EXT support. diff --git a/sdk/tests/conformance/extensions/ext-texture-compression-bptc.html b/sdk/tests/conformance/extensions/ext-texture-compression-bptc.html index d4bb685a3b..78078d7968 100644 --- a/sdk/tests/conformance/extensions/ext-texture-compression-bptc.html +++ b/sdk/tests/conformance/extensions/ext-texture-compression-bptc.html @@ -87,10 +87,16 @@ expectation: gl.INVALID_OPERATION, message: "level is 0, width is not a multiple of 4" }, { level: 0, width: 4, height: 4, expectation: gl.NO_ERROR, message: "is valid" }, + { level: 1, width: 1, height: 1, + expectation: gl.INVALID_OPERATION, message: "implied base mip 2x2 is invalid" }, + { level: 1, width: 1, height: 2, + expectation: gl.INVALID_OPERATION, message: "implied base mip 2x4 is invalid" }, + { level: 1, width: 2, height: 1, + expectation: gl.INVALID_OPERATION, message: "implied base mip 4x2 is invalid" }, { level: 1, width: 2, height: 2, - expectation: gl.NO_ERROR, message: "level > 0, is valid" }, - { level: 2, width: 1, height: 1, - expectation: gl.NO_ERROR, message: "level > 0, is valid" }, + expectation: gl.NO_ERROR, message: "implied base mip 4x4 is valid" }, + { level: 2, width: 1, height: 3, + expectation: gl.NO_ERROR, message: "implied base mip 4x12 is valid" }, ]); // Test that BPTC enums are not accepted by texImage2D diff --git a/sdk/tests/conformance/extensions/ext-texture-compression-rgtc.html b/sdk/tests/conformance/extensions/ext-texture-compression-rgtc.html index 1542131bc8..74ae509b19 100644 --- a/sdk/tests/conformance/extensions/ext-texture-compression-rgtc.html +++ b/sdk/tests/conformance/extensions/ext-texture-compression-rgtc.html @@ -92,10 +92,16 @@ expectation: gl.INVALID_OPERATION, message: "level is 0, width is not a multiple of 4" }, { level: 0, width: 4, height: 4, expectation: gl.NO_ERROR, message: "is valid" }, + { level: 1, width: 1, height: 1, + expectation: gl.INVALID_OPERATION, message: "implied base mip 2x2 is invalid" }, + { level: 1, width: 1, height: 2, + expectation: gl.INVALID_OPERATION, message: "implied base mip 2x4 is invalid" }, + { level: 1, width: 2, height: 1, + expectation: gl.INVALID_OPERATION, message: "implied base mip 4x2 is invalid" }, { level: 1, width: 2, height: 2, - expectation: gl.NO_ERROR, message: "level > 0, is valid" }, - { level: 2, width: 1, height: 1, - expectation: gl.NO_ERROR, message: "level > 0, is valid" }, + expectation: gl.NO_ERROR, message: "implied base mip 4x4 is valid" }, + { level: 2, width: 1, height: 3, + expectation: gl.NO_ERROR, message: "implied base mip 4x12 is valid" }, ]); // Test that RGTC enums are not accepted by texImage2D diff --git a/sdk/tests/conformance/extensions/s3tc-and-rgtc.html b/sdk/tests/conformance/extensions/s3tc-and-rgtc.html index 55dc483afe..d6ffb6aad4 100644 --- a/sdk/tests/conformance/extensions/s3tc-and-rgtc.html +++ b/sdk/tests/conformance/extensions/s3tc-and-rgtc.html @@ -301,9 +301,24 @@ debug("Testing NPOT textures"); ctu.testTexImageLevelDimensions(gl, ext, validFormats, expectedByteLength, getBlockDimensions, [ + { level: 0, width: 0, height: 0, expectation: gl.NO_ERROR, message: "0: 0x0 is valid" }, + { level: 0, width: 1, height: 1, expectation: gl.INVALID_OPERATION, message: "0: 1x1 is invalid" }, + { level: 0, width: 2, height: 2, expectation: gl.INVALID_OPERATION, message: "0: 2x2 is invalid" }, + { level: 0, width: 3, height: 3, expectation: gl.INVALID_OPERATION, message: "0: 3x3 is invalid" }, + { level: 0, width: 10, height: 10, expectation: gl.INVALID_OPERATION, message: "0: 10x10 is invalid" }, + { level: 0, width: 11, height: 11, expectation: gl.INVALID_OPERATION, message: "0: 11x11 is invalid" }, + { level: 0, width: 11, height: 12, expectation: gl.INVALID_OPERATION, message: "0: 11x12 is invalid" }, + { level: 0, width: 12, height: 11, expectation: gl.INVALID_OPERATION, message: "0: 12x11 is invalid" }, { level: 0, width: 12, height: 12, expectation: gl.NO_ERROR, message: "0: 12x12 is valid" }, + { level: 1, width: 0, height: 0, expectation: gl.NO_ERROR, message: "1: 0x0, is valid" }, + { level: 1, width: 3, height: 3, expectation: gl.INVALID_OPERATION, message: "1: 3x3, is invalid" }, + { level: 1, width: 5, height: 5, expectation: gl.INVALID_OPERATION, message: "1: 5x5, is invalid" }, + { level: 1, width: 5, height: 6, expectation: gl.INVALID_OPERATION, message: "1: 5x6, is invalid" }, + { level: 1, width: 6, height: 5, expectation: gl.INVALID_OPERATION, message: "1: 6x5, is invalid" }, { level: 1, width: 6, height: 6, expectation: gl.NO_ERROR, message: "1: 6x6, is valid" }, + { level: 2, width: 0, height: 0, expectation: gl.NO_ERROR, message: "2: 0x0, is valid" }, { level: 2, width: 3, height: 3, expectation: gl.NO_ERROR, message: "2: 3x3, is valid" }, + { level: 3, width: 1, height: 3, expectation: gl.NO_ERROR, message: "3: 1x3, is valid" }, { level: 3, width: 1, height: 1, expectation: gl.NO_ERROR, message: "3: 1x1, is valid" }, ]);