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

[shader-ast] Unsigned integer vector arithmetic #435

Closed
sylee957 opened this issue Dec 29, 2023 · 1 comment
Closed

[shader-ast] Unsigned integer vector arithmetic #435

sylee957 opened this issue Dec 29, 2023 · 1 comment

Comments

@sylee957
Copy link

import { sym } from "@thi.ng/shader-ast/ast/sym";
import { add, mul } from "@thi.ng/shader-ast/ast/ops";
import { uint } from "@thi.ng/shader-ast/ast/lit";

const x = sym("uvec4");
add(x, uint(1234));

doesn't work because there is no type definition for arithmetic between uvec and uint.
I'm trying the workaround at the moment now,
but I'd like to see operators are 100% covered

declare module "@thi.ng/shader-ast/ast/ops" {
  function add<T extends UVec>(l: UintTerm | number, r: Term<T>): Op2<T>;
  function add<T extends UVec>(l: Term<T>, r: UintTerm | number): Op2<T>;
  function sub<T extends UVec>(l: UintTerm | number, r: Term<T>): Op2<T>;
  function sub<T extends UVec>(l: Term<T>, r: UintTerm | number): Op2<T>;
  function mul<T extends UVec>(l: UintTerm | number, r: Term<T>): Op2<T>;
  function mul<T extends UVec>(l: Term<T>, r: UintTerm | number): Op2<T>;
  function div<T extends UVec>(l: UintTerm | number, r: Term<T>): Op2<T>;
  function div<T extends UVec>(l: Term<T>, r: UintTerm | number): Op2<T>;
}
@sylee957 sylee957 changed the title [shader-ast] Unsigned integer vector arithmetic doesn't have type definition [shader-ast] Unsigned integer vector arithmetic Dec 29, 2023
postspectacular added a commit that referenced this issue Dec 29, 2023
- update function signatures for basic math ops: add, sub, mul, div
@postspectacular
Copy link
Member

Sorry referenced the wrong issue number in these 2 last commits, should have been #434...

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

No branches or pull requests

2 participants