Skip to content

Commit

Permalink
Spec and test w,h constraints for BPTC, RGTC, and S3TC. (KhronosGroup…
Browse files Browse the repository at this point in the history
…#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 KhronosGroup#3117.
  • Loading branch information
kdashg authored Aug 3, 2021
1 parent ad14195 commit 6e9256f
Show file tree
Hide file tree
Showing 6 changed files with 44 additions and 19 deletions.
6 changes: 3 additions & 3 deletions extensions/EXT_texture_compression_bptc/extension.xml
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@
<dt>COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT</dt>
<dt>COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT</dt>
<dd>
<p>When <code>level</code> equals zero <code>width</code> and <code>height</code>
<p><code>width &lt;&lt; level</code> and <code>height &lt;&lt; level</code>
must be a multiple of 4.</p>
<p>
If they are not an <code>INVALID_OPERATION</code> error is generated.
Expand Down Expand Up @@ -117,8 +117,8 @@ interface EXT_texture_compression_bptc {
</error>
<error enum="INVALID_OPERATION">
The error <code>INVALID_OPERATION</code> is generated by <code>compressedTexImage2D</code> and
<code>compressedTexSubImage2D</code> if the <code>level</code> parameter is
<code>0</code> and the <code>width</code> or <code>height</code> is not a multiple of 4.
<code>compressedTexSubImage2D</code> if <code>width &lt;&lt; level</code> and
<code>height &lt;&lt; level</code> are not multiples of 4.
</error>
</errors>

Expand Down
4 changes: 2 additions & 2 deletions extensions/EXT_texture_compression_rgtc/extension.xml
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@
ceil(width / 4) * ceil(height / 4) * 8
</code></blockquote>
<p>If it is not, an <code>INVALID_VALUE</code> error is generated.</p>
<p>When <code>level</code> equals zero <code>width</code> and <code>height</code>
<p><code>width &lt;&lt; level</code> and <code>height &lt;&lt; level</code>
must be a multiple of 4.</p>
<p>
If they are not an <code>INVALID_OPERATION</code> error is generated.
Expand All @@ -68,7 +68,7 @@
ceil(width / 4) * ceil(height / 4) * 16
</code></blockquote>
<p>If it is not, an <code>INVALID_VALUE</code> error is generated.</p>
<p>When <code>level</code> equals zero <code>width</code> and <code>height</code>
<p><code>width &lt;&lt; level</code> and <code>height &lt;&lt; level</code>
must be a multiple of 4.</p>
<p>
If they are not an <code>INVALID_OPERATION</code> error is generated.
Expand Down
14 changes: 6 additions & 8 deletions extensions/WEBGL_compressed_texture_s3tc/extension.xml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
</depends>
<overview>
<p>
This extension exposes the compressed texture formats defined in the
This extension exposes the compressed texture formats defined in the
<a href="http://www.opengl.org/registry/specs/EXT/texture_compression_s3tc.txt">
EXT_texture_compression_s3tc</a> OpenGL extension to WebGL.
</p>
Expand Down Expand Up @@ -53,9 +53,8 @@
<p>
If it is not an <code>INVALID_VALUE</code> error is generated.
</p>
<p>When <code>level</code> equals zero <code>width</code> and <code>height</code>
must be a multiple of 4. When <code>level</code> is greater than 0 <code>width</code>
and <code>height</code> must be 0, 1, 2 or a multiple of 4.</p>
<p><code>width &lt;&lt; level</code> and <code>height &lt;&lt; level</code>
must be a multiple of 4.</p>
<p>
If they are not an <code>INVALID_OPERATION</code> error is generated.
</p>
Expand All @@ -80,9 +79,8 @@
<p>
If it is not an <code>INVALID_VALUE</code> error is generated.
</p>
<p>When <code>level</code> equals zero <code>width</code> and <code>height</code>
must be a multiple of 4. When <code>level</code> is greater than 0 <code>width</code>
and <code>height</code> must be 0, 1, 2 or a multiple of 4.</p>
<p><code>width &lt;&lt; level</code> and <code>height &lt;&lt; level</code>
must be a multiple of 4.</p>
<p>
If they are not an <code>INVALID_OPERATION</code> error is generated.
</p>
Expand Down Expand Up @@ -126,7 +124,7 @@ interface WEBGL_compressed_texture_s3tc {
<change>Added NoInterfaceObject extended attribute.</change>
</revision>
<revision date="2019/10/24">
<change>Added a note about <code>COMPRESSED_RGB_S3TC_DXT1_EXT</code> support.</change>
<change>Added a note about <code>COMPRESSED_RGB_S3TC_DXT1_EXT</code> support.</change>
</revision>
</history>
</ratified>
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
15 changes: 15 additions & 0 deletions sdk/tests/conformance/extensions/s3tc-and-rgtc.html
Original file line number Diff line number Diff line change
Expand Up @@ -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" },
]);

Expand Down

0 comments on commit 6e9256f

Please sign in to comment.