| OLD | NEW |
| (Empty) |
| 1 <!DOCTYPE html> | |
| 2 <html> | |
| 3 <head> | |
| 4 <meta charset="utf-8"> | |
| 5 <title>WebGL shader precision format test.</title> | |
| 6 <script src="../../../resources/js-test.js"></script> | |
| 7 <script src="resources/webgl-test.js"> </script> | |
| 8 <script src="resources/webgl-test-utils.js"> </script> | |
| 9 </head> | |
| 10 <body> | |
| 11 <canvas id="canvas" width="2" height="2" style="width: 40px; height: 40px;"></ca
nvas> | |
| 12 <div id="description"></div> | |
| 13 <div id="console"></div> | |
| 14 <script> | |
| 15 if (window.initNonKhronosFramework) { | |
| 16 window.initNonKhronosFramework(true); | |
| 17 } | |
| 18 | |
| 19 if (window.internals) | |
| 20 window.internals.settings.setWebGLErrorsToConsoleEnabled(false); | |
| 21 | |
| 22 var wtu = WebGLTestUtils; | |
| 23 description(document.title); | |
| 24 debug("Tests that WebGLShaderPrecisionFormat class and getShaderPrecisionFormat
work."); | |
| 25 debug(""); | |
| 26 var gl = create3DContext(document.getElementById("canvas")); | |
| 27 | |
| 28 function verifyShaderPrecisionFormat(shadertype, precisiontype) { | |
| 29 shouldBeTrue('gl.getShaderPrecisionFormat(' + shadertype + ', ' + | |
| 30 precisiontype + ') instanceof WebGLShaderPrecisionFormat'); | |
| 31 } | |
| 32 | |
| 33 debug(""); | |
| 34 debug("Test that getShaderPrecisionFormat returns a WebGLShaderPrecisionFormat o
bject."); | |
| 35 debug(""); | |
| 36 | |
| 37 verifyShaderPrecisionFormat('gl.VERTEX_SHADER', 'gl.LOW_FLOAT'); | |
| 38 verifyShaderPrecisionFormat('gl.VERTEX_SHADER', 'gl.MEDIUM_FLOAT'); | |
| 39 verifyShaderPrecisionFormat('gl.VERTEX_SHADER', 'gl.HIGH_FLOAT'); | |
| 40 verifyShaderPrecisionFormat('gl.VERTEX_SHADER', 'gl.LOW_INT'); | |
| 41 verifyShaderPrecisionFormat('gl.VERTEX_SHADER', 'gl.MEDIUM_INT'); | |
| 42 verifyShaderPrecisionFormat('gl.VERTEX_SHADER', 'gl.HIGH_INT'); | |
| 43 verifyShaderPrecisionFormat('gl.FRAGMENT_SHADER', 'gl.LOW_FLOAT'); | |
| 44 verifyShaderPrecisionFormat('gl.FRAGMENT_SHADER', 'gl.MEDIUM_FLOAT'); | |
| 45 verifyShaderPrecisionFormat('gl.FRAGMENT_SHADER', 'gl.HIGH_FLOAT'); | |
| 46 verifyShaderPrecisionFormat('gl.FRAGMENT_SHADER', 'gl.LOW_INT'); | |
| 47 verifyShaderPrecisionFormat('gl.FRAGMENT_SHADER', 'gl.MEDIUM_INT'); | |
| 48 verifyShaderPrecisionFormat('gl.FRAGMENT_SHADER', 'gl.HIGH_INT'); | |
| 49 | |
| 50 debug(""); | |
| 51 debug("Test that getShaderPrecisionFormat throws an error with invalid parameter
s."); | |
| 52 debug(""); | |
| 53 | |
| 54 shouldGenerateGLError(gl, gl.INVALID_ENUM, 'gl.getShaderPrecisionFormat(gl.HIGH_
INT, gl.VERTEX_SHADER)'); | |
| 55 | |
| 56 debug(""); | |
| 57 debug("Test that WebGLShaderPrecisionFormat values are sensible."); | |
| 58 debug(""); | |
| 59 | |
| 60 // The minimum values are from OpenGL ES Shading Language spec, section 4.5. | |
| 61 | |
| 62 var shaderPrecisionFormat = gl.getShaderPrecisionFormat(gl.VERTEX_SHADER, gl.LOW
_FLOAT); | |
| 63 shouldBeTrue('shaderPrecisionFormat.rangeMin >= 1'); | |
| 64 shouldBeTrue('shaderPrecisionFormat.rangeMax >= 1'); | |
| 65 shouldBeTrue('shaderPrecisionFormat.precision >= 8'); | |
| 66 | |
| 67 shaderPrecisionFormat = gl.getShaderPrecisionFormat(gl.VERTEX_SHADER, gl.MEDIUM_
FLOAT); | |
| 68 shouldBeTrue('shaderPrecisionFormat.rangeMin >= 14'); | |
| 69 shouldBeTrue('shaderPrecisionFormat.rangeMax >= 14'); | |
| 70 shouldBeTrue('shaderPrecisionFormat.precision >= 10'); | |
| 71 | |
| 72 shaderPrecisionFormat = gl.getShaderPrecisionFormat(gl.VERTEX_SHADER, gl.HIGH_FL
OAT); | |
| 73 shouldBeTrue('shaderPrecisionFormat.rangeMin >= 62'); | |
| 74 shouldBeTrue('shaderPrecisionFormat.rangeMax >= 62'); | |
| 75 shouldBeTrue('shaderPrecisionFormat.precision >= 16'); | |
| 76 | |
| 77 shaderPrecisionFormat = gl.getShaderPrecisionFormat(gl.VERTEX_SHADER, gl.LOW_INT
); | |
| 78 shouldBeTrue('shaderPrecisionFormat.rangeMin >= 8'); | |
| 79 shouldBeTrue('shaderPrecisionFormat.rangeMax >= 8'); | |
| 80 shouldBeTrue('shaderPrecisionFormat.precision == 0'); | |
| 81 | |
| 82 shaderPrecisionFormat = gl.getShaderPrecisionFormat(gl.VERTEX_SHADER, gl.MEDIUM_
INT); | |
| 83 shouldBeTrue('shaderPrecisionFormat.rangeMin >= 10'); | |
| 84 shouldBeTrue('shaderPrecisionFormat.rangeMax >= 10'); | |
| 85 shouldBeTrue('shaderPrecisionFormat.precision == 0'); | |
| 86 | |
| 87 shaderPrecisionFormat = gl.getShaderPrecisionFormat(gl.VERTEX_SHADER, gl.HIGH_IN
T); | |
| 88 shouldBeTrue('shaderPrecisionFormat.rangeMin >= 16'); | |
| 89 shouldBeTrue('shaderPrecisionFormat.rangeMax >= 16'); | |
| 90 shouldBeTrue('shaderPrecisionFormat.precision == 0'); | |
| 91 | |
| 92 debug(""); | |
| 93 debug("Test that getShaderPrecisionFormat returns the same thing every call."); | |
| 94 debug(""); | |
| 95 | |
| 96 shaderPrecisionFormat = gl.getShaderPrecisionFormat(gl.VERTEX_SHADER, gl.LOW_FLO
AT); | |
| 97 var shaderPrecisionFormat2 = gl.getShaderPrecisionFormat(gl.VERTEX_SHADER, gl.LO
W_FLOAT); | |
| 98 shouldBeTrue('shaderPrecisionFormat.rangeMin == shaderPrecisionFormat2.rangeMin'
); | |
| 99 shouldBeTrue('shaderPrecisionFormat.rangeMax == shaderPrecisionFormat2.rangeMax'
); | |
| 100 shouldBeTrue('shaderPrecisionFormat.precision == shaderPrecisionFormat2.precisio
n'); | |
| 101 | |
| 102 finishTest(); | |
| 103 </script> | |
| 104 | |
| 105 </body> | |
| 106 </html> | |
| 107 | |
| 108 | |
| OLD | NEW |