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 Structure as Inout Parameter Test
</title>
12 <link rel=
"stylesheet" href=
"../../../resources/js-test-style.css"/>
13 <link rel=
"stylesheet" href=
"../../../resources/glsl-feature-tests.css"/>
14 <script src=
"../../../js/js-test-pre.js"></script>
15 <script src=
"../../../js/webgl-test-utils.js"> </script>
16 <script src=
"../../../js/glsl-conformance-test.js"></script>
18 <script id=
"simple-vs" type=
"x-shader/x-vertex">
19 attribute vec4 a_position;
21 gl_Position = a_position;
24 <script id=
"struct-inout-parameter-fs" type=
"x-shader/x-fragment">
30 void modify(inout ColorData colorData) {
31 colorData.red += vec3(
0.5,
0.0,
0.0);
32 colorData.blue += vec3(
0.0,
0.0,
0.5);
37 colorData.red = vec3(
0.5,
0.0,
0.0);
38 colorData.blue = vec3(
0.0,
0.0,
0.5);
40 vec3 red = vec3(
1.0,
0.0,
0.0);
41 vec3 green = vec3(
0.0,
1.0,
0.0);
42 vec3 blue = vec3(
0.0,
0.0,
1.0);
47 if (colorData.red == red && colorData.blue == blue)
52 gl_FragColor = vec4(finalColor,
1.0);
57 <div id=
"description"></div>
58 <div id=
"console"></div>
61 description("Testing structs as inout parameter");
63 debug('Regression test for <a href="http://crbug.com/851870">http://crbug.com/851870</a> / <a href="https://github.com/mrdoob/three.js/issues/14137">https://github.com/mrdoob/three.js/issues/14137</a>');
65 function prepend(floatPrecision
) {
66 let source
= document
.getElementById('struct-inout-parameter-fs').text
;
67 return 'precision ' + floatPrecision
+ ' float;\n' + source
;
72 vShaderId
: "simple-vs",
74 fShaderSource
: prepend('lowp'),
78 passMsg
: "lowp struct used as inout parameter",
81 vShaderId
: "simple-vs",
83 fShaderSource
: prepend('mediump'),
87 passMsg
: "mediump struct used as inout parameter",
91 let wtu
= WebGLTestUtils
;
92 let gl
= wtu
.create3DContext();
93 let precision
= gl
.getShaderPrecisionFormat(gl
.FRAGMENT_SHADER
, gl
.HIGH_FLOAT
);
94 let highpSupported
= (precision
.rangeMin
>= 62 && precision
.rangeMax
>= 62 && precision
.precision
>= 16);
95 debug("highp is" + (highpSupported
? "" : " not") + " supported in fragment shaders");
100 vShaderId
: "simple-vs",
101 vShaderSuccess
: true,
102 fShaderSource
: prepend('highp'),
103 fShaderSuccess
: true,
106 passMsg
: "highp struct used as inout parameter",
111 GLSLConformanceTester
.runTests(tests
);
114 var successfullyParsed
= true;