Skip to content

Commit

Permalink
feat(shader-ast-js): fix #435, add new lshift/rshift ops/variations
Browse files Browse the repository at this point in the history
  • Loading branch information
postspectacular committed Dec 30, 2023
1 parent a986766 commit a78d313
Show file tree
Hide file tree
Showing 7 changed files with 26 additions and 12 deletions.
2 changes: 2 additions & 0 deletions packages/shader-ast-js/src/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,8 @@ export interface JSBuiltinsIntVec
JSBuiltinsVecCompare {
modivn: Fn2<Vec, number, Vec>;
modinv: Fn2<number, Vec, Vec>;
lshiftvn: Fn2<Vec, number, Vec>;
rshiftvn: Fn2<Vec, number, Vec>;
}

export interface JSBuiltinsMat
Expand Down
6 changes: 4 additions & 2 deletions packages/shader-ast-js/src/env/ivec2.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ import { bitXorI2 } from "@thi.ng/vectors/bit-xor";
import { divI2, divNI2 } from "@thi.ng/vectors/divi";
import { fmod2 } from "@thi.ng/vectors/fmod";
import { fmodN2 } from "@thi.ng/vectors/fmodn";
import { lshiftI2 } from "@thi.ng/vectors/lshift";
import { lshiftI2, lshiftNI2 } from "@thi.ng/vectors/lshift";
import { mulI2, mulNI2 } from "@thi.ng/vectors/muli";
import { rshiftI2 } from "@thi.ng/vectors/rshift";
import { rshiftI2, rshiftNI2 } from "@thi.ng/vectors/rshift";
import { subI2, subNI2 } from "@thi.ng/vectors/subi";
import type { JSBuiltinsIntVec } from "../api.js";
import { POOL_IVEC2 } from "../pool.js";
Expand All @@ -35,8 +35,10 @@ export const IVEC2: JSBuiltinsIntVec = {
subnv: (a, b) => subI2(null, uniform(a), b),
bitand: (a, b) => bitAndI2(next(), a, b),
lshift: (a, b) => lshiftI2(next(), a, b),
lshiftvn: (a, b) => lshiftNI2(next(), a, b),
bitnot1: (a) => bitNotI2(next(), a),
bitor: (a, b) => bitOrI2(next(), a, b),
rshift: (a, b) => rshiftI2(next(), a, b),
rshiftvn: (a, b) => rshiftNI2(next(), a, b),
bitxor: (a, b) => bitXorI2(next(), a, b),
};
6 changes: 4 additions & 2 deletions packages/shader-ast-js/src/env/ivec3.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ import { bitXorI3 } from "@thi.ng/vectors/bit-xor";
import { divI3, divNI3 } from "@thi.ng/vectors/divi";
import { fmod3 } from "@thi.ng/vectors/fmod";
import { fmodN3 } from "@thi.ng/vectors/fmodn";
import { lshiftI3 } from "@thi.ng/vectors/lshift";
import { lshiftI3, lshiftNI3 } from "@thi.ng/vectors/lshift";
import { mulI3, mulNI3 } from "@thi.ng/vectors/muli";
import { rshiftI3 } from "@thi.ng/vectors/rshift";
import { rshiftI3, rshiftNI3 } from "@thi.ng/vectors/rshift";
import { subI3, subNI3 } from "@thi.ng/vectors/subi";
import type { JSBuiltinsIntVec } from "../api.js";
import { POOL_IVEC3 } from "../pool.js";
Expand All @@ -35,8 +35,10 @@ export const IVEC3: JSBuiltinsIntVec = {
subnv: (a, b) => subI3(null, uniform(a), b),
bitand: (a, b) => bitAndI3(next(), a, b),
lshift: (a, b) => lshiftI3(next(), a, b),
lshiftvn: (a, b) => lshiftNI3(next(), a, b),
bitnot1: (a) => bitNotI3(next(), a),
bitor: (a, b) => bitOrI3(next(), a, b),
rshift: (a, b) => rshiftI3(next(), a, b),
rshiftvn: (a, b) => rshiftNI3(next(), a, b),
bitxor: (a, b) => bitXorI3(next(), a, b),
};
6 changes: 4 additions & 2 deletions packages/shader-ast-js/src/env/ivec4.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ import { bitXorI4 } from "@thi.ng/vectors/bit-xor";
import { divI4, divNI4 } from "@thi.ng/vectors/divi";
import { fmod4 } from "@thi.ng/vectors/fmod";
import { fmodN4 } from "@thi.ng/vectors/fmodn";
import { lshiftI4 } from "@thi.ng/vectors/lshift";
import { lshiftI4, lshiftNI4 } from "@thi.ng/vectors/lshift";
import { mulI4, mulNI4 } from "@thi.ng/vectors/muli";
import { rshiftI4 } from "@thi.ng/vectors/rshift";
import { rshiftI4, rshiftNI4 } from "@thi.ng/vectors/rshift";
import { subI4, subNI4 } from "@thi.ng/vectors/subi";
import type { JSBuiltinsIntVec } from "../api.js";
import { POOL_IVEC4 } from "../pool.js";
Expand All @@ -35,8 +35,10 @@ export const IVEC4: JSBuiltinsIntVec = {
subnv: (a, b) => subI4(null, uniform(a), b),
bitand: (a, b) => bitAndI4(next(), a, b),
lshift: (a, b) => lshiftI4(next(), a, b),
lshiftvn: (a, b) => lshiftNI4(next(), a, b),
bitnot1: (a) => bitNotI4(next(), a),
bitor: (a, b) => bitOrI4(next(), a, b),
rshift: (a, b) => rshiftI4(next(), a, b),
rshiftvn: (a, b) => rshiftNI4(next(), a, b),
bitxor: (a, b) => bitXorI4(next(), a, b),
};
6 changes: 4 additions & 2 deletions packages/shader-ast-js/src/env/uvec2.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ import { bitXorU2 } from "@thi.ng/vectors/bit-xor";
import { divNU2, divU2 } from "@thi.ng/vectors/divi";
import { fmod2 } from "@thi.ng/vectors/fmod";
import { fmodN2 } from "@thi.ng/vectors/fmodn";
import { lshiftU2 } from "@thi.ng/vectors/lshift";
import { lshiftNU2, lshiftU2 } from "@thi.ng/vectors/lshift";
import { mulNU2, mulU2 } from "@thi.ng/vectors/muli";
import { rshiftU2 } from "@thi.ng/vectors/rshift";
import { rshiftNU2, rshiftU2 } from "@thi.ng/vectors/rshift";
import { subNU2, subU2 } from "@thi.ng/vectors/subi";
import type { JSBuiltinsIntVec } from "../api.js";
import { POOL_UVEC2 } from "../pool.js";
Expand All @@ -35,8 +35,10 @@ export const UVEC2: JSBuiltinsIntVec = {
subnv: (a, b) => subU2(null, uniform(a), b),
bitand: (a, b) => bitAndU2(next(), a, b),
lshift: (a, b) => lshiftU2(next(), a, b),
lshiftvn: (a, b) => lshiftNU2(next(), a, b),
bitnot1: (a) => bitNotU2(next(), a),
bitor: (a, b) => bitOrU2(next(), a, b),
rshift: (a, b) => rshiftU2(next(), a, b),
rshiftvn: (a, b) => rshiftNU2(next(), a, b),
bitxor: (a, b) => bitXorU2(next(), a, b),
};
6 changes: 4 additions & 2 deletions packages/shader-ast-js/src/env/uvec3.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ import { bitXorU3 } from "@thi.ng/vectors/bit-xor";
import { divNU3, divU3 } from "@thi.ng/vectors/divi";
import { fmod3 } from "@thi.ng/vectors/fmod";
import { fmodN3 } from "@thi.ng/vectors/fmodn";
import { lshiftU3 } from "@thi.ng/vectors/lshift";
import { lshiftNU3, lshiftU3 } from "@thi.ng/vectors/lshift";
import { mulNU3, mulU3 } from "@thi.ng/vectors/muli";
import { rshiftU3 } from "@thi.ng/vectors/rshift";
import { rshiftNU3, rshiftU3 } from "@thi.ng/vectors/rshift";
import { subNU3, subU3 } from "@thi.ng/vectors/subi";
import type { JSBuiltinsIntVec } from "../api.js";
import { POOL_UVEC3 } from "../pool.js";
Expand All @@ -35,8 +35,10 @@ export const UVEC3: JSBuiltinsIntVec = {
subnv: (a, b) => subU3(null, uniform(a), b),
bitand: (a, b) => bitAndU3(next(), a, b),
lshift: (a, b) => lshiftU3(next(), a, b),
lshiftvn: (a, b) => lshiftNU3(next(), a, b),
bitnot1: (a) => bitNotU3(next(), a),
bitor: (a, b) => bitOrU3(next(), a, b),
rshift: (a, b) => rshiftU3(next(), a, b),
rshiftvn: (a, b) => rshiftNU3(next(), a, b),
bitxor: (a, b) => bitXorU3(next(), a, b),
};
6 changes: 4 additions & 2 deletions packages/shader-ast-js/src/env/uvec4.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ import { bitXorU4 } from "@thi.ng/vectors/bit-xor";
import { divNU4, divU4 } from "@thi.ng/vectors/divi";
import { fmod4 } from "@thi.ng/vectors/fmod";
import { fmodN4 } from "@thi.ng/vectors/fmodn";
import { lshiftU4 } from "@thi.ng/vectors/lshift";
import { lshiftNU4, lshiftU4 } from "@thi.ng/vectors/lshift";
import { mulNU4, mulU4 } from "@thi.ng/vectors/muli";
import { rshiftU4 } from "@thi.ng/vectors/rshift";
import { rshiftNU4, rshiftU4 } from "@thi.ng/vectors/rshift";
import { subNU4, subU4 } from "@thi.ng/vectors/subi";
import type { JSBuiltinsIntVec } from "../api.js";
import { POOL_UVEC4 } from "../pool.js";
Expand All @@ -35,8 +35,10 @@ export const UVEC4: JSBuiltinsIntVec = {
subnv: (a, b) => subU4(null, uniform(a), b),
bitand: (a, b) => bitAndU4(next(), a, b),
lshift: (a, b) => lshiftU4(next(), a, b),
lshiftvn: (a, b) => lshiftNU4(next(), a, b),
bitnot1: (a) => bitNotU4(next(), a),
bitor: (a, b) => bitOrU4(next(), a, b),
rshift: (a, b) => rshiftU4(next(), a, b),
rshiftvn: (a, b) => rshiftNU4(next(), a, b),
bitxor: (a, b) => bitXorU4(next(), a, b),
};

0 comments on commit a78d313

Please sign in to comment.