Skip to content

Commit

Permalink
Add npot tests to S3TC (KhronosGroup#3258)
Browse files Browse the repository at this point in the history
Fixes KhronosGroup#3117.

The updated tests pass on Chrome Stable .

Related to http://crbug.com/angleproject/4841 .
  • Loading branch information
lexaknyazev authored Apr 6, 2021
1 parent 9ac6bba commit 5fcfea8
Show file tree
Hide file tree
Showing 5 changed files with 167 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@
// * <height> is not a multiple of four, and <height> plus <yoffset> is
// not equal to TEXTURE_HEIGHT; or
// * <xoffset> or <yoffset> is not a multiple of four.
ctu.testTexSubImageDimensions(gl, validFormats, expectedByteLength, getBlockDimensions,
ctu.testTexSubImageDimensions(gl, ext, validFormats, expectedByteLength, getBlockDimensions,
16, 16, [
{ xoffset: 0, yoffset: 0, width: 4, height: 3,
expectation: gl.INVALID_OPERATION, message: "height is not a multiple of 4" },
Expand All @@ -77,7 +77,7 @@
// Test TexImage validation on level dimensions combinations.
// When level equals 0, width and height must be a multiple of 4.
// When level is larger than 0, this constraint doesn't apply.
ctu.testTexImageLevelDimensions(gl, validFormats, expectedByteLength, getBlockDimensions,
ctu.testTexImageLevelDimensions(gl, ext, validFormats, expectedByteLength, getBlockDimensions,
[
{ level: 0, width: 4, height: 3,
expectation: gl.INVALID_OPERATION, message: "level is 0, height is not a multiple of 4" },
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@
// * <height> is not a multiple of four, and <height> plus <yoffset> is
// not equal to TEXTURE_HEIGHT; or
// * <xoffset> or <yoffset> is not a multiple of four.
ctu.testTexSubImageDimensions(gl, validFormats, expectedByteLength, getBlockDimensions,
ctu.testTexSubImageDimensions(gl, ext, validFormats, expectedByteLength, getBlockDimensions,
16, 16, [
{ xoffset: 0, yoffset: 0, width: 4, height: 3,
expectation: gl.INVALID_OPERATION, message: "height is not a multiple of 4" },
Expand All @@ -82,7 +82,7 @@
// Test TexImage validation on level dimensions combinations.
// When level equals 0, width and height must be a multiple of 4.
// When level is larger than 0, this constraint doesn't apply.
ctu.testTexImageLevelDimensions(gl, validFormats, expectedByteLength, getBlockDimensions,
ctu.testTexImageLevelDimensions(gl, ext, validFormats, expectedByteLength, getBlockDimensions,
[
{ level: 0, width: 4, height: 3,
expectation: gl.INVALID_OPERATION, message: "level is 0, height is not a multiple of 4" },
Expand Down
66 changes: 66 additions & 0 deletions sdk/tests/conformance/extensions/s3tc-and-rgtc.html
Original file line number Diff line number Diff line change
Expand Up @@ -267,6 +267,72 @@
if (contextVersion >= 2) {
testDXT5_RGBA_PBO();
}

// Test TexImage validation on level dimensions combinations.
debug("");
debug("When level equals 0, width and height must be a multiple of 4.");
debug("When level is larger than 0, this constraint doesn't apply.");
ctu.testTexImageLevelDimensions(gl, ext, validFormats, expectedByteLength, getBlockDimensions,
[
{ level: 0, width: 4, height: 3, expectation: gl.INVALID_OPERATION, message: "0: 4x3" },
{ level: 0, width: 3, height: 4, expectation: gl.INVALID_OPERATION, message: "0: 3x4" },
{ level: 0, width: 2, height: 2, expectation: gl.INVALID_OPERATION, message: "0: 2x2" },
{ level: 0, width: 4, height: 4, expectation: gl.NO_ERROR, message: "0: 4x4" },
{ level: 1, width: 2, height: 2, expectation: gl.NO_ERROR, message: "1: 2x2" },
{ level: 2, width: 1, height: 1, expectation: gl.NO_ERROR, message: "2: 1x1" },
]);

ctu.testTexSubImageDimensions(gl, ext, validFormats, expectedByteLength, getBlockDimensions, 16, 16,
[
{ xoffset: 0, yoffset: 0, width: 4, height: 3,
expectation: gl.INVALID_OPERATION, message: "height is not a multiple of 4" },
{ xoffset: 0, yoffset: 0, width: 3, height: 4,
expectation: gl.INVALID_OPERATION, message: "width is not a multiple of 4" },
{ xoffset: 1, yoffset: 0, width: 4, height: 4,
expectation: gl.INVALID_OPERATION, message: "xoffset is not a multiple of 4" },
{ xoffset: 0, yoffset: 1, width: 4, height: 4,
expectation: gl.INVALID_OPERATION, message: "yoffset is not a multiple of 4" },
{ xoffset: 12, yoffset: 12, width: 4, height: 4,
expectation: gl.NO_ERROR, message: "is valid" },
]);

if (contextVersion >= 2) {
debug("");
debug("Testing NPOT textures");
ctu.testTexImageLevelDimensions(gl, ext, validFormats, expectedByteLength, getBlockDimensions,
[
{ level: 0, width: 12, height: 12, expectation: gl.NO_ERROR, message: "0: 12x12 is valid" },
{ level: 1, width: 6, height: 6, expectation: gl.NO_ERROR, message: "1: 6x6, is valid" },
{ level: 2, width: 3, height: 3, expectation: gl.NO_ERROR, message: "2: 3x3, is valid" },
{ level: 3, width: 1, height: 1, expectation: gl.NO_ERROR, message: "3: 1x1, is valid" },
]);

debug("");
debug("Testing partial updates");
ctu.testTexSubImageDimensions(gl, ext, validFormats, expectedByteLength, getBlockDimensions, 12, 12,
[
{ xoffset: 0, yoffset: 0, width: 4, height: 3,
expectation: gl.INVALID_OPERATION, message: "height is not a multiple of 4" },
{ xoffset: 0, yoffset: 0, width: 3, height: 4,
expectation: gl.INVALID_OPERATION, message: "width is not a multiple of 4" },
{ xoffset: 1, yoffset: 0, width: 4, height: 4,
expectation: gl.INVALID_OPERATION, message: "xoffset is not a multiple of 4" },
{ xoffset: 0, yoffset: 1, width: 4, height: 4,
expectation: gl.INVALID_OPERATION, message: "yoffset is not a multiple of 4" },
{ xoffset: 8, yoffset: 8, width: 4, height: 4,
expectation: gl.NO_ERROR, message: "is valid" },
]);

debug("");
debug("Testing immutable NPOT textures");
ctu.testTexStorageLevelDimensions(gl, ext, validFormats, expectedByteLength, getBlockDimensions,
[
{ width: 12, height: 12, expectation: gl.NO_ERROR, message: "0: 12x12 is valid" },
{ width: 6, height: 6, expectation: gl.NO_ERROR, message: "1: 6x6, is valid" },
{ width: 3, height: 3, expectation: gl.NO_ERROR, message: "2: 3x3, is valid" },
{ width: 1, height: 1, expectation: gl.NO_ERROR, message: "3: 1x1, is valid" },
]);
}
}

function runTestRGTC() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -226,6 +226,72 @@
if (contextVersion >= 2) {
testDXT5_SRGB_ALPHA_PBO();
}

// Test TexImage validation on level dimensions combinations.
debug("");
debug("When level equals 0, width and height must be a multiple of 4.");
debug("When level is larger than 0, this constraint doesn't apply.");
ctu.testTexImageLevelDimensions(gl, ext, validFormats, expectedByteLength, getBlockDimensions,
[
{ level: 0, width: 4, height: 3, expectation: gl.INVALID_OPERATION, message: "0: 4x3" },
{ level: 0, width: 3, height: 4, expectation: gl.INVALID_OPERATION, message: "0: 3x4" },
{ level: 0, width: 2, height: 2, expectation: gl.INVALID_OPERATION, message: "0: 2x2" },
{ level: 0, width: 4, height: 4, expectation: gl.NO_ERROR, message: "0: 4x4" },
{ level: 1, width: 2, height: 2, expectation: gl.NO_ERROR, message: "1: 2x2" },
{ level: 2, width: 1, height: 1, expectation: gl.NO_ERROR, message: "2: 1x1" },
]);

ctu.testTexSubImageDimensions(gl, ext, validFormats, expectedByteLength, getBlockDimensions, 16, 16,
[
{ xoffset: 0, yoffset: 0, width: 4, height: 3,
expectation: gl.INVALID_OPERATION, message: "height is not a multiple of 4" },
{ xoffset: 0, yoffset: 0, width: 3, height: 4,
expectation: gl.INVALID_OPERATION, message: "width is not a multiple of 4" },
{ xoffset: 1, yoffset: 0, width: 4, height: 4,
expectation: gl.INVALID_OPERATION, message: "xoffset is not a multiple of 4" },
{ xoffset: 0, yoffset: 1, width: 4, height: 4,
expectation: gl.INVALID_OPERATION, message: "yoffset is not a multiple of 4" },
{ xoffset: 12, yoffset: 12, width: 4, height: 4,
expectation: gl.NO_ERROR, message: "is valid" },
]);

if (contextVersion >= 2) {
debug("");
debug("Testing NPOT textures");
ctu.testTexImageLevelDimensions(gl, ext, validFormats, expectedByteLength, getBlockDimensions,
[
{ level: 0, width: 12, height: 12, expectation: gl.NO_ERROR, message: "0: 12x12 is valid" },
{ level: 1, width: 6, height: 6, expectation: gl.NO_ERROR, message: "1: 6x6, is valid" },
{ level: 2, width: 3, height: 3, expectation: gl.NO_ERROR, message: "2: 3x3, is valid" },
{ level: 3, width: 1, height: 1, expectation: gl.NO_ERROR, message: "3: 1x1, is valid" },
]);

debug("");
debug("Testing partial updates");
ctu.testTexSubImageDimensions(gl, ext, validFormats, expectedByteLength, getBlockDimensions, 12, 12,
[
{ xoffset: 0, yoffset: 0, width: 4, height: 3,
expectation: gl.INVALID_OPERATION, message: "height is not a multiple of 4" },
{ xoffset: 0, yoffset: 0, width: 3, height: 4,
expectation: gl.INVALID_OPERATION, message: "width is not a multiple of 4" },
{ xoffset: 1, yoffset: 0, width: 4, height: 4,
expectation: gl.INVALID_OPERATION, message: "xoffset is not a multiple of 4" },
{ xoffset: 0, yoffset: 1, width: 4, height: 4,
expectation: gl.INVALID_OPERATION, message: "yoffset is not a multiple of 4" },
{ xoffset: 8, yoffset: 8, width: 4, height: 4,
expectation: gl.NO_ERROR, message: "is valid" },
]);

debug("");
debug("Testing immutable NPOT textures");
ctu.testTexStorageLevelDimensions(gl, ext, validFormats, expectedByteLength, getBlockDimensions,
[
{ width: 12, height: 12, expectation: gl.NO_ERROR, message: "0: 12x12 is valid" },
{ width: 6, height: 6, expectation: gl.NO_ERROR, message: "1: 6x6, is valid" },
{ width: 3, height: 3, expectation: gl.NO_ERROR, message: "2: 3x3, is valid" },
{ width: 1, height: 1, expectation: gl.NO_ERROR, message: "3: 1x1, is valid" },
]);
}
}

function testDXT1_SRGB() {
Expand Down
33 changes: 31 additions & 2 deletions sdk/tests/js/tests/compressed-texture-utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -165,14 +165,15 @@ let testFormatRestrictionsOnBufferSize = function(gl, validFormats, expectedByte
* @param {number} height Height of the image in pixels.
* @param {Object} subImageConfigs configs for compressedTexSubImage calls
*/
let testTexSubImageDimensions = function(gl, validFormats, expectedByteLength, getBlockDimensions, width, height, subImageConfigs) {
let testTexSubImageDimensions = function(gl, ext, validFormats, expectedByteLength, getBlockDimensions, width, height, subImageConfigs) {
let tex = gl.createTexture();
gl.bindTexture(gl.TEXTURE_2D, tex);

for (let formatId in validFormats) {
if (validFormats.hasOwnProperty(formatId)) {
let format = validFormats[formatId];
let blockSize = getBlockDimensions(format);
debug("testing " + ctu.formatToString(ext, format));
let expectedSize = expectedByteLength(width, height, format);
let data = new Uint8Array(expectedSize);

Expand All @@ -192,14 +193,15 @@ let testTexSubImageDimensions = function(gl, validFormats, expectedByteLength, g
gl.deleteTexture(tex);
};

let testTexImageLevelDimensions = function(gl, validFormats, expectedByteLength, getBlockDimensions, imageConfigs) {
let testTexImageLevelDimensions = function(gl, ext, validFormats, expectedByteLength, getBlockDimensions, imageConfigs) {
let tex = gl.createTexture();
gl.bindTexture(gl.TEXTURE_2D, tex);

for (let formatId in validFormats) {
if (validFormats.hasOwnProperty(formatId)) {
let format = validFormats[formatId];
let blockSize = getBlockDimensions(format);
debug("testing " + ctu.formatToString(ext, format));

for (let i = 0, len = imageConfigs.length; i < len; ++i) {
let c = imageConfigs[i];
Expand All @@ -214,6 +216,32 @@ let testTexImageLevelDimensions = function(gl, validFormats, expectedByteLength,
gl.deleteTexture(tex);
}

let testTexStorageLevelDimensions = function(gl, ext, validFormats, expectedByteLength, getBlockDimensions, imageConfigs) {
for (let formatId in validFormats) {
let tex = gl.createTexture();
gl.bindTexture(gl.TEXTURE_2D, tex);

if (validFormats.hasOwnProperty(formatId)) {
let format = validFormats[formatId];
let blockSize = getBlockDimensions(format);
debug("testing " + ctu.formatToString(ext, format));

for (let i = 0, len = imageConfigs.length; i < len; ++i) {
let c = imageConfigs[i];
let data = new Uint8Array(expectedByteLength(c.width, c.height, format));
if (i == 0) {
gl.texStorage2D(gl.TEXTURE_2D, imageConfigs.length, format, c.width, c.height);
wtu.glErrorShouldBe(gl, c.expectation, c.message);
}
gl.compressedTexSubImage2D(gl.TEXTURE_2D, i, 0, 0, c.width, c.height, format, data);
wtu.glErrorShouldBe(gl, c.expectation, c.message);
}
}
gl.bindTexture(gl.TEXTURE_2D, null);
gl.deleteTexture(tex);
}
}

return {
formatToString: formatToString,
insertCaptionedImg: insertCaptionedImg,
Expand All @@ -224,6 +252,7 @@ return {
testFormatRestrictionsOnBufferSize: testFormatRestrictionsOnBufferSize,
testTexSubImageDimensions: testTexSubImageDimensions,
testTexImageLevelDimensions: testTexImageLevelDimensions,
testTexStorageLevelDimensions: testTexStorageLevelDimensions,
};

})();

0 comments on commit 5fcfea8

Please sign in to comment.