Skip to content

Commit

Permalink
webgl: Fix up maximum size validation.
Browse files Browse the repository at this point in the history
We were checking to see if it was too big to be level 0, but we really
want to see if it's too big to be the given level.

This was the last remaining failure in texture-size-limit.html.
  • Loading branch information
anholt committed Oct 24, 2016
1 parent 2f68297 commit 5b852b1
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 188 deletions.
10 changes: 5 additions & 5 deletions components/script/dom/webgl_validations/tex_image_2d.rs
Expand Up @@ -163,18 +163,18 @@ impl<'a> WebGLValidator for CommonTexImage2DValidator<'a> {
return Err(TexImageValidationError::NegativeDimension);
}

let width = self.width as u32;
let height = self.height as u32;
let level = self.level as u32;

// GL_INVALID_VALUE is generated if width or height is greater than
// GL_MAX_TEXTURE_SIZE when target is GL_TEXTURE_2D or
// GL_MAX_CUBE_MAP_TEXTURE_SIZE when target is not GL_TEXTURE_2D.
if self.width as u32 > max_size || self.height as u32 > max_size {
if width > max_size >> level || height > max_size >> level {
self.context.webgl_error(InvalidValue);
return Err(TexImageValidationError::TextureTooBig);
}

let width = self.width as u32;
let height = self.height as u32;
let level = self.level as u32;

// GL_INVALID_VALUE is generated if level is greater than zero and the
// texture is not power of two.
if level > 0 && (!width.is_power_of_two() || !height.is_power_of_two()) {
Expand Down

This file was deleted.

0 comments on commit 5b852b1

Please sign in to comment.