Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
79 changes: 64 additions & 15 deletions sdk/tests/conformance/extensions/webgl-compressed-texture-astc.html
Original file line number Diff line number Diff line change
Expand Up @@ -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");

Expand All @@ -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);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For completeness, please also test the length override parameter like

compressedTexSubImage2D(target, 0, x, y, blitWidth, blitHeight, format, data,
                        0, data.length - 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);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ditto.

checkResult(target, [gl.INVALID_ENUM, gl.NO_ERROR, gl.NO_ERROR], "3D", true);
}
}

function setupFilledTexture(target) {
var tex = gl.createTexture();
gl.bindTexture(target, tex);
Expand Down Expand Up @@ -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");
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Incorrect message

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");
Expand Down Expand Up @@ -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");
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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));
Expand Down