diff options
author | bors-servo <lbergstrom+bors@mozilla.com> | 2020-03-17 10:31:01 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-03-17 10:31:01 -0400 |
commit | 59c68e2eb7afdda17fc27e866360a1746a78bbda (patch) | |
tree | c93afd0def04971b4c2091c266ae6e2d058bb828 /components/script/dom/webgl2renderingcontext.rs | |
parent | 54769a86b9de1815e935065de83548ef534ebeeb (diff) | |
parent | a6359fe587aa5ed55aee8bb1b7a4a2c4138ec6c3 (diff) | |
download | servo-59c68e2eb7afdda17fc27e866360a1746a78bbda.tar.gz servo-59c68e2eb7afdda17fc27e866360a1746a78bbda.zip |
Auto merge of #25975 - mmatyas:webgl_fns_read_draw_buffers_p2, r=jdm
Do not try to read pixels from an FBO without read buffer
A follow up to #25905, this 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.
<!-- Please describe your changes on the following line: -->
cc @jdm @zakorgy
However, it seems there's an issue with the headless mode: when ReadBuffer is called on the default framebuffer with the value `GL_BACK`, like [here](https://github.com/servo/servo/blob/e1103176e3de8a8c0996d1d60c092cfd8f60e805/tests/wpt/webgl/tests/conformance2/renderbuffers/readbuffer.html#L77), in headless mode an invalid operation is generated. In non-headless mode the whole test completes successfully:

---
<!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `___` with appropriate data: -->
- [x] `./mach build -d` does not report any errors
- [x] `./mach test-tidy` does not report any errors
- [x] There are tests for these changes
<!-- Also, please make sure that "Allow edits from maintainers" checkbox is checked, so that we can help you if you get stuck somewhere along the way.-->
<!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. -->
Diffstat (limited to 'components/script/dom/webgl2renderingcontext.rs')
-rw-r--r-- | components/script/dom/webgl2renderingcontext.rs | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/components/script/dom/webgl2renderingcontext.rs b/components/script/dom/webgl2renderingcontext.rs index c0c3aab5ad6..7b1a68b475a 100644 --- a/components/script/dom/webgl2renderingcontext.rs +++ b/components/script/dom/webgl2renderingcontext.rs @@ -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); } |