Skip to content

Conversation

iwoplaza
Copy link
Collaborator

No description provided.

@iwoplaza iwoplaza marked this pull request as draft September 17, 2025 15:41
Copy link

github-actions bot commented Sep 17, 2025

pkg.pr.new

packages
Ready to be installed by your favorite package manager ⬇️

https://pkg.pr.new/software-mansion/TypeGPU/typegpu@3786826f32fe78c4def5733136fd53e1cc6a90bd
https://pkg.pr.new/software-mansion/TypeGPU/@typegpu/noise@3786826f32fe78c4def5733136fd53e1cc6a90bd
https://pkg.pr.new/software-mansion/TypeGPU/unplugin-typegpu@3786826f32fe78c4def5733136fd53e1cc6a90bd

benchmark
view benchmark

commit
view commit

@iwoplaza iwoplaza marked this pull request as ready for review September 18, 2025 09:56
Copy link
Contributor

Choose a reason for hiding this comment

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

wgsl.MatchingBoolInstance<T> can also simplify select signature


const cpuLt = <T extends AnyNumericVecInstance>(lhs: T, rhs: T) =>
VectorOps.lt[lhs.kind](lhs, rhs);
function cpuLt(lhs: number, rhs: number): boolean;
Copy link
Contributor

Choose a reason for hiding this comment

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

At some point we decided that if a plain js operator works, then we do not write overloads for std operators so as not to encourage users to complicate their code.
I assume we withdraw that decision to allow for overloaded functions, right? If so, the JSDocs would need updating


const cpuLt = <T extends AnyNumericVecInstance>(lhs: T, rhs: T) =>
VectorOps.lt[lhs.kind](lhs, rhs);
function cpuLt(lhs: number, rhs: number): boolean;
Copy link
Contributor

Choose a reason for hiding this comment

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

I am not convinced about these new overloads. The following now becomes type safe, and it will generate invalid wgsl. It would be fine if we handled mixed comparisons though. Maybe we could make unify cast numbers to vectors by wrapping them?

function cmpLt(a: number | AnyNumericVecInstance, b: number | AnyNumericVecInstance) {
  "kernel";
  return lt(a, b);
}

cmpLt(3, vec2f());

returnType: correspondingBooleanVectorSchema(uargs[0]),
});
},
normalImpl: <T extends AnyNumericVecInstance>(lhs: T, rhs: T) =>
Copy link
Contributor

Choose a reason for hiding this comment

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

This function's interface is now inconsistent with other boolean functions

returnType: correspondingBooleanVectorSchema(uargs[0]),
});
},
normalImpl: <T extends AnyNumericVecInstance>(lhs: T, rhs: T) =>
Copy link
Contributor

Choose a reason for hiding this comment

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

Here as well

@iwoplaza iwoplaza marked this pull request as draft September 26, 2025 11:25
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.

2 participants