-
-
Notifications
You must be signed in to change notification settings - Fork 3k
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
Replace object
function arguments in WebGL with typed arrays
#20396
Conversation
Heads up! This PR modifies the following files:
|
@bors-servo try |
Replace `object` function arguments in WebGL with typed arrays <!-- Please describe your changes on the following line: --> Could use a servo/rust-mozjs#402 in some places, as this should simplify a little bit and remove unnecessary `#[allow(unsafe_code)]` attributes. I sort of hacked my way through for #20394 since I encountered this issue as well. I agree that the comment above makes me feel uneasy about this and feels like I'm missing something and this shouldn't be the way we eventually resolve the overloads with auto rootable types. r? @jdm --- <!-- 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 - [X] These changes fix #20342 (github issue number if applicable). <!-- Either: --> - [ ] There are tests for these changes OR - [X] These changes do not require tests because if the bindings compile now, it works! <!-- 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/20396) <!-- Reviewable:end -->
💔 Test failed - linux-rel-css |
|
Right, I wanted to be so smart about the deduplication in function overloads, so I actually didn't move sanity check to the proper function in vertex attribs. Oops! Hopefully this should work now, this passes webgl test suite for me locally. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm really excited to see these changes! The typed array binding support is a big improvement :)
@@ -825,15 +825,13 @@ impl WebGLRenderingContext { | |||
} | |||
|
|||
// TODO(emilio): Move this logic to a validator. | |||
#[allow(unsafe_code)] | |||
unsafe fn validate_tex_image_2d_data(&self, | |||
fn validate_tex_image_2d_data(&self, | |||
width: u32, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: indentation
"arg%d" % distinguishingIndex) | ||
argName) | ||
if type_needs_auto_root(type): | ||
testCode.append(CGGeneric("auto_root!(in(cx) let %s = %s);" % (argName, argName))) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What if we move this into instantiateJSToNativeConversionTemplate
instead? Can we also add codegen tests for:
- two overloads - ArrayBuffer and DOMString
- three overloads - a union containing ArrayBuffer and DOMString
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Specifically, if we add a field to JSToNativeConversionInfo and make getJSToNativeConversionInfo set it appropriately, instantiateJSToNativeConversionTemplate could add the extra auto_root! declaration.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, now that I read your reply, it seems I misread it. Do you think 01c6bee is sufficient for now or should I change it further?
Re overloads:
Currently unions at distinguishable indices are not supported by CodegenRust (see WebGLRenderingContext.webidl:493), so this still blocks us on removing last object?
workaround function here.
I can definitely add codegen tests for overloads with auto rootable types here though (e.g. overloads on ArrayBuffer and DOMString)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm a bit worried that we'll keep hitting similar issues with missing CustomAutoRoot wrappers if we keep doing spot-fixes that only change a single call-site at a time.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, I agree completely.
However in this particular case I'm not sure what might be the best approach.
In general getJSToNativeConversionInfo
returns template, declType and default, which is then later passed manually to instantiateJSToNativeConversionTemplate
.
In the updated 01c6bee, for the instantiateJSToNativeConversionTemplate
call I'm passing the information if the intantiated template needs the rooting (which is later done inside the call).
If I'm not mistaken, do you mean that we should return an additional field (e.g. needsAutoRooting
) from getJSToNativeConversionInfo
and pass it later manually for every following instantiateJSToNativeConversionTemplate
call if needed, as well?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Bleah. We should really refactor the code generation to pass the JSToNativeConversionInfo class directly to instantiateJSToNativeConversionTemplate so it's easier to make changes like this. I'll file a separate issue to do that and clean up the changes from this PR.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Filed #20403.
2584199
to
80c6891
Compare
Rebased and force-pushed to take advantage of servo/rust-mozjs#402 (less |
@bors-servo r+ |
📌 Commit 80c6891 has been approved by |
Replace `object` function arguments in WebGL with typed arrays <!-- Please describe your changes on the following line: --> Could use a servo/rust-mozjs#402 in some places, as this should simplify a little bit and remove unnecessary `#[allow(unsafe_code)]` attributes. I sort of hacked my way through for #20394 since I encountered this issue as well. I agree that the comment above makes me feel uneasy about this and feels like I'm missing something and this shouldn't be the way we eventually resolve the overloads with auto rootable types (talking about this: https://github.com/servo/servo/pull/20396/files#diff-60d01595cff328c165842fea9e4ccbc2R428). r? @jdm --- <!-- 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 - [X] These changes fix #20342 (github issue number if applicable). <!-- Either: --> - [ ] There are tests for these changes OR - [X] These changes do not require tests because if the bindings compile now, it works! <!-- 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/20396) <!-- Reviewable:end -->
☀️ 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 |
Could use a servo/rust-mozjs#402 in some places, as this should simplify a little bit and remove unnecessary
#[allow(unsafe_code)]
attributes.I sort of hacked my way through for #20394 since I encountered this issue as well. I agree that the comment above makes me feel uneasy about this and feels like I'm missing something and this shouldn't be the way we eventually resolve the overloads with auto rootable types (talking about this: https://github.com/servo/servo/pull/20396/files#diff-60d01595cff328c165842fea9e4ccbc2R428).
r? @jdm
./mach build -d
does not report any errors./mach test-tidy
does not report any errorsobject
argument with typed arrays instead #20342 (github issue number if applicable).This change is