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.
9 <title>WebGL
2 Normalized Vertex Attributes Conformance Test
</title>
10 <meta charset=
"utf-8">
11 <link rel=
"stylesheet" href=
"../../resources/js-test-style.css"/>
14 <canvas width=
1 height=
1></canvas>
15 <div id=
"description"></div>
16 <div id=
"console"></div>
17 <script id=
"vertex-shader" type=
"x-shader/x-vertex">#version
300 es
18 layout(location =
0) in vec3 vertex;
23 gl_Position = vec4(vertex.xy,
0,
1);
24 normAttrib = vertex.z;
27 <script id=
"fragment-shader" type=
"x-shader/x-fragment">#version
300 es
28 in lowp float normAttrib;
30 layout(location=
0) out lowp vec4 fragColor;
33 fragColor = vec4(vec3(normAttrib == -
1.0 ?
1.0 :
0.0),
1);
36 <script src=
"../../js/js-test-pre.js"></script>
37 <script src=
"../../js/webgl-test-utils.js"></script>
42 var wtu
= WebGLTestUtils
;
44 var gl
= wtu
.create3DContext(document
.querySelector('canvas'), null, 2);
46 var program
= wtu
.setupProgram(gl
, ['vertex-shader', 'fragment-shader']);
48 gl
.useProgram(program
);
50 var buffer
= gl
.createBuffer();
51 gl
.bindBuffer(gl
.ARRAY_BUFFER
, buffer
);
52 gl
.bufferData(gl
.ARRAY_BUFFER
, new Int8Array([
53 // Here we set the third component (the one that's actually tested)
54 // to (MIN_INT + 1). If non-zero-preserving rules are used, it'll be
55 // converted to a float that's slightly greater than -1. If zero-preserving
56 // rules are used, as the GLES 3 spec requires, result of conversion
57 // should be exactly -1.
66 gl
.enableVertexAttribArray(0);
67 gl
.vertexAttribPointer(0, 3, gl
.BYTE
, true, 0, 0);
69 gl
.drawArrays(gl
.TRIANGLE_STRIP
, 0, 6);
71 wtu
.checkCanvas(gl
, [255, 255, 255, 255], "should be opaque white");
75 description('Verify that conversion of normalized signed int attributes to floats uses zero-preserving rule.');
76 window
.successfullyParsed
= true;
78 <script src=
"../../js/js-test-post.js"></script>