thi-ng / umbrella

⛱ Broadly scoped ecosystem & mono-repository of 199 TypeScript projects (and ~180 examples) for general purpose, functional, data driven development
https://thi.ng
Apache License 2.0
3.41k stars 151 forks source link

[shader-ast] Unsigned integer vector arithmetic #435

Closed sylee957 closed 11 months ago

sylee957 commented 11 months ago
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>;
}
postspectacular commented 11 months ago

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