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

feat(ext/geometry): Geometry Interfaces Module Level 1 #27527

Draft
wants to merge 9 commits into
base: main
Choose a base branch
from

Conversation

petamoriken
Copy link
Contributor

@petamoriken petamoriken commented Jan 2, 2025

@petamoriken
Copy link
Contributor Author

I'll work on using denoland/deno_core#1003 to reduce the JavaScript code.

@petamoriken petamoriken marked this pull request as draft January 2, 2025 13:45
// SAFETY: in-range access
unsafe {
*self.inner.borrow_mut().get_unchecked_mut(INDEX_M11) = value;
}
Copy link

@saturday06 saturday06 Jan 2, 2025

Choose a reason for hiding this comment

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

I would suggest a normal array assignment.

pub fn m11(&self, value: f64) {
  self.inner.borrow_mut().data.0[0][0] = value;
}

Since the array index is constant, and since Matrix4 internals are fixed-width arrays and the compiler knows the length of the array, the boundary checks disappear in the compiler's optimization. The execution efficiency will be exactly the same as get_unchecked_mut.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks for your suggestion! I will simply do the following to remove unsafe:

self.inner.borrow_mut().m11 = 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.

Unfortunately, the order of subscripts differs between nalgebra and DOMMatrix, so it would be easier to understand the code using unsafe as it is.

@petamoriken
Copy link
Contributor Author

After I finish the implementation around Web IDL conversion, I will check if I can migrate from nalgebra to wgpu crate. I have concerns about the possibility of synchronously retrieving ArrayBuffer and implementing Web IDL Serializable when using GPUs.

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.

Feature Request: Geometry Interfaces Module Level 1
2 participants