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 texture offset with non-constant 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=
"fshaderTextureOffset" type=
"x-shader/x-fragment">#version
300 es
21 precision mediump float;
23 out vec4 my_FragColor;
24 uniform sampler2D u_sampler;
25 uniform vec2 u_texCoord;
28 ivec2 offset = ivec2(
0);
29 my_FragColor = textureOffset(u_sampler, u_texCoord, offset);
32 <script id=
"fshaderTextureProjOffset" type=
"x-shader/x-fragment">#version
300 es
33 precision mediump float;
35 out vec4 my_FragColor;
36 uniform sampler2D u_sampler;
37 uniform vec4 u_texCoord;
40 ivec2 offset = ivec2(
0);
41 my_FragColor = textureProjOffset(u_sampler, u_texCoord, offset);
44 <script id=
"fshaderTextureLodOffset" type=
"x-shader/x-fragment">#version
300 es
45 precision mediump float;
47 out vec4 my_FragColor;
48 uniform sampler2D u_sampler;
49 uniform vec2 u_texCoord;
53 ivec2 offset = ivec2(
0);
54 my_FragColor = textureLodOffset(u_sampler, u_texCoord, u_lod, offset);
57 <script id=
"fshaderTextureProjLodOffset" type=
"x-shader/x-fragment">#version
300 es
58 precision mediump float;
60 out vec4 my_FragColor;
61 uniform sampler2D u_sampler;
62 uniform vec4 u_texCoord;
66 ivec2 offset = ivec2(
0);
67 my_FragColor = textureProjLodOffset(u_sampler, u_texCoord, u_lod, offset);
70 <script id=
"fshaderTextureGradOffset" type=
"x-shader/x-fragment">#version
300 es
71 precision mediump float;
73 out vec4 my_FragColor;
74 uniform sampler2D u_sampler;
75 uniform vec2 u_texCoord;
80 ivec2 offset = ivec2(
0);
81 my_FragColor = textureGradOffset(u_sampler, u_texCoord, u_dPdx, u_dPdy, offset);
84 <script id=
"fshaderTextureProjGradOffset" type=
"x-shader/x-fragment">#version
300 es
85 precision mediump float;
87 out vec4 my_FragColor;
88 uniform sampler2D u_sampler;
89 uniform vec4 u_texCoord;
94 ivec2 offset = ivec2(
0);
95 my_FragColor = textureProjGradOffset(u_sampler, u_texCoord, u_dPdx, u_dPdy, offset);
98 <script id=
"fshaderTexelFetchOffset" type=
"x-shader/x-fragment">#version
300 es
99 precision mediump float;
101 out vec4 my_FragColor;
102 uniform sampler2D u_sampler;
103 uniform vec2 u_texCoord;
107 ivec2 offset = ivec2(
0);
108 my_FragColor = texelFetchOffset(u_sampler, ivec2(u_texCoord), int(u_lod), offset);
111 <script type=
"application/javascript">
113 description(
"A non-constant offset is not valid in texture offset functions.");
115 var wtu = WebGLTestUtils;
117 var shaderTextureOffsetSrc = wtu.getScript('fshaderTextureOffset');
118 var shaderTextureLodOffsetSrc = wtu.getScript('fshaderTextureLodOffset');
119 var shaderTextureGradOffsetSrc = wtu.getScript('fshaderTextureGradOffset');
120 var shaderTextureProjOffsetSrc = wtu.getScript('fshaderTextureProjOffset');
121 var shaderTextureProjLodOffsetSrc = wtu.getScript('fshaderTextureProjLodOffset');
122 var shaderTextureProjGradOffsetSrc = wtu.getScript('fshaderTextureProjGradOffset');
123 var shaderTexelFetchOffsetSrc = wtu.getScript('fshaderTexelFetchOffset');
125 var gl = wtu.create3DContext(undefined, undefined,
2);
128 testFailed(
"Unable to initialize WebGL 2.0 context.");
130 GLSLConformanceTester.runTests([
132 fShaderSource: shaderTextureOffsetSrc,
133 fShaderSuccess: false,
134 passMsg: 'textureOffset with non-constant offset is invalid'
137 fShaderSource: shaderTextureLodOffsetSrc,
138 fShaderSuccess: false,
139 passMsg: 'textureLodOffset with non-constant offset is invalid'
142 fShaderSource: shaderTextureGradOffsetSrc,
143 fShaderSuccess: false,
144 passMsg: 'textureGradOffset with non-constant offset is invalid'
147 fShaderSource: shaderTextureProjOffsetSrc,
148 fShaderSuccess: false,
149 passMsg: 'textureProjOffset with non-constant offset is invalid'
152 fShaderSource: shaderTextureProjLodOffsetSrc,
153 fShaderSuccess: false,
154 passMsg: 'textureProjLodOffset with non-constant offset is invalid'
157 fShaderSource: shaderTextureProjGradOffsetSrc,
158 fShaderSuccess: false,
159 passMsg: 'textureProjGradOffset with non-constant offset is invalid'
162 fShaderSource: shaderTexelFetchOffsetSrc,
163 fShaderSuccess: false,
164 passMsg: 'texelFetchOffset with non-constant offset is invalid'