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>WebGL buffer overflow test for bindBufferRange
</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>
17 <div id=
"description"></div>
18 <div id=
"console"></div>
21 description("WebGL buffer overflow test: buffer overflow will not lead to failure in bindBufferRange");
23 var wtu
= WebGLTestUtils
;
25 var gl
= wtu
.create3DContext(undefined, undefined, 2);
28 var buffer1
= gl
.createBuffer();
29 gl
.bindBufferRange(gl
.TRANSFORM_FEEDBACK_BUFFER
, 0, buffer1
, 0, 4);
30 wtu
.glErrorShouldBe(gl
, gl
.NO_ERROR
,
31 "Calling bindBufferRange on a buffer where no storage is allocated should succeed.");
32 shouldBe("buffer1", "gl.getIndexedParameter(gl.TRANSFORM_FEEDBACK_BUFFER_BINDING, 0)");
33 shouldBe("4", "gl.getIndexedParameter(gl.TRANSFORM_FEEDBACK_BUFFER_SIZE, 0)");
34 shouldBe("0", "gl.getIndexedParameter(gl.TRANSFORM_FEEDBACK_BUFFER_START, 0)");
36 var buffer2
= gl
.createBuffer();
37 gl
.bindBuffer(gl
.UNIFORM_BUFFER
, buffer2
);
38 gl
.bufferData(gl
.UNIFORM_BUFFER
, 4, gl
.STATIC_DRAW
);
39 gl
.bindBufferRange(gl
.UNIFORM_BUFFER
, 1, buffer2
, 0, 8);
40 wtu
.glErrorShouldBe(gl
, gl
.NO_ERROR
,
41 "Calling bindBufferRange on a buffer where the storage is not big enough should succeed.");
42 shouldBe("buffer2", "gl.getIndexedParameter(gl.UNIFORM_BUFFER_BINDING, 1)");
43 shouldBe("8", "gl.getIndexedParameter(gl.UNIFORM_BUFFER_SIZE, 1)");
44 shouldBe("0", "gl.getIndexedParameter(gl.UNIFORM_BUFFER_START, 1)");
47 var successfullyParsed
= true;
49 <script src=
"../../js/js-test-post.js"></script>