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 <link rel=
"stylesheet" href=
"../../resources/js-test-style.css"/>
12 <script src=
"../../js/js-test-pre.js"></script>
13 <script src=
"../../js/webgl-test-utils.js"></script>
16 <div id=
"description"></div>
17 <div id=
"console"></div>
21 description("Tests deletion behavior for WebGL2 buffer, sampler, vertexArray and transformFeedback objects.");
23 var wtu
= WebGLTestUtils
;
24 var gl
= wtu
.create3DContext(undefined, undefined, 2);
25 var shouldGenerateGLError
= wtu
.shouldGenerateGLError
;
28 debug("buffer deletion");
30 var bufferBaseUniform
= gl
.createBuffer();
31 shouldBeNonNull("bufferBaseUniform");
32 shouldGenerateGLError(gl
, gl
.NO_ERROR
, "gl.bindBufferBase(gl.UNIFORM_BUFFER, 0, bufferBaseUniform)");
33 shouldBe("gl.getParameter(gl.UNIFORM_BUFFER_BINDING)", "bufferBaseUniform");
34 shouldGenerateGLError(gl
, gl
.NO_ERROR
, "gl.deleteBuffer(bufferBaseUniform)");
35 shouldBeFalse("gl.isBuffer(bufferBaseUniform)");
36 shouldBeNull("gl.getParameter(gl.UNIFORM_BUFFER_BINDING)");
37 shouldGenerateGLError(gl
, gl
.INVALID_OPERATION
, "gl.bindBufferBase(gl.UNIFORM_BUFFER, 0, bufferBaseUniform)");
38 shouldBeNull("gl.getParameter(gl.UNIFORM_BUFFER_BINDING)");
40 var bufferBaseTransformFeedback
= gl
.createBuffer();
41 shouldBeNonNull("bufferBaseTransformFeedback");
42 shouldGenerateGLError(gl
, gl
.NO_ERROR
, "gl.bindBufferBase(gl.TRANSFORM_FEEDBACK_BUFFER, 0, bufferBaseTransformFeedback)");
43 shouldBe("gl.getParameter(gl.TRANSFORM_FEEDBACK_BUFFER_BINDING)", "bufferBaseTransformFeedback");
44 shouldGenerateGLError(gl
, gl
.NO_ERROR
, "gl.deleteBuffer(bufferBaseTransformFeedback)");
45 shouldBeFalse("gl.isBuffer(bufferBaseTransformFeedback)");
46 shouldBeNull("gl.getParameter(gl.TRANSFORM_FEEDBACK_BUFFER_BINDING)");
47 shouldGenerateGLError(gl
, gl
.INVALID_OPERATION
, "gl.bindBufferBase(gl.TRANSFORM_FEEDBACK_BUFFER, 0, bufferBaseTransformFeedback)");
48 shouldBeNull("gl.getParameter(gl.TRANSFORM_FEEDBACK_BUFFER_BINDING)");
50 var bufferRangeUniform
= gl
.createBuffer();
51 shouldBeNonNull("bufferRangeUniform");
52 shouldGenerateGLError(gl
, gl
.NO_ERROR
, "gl.bindBufferRange(gl.UNIFORM_BUFFER, 0, bufferRangeUniform, 0, gl.UNIFORM_BUFFER_OFFSET_ALIGNMENT)");
53 shouldBe("gl.getParameter(gl.UNIFORM_BUFFER_BINDING)", "bufferRangeUniform");
54 shouldGenerateGLError(gl
, gl
.NO_ERROR
, "gl.deleteBuffer(bufferRangeUniform)");
55 shouldBeFalse("gl.isBuffer(bufferRangeUniform)");
56 shouldBeNull("gl.getParameter(gl.UNIFORM_BUFFER_BINDING)");
57 shouldGenerateGLError(gl
, gl
.INVALID_OPERATION
, "gl.bindBufferRange(gl.UNIFORM_BUFFER, 0, bufferRangeUniform, 0, gl.UNIFORM_BUFFER_OFFSET_ALIGNMENT)");
58 shouldBeNull("gl.getParameter(gl.UNIFORM_BUFFER_BINDING)");
60 var bufferRangeTransformFeedback
= gl
.createBuffer();
61 shouldBeNonNull("bufferRangeTransformFeedback");
62 shouldGenerateGLError(gl
, gl
.NO_ERROR
, "gl.bindBufferRange(gl.TRANSFORM_FEEDBACK_BUFFER, 0, bufferRangeTransformFeedback, 0, 4)");
63 shouldBe("gl.getParameter(gl.TRANSFORM_FEEDBACK_BUFFER_BINDING)", "bufferRangeTransformFeedback");
64 shouldGenerateGLError(gl
, gl
.NO_ERROR
, "gl.deleteBuffer(bufferRangeTransformFeedback)");
65 shouldBeFalse("gl.isBuffer(bufferRangeTransformFeedback)");
66 shouldBeNull("gl.getParameter(gl.TRANSFORM_FEEDBACK_BUFFER_BINDING)");
67 shouldGenerateGLError(gl
, gl
.INVALID_OPERATION
, "gl.bindBufferRange(gl.TRANSFORM_FEEDBACK_BUFFER, 0, bufferRangeTransformFeedback, 0, 4)");
68 shouldBeNull("gl.getParameter(gl.TRANSFORM_FEEDBACK_BUFFER_BINDING)");
71 debug("sampler deletion");
73 var sampler
= gl
.createSampler();
74 shouldBeNonNull("sampler");
75 shouldGenerateGLError(gl
, gl
.NO_ERROR
, "gl.bindSampler(0, sampler)");
76 shouldBe("gl.getParameter(gl.SAMPLER_BINDING)", "sampler");
77 shouldGenerateGLError(gl
, gl
.NO_ERROR
, "gl.deleteSampler(sampler)");
78 shouldBeFalse("gl.isSampler(sampler)");
79 shouldBeNull("gl.getParameter(gl.SAMPLER_BINDING)");
80 shouldGenerateGLError(gl
, gl
.INVALID_OPERATION
, "gl.bindSampler(0, sampler)");
81 shouldBeNull("gl.getParameter(gl.SAMPLER_BINDING)");
84 debug("vertexArray deletion");
86 var vertexArray
= gl
.createVertexArray();
87 shouldBeNonNull("vertexArray");
88 shouldGenerateGLError(gl
, gl
.NO_ERROR
, "gl.bindVertexArray(vertexArray)");
89 shouldBe("gl.getParameter(gl.VERTEX_ARRAY_BINDING)", "vertexArray");
90 shouldGenerateGLError(gl
, gl
.NO_ERROR
, "gl.deleteVertexArray(vertexArray)");
91 shouldBeFalse("gl.isVertexArray(vertexArray)");
92 shouldBeNull("gl.getParameter(gl.VERTEX_ARRAY_BINDING)");
93 shouldGenerateGLError(gl
, gl
.INVALID_OPERATION
, "gl.bindVertexArray(vertexArray)");
94 shouldBeNull("gl.getParameter(gl.VERTEX_ARRAY_BINDING)");
97 debug("transformFeedback deletion");
99 var transformFeedback
= gl
.createTransformFeedback();
100 shouldBeNonNull("transformFeedback");
101 shouldGenerateGLError(gl
, gl
.NO_ERROR
, "gl.bindTransformFeedback(gl.TRANSFORM_FEEDBACK, transformFeedback)");
102 shouldBe("gl.getParameter(gl.TRANSFORM_FEEDBACK_BINDING)", "transformFeedback");
103 shouldGenerateGLError(gl
, gl
.NO_ERROR
, "gl.deleteTransformFeedback(transformFeedback)");
104 shouldBeFalse("gl.isTransformFeedback(transformFeedback)");
105 shouldBeNull("gl.getParameter(gl.TRANSFORM_FEEDBACK_BINDING)");
106 shouldGenerateGLError(gl
, gl
.INVALID_OPERATION
, "gl.bindTransformFeedback(gl.TRANSFORM_FEEDBACK, transformFeedback)");
107 shouldBeNull("gl.getParameter(gl.TRANSFORM_FEEDBACK_BINDING)");
109 var successfullyParsed
= true;
112 <script src=
"../../js/js-test-post.js"></script>