diff --git a/sdk/tests/conformance/extensions/webgl-compressed-texture-astc.html b/sdk/tests/conformance/extensions/webgl-compressed-texture-astc.html index d737c3f2a..bc9ce6ff0 100644 --- a/sdk/tests/conformance/extensions/webgl-compressed-texture-astc.html +++ b/sdk/tests/conformance/extensions/webgl-compressed-texture-astc.html @@ -2163,20 +2163,6 @@ } function uploadSubData(target) { - function checkResult(target, expectations, dim) { - switch (target) { - case gl.TEXTURE_2D: - wtu.glErrorShouldBe(gl, expectations[0], "uploading compressed 2D texture data via compressedTexSubImage" + dim); - break; - case gl.TEXTURE_2D_ARRAY: - wtu.glErrorShouldBe(gl, expectations[1], "uploading compressed 2D array texture data via compressedTexSubImage" + dim); - break; - case gl.TEXTURE_3D: - wtu.glErrorShouldBe(gl, expectations[2], "uploading compressed 3D texture data via compressedTexSubImage" + dim); - break; - } - } - gl.compressedTexSubImage2D(target, 0, 0, 0, width, height, format, data); checkResult(target, [gl.NO_ERROR, gl.INVALID_ENUM, gl.INVALID_ENUM ], "2D"); @@ -2186,6 +2172,31 @@ } } + function uploadSubDataOffset(target) { + const blockSize = getBlockDimensions(format); + if ((width % blockSize.width) || (height % blockSize.height)) { + // Skip test for unaligned blocks + return; + } + + const x = blockSize.width; + const y = blockSize.height; + const blitWidth = width - x; + const blitHeight = height - y; + + // Offset the update by one horizontal and one vertical rows. + // ASTC block size is always 16 bytes (128 bits) + const offset = (width / blockSize.width + height / blockSize.height - 1) * 16; + + gl.compressedTexSubImage2D(target, 0, x, y, blitWidth, blitHeight, format, data, offset); + checkResult(target, [gl.NO_ERROR, gl.INVALID_ENUM, gl.INVALID_ENUM ], "2D", true); + + if (useES3) { + gl.compressedTexSubImage3D(target, 0, x, y, 0, blitWidth, blitHeight, 1, format, data, offset); + checkResult(target, [gl.INVALID_ENUM, gl.NO_ERROR, gl.NO_ERROR], "3D", true); + } + } + function setupFilledTexture(target) { var tex = gl.createTexture(); gl.bindTexture(target, tex); @@ -2277,6 +2288,12 @@ checkSampling(gl.TEXTURE_2D) gl.deleteTexture(tex); + // Upload with offsets + tex = setupEmptyTexture(gl.TEXTURE_2D, false); + wtu.glErrorShouldBe(gl, gl.NO_ERROR, "allocating empty compressed texture array via compressedTexImage3D"); + uploadSubDataOffset(gl.TEXTURE_2D); + gl.deleteTexture(tex); + // mutable filled tex = setupFilledTexture(gl.TEXTURE_2D); wtu.glErrorShouldBe(gl, gl.NO_ERROR, "allocating filled compressed texture via compressedTexImage2D"); @@ -2304,6 +2321,12 @@ checkSampling(gl.TEXTURE_2D_ARRAY) gl.deleteTexture(tex); + // Upload with offsets + tex = setupEmptyTexture(gl.TEXTURE_2D_ARRAY, false); + wtu.glErrorShouldBe(gl, gl.NO_ERROR, "allocating empty compressed texture array via compressedTexImage3D"); + uploadSubDataOffset(gl.TEXTURE_2D_ARRAY); + gl.deleteTexture(tex); + // mutable filled tex = setupFilledTexture(gl.TEXTURE_2D_ARRAY); wtu.glErrorShouldBe(gl, gl.NO_ERROR, "allocating filled compressed texture array via compressedTexImage3D"); @@ -2338,6 +2361,17 @@ } gl.deleteTexture(tex); + // Upload with offsets + tex = setupEmptyTexture(gl.TEXTURE_3D, false); + if (hasHdr) { + wtu.glErrorShouldBe(gl, gl.NO_ERROR, "allocating empty compressed sliced 3D texture via compressedTexImage3D"); + checkErrorColor(); + uploadSubDataOffset(gl.TEXTURE_3D); + } else { + wtu.glErrorShouldBe(gl, gl.INVALID_OPERATION, "allocating empty compressed sliced 3D texture via compressedTexImage3D"); + } + gl.deleteTexture(tex); + // mutable filled tex = setupFilledTexture(gl.TEXTURE_3D); if (hasHdr) { @@ -2420,6 +2454,21 @@ } } +function checkResult(target, expectations, dim, offsets = false) { + const offsetStr = offsets ? " with x/y offsets" : ""; + switch (target) { + case gl.TEXTURE_2D: + wtu.glErrorShouldBe(gl, expectations[0], "uploading compressed 2D texture data via compressedTexSubImage" + dim + offsetStr); + break; + case gl.TEXTURE_2D_ARRAY: + wtu.glErrorShouldBe(gl, expectations[1], "uploading compressed 2D array texture data via compressedTexSubImage" + dim + offsetStr); + break; + case gl.TEXTURE_3D: + wtu.glErrorShouldBe(gl, expectations[2], "uploading compressed 3D texture data via compressedTexSubImage" + dim + offsetStr); + break; + } +} + // Builds several tests from two arrays // data gives each Uint8Array encoded data to use // formats the associate format to decode the data @@ -2484,7 +2533,7 @@ return { width: parseInt(match[1], 10), height: parseInt(match[2], 10) - }; + }; } } testFailed('Could not find block dimensions for format ' + ctu.formatToString(ext, format));