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.
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>
18 <div id=
"description"></div>
19 <div id=
"console"></div>
20 <script id=
"vshaderInvalidOffset" type=
"x-shader/x-vertex">#version
300 es
27 gl_Position = a_position;
31 <script id=
"fshaderInvalidOffset" type=
"x-shader/x-fragment">#version
300 es
32 precision mediump float;
35 out vec4 my_FragColor;
36 uniform sampler2D u_sampler;
40 my_FragColor = textureOffset(u_sampler, v_texCoord, ivec2(
0, $(yoffset)));
43 <script type=
"application/javascript">
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);
55 testFailed(
"Unable to initialize WebGL 2.0 context.");
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,
72 passMsg: 'Minimum in-range texture offset should compile'
75 vShaderSource: vshader,
76 fShaderSource: shaderSrcValidMax,
79 passMsg: 'Maximum in-range texture offset should compile'
82 vShaderSource: vshader,
83 fShaderSource: shaderSrcBelowMin,
84 fShaderSuccess: false,
86 passMsg: 'Texture offset below minimum valid value should not compile'
89 vShaderSource: vshader,
90 fShaderSource: shaderSrcAboveMax,
91 fShaderSuccess: false,
93 passMsg: 'Texture offset above maximum valid value should not compile'
96 vShaderSource: vshader,
97 fShaderSource: shaderSrcDynamic,
98 fShaderSuccess: false,
100 passMsg: 'Dynamic texture offset should not compile'