From 5fcfea8e05a29ab3d81c10cc56f97179e8a84110 Mon Sep 17 00:00:00 2001 From: Alexey Knyazev <3479527+lexaknyazev@users.noreply.github.com> Date: Tue, 6 Apr 2021 22:55:59 +0400 Subject: [PATCH] Add npot tests to S3TC (#3258) Fixes #3117. The updated tests pass on Chrome Stable . Related to http://crbug.com/angleproject/4841 . --- .../ext-texture-compression-bptc.html | 4 +- .../ext-texture-compression-rgtc.html | 4 +- .../conformance/extensions/s3tc-and-rgtc.html | 66 +++++++++++++++++++ .../webgl-compressed-texture-s3tc-srgb.html | 66 +++++++++++++++++++ .../js/tests/compressed-texture-utils.js | 33 +++++++++- 5 files changed, 167 insertions(+), 6 deletions(-) diff --git a/sdk/tests/conformance/extensions/ext-texture-compression-bptc.html b/sdk/tests/conformance/extensions/ext-texture-compression-bptc.html index 1fed9d9fd7..d4bb685a3b 100644 --- a/sdk/tests/conformance/extensions/ext-texture-compression-bptc.html +++ b/sdk/tests/conformance/extensions/ext-texture-compression-bptc.html @@ -60,7 +60,7 @@ // * is not a multiple of four, and plus is // not equal to TEXTURE_HEIGHT; or // * or 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" }, @@ -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" }, diff --git a/sdk/tests/conformance/extensions/ext-texture-compression-rgtc.html b/sdk/tests/conformance/extensions/ext-texture-compression-rgtc.html index c2a2d41690..1542131bc8 100644 --- a/sdk/tests/conformance/extensions/ext-texture-compression-rgtc.html +++ b/sdk/tests/conformance/extensions/ext-texture-compression-rgtc.html @@ -65,7 +65,7 @@ // * is not a multiple of four, and plus is // not equal to TEXTURE_HEIGHT; or // * or 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" }, @@ -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" }, diff --git a/sdk/tests/conformance/extensions/s3tc-and-rgtc.html b/sdk/tests/conformance/extensions/s3tc-and-rgtc.html index a91e8efef0..55dc483afe 100644 --- a/sdk/tests/conformance/extensions/s3tc-and-rgtc.html +++ b/sdk/tests/conformance/extensions/s3tc-and-rgtc.html @@ -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() { diff --git a/sdk/tests/conformance/extensions/webgl-compressed-texture-s3tc-srgb.html b/sdk/tests/conformance/extensions/webgl-compressed-texture-s3tc-srgb.html index 80221508eb..2743b92adf 100644 --- a/sdk/tests/conformance/extensions/webgl-compressed-texture-s3tc-srgb.html +++ b/sdk/tests/conformance/extensions/webgl-compressed-texture-s3tc-srgb.html @@ -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() { diff --git a/sdk/tests/js/tests/compressed-texture-utils.js b/sdk/tests/js/tests/compressed-texture-utils.js index d6f02c4d43..46d155f5f1 100644 --- a/sdk/tests/js/tests/compressed-texture-utils.js +++ b/sdk/tests/js/tests/compressed-texture-utils.js @@ -165,7 +165,7 @@ 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); @@ -173,6 +173,7 @@ let testTexSubImageDimensions = function(gl, validFormats, expectedByteLength, g 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); @@ -192,7 +193,7 @@ 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); @@ -200,6 +201,7 @@ let testTexImageLevelDimensions = function(gl, validFormats, expectedByteLength, 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]; @@ -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, @@ -224,6 +252,7 @@ return { testFormatRestrictionsOnBufferSize: testFormatRestrictionsOnBufferSize, testTexSubImageDimensions: testTexSubImageDimensions, testTexImageLevelDimensions: testTexImageLevelDimensions, + testTexStorageLevelDimensions: testTexStorageLevelDimensions, }; })(); \ No newline at end of file