Automatic update from web-platform-tests script: Fix panic in compressedTexSubImage2D when no base image exists Calling compressedTexSubImage2D without a prior compressedTexImage2D for the same texture target and level caused a panic because image_info_for_target returned None and .unwrap() was called on it. Per the WebGL spec, this should generate GL_INVALID_OPERATION instead of panicking. Replace the unwrap with proper error handling. Also adds a WPT crash test that reproduces the original panic. Fixes: #43527 Signed-off-by: thebabalola <t.babalolajoseph@gmail.com> -- script: Add MissingBaseTexture variant and rewrite WPT test as testharness Signed-off-by: thebabalola <t.babalolajoseph@gmail.com> -- wpt-commits: 1d323b6b5c723bb21f852e16c6f47f4552cb5075, c94a02b563e7b4e8f89d35f19261657b29f4e0ae wpt-pr: 59061
38 lines
1.4 KiB
HTML
38 lines
1.4 KiB
HTML
<!doctype html>
|
|
<title>compressedTexSubImage2D without prior compressedTexImage2D generates INVALID_OPERATION</title>
|
|
<link rel=author title="Babalola Taiwo Joseph" href=mailto:t.babalolajoseph@gmail.com>
|
|
<link rel=help href=https://www.khronos.org/registry/webgl/specs/latest/#5.14.8>
|
|
<script src=/resources/testharness.js></script>
|
|
<script src=/resources/testharnessreport.js></script>
|
|
|
|
<div id=log></div>
|
|
<script>
|
|
test(function() {
|
|
var canvas = document.createElement("canvas");
|
|
var gl = canvas.getContext("webgl");
|
|
assert_true(!!gl, "WebGL context should be available");
|
|
|
|
var s3tc = gl.getExtension("WEBGL_compressed_texture_s3tc");
|
|
var etc1 = gl.getExtension("WEBGL_compressed_texture_etc1");
|
|
|
|
var format, dataSize;
|
|
if (s3tc) {
|
|
format = s3tc.COMPRESSED_RGB_S3TC_DXT1_EXT;
|
|
dataSize = 8;
|
|
} else if (etc1) {
|
|
format = etc1.COMPRESSED_RGB_ETC1_WEBGL;
|
|
dataSize = 8;
|
|
}
|
|
|
|
assert_true(!!format, "A supported compressed texture format must be available");
|
|
|
|
var texture = gl.createTexture();
|
|
gl.bindTexture(gl.TEXTURE_2D, texture);
|
|
|
|
gl.compressedTexSubImage2D(gl.TEXTURE_2D, 0, 0, 0, 4, 4, format, new Uint8Array(dataSize));
|
|
|
|
assert_equals(gl.getError(), gl.INVALID_OPERATION,
|
|
"compressedTexSubImage2D without a prior compressedTexImage2D should generate INVALID_OPERATION");
|
|
}, "compressedTexSubImage2D without base image generates INVALID_OPERATION");
|
|
</script>
|