content/canvas/test/webgl-conformance/conformance/glsl/misc/attrib-location-length-limits.html

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/content/canvas/test/webgl-conformance/conformance/glsl/misc/attrib-location-length-limits.html	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,82 @@
     1.4 +<!DOCTYPE html>
     1.5 +<html>
     1.6 +<head>
     1.7 +<meta charset="utf-8">
     1.8 +<title>WebGL attrib location length tests</title>
     1.9 +<link rel="stylesheet" href="../../../resources/js-test-style.css"/>
    1.10 +<link rel="stylesheet" href="../../resources/glsl-feature-tests.css"/>
    1.11 +<script src="../../../resources/js-test-pre.js"></script>
    1.12 +<script src="../../resources/webgl-test.js"> </script>
    1.13 +<script src="../../resources/webgl-test-utils.js"> </script>
    1.14 +</head>
    1.15 +<body>
    1.16 +<canvas id="example" width="50" height="50">
    1.17 +There is supposed to be an example drawing here, but it's not important.
    1.18 +</canvas>
    1.19 +<div id="description">Verify limits on the lengths of attribute locations per WebGL spec, "Maximum Uniform and Attribute Location Lengths".</div>
    1.20 +<div id="console"></div>
    1.21 +<script id="goodVertexShader" type="x-shader/x-vertex">
    1.22 +// A vertex shader where the needed attrib location is exactly 256 characters.
    1.23 +attribute vec4 vPosition0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456;
    1.24 +
    1.25 +void main()
    1.26 +{
    1.27 +    gl_Position = vPosition0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456;
    1.28 +}
    1.29 +</script>
    1.30 +<script id="badVertexShader" type="x-shader/x-vertex">
    1.31 +// A vertex shader where the needed attrib location is 257 characters.
    1.32 +attribute vec4 vPosition01234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567;
    1.33 +
    1.34 +void main()
    1.35 +{
    1.36 +    gl_Position = vPosition01234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567;
    1.37 +}
    1.38 +</script>
    1.39 +<script id="fragmentShader" type="x-shader/x-fragment">
    1.40 +precision mediump float;
    1.41 +
    1.42 +void main() {
    1.43 +    gl_FragColor = vec4(1.0, 0.0, 0.0, 1.0);
    1.44 +}
    1.45 +</script>
    1.46 +<script>
    1.47 +if (window.initNonKhronosFramework) {
    1.48 +    window.initNonKhronosFramework(false);
    1.49 +}
    1.50 +description("test attrib location length limit");
    1.51 +
    1.52 +var wtu = WebGLTestUtils;
    1.53 +var gl = wtu.create3DContext("example");
    1.54 +
    1.55 +debug("Test attrib location underneath the length limit");
    1.56 +var program = wtu.loadProgramFromScript(gl, "goodVertexShader", "fragmentShader");
    1.57 +shouldBe('gl.getProgramParameter(program, gl.LINK_STATUS)', 'true');
    1.58 +var attribLoc = gl.getAttribLocation(program, "vPosition0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456");
    1.59 +if (attribLoc == -1) {
    1.60 +    testFailed("attrib location was -1, should not be");
    1.61 +} else {
    1.62 +    testPassed("attrib location should not be -1");
    1.63 +}
    1.64 +wtu.glErrorShouldBe(gl, gl.NONE);
    1.65 +
    1.66 +debug("Test attrib location over the length limit");
    1.67 +debug("Shader compilation or link should fail");
    1.68 +shouldBe('wtu.loadProgramFromScriptExpectError(gl, "badVertexShader", "fragmentShader")', 'null');
    1.69 +wtu.glErrorShouldBe(gl, gl.NONE);
    1.70 +
    1.71 +debug("Attempt to bind too-long attrib location should produce error");
    1.72 +program = gl.createProgram();
    1.73 +gl.bindAttribLocation(program, 0, "vPosition01234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567");
    1.74 +wtu.glErrorShouldBe(gl, gl.INVALID_VALUE);
    1.75 +
    1.76 +debug("Attempt to fetch too-long attrib location should produce error");
    1.77 +program = wtu.loadStandardProgram(gl);
    1.78 +shouldBe('gl.getAttribLocation(program, "vPosition01234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567")', '-1');
    1.79 +wtu.glErrorShouldBe(gl, gl.INVALID_VALUE);
    1.80 +
    1.81 +successfullyParsed = true;
    1.82 +</script>
    1.83 +<script>finishTest();</script>
    1.84 +</body>
    1.85 +</html>

mercurial