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 deletion behavior 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>
17 <div id=
"description"></div>
18 <div id=
"console"></div>
21 description("Test buffer deletion behavior.");
22 // This is a regression test for https://crbug.com/822976
24 var wtu
= WebGLTestUtils
;
26 var gl
= wtu
.create3DContext(undefined, undefined, 2);
27 wtu
.glErrorShouldBe(gl
, gl
.NO_ERROR
, "Should be no errors from setup.");
29 function runTexImageTest(gl
) {
31 var buffer
= gl
.createBuffer();
32 gl
.bindBuffer(gl
.PIXEL_UNPACK_BUFFER
, buffer
);
33 gl
.bufferData(gl
.PIXEL_UNPACK_BUFFER
, 4, gl
.DYNAMIC_DRAW
);
34 gl
.bindBufferBase(gl
.UNIFORM_BUFFER
, 0, buffer
);
35 gl
.deleteBuffer(buffer
);
36 // Indexed uniform buffer bindings should not prevent a buffer from being
37 // deleted. Therefore, PIXEL_UNPACK_BUFFER binding should also be 0.
38 wtu
.glErrorShouldBe(gl
, gl
.NO_ERROR
, "no error");
40 var tex
= gl
.createTexture();
41 gl
.bindTexture(gl
.TEXTURE_2D
, tex
);
42 var data
= new Uint8Array(1024);
43 gl
.texImage2D(gl
.TEXTURE_2D
, 0, gl
.RGBA8
, 16, 16, 0,
44 gl
.RGBA
, gl
.UNSIGNED_BYTE
, data
);
45 wtu
.glErrorShouldBe(gl
, gl
.NO_ERROR
, "texImage2D should succeed");
47 // Clean up bindings just in case an implementation gets it wrong.
48 gl
.bindBuffer(gl
.PIXEL_UNPACK_BUFFER
, null);
49 gl
.bindBufferBase(gl
.UNIFORM_BUFFER
, 0, null);
52 function runReadPixelsTest(gl
) {
54 var buffer
= gl
.createBuffer();
55 gl
.bindBuffer(gl
.PIXEL_PACK_BUFFER
, buffer
);
56 gl
.bufferData(gl
.PIXEL_PACK_BUFFER
, 4, gl
.DYNAMIC_DRAW
);
57 gl
.bindBufferBase(gl
.UNIFORM_BUFFER
, 0, buffer
);
58 gl
.deleteBuffer(buffer
);
59 // Indexed transform feedback buffer bindings should not prevent a buffer
60 // from being deleted. Therefore, PIXEL_PACK_BUFFER binding should also be 0.
61 wtu
.glErrorShouldBe(gl
, gl
.NO_ERROR
, "no error");
63 var buffer
= new Uint8Array(1024);
64 gl
.readPixels(0, 0, 16, 16, gl
.RGBA
, gl
.UNSIGNED_BYTE
, buffer
);
65 wtu
.glErrorShouldBe(gl
, gl
.NO_ERROR
, "readPixels should succeed");
67 // Clean up bindings just in case an implementation gets it wrong.
68 gl
.bindBuffer(gl
.PIXEL_PACK_BUFFER
, null);
69 gl
.bindBufferBase(gl
.UNIFORM_BUFFER
, 0, null);
73 runReadPixelsTest(gl
);
76 var successfullyParsed
= true;
78 <script src=
"../../js/js-test-post.js"></script>