content/canvas/test/webgl-conformance/conformance/misc/shader-precision-format.html

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

     1 <!--
     2 Copyright (c) 2011 Mozilla Foundation. All rights reserved.
     3 Use of this source code is governed by a BSD-style license that can be
     4 found in the LICENSE file.
     5  -->
     6 <!DOCTYPE html>
     7 <html>
     8 <head>
     9 <meta charset="utf-8">
    10 <title>WebGL shader precision format test.</title>
    11 <link rel="stylesheet" href="../../resources/js-test-style.css"/>
    12 <script src="../../resources/js-test-pre.js"></script>
    13 <script src="../resources/webgl-test.js"> </script>
    14 <script src="../resources/webgl-test-utils.js"> </script>
    15 </head>
    16 <body>
    17 <canvas id="canvas" width="2" height="2" style="width: 40px; height: 40px;"></canvas>
    18 <div id="description"></div>
    19 <div id="console"></div>
    20 <script>
    21 var wtu = WebGLTestUtils;
    22 description(document.title);
    23 debug("Tests that WebGLShaderPrecisionFormat class and getShaderPrecisionFormat work.");
    24 debug("");
    25 var gl = wtu.create3DContext("canvas");
    27 function verifyShaderPrecisionFormat(shadertype, precisiontype) {
    28     shouldBeTrue('gl.getShaderPrecisionFormat(' + shadertype + ', ' +
    29                  precisiontype + ') instanceof WebGLShaderPrecisionFormat');
    30 }
    32 if (gl.getShaderPrecisionFormat == null || typeof gl.getShaderPrecisionFormat != 'function') {
    33     debug("getShaderPrecisionFormat() function not found.");
    34 } else {
    35     debug("");
    36     debug("Test that getShaderPrecisionFormat returns a WebGLShaderPrecisionFormat object.");
    37     debug("");
    39     verifyShaderPrecisionFormat('gl.VERTEX_SHADER', 'gl.LOW_FLOAT');
    40     verifyShaderPrecisionFormat('gl.VERTEX_SHADER', 'gl.MEDIUM_FLOAT');
    41     verifyShaderPrecisionFormat('gl.VERTEX_SHADER', 'gl.HIGH_FLOAT');
    42     verifyShaderPrecisionFormat('gl.VERTEX_SHADER', 'gl.LOW_INT');
    43     verifyShaderPrecisionFormat('gl.VERTEX_SHADER', 'gl.MEDIUM_INT');
    44     verifyShaderPrecisionFormat('gl.VERTEX_SHADER', 'gl.HIGH_INT');
    45     verifyShaderPrecisionFormat('gl.FRAGMENT_SHADER', 'gl.LOW_FLOAT');
    46     verifyShaderPrecisionFormat('gl.FRAGMENT_SHADER', 'gl.MEDIUM_FLOAT');
    47     verifyShaderPrecisionFormat('gl.FRAGMENT_SHADER', 'gl.HIGH_FLOAT');
    48     verifyShaderPrecisionFormat('gl.FRAGMENT_SHADER', 'gl.LOW_INT');
    49     verifyShaderPrecisionFormat('gl.FRAGMENT_SHADER', 'gl.MEDIUM_INT');
    50     verifyShaderPrecisionFormat('gl.FRAGMENT_SHADER', 'gl.HIGH_INT');
    52     debug("");
    53     debug("Test that getShaderPrecisionFormat throws an error with invalid parameters.");
    54     debug("");
    56     shouldGenerateGLError(gl, gl.INVALID_ENUM, 'gl.getShaderPrecisionFormat(gl.HIGH_INT, gl.VERTEX_SHADER)');
    58     debug("");
    59     debug("Test that WebGLShaderPrecisionFormat values are sensible.");
    60     debug("");
    62     var shaderPrecisionFormat = gl.getShaderPrecisionFormat(gl.VERTEX_SHADER, gl.LOW_FLOAT);
    63     shouldBeTrue('shaderPrecisionFormat.rangeMin >= 0 && shaderPrecisionFormat.rangeMin <= 128');
    64     shouldBeTrue('shaderPrecisionFormat.rangeMax >= 0 && shaderPrecisionFormat.rangeMax <= 128');
    65     shouldBeTrue('shaderPrecisionFormat.precision >= 0 && shaderPrecisionFormat.precision <= 128');
    67     debug("");
    68     debug("Test that getShaderPrecisionFormat returns the same thing every call.");
    69     debug("");
    71     var shaderPrecisionFormat2 = gl.getShaderPrecisionFormat(gl.VERTEX_SHADER, gl.LOW_FLOAT);
    72     shouldBeTrue('shaderPrecisionFormat.rangeMin == shaderPrecisionFormat2.rangeMin');
    73     shouldBeTrue('shaderPrecisionFormat.rangeMax == shaderPrecisionFormat2.rangeMax');
    74     shouldBeTrue('shaderPrecisionFormat.precision == shaderPrecisionFormat2.precision');
    75 }
    77 finishTest();
    78 </script>
    80 </body>
    81 </html>

mercurial