Do not try to read pixels from an FBO without read buffer

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.
This commit is contained in:
Mátyás Mustoha 2020-03-16 13:06:02 +01:00
parent 0afe27ef18
commit a6359fe587
2 changed files with 5 additions and 7 deletions

View file

@ -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);
}

View file

@ -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