-
-
Notifications
You must be signed in to change notification settings - Fork 10
feat: Cast elements to correct type when creating vectors #1311
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
base: main
Are you sure you want to change the base?
feat: Cast elements to correct type when creating vectors #1311
Conversation
…-correct-type-when-creating-vectors
pkg.pr.new packages
benchmark commit |
@@ -834,13 +850,13 @@ describe('v3i', () => { | |||
describe('v4f', () => { | |||
describe('(v3f, number) constructor', () => { | |||
it('works in JS', () => { | |||
const red = d.vec3f(0.9, 0.2, 0.1); | |||
const red = d.vec3f(0.125, 0.25, 0.375); |
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.
@aleksanderkatan Try the PR build, sometimes release builds are faster than local builds because of the transform that the bundler performs. |
@iwoplaza if this is what you meant, then sadly there is no significant change ![]() |
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.
Well done!! 🚀
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 on the fence about this — I get that the consistency between JS and WGSL is nice, but is it really worth the performance hit (which, as we've established, is kind of important)?
Maybe we could leave this in and figure out a way to provide users with a very fast mass vector constructor |
I think we could modify the schema casts for scalar values, so that Edit: Another benefit is that we'd avoid the floating point error in parsed wgsl. |
I think we should keep the casting logic to stay compliant with WGSL's behavior. I’m actually curious how much of the performance hit comes from the casting itself versus the overhead of the function calls. |
…-correct-type-when-creating-vectors
@reczkok seems like most of the overhead is in Math functions and array writes. When calling schema constructors, but all they do is return the value passed in: When calling schema constructors, and casting all values properly: Edit: the results aren't too consistent. Sometimes I get latest with 3500 ops/s, and once it returned 1500 ops/s |
…-correct-type-when-creating-vectors
The benchmark results are now wildly inconsistent. For one test, I get 30 ops/s five times in a row, then I get 11 ops/s five times in a row... I added the coercion to the vector element assignment (through |
No description provided.