Skip to content

Commit

Permalink
Add support for WebGL2 RASTERIZER_DISCARD enum.
Browse files Browse the repository at this point in the history
Add support for the `RASTERIZER_DISCARD` enum for the WebGL2 version
of the `Enable`, `Disable` and `IsEnabled` functions.

See https://www.khronos.org/registry/webgl/specs/latest/2.0/#3.7.2
  • Loading branch information
mmatyas committed Jan 14, 2020
1 parent 3eec5f6 commit 500b36b
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 40 deletions.
25 changes: 21 additions & 4 deletions components/script/dom/webgl2renderingcontext.rs
Expand Up @@ -71,6 +71,7 @@ pub struct WebGL2RenderingContext {
texture_pack_row_length: Cell<usize>, texture_pack_row_length: Cell<usize>,
texture_pack_skip_pixels: Cell<usize>, texture_pack_skip_pixels: Cell<usize>,
texture_pack_skip_rows: Cell<usize>, texture_pack_skip_rows: Cell<usize>,
enable_rasterizer_discard: Cell<bool>,
} }


fn typedarray_elem_size(typeid: Type) -> usize { fn typedarray_elem_size(typeid: Type) -> usize {
Expand Down Expand Up @@ -124,6 +125,7 @@ impl WebGL2RenderingContext {
texture_pack_row_length: Cell::new(0), texture_pack_row_length: Cell::new(0),
texture_pack_skip_pixels: Cell::new(0), texture_pack_skip_pixels: Cell::new(0),
texture_pack_skip_rows: Cell::new(0), texture_pack_skip_rows: Cell::new(0),
enable_rasterizer_discard: Cell::new(false),
}) })
} }


Expand Down Expand Up @@ -991,12 +993,24 @@ impl WebGL2RenderingContextMethods for WebGL2RenderingContext {


/// https://www.khronos.org/registry/webgl/specs/latest/1.0/#5.14.3 /// https://www.khronos.org/registry/webgl/specs/latest/1.0/#5.14.3
fn Enable(&self, cap: u32) { fn Enable(&self, cap: u32) {
self.base.Enable(cap) match cap {
constants::RASTERIZER_DISCARD => {
self.enable_rasterizer_discard.set(true);
self.base.send_command(WebGLCommand::Enable(cap));
},
_ => self.base.Enable(cap),
}
} }


/// https://www.khronos.org/registry/webgl/specs/latest/1.0/#5.14.3 /// https://www.khronos.org/registry/webgl/specs/latest/1.0/#5.14.3
fn Disable(&self, cap: u32) { fn Disable(&self, cap: u32) {
self.base.Disable(cap) match cap {
constants::RASTERIZER_DISCARD => {
self.enable_rasterizer_discard.set(false);
self.base.send_command(WebGLCommand::Disable(cap));
},
_ => self.base.Disable(cap),
}
} }


/// https://www.khronos.org/registry/webgl/specs/latest/1.0/#5.14.9 /// https://www.khronos.org/registry/webgl/specs/latest/1.0/#5.14.9
Expand Down Expand Up @@ -1200,9 +1214,12 @@ impl WebGL2RenderingContextMethods for WebGL2RenderingContext {
} }


// TODO: We could write this without IPC, recording the calls to `enable` and `disable`. // TODO: We could write this without IPC, recording the calls to `enable` and `disable`.
/// https://www.khronos.org/registry/webgl/specs/latest/1.0/#5.14.3 /// https://www.khronos.org/registry/webgl/specs/latest/2.0/#3.7.2
fn IsEnabled(&self, cap: u32) -> bool { fn IsEnabled(&self, cap: u32) -> bool {
self.base.IsEnabled(cap) match cap {
constants::RASTERIZER_DISCARD => self.enable_rasterizer_discard.get(),
_ => self.base.IsEnabled(cap),
}
} }


/// https://www.khronos.org/registry/webgl/specs/latest/1.0/#5.14.6 /// https://www.khronos.org/registry/webgl/specs/latest/1.0/#5.14.6
Expand Down

This file was deleted.

@@ -1,13 +1,4 @@
[transform_feedback.html] [transform_feedback.html]
[WebGL test #2: getError expected: NO_ERROR. Was INVALID_ENUM : TRANSFORM_FEEDBACK_BINDING query should succeed]
expected: FAIL

[WebGL test #35: getError expected: NO_ERROR. Was INVALID_ENUM : linking transform feedback shader should not set an error]
expected: FAIL

[WebGL test #29: getError expected: NO_ERROR. Was INVALID_ENUM : linking transform feedback shader should not set an error]
expected: FAIL

[WebGL test #31: buffer should match expected values] [WebGL test #31: buffer should match expected values]
expected: FAIL expected: FAIL


Expand All @@ -26,9 +17,12 @@
[WebGL test #28: buffer should match expected values] [WebGL test #28: buffer should match expected values]
expected: FAIL expected: FAIL


[WebGL test #24: getError expected: INVALID_OPERATION. Was INVALID_ENUM : after evaluating: gl.getBufferSubData(gl.TRANSFORM_FEEDBACK_BUFFER, 0, retArray, 0, retArray.length)] [WebGL test #35: getError expected: NO_ERROR. Was INVALID_OPERATION : linking transform feedback shader should not set an error]
expected: FAIL expected: FAIL


[WebGL test #34: TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN query returned an incorrect result 0 (expected 3)] [WebGL test #34: TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN query returned an incorrect result 0 (expected 3)]
expected: FAIL expected: FAIL


[WebGL test #29: getError expected: NO_ERROR. Was INVALID_OPERATION : linking transform feedback shader should not set an error]
expected: FAIL

@@ -1,19 +1,7 @@
[unwritten-output-defaults-to-zero.html] [unwritten-output-defaults-to-zero.html]
[WebGL test #1: Fail to set up the program]
expected: FAIL

[WebGL test #2: Fail to set up the program]
expected: FAIL

[WebGL test #1: successfullyParsed should be true (of type boolean). Was undefined (of type undefined).]
expected: FAIL

[WebGL test #2: successfullyParsed should be true (of type boolean). Was undefined (of type undefined).]
expected: FAIL

[WebGL test #2: buffer should match expected values] [WebGL test #2: buffer should match expected values]
expected: FAIL expected: FAIL


[WebGL test #3: getError expected: NO_ERROR. Was INVALID_ENUM : Set up program should succeed] [WebGL test #3: getError expected: NO_ERROR. Was INVALID_OPERATION : Set up program should succeed]
expected: FAIL expected: FAIL


0 comments on commit 500b36b

Please sign in to comment.