Source code
Revision control
Copy as Markdown
Other Tools
<!--
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>GLSL similar names issue</title>
<link rel="stylesheet" href="../../../resources/js-test-style.css"/>
<link rel="stylesheet" href="../../../resources/glsl-feature-tests.css"/>
<script src="../../../js/js-test-pre.js"></script>
<script src="../../../js/webgl-test-utils.js"> </script>
<script id="vshader" type="x-shader/x-vertex">
attribute vec4 a_position;
void main(void) {
gl_Position = a_position;
}
</script>
<script id="fshader1" type="x-shader/x-fragment">
precision mediump float;
uniform vec4 u_nameCollision[2];
uniform vec4 u_nameCollision2[2];
uniform vec4 u_name[2];
void main(void) {
gl_FragColor = u_nameCollision[0] + u_nameCollision2[0] + u_name[0];
}
</script>
<script id="fshader2" type="x-shader/x-fragment">
precision mediump float;
uniform vec4 u_nameCollision2[2];
uniform vec4 u_nameCollision[2];
uniform vec4 u_name[2];
void main(void) {
gl_FragColor = u_nameCollision2[0] + u_nameCollision[0] + u_name[0];
}
</script>
<script id="fshader3" type="x-shader/x-fragment">
precision mediump float;
uniform vec4 u_nameCollision[2];
uniform vec4 u_name[2];
uniform vec4 u_nameCollision2[2];
void main(void) {
gl_FragColor = u_nameCollision[0] + u_name[0] + u_nameCollision2[0];
}
</script>
<script id="fshader4" type="x-shader/x-fragment">
precision mediump float;
uniform vec4 u_nameCollision2[2];
uniform vec4 u_name[2];
uniform vec4 u_nameCollision[2];
void main(void) {
gl_FragColor = u_nameCollision2[0] + u_name[0] + u_nameCollision[0];
}
</script>
<script id="fshader5" type="x-shader/x-fragment">
precision mediump float;
uniform vec4 u_name[2];
uniform vec4 u_nameCollision[2];
uniform vec4 u_nameCollision2[2];
void main(void) {
gl_FragColor = u_name[0] + u_nameCollision[0] + u_nameCollision2[0];
}
</script>
<script id="fshader6" type="x-shader/x-fragment">
precision mediump float;
uniform vec4 u_name[2];
uniform vec4 u_nameCollision2[2];
uniform vec4 u_nameCollision[2];
void main(void) {
gl_FragColor = u_name[0] + u_nameCollision2[0] + u_nameCollision[0];
}
</script>
</head>
<body>
<canvas id="canvas" width="50" height="50"></canvas>
<div id="description"></div>
<div id="console"></div>
<script>
"use strict";
description();
var wtu = WebGLTestUtils;
var gl = wtu.create3DContext("canvas");
wtu.setupUnitQuad(gl);
for (var ii = 0; ii < 6; ++ii) {
var program = wtu.setupProgram(gl, ["vshader", "fshader" + (ii + 1)], ["a_position"]);
var loc1 = gl.getUniformLocation(program, "u_name[0]");
var loc2 = gl.getUniformLocation(program, "u_nameCollision[0]");
var loc3 = gl.getUniformLocation(program, "u_nameCollision2[0]");
gl.uniform4fv(loc1, [1, 0, 0, 0]);
gl.uniform4fv(loc2, [0, 1, 0, 0]);
gl.uniform4fv(loc3, [0, 0, 0, 1]);
wtu.clearAndDrawUnitQuad(gl);
wtu.checkCanvas(gl, [255, 255, 0, 255], "Should be yellow");
}
wtu.glErrorShouldBe(gl, gl.NO_ERROR, "there should be no errors");
var successfullyParsed = true;
</script>
<script src="../../../js/js-test-post.js"></script>
</body>
</html>