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>Test draw framebuffer completeness when an incomplete framebuffer is bound to read framebuffer
</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>
20 // This exposes a bug in Chrome 67: If the read framebuffer is incomplete, then draw can fail even if the draw framebuffer is complete.
21 // http://anglebug.com/2737
26 var wtu
= WebGLTestUtils
;
27 var gl
= wtu
.create3DContext(undefined, undefined, 2);
29 testFailed("context does not exist");
31 testPassed("context exists");
33 var incompleteFb
= gl
.createFramebuffer();
34 gl
.bindFramebuffer(gl
.FRAMEBUFFER
, incompleteFb
);
35 var incompleteTex
= gl
.createTexture();
36 gl
.bindTexture(gl
.TEXTURE_2D
, incompleteTex
);
37 gl
.framebufferTexture2D(gl
.FRAMEBUFFER
, gl
.COLOR_ATTACHMENT0
, gl
.TEXTURE_2D
, incompleteTex
, 0);
38 shouldBe('gl.checkFramebufferStatus(gl.FRAMEBUFFER)', 'gl.FRAMEBUFFER_INCOMPLETE_ATTACHMENT');
40 wtu
.setupUnitQuad(gl
, 0, 1);
42 var testProgram
= wtu
.setupSimpleColorProgram(gl
, 0);
44 // If this is changed to gl.FRAMEBUFFER, the rendering succeeds on Chrome 67.
45 var drawFbTarget
= gl
.DRAW_FRAMEBUFFER
;
47 var completeFb
= gl
.createFramebuffer();
48 gl
.bindFramebuffer(drawFbTarget
, completeFb
);
49 var completeTex
= gl
.createTexture();
50 gl
.bindTexture(gl
.TEXTURE_2D
, completeTex
);
51 gl
.texStorage2D(gl
.TEXTURE_2D
, 1, gl
.RGBA8
, 128, 128);
52 gl
.framebufferTexture2D(drawFbTarget
, gl
.COLOR_ATTACHMENT0
, gl
.TEXTURE_2D
, completeTex
, 0);
53 wtu
.glErrorShouldBe(gl
, gl
.NO_ERROR
, "should be no error after setup");
55 shouldBe('gl.checkFramebufferStatus(gl.READ_FRAMEBUFFER)', 'gl.FRAMEBUFFER_INCOMPLETE_ATTACHMENT');
56 shouldBe('gl.checkFramebufferStatus(gl.DRAW_FRAMEBUFFER)', 'gl.FRAMEBUFFER_COMPLETE');
58 gl
.viewport(0, 0, 128, 128);
59 gl
.uniform4f(gl
.getUniformLocation(testProgram
, 'u_color'), 0, 1, 0, 1);
62 wtu
.glErrorShouldBe(gl
, gl
.NO_ERROR
, "should be no error after draw");
63 gl
.bindFramebuffer(gl
.READ_FRAMEBUFFER
, completeFb
);
64 wtu
.checkCanvasRect(gl
, 0, 0, 128, 128, [0, 255, 0, 255], 'should be green', 2);
68 var successfullyParsed
= true;
71 <script src=
"../../js/js-test-post.js"></script>