Skip to content

Initial implementation of WebGLQueries - #24178

Merged
bors-servo merged 1 commit into
servo:masterfrom
mmatyas:webgl_fns_query
Oct 1, 2019
Merged

bors-servo merged 1 commit into
servo:masterfrom
mmatyas:webgl_fns_query

Conversation

@mmatyas

@mmatyas mmatyas commented Sep 11, 2019 •

Copy link
Copy Markdown
Contributor

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
Copy Markdown

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
Copy Markdown

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

mmatyas commented Sep 11, 2019

Copy link
Copy Markdown
Contributor Author

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.

@jdm jdm left a comment

Copy link
Copy Markdown
Member

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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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

jdm commented Sep 16, 2019

Copy link
Copy Markdown
Member

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 done
@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

mmatyas commented Sep 23, 2019

Copy link
Copy Markdown
Contributor Author

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

jdm commented Sep 23, 2019

Copy link
Copy Markdown
Member

@bors-servo try=wpt

@bors-servo

Copy link
Copy Markdown
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
Copy Markdown
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 done
@bors-servo

Copy link
Copy Markdown
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

mmatyas commented Sep 25, 2019

Copy link
Copy Markdown
Contributor Author

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
Copy Markdown
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

jdm commented Sep 30, 2019

Copy link
Copy Markdown
Member

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

jdm commented Sep 30, 2019

Copy link
Copy Markdown
Member

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

mmatyas commented Oct 1, 2019

Copy link
Copy Markdown
Contributor Author

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

@jdm

jdm commented Oct 1, 2019

Copy link
Copy Markdown
Member

@bors-servo r+

@bors-servo

Copy link
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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

jdm commented Oct 1, 2019

Copy link
Copy Markdown
Member

@bors-servo retry

@bors-servo

Copy link
Copy Markdown
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
Copy Markdown
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
3 of 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.

5 participants