Backed out changeset 7272b7396c78 (bug 1932758) for causing fenix debug failures...
[gecko.git] / dom / canvas / test / webgl-conf / checkout / conformance2 / glsl3 / texture-offset-out-of-range.html
blob99e698fb6ef232bbb14059927ee470b30196bb84
1 <!--
2 Copyright (c) 2019 The Khronos Group Inc.
3 Use of this source code is governed by an MIT-style license that can be
4 found in the LICENSE.txt file.
5 -->
7 <!DOCTYPE html>
8 <html>
9 <head>
10 <meta charset="utf-8">
11 <title>GLSL out-of-range texture offset test</title>
12 <link rel="stylesheet" href="../../resources/js-test-style.css"/>
13 <script src="../../js/js-test-pre.js"></script>
14 <script src="../../js/webgl-test-utils.js"></script>
15 <script src="../../js/glsl-conformance-test.js"></script>
16 </head>
17 <body>
18 <div id="description"></div>
19 <div id="console"></div>
20 <script id="vshaderInvalidOffset" type="x-shader/x-vertex">#version 300 es
21 in vec4 a_position;
22 in vec2 a_in0;
23 out vec2 v_texCoord;
25 void main()
27 gl_Position = a_position;
28 v_texCoord = a_in0;
30 </script>
31 <script id="fshaderInvalidOffset" type="x-shader/x-fragment">#version 300 es
32 precision mediump float;
34 in vec2 v_texCoord;
35 out vec4 my_FragColor;
36 uniform sampler2D u_sampler;
37 uniform int x;
39 void main() {
40 my_FragColor = textureOffset(u_sampler, v_texCoord, ivec2(0, $(yoffset)));
42 </script>
43 <script type="application/javascript">
44 "use strict";
45 description("Out-of-range texture offset should not compile.");
47 var wtu = WebGLTestUtils;
49 var vshader = wtu.getScript('vshaderInvalidOffset');
50 var fshaderTemplate = wtu.getScript('fshaderInvalidOffset');
52 var gl = wtu.create3DContext(undefined, undefined, 2);
54 if (!gl) {
55 testFailed("Unable to initialize WebGL 2.0 context.");
56 } else {
57 var minOffset = gl.getParameter(gl.MIN_PROGRAM_TEXEL_OFFSET);
58 var maxOffset = gl.getParameter(gl.MAX_PROGRAM_TEXEL_OFFSET);
60 var shaderSrcValidMin = wtu.replaceParams(fshaderTemplate, {'yoffset': minOffset});
61 var shaderSrcValidMax = wtu.replaceParams(fshaderTemplate, {'yoffset': maxOffset});
62 var shaderSrcBelowMin = wtu.replaceParams(fshaderTemplate, {'yoffset': (minOffset - 1)});
63 var shaderSrcAboveMax = wtu.replaceParams(fshaderTemplate, {'yoffset': (maxOffset + 1)});
64 var shaderSrcDynamic = wtu.replaceParams(fshaderTemplate, {'yoffset': 'x'});
66 GLSLConformanceTester.runTests([
68 vShaderSource: vshader,
69 fShaderSource: shaderSrcValidMin,
70 fShaderSuccess: true,
71 linkSuccess: true,
72 passMsg: 'Minimum in-range texture offset should compile'
75 vShaderSource: vshader,
76 fShaderSource: shaderSrcValidMax,
77 fShaderSuccess: true,
78 linkSuccess: true,
79 passMsg: 'Maximum in-range texture offset should compile'
82 vShaderSource: vshader,
83 fShaderSource: shaderSrcBelowMin,
84 fShaderSuccess: false,
85 linkSuccess: false,
86 passMsg: 'Texture offset below minimum valid value should not compile'
89 vShaderSource: vshader,
90 fShaderSource: shaderSrcAboveMax,
91 fShaderSuccess: false,
92 linkSuccess: false,
93 passMsg: 'Texture offset above maximum valid value should not compile'
96 vShaderSource: vshader,
97 fShaderSource: shaderSrcDynamic,
98 fShaderSuccess: false,
99 linkSuccess: false,
100 passMsg: 'Dynamic texture offset should not compile'
102 ], 2);
104 </script>
105 </body>
106 </html>