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 struct containing an array of samplers passed into a user-defined function
</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>
19 <canvas id=
"output" style=
"border: none;" width=
"64" height=
"64"></canvas>
20 <div id=
"description"></div>
21 <div id=
"console"></div>
22 <script id=
"fshaderSampler" type=
"x-shader/x-fragment">
23 precision mediump float;
31 vec4 useSampler(S arg)
33 return texture2D(arg.sam[
0], vec2(
0.0,
0.0));
37 gl_FragColor = vec4(useSampler(uni));
40 <script type=
"application/javascript">
44 var wtu = WebGLTestUtils;
45 var canvas = document.getElementById(
"output");
46 var gl = wtu.create3DContext(canvas);
49 testFailed(
"Could not create a GL context.");
51 debug(
"Drawing with a shader that uses a sampler array in a struct passed into a function.");
52 var program = wtu.setupProgram(
53 gl, [wtu.simpleVertexShader, 'fshaderSampler'], ['a_position'], [
0], true);
54 wtu.setupUnitQuad(gl);
56 var tex = gl.createTexture();
57 gl.bindTexture(gl.TEXTURE_2D, tex);
58 gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.NEAREST);
59 gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.NEAREST);
60 gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE);
61 gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE);
62 wtu.fillTexture(gl, tex,
1,
1, [
0,
255,
0,
255]);
64 wtu.clearAndDrawUnitQuad(gl);
65 wtu.checkCanvas(gl, [
0,
255,
0,
255],
"should be green");
68 var successfullyParsed = true;
70 <script src=
"../../../js/js-test-post.js"></script>