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/rgb-format-support.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/rgb-format-support.html')
-rw-r--r-- | dom/canvas/test/webgl-conf/checkout/conformance2/rendering/rgb-format-support.html | 111 |
1 files changed, 111 insertions, 0 deletions
diff --git a/dom/canvas/test/webgl-conf/checkout/conformance2/rendering/rgb-format-support.html b/dom/canvas/test/webgl-conf/checkout/conformance2/rendering/rgb-format-support.html new file mode 100644 index 0000000000..46712ae68b --- /dev/null +++ b/dom/canvas/test/webgl-conf/checkout/conformance2/rendering/rgb-format-support.html @@ -0,0 +1,111 @@ +<!-- +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"> +<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> +<script> +"use strict"; +var wtu = WebGLTestUtils; +description("Verify RGB/RGB8 textures and renderbuffers support"); + +var gl = wtu.create3DContext(undefined, undefined, 2); + +function testRenderbuffer(width, height) { + var samples = gl.getInternalformatParameter(gl.RENDERBUFFER, gl.RGB8, gl.SAMPLES); + wtu.glErrorShouldBe(gl, gl.NO_ERROR, "should be no errors from getInternalformatParameter()"); + + if (!samples || samples.length == 0) { + testFailed("getInternalformatParameter on RGB8 fails to return valid samples"); + return; + } + + for (var idx = 0; idx < samples.length + 2; ++idx) { + debug(""); + var renderbuffer = gl.createRenderbuffer(); + gl.bindRenderbuffer(gl.RENDERBUFFER, renderbuffer); + var sampleCount = 0; + switch (idx) { + case samples.length: + sampleCount = 0; + break; + case samples.length + 1: + sampleCount = -1; // non multisampled + break; + default: + sampleCount = samples[idx]; + } + + if (sampleCount < 0) { + debug("test non-multisampled RGB8 renderbuffer"); + gl.renderbufferStorage(gl.RENDERBUFFER, gl.RGB8, 2, 2); + } else { + debug("test RGB8 renderbuffer with " + sampleCount + " samples"); + gl.renderbufferStorageMultisample(gl.RENDERBUFFER, sampleCount, gl.RGB8, width, height); + } + wtu.glErrorShouldBe(gl, gl.NO_ERROR, "should be no errors from renderbufferStorage{Multisample}"); + + var fbo = gl.createFramebuffer(); + gl.bindFramebuffer(gl.FRAMEBUFFER, fbo); + gl.framebufferRenderbuffer(gl.FRAMEBUFFER, gl.COLOR_ATTACHMENT0, gl.RENDERBUFFER, renderbuffer); + if (gl.checkFramebufferStatus(gl.FRAMEBUFFER) != gl.FRAMEBUFFER_COMPLETE) { + testFailed("framebuffer with renderbuffer is incomplete"); + } else { + testPassed("framebuffer with renderbuffer is complete"); + } + + gl.clearColor(1, 0, 1, 1); + gl.clear(gl.COLOR_BIT); + wtu.glErrorShouldBe(gl, gl.NO_ERROR, "should be no errors from clear()"); + } +} + +function testTexture(width, height) { + var formats = [ "RGB", "RGB8" ]; + for (var idx = 0; idx < formats.length; ++idx) { + debug(""); + debug("test texture format " + formats[idx]); + var internalformat = gl[formats[idx]]; + var tex = gl.createTexture(); + gl.bindTexture(gl.TEXTURE_2D, tex); + gl.texImage2D(gl.TEXTURE_2D, 0, internalformat, width, height, 0, gl.RGB, gl.UNSIGNED_BYTE, null); + wtu.glErrorShouldBe(gl, gl.NO_ERROR, "should be no errors from texture setup"); + + var fbo = gl.createFramebuffer(); + gl.bindFramebuffer(gl.FRAMEBUFFER, fbo); + gl.framebufferTexture2D(gl.FRAMEBUFFER, gl.COLOR_ATTACHMENT0, gl.TEXTURE_2D, tex, 0); + if (gl.checkFramebufferStatus(gl.FRAMEBUFFER) != gl.FRAMEBUFFER_COMPLETE) { + testFailed("framebuffer with texture is incomplete"); + } else { + testPassed("framebuffer with texture is complete"); + } + + gl.clearColor(1, 0, 1, 1); + gl.clear(gl.COLOR_BIT); + wtu.glErrorShouldBe(gl, gl.NO_ERROR, "should be no errors from clear()"); + } +} + +if (!gl) { + testFailed('canvas.getContext() failed'); +} else { + testRenderbuffer(2, 2); + testTexture(2, 2); +} + +var successfullyParsed = true; +</script> +<script src="../../js/js-test-post.js"></script> +</body> +</html> |