summaryrefslogtreecommitdiffstats
path: root/dom/canvas/test/webgl-conf/checkout/conformance/glsl/misc/uniform-location-length-limits.html
blob: 8aeaeb1937eb4f6088d52adb3db98e6877c0f6b0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<!--
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.
-->
<title>WebGL uniform location length tests</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>
</head>
<body>
<canvas id="example" width="50" height="50">
There is supposed to be an example drawing here, but it's not important.
</canvas>
<div id="description">Verify limits on the lengths of uniform locations per WebGL spec, "Maximum Uniform and Attribute Location Lengths".</div>
<div id="console"></div>
<script id="goodVertexShader" type="x-shader/x-vertex">
// A vertex shader where the needed uniform location is exactly 256 characters.
struct Nesting2 {
    vec4 identifier62CharactersLong_01234567890123456789012345678901234;
};

struct Nesting1 {
    Nesting2 identifier64CharactersLong_0123456789012345678901234567890123456;
};

uniform Nesting1 identifier128CharactersLong_0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789;

void main() {
    gl_Position = identifier128CharactersLong_0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789.identifier64CharactersLong_0123456789012345678901234567890123456.identifier62CharactersLong_01234567890123456789012345678901234;
}
</script>
<script id="badVertexShader" type="x-shader/x-vertex">
// A vertex shader where the needed uniform location is 257 characters.
struct Nesting2 {
    vec4 identifier63CharactersLong_012345678901234567890123456789012345;
};

struct Nesting1 {
    Nesting2 identifier64CharactersLong_0123456789012345678901234567890123456;
};

uniform Nesting1 identifier128CharactersLong_0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789;

void main() {
    Nesting2 temp = identifier128CharactersLong_0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789.identifier64CharactersLong_0123456789012345678901234567890123456;
    gl_Position = temp.identifier63CharactersLong_012345678901234567890123456789012345;
}
</script>
<script id="fragmentShader" type="x-shader/x-fragment">
precision mediump float;

void main() {
    gl_FragColor = vec4(1.0, 0.0, 0.0, 1.0);
}
</script>
<script>
"use strict";
var wtu = WebGLTestUtils;
var gl = wtu.create3DContext("example");

debug("Test uniform location underneath the length limit");
var program = wtu.loadProgramFromScript(gl, "goodVertexShader", "fragmentShader");
shouldBe('gl.getProgramParameter(program, gl.LINK_STATUS)', 'true');
var uniformLoc = gl.getUniformLocation(program, "identifier128CharactersLong_0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789.identifier64CharactersLong_0123456789012345678901234567890123456.identifier62CharactersLong_01234567890123456789012345678901234");
shouldBeNonNull('uniformLoc');
wtu.glErrorShouldBe(gl, gl.NONE);

debug("Test uniform location over the length limit");
program = wtu.loadProgramFromScript(gl, "badVertexShader", "fragmentShader");
wtu.glErrorShouldBe(gl, gl.NONE);
shouldBe('gl.getProgramParameter(program, gl.LINK_STATUS)', 'true');
var uniformLoc = gl.getUniformLocation(program, "identifier128CharactersLong_0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789.identifier64CharactersLong_0123456789012345678901234567890123456.identifier63CharactersLong_012345678901234567890123456789012345");
wtu.glErrorShouldBe(gl, gl.INVALID_VALUE);
shouldBeNull('uniformLoc');

var successfullyParsed = true;
</script>
<script src="../../../js/js-test-post.js"></script>
</body>
</html>