webgl: Differentiate between missing colour attachments and incomplete attachments.

This commit is contained in:
Josh Matthews 2018-08-22 15:26:32 -04:00
parent 690c98dda7
commit df8e36aa78
3 changed files with 18 additions and 17 deletions

View file

@ -18,6 +18,12 @@ use dom::webgltexture::WebGLTexture;
use dom_struct::dom_struct; use dom_struct::dom_struct;
use std::cell::Cell; use std::cell::Cell;
pub enum CompleteForRendering {
Complete,
Incomplete,
MissingColorAttachment,
}
#[must_root] #[must_root]
#[derive(Clone, JSTraceable, MallocSizeOf)] #[derive(Clone, JSTraceable, MallocSizeOf)]
enum WebGLFramebufferAttachment { enum WebGLFramebufferAttachment {
@ -214,14 +220,14 @@ impl WebGLFramebuffer {
return self.status.get(); return self.status.get();
} }
pub fn check_status_for_rendering(&self) -> u32 { pub fn check_status_for_rendering(&self) -> CompleteForRendering {
let result = self.check_status(); let result = self.check_status();
if result != constants::FRAMEBUFFER_COMPLETE { if result != constants::FRAMEBUFFER_COMPLETE {
return result; return CompleteForRendering::Incomplete;
} }
if self.color.borrow().is_none() { if self.color.borrow().is_none() {
return constants::FRAMEBUFFER_INCOMPLETE_ATTACHMENT; return CompleteForRendering::MissingColorAttachment;
} }
if !self.is_initialized.get() { if !self.is_initialized.get() {
@ -245,7 +251,7 @@ impl WebGLFramebuffer {
self.is_initialized.set(true); self.is_initialized.set(true);
} }
constants::FRAMEBUFFER_COMPLETE CompleteForRendering::Complete
} }
pub fn renderbuffer(&self, attachment: u32, rb: Option<&WebGLRenderbuffer>) -> WebGLResult<()> { pub fn renderbuffer(&self, attachment: u32, rb: Option<&WebGLRenderbuffer>) -> WebGLResult<()> {

View file

@ -39,7 +39,7 @@ use dom::webgl_validations::types::{TexDataType, TexFormat, TexImageTarget};
use dom::webglactiveinfo::WebGLActiveInfo; use dom::webglactiveinfo::WebGLActiveInfo;
use dom::webglbuffer::WebGLBuffer; use dom::webglbuffer::WebGLBuffer;
use dom::webglcontextevent::WebGLContextEvent; use dom::webglcontextevent::WebGLContextEvent;
use dom::webglframebuffer::{WebGLFramebuffer, WebGLFramebufferAttachmentRoot}; use dom::webglframebuffer::{WebGLFramebuffer, WebGLFramebufferAttachmentRoot, CompleteForRendering};
use dom::webglobject::WebGLObject; use dom::webglobject::WebGLObject;
use dom::webglprogram::WebGLProgram; use dom::webglprogram::WebGLProgram;
use dom::webglrenderbuffer::WebGLRenderbuffer; use dom::webglrenderbuffer::WebGLRenderbuffer;
@ -339,10 +339,14 @@ impl WebGLRenderingContext {
// this: clear() and getParameter(IMPLEMENTATION_COLOR_READ_*). // this: clear() and getParameter(IMPLEMENTATION_COLOR_READ_*).
fn validate_framebuffer(&self) -> WebGLResult<()> { fn validate_framebuffer(&self) -> WebGLResult<()> {
match self.bound_framebuffer.get() { match self.bound_framebuffer.get() {
Some(ref fb) if fb.check_status_for_rendering() != constants::FRAMEBUFFER_COMPLETE => { Some(fb) => match fb.check_status_for_rendering() {
Err(InvalidFramebufferOperation) CompleteForRendering::Complete => Ok(()),
CompleteForRendering::Incomplete =>
Err(InvalidFramebufferOperation),
CompleteForRendering::MissingColorAttachment =>
Err(InvalidOperation),
}, },
_ => Ok(()), None => Ok(()),
} }
} }

View file

@ -1,12 +1,3 @@
[framebuffer-object-attachment.html] [framebuffer-object-attachment.html]
[WebGL test #139: at (0, 0) expected: 0,255,0,255 was 255,0,0,255] [WebGL test #139: at (0, 0) expected: 0,255,0,255 was 255,0,0,255]
expected: fail expected: fail
[WebGL test #559: getError expected: INVALID_OPERATION. Was INVALID_FRAMEBUFFER_OPERATION : After CopyTexSubImage2D from missing attachment]
expected: FAIL
[WebGL test #555: getError expected: INVALID_OPERATION. Was INVALID_FRAMEBUFFER_OPERATION : After ReadPixels from missing attachment]
expected: FAIL
[WebGL test #557: getError expected: INVALID_OPERATION. Was INVALID_FRAMEBUFFER_OPERATION : After CopyTexImage2D from missing attachment]
expected: FAIL