mirror of
https://github.com/servo/servo.git
synced 2025-08-03 20:50:07 +01:00
webgl: Ensure that framebuffers have a color attachment before reading or writing.
This commit is contained in:
parent
80ed829241
commit
d179435eab
4 changed files with 129 additions and 4 deletions
|
@ -203,6 +203,16 @@ impl WebGLFramebuffer {
|
|||
return self.status.get();
|
||||
}
|
||||
|
||||
pub fn check_status_for_rendering(&self) -> u32 {
|
||||
let result = self.check_status();
|
||||
if result == constants::FRAMEBUFFER_COMPLETE {
|
||||
if self.color.borrow().is_none() {
|
||||
return constants::FRAMEBUFFER_INCOMPLETE_ATTACHMENT;
|
||||
}
|
||||
}
|
||||
result
|
||||
}
|
||||
|
||||
pub fn renderbuffer(&self, attachment: u32, rb: Option<&WebGLRenderbuffer>) -> WebGLResult<()> {
|
||||
let binding = match attachment {
|
||||
constants::COLOR_ATTACHMENT0 => &self.color,
|
||||
|
|
|
@ -339,7 +339,7 @@ impl WebGLRenderingContext {
|
|||
// this: clear() and getParameter(IMPLEMENTATION_COLOR_READ_*).
|
||||
fn validate_framebuffer(&self) -> WebGLResult<()> {
|
||||
match self.bound_framebuffer.get() {
|
||||
Some(ref fb) if fb.check_status() != constants::FRAMEBUFFER_COMPLETE => {
|
||||
Some(ref fb) if fb.check_status_for_rendering() != constants::FRAMEBUFFER_COMPLETE => {
|
||||
Err(InvalidFramebufferOperation)
|
||||
},
|
||||
_ => Ok(()),
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue