mirror of
https://github.com/servo/servo.git
synced 2025-08-05 13:40:08 +01:00
Auto merge of #13898 - anholt:webgl-texture-fixes, r=emilio
webgl: texture size validation fixes <!-- Please describe your changes on the following line: --> This pull request fixes the errors in texture-size-limit.html. --- <!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `__` with appropriate data: --> - [X] `./mach build -d` does not report any errors - [X] `./mach test-tidy` does not report any errors - [ ] These changes fix #__ (github issue number if applicable). <!-- Either: --> - [X] There are tests for these changes OR - [ ] These changes do not require tests because _____ <!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. --> <!-- 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/13898) <!-- Reviewable:end -->
This commit is contained in:
commit
f3973a0d3b
6 changed files with 1172 additions and 1547 deletions
|
@ -163,18 +163,18 @@ impl<'a> WebGLValidator for CommonTexImage2DValidator<'a> {
|
|||
return Err(TexImageValidationError::NegativeDimension);
|
||||
}
|
||||
|
||||
// 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 {
|
||||
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 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 width > max_size >> level || height > max_size >> level {
|
||||
self.context.webgl_error(InvalidValue);
|
||||
return Err(TexImageValidationError::TextureTooBig);
|
||||
}
|
||||
|
||||
// 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()) {
|
||||
|
|
|
@ -2359,7 +2359,13 @@ impl WebGLRenderingContextMethods for WebGLRenderingContext {
|
|||
Some(data) => data,
|
||||
};
|
||||
|
||||
if buff.len() != expected_byte_length as usize {
|
||||
// From the WebGL spec:
|
||||
//
|
||||
// "If pixels is non-null but its size is less than what
|
||||
// is required by the specified width, height, format,
|
||||
// type, and pixel storage parameters, generates an
|
||||
// INVALID_OPERATION error."
|
||||
if buff.len() < expected_byte_length as usize {
|
||||
return Ok(self.webgl_error(InvalidOperation));
|
||||
}
|
||||
|
||||
|
@ -2459,8 +2465,13 @@ impl WebGLRenderingContextMethods for WebGLRenderingContext {
|
|||
Some(data) => data,
|
||||
};
|
||||
|
||||
if expected_byte_length != 0 &&
|
||||
buff.len() != expected_byte_length as usize {
|
||||
// From the WebGL spec:
|
||||
//
|
||||
// "If pixels is non-null but its size is less than what
|
||||
// is required by the specified width, height, format,
|
||||
// type, and pixel storage parameters, generates an
|
||||
// INVALID_OPERATION error."
|
||||
if buff.len() < expected_byte_length as usize {
|
||||
return Ok(self.webgl_error(InvalidOperation));
|
||||
}
|
||||
|
||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -1,26 +0,0 @@
|
|||
[texture-formats-test.html]
|
||||
type: testharness
|
||||
[WebGL test #1: successfullyParsed should be true (of type boolean). Was undefined (of type undefined).]
|
||||
expected: FAIL
|
||||
|
||||
[WebGL test #0: Unable to fetch WebGL rendering context for Canvas]
|
||||
expected: FAIL
|
||||
|
||||
[WebGL test #1: context does not exist]
|
||||
expected: FAIL
|
||||
|
||||
[WebGL test #77: getError expected: NO_ERROR. Was INVALID_OPERATION : gl.texImage2D with format: RGBA, type: UNSIGNED_SHORT_4_4_4_4 should generate NO_ERROR]
|
||||
expected: FAIL
|
||||
|
||||
[WebGL test #78: at (0, 0) expected: 0,0,255,255 was 0,255,0,255]
|
||||
expected: FAIL
|
||||
|
||||
[WebGL test #79: getError expected: NO_ERROR. Was INVALID_OPERATION : gl.texImage2D with format: RGB, type: UNSIGNED_SHORT_5_6_5 should generate NO_ERROR]
|
||||
expected: FAIL
|
||||
|
||||
[WebGL test #81: getError expected: NO_ERROR. Was INVALID_OPERATION : gl.texImage2D with format: RGBA, type: UNSIGNED_SHORT_5_5_5_1 should generate NO_ERROR]
|
||||
expected: FAIL
|
||||
|
||||
[WebGL test #82: at (0, 0) expected: 0,0,255,255 was 0,255,0,255]
|
||||
expected: FAIL
|
||||
|
|
@ -3,33 +3,21 @@
|
|||
[WebGL test #4: at (0, 0) expected: 0,0,0,255 was 192,0,128,64]
|
||||
expected: FAIL
|
||||
|
||||
[WebGL test #14: getError expected: NO_ERROR. Was INVALID_OPERATION : gl.texImage2D with NPOT texture at level 0 should succeed]
|
||||
expected: FAIL
|
||||
|
||||
[WebGL test #20: at (0, 0) expected: 192,0,128,255 was 0,0,0,255]
|
||||
expected: FAIL
|
||||
|
||||
[WebGL test #26: getError expected: NO_ERROR. Was INVALID_OPERATION : gl.texImage2D with NPOT texture at level 0 should succeed]
|
||||
expected: FAIL
|
||||
|
||||
[WebGL test #32: at (0, 0) expected: 192,192,192,255 was 0,0,0,255]
|
||||
expected: FAIL
|
||||
|
||||
[WebGL test #38: getError expected: NO_ERROR. Was INVALID_OPERATION : gl.texImage2D with NPOT texture at level 0 should succeed]
|
||||
expected: FAIL
|
||||
|
||||
[WebGL test #44: at (0, 0) expected: 0,0,0,64 was 0,0,0,255]
|
||||
expected: FAIL
|
||||
|
||||
[WebGL test #50: getError expected: NO_ERROR. Was INVALID_OPERATION : gl.texImage2D with NPOT texture at level 0 should succeed]
|
||||
expected: FAIL
|
||||
|
||||
[WebGL test #56: at (0, 0) expected: 192,192,192,64 was 0,0,0,255]
|
||||
expected: FAIL
|
||||
|
||||
[WebGL test #64: at (0, 0) expected: 0,0,0,255 was 0,192,128,255]
|
||||
expected: FAIL
|
||||
|
||||
[WebGL test #76: at (0, 0) expected: 0,0,0,255 was 0,192,128,255]
|
||||
expected: FAIL
|
||||
|
||||
[WebGL test #16: at (0, 0) expected: 0,0,0,255 was 192,0,128,255]
|
||||
expected: FAIL
|
||||
|
||||
[WebGL test #28: at (0, 0) expected: 0,0,0,255 was 192,192,192,255]
|
||||
expected: FAIL
|
||||
|
||||
[WebGL test #40: at (0, 0) expected: 0,0,0,255 was 0,0,0,64]
|
||||
expected: FAIL
|
||||
|
||||
[WebGL test #52: at (0, 0) expected: 0,0,0,255 was 192,192,192,64]
|
||||
expected: FAIL
|
||||
|
||||
|
|
|
@ -1,183 +0,0 @@
|
|||
[texture-size-limit.html]
|
||||
type: testharness
|
||||
expected: CRASH
|
||||
[WebGL test #0: Unable to fetch WebGL rendering context for Canvas]
|
||||
expected: FAIL
|
||||
|
||||
[WebGL test #2: getError expected: INVALID_VALUE. Was NO_ERROR : width or height out of bounds for specified level: should generate INVALID_VALUE: level is 14, size is 4x4.]
|
||||
expected: FAIL
|
||||
|
||||
[WebGL test #3: getError expected: NO_ERROR. Was INVALID_OPERATION : there should be no error for level: 14 1x1]
|
||||
expected: FAIL
|
||||
|
||||
[WebGL test #4: getError expected: NO_ERROR. Was INVALID_OPERATION : there should be no error for level: 14 1x1]
|
||||
expected: FAIL
|
||||
|
||||
[WebGL test #5: getError expected: INVALID_VALUE. Was NO_ERROR : should generate INVALID_VALUE for level: 14 2x1]
|
||||
expected: FAIL
|
||||
|
||||
[WebGL test #6: getError expected: INVALID_VALUE. Was NO_ERROR : should generate INVALID_VALUE for level: 14 1x2]
|
||||
expected: FAIL
|
||||
|
||||
[WebGL test #7: getError expected: NO_ERROR. Was INVALID_OPERATION : there should be no error for level: 13 2x1]
|
||||
expected: FAIL
|
||||
|
||||
[WebGL test #8: getError expected: NO_ERROR. Was INVALID_OPERATION : there should be no error for level: 13 1x2]
|
||||
expected: FAIL
|
||||
|
||||
[WebGL test #9: getError expected: INVALID_VALUE. Was NO_ERROR : should generate INVALID_VALUE for level: 13 4x1]
|
||||
expected: FAIL
|
||||
|
||||
[WebGL test #10: getError expected: INVALID_VALUE. Was NO_ERROR : should generate INVALID_VALUE for level: 13 1x4]
|
||||
expected: FAIL
|
||||
|
||||
[WebGL test #11: getError expected: NO_ERROR. Was INVALID_OPERATION : there should be no error for level: 12 4x1]
|
||||
expected: FAIL
|
||||
|
||||
[WebGL test #12: getError expected: NO_ERROR. Was INVALID_OPERATION : there should be no error for level: 12 1x4]
|
||||
expected: FAIL
|
||||
|
||||
[WebGL test #13: getError expected: INVALID_VALUE. Was NO_ERROR : should generate INVALID_VALUE for level: 12 8x1]
|
||||
expected: FAIL
|
||||
|
||||
[WebGL test #14: getError expected: INVALID_VALUE. Was NO_ERROR : should generate INVALID_VALUE for level: 12 1x8]
|
||||
expected: FAIL
|
||||
|
||||
[WebGL test #15: getError expected: NO_ERROR. Was INVALID_OPERATION : there should be no error for level: 11 8x1]
|
||||
expected: FAIL
|
||||
|
||||
[WebGL test #16: getError expected: NO_ERROR. Was INVALID_OPERATION : there should be no error for level: 11 1x8]
|
||||
expected: FAIL
|
||||
|
||||
[WebGL test #17: getError expected: INVALID_VALUE. Was NO_ERROR : should generate INVALID_VALUE for level: 11 16x1]
|
||||
expected: FAIL
|
||||
|
||||
[WebGL test #18: getError expected: INVALID_VALUE. Was NO_ERROR : should generate INVALID_VALUE for level: 11 1x16]
|
||||
expected: FAIL
|
||||
|
||||
[WebGL test #19: getError expected: NO_ERROR. Was INVALID_OPERATION : there should be no error for level: 10 16x1]
|
||||
expected: FAIL
|
||||
|
||||
[WebGL test #20: getError expected: NO_ERROR. Was INVALID_OPERATION : there should be no error for level: 10 1x16]
|
||||
expected: FAIL
|
||||
|
||||
[WebGL test #21: getError expected: INVALID_VALUE. Was NO_ERROR : should generate INVALID_VALUE for level: 10 32x1]
|
||||
expected: FAIL
|
||||
|
||||
[WebGL test #22: getError expected: INVALID_VALUE. Was NO_ERROR : should generate INVALID_VALUE for level: 10 1x32]
|
||||
expected: FAIL
|
||||
|
||||
[WebGL test #23: getError expected: NO_ERROR. Was INVALID_OPERATION : there should be no error for level: 9 32x1]
|
||||
expected: FAIL
|
||||
|
||||
[WebGL test #24: getError expected: NO_ERROR. Was INVALID_OPERATION : there should be no error for level: 9 1x32]
|
||||
expected: FAIL
|
||||
|
||||
[WebGL test #25: getError expected: INVALID_VALUE. Was NO_ERROR : should generate INVALID_VALUE for level: 9 64x1]
|
||||
expected: FAIL
|
||||
|
||||
[WebGL test #26: getError expected: INVALID_VALUE. Was NO_ERROR : should generate INVALID_VALUE for level: 9 1x64]
|
||||
expected: FAIL
|
||||
|
||||
[WebGL test #27: getError expected: NO_ERROR. Was INVALID_OPERATION : there should be no error for level: 8 64x1]
|
||||
expected: FAIL
|
||||
|
||||
[WebGL test #28: getError expected: NO_ERROR. Was INVALID_OPERATION : there should be no error for level: 8 1x64]
|
||||
expected: FAIL
|
||||
|
||||
[WebGL test #29: getError expected: INVALID_VALUE. Was NO_ERROR : should generate INVALID_VALUE for level: 8 128x1]
|
||||
expected: FAIL
|
||||
|
||||
[WebGL test #30: getError expected: INVALID_VALUE. Was NO_ERROR : should generate INVALID_VALUE for level: 8 1x128]
|
||||
expected: FAIL
|
||||
|
||||
[WebGL test #31: getError expected: NO_ERROR. Was INVALID_OPERATION : there should be no error for level: 7 128x1]
|
||||
expected: FAIL
|
||||
|
||||
[WebGL test #32: getError expected: NO_ERROR. Was INVALID_OPERATION : there should be no error for level: 7 1x128]
|
||||
expected: FAIL
|
||||
|
||||
[WebGL test #33: getError expected: INVALID_VALUE. Was NO_ERROR : should generate INVALID_VALUE for level: 7 256x1]
|
||||
expected: FAIL
|
||||
|
||||
[WebGL test #34: getError expected: INVALID_VALUE. Was NO_ERROR : should generate INVALID_VALUE for level: 7 1x256]
|
||||
expected: FAIL
|
||||
|
||||
[WebGL test #35: getError expected: NO_ERROR. Was INVALID_OPERATION : there should be no error for level: 6 256x1]
|
||||
expected: FAIL
|
||||
|
||||
[WebGL test #36: getError expected: NO_ERROR. Was INVALID_OPERATION : there should be no error for level: 6 1x256]
|
||||
expected: FAIL
|
||||
|
||||
[WebGL test #37: getError expected: INVALID_VALUE. Was NO_ERROR : should generate INVALID_VALUE for level: 6 512x1]
|
||||
expected: FAIL
|
||||
|
||||
[WebGL test #38: getError expected: INVALID_VALUE. Was NO_ERROR : should generate INVALID_VALUE for level: 6 1x512]
|
||||
expected: FAIL
|
||||
|
||||
[WebGL test #39: getError expected: NO_ERROR. Was INVALID_OPERATION : there should be no error for level: 5 512x1]
|
||||
expected: FAIL
|
||||
|
||||
[WebGL test #40: getError expected: NO_ERROR. Was INVALID_OPERATION : there should be no error for level: 5 1x512]
|
||||
expected: FAIL
|
||||
|
||||
[WebGL test #41: getError expected: INVALID_VALUE. Was NO_ERROR : should generate INVALID_VALUE for level: 5 1024x1]
|
||||
expected: FAIL
|
||||
|
||||
[WebGL test #42: getError expected: INVALID_VALUE. Was NO_ERROR : should generate INVALID_VALUE for level: 5 1x1024]
|
||||
expected: FAIL
|
||||
|
||||
[WebGL test #43: getError expected: NO_ERROR. Was INVALID_OPERATION : there should be no error for level: 4 1024x1]
|
||||
expected: FAIL
|
||||
|
||||
[WebGL test #44: getError expected: NO_ERROR. Was INVALID_OPERATION : there should be no error for level: 4 1x1024]
|
||||
expected: FAIL
|
||||
|
||||
[WebGL test #45: getError expected: INVALID_VALUE. Was NO_ERROR : should generate INVALID_VALUE for level: 4 2048x1]
|
||||
expected: FAIL
|
||||
|
||||
[WebGL test #46: getError expected: INVALID_VALUE. Was NO_ERROR : should generate INVALID_VALUE for level: 4 1x2048]
|
||||
expected: FAIL
|
||||
|
||||
[WebGL test #47: getError expected: NO_ERROR. Was INVALID_OPERATION : there should be no error for level: 3 2048x1]
|
||||
expected: FAIL
|
||||
|
||||
[WebGL test #48: getError expected: NO_ERROR. Was INVALID_OPERATION : there should be no error for level: 3 1x2048]
|
||||
expected: FAIL
|
||||
|
||||
[WebGL test #49: getError expected: INVALID_VALUE. Was NO_ERROR : should generate INVALID_VALUE for level: 3 4096x1]
|
||||
expected: FAIL
|
||||
|
||||
[WebGL test #50: getError expected: INVALID_VALUE. Was NO_ERROR : should generate INVALID_VALUE for level: 3 1x4096]
|
||||
expected: FAIL
|
||||
|
||||
[WebGL test #51: getError expected: NO_ERROR. Was INVALID_OPERATION : there should be no error for level: 2 4096x1]
|
||||
expected: FAIL
|
||||
|
||||
[WebGL test #52: getError expected: NO_ERROR. Was INVALID_OPERATION : there should be no error for level: 2 1x4096]
|
||||
expected: FAIL
|
||||
|
||||
[WebGL test #53: getError expected: INVALID_VALUE. Was NO_ERROR : should generate INVALID_VALUE for level: 2 8192x1]
|
||||
expected: FAIL
|
||||
|
||||
[WebGL test #54: getError expected: INVALID_VALUE. Was NO_ERROR : should generate INVALID_VALUE for level: 2 1x8192]
|
||||
expected: FAIL
|
||||
|
||||
[WebGL test #55: getError expected: NO_ERROR. Was INVALID_OPERATION : there should be no error for level: 1 8192x1]
|
||||
expected: FAIL
|
||||
|
||||
[WebGL test #56: getError expected: NO_ERROR. Was INVALID_OPERATION : there should be no error for level: 1 1x8192]
|
||||
expected: FAIL
|
||||
|
||||
[WebGL test #57: getError expected: INVALID_VALUE. Was NO_ERROR : should generate INVALID_VALUE for level: 1 16384x1]
|
||||
expected: FAIL
|
||||
|
||||
[WebGL test #58: getError expected: INVALID_VALUE. Was NO_ERROR : should generate INVALID_VALUE for level: 1 1x16384]
|
||||
expected: FAIL
|
||||
|
||||
[WebGL test #59: getError expected: NO_ERROR. Was INVALID_OPERATION : there should be no error for level: 0 16384x1]
|
||||
expected: FAIL
|
||||
|
||||
[WebGL test #60: getError expected: NO_ERROR. Was INVALID_OPERATION : there should be no error for level: 0 1x16384]
|
||||
expected: FAIL
|
||||
|
Loading…
Add table
Add a link
Reference in a new issue