Join GitHub today
GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together.
Sign upReplace `object` function arguments in WebGL with typed arrays #20396
Conversation
highfive
commented
Mar 23, 2018
|
Heads up! This PR modifies the following files:
|
highfive
commented
Mar 23, 2018
|
@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 -->
|
|
|
|
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. |
|
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, | |||
This comment has been minimized.
This comment has been minimized.
| "arg%d" % distinguishingIndex) | ||
| argName) | ||
| if type_needs_auto_root(type): | ||
| testCode.append(CGGeneric("auto_root!(in(cx) let %s = %s);" % (argName, argName))) |
This comment has been minimized.
This comment has been minimized.
jdm
Mar 23, 2018
Member
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
This comment has been minimized.
This comment has been minimized.
jdm
Mar 23, 2018
Member
Specifically, if we add a field to JSToNativeConversionInfo and make getJSToNativeConversionInfo set it appropriately, instantiateJSToNativeConversionTemplate could add the extra auto_root! declaration.
This comment has been minimized.
This comment has been minimized.
Xanewok
Mar 23, 2018
•
Author
Contributor
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)
This comment has been minimized.
This comment has been minimized.
jdm
Mar 23, 2018
Member
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.
This comment has been minimized.
This comment has been minimized.
Xanewok
Mar 23, 2018
Author
Contributor
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?
This comment has been minimized.
This comment has been minimized.
jdm
Mar 23, 2018
Member
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.
This comment has been minimized.
This comment has been minimized.
|
Rebased and force-pushed to take advantage of servo/rust-mozjs#402 (less |
|
@bors-servo r+ |
|
|
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 -->
|
|
Xanewok commentedMar 23, 2018
•
edited
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 -ddoes not report any errors./mach test-tidydoes not report any errorsThis change is