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 uniform texture coordinates 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 my_FragColor = textureOffset(u_sampler, u_texCoord, ivec2(
0,
1));
31 <script id=
"fshaderTextureProjOffset" type=
"x-shader/x-fragment">#version
300 es
32 precision mediump float;
34 out vec4 my_FragColor;
35 uniform sampler2D u_sampler;
36 uniform vec4 u_texCoord;
39 my_FragColor = textureProjOffset(u_sampler, u_texCoord, ivec2(
0,
1));
42 <script id=
"fshaderTextureLodOffset" type=
"x-shader/x-fragment">#version
300 es
43 precision mediump float;
45 out vec4 my_FragColor;
46 uniform sampler2D u_sampler;
47 uniform vec2 u_texCoord;
51 my_FragColor = textureLodOffset(u_sampler, u_texCoord, u_lod, ivec2(
0,
1));
54 <script id=
"fshaderTextureProjLodOffset" type=
"x-shader/x-fragment">#version
300 es
55 precision mediump float;
57 out vec4 my_FragColor;
58 uniform sampler2D u_sampler;
59 uniform vec4 u_texCoord;
63 my_FragColor = textureProjLodOffset(u_sampler, u_texCoord, u_lod, ivec2(
0,
1));
66 <script id=
"fshaderTextureGradOffset" type=
"x-shader/x-fragment">#version
300 es
67 precision mediump float;
69 out vec4 my_FragColor;
70 uniform sampler2D u_sampler;
71 uniform vec2 u_texCoord;
76 my_FragColor = textureGradOffset(u_sampler, u_texCoord, u_dPdx, u_dPdy, ivec2(
0,
1));
79 <script id=
"fshaderTextureProjGradOffset" type=
"x-shader/x-fragment">#version
300 es
80 precision mediump float;
82 out vec4 my_FragColor;
83 uniform sampler2D u_sampler;
84 uniform vec4 u_texCoord;
89 my_FragColor = textureProjGradOffset(u_sampler, u_texCoord, u_dPdx, u_dPdy, ivec2(
0,
1));
92 <script id=
"fshaderTexelFetchOffset" type=
"x-shader/x-fragment">#version
300 es
93 precision mediump float;
95 out vec4 my_FragColor;
96 uniform sampler2D u_sampler;
97 uniform vec2 u_texCoord;
101 my_FragColor = texelFetchOffset(u_sampler, ivec2(u_texCoord), int(u_lod), ivec2(
0,
1));
104 <script type=
"application/javascript">
106 description(
"Texture coordinates expressed as uniform variable should not crash in texture offset functions.");
108 var wtu = WebGLTestUtils;
110 var shaderTextureOffsetSrc = wtu.getScript('fshaderTextureOffset');
111 var shaderTextureLodOffsetSrc = wtu.getScript('fshaderTextureLodOffset');
112 var shaderTextureGradOffsetSrc = wtu.getScript('fshaderTextureGradOffset');
113 var shaderTextureProjOffsetSrc = wtu.getScript('fshaderTextureProjOffset');
114 var shaderTextureProjLodOffsetSrc = wtu.getScript('fshaderTextureProjLodOffset');
115 var shaderTextureProjGradOffsetSrc = wtu.getScript('fshaderTextureProjGradOffset');
116 var shaderTexelFetchOffsetSrc = wtu.getScript('fshaderTexelFetchOffset');
118 var gl = wtu.create3DContext(undefined, undefined,
2);
121 testFailed(
"Unable to initialize WebGL 2.0 context.");
123 GLSLConformanceTester.runTests([
125 fShaderSource: shaderTextureOffsetSrc,
126 fShaderSuccess: true,
128 passMsg: 'textureOffset with uniform texture coordinates should not crash'
131 fShaderSource: shaderTextureLodOffsetSrc,
132 fShaderSuccess: true,
134 passMsg: 'textureLodOffset with uniform texture coordinates should not crash'
137 fShaderSource: shaderTextureGradOffsetSrc,
138 fShaderSuccess: true,
140 passMsg: 'textureGradOffset with uniform texture coordinates should not crash'
143 fShaderSource: shaderTextureProjOffsetSrc,
144 fShaderSuccess: true,
146 passMsg: 'textureProjOffset with uniform texture coordinates should not crash'
149 fShaderSource: shaderTextureProjLodOffsetSrc,
150 fShaderSuccess: true,
152 passMsg: 'textureProjLodOffset with uniform texture coordinates should not crash'
155 fShaderSource: shaderTextureProjGradOffsetSrc,
156 fShaderSuccess: true,
158 passMsg: 'textureProjGradOffset with uniform texture coordinates should not crash'
161 fShaderSource: shaderTexelFetchOffsetSrc,
162 fShaderSuccess: true,
164 passMsg: 'texelFetchOffset with uniform texture coordinates should not crash'