summaryrefslogtreecommitdiffstats
path: root/dom/canvas/test/webgl-mochitest/ensure-exts/test_implicit.html
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-19 00:47:55 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-19 00:47:55 +0000
commit26a029d407be480d791972afb5975cf62c9360a6 (patch)
treef435a8308119effd964b339f76abb83a57c29483 /dom/canvas/test/webgl-mochitest/ensure-exts/test_implicit.html
parentInitial commit. (diff)
downloadfirefox-26a029d407be480d791972afb5975cf62c9360a6.tar.xz
firefox-26a029d407be480d791972afb5975cf62c9360a6.zip
Adding upstream version 124.0.1.upstream/124.0.1
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'dom/canvas/test/webgl-mochitest/ensure-exts/test_implicit.html')
-rw-r--r--dom/canvas/test/webgl-mochitest/ensure-exts/test_implicit.html129
1 files changed, 129 insertions, 0 deletions
diff --git a/dom/canvas/test/webgl-mochitest/ensure-exts/test_implicit.html b/dom/canvas/test/webgl-mochitest/ensure-exts/test_implicit.html
new file mode 100644
index 0000000000..e3ce1ad130
--- /dev/null
+++ b/dom/canvas/test/webgl-mochitest/ensure-exts/test_implicit.html
@@ -0,0 +1,129 @@
+<!DOCTYPE HTML>
+<html>
+ <head>
+ <meta charset='utf-8'/>
+ <script src='/tests/SimpleTest/SimpleTest.js'></script>
+ <link rel='stylesheet' href='/tests/SimpleTest/test.css'>
+ <script src='ensure-ext.js'></script>
+ </head>
+ <body>
+ <script id='g_vs' type='text/plain'>
+
+void main() {
+ gl_PointSize = 1.0;
+}
+
+ </script>
+ <script id='g_fs' type='text/plain'>
+
+void main() {
+ gl_FragColor = vec4(0);
+}
+
+ </script>
+ <script>
+
+'use strict';
+
+let gl = null;
+
+function CheckTexFloatRenderable(rgbaInternal, type) {
+ const tex = gl.createTexture();
+ gl.bindTexture(gl.TEXTURE_2D, tex);
+ gl.texImage2D(gl.TEXTURE_2D, 0, rgbaInternal, 1, 1, 0, gl.RGBA, type, null);
+
+ const fb = gl.createFramebuffer();
+ gl.bindFramebuffer(gl.FRAMEBUFFER, fb);
+ gl.framebufferTexture2D(gl.FRAMEBUFFER, gl.COLOR_ATTACHMENT0, gl.TEXTURE_2D, tex, 0);
+ return gl.checkFramebufferStatus(gl.FRAMEBUFFER) == gl.FRAMEBUFFER_COMPLETE;
+}
+
+function CheckRbFloatRenderable(format) {
+ const rb = gl.createRenderbuffer();
+ gl.bindRenderbuffer(gl.RENDERBUFFER, rb);
+ gl.renderbufferStorage(gl.RENDERBUFFER, format, 1, 1);
+
+ const fb = gl.createFramebuffer();
+ gl.bindFramebuffer(gl.FRAMEBUFFER, fb);
+ gl.framebufferRenderbuffer(gl.FRAMEBUFFER, gl.COLOR_ATTACHMENT0, gl.RENDERBUFFER, rb);
+ return gl.checkFramebufferStatus(gl.FRAMEBUFFER) == gl.FRAMEBUFFER_COMPLETE;
+}
+
+function CheckBlending() {
+ function CompileShader(type, elem) {
+ const text = elem.innerHTML.trim();
+ const s = gl.createShader(type);
+ gl.shaderSource(s, text);
+ gl.compileShader(s);
+ return s;
+ }
+
+ const vs = CompileShader(gl.VERTEX_SHADER, g_vs);
+ const fs = CompileShader(gl.FRAGMENT_SHADER, g_fs);
+ const p = gl.createProgram();
+ gl.attachShader(p, vs);
+ gl.attachShader(p, fs);
+ gl.linkProgram(p);
+ gl.useProgram(p);
+
+ gl.drawArrays(gl.POINTS, 0, 1);
+ if (gl.getError()) throw new Error('Unexpected GL error,');
+
+ gl.enable(gl.BLEND);
+ gl.drawArrays(gl.POINTS, 0, 1);
+ return gl.getError() == 0;
+}
+
+function ResetGl(type) {
+ if (gl) {
+ const ext = gl.getExtension('WEBGL_lose_context');
+ ext.loseContext();
+ gl = null;
+ }
+ const c = document.createElement('canvas');
+ gl = c.getContext(type);
+ return !!gl;
+}
+
+function HasExt(name) {
+ return gl.getSupportedExtensions().indexOf(name) != -1;
+}
+
+ResetGl('webgl');
+if (HasExt('EXT_color_buffer_half_float')) {
+ const ext = gl.getExtension('OES_texture_half_float');
+ const implicitEnabled = CheckTexFloatRenderable(gl.RGBA, ext.HALF_FLOAT_OES);
+ ok(implicitEnabled, 'OES_texture_half_float should implicitly enable EXT_color_buffer_half_float.');
+}
+
+ResetGl('webgl');
+if (HasExt('WEBGL_color_buffer_float')) {
+ const ext = gl.getExtension('OES_texture_float');
+ const implicitEnabled = CheckTexFloatRenderable(gl.RGBA, gl.FLOAT);
+ ok(implicitEnabled, 'OES_texture_float should implicitly enable WEBGL_color_buffer_float.');
+
+ if (HasExt('EXT_float_blend')) {
+ ok(CheckBlending(), 'OES_texture_float should implicitly enable EXT_float_blend.');
+ }
+}
+
+ResetGl('webgl');
+if (HasExt('EXT_float_blend')) {
+ const ext = gl.getExtension('WEBGL_color_buffer_float');
+ CheckRbFloatRenderable(ext.RGBA32F_EXT);
+ const implicitEnabled = CheckBlending();
+ ok(implicitEnabled, 'WEBGL_color_buffer_float should implicitly enable EXT_float_blend.');
+}
+
+if (ResetGl('webgl2')) {
+ if (HasExt('EXT_float_blend')) {
+ const ext = gl.getExtension('EXT_color_buffer_float');
+ CheckTexFloatRenderable(gl.RGBA32F, gl.FLOAT);
+ const implicitEnabled = CheckBlending();
+ ok(implicitEnabled, 'EXT_color_buffer_float should implicitly enable EXT_float_blend.');
+ }
+}
+
+ </script>
+ </body>
+</html>