Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Kick off WebGL 2.0 implementation #19028

Merged
merged 1 commit into from Oct 27, 2017
Merged

Conversation

MortimerGoro
Copy link
Contributor

@MortimerGoro MortimerGoro commented Oct 26, 2017

This PR kicks off the WebGL 2.0 implementation:

  • Include WebGL2RenderingContext.webidl and comment unimplemented methods
  • Create WebGL2 struct hierarchy with WebGL 1.0 backwards compatibility
  • Add WebGL 2.0 entry points to canvas
  • Select the correct GL Version on GLContext backends (related PR Add support for selecting OpenGL/ES versions surfman#108)
  • Add WebGL version selection in shader compilations
  • Create a WebGL 2.0 preference

I tried a complex three.js demo using canvas.getContext("webgl2") and the backwards compatibility worked great.

Next steps:

  • I'll add WebGLVersion selection/filtering to WebGLExtensions and move some extensions to core in WebGL 2.0 (e.g. VAOs)
  • I'll add the WebGL 2.0 conformance WPT
  • I'll create a mega-issue with a the list of all TODO methods for a complete WebGL 2.0 implementation (as @emilio did with WebGL 1.0), so we can start start getting community involvement.

  • ./mach build -d does not report any errors
  • ./mach test-tidy does not report any errors
  • These changes fix #__ (github issue number if applicable).
  • There are tests for these changes OR
  • These changes do not require tests because I will add the entire webgl 2.0 WPT in a different PR

This change is Reviewable

@highfive
Copy link

Heads up! This PR modifies the following files:

  • @KiChjang: components/script/dom/bindings/codegen/CodegenRust.py, components/script/dom/webglrenderingcontext.rs, components/script/dom/webgl2renderingcontext.rs, components/script/dom/webidls/WebGL2RenderingContext.webidl, components/script/dom/webglshader.rs and 4 more
  • @fitzgen: components/script/dom/bindings/codegen/CodegenRust.py, components/script/dom/webglrenderingcontext.rs, components/script/dom/webgl2renderingcontext.rs, components/script/dom/webidls/WebGL2RenderingContext.webidl, components/script/dom/webglshader.rs and 4 more
  • @emilio: components/canvas/webgl_thread.rs, components/script/dom/webglrenderingcontext.rs, components/script/dom/webgl2renderingcontext.rs, components/script/dom/webglshader.rs

@highfive
Copy link

warning Warning warning

  • These commits modify unsafe code. Please review it carefully!
  • These commits modify script code, but no tests are modified. Please consider adding a test!

@highfive highfive added the S-awaiting-review There is new code that needs to be reviewed. label Oct 26, 2017
Copy link
Member

@emilio emilio left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Huh, it was way simpler to review than what I expected!

r=me, with the nits


#[allow(unsafe_code)]
fn get_gl_attributes(cx: *mut JSContext, attrs: Option<HandleValue>) -> Option<GLContextAttributes> {
if let Some(webgl_attributes) = attrs {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: This can read nicer like:

let webgl_attributes = match attrs {
    Some(attrs) => attrs,
    None => return Some(GlContextAttributes::default()),
};

// ...

}

impl WebGL2RenderingContext {
fn new_inherited(window: &Window,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: For new code, I think it's preferable to use block indentation for arguments and such, like:

fn new_inherited(
    window: &Window,
    canvas: &HTMLCanvasElement,
    size: Size2D<i32>,
    attrs: GLContextAttributes,
) -> Option<Self> {

This applies to other parts of the patch, feel free to reformat the signatures you're touching too if you want.

}

impl WebGL2RenderingContextMethods for WebGL2RenderingContext {
// https://www.khronos.org/registry/webgl/specs/latest/1.0/#5.14.1
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: I'd use doc comments (/// instead of //), but no big deal.

#[allow(unsafe_code)]
// https://www.khronos.org/registry/webgl/specs/latest/1.0/#5.14.5
unsafe fn BufferData(&self, cx: *mut JSContext, target: u32, data: *mut JSObject, usage: u32) -> Fallible<()> {
self.base.BufferData(cx, target, data, usage)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ugh, it'd be nice to forward all these a bit more easily :(.

Can you file an issue to maybe generate macros from CodegenBinding.py or something like that? Not sure if it's common enough to be worth it, but...

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I didn't find this pattern in another API. WebGL 2.0 WebIDL implements both interfaces instead of using inheritance.

At least I generated all this stuff with a local script ;) I'll open that issue to see if it's worth for more APIs

@emilio
Copy link
Member

emilio commented Oct 26, 2017

@bors-servo delegate+

@bors-servo
Copy link
Contributor

✌️ @MortimerGoro can now approve this pull request

@MortimerGoro
Copy link
Contributor Author

@bors-servo r=emilio

@bors-servo
Copy link
Contributor

📌 Commit 379a6a0 has been approved by emilio

@highfive highfive assigned emilio and unassigned metajack Oct 26, 2017
@highfive highfive added S-awaiting-merge The PR is in the process of compiling and running tests on the automated CI. and removed S-awaiting-review There is new code that needs to be reviewed. labels Oct 26, 2017
@bors-servo
Copy link
Contributor

⌛ Testing commit 379a6a0 with merge cef0baf...

bors-servo pushed a commit that referenced this pull request Oct 26, 2017
Kick off WebGL 2.0 implementation

<!-- Please describe your changes on the following line: -->

This PR kicks off the WebGL 2.0 implementation:

- Include WebGL2RenderingContext.webidl and comment unimplemented methods
- Create WebGL2 struct hierarchy with WebGL 1.0 backwards compatibility
- Add WebGL 2.0 entry points to canvas
- Select the correct GL Version on GLContext backends (related PR servo/surfman#108)
- Add WebGL version selection in shader compilations
- Create a WebGL 2.0 preference

I tried a complex three.js demo using canvas.getContext("webgl2") and the backwards compatibility worked great.

Next steps:

- I'll add WebGLVersion selection/filtering to WebGLExtensions and move some extensions to core in WebGL 2.0 (e.g. VAOs)
- I'll add the WebGL 2.0 conformance WPT
- I'll create a mega-issue with a the list of all TODO methods for a complete WebGL 2.0 implementation (as @emilio did with WebGL 1.0), so we can start start getting community involvement.

---
<!-- 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: -->
- [ ] There are tests for these changes OR
- [x] These changes do not require tests because I will add the entire webgl 2.0 WPT in a different PR

<!-- Also, please make sure that "Allow edits from maintainers" checkbox is checked, so that we can help you if you get stuck somewhere along the way.-->

<!-- 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/19028)
<!-- Reviewable:end -->
@bors-servo
Copy link
Contributor

💔 Test failed - mac-rel-wpt3

@highfive highfive added S-tests-failed The changes caused existing tests to fail. and removed S-awaiting-merge The PR is in the process of compiling and running tests on the automated CI. labels Oct 26, 2017
@highfive highfive added S-awaiting-review There is new code that needs to be reviewed. and removed S-tests-failed The changes caused existing tests to fail. labels Oct 27, 2017
@MortimerGoro
Copy link
Contributor Author

MortimerGoro commented Oct 27, 2017

Test failures fixed: It was just due to a invalid CanvasContext::WebGL2 enum set in HTMLCanvasElementContext when creating a WebGL1 context.

@bors-servo r=emilio

@bors-servo
Copy link
Contributor

📌 Commit ddd6c86 has been approved by emilio

@highfive highfive added S-awaiting-merge The PR is in the process of compiling and running tests on the automated CI. and removed S-awaiting-review There is new code that needs to be reviewed. labels Oct 27, 2017
@bors-servo
Copy link
Contributor

⌛ Testing commit ddd6c86 with merge c007194...

bors-servo pushed a commit that referenced this pull request Oct 27, 2017
Kick off WebGL 2.0 implementation

<!-- Please describe your changes on the following line: -->

This PR kicks off the WebGL 2.0 implementation:

- Include WebGL2RenderingContext.webidl and comment unimplemented methods
- Create WebGL2 struct hierarchy with WebGL 1.0 backwards compatibility
- Add WebGL 2.0 entry points to canvas
- Select the correct GL Version on GLContext backends (related PR servo/surfman#108)
- Add WebGL version selection in shader compilations
- Create a WebGL 2.0 preference

I tried a complex three.js demo using canvas.getContext("webgl2") and the backwards compatibility worked great.

Next steps:

- I'll add WebGLVersion selection/filtering to WebGLExtensions and move some extensions to core in WebGL 2.0 (e.g. VAOs)
- I'll add the WebGL 2.0 conformance WPT
- I'll create a mega-issue with a the list of all TODO methods for a complete WebGL 2.0 implementation (as @emilio did with WebGL 1.0), so we can start start getting community involvement.

---
<!-- 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: -->
- [ ] There are tests for these changes OR
- [x] These changes do not require tests because I will add the entire webgl 2.0 WPT in a different PR

<!-- Also, please make sure that "Allow edits from maintainers" checkbox is checked, so that we can help you if you get stuck somewhere along the way.-->

<!-- 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/19028)
<!-- Reviewable:end -->
@bors-servo
Copy link
Contributor

💡 This pull request was already approved, no need to approve it again.

  • This pull request is currently being tested. If there's no response from the continuous integration service, you may use retry to trigger a build again.

@bors-servo
Copy link
Contributor

📌 Commit ddd6c86 has been approved by emilio

@bors-servo
Copy link
Contributor

⌛ Testing commit ddd6c86 with merge d21657a...

bors-servo pushed a commit that referenced this pull request Oct 27, 2017
Kick off WebGL 2.0 implementation

<!-- Please describe your changes on the following line: -->

This PR kicks off the WebGL 2.0 implementation:

- Include WebGL2RenderingContext.webidl and comment unimplemented methods
- Create WebGL2 struct hierarchy with WebGL 1.0 backwards compatibility
- Add WebGL 2.0 entry points to canvas
- Select the correct GL Version on GLContext backends (related PR servo/surfman#108)
- Add WebGL version selection in shader compilations
- Create a WebGL 2.0 preference

I tried a complex three.js demo using canvas.getContext("webgl2") and the backwards compatibility worked great.

Next steps:

- I'll add WebGLVersion selection/filtering to WebGLExtensions and move some extensions to core in WebGL 2.0 (e.g. VAOs)
- I'll add the WebGL 2.0 conformance WPT
- I'll create a mega-issue with a the list of all TODO methods for a complete WebGL 2.0 implementation (as @emilio did with WebGL 1.0), so we can start start getting community involvement.

---
<!-- 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: -->
- [ ] There are tests for these changes OR
- [x] These changes do not require tests because I will add the entire webgl 2.0 WPT in a different PR

<!-- Also, please make sure that "Allow edits from maintainers" checkbox is checked, so that we can help you if you get stuck somewhere along the way.-->

<!-- 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/19028)
<!-- Reviewable:end -->
@bors-servo
Copy link
Contributor

☀️ Test successful - android, arm32, arm64, linux-dev, linux-rel-css, linux-rel-wpt, mac-dev-unit, mac-rel-css1, mac-rel-css2, mac-rel-wpt1, mac-rel-wpt2, mac-rel-wpt3, mac-rel-wpt4, windows-msvc-dev
Approved by: emilio
Pushing d21657a to master...

@bors-servo bors-servo merged commit ddd6c86 into servo:master Oct 27, 2017
@highfive highfive removed the S-awaiting-merge The PR is in the process of compiling and running tests on the automated CI. label Oct 27, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants