Backed out changeset 7272b7396c78 (bug 1932758) for causing fenix debug failures...
[gecko.git] / dom / canvas / test / webgl-conf / checkout / conformance2 / buffers / uniform-buffers-second-compile.html
blob936126856ec7265b75dcfefe72f1319480967914
1 <!--
2 Copyright (c) 2019 The Khronos Group Inc.
3 Use of this source code is governed by an MIT-style license that can be
4 found in the LICENSE.txt file.
5 -->
7 <!DOCTYPE html>
8 <html>
9 <head>
10 <meta charset="utf-8">
11 <title>WebGL Uniform Buffers should work on second compile</title>
12 <link rel="stylesheet" href="../../resources/js-test-style.css"/>
13 <script src="../../js/js-test-pre.js"></script>
14 <script src="../../js/webgl-test-utils.js"></script>
15 <script id='vshader' type='x-shader/x-vertex'>
16 #version 300 es
18 layout(location=0) in vec4 position;
19 layout(std140, column_major) uniform Uniforms1 {
20 mat4 transform;
22 out vec3 vColor;
24 void main() {
25 gl_Position = transform * position;
27 </script>
28 <script id='fshader' type='x-shader/x-fragment'>
29 #version 300 es
30 precision highp float;
32 layout(std140) uniform Uniforms2 {
33 vec4 color;
35 out vec4 fragColor;
37 void main(){
38 fragColor = color;
40 </script>
41 </head>
42 <body>
43 <div id="description"></div>
44 <canvas id="canvas" style="width: 50px; height: 50px;"> </canvas>
45 <div id="console"></div>
46 <script>
47 "use strict";
48 description("This test verifies that getUniformBlockIndex isn't broken on second compile.");
50 debug("This is a regression test for <a href='http://crbug.com/716018'>http://crbug.com/716018</a>");
51 debug("");
53 var wtu = WebGLTestUtils;
54 var canvas = document.getElementById("canvas");
55 var gl = wtu.create3DContext(canvas, null, 2);
57 // Initialize
58 gl.clearColor(0, 0, 0, 1);
59 var vsSource = document.getElementById("vshader").text.trim();
60 var fsSource = document.getElementById("fshader").text.trim();
62 function runTest() {
63 // Run twice to make sure that the second build does not cause errors
64 // (i.e. due to caching).
65 for (var i = 0; i < 2; ++i) {
66 debug("Compile/test iteration " + i);
68 var vertexShader = gl.createShader(gl.VERTEX_SHADER);
69 gl.shaderSource(vertexShader, vsSource);
70 gl.compileShader(vertexShader);
71 // Note: if COMPILE_STATUS is retrieved here, it hides the bug.
73 var fragmentShader = gl.createShader(gl.FRAGMENT_SHADER);
74 gl.shaderSource(fragmentShader, fsSource);
75 gl.compileShader(fragmentShader);
76 // Note: if COMPILE_STATUS is retrieved here, it hides the bug.
78 var program = gl.createProgram();
79 gl.attachShader(program, vertexShader);
80 gl.attachShader(program, fragmentShader);
81 gl.linkProgram(program);
83 gl.useProgram(program);
85 var uniforms1Location = gl.getUniformBlockIndex(program, "Uniforms1");
86 gl.uniformBlockBinding(program, uniforms1Location, 0);
87 wtu.glErrorShouldBe(gl, gl.NO_ERROR, "uniforms1Location was " + uniforms1Location);
89 var uniforms2Location = gl.getUniformBlockIndex(program, "Uniforms2");
90 gl.uniformBlockBinding(program, uniforms2Location, 1);
91 wtu.glErrorShouldBe(gl, gl.NO_ERROR, "uniforms2Location was " + uniforms2Location);
93 debug("");
97 runTest();
99 var successfullyParsed = true;
100 </script>
102 <script src="../../js/js-test-post.js"></script>
103 </body>
104 </html>