summaryrefslogtreecommitdiffstats
path: root/dom/canvas/test/webgl-conf/checkout/conformance2/glsl3/texture-offset-uniform-texture-coordinate.html
blob: 56caf47f46bca152e19f8beedfa2e38dc29b7c58 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
<!--
Copyright (c) 2019 The Khronos Group Inc.
Use of this source code is governed by an MIT-style license that can be
found in the LICENSE.txt file.
-->

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>GLSL texture offset with uniform texture coordinates test</title>
<link rel="stylesheet" href="../../resources/js-test-style.css"/>
<script src="../../js/js-test-pre.js"></script>
<script src="../../js/webgl-test-utils.js"></script>
<script src="../../js/glsl-conformance-test.js"></script>
</head>
<body>
<div id="description"></div>
<div id="console"></div>
<script id="fshaderTextureOffset" type="x-shader/x-fragment">#version 300 es
precision mediump float;

out vec4 my_FragColor;
uniform sampler2D u_sampler;
uniform vec2 u_texCoord;

void main() {
    my_FragColor = textureOffset(u_sampler, u_texCoord, ivec2(0, 1));
}
</script>
<script id="fshaderTextureProjOffset" type="x-shader/x-fragment">#version 300 es
precision mediump float;

out vec4 my_FragColor;
uniform sampler2D u_sampler;
uniform vec4 u_texCoord;

void main() {
    my_FragColor = textureProjOffset(u_sampler, u_texCoord, ivec2(0, 1));
}
</script>
<script id="fshaderTextureLodOffset" type="x-shader/x-fragment">#version 300 es
precision mediump float;

out vec4 my_FragColor;
uniform sampler2D u_sampler;
uniform vec2 u_texCoord;
uniform float u_lod;

void main() {
    my_FragColor = textureLodOffset(u_sampler, u_texCoord, u_lod, ivec2(0, 1));
}
</script>
<script id="fshaderTextureProjLodOffset" type="x-shader/x-fragment">#version 300 es
precision mediump float;

out vec4 my_FragColor;
uniform sampler2D u_sampler;
uniform vec4 u_texCoord;
uniform float u_lod;

void main() {
    my_FragColor = textureProjLodOffset(u_sampler, u_texCoord, u_lod, ivec2(0, 1));
}
</script>
<script id="fshaderTextureGradOffset" type="x-shader/x-fragment">#version 300 es
precision mediump float;

out vec4 my_FragColor;
uniform sampler2D u_sampler;
uniform vec2 u_texCoord;
uniform vec2 u_dPdx;
uniform vec2 u_dPdy;

void main() {
    my_FragColor = textureGradOffset(u_sampler, u_texCoord, u_dPdx, u_dPdy, ivec2(0, 1));
}
</script>
<script id="fshaderTextureProjGradOffset" type="x-shader/x-fragment">#version 300 es
precision mediump float;

out vec4 my_FragColor;
uniform sampler2D u_sampler;
uniform vec4 u_texCoord;
uniform vec2 u_dPdx;
uniform vec2 u_dPdy;

void main() {
    my_FragColor = textureProjGradOffset(u_sampler, u_texCoord, u_dPdx, u_dPdy, ivec2(0, 1));
}
</script>
<script id="fshaderTexelFetchOffset" type="x-shader/x-fragment">#version 300 es
precision mediump float;

out vec4 my_FragColor;
uniform sampler2D u_sampler;
uniform vec2 u_texCoord;
uniform vec2 u_lod;

void main() {
    my_FragColor = texelFetchOffset(u_sampler, ivec2(u_texCoord), int(u_lod), ivec2(0, 1));
}
</script>
<script type="application/javascript">
"use strict";
description("Texture coordinates expressed as uniform variable should not crash in texture offset functions.");

var wtu = WebGLTestUtils;

var shaderTextureOffsetSrc = wtu.getScript('fshaderTextureOffset');
var shaderTextureLodOffsetSrc = wtu.getScript('fshaderTextureLodOffset');
var shaderTextureGradOffsetSrc = wtu.getScript('fshaderTextureGradOffset');
var shaderTextureProjOffsetSrc = wtu.getScript('fshaderTextureProjOffset');
var shaderTextureProjLodOffsetSrc = wtu.getScript('fshaderTextureProjLodOffset');
var shaderTextureProjGradOffsetSrc = wtu.getScript('fshaderTextureProjGradOffset');
var shaderTexelFetchOffsetSrc = wtu.getScript('fshaderTexelFetchOffset');

var gl = wtu.create3DContext(undefined, undefined, 2);

if (!gl) {
    testFailed("Unable to initialize WebGL 2.0 context.");
} else {
    GLSLConformanceTester.runTests([
    {
        fShaderSource: shaderTextureOffsetSrc,
        fShaderSuccess: true,
        linkSuccess: true,
        passMsg: 'textureOffset with uniform texture coordinates should not crash'
    },
    {
        fShaderSource: shaderTextureLodOffsetSrc,
        fShaderSuccess: true,
        linkSuccess: true,
        passMsg: 'textureLodOffset with uniform texture coordinates should not crash'
    },
    {
        fShaderSource: shaderTextureGradOffsetSrc,
        fShaderSuccess: true,
        linkSuccess: true,
        passMsg: 'textureGradOffset with uniform texture coordinates should not crash'
    },
    {
        fShaderSource: shaderTextureProjOffsetSrc,
        fShaderSuccess: true,
        linkSuccess: true,
        passMsg: 'textureProjOffset with uniform texture coordinates should not crash'
    },
    {
        fShaderSource: shaderTextureProjLodOffsetSrc,
        fShaderSuccess: true,
        linkSuccess: true,
         passMsg: 'textureProjLodOffset with uniform texture coordinates should not crash'
    },
    {
        fShaderSource: shaderTextureProjGradOffsetSrc,
        fShaderSuccess: true,
        linkSuccess: true,
        passMsg: 'textureProjGradOffset with uniform texture coordinates should not crash'
    },
    {
        fShaderSource: shaderTexelFetchOffsetSrc,
        fShaderSuccess: true,
        linkSuccess: true,
        passMsg: 'texelFetchOffset with uniform texture coordinates should not crash'
    }
    ], 2);
}
</script>
</body>
</html>