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 dynamic vector and matrix indexing 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=
"fshaderLValueVectorBeingIndexedHasSideEffects" type=
"x-shader/x-fragment">#version
300 es
21 precision mediump float;
23 out vec4 my_FragColor;
27 int sideEffectCounter =
0;
29 int funcWithSideEffects() {
36 V[
0] = vec4(
1.0,
2.0,
3.0,
4.0);
37 V[
1] = vec4(
5.0,
6.0,
7.0,
8.0);
38 // In case this is broken down to two expressions where one reads V[funcWithSideEffects()]
39 // and another writes it, it needs to be made sure that funcWithSideEffects() only gets called once.
40 V[funcWithSideEffects()][u_zero +
1]++;
41 vec4 expectedV0 = vec4(
1.0,
2.0,
3.0,
4.0);
42 vec4 expectedV1 = vec4(
5.0,
7.0,
7.0,
8.0);
43 float f =
1.0 - distance(V[
0], expectedV0) - distance(V[
1], expectedV1);
44 if (sideEffectCounter !=
1) {
47 my_FragColor = vec4(
1.0 - f, f,
0.0,
1.0);
50 <script type=
"application/javascript">
52 description(
"Dynamic indexing of vectors and matrices should work.");
54 debug(
"This test exposes a NVidia driver bug on Linux");
56 GLSLConformanceTester.runRenderTests([
58 fShaderId: 'fshaderLValueVectorBeingIndexedHasSideEffects',
61 passMsg: 'Index a vector expression that itself has side effects, in an l-value'