diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 19:33:14 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 19:33:14 +0000 |
commit | 36d22d82aa202bb199967e9512281e9a53db42c9 (patch) | |
tree | 105e8c98ddea1c1e4784a60a5a6410fa416be2de /dom/canvas/test/webgl-conf/checkout/conformance2/rendering/clearbuffer-sub-source.html | |
parent | Initial commit. (diff) | |
download | firefox-esr-36d22d82aa202bb199967e9512281e9a53db42c9.tar.xz firefox-esr-36d22d82aa202bb199967e9512281e9a53db42c9.zip |
Adding upstream version 115.7.0esr.upstream/115.7.0esrupstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'dom/canvas/test/webgl-conf/checkout/conformance2/rendering/clearbuffer-sub-source.html')
-rw-r--r-- | dom/canvas/test/webgl-conf/checkout/conformance2/rendering/clearbuffer-sub-source.html | 110 |
1 files changed, 110 insertions, 0 deletions
diff --git a/dom/canvas/test/webgl-conf/checkout/conformance2/rendering/clearbuffer-sub-source.html b/dom/canvas/test/webgl-conf/checkout/conformance2/rendering/clearbuffer-sub-source.html new file mode 100644 index 0000000000..616d2bda4c --- /dev/null +++ b/dom/canvas/test/webgl-conf/checkout/conformance2/rendering/clearbuffer-sub-source.html @@ -0,0 +1,110 @@ +<!-- +Copyright (c) 2019 The Khronos Group Inc. +Use of this source code is governed by an MIT-style license that can be +found in the LICENSE.txt file. +--> + +<!DOCTYPE html> +<html> +<head> +<meta charset="utf-8"> +<title>Test clearBuffer functions with optional srcOffset argument</title> +<link rel="stylesheet" href="../../resources/js-test-style.css"/> +<script src="../../js/js-test-pre.js"></script> +<script src="../../js/webgl-test-utils.js"></script> +</head> +<body> +<div id="description"></div> +<div id="console"></div> +<canvas id="canvas" width="20" height="20"> </canvas> +<script> +"use strict"; +description("This tests clearBuffer* functions with optional srcOffset argument"); + +function verifyOnePixel(readFormat, readType, arrayType, expectedColor) { + var buffer = new arrayType(4); + gl.readPixels(0, 0, 1, 1, readFormat, readType, buffer); + if (buffer[0] == expectedColor[0] && + buffer[1] == expectedColor[1] && + buffer[2] == expectedColor[2] && + buffer[3] == expectedColor[3]) { + testPassed("clearBuffer sets the renderbuffer with the correct data"); + } else { + testFailed("clearBuffer fails to work. Expected: " + expectedColor + ", got: " + buffer); + } +} + +function testClearBuffer(func, format, arrayType, readFormat, readType) { + debug(""); + debug("Testing " + func); + + var fb = gl.createFramebuffer(); + gl.bindFramebuffer(gl.FRAMEBUFFER, fb); + + var renderbuffer = gl.createRenderbuffer(); + gl.bindRenderbuffer(gl.RENDERBUFFER, renderbuffer); + gl.framebufferRenderbuffer(gl.FRAMEBUFFER, gl.COLOR_ATTACHMENT0, gl.RENDERBUFFER, renderbuffer); + gl.renderbufferStorage(gl.RENDERBUFFER, format, canvas.width, canvas.height); + shouldBe('gl.checkFramebufferStatus(gl.FRAMEBUFFER)', 'gl.FRAMEBUFFER_COMPLETE'); + + var srcData = new arrayType([1, 2, 3, 4, 5, 6]); + gl[func](gl.COLOR, 0, srcData); + wtu.glErrorShouldBe(gl, gl.NO_ERROR, "clearBuffer with no srcOffset should succeed"); + verifyOnePixel(readFormat, readType, arrayType, [1,2,3,4]); + + gl[func](gl.COLOR, 0, srcData, 0); + wtu.glErrorShouldBe(gl, gl.NO_ERROR, "clearBuffer with srcOffset = 0 should succeed"); + verifyOnePixel(readFormat, readType, arrayType, [1,2,3,4]); + + gl[func](gl.COLOR, 0, srcData, 2); + wtu.glErrorShouldBe(gl, gl.NO_ERROR, "clearBuffer with srcOffset = 2 should succeed"); + verifyOnePixel(readFormat, readType, arrayType, [3,4, 5, 6]); + + gl[func](gl.COLOR, 0, srcData, 4); + wtu.glErrorShouldBe(gl, gl.INVALID_VALUE, "clearBuffer with srcOffset = 4 should fail: out of bounds"); + + gl.deleteFramebuffer(fb); + gl.deleteRenderbuffer(renderbuffer); +} + +var wtu = WebGLTestUtils; +var canvas = document.getElementById("canvas"); +var gl = wtu.create3DContext(canvas, undefined, 2); +if (!gl) { + testFailed("context does not exist"); +} else { + testPassed("context exists"); + + var testCases = [ + { + func: "clearBufferiv", format: gl.RGBA32I, arrayType: Int32Array, + readFormat: gl.RGBA_INTEGER, readType: gl.INT, + }, + { + func: "clearBufferuiv", format: gl.RGBA32UI, arrayType: Uint32Array, + readFormat: gl.RGBA_INTEGER, readType: gl.UNSIGNED_INT, + }, + { + func: "clearBufferfv", format: gl.RGBA32F, arrayType: Float32Array, + readFormat: gl.RGBA, readType: gl.FLOAT, + extension: "EXT_color_buffer_float", + }, + ]; + + for (var tt = 0; tt < testCases.length; ++tt) { + var test = testCases[tt]; + if (test.extension && !gl.getExtension(test.extension)) + continue; + testClearBuffer(test.func, test.format, test.arrayType, test.readFormat, test.readType); + } +} + +debug(""); +wtu.glErrorShouldBe(gl, gl.NO_ERROR, "should be no error"); +var successfullyParsed = true; + +</script> +<script src="../../js/js-test-post.js"></script> + +</body> +</html> |