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/renderbuffers/multisample-with-full-sample-counts.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/renderbuffers/multisample-with-full-sample-counts.html')
-rw-r--r-- | dom/canvas/test/webgl-conf/checkout/conformance2/renderbuffers/multisample-with-full-sample-counts.html | 98 |
1 files changed, 98 insertions, 0 deletions
diff --git a/dom/canvas/test/webgl-conf/checkout/conformance2/renderbuffers/multisample-with-full-sample-counts.html b/dom/canvas/test/webgl-conf/checkout/conformance2/renderbuffers/multisample-with-full-sample-counts.html new file mode 100644 index 0000000000..2e04385f28 --- /dev/null +++ b/dom/canvas/test/webgl-conf/checkout/conformance2/renderbuffers/multisample-with-full-sample-counts.html @@ -0,0 +1,98 @@ +<!-- +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> +<canvas id="canvas" width="32" height="32" style="width: 32px; height: 32px;"></canvas> +<div id="description"></div> +<div id="console"></div> +<script> +"use strict"; +var wtu = WebGLTestUtils; +description(' Test multisample with sample number from 1 to max sample number which also includes the samples that may not be in the supported sample list'); + +var gl = wtu.create3DContext("canvas", null, 2); +var size = 32; +var program; + +if (!gl) { + testFailed('canvas.getContext() failed'); +} else { + program = wtu.setupColorQuad(gl); + gl.viewport(0, 0, size, size); + var supportedSampleCountArray = gl.getInternalformatParameter(gl.RENDERBUFFER, gl.RGBA8, gl.SAMPLES); + var iterationCount = supportedSampleCountArray[0] + 1; + for (var i = 1; i < iterationCount; i++) + { + runTest(gl, i, false); + runTest(gl, i, true); + } +} + +function runTest(gl, sampleCount, isInverted) { + // Setup multi-sample RBO + var msColorRbo = gl.createRenderbuffer(); + gl.bindRenderbuffer(gl.RENDERBUFFER, msColorRbo); + gl.renderbufferStorageMultisample(gl.RENDERBUFFER, sampleCount, gl.RGBA8, size, size); + + // Setup multi-sample FBO. + var msFbo = gl.createFramebuffer(); + gl.bindFramebuffer(gl.FRAMEBUFFER, msFbo); + gl.framebufferRenderbuffer(gl.FRAMEBUFFER, gl.COLOR_ATTACHMENT0, gl.RENDERBUFFER, msColorRbo); + + // Setup resolve color RBO. + var resolveColorRbo = gl.createRenderbuffer(); + gl.bindRenderbuffer(gl.RENDERBUFFER, resolveColorRbo); + gl.renderbufferStorage(gl.RENDERBUFFER, gl.RGBA8, size, size); + // Setup resolve FBO + var resolveFbo = gl.createFramebuffer(); + gl.bindFramebuffer(gl.FRAMEBUFFER, resolveFbo); + gl.framebufferRenderbuffer(gl.FRAMEBUFFER, gl.COLOR_ATTACHMENT0, gl.RENDERBUFFER, resolveColorRbo); + + gl.bindFramebuffer(gl.FRAMEBUFFER, msFbo); + if (gl.checkFramebufferStatus(gl.FRAMEBUFFER) != gl.FRAMEBUFFER_COMPLETE) { + testFailed("Framebuffer incomplete."); + return; + } + gl.clearColor(0.0, 0.0, 0.0, 1.0); + gl.clear(gl.COLOR_BUFFER_BIT); + + gl.enable(gl.SAMPLE_COVERAGE); + var coverageValue = isInverted ? 0.0 : 1.0; + gl.sampleCoverage(coverageValue, isInverted); + + var quadColor = [1.0, 0.0, 0.0, 1.0]; + gl.useProgram(program); + wtu.drawFloatColorQuad(gl, quadColor); + + gl.bindFramebuffer(gl.DRAW_FRAMEBUFFER, resolveFbo); + gl.blitFramebuffer(0, 0, size, size, 0, 0, size, size, gl.COLOR_BUFFER_BIT, gl.NEAREST); + + gl.bindFramebuffer(gl.FRAMEBUFFER, resolveFbo); + wtu.checkCanvasRect(gl, 0, 0, size, size, [255, 0, 0, 255], + "User buffer has been rendered to red with sample = " + + sampleCount + ", coverageValue = " + coverageValue + + " and isInverted = " + isInverted, 3); + + gl.disable(gl.SAMPLE_COVERAGE); + gl.deleteRenderbuffer(msColorRbo); + gl.deleteRenderbuffer(resolveColorRbo); + gl.deleteFramebuffer(msFbo); + gl.deleteFramebuffer(resolveFbo); +} + +var successfullyParsed = true; +</script> +<script src="../../js/js-test-post.js"></script> +</body> +</html> |