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

Initial implementation of WebGLQueries #24178

Merged
merged 1 commit into from Oct 1, 2019

Conversation

mmatyas
Copy link
Contributor

@mmatyas mmatyas commented Sep 11, 2019

This patch adds initial support for WeGLQueries. Most related WebGL functions and objects (1) are implemented; what's still missing is:

  • syncing the result of getQueryParameter with the event loop
  • EXT_disjoint_timer_query_webgl2 support

cc @jdm @zakorgy


  • ./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 ___

This change is Reviewable

@highfive
Copy link

Heads up! This PR modifies the following files:

  • @asajeffrey: components/script/dom/webglrenderingcontext.rs, components/script/dom/webidls/WebGL2RenderingContext.webidl, components/script/dom/webidls/WebGLQuery.webidl, components/script/dom/mod.rs, components/script/dom/bindings/trace.rs and 2 more
  • @jgraham: tests/wpt/webgl/meta/conformance2/query/occlusion-query.html.ini, tests/wpt/webgl/meta/conformance2/query/query.html.ini
  • @KiChjang: components/script/dom/webglrenderingcontext.rs, components/script/dom/webidls/WebGL2RenderingContext.webidl, components/script/dom/webidls/WebGLQuery.webidl, components/script/dom/mod.rs, components/script/dom/bindings/trace.rs and 2 more

@highfive
Copy link

warning Warning warning

  • These commits modify unsafe code. Please review it carefully!

@highfive highfive added the S-awaiting-review There is new code that needs to be reviewed. label Sep 11, 2019
@mmatyas
Copy link
Contributor Author

mmatyas commented Sep 11, 2019

Note: the patch doesn't pass test-tidy at the moment, because in my opinion this:

match target {
    constants::ANY_SAMPLES_PASSED |
    constants::ANY_SAMPLES_PASSED_CONSERVATIVE => {
        &self.occlusion_query
    },
    constants::TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN => {
        &self.primitives_query
    },

is more readable than this:

match target {
    constants::ANY_SAMPLES_PASSED | constants::ANY_SAMPLES_PASSED_CONSERVATIVE => {
        &self.occlusion_query
    },
    constants::TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN => &self.primitives_query,

Of course, I can apply test-tidy's changes in case you disagree.

Also I'm pretty sure many Option check could be simplified with some creative use of and_then and co., I'd be happy to hear your thoughs about them.

Copy link
Member

@jdm jdm left a comment

Choose a reason for hiding this comment

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

The rest of the changes look good!

);
match query.get_parameter(&self.base, pname) {
Ok(value) => match pname {
constants::QUERY_RESULT => UInt32Value(value),
Copy link
Member

Choose a reason for hiding this comment

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

To get the event loop integration right, I recommend this strategy:

  • add Option<u32> and Option<bool> members for storing cached versions of these results
  • if both these fields are None, get the query parameter from the GL thread and store the result in the appropriate field, and return the result
  • if either field is Some, get the query parameter from the GL thread, queue a task that will update the cached values, and return the current cached value

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 see, but what do you mean exactly by queuing a task? The query results should not change until the next time we're in the event loop; do we have a way for scheduling a callback to run at that time? Or you mean connect it somehow to the DOM's global scheduler?

Copy link
Member

Choose a reason for hiding this comment

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

I mean using the task! macro to declare a closure that will run asynchronously on the script thread, and using the task source API to enqueue it to run later. This code is one example of many in the script/ code of queueing a task.

@jdm jdm assigned jdm and unassigned Manishearth Sep 16, 2019
@jdm jdm added S-needs-code-changes Changes have not yet been made that were requested by a reviewer. and removed S-awaiting-review There is new code that needs to be reviewed. labels Sep 16, 2019
@jdm
Copy link
Member

jdm commented Sep 16, 2019

As for the question about tidy, you can add a #[cfg(rustfmt_skip) annotation if you would prefer.

@jdm jdm mentioned this pull request Sep 20, 2019
3 tasks
@highfive highfive added S-awaiting-review There is new code that needs to be reviewed. and removed S-needs-code-changes Changes have not yet been made that were requested by a reviewer. labels Sep 23, 2019
@mmatyas
Copy link
Contributor Author

mmatyas commented Sep 23, 2019

Ok, I've updated the patch with the task queue (thanks!), and I've also added a Drop implementation. The timing tests now pass, but the actual query results might fail (wtu.drawUnitQuad produces a crash on my PC, unrelated to this patch). I wonder if it passes on the CI.

@jdm
Copy link
Member

jdm commented Sep 23, 2019

@bors-servo try=wpt

@bors-servo
Copy link
Contributor

⌛ Trying commit bea2682 with merge d4fb458...

bors-servo pushed a commit that referenced this pull request Sep 23, 2019
Initial implementation of WebGLQueries

This patch adds initial support for WeGLQueries. Most related WebGL functions and objects ([1]) are implemented; what's still missing is:

- syncing the result of `getQueryParameter` with the event loop
- `EXT_disjoint_timer_query_webgl2` support

[1]: https://www.khronos.org/registry/webgl/specs/latest/2.0/#3.7.12

<!-- Please describe your changes on the following line: -->
cc @jdm @zakorgy

---
<!-- 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
- [ ] `./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 ___

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

💔 Test failed - linux-rel-wpt

@highfive highfive added the S-tests-failed The changes caused existing tests to fail. label Sep 23, 2019
imiklos pushed a commit to imiklos/servo that referenced this pull request Sep 23, 2019
The following pull requests depend on it: servo#24250, servo#24178.
@imiklos imiklos mentioned this pull request Sep 23, 2019
3 tasks
@bors-servo
Copy link
Contributor

☔ The latest upstream changes (presumably #24242) made this pull request unmergeable. Please resolve the merge conflicts.

@highfive highfive added the S-needs-rebase There are merge conflict errors. label Sep 24, 2019
bors-servo pushed a commit that referenced this pull request Sep 24, 2019
Update sparkle crate

The following pull requests depend on it: #24250, #24178.

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

---
<!-- 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

<!-- Either: -->
- [X] There are tests for these changes

<!-- 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/24266)
<!-- Reviewable:end -->
bors-servo pushed a commit that referenced this pull request Sep 24, 2019
Update sparkle crate

The following pull requests depend on it: #24250, #24178.

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

---
<!-- 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

<!-- Either: -->
- [X] There are tests for these changes

<!-- 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/24266)
<!-- Reviewable:end -->
@highfive highfive removed the S-tests-failed The changes caused existing tests to fail. label Sep 25, 2019
@mmatyas
Copy link
Contributor Author

mmatyas commented Sep 25, 2019

Rebased to master. I've also improved the Drop impl making it support the fallible case. In the commit message I've removed the note about the missing event loop sync implementation, as it now works too.

//

[Exposed=Window]
interface WebGLQuery : WebGLObject {
Copy link
Member

Choose a reason for hiding this comment

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

This needs to be hidden behind the webgl2 preference:

@jdm
Copy link
Member

jdm commented Sep 30, 2019

Here's the reason for those failures - the test harness automatically adds a #N prefix to each test message in this code. Since it only calls testFailed if a method is missing, it now executes testFailed fewer times than previously since there are new methods present in the interface, to the test messages contain different #N prefixes than before. You should delete tests/wpt/webgl/meta/conformance2/context/methods-2.html.ini and regenerate it in order to update the expected error messages.

@jdm jdm added S-needs-code-changes Changes have not yet been made that were requested by a reviewer. and removed S-awaiting-review There is new code that needs to be reviewed. S-needs-rebase There are merge conflict errors. labels Sep 30, 2019
@jdm
Copy link
Member

jdm commented Sep 30, 2019

Also some other interface test expectations needs updating:

{
    "status": "PASS", 
    "group": "default", 
    "message": null, 
    "stack": null, 
    "subtest": "WebGLQuery interface: existence and properties of interface object", 
    "test": "/webgl/idlharness.any.html", 
    "line": 332663, 
    "action": "test_result", 
    "expected": "FAIL"
}
{
    "status": "PASS", 
    "group": "default", 
    "message": null, 
    "stack": null, 
    "subtest": "WebGLQuery interface object length", 
    "test": "/webgl/idlharness.any.html", 
    "line": 332664, 
    "action": "test_result", 
    "expected": "FAIL"
}
{
    "status": "PASS", 
    "group": "default", 
    "message": null, 
    "stack": null, 
    "subtest": "WebGLQuery interface object name", 
    "test": "/webgl/idlharness.any.html", 
    "line": 332665, 
    "action": "test_result", 
    "expected": "FAIL"
}
{
    "status": "PASS", 
    "group": "default", 
    "message": null, 
    "stack": null, 
    "subtest": "WebGLQuery interface: existence and properties of interface prototype object", 
    "test": "/webgl/idlharness.any.html", 
    "line": 332666, 
    "action": "test_result", 
    "expected": "FAIL"
}
{
    "status": "PASS", 
    "group": "default", 
    "message": null, 
    "stack": null, 
    "subtest": "WebGLQuery interface: existence and properties of interface prototype object's \"constructor\" property", 
    "test": "/webgl/idlharness.any.html", 
    "line": 332667, 
    "action": "test_result", 
    "expected": "FAIL"
}
{
    "status": "PASS", 
    "group": "default", 
    "message": null, 
    "stack": null, 
    "subtest": "WebGLQuery interface: existence and properties of interface prototype object's @@unscopables property", 
    "test": "/webgl/idlharness.any.html", 
    "line": 332668, 
    "action": "test_result", 
    "expected": "FAIL"
}

This patch adds initial support for WeGLQueries. Most related WebGL
functions and objects are implemented [1]. What's still missing is
the `EXT_disjoint_timer_query_webgl2` support.

[1]: https://www.khronos.org/registry/webgl/specs/latest/2.0/#3.7.12
@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. S-needs-code-changes Changes have not yet been made that were requested by a reviewer. labels Oct 1, 2019
@mmatyas
Copy link
Contributor Author

mmatyas commented Oct 1, 2019

Thanks, updated with the methods-2 and Pref changes. However, I couldn't reproduce the idlharness fails, even after regenerating its ini, hm.

@jdm
Copy link
Member

jdm commented Oct 1, 2019

@bors-servo r+

@bors-servo
Copy link
Contributor

📌 Commit f2e2b3d has been approved by jdm

@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 1, 2019
@bors-servo
Copy link
Contributor

⌛ Testing commit f2e2b3d with merge cfcff8e...

bors-servo pushed a commit that referenced this pull request Oct 1, 2019
Initial implementation of WebGLQueries

This patch adds initial support for WeGLQueries. Most related WebGL functions and objects ([1]) are implemented; what's still missing is:

- syncing the result of `getQueryParameter` with the event loop
- `EXT_disjoint_timer_query_webgl2` support

[1]: https://www.khronos.org/registry/webgl/specs/latest/2.0/#3.7.12

<!-- Please describe your changes on the following line: -->
cc @jdm @zakorgy

---
<!-- 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
- [ ] `./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 ___

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

💔 Test failed - status-taskcluster

@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 1, 2019
@jdm
Copy link
Member

jdm commented Oct 1, 2019

@bors-servo retry

@bors-servo
Copy link
Contributor

⌛ Testing commit f2e2b3d with merge d3475e5...

bors-servo pushed a commit that referenced this pull request Oct 1, 2019
Initial implementation of WebGLQueries

This patch adds initial support for WeGLQueries. Most related WebGL functions and objects ([1]) are implemented; what's still missing is:

- syncing the result of `getQueryParameter` with the event loop
- `EXT_disjoint_timer_query_webgl2` support

[1]: https://www.khronos.org/registry/webgl/specs/latest/2.0/#3.7.12

<!-- Please describe your changes on the following line: -->
cc @jdm @zakorgy

---
<!-- 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
- [ ] `./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 ___

<!-- 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/24178)
<!-- Reviewable:end -->
@highfive highfive added S-awaiting-merge The PR is in the process of compiling and running tests on the automated CI. and removed S-tests-failed The changes caused existing tests to fail. labels Oct 1, 2019
@bors-servo
Copy link
Contributor

☀️ Test successful - linux-rel-css, linux-rel-wpt, status-taskcluster
Approved by: jdm
Pushing d3475e5 to master...

@bors-servo bors-servo merged commit f2e2b3d into servo:master Oct 1, 2019
@highfive highfive removed the S-awaiting-merge The PR is in the process of compiling and running tests on the automated CI. label Oct 1, 2019
@bors-servo bors-servo mentioned this pull request Oct 1, 2019
5 tasks
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