Auto merge of #21142 - servo:webgl, r=emilio

A couple of small WebGL fixes

<!-- Reviewable:start -->
This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/21142)
<!-- Reviewable:end -->
This commit is contained in:
bors-servo 2018-07-09 09:29:29 -04:00 committed by GitHub
commit 3dc560761e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 25 additions and 1136 deletions

View file

@ -18,6 +18,7 @@ use dom::webglrenderingcontext::MAX_UNIFORM_AND_ATTRIBUTE_LEN;
use dom::webglshader::WebGLShader;
use dom::window::Window;
use dom_struct::dom_struct;
use fnv::FnvHashSet;
use std::cell::{Cell, Ref};
#[dom_struct]
@ -121,6 +122,26 @@ impl WebGLProgram {
let (sender, receiver) = webgl_channel().unwrap();
self.renderer.send(WebGLCommand::LinkProgram(self.id, sender)).unwrap();
let link_info = receiver.recv().unwrap();
// https://www.khronos.org/registry/webgl/specs/latest/1.0/#6.31
let mut used_locs = FnvHashSet::default();
for active_attrib in &*link_info.active_attribs {
if active_attrib.location == -1 {
continue;
}
let columns = match active_attrib.type_ {
constants::FLOAT_MAT2 => 2,
constants::FLOAT_MAT3 => 3,
constants::FLOAT_MAT4 => 4,
_ => 1,
};
for column in 0..columns {
if !used_locs.insert(active_attrib.location as u32 + column) {
return Ok(());
}
}
}
self.linked.set(link_info.linked);
*self.active_attribs.borrow_mut() = link_info.active_attribs;
Ok(())

View file

@ -106,8 +106,6 @@ impl WebGLRenderbuffer {
_ => return Err(WebGLError::InvalidEnum),
};
// FIXME: Check that w/h are < MAX_RENDERBUFFER_SIZE
// FIXME: Invalidate completeness after the call
let msg = WebGLCommand::RenderbufferStorage(constants::RENDERBUFFER, internal_format, width, height);

View file

@ -3863,27 +3863,14 @@ impl WebGLRenderingContextMethods for WebGLRenderingContext {
}
// https://www.khronos.org/registry/webgl/specs/latest/1.0/#5.14.7
fn RenderbufferStorage(&self, target: u32, internal_format: u32,
width: i32, height: i32) {
// From the GLES 2.0.25 spec:
//
// "target must be RENDERBUFFER."
fn RenderbufferStorage(&self, target: u32, internal_format: u32, width: i32, height: i32) {
if target != constants::RENDERBUFFER {
return self.webgl_error(InvalidEnum);
}
// From the GLES 2.0.25 spec:
//
// "If either width or height is greater than the value of
// MAX_RENDERBUFFER_SIZE , the error INVALID_VALUE is
// generated."
//
// and we have to throw out negative-size values as well just
// like for TexImage.
//
// FIXME: Handle max_renderbuffer_size, which doesn't seem to
// be in limits.
if width < 0 || height < 0 {
let max = self.limits.max_renderbuffer_size;
if width < 0 || width as u32 > max || height < 0 || height as u32 > max {
return self.webgl_error(InvalidValue);
}