mirror of
https://github.com/servo/servo.git
synced 2025-07-27 09:10:28 +01:00
Refactor some vertex attrib checks
This commit is contained in:
parent
f108a3e797
commit
0018e5e6ba
1 changed files with 10 additions and 14 deletions
|
@ -2202,13 +2202,7 @@ impl WebGLRenderingContextMethods for WebGLRenderingContext {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
handle_potential_webgl_error!(self, self.vertex_attribs.validate_for_draw(), return);
|
||||||
// https://www.khronos.org/registry/webgl/specs/latest/1.0/#6.2
|
|
||||||
let buffers = self.vertex_attribs.borrow();
|
|
||||||
if buffers.iter().any(|data| data.enabled_as_array && data.buffer.is_none()) {
|
|
||||||
return self.webgl_error(InvalidOperation);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if !self.validate_framebuffer_complete() {
|
if !self.validate_framebuffer_complete() {
|
||||||
return;
|
return;
|
||||||
|
@ -2277,13 +2271,7 @@ impl WebGLRenderingContextMethods for WebGLRenderingContext {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
handle_potential_webgl_error!(self, self.vertex_attribs.validate_for_draw(), return);
|
||||||
// https://www.khronos.org/registry/webgl/specs/latest/1.0/#6.2
|
|
||||||
let buffers = self.vertex_attribs.borrow();
|
|
||||||
if buffers.iter().any(|data| data.enabled_as_array && data.buffer.is_none()) {
|
|
||||||
return self.webgl_error(InvalidOperation);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if !self.validate_framebuffer_complete() {
|
if !self.validate_framebuffer_complete() {
|
||||||
return;
|
return;
|
||||||
|
@ -3852,6 +3840,14 @@ impl VertexAttribs {
|
||||||
fn bind_buffer(&self, index: u32, buffer: &WebGLBuffer) {
|
fn bind_buffer(&self, index: u32, buffer: &WebGLBuffer) {
|
||||||
self.attribs.borrow_mut()[index as usize].buffer = Some(Dom::from_ref(buffer));
|
self.attribs.borrow_mut()[index as usize].buffer = Some(Dom::from_ref(buffer));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn validate_for_draw(&self) -> WebGLResult<()> {
|
||||||
|
// https://www.khronos.org/registry/webgl/specs/latest/1.0/#6.2
|
||||||
|
if self.borrow().iter().any(|data| data.enabled_as_array && data.buffer.is_none()) {
|
||||||
|
return Err(InvalidOperation);
|
||||||
|
}
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Clone, Default, JSTraceable, MallocSizeOf)]
|
#[derive(Clone, Default, JSTraceable, MallocSizeOf)]
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue