OLD | NEW |
(Empty) | |
| 1 <!-- |
| 2 |
| 3 /* |
| 4 ** Copyright (c) 2012 The Khronos Group Inc. |
| 5 ** |
| 6 ** Permission is hereby granted, free of charge, to any person obtaining a |
| 7 ** copy of this software and/or associated documentation files (the |
| 8 ** "Materials"), to deal in the Materials without restriction, including |
| 9 ** without limitation the rights to use, copy, modify, merge, publish, |
| 10 ** distribute, sublicense, and/or sell copies of the Materials, and to |
| 11 ** permit persons to whom the Materials are furnished to do so, subject to |
| 12 ** the following conditions: |
| 13 ** |
| 14 ** The above copyright notice and this permission notice shall be included |
| 15 ** in all copies or substantial portions of the Materials. |
| 16 ** |
| 17 ** THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, |
| 18 ** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF |
| 19 ** MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. |
| 20 ** IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY |
| 21 ** CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, |
| 22 ** TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE |
| 23 ** MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS. |
| 24 */ |
| 25 |
| 26 --> |
| 27 <!DOCTYPE html> |
| 28 <html> |
| 29 <head> |
| 30 <meta charset="utf-8"> |
| 31 <title>WebGL shader precision format test.</title> |
| 32 <link rel="stylesheet" href="../../resources/js-test-style.css"/> |
| 33 <script src="../../resources/js-test-pre.js"></script> |
| 34 <script src="../resources/webgl-test.js"> </script> |
| 35 <script src="../resources/webgl-test-utils.js"> </script> |
| 36 </head> |
| 37 <body> |
| 38 <canvas id="canvas" width="2" height="2" style="width: 40px; height: 40px;"></ca
nvas> |
| 39 <div id="description"></div> |
| 40 <div id="console"></div> |
| 41 <script> |
| 42 var wtu = WebGLTestUtils; |
| 43 description(document.title); |
| 44 debug("Tests that WebGLShaderPrecisionFormat class and getShaderPrecisionFormat
work."); |
| 45 debug(""); |
| 46 var gl = wtu.create3DContext("canvas"); |
| 47 |
| 48 function verifyShaderPrecisionFormat(shadertype, precisiontype) { |
| 49 shouldBeTrue('gl.getShaderPrecisionFormat(' + shadertype + ', ' + |
| 50 precisiontype + ') instanceof WebGLShaderPrecisionFormat'); |
| 51 } |
| 52 |
| 53 debug(""); |
| 54 debug("Test that getShaderPrecisionFormat returns a WebGLShaderPrecisionFormat o
bject."); |
| 55 debug(""); |
| 56 |
| 57 verifyShaderPrecisionFormat('gl.VERTEX_SHADER', 'gl.LOW_FLOAT'); |
| 58 verifyShaderPrecisionFormat('gl.VERTEX_SHADER', 'gl.MEDIUM_FLOAT'); |
| 59 verifyShaderPrecisionFormat('gl.VERTEX_SHADER', 'gl.HIGH_FLOAT'); |
| 60 verifyShaderPrecisionFormat('gl.VERTEX_SHADER', 'gl.LOW_INT'); |
| 61 verifyShaderPrecisionFormat('gl.VERTEX_SHADER', 'gl.MEDIUM_INT'); |
| 62 verifyShaderPrecisionFormat('gl.VERTEX_SHADER', 'gl.HIGH_INT'); |
| 63 verifyShaderPrecisionFormat('gl.FRAGMENT_SHADER', 'gl.LOW_FLOAT'); |
| 64 verifyShaderPrecisionFormat('gl.FRAGMENT_SHADER', 'gl.MEDIUM_FLOAT'); |
| 65 verifyShaderPrecisionFormat('gl.FRAGMENT_SHADER', 'gl.HIGH_FLOAT'); |
| 66 verifyShaderPrecisionFormat('gl.FRAGMENT_SHADER', 'gl.LOW_INT'); |
| 67 verifyShaderPrecisionFormat('gl.FRAGMENT_SHADER', 'gl.MEDIUM_INT'); |
| 68 verifyShaderPrecisionFormat('gl.FRAGMENT_SHADER', 'gl.HIGH_INT'); |
| 69 |
| 70 debug(""); |
| 71 debug("Test that getShaderPrecisionFormat throws an error with invalid parameter
s."); |
| 72 debug(""); |
| 73 |
| 74 shouldGenerateGLError(gl, gl.INVALID_ENUM, 'gl.getShaderPrecisionFormat(gl.HIGH_
INT, gl.VERTEX_SHADER)'); |
| 75 |
| 76 debug(""); |
| 77 debug("Test that WebGLShaderPrecisionFormat values are sensible."); |
| 78 debug(""); |
| 79 |
| 80 // The minimum values are from OpenGL ES Shading Language spec, section 4.5. |
| 81 |
| 82 var shaderPrecisionFormat = gl.getShaderPrecisionFormat(gl.VERTEX_SHADER, gl.LOW
_FLOAT); |
| 83 shouldBeTrue('shaderPrecisionFormat.rangeMin >= 1'); |
| 84 shouldBeTrue('shaderPrecisionFormat.rangeMax >= 1'); |
| 85 shouldBeTrue('shaderPrecisionFormat.precision >= 8'); |
| 86 |
| 87 shaderPrecisionFormat = gl.getShaderPrecisionFormat(gl.VERTEX_SHADER, gl.MEDIUM_
FLOAT); |
| 88 shouldBeTrue('shaderPrecisionFormat.rangeMin >= 14'); |
| 89 shouldBeTrue('shaderPrecisionFormat.rangeMax >= 14'); |
| 90 shouldBeTrue('shaderPrecisionFormat.precision >= 10'); |
| 91 |
| 92 shaderPrecisionFormat = gl.getShaderPrecisionFormat(gl.VERTEX_SHADER, gl.HIGH_FL
OAT); |
| 93 shouldBeTrue('shaderPrecisionFormat.rangeMin >= 62'); |
| 94 shouldBeTrue('shaderPrecisionFormat.rangeMax >= 62'); |
| 95 shouldBeTrue('shaderPrecisionFormat.precision >= 16'); |
| 96 |
| 97 shaderPrecisionFormat = gl.getShaderPrecisionFormat(gl.VERTEX_SHADER, gl.LOW_INT
); |
| 98 shouldBeTrue('shaderPrecisionFormat.rangeMin >= 8'); |
| 99 shouldBeTrue('shaderPrecisionFormat.rangeMax >= 8'); |
| 100 shouldBeTrue('shaderPrecisionFormat.precision == 0'); |
| 101 |
| 102 shaderPrecisionFormat = gl.getShaderPrecisionFormat(gl.VERTEX_SHADER, gl.MEDIUM_
INT); |
| 103 shouldBeTrue('shaderPrecisionFormat.rangeMin >= 10'); |
| 104 shouldBeTrue('shaderPrecisionFormat.rangeMax >= 10'); |
| 105 shouldBeTrue('shaderPrecisionFormat.precision == 0'); |
| 106 |
| 107 shaderPrecisionFormat = gl.getShaderPrecisionFormat(gl.VERTEX_SHADER, gl.HIGH_IN
T); |
| 108 shouldBeTrue('shaderPrecisionFormat.rangeMin >= 16'); |
| 109 shouldBeTrue('shaderPrecisionFormat.rangeMax >= 16'); |
| 110 shouldBeTrue('shaderPrecisionFormat.precision == 0'); |
| 111 |
| 112 debug(""); |
| 113 debug("Test that getShaderPrecisionFormat returns the same thing every call."); |
| 114 debug(""); |
| 115 |
| 116 shaderPrecisionFormat = gl.getShaderPrecisionFormat(gl.VERTEX_SHADER, gl.LOW_FLO
AT); |
| 117 var shaderPrecisionFormat2 = gl.getShaderPrecisionFormat(gl.VERTEX_SHADER, gl.LO
W_FLOAT); |
| 118 shouldBeTrue('shaderPrecisionFormat.rangeMin == shaderPrecisionFormat2.rangeMin'
); |
| 119 shouldBeTrue('shaderPrecisionFormat.rangeMax == shaderPrecisionFormat2.rangeMax'
); |
| 120 shouldBeTrue('shaderPrecisionFormat.precision == shaderPrecisionFormat2.precisio
n'); |
| 121 |
| 122 finishTest(); |
| 123 </script> |
| 124 |
| 125 </body> |
| 126 </html> |
| 127 |
| 128 |
OLD | NEW |