Skip to content

Commit

Permalink
Do not try to read pixels from an FBO without read buffer
Browse files Browse the repository at this point in the history
Adds another check to the WebGL2 ReadPixels implementation to fix
an OpenGL invalid operation crash when the method is called on a
bound framebuffer that has no read buffer.
  • Loading branch information
mmatyas committed Mar 17, 2020
1 parent 0afe27e commit a6359fe
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 7 deletions.
6 changes: 5 additions & 1 deletion components/script/dom/webgl2renderingcontext.rs
Expand Up @@ -349,7 +349,11 @@ impl WebGL2RenderingContext {
}

let fb_slot = self.base.get_draw_framebuffer_slot();
if fb_slot.get().is_none() && self.default_fb_readbuffer.get() == constants::NONE {
let fb_readbuffer_valid = match fb_slot.get() {
Some(fb) => fb.attachment(fb.read_buffer()).is_some(),
None => self.default_fb_readbuffer.get() != constants::NONE,
};
if !fb_readbuffer_valid {
return self.base.webgl_error(InvalidOperation);
}

Expand Down
@@ -1,8 +1,2 @@
[readbuffer.html]
expected: TIMEOUT
[WebGL test #3: gl.getParameter(gl.READ_BUFFER) should be 1029 (of type number). Was null (of type object).]
expected: FAIL

[WebGL test #4: successfullyParsed should be true (of type boolean). Was undefined (of type undefined).]
expected: FAIL

0 comments on commit a6359fe

Please sign in to comment.