typegpu 0.8.1 → 0.9.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (63) hide show
  1. package/README.md +1 -1
  2. package/chunk-5ABKYSJD.js +2 -0
  3. package/chunk-5ABKYSJD.js.map +1 -0
  4. package/chunk-D5UYO3OX.js +3 -0
  5. package/chunk-D5UYO3OX.js.map +1 -0
  6. package/chunk-EHLRP4V2.js +2 -0
  7. package/chunk-EHLRP4V2.js.map +1 -0
  8. package/chunk-LMPPDGRD.js +2 -0
  9. package/chunk-LMPPDGRD.js.map +1 -0
  10. package/chunk-MBB2XFH6.js +2 -0
  11. package/chunk-MBB2XFH6.js.map +1 -0
  12. package/chunk-SHSILTWI.js +10 -0
  13. package/chunk-SHSILTWI.js.map +1 -0
  14. package/common/index.d.ts +1 -1
  15. package/common/index.js +1 -1
  16. package/common/index.js.map +1 -1
  17. package/comptime-DKpw1IVu.d.ts +28 -0
  18. package/data/index.d.ts +124 -123
  19. package/data/index.js +1 -1
  20. package/data/index.js.map +1 -1
  21. package/index.d.ts +114 -25
  22. package/index.js +169 -164
  23. package/index.js.map +1 -1
  24. package/{matrix-DHFT4O8f.d.cts → matrix-C4IFKU1R.d.ts} +5 -4
  25. package/package.json +6 -14
  26. package/std/index.d.ts +25 -41
  27. package/std/index.js +1 -1
  28. package/std/index.js.map +1 -1
  29. package/{tgpuConstant-BU72w5qs.d.cts → tgpuConstant-BOn7U_lv.d.ts} +135 -1296
  30. package/chunk-2UXPGML5.js +0 -7
  31. package/chunk-2UXPGML5.js.map +0 -1
  32. package/chunk-3246CM7C.cjs +0 -2
  33. package/chunk-3246CM7C.cjs.map +0 -1
  34. package/chunk-4W5Z7BO4.js +0 -10
  35. package/chunk-4W5Z7BO4.js.map +0 -1
  36. package/chunk-5Y6GTBWR.cjs +0 -3
  37. package/chunk-5Y6GTBWR.cjs.map +0 -1
  38. package/chunk-7S3IK3D4.js +0 -2
  39. package/chunk-7S3IK3D4.js.map +0 -1
  40. package/chunk-7XFSK632.js +0 -3
  41. package/chunk-7XFSK632.js.map +0 -1
  42. package/chunk-PRMFGUQT.cjs +0 -2
  43. package/chunk-PRMFGUQT.cjs.map +0 -1
  44. package/chunk-TRE7NUKE.cjs +0 -10
  45. package/chunk-TRE7NUKE.cjs.map +0 -1
  46. package/chunk-VOVQAOVG.js +0 -2
  47. package/chunk-VOVQAOVG.js.map +0 -1
  48. package/chunk-ZYGTVBDH.cjs +0 -7
  49. package/chunk-ZYGTVBDH.cjs.map +0 -1
  50. package/common/index.cjs +0 -7
  51. package/common/index.cjs.map +0 -1
  52. package/common/index.d.cts +0 -24
  53. package/data/index.cjs +0 -2
  54. package/data/index.cjs.map +0 -1
  55. package/data/index.d.cts +0 -402
  56. package/index.cjs +0 -192
  57. package/index.cjs.map +0 -1
  58. package/index.d.cts +0 -369
  59. package/matrix-DLipCOZF.d.ts +0 -122
  60. package/std/index.cjs +0 -2
  61. package/std/index.cjs.map +0 -1
  62. package/std/index.d.cts +0 -639
  63. package/tgpuConstant-BU72w5qs.d.ts +0 -5192
@@ -1,20 +1,21 @@
1
- import { bB as Mat2x2f, bC as Mat3x3f, bD as Mat4x4f, by as m2x2f, bz as m3x3f, bA as m4x4f, b9 as DualFn, bK as v3f } from './tgpuConstant-BU72w5qs.cjs';
1
+ import { bE as Mat2x2f, bF as Mat3x3f, bG as Mat4x4f, bB as m2x2f, bC as m3x3f, bD as m4x4f, dO as DualFn, bN as v3f } from './tgpuConstant-BOn7U_lv.js';
2
+ import { T as TgpuComptime } from './comptime-DKpw1IVu.js';
2
3
 
3
4
  /**
4
5
  * Returns a 2-by-2 identity matrix.
5
6
  * @returns {m2x2f} The result matrix.
6
7
  */
7
- declare const identity2: DualFn<() => m2x2f>;
8
+ declare const identity2: TgpuComptime<() => m2x2f>;
8
9
  /**
9
10
  * Returns a 3-by-3 identity matrix.
10
11
  * @returns {m3x3f} The result matrix.
11
12
  */
12
- declare const identity3: DualFn<() => m3x3f>;
13
+ declare const identity3: TgpuComptime<() => m3x3f>;
13
14
  /**
14
15
  * Returns a 4-by-4 identity matrix.
15
16
  * @returns {m4x4f} The result matrix.
16
17
  */
17
- declare const identity4: DualFn<() => m4x4f>;
18
+ declare const identity4: TgpuComptime<() => m4x4f>;
18
19
  /**
19
20
  * Creates a 4-by-4 matrix which translates by the given vector v.
20
21
  * @param {v3f} vector - The vector by which to translate.
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "typegpu",
3
3
  "private": false,
4
- "version": "0.8.1",
4
+ "version": "0.9.0",
5
5
  "description": "A thin layer between JS and WebGPU/WGSL that improves development experience and allows for faster iteration.",
6
6
  "license": "MIT",
7
7
  "type": "module",
@@ -9,27 +9,19 @@
9
9
  "./package.json": "./package.json",
10
10
  ".": {
11
11
  "types": "./index.d.ts",
12
- "module": "./index.js",
13
- "import": "./index.js",
14
- "default": "./index.cjs"
12
+ "default": "./index.js"
15
13
  },
16
14
  "./data": {
17
15
  "types": "./data/index.d.ts",
18
- "module": "./data/index.js",
19
- "import": "./data/index.js",
20
- "default": "./data/index.cjs"
16
+ "default": "./data/index.js"
21
17
  },
22
18
  "./std": {
23
19
  "types": "./std/index.d.ts",
24
- "module": "./std/index.js",
25
- "import": "./std/index.js",
26
- "default": "./std/index.cjs"
20
+ "default": "./std/index.js"
27
21
  },
28
22
  "./common": {
29
23
  "types": "./common/index.d.ts",
30
- "module": "./common/index.js",
31
- "import": "./common/index.js",
32
- "default": "./common/index.cjs"
24
+ "default": "./common/index.js"
33
25
  }
34
26
  },
35
27
  "sideEffects": false,
@@ -55,7 +47,7 @@
55
47
  },
56
48
  "homepage": "https://typegpu.com",
57
49
  "dependencies": {
58
- "tinyest": "~0.1.2",
50
+ "tinyest": "~0.2.0",
59
51
  "typed-binary": "^4.3.1"
60
52
  },
61
53
  "main": "./index.js",
package/std/index.d.ts CHANGED
@@ -1,5 +1,6 @@
1
- import { b9 as DualFn, dL as AnyNumericVecInstance, dM as AnyFloatVecInstance, dN as AnyIntegerVecInstance, bK as v3f, dO as v3h, dP as AnyMatInstance, I as Infer, b8 as WgslStruct, b4 as F32, b5 as I32, b3 as F16, dQ as AbstractFloat, dR as AbstractInt, aP as Vec2f, aS as Vec2i, aV as Vec3f, aX as Vec3i, a_ as Vec4f, b0 as Vec4i, aR as Vec2h, aW as Vec3h, a$ as Vec4h, bG as v2f, dS as v2h, bH as v2i, bL as v3i, bO as v4f, dT as v4h, bP as v4i, dU as AnyFloat32VecInstance, dV as AnySignedVecInstance, dW as vBaseForMat, dX as mBaseForVec, bA as m4x4f, bs as AnyVecInstance, dY as AnyVec2Instance, bF as v2b, dZ as AnyVec3Instance, bJ as v3b, bN as v4b, d_ as AnyBooleanVecInstance, d$ as atomicI32, e0 as atomicU32, bT as texture1d, c4 as textureStorage1d, bU as texture2d, bV as texture2dArray, bX as textureCube, bY as textureCubeArray, c5 as textureStorage2d, c6 as textureStorage2dArray, c2 as textureExternal, bI as v2u, bW as texture3d, c7 as textureStorage3d, bM as v3u, bQ as v4u, $ as $internal, c3 as textureMultisampled2d, e1 as StorageTextureFormats, e2 as TextureFormats, e3 as $repr, ct as sampler, bZ as textureDepth2d, b_ as textureDepth2dArray, b$ as textureDepthCube, cs as comparisonSampler, d as WgslExtension } from '../tgpuConstant-BU72w5qs.js';
2
- export { i as identity2, d as identity3, e as identity4, r as rotationX4, f as rotationY4, g as rotationZ4, s as scaling4, t as translation4 } from '../matrix-DLipCOZF.js';
1
+ import { dO as DualFn, dP as AnyNumericVecInstance, dQ as AnyFloatVecInstance, dR as AnyIntegerVecInstance, bN as v3f, dS as v3h, dT as AnyMatInstance, o as Infer, a_ as WgslStruct, aW as F32, aX as I32, aV as F16, dU as AbstractFloat, dV as AbstractInt, aT as Vec2f, b3 as Vec2i, b6 as Vec3f, b8 as Vec3i, bb as Vec4f, bd as Vec4i, b2 as Vec2h, b7 as Vec3h, bc as Vec4h, bJ as v2f, dW as v2h, bK as v2i, bO as v3i, bR as v4f, dX as v4h, bS as v4i, dY as AnyFloat32VecInstance, dZ as AnySignedVecInstance, d_ as vBaseForMat, d$ as mBaseForVec, bD as m4x4f, bv as AnyVecInstance, e0 as AnyVec2Instance, bI as v2b, e1 as AnyVec3Instance, bM as v3b, bQ as v4b, e2 as AnyBooleanVecInstance, e3 as atomicI32, e4 as atomicU32, cz as ref, bW as texture1d, c7 as textureStorage1d, bX as texture2d, bY as texture2dArray, b_ as textureCube, b$ as textureCubeArray, c8 as textureStorage2d, c9 as textureStorage2dArray, c5 as textureExternal, bL as v2u, bZ as texture3d, ca as textureStorage3d, bP as v3u, bT as v4u, $ as $internal, c6 as textureMultisampled2d, e5 as StorageTextureFormats, e6 as TextureFormats, e7 as $repr, cw as sampler, c0 as textureDepth2d, c1 as textureDepth2dArray, c2 as textureDepthCube, cv as comparisonSampler, W as WgslExtension } from '../tgpuConstant-BOn7U_lv.js';
2
+ export { i as identity2, d as identity3, e as identity4, r as rotationX4, f as rotationY4, g as rotationZ4, s as scaling4, t as translation4 } from '../matrix-C4IFKU1R.js';
3
+ import { T as TgpuComptime } from '../comptime-DKpw1IVu.js';
3
4
  import 'tinyest';
4
5
 
5
6
  declare const discard: DualFn<() => never>;
@@ -128,7 +129,7 @@ type FrexpOverload = {
128
129
  (value: number): Infer<typeof FrexpResults['f32']>;
129
130
  <T extends AnyFloatVecInstance>(value: T): Infer<typeof FrexpResults[T['kind']]>;
130
131
  };
131
- declare const frexp: FrexpOverload;
132
+ declare const frexp: DualFn<FrexpOverload>;
132
133
  declare function cpuInsertBits(e: number, newbits: number, offset: number, count: number): number;
133
134
  declare function cpuInsertBits<T extends AnyIntegerVecInstance>(e: T, newbits: T, offset: number, count: number): T;
134
135
  declare const insertBits: DualFn<typeof cpuInsertBits>;
@@ -149,12 +150,12 @@ declare const log: DualFn<typeof cpuLog>;
149
150
  declare function cpuLog2(value: number): number;
150
151
  declare function cpuLog2<T extends AnyFloatVecInstance>(value: T): T;
151
152
  declare const log2: DualFn<typeof cpuLog2>;
152
- declare function cpuMax(a: number, b: number): number;
153
- declare function cpuMax<T extends NumVec$1>(a: T, b: T): T;
154
- declare const max: DualFn<typeof cpuMax>;
155
- declare function cpuMin(a: number, b: number): number;
156
- declare function cpuMin<T extends NumVec$1>(a: T, b: T): T;
157
- declare const min: DualFn<typeof cpuMin>;
153
+ type VariadicOverload = {
154
+ (fst: number, ...rest: number[]): number;
155
+ <T extends NumVec$1>(fst: T, ...rest: T[]): T;
156
+ };
157
+ declare const max: DualFn<VariadicOverload>;
158
+ declare const min: DualFn<VariadicOverload>;
158
159
  declare function cpuMix(e1: number, e2: number, e3: number): number;
159
160
  declare function cpuMix<T extends AnyFloatVecInstance>(e1: T, e2: T, e3: number): T;
160
161
  declare function cpuMix<T extends AnyFloatVecInstance>(e1: T, e2: T, e3: T): T;
@@ -454,9 +455,9 @@ declare function cpuSelect<T extends AnyVecInstance>(f: T, t: T, cond: boolean |
454
455
  declare const select: DualFn<typeof cpuSelect>;
455
456
 
456
457
  type AnyAtomic = atomicI32 | atomicU32;
457
- declare const workgroupBarrier: DualFn<() => void>;
458
- declare const storageBarrier: DualFn<() => void>;
459
- declare const textureBarrier: DualFn<() => void>;
458
+ declare const workgroupBarrier: DualFn<(...args: never[]) => unknown>;
459
+ declare const storageBarrier: DualFn<(...args: never[]) => unknown>;
460
+ declare const textureBarrier: DualFn<(...args: never[]) => unknown>;
460
461
  declare const atomicLoad: DualFn<(<T extends AnyAtomic>(a: T) => number)>;
461
462
  declare const atomicStore: DualFn<(<T extends AnyAtomic>(a: T, value: number) => void)>;
462
463
  declare const atomicAdd: DualFn<(<T extends AnyAtomic>(a: T, value: number) => number)>;
@@ -467,35 +468,18 @@ declare const atomicAnd: DualFn<(<T extends AnyAtomic>(a: T, value: number) => n
467
468
  declare const atomicOr: DualFn<(<T extends AnyAtomic>(a: T, value: number) => number)>;
468
469
  declare const atomicXor: DualFn<(<T extends AnyAtomic>(a: T, value: number) => number)>;
469
470
 
470
- declare function cpuDpdx(value: number): number;
471
- declare function cpuDpdx<T extends AnyFloat32VecInstance>(value: T): T;
472
- declare const dpdx: DualFn<typeof cpuDpdx>;
473
- declare function cpuDpdxCoarse(value: number): number;
474
- declare function cpuDpdxCoarse<T extends AnyFloat32VecInstance>(value: T): T;
475
- declare const dpdxCoarse: DualFn<typeof cpuDpdxCoarse>;
476
- declare function cpuDpdxFine(value: number): number;
477
- declare function cpuDpdxFine<T extends AnyFloat32VecInstance>(value: T): T;
478
- declare const dpdxFine: DualFn<typeof cpuDpdxFine>;
479
- declare function cpuDpdy(value: number): number;
480
- declare function cpuDpdy<T extends AnyFloat32VecInstance>(value: T): T;
481
- declare const dpdy: DualFn<typeof cpuDpdy>;
482
- declare function cpuDpdyCoarse(value: number): number;
483
- declare function cpuDpdyCoarse<T extends AnyFloat32VecInstance>(value: T): T;
484
- declare const dpdyCoarse: DualFn<typeof cpuDpdyCoarse>;
485
- declare function cpuDpdyFine(value: number): number;
486
- declare function cpuDpdyFine<T extends AnyFloat32VecInstance>(value: T): T;
487
- declare const dpdyFine: DualFn<typeof cpuDpdyFine>;
488
- declare function cpuFwidth(value: number): number;
489
- declare function cpuFwidth<T extends AnyFloat32VecInstance>(value: T): T;
490
- declare const fwidth: DualFn<typeof cpuFwidth>;
491
- declare function cpuFwidthCoarse(value: number): number;
492
- declare function cpuFwidthCoarse<T extends AnyFloat32VecInstance>(value: T): T;
493
- declare const fwidthCoarse: DualFn<typeof cpuFwidthCoarse>;
494
- declare function cpuFwidthFine(value: number): number;
495
- declare function cpuFwidthFine<T extends AnyFloat32VecInstance>(value: T): T;
496
- declare const fwidthFine: DualFn<typeof cpuFwidthFine>;
471
+ type DerivativeSignature = ((value: number) => number) & (<T extends AnyFloat32VecInstance>(value: T) => T);
472
+ declare const dpdx: DualFn<DerivativeSignature>;
473
+ declare const dpdxCoarse: DualFn<DerivativeSignature>;
474
+ declare const dpdxFine: DualFn<DerivativeSignature>;
475
+ declare const dpdy: DualFn<DerivativeSignature>;
476
+ declare const dpdyCoarse: DualFn<DerivativeSignature>;
477
+ declare const dpdyFine: DualFn<DerivativeSignature>;
478
+ declare const fwidth: DualFn<DerivativeSignature>;
479
+ declare const fwidthCoarse: DualFn<DerivativeSignature>;
480
+ declare const fwidthFine: DualFn<DerivativeSignature>;
497
481
 
498
- declare const arrayLength: DualFn<(a: unknown[]) => number>;
482
+ declare const arrayLength: DualFn<(a: unknown[] | ref<unknown[]>) => number>;
499
483
 
500
484
  /**
501
485
  * @privateRemarks
@@ -629,7 +613,7 @@ declare const subgroupShuffleUp: DualFn<IdentityNumOrVecWithDelta>;
629
613
  declare const subgroupShuffleXor: DualFn<IdentityNumOrVecWithMask>;
630
614
  declare const subgroupXor: DualFn<IdentityIntNumOrVec>;
631
615
 
632
- declare const extensionEnabled: DualFn<(extensionName: WgslExtension) => boolean>;
616
+ declare const extensionEnabled: TgpuComptime<(extensionName: WgslExtension) => boolean>;
633
617
 
634
618
  type BitcastU32toF32Overload = ((value: number) => number) & ((value: v2u) => v2f) & ((value: v3u) => v3f) & ((value: v4u) => v4f);
635
619
  declare const bitcastU32toF32: DualFn<BitcastU32toF32Overload>;
package/std/index.js CHANGED
@@ -1,2 +1,2 @@
1
- import{a as G,c as nt,d as ut,e as at,f as pt,g as st,h as it,i as P,k as mt,l as dt,m as lt,n as ct,o as xt,p as Tt,q as ft,r as yt,s as bt,t as vt,u as gt,v as It,w as ht,x as wt}from"../chunk-VOVQAOVG.js";import{a as U}from"../chunk-7S3IK3D4.js";import{$ as z,$a as ze,Aa as he,Ba as we,Ca as Ce,Da as Ae,Ea as Se,Fa as Ee,Ga as De,Ha as $e,Ia as Fe,Ja as Oe,Ka as Ve,La as Le,Ma as We,Na as Be,Oa as Ne,Pa as _e,Qa as Me,R as M,Ra as Ge,Sa as Pe,Ta as Ue,Ua as ke,Va as Xe,Wa as Re,X as j,Xa as Ze,Y,Ya as je,Z as F,Za as Ye,_ as q,_a as qe,aa as H,ab as He,b as X,ba as J,bb as Je,c as R,ca as K,cb as Ke,d as Z,da as Q,db as Qe,e as C,ea as ee,eb as et,f as A,fa as te,fb as tt,g as S,ga as re,gb as rt,h as E,ha as oe,hb as ot,i as D,ia as ne,ja as ue,ka as ae,la as pe,ma as se,na as ie,oa as me,pa as de,qa as le,ra as ce,sa as xe,ta as Te,ua as fe,va as ye,wa as be,xa as ve,ya as ge,za as Ie}from"../chunk-2UXPGML5.js";import{Aa as V,B as l,C as O,Da as L,E as $,Ea as r,Ha as y,La as u,Na as n,Oa as W,Qa as T,Ra as m,Ta as g,Ua as I,_a as B,a as p,aa as o,db as N,fb as b,hb as _,ib as w,lb as c,q as x}from"../chunk-4W5Z7BO4.js";var Ct=u(()=>{throw new Error("`discard` relies on GPU resources and cannot be executed outside of a draw call")},()=>o("discard;",x),"discard");var h=F[p].jsImpl,At=C[p].jsImpl,St=C[p].gpuImpl,Et=A[p].jsImpl,Dt=A[p].gpuImpl,$t=S[p].jsImpl,Ft=S[p].gpuImpl,Ot=E[p].jsImpl,Vt=E[p].gpuImpl,Lt=D[p].jsImpl,Wt=D[p].gpuImpl,Bt=u((e,t)=>h(At(t),e),(e,t)=>o(r`(${St(t)} * ${e})`,e.dataType),"translate4"),Nt=u((e,t)=>h(Et(t),e),(e,t)=>o(r`(${Dt(t)} * ${e})`,e.dataType),"scale4"),_t=u((e,t)=>h($t(t),e),(e,t)=>o(r`(${Ft(t)} * ${e})`,e.dataType),"rotateX4"),Mt=u((e,t)=>h(Ot(t),e),(e,t)=>o(r`(${Vt(t)} * ${e})`,e.dataType),"rotateY4"),Gt=u((e,t)=>h(Lt(t),e),(e,t)=>o(r`(${Wt(t)} * ${e})`,e.dataType),"rotateZ4");var Pt=u(()=>console.warn("workgroupBarrier is a no-op outside of CODEGEN mode."),()=>o("workgroupBarrier()",x),"workgroupBarrier"),Ut=u(()=>console.warn("storageBarrier is a no-op outside of CODEGEN mode."),()=>o("storageBarrier()",x),"storageBarrier"),kt=u(()=>console.warn("textureBarrier is a no-op outside of CODEGEN mode."),()=>o("textureBarrier()",x),"textureBarrier"),Xt=u(e=>{throw new Error("Atomic operations are not supported outside of CODEGEN mode.")},e=>{if(l(e.dataType)&&e.dataType.type==="atomic")return o(r`atomicLoad(&${e})`,e.dataType.inner);throw new Error(`Invalid atomic type: ${c(e.dataType)}`)},"atomicLoad"),Rt=u((e,t)=>{throw new Error("Atomic operations are not supported outside of CODEGEN mode.")},(e,t)=>{if(!l(e.dataType)||e.dataType.type!=="atomic")throw new Error(`Invalid atomic type: ${c(e.dataType)}`);return o(r`atomicStore(&${e}, ${t})`,x)},"atomicStore"),f=(e,t)=>e.dataType.type==="atomic"&&e.dataType.inner.type==="i32"?[e.dataType,g]:[e.dataType,m],Zt=u((e,t)=>{throw new Error("Atomic operations are not supported outside of CODEGEN mode.")},(e,t)=>{if(l(e.dataType)&&e.dataType.type==="atomic")return o(r`atomicAdd(&${e}, ${t})`,e.dataType.inner);throw new Error(`Invalid atomic type: ${c(e.dataType)}`)},"atomicAdd",f),jt=u((e,t)=>{throw new Error("Atomic operations are not supported outside of CODEGEN mode.")},(e,t)=>{if(l(e.dataType)&&e.dataType.type==="atomic")return o(r`atomicSub(&${e}, ${t})`,e.dataType.inner);throw new Error(`Invalid atomic type: ${c(e.dataType)}`)},"atomicSub",f),Yt=u((e,t)=>{throw new Error("Atomic operations are not supported outside of CODEGEN mode.")},(e,t)=>{if(l(e.dataType)&&e.dataType.type==="atomic")return o(r`atomicMax(&${e}, ${t})`,e.dataType.inner);throw new Error(`Invalid atomic type: ${c(e.dataType)}`)},"atomicMax",f),qt=u((e,t)=>{throw new Error("Atomic operations are not supported outside of CODEGEN mode.")},(e,t)=>{if(l(e.dataType)&&e.dataType.type==="atomic")return o(r`atomicMin(&${e}, ${t})`,e.dataType.inner);throw new Error(`Invalid atomic type: ${c(e.dataType)}`)},"atomicMin",f),zt=u((e,t)=>{throw new Error("Atomic operations are not supported outside of CODEGEN mode.")},(e,t)=>{if(l(e.dataType)&&e.dataType.type==="atomic")return o(r`atomicAnd(&${e}, ${t})`,e.dataType.inner);throw new Error(`Invalid atomic type: ${c(e.dataType)}`)},"atomicAnd",f),Ht=u((e,t)=>{throw new Error("Atomic operations are not supported outside of CODEGEN mode.")},(e,t)=>{if(l(e.dataType)&&e.dataType.type==="atomic")return o(r`atomicOr(&${e}, ${t})`,e.dataType.inner);throw new Error(`Invalid atomic type: ${c(e.dataType)}`)},"atomicOr",f),Jt=u((e,t)=>{throw new Error("Atomic operations are not supported outside of CODEGEN mode.")},(e,t)=>{if(l(e.dataType)&&e.dataType.type==="atomic")return o(r`atomicXor(&${e}, ${t})`,e.dataType.inner);throw new Error(`Invalid atomic type: ${c(e.dataType)}`)},"atomicXor",f);function Kt(e){throw new Error("Derivative builtins are not allowed on the cpu")}var Qt=u(Kt,e=>o(r`dpdx(${e})`,e.dataType),"dpdx");function er(e){throw new Error("Derivative builtins are not allowed on the cpu")}var tr=u(er,e=>o(r`dpdxCoarse(${e})`,e.dataType),"dpdxCoarse");function rr(e){throw new Error("Derivative builtins are not allowed on the cpu")}var or=u(rr,e=>o(r`dpdxFine(${e})`,e.dataType),"dpdxFine");function nr(e){throw new Error("Derivative builtins are not allowed on the cpu")}var ur=u(nr,e=>o(r`dpdy(${e})`,e.dataType),"dpdy");function ar(e){throw new Error("Derivative builtins are not allowed on the cpu")}var pr=u(ar,e=>o(r`dpdyCoarse(${e})`,e.dataType),"dpdyCoarse");function sr(e){throw new Error("Derivative builtins are not allowed on the cpu")}var ir=u(sr,e=>o(r`dpdyFine(${e})`,e.dataType),"dpdyFine");function mr(e){throw new Error("Derivative builtins are not allowed on the cpu")}var dr=u(mr,e=>o(r`fwidth(${e})`,e.dataType),"fwidth");function lr(e){throw new Error("Derivative builtins are not allowed on the cpu")}var cr=u(lr,e=>o(r`fwidthCoarse(${e})`,e.dataType),"fwidthCoarse");function xr(e){throw new Error("Derivative builtins are not allowed on the cpu")}var Tr=u(xr,e=>o(r`fwidthFine(${e})`,e.dataType),"fwidthFine");var k=e=>$(e)&&O(e.inner)?e.inner.elementCount:0,fr=n({name:"arrayLength",signature:e=>{let t=$(e)?e:U(e);return{argTypes:[t],returnType:k(t)>0?W:m}},normalImpl:e=>e.length,codegenImpl(e){let t=k(e.dataType);return t>0?String(t):r`arrayLength(${e})`}});function yr(e,t,d,i,s){throw new Error("Texture sampling relies on GPU resources and cannot be executed outside of a draw call")}var br=n({name:"textureSample",normalImpl:yr,codegenImpl:(...e)=>r`textureSample(${e})`,signature:(...e)=>{let t=e[0].type.startsWith("texture_depth");return{argTypes:e,returnType:t?I:b}}});function vr(e,t,d,i,s,v){throw new Error("Texture sampling with bias relies on GPU resources and cannot be executed outside of a draw call")}var gr=n({name:"textureSampleBias",normalImpl:vr,codegenImpl:(...e)=>r`textureSampleBias(${e})`,signature:(...e)=>({argTypes:e,returnType:b})});function Ir(e,t,d,i,s,v){throw new Error("Texture sampling relies on GPU resources and cannot be executed outside of a draw call")}var hr=n({name:"textureSampleLevel",normalImpl:Ir,codegenImpl:(...e)=>r`textureSampleLevel(${e})`,signature:(...e)=>{let t=e[0].type.startsWith("texture_depth");return{argTypes:e,returnType:t?I:b}}});function wr(e,t,d){throw new Error("`textureLoad` relies on GPU resources and cannot be executed outside of a draw call")}var Cr=n({name:"textureLoad",normalImpl:wr,codegenImpl:(...e)=>r`textureLoad(${e})`,signature:(...e)=>{let t=e[0];if(M(t)){let s=t.type.startsWith("texture_depth"),v=t.sampleType;return{argTypes:e,returnType:s?I:v.type==="f32"?b:v.type==="u32"?w:_}}let d=t.format,i=G[d].vectorType;return{argTypes:e,returnType:i}}});function Ar(e,t,d,i){throw new Error("`textureStore` relies on GPU resources and cannot be executed outside of a draw call")}var Sr=n({name:"textureStore",normalImpl:Ar,codegenImpl:(...e)=>r`textureStore(${e})`,signature:(...e)=>({argTypes:e,returnType:x})});function Er(e,t){throw new Error("`textureDimensions` relies on GPU resources and cannot be executed outside of a draw call")}var Dr=n({name:"textureDimensions",normalImpl:Er,codegenImpl:(...e)=>r`textureDimensions(${e})`,signature:(...e)=>{let t=e[0].dimension;return t==="1d"?{argTypes:e,returnType:m}:t==="3d"?{argTypes:e,returnType:N}:{argTypes:e,returnType:B}}});function $r(e,t,d,i,s,v){throw new Error("Texture comparison sampling relies on GPU resources and cannot be executed outside of a draw call")}var Fr=n({name:"textureSampleCompare",normalImpl:$r,codegenImpl:(...e)=>r`textureSampleCompare(${e})`,signature:(...e)=>({argTypes:e,returnType:I})});function Or(e,t,d){throw new Error("Texture sampling with base clamp to edge is not supported outside of GPU mode.")}var Vr=n({name:"textureSampleBaseClampToEdge",normalImpl:Or,codegenImpl:(...e)=>r`textureSampleBaseClampToEdge(${e})`,signature:(...e)=>({argTypes:e,returnType:b})});var a="Subgroup operations can only be used in the GPU context.",Lr=n({name:"subgroupAdd",signature:e=>({argTypes:[e],returnType:e}),normalImpl:a,codegenImpl:e=>r`subgroupAdd(${e})`}),Wr=n({name:"subgroupExclusiveAdd",signature:e=>({argTypes:[e],returnType:e}),normalImpl:a,codegenImpl:e=>r`subgroupExclusiveAdd(${e})`}),Br=n({name:"subgroupInclusiveAdd",signature:e=>({argTypes:[e],returnType:e}),normalImpl:a,codegenImpl:e=>r`subgroupInclusiveAdd(${e})`}),Nr=n({name:"subgroupAll",signature:{argTypes:[T],returnType:T},normalImpl:a,codegenImpl:e=>r`subgroupAll(${e})`}),_r=n({name:"subgroupAnd",signature:e=>({argTypes:[e],returnType:e}),normalImpl:a,codegenImpl:e=>r`subgroupAnd(${e})`}),Mr=n({name:"subgroupAny",signature:{argTypes:[T],returnType:T},normalImpl:a,codegenImpl:e=>r`subgroupAny(${e})`}),Gr=n({name:"subgroupBallot",signature:{argTypes:[T],returnType:w},normalImpl:a,codegenImpl:e=>r`subgroupBallot(${e})`}),Pr=n({name:"subgroupBroadcast",signature:(...e)=>{let t=y([e[1]],[g,m]);if(!t)throw new Error(`subgroupBroadcast's second argument has to be compatible with i32 or u32. Got: ${e[1].type}`);return{argTypes:[e[0],t[0]],returnType:e[0]}},normalImpl:a,codegenImpl:(e,t)=>r`subgroupBroadcast(${e}, ${t})`}),Ur=n({name:"subgroupBroadcastFirst",signature:e=>({argTypes:[e],returnType:e}),normalImpl:a,codegenImpl:e=>r`subgroupBroadcastFirst(${e})`}),kr=n({name:"subgroupElect",signature:{argTypes:[],returnType:T},normalImpl:a,codegenImpl:()=>r`subgroupElect()`}),Xr=n({name:"subgroupMax",signature:e=>({argTypes:[e],returnType:e}),normalImpl:a,codegenImpl:e=>r`subgroupMax(${e})`}),Rr=n({name:"subgroupMin",signature:e=>({argTypes:[e],returnType:e}),normalImpl:a,codegenImpl:e=>r`subgroupMin(${e})`}),Zr=n({name:"subgroupMul",signature:e=>({argTypes:[e],returnType:e}),normalImpl:a,codegenImpl:e=>r`subgroupMul(${e})`}),jr=n({name:"subgroupExclusiveMul",signature:e=>({argTypes:[e],returnType:e}),normalImpl:a,codegenImpl:e=>r`subgroupExclusiveMul(${e})`}),Yr=n({name:"subgroupInclusiveMul",signature:e=>({argTypes:[e],returnType:e}),normalImpl:a,codegenImpl:e=>r`subgroupInclusiveMul(${e})`}),qr=n({name:"subgroupOr",signature:e=>({argTypes:[e],returnType:e}),normalImpl:a,codegenImpl:e=>r`subgroupOr(${e})`}),zr=n({name:"subgroupShuffle",signature:(...e)=>{let t=y([e[1]],[g,m]);if(!t)throw new Error(`subgroupShuffle's second argument has to be compatible with i32 or u32. Got: ${e[1].type}`);return{argTypes:[e[0],t[0]],returnType:e[0]}},normalImpl:a,codegenImpl:(e,t)=>r`subgroupShuffle(${e}, ${t})`}),Hr=n({name:"subgroupShuffleDown",signature:(...e)=>{let t=y([e[1]],[m]);if(!t)throw new Error(`subgroupShuffleDown's second argument has to be compatible with u32. Got: ${e[1].type}`);return{argTypes:[e[0],t[0]],returnType:e[0]}},normalImpl:a,codegenImpl:(e,t)=>r`subgroupShuffleDown(${e}, ${t})`}),Jr=n({name:"subgroupShuffleUp",signature:(...e)=>{let t=y([e[1]],[m]);if(!t)throw new Error(`subgroupShuffleUp's second argument has to be compatible with u32. Got: ${e[1].type}`);return{argTypes:[e[0],t[0]],returnType:e[0]}},normalImpl:a,codegenImpl:(e,t)=>r`subgroupShuffleUp(${e}, ${t})`}),Kr=n({name:"subgroupShuffleXor",signature:(...e)=>{let t=y([e[1]],[m]);if(!t)throw new Error(`subgroupShuffleXor's second argument has to be compatible with u32. Got: ${e[1].type}`);return{argTypes:[e[0],t[0]],returnType:e[0]}},normalImpl:a,codegenImpl:(e,t)=>r`subgroupShuffleXor(${e}, ${t})`}),Qr=n({name:"subgroupXor",signature:e=>({argTypes:[e],returnType:e}),normalImpl:a,codegenImpl:e=>r`subgroupXor(${e})`});var eo=(()=>{let e=i=>{let s=V();if(!s)throw new Error("extensionEnabled can only be called in a GPU codegen context.");return(s.enableExtensions??[]).includes(i)},t=i=>{let{value:s}=i;if(typeof s!="string"||!P.includes(s))throw new Error(`extensionEnabled has to be called with a string literal representing a valid WGSL extension name. Got: ${s}`);return o(e(s),T)},d=i=>{if(L())return t(i);throw new Error("extensionEnabled can only be called in a GPU codegen context.")};return Object.defineProperty(d,p,{value:{jsImpl:e,gpuImpl:t,argConversionHint:"keep"}}),d})();export{J as abs,K as acos,Q as acosh,j as add,gt as all,mt as allEq,vt as and,It as any,fr as arrayLength,ee as asin,te as asinh,re as atan,ne as atan2,oe as atanh,Zt as atomicAdd,zt as atomicAnd,Xt as atomicLoad,Yt as atomicMax,qt as atomicMin,Ht as atomicOr,Rt as atomicStore,jt as atomicSub,Jt as atomicXor,nt as bitcastU32toF32,ut as bitcastU32toI32,ue as ceil,ae as clamp,pe as cos,se as cosh,ie as countLeadingZeros,me as countOneBits,de as countTrailingZeros,le as cross,ce as degrees,xe as determinant,Ct as discard,Te as distance,q as div,fe as dot,be as dot4I8Packed,ye as dot4U8Packed,Qt as dpdx,tr as dpdxCoarse,or as dpdxFine,ur as dpdy,pr as dpdyCoarse,ir as dpdyFine,dt as eq,ve as exp,ge as exp2,eo as extensionEnabled,Ie as extractBits,he as faceForward,we as firstLeadingBit,Ce as firstTrailingBit,Ae as floor,Se as fma,Ee as fract,De as frexp,dr as fwidth,cr as fwidthCoarse,Tr as fwidthFine,ft as ge,Tt as gt,X as identity2,R as identity3,Z as identity4,$e as insertBits,Fe as inverseSqrt,ht as isCloseTo,Oe as ldexp,xt as le,Ve as length,Le as log,We as log2,ct as lt,Be as max,Ne as min,_e as mix,z as mod,Me as modf,F as mul,lt as ne,H as neg,Ge as normalize,yt as not,bt as or,pt as pack2x16float,it as pack4x8unorm,Pe as pow,Ue as quantizeToF16,ke as radians,Xe as reflect,Re as refract,Ze as reverseBits,_t as rotateX4,Mt as rotateY4,Gt as rotateZ4,S as rotationX4,E as rotationY4,D as rotationZ4,je as round,Ye as saturate,Nt as scale4,A as scaling4,wt as select,qe as sign,ze as sin,He as sinh,Je as smoothstep,Ke as sqrt,Qe as step,Ut as storageBarrier,Y as sub,Lr as subgroupAdd,Nr as subgroupAll,_r as subgroupAnd,Mr as subgroupAny,Gr as subgroupBallot,Pr as subgroupBroadcast,Ur as subgroupBroadcastFirst,kr as subgroupElect,Wr as subgroupExclusiveAdd,jr as subgroupExclusiveMul,Br as subgroupInclusiveAdd,Yr as subgroupInclusiveMul,Xr as subgroupMax,Rr as subgroupMin,Zr as subgroupMul,qr as subgroupOr,zr as subgroupShuffle,Hr as subgroupShuffleDown,Jr as subgroupShuffleUp,Kr as subgroupShuffleXor,Qr as subgroupXor,et as tan,tt as tanh,kt as textureBarrier,Dr as textureDimensions,Cr as textureLoad,br as textureSample,Vr as textureSampleBaseClampToEdge,gr as textureSampleBias,Fr as textureSampleCompare,hr as textureSampleLevel,Sr as textureStore,Bt as translate4,C as translation4,rt as transpose,ot as trunc,at as unpack2x16float,st as unpack4x8unorm,Pt as workgroupBarrier};
1
+ import{$ as Je,A as Ce,Aa as ht,B as Ae,Ba as St,C as $e,Ca as Ct,D as we,Da as At,E as De,Ea as $t,F as Ee,G as Le,H as Oe,I as Be,J as We,K as Fe,L as Ve,M as _e,N as Me,O as Ne,P as Ge,Q as Pe,R as Ue,S as Xe,T as ke,U as Re,V as Ze,W as Ye,X as je,Y as qe,Z as ze,_ as He,a as k,aa as Ke,ba as Qe,c as ee,ca as et,d as te,da as tt,e as re,ea as rt,f as oe,fa as ot,g as ne,ga as nt,h as ue,ha as ut,i as ae,ia as at,j as se,ja as st,k as pe,ka as pt,l as me,la as mt,m as ie,ma as it,n as le,na as lt,o as de,oa as dt,p as ce,pa as R,q as xe,r as fe,ra as ct,s as ge,sa as xt,t as Te,ta as ft,u as ye,ua as gt,v as be,va as Tt,w as ve,wa as yt,x as Ie,xa as bt,y as he,ya as vt,z as Se,za as It}from"../chunk-5ABKYSJD.js";import{Q as X,b as Y,c as j,d as q,e as S,f as C,g as A,h as $,i as w,l as c,r as z,s as H,t as O,u as J,v as K,w as Q}from"../chunk-EHLRP4V2.js";import{Ab as h,C as W,E,Ha as F,Hb as U,Ib as D,La as o,Ma as V,Va as _,_a as g,a,db as r,eb as M,gb as l,hb as u,jb as T,kb as d,q as p,qb as N,sb as L,vb as G,xb as y,zb as P}from"../chunk-SHSILTWI.js";var wt=r({name:"discard",normalImpl:"`discard` relies on GPU resources and cannot be executed outside of a draw call",signature:{argTypes:[],returnType:p},codegenImpl:()=>"discard;"});var I=O[a].jsImpl,Dt=S[a].jsImpl,Et=S[a].gpuImpl,Lt=C[a].jsImpl,Ot=C[a].gpuImpl,Bt=A[a].jsImpl,Wt=A[a].gpuImpl,Ft=$[a].jsImpl,Vt=$[a].gpuImpl,_t=w[a].jsImpl,Mt=w[a].gpuImpl,Nt=r({name:"translate4",normalImpl:(e,t)=>I(Dt(t),e),signature:{argTypes:[c,L],returnType:c},codegenImpl:(e,t)=>o`(${Et(t)} * ${e})`}),Gt=r({name:"scale4",normalImpl:(e,t)=>I(Lt(t),e),signature:{argTypes:[c,L],returnType:c},codegenImpl:(e,t)=>o`(${Ot(t)} * ${e})`}),B={argTypes:[c,d],returnType:c},Pt=r({name:"rotateX4",normalImpl:(e,t)=>I(Bt(t),e),signature:B,codegenImpl:(e,t)=>o`(${Wt(t)} * ${e})`}),Ut=r({name:"rotateY4",normalImpl:(e,t)=>I(Ft(t),e),signature:B,codegenImpl:(e,t)=>o`(${Vt(t)} * ${e})`}),Xt=r({name:"rotateZ4",normalImpl:(e,t)=>I(_t(t),e),signature:B,codegenImpl:(e,t)=>o`(${Mt(t)} * ${e})`});var kt=r({name:"workgroupBarrier",normalImpl:"workgroupBarrier is a no-op outside of CODEGEN mode.",signature:{argTypes:[],returnType:p},codegenImpl:()=>"workgroupBarrier()"}),Rt=r({name:"storageBarrier",normalImpl:"storageBarrier is a no-op outside of CODEGEN mode.",signature:{argTypes:[],returnType:p},codegenImpl:()=>"storageBarrier()"}),Zt=r({name:"textureBarrier",normalImpl:"textureBarrier is a no-op outside of CODEGEN mode.",signature:{argTypes:[],returnType:p},codegenImpl:()=>"textureBarrier()"}),m="Atomic operations are not supported outside of CODEGEN mode.",Yt=r({name:"atomicLoad",normalImpl:m,signature:e=>{if(e.type!=="atomic")throw new Error(`Invalid atomic type: ${D(e)}`);return{argTypes:[e],returnType:e.inner}},codegenImpl:e=>o`atomicLoad(&${e})`}),jt=(e,t)=>{if(e.type!=="atomic")throw new Error(`Invalid atomic type: ${D(e)}`);return{argTypes:[e,e.inner.type==="u32"?u:T],returnType:p}},x=(e,t)=>{if(e.type!=="atomic")throw new Error(`Invalid atomic type: ${D(e)}`);let s=e.inner.type==="u32"?u:T;return{argTypes:[e,s],returnType:s}},qt=r({name:"atomicStore",normalImpl:m,signature:jt,codegenImpl:(e,t)=>o`atomicStore(&${e}, ${t})`}),zt=r({name:"atomicAdd",normalImpl:m,signature:x,codegenImpl:(e,t)=>o`atomicAdd(&${e}, ${t})`}),Ht=r({name:"atomicSub",normalImpl:m,signature:x,codegenImpl:(e,t)=>o`atomicSub(&${e}, ${t})`}),Jt=r({name:"atomicMax",normalImpl:m,signature:x,codegenImpl:(e,t)=>o`atomicMax(&${e}, ${t})`}),Kt=r({name:"atomicMin",normalImpl:m,signature:x,codegenImpl:(e,t)=>o`atomicMin(&${e}, ${t})`}),Qt=r({name:"atomicAnd",normalImpl:m,signature:x,codegenImpl:(e,t)=>o`atomicAnd(&${e}, ${t})`}),er=r({name:"atomicOr",normalImpl:m,signature:x,codegenImpl:(e,t)=>o`atomicOr(&${e}, ${t})`}),tr=r({name:"atomicXor",normalImpl:m,signature:x,codegenImpl:(e,t)=>o`atomicXor(&${e}, ${t})`});var i="Derivative builtins are not allowed on the CPU",rr=r({name:"dpdx",normalImpl:i,signature:e=>({argTypes:[e],returnType:e}),codegenImpl:e=>o`dpdx(${e})`}),or=r({name:"dpdxCoarse",normalImpl:i,signature:e=>({argTypes:[e],returnType:e}),codegenImpl:e=>o`dpdxCoarse(${e})`}),nr=r({name:"dpdxFine",normalImpl:i,signature:e=>({argTypes:[e],returnType:e}),codegenImpl:e=>o`dpdxFine(${e})`}),ur=r({name:"dpdy",normalImpl:i,signature:e=>({argTypes:[e],returnType:e}),codegenImpl:e=>o`dpdy(${e})`}),ar=r({name:"dpdyCoarse",normalImpl:i,signature:e=>({argTypes:[e],returnType:e}),codegenImpl:e=>o`dpdyCoarse(${e})`}),sr=r({name:"dpdyFine",normalImpl:i,signature:e=>({argTypes:[e],returnType:e}),codegenImpl:e=>o`dpdyFine(${e})`}),pr=r({name:"fwidth",normalImpl:i,signature:e=>({argTypes:[e],returnType:e}),codegenImpl:e=>o`fwidth(${e})`}),mr=r({name:"fwidthCoarse",normalImpl:i,signature:e=>({argTypes:[e],returnType:e}),codegenImpl:e=>o`fwidthCoarse(${e})`}),ir=r({name:"fwidthFine",normalImpl:i,signature:e=>({argTypes:[e],returnType:e}),codegenImpl:e=>o`fwidthFine(${e})`});var Z=e=>E(e)&&W(e.inner)?e.inner.elementCount:0,lr=r({name:"arrayLength",signature:e=>{let t=E(e)?e:V(e);return{argTypes:[t],returnType:Z(t)>0?M:u}},normalImpl:e=>_(e)?e.$.length:e.length,codegenImpl(e){let t=Z(e.dataType);return t>0?String(t):o`arrayLength(${e})`}});function dr(e,t,s,f,b){throw new Error("Texture sampling relies on GPU resources and cannot be executed outside of a draw call")}var cr=r({name:"textureSample",normalImpl:dr,codegenImpl:(...e)=>o`textureSample(${e})`,signature:(...e)=>{let t=e[0].type.startsWith("texture_depth");return{argTypes:e,returnType:t?d:y}}});function xr(e,t,s,f,b,v){throw new Error("Texture sampling with bias relies on GPU resources and cannot be executed outside of a draw call")}var fr=r({name:"textureSampleBias",normalImpl:xr,codegenImpl:(...e)=>o`textureSampleBias(${e})`,signature:(...e)=>({argTypes:e,returnType:y})});function gr(e,t,s,f,b,v){throw new Error("Texture sampling relies on GPU resources and cannot be executed outside of a draw call")}var Tr=r({name:"textureSampleLevel",normalImpl:gr,codegenImpl:(...e)=>o`textureSampleLevel(${e})`,signature:(...e)=>{let t=e[0].type.startsWith("texture_depth");return{argTypes:e,returnType:t?d:y}}});function yr(e,t,s){throw new Error("`textureLoad` relies on GPU resources and cannot be executed outside of a draw call")}var br=r({name:"textureLoad",normalImpl:yr,codegenImpl:(...e)=>o`textureLoad(${e})`,signature:(...e)=>{let t=e[0];if(X(t)){let b=t.type.startsWith("texture_depth"),v=t.sampleType;return{argTypes:e,returnType:b?d:v.type==="f32"?y:v.type==="u32"?h:P}}let s=t.format,f=k(s).vectorType;return{argTypes:e,returnType:f}}});function vr(e,t,s,f){throw new Error("`textureStore` relies on GPU resources and cannot be executed outside of a draw call")}var Ir=r({name:"textureStore",normalImpl:vr,codegenImpl:(...e)=>o`textureStore(${e})`,signature:(...e)=>({argTypes:e,returnType:p})});function hr(e,t){throw new Error("`textureDimensions` relies on GPU resources and cannot be executed outside of a draw call")}var Sr=r({name:"textureDimensions",normalImpl:hr,codegenImpl:(...e)=>o`textureDimensions(${e})`,signature:(...e)=>{let t=e[0].dimension;return t==="1d"?{argTypes:e,returnType:u}:t==="3d"?{argTypes:e,returnType:G}:{argTypes:e,returnType:N}}});function Cr(e,t,s,f,b,v){throw new Error("Texture comparison sampling relies on GPU resources and cannot be executed outside of a draw call")}var Ar=r({name:"textureSampleCompare",normalImpl:Cr,codegenImpl:(...e)=>o`textureSampleCompare(${e})`,signature:(...e)=>({argTypes:e,returnType:d})});function $r(e,t,s){throw new Error("Texture sampling with base clamp to edge is not supported outside of GPU mode.")}var wr=r({name:"textureSampleBaseClampToEdge",normalImpl:$r,codegenImpl:(...e)=>o`textureSampleBaseClampToEdge(${e})`,signature:(...e)=>({argTypes:e,returnType:y})});var n="Subgroup operations can only be used in the GPU context.",Dr=r({name:"subgroupAdd",signature:e=>({argTypes:[e],returnType:e}),normalImpl:n,codegenImpl:e=>o`subgroupAdd(${e})`}),Er=r({name:"subgroupExclusiveAdd",signature:e=>({argTypes:[e],returnType:e}),normalImpl:n,codegenImpl:e=>o`subgroupExclusiveAdd(${e})`}),Lr=r({name:"subgroupInclusiveAdd",signature:e=>({argTypes:[e],returnType:e}),normalImpl:n,codegenImpl:e=>o`subgroupInclusiveAdd(${e})`}),Or=r({name:"subgroupAll",signature:{argTypes:[l],returnType:l},normalImpl:n,codegenImpl:e=>o`subgroupAll(${e})`}),Br=r({name:"subgroupAnd",signature:e=>({argTypes:[e],returnType:e}),normalImpl:n,codegenImpl:e=>o`subgroupAnd(${e})`}),Wr=r({name:"subgroupAny",signature:{argTypes:[l],returnType:l},normalImpl:n,codegenImpl:e=>o`subgroupAny(${e})`}),Fr=r({name:"subgroupBallot",signature:{argTypes:[l],returnType:h},normalImpl:n,codegenImpl:e=>o`subgroupBallot(${e})`}),Vr=r({name:"subgroupBroadcast",signature:(...e)=>{let t=g([e[1]],[T,u]);if(!t)throw new Error(`subgroupBroadcast's second argument has to be compatible with i32 or u32. Got: ${e[1].type}`);return{argTypes:[e[0],t[0]],returnType:e[0]}},normalImpl:n,codegenImpl:(e,t)=>o`subgroupBroadcast(${e}, ${t})`}),_r=r({name:"subgroupBroadcastFirst",signature:e=>({argTypes:[e],returnType:e}),normalImpl:n,codegenImpl:e=>o`subgroupBroadcastFirst(${e})`}),Mr=r({name:"subgroupElect",signature:{argTypes:[],returnType:l},normalImpl:n,codegenImpl:()=>o`subgroupElect()`}),Nr=r({name:"subgroupMax",signature:e=>({argTypes:[e],returnType:e}),normalImpl:n,codegenImpl:e=>o`subgroupMax(${e})`}),Gr=r({name:"subgroupMin",signature:e=>({argTypes:[e],returnType:e}),normalImpl:n,codegenImpl:e=>o`subgroupMin(${e})`}),Pr=r({name:"subgroupMul",signature:e=>({argTypes:[e],returnType:e}),normalImpl:n,codegenImpl:e=>o`subgroupMul(${e})`}),Ur=r({name:"subgroupExclusiveMul",signature:e=>({argTypes:[e],returnType:e}),normalImpl:n,codegenImpl:e=>o`subgroupExclusiveMul(${e})`}),Xr=r({name:"subgroupInclusiveMul",signature:e=>({argTypes:[e],returnType:e}),normalImpl:n,codegenImpl:e=>o`subgroupInclusiveMul(${e})`}),kr=r({name:"subgroupOr",signature:e=>({argTypes:[e],returnType:e}),normalImpl:n,codegenImpl:e=>o`subgroupOr(${e})`}),Rr=r({name:"subgroupShuffle",signature:(...e)=>{let t=g([e[1]],[T,u]);if(!t)throw new Error(`subgroupShuffle's second argument has to be compatible with i32 or u32. Got: ${e[1].type}`);return{argTypes:[e[0],t[0]],returnType:e[0]}},normalImpl:n,codegenImpl:(e,t)=>o`subgroupShuffle(${e}, ${t})`}),Zr=r({name:"subgroupShuffleDown",signature:(...e)=>{let t=g([e[1]],[u]);if(!t)throw new Error(`subgroupShuffleDown's second argument has to be compatible with u32. Got: ${e[1].type}`);return{argTypes:[e[0],t[0]],returnType:e[0]}},normalImpl:n,codegenImpl:(e,t)=>o`subgroupShuffleDown(${e}, ${t})`}),Yr=r({name:"subgroupShuffleUp",signature:(...e)=>{let t=g([e[1]],[u]);if(!t)throw new Error(`subgroupShuffleUp's second argument has to be compatible with u32. Got: ${e[1].type}`);return{argTypes:[e[0],t[0]],returnType:e[0]}},normalImpl:n,codegenImpl:(e,t)=>o`subgroupShuffleUp(${e}, ${t})`}),jr=r({name:"subgroupShuffleXor",signature:(...e)=>{let t=g([e[1]],[u]);if(!t)throw new Error(`subgroupShuffleXor's second argument has to be compatible with u32. Got: ${e[1].type}`);return{argTypes:[e[0],t[0]],returnType:e[0]}},normalImpl:n,codegenImpl:(e,t)=>o`subgroupShuffleXor(${e}, ${t})`}),qr=r({name:"subgroupXor",signature:e=>({argTypes:[e],returnType:e}),normalImpl:n,codegenImpl:e=>o`subgroupXor(${e})`});var zr=U(e=>{let t=F();if(!t)throw new Error("Functions using `extensionEnabled` cannot be called directly. Either generate WGSL from them, or use tgpu['~unstable'].simulate(...)");if(typeof e!="string"||!R.includes(e))throw new Error(`extensionEnabled has to be called with a string literal representing a valid WGSL extension name. Got: '${e}'`);return(t.enableExtensions??[]).includes(e)});export{ee as abs,te as acos,re as acosh,z as add,St as all,ct as allEq,ht as and,Ct as any,lr as arrayLength,oe as asin,ne as asinh,ue as atan,se as atan2,ae as atanh,zt as atomicAdd,Qt as atomicAnd,Yt as atomicLoad,Jt as atomicMax,Kt as atomicMin,er as atomicOr,qt as atomicStore,Ht as atomicSub,tr as atomicXor,st as bitcastU32toF32,pt as bitcastU32toI32,pe as ceil,me as clamp,ie as cos,le as cosh,de as countLeadingZeros,ce as countOneBits,xe as countTrailingZeros,fe as cross,ge as degrees,Te as determinant,wt as discard,ye as distance,J as div,be as dot,Ie as dot4I8Packed,ve as dot4U8Packed,rr as dpdx,or as dpdxCoarse,nr as dpdxFine,ur as dpdy,ar as dpdyCoarse,sr as dpdyFine,xt as eq,he as exp,Se as exp2,zr as extensionEnabled,Ce as extractBits,Ae as faceForward,$e as firstLeadingBit,we as firstTrailingBit,De as floor,Ee as fma,Le as fract,Oe as frexp,pr as fwidth,mr as fwidthCoarse,ir as fwidthFine,bt as ge,yt as gt,Y as identity2,j as identity3,q as identity4,Be as insertBits,We as inverseSqrt,At as isCloseTo,Fe as ldexp,Tt as le,Ve as length,_e as log,Me as log2,gt as lt,Ne as max,Ge as min,Pe as mix,K as mod,Ue as modf,O as mul,ft as ne,Q as neg,Xe as normalize,vt as not,It as or,it as pack2x16float,dt as pack4x8unorm,ke as pow,Re as quantizeToF16,Ze as radians,Ye as reflect,je as refract,qe as reverseBits,Pt as rotateX4,Ut as rotateY4,Xt as rotateZ4,A as rotationX4,$ as rotationY4,w as rotationZ4,ze as round,He as saturate,Gt as scale4,C as scaling4,$t as select,Je as sign,Ke as sin,Qe as sinh,et as smoothstep,tt as sqrt,rt as step,Rt as storageBarrier,H as sub,Dr as subgroupAdd,Or as subgroupAll,Br as subgroupAnd,Wr as subgroupAny,Fr as subgroupBallot,Vr as subgroupBroadcast,_r as subgroupBroadcastFirst,Mr as subgroupElect,Er as subgroupExclusiveAdd,Ur as subgroupExclusiveMul,Lr as subgroupInclusiveAdd,Xr as subgroupInclusiveMul,Nr as subgroupMax,Gr as subgroupMin,Pr as subgroupMul,kr as subgroupOr,Rr as subgroupShuffle,Zr as subgroupShuffleDown,Yr as subgroupShuffleUp,jr as subgroupShuffleXor,qr as subgroupXor,ot as tan,nt as tanh,Zt as textureBarrier,Sr as textureDimensions,br as textureLoad,cr as textureSample,wr as textureSampleBaseClampToEdge,fr as textureSampleBias,Ar as textureSampleCompare,Tr as textureSampleLevel,Ir as textureStore,Nt as translate4,S as translation4,ut as transpose,at as trunc,mt as unpack2x16float,lt as unpack4x8unorm,kt as workgroupBarrier};
2
2
  //# sourceMappingURL=index.js.map
package/std/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/std/discard.ts","../../src/std/matrix.ts","../../src/std/atomic.ts","../../src/std/derivative.ts","../../src/std/array.ts","../../src/std/texture.ts","../../src/std/subgroup.ts","../../src/std/extensions.ts"],"sourcesContent":["import { snip } from '../data/snippet.ts';\nimport { Void } from '../data/wgslTypes.ts';\nimport { createDualImpl } from '../core/function/dualImpl.ts';\n\nexport const discard = createDualImpl(\n // CPU\n (): never => {\n throw new Error(\n '`discard` relies on GPU resources and cannot be executed outside of a draw call',\n );\n },\n // GPU\n () => snip('discard;', Void),\n 'discard',\n);\n","import { stitch } from '../core/resolve/stitch.ts';\nimport { snip } from '../data/snippet.ts';\nimport {\n rotationX4,\n rotationY4,\n rotationZ4,\n scaling4,\n translation4,\n} from '../data/matrix.ts';\nimport type { m4x4f, v3f } from '../data/wgslTypes.ts';\nimport { createDualImpl } from '../core/function/dualImpl.ts';\nimport { mul } from './operators.ts';\nimport { $internal } from '../shared/symbols.ts';\n\nconst cpuMul = mul[$internal].jsImpl;\n\nconst cpuTranslation4 = translation4[$internal].jsImpl;\nconst gpuTranslation4 = translation4[$internal].gpuImpl;\n\nconst cpuScaling4 = scaling4[$internal].jsImpl;\nconst gpuScaling4 = scaling4[$internal].gpuImpl;\n\nconst cpuRotationX4 = rotationX4[$internal].jsImpl;\nconst gpuRotationX4 = rotationX4[$internal].gpuImpl;\n\nconst cpuRotationY4 = rotationY4[$internal].jsImpl;\nconst gpuRotationY4 = rotationY4[$internal].gpuImpl;\n\nconst cpuRotationZ4 = rotationZ4[$internal].jsImpl;\nconst gpuRotationZ4 = rotationZ4[$internal].gpuImpl;\n\n/**\n * Translates the given 4-by-4 matrix by the given vector.\n * @param {m4x4f} matrix - The matrix to be modified.\n * @param {v3f} vector - The vector by which to translate the matrix.\n * @returns {m4x4f} The translated matrix.\n */\nexport const translate4 = createDualImpl(\n // CPU implementation\n (matrix: m4x4f, vector: v3f) => cpuMul(cpuTranslation4(vector), matrix),\n // GPU implementation\n (matrix, vector) =>\n snip(stitch`(${gpuTranslation4(vector)} * ${matrix})`, matrix.dataType),\n 'translate4',\n);\n\n/**\n * Scales the given 4-by-4 matrix in each dimension by an amount given by the corresponding entry in the given vector.\n * @param {m4x4f} matrix - The matrix to be modified.\n * @param {v3f} vector - A vector of three entries specifying the factor by which to scale in each dimension.\n * @returns {m4x4f} The scaled matrix.\n */\nexport const scale4 = createDualImpl(\n // CPU implementation\n (matrix: m4x4f, vector: v3f) => cpuMul(cpuScaling4(vector), matrix),\n // GPU implementation\n (matrix, vector) =>\n snip(stitch`(${(gpuScaling4(vector))} * ${matrix})`, matrix.dataType),\n 'scale4',\n);\n\n/**\n * Rotates the given 4-by-4 matrix around the x-axis by the given angle.\n * @param {m4x4f} matrix - The matrix to be modified.\n * @param {number} angle - The angle by which to rotate (in radians).\n * @returns {m4x4f} The rotated matrix.\n */\nexport const rotateX4 = createDualImpl(\n // CPU implementation\n (matrix: m4x4f, angle: number) => cpuMul(cpuRotationX4(angle), matrix),\n // GPU implementation\n (matrix, angle) =>\n snip(stitch`(${(gpuRotationX4(angle))} * ${matrix})`, matrix.dataType),\n 'rotateX4',\n);\n\n/**\n * Rotates the given 4-by-4 matrix around the y-axis by the given angle.\n * @param {m4x4f} matrix - The matrix to be modified.\n * @param {number} angle - The angle by which to rotate (in radians).\n * @returns {m4x4f} The rotated matrix.\n */\nexport const rotateY4 = createDualImpl(\n // CPU implementation\n (matrix: m4x4f, angle: number) => cpuMul(cpuRotationY4(angle), matrix),\n // GPU implementation\n (matrix, angle) =>\n snip(stitch`(${(gpuRotationY4(angle))} * ${matrix})`, matrix.dataType),\n 'rotateY4',\n);\n\n/**\n * Rotates the given 4-by-4 matrix around the z-axis by the given angle.\n * @param {m4x4f} matrix - The matrix to be modified.\n * @param {number} angle - The angle by which to rotate (in radians).\n * @returns {m4x4f} The rotated matrix.\n */\nexport const rotateZ4 = createDualImpl(\n // CPU implementation\n (matrix: m4x4f, angle: number) => cpuMul(cpuRotationZ4(angle), matrix),\n // GPU implementation\n (matrix, angle) =>\n snip(stitch`(${(gpuRotationZ4(angle))} * ${matrix})`, matrix.dataType),\n 'rotateZ4',\n);\n","import { createDualImpl } from '../core/function/dualImpl.ts';\nimport { stitch } from '../core/resolve/stitch.ts';\nimport { i32, u32 } from '../data/numeric.ts';\nimport { snip, type Snippet } from '../data/snippet.ts';\nimport {\n type AnyWgslData,\n type atomicI32,\n type atomicU32,\n isWgslData,\n Void,\n} from '../data/wgslTypes.ts';\nimport { safeStringify } from '../shared/stringify.ts';\ntype AnyAtomic = atomicI32 | atomicU32;\n\nexport const workgroupBarrier = createDualImpl(\n // CPU implementation\n () => console.warn('workgroupBarrier is a no-op outside of CODEGEN mode.'),\n // CODEGEN implementation\n () => snip('workgroupBarrier()', Void),\n 'workgroupBarrier',\n);\n\nexport const storageBarrier = createDualImpl(\n // CPU implementation\n () => console.warn('storageBarrier is a no-op outside of CODEGEN mode.'),\n // CODEGEN implementation\n () => snip('storageBarrier()', Void),\n 'storageBarrier',\n);\n\nexport const textureBarrier = createDualImpl(\n // CPU implementation\n () => console.warn('textureBarrier is a no-op outside of CODEGEN mode.'),\n // CODEGEN implementation\n () => snip('textureBarrier()', Void),\n 'textureBarrier',\n);\n\nexport const atomicLoad = createDualImpl(\n // CPU implementation\n <T extends AnyAtomic>(a: T): number => {\n throw new Error(\n 'Atomic operations are not supported outside of CODEGEN mode.',\n );\n },\n // CODEGEN implementation\n (a) => {\n if (isWgslData(a.dataType) && a.dataType.type === 'atomic') {\n return snip(stitch`atomicLoad(&${a})`, a.dataType.inner);\n }\n throw new Error(\n `Invalid atomic type: ${safeStringify(a.dataType)}`,\n );\n },\n 'atomicLoad',\n);\n\nexport const atomicStore = createDualImpl(\n // CPU implementation\n <T extends AnyAtomic>(a: T, value: number): void => {\n throw new Error(\n 'Atomic operations are not supported outside of CODEGEN mode.',\n );\n },\n // CODEGEN implementation\n (a, value) => {\n if (!isWgslData(a.dataType) || a.dataType.type !== 'atomic') {\n throw new Error(\n `Invalid atomic type: ${safeStringify(a.dataType)}`,\n );\n }\n return snip(stitch`atomicStore(&${a}, ${value})`, Void);\n },\n 'atomicStore',\n);\n\nconst atomicTypeFn = (a: Snippet, _value: Snippet): AnyWgslData[] => {\n if (a.dataType.type === 'atomic' && a.dataType.inner.type === 'i32') {\n return [a.dataType, i32];\n }\n return [a.dataType as AnyWgslData, u32];\n};\n\nexport const atomicAdd = createDualImpl(\n // CPU implementation\n <T extends AnyAtomic>(a: T, value: number): number => {\n throw new Error(\n 'Atomic operations are not supported outside of CODEGEN mode.',\n );\n },\n // CODEGEN implementation\n (a, value) => {\n if (isWgslData(a.dataType) && a.dataType.type === 'atomic') {\n return snip(stitch`atomicAdd(&${a}, ${value})`, a.dataType.inner);\n }\n throw new Error(\n `Invalid atomic type: ${safeStringify(a.dataType)}`,\n );\n },\n 'atomicAdd',\n atomicTypeFn,\n);\n\nexport const atomicSub = createDualImpl(\n // CPU implementation\n <T extends AnyAtomic>(a: T, value: number): number => {\n throw new Error(\n 'Atomic operations are not supported outside of CODEGEN mode.',\n );\n },\n // CODEGEN implementation\n (a, value) => {\n if (isWgslData(a.dataType) && a.dataType.type === 'atomic') {\n return snip(stitch`atomicSub(&${a}, ${value})`, a.dataType.inner);\n }\n throw new Error(\n `Invalid atomic type: ${safeStringify(a.dataType)}`,\n );\n },\n 'atomicSub',\n atomicTypeFn,\n);\n\nexport const atomicMax = createDualImpl(\n // CPU implementation\n <T extends AnyAtomic>(a: T, value: number): number => {\n throw new Error(\n 'Atomic operations are not supported outside of CODEGEN mode.',\n );\n },\n // CODEGEN implementation\n (a, value) => {\n if (isWgslData(a.dataType) && a.dataType.type === 'atomic') {\n return snip(stitch`atomicMax(&${a}, ${value})`, a.dataType.inner);\n }\n throw new Error(\n `Invalid atomic type: ${safeStringify(a.dataType)}`,\n );\n },\n 'atomicMax',\n atomicTypeFn,\n);\n\nexport const atomicMin = createDualImpl(\n // CPU implementation\n <T extends AnyAtomic>(a: T, value: number): number => {\n throw new Error(\n 'Atomic operations are not supported outside of CODEGEN mode.',\n );\n },\n // CODEGEN implementation\n (a, value) => {\n if (isWgslData(a.dataType) && a.dataType.type === 'atomic') {\n return snip(stitch`atomicMin(&${a}, ${value})`, a.dataType.inner);\n }\n throw new Error(\n `Invalid atomic type: ${safeStringify(a.dataType)}`,\n );\n },\n 'atomicMin',\n atomicTypeFn,\n);\n\nexport const atomicAnd = createDualImpl(\n // CPU implementation\n <T extends AnyAtomic>(a: T, value: number): number => {\n throw new Error(\n 'Atomic operations are not supported outside of CODEGEN mode.',\n );\n },\n // CODEGEN implementation\n (a, value) => {\n if (isWgslData(a.dataType) && a.dataType.type === 'atomic') {\n return snip(stitch`atomicAnd(&${a}, ${value})`, a.dataType.inner);\n }\n throw new Error(\n `Invalid atomic type: ${safeStringify(a.dataType)}`,\n );\n },\n 'atomicAnd',\n atomicTypeFn,\n);\n\nexport const atomicOr = createDualImpl(\n // CPU implementation\n <T extends AnyAtomic>(a: T, value: number): number => {\n throw new Error(\n 'Atomic operations are not supported outside of CODEGEN mode.',\n );\n },\n // CODEGEN implementation\n (a, value) => {\n if (isWgslData(a.dataType) && a.dataType.type === 'atomic') {\n return snip(stitch`atomicOr(&${a}, ${value})`, a.dataType.inner);\n }\n throw new Error(\n `Invalid atomic type: ${safeStringify(a.dataType)}`,\n );\n },\n 'atomicOr',\n atomicTypeFn,\n);\n\nexport const atomicXor = createDualImpl(\n // CPU implementation\n <T extends AnyAtomic>(a: T, value: number): number => {\n throw new Error(\n 'Atomic operations are not supported outside of CODEGEN mode.',\n );\n },\n // CODEGEN implementation\n (a, value) => {\n if (isWgslData(a.dataType) && a.dataType.type === 'atomic') {\n return snip(stitch`atomicXor(&${a}, ${value})`, a.dataType.inner);\n }\n throw new Error(\n `Invalid atomic type: ${safeStringify(a.dataType)}`,\n );\n },\n 'atomicXor',\n atomicTypeFn,\n);\n","import { createDualImpl } from '../core/function/dualImpl.ts';\nimport { stitch } from '../core/resolve/stitch.ts';\nimport { snip } from '../data/snippet.ts';\nimport type { AnyFloat32VecInstance } from '../data/wgslTypes.ts';\n\nfunction cpuDpdx(value: number): number;\nfunction cpuDpdx<T extends AnyFloat32VecInstance>(value: T): T;\nfunction cpuDpdx<T extends AnyFloat32VecInstance | number>(value: T): T {\n throw new Error('Derivative builtins are not allowed on the cpu');\n}\n\nexport const dpdx = createDualImpl(\n cpuDpdx,\n (value) => snip(stitch`dpdx(${value})`, value.dataType),\n 'dpdx',\n);\n\nfunction cpuDpdxCoarse(value: number): number;\nfunction cpuDpdxCoarse<T extends AnyFloat32VecInstance>(value: T): T;\nfunction cpuDpdxCoarse<T extends AnyFloat32VecInstance | number>(\n value: T,\n): T {\n throw new Error('Derivative builtins are not allowed on the cpu');\n}\n\nexport const dpdxCoarse = createDualImpl(\n cpuDpdxCoarse,\n (value) => snip(stitch`dpdxCoarse(${value})`, value.dataType),\n 'dpdxCoarse',\n);\n\nfunction cpuDpdxFine(value: number): number;\nfunction cpuDpdxFine<T extends AnyFloat32VecInstance>(value: T): T;\nfunction cpuDpdxFine<T extends AnyFloat32VecInstance | number>(value: T): T {\n throw new Error('Derivative builtins are not allowed on the cpu');\n}\n\nexport const dpdxFine = createDualImpl(\n cpuDpdxFine,\n (value) => snip(stitch`dpdxFine(${value})`, value.dataType),\n 'dpdxFine',\n);\n\nfunction cpuDpdy(value: number): number;\nfunction cpuDpdy<T extends AnyFloat32VecInstance>(value: T): T;\nfunction cpuDpdy<T extends AnyFloat32VecInstance | number>(value: T): T {\n throw new Error('Derivative builtins are not allowed on the cpu');\n}\n\nexport const dpdy = createDualImpl(\n cpuDpdy,\n (value) => snip(stitch`dpdy(${value})`, value.dataType),\n 'dpdy',\n);\n\nfunction cpuDpdyCoarse(value: number): number;\nfunction cpuDpdyCoarse<T extends AnyFloat32VecInstance>(value: T): T;\nfunction cpuDpdyCoarse<T extends AnyFloat32VecInstance | number>(\n value: T,\n): T {\n throw new Error('Derivative builtins are not allowed on the cpu');\n}\n\nexport const dpdyCoarse = createDualImpl(\n cpuDpdyCoarse,\n (value) => snip(stitch`dpdyCoarse(${value})`, value.dataType),\n 'dpdyCoarse',\n);\n\nfunction cpuDpdyFine(value: number): number;\nfunction cpuDpdyFine<T extends AnyFloat32VecInstance>(value: T): T;\nfunction cpuDpdyFine<T extends AnyFloat32VecInstance | number>(value: T): T {\n throw new Error('Derivative builtins are not allowed on the cpu');\n}\n\nexport const dpdyFine = createDualImpl(\n cpuDpdyFine,\n (value) => snip(stitch`dpdyFine(${value})`, value.dataType),\n 'dpdyFine',\n);\n\nfunction cpuFwidth(value: number): number;\nfunction cpuFwidth<T extends AnyFloat32VecInstance>(value: T): T;\nfunction cpuFwidth<T extends AnyFloat32VecInstance | number>(value: T): T {\n throw new Error('Derivative builtins are not allowed on the cpu');\n}\n\nexport const fwidth = createDualImpl(\n cpuFwidth,\n (value) => snip(stitch`fwidth(${value})`, value.dataType),\n 'fwidth',\n);\n\nfunction cpuFwidthCoarse(value: number): number;\nfunction cpuFwidthCoarse<T extends AnyFloat32VecInstance>(value: T): T;\nfunction cpuFwidthCoarse<T extends AnyFloat32VecInstance | number>(\n value: T,\n): T {\n throw new Error('Derivative builtins are not allowed on the cpu');\n}\n\nexport const fwidthCoarse = createDualImpl(\n cpuFwidthCoarse,\n (value) => snip(stitch`fwidthCoarse(${value})`, value.dataType),\n 'fwidthCoarse',\n);\n\nfunction cpuFwidthFine(value: number): number;\nfunction cpuFwidthFine<T extends AnyFloat32VecInstance>(value: T): T;\nfunction cpuFwidthFine<T extends AnyFloat32VecInstance | number>(\n value: T,\n): T {\n throw new Error('Derivative builtins are not allowed on the cpu');\n}\n\nexport const fwidthFine = createDualImpl(\n cpuFwidthFine,\n (value) => snip(stitch`fwidthFine(${value})`, value.dataType),\n 'fwidthFine',\n);\n","import { dualImpl } from '../core/function/dualImpl.ts';\nimport { stitch } from '../core/resolve/stitch.ts';\nimport { abstractInt, u32 } from '../data/numeric.ts';\nimport { ptrFn } from '../data/ptr.ts';\nimport { isPtr, isWgslArray, type StorableData } from '../data/wgslTypes.ts';\n\nconst sizeOfPointedToArray = (dataType: unknown) =>\n isPtr(dataType) && isWgslArray(dataType.inner)\n ? dataType.inner.elementCount\n : 0;\n\nexport const arrayLength = dualImpl({\n name: 'arrayLength',\n signature: (arg) => {\n const ptrArg = isPtr(arg) ? arg : ptrFn(arg as StorableData);\n return ({\n argTypes: [ptrArg],\n returnType: sizeOfPointedToArray(ptrArg) > 0 ? abstractInt : u32,\n });\n },\n normalImpl: (a: unknown[]) => a.length,\n codegenImpl(a) {\n const length = sizeOfPointedToArray(a.dataType);\n return length > 0 ? String(length) : stitch`arrayLength(${a})`;\n },\n});\n","import { stitch } from '../core/resolve/stitch.ts';\nimport {\n isWgslTexture,\n type WgslExternalTexture,\n type WgslStorageTexture,\n type WgslTexture,\n} from '../data/texture.ts';\nimport type { TexelData } from '../core/texture/texture.ts';\nimport { dualImpl } from '../core/function/dualImpl.ts';\nimport { f32, u32 } from '../data/numeric.ts';\nimport { vec2u, vec3u, vec4f, vec4i, vec4u } from '../data/vector.ts';\nimport {\n type v2f,\n type v2i,\n type v2u,\n type v3f,\n type v3i,\n type v3u,\n type v4f,\n type v4i,\n type v4u,\n Void,\n} from '../data/wgslTypes.ts';\nimport {\n type StorageTextureFormats,\n type TextureFormats,\n textureFormats,\n} from '../core/texture/textureFormats.ts';\nimport type { $internal, $repr } from '../shared/symbols.ts';\nimport type {\n texture1d,\n texture2d,\n texture2dArray,\n texture3d,\n textureCube,\n textureCubeArray,\n textureDepth2d,\n textureDepth2dArray,\n textureDepthCube,\n textureExternal,\n textureMultisampled2d,\n textureStorage1d,\n textureStorage2d,\n textureStorage2dArray,\n textureStorage3d,\n} from '../data/texture.ts';\n\nimport type { AnyData } from '../data/dataTypes.ts';\nimport type { comparisonSampler, sampler } from '../data/sampler.ts';\n\nfunction sampleCpu<T extends texture1d>(\n texture: T,\n sampler: sampler,\n coords: number,\n): v4f;\nfunction sampleCpu<T extends texture2d>(\n texture: T,\n sampler: sampler,\n coords: v2f,\n offset?: v2i,\n): v4f;\nfunction sampleCpu<T extends texture2dArray>(\n texture: T,\n sampler: sampler,\n coords: v2f,\n arrayIndex: number,\n offset?: v2i,\n): v4f;\nfunction sampleCpu<T extends texture3d | textureCube>(\n texture: T,\n sampler: sampler,\n coords: v3f,\n): v4f;\nfunction sampleCpu<T extends texture3d>(\n texture: T,\n sampler: sampler,\n coords: v3f,\n offset: v3i,\n): v4f;\nfunction sampleCpu<T extends textureCubeArray>(\n texture: T,\n sampler: sampler,\n coords: v3f,\n arrayIndex: number,\n): v4f;\nfunction sampleCpu<T extends textureDepth2d>(\n texture: T,\n sampler: sampler,\n coords: v2f,\n offset?: v2i,\n): number;\nfunction sampleCpu<T extends textureDepth2dArray>(\n texture: T,\n sampler: sampler,\n coords: v2f,\n arrayIndex: number,\n offset?: v2i,\n): number;\nfunction sampleCpu<T extends textureDepthCube>(\n texture: T,\n sampler: sampler,\n coords: v3f,\n arrayIndex?: number,\n): number;\nfunction sampleCpu(\n _texture: WgslTexture,\n _sampler: sampler,\n _coords: number | v2f | v3f,\n _offsetOrArrayIndex?: v2i | v3i | number,\n _maybeOffset?: v2i | v3i,\n): v4f | number {\n throw new Error(\n 'Texture sampling relies on GPU resources and cannot be executed outside of a draw call',\n );\n}\n\nexport const textureSample = dualImpl({\n name: 'textureSample',\n normalImpl: sampleCpu,\n codegenImpl: (...args) => stitch`textureSample(${args})`,\n signature: (...args) => {\n const isDepth = (args[0] as WgslTexture).type.startsWith('texture_depth');\n return {\n argTypes: args as AnyData[],\n returnType: isDepth ? f32 : vec4f,\n };\n },\n});\n\nfunction sampleBiasCpu<T extends texture1d>(\n texture: T,\n sampler: sampler,\n coords: number,\n bias: number,\n): v4f;\nfunction sampleBiasCpu<T extends texture2d>(\n texture: T,\n sampler: sampler,\n coords: v2f,\n bias: number,\n offset?: v2i,\n): v4f;\nfunction sampleBiasCpu<T extends texture2dArray>(\n texture: T,\n sampler: sampler,\n coords: v2f,\n arrayIndex: number,\n bias: number,\n offset?: v2i,\n): v4f;\nfunction sampleBiasCpu<T extends texture3d | textureCube>(\n texture: T,\n sampler: sampler,\n coords: v3f,\n bias: number,\n offset?: v3i,\n): v4f;\nfunction sampleBiasCpu<T extends textureCubeArray>(\n texture: T,\n sampler: sampler,\n coords: v3f,\n arrayIndex: number,\n bias: number,\n): v4f;\nfunction sampleBiasCpu(\n _texture: WgslTexture,\n _sampler: sampler,\n _coords: number | v2f | v3f,\n _biasOrArrayIndex: number,\n _biasOrOffset?: number | v2i | v3i,\n _maybeOffset?: v2i | v3i,\n): v4f {\n throw new Error(\n 'Texture sampling with bias relies on GPU resources and cannot be executed outside of a draw call',\n );\n}\n\nexport const textureSampleBias = dualImpl({\n name: 'textureSampleBias',\n normalImpl: sampleBiasCpu,\n codegenImpl: (...args) => stitch`textureSampleBias(${args})`,\n signature: (...args) => ({\n argTypes: args as AnyData[],\n returnType: vec4f,\n }),\n});\n\nfunction sampleLevelCpu<T extends texture1d>(\n texture: T,\n sampler: sampler,\n coords: number,\n level: number,\n): v4f;\nfunction sampleLevelCpu<T extends texture2d>(\n texture: T,\n sampler: sampler,\n coords: v2f,\n level: number,\n): v4f;\nfunction sampleLevelCpu<T extends texture2d>(\n texture: T,\n sampler: sampler,\n coords: v2f,\n level: number,\n offset: v2i,\n): v4f;\nfunction sampleLevelCpu<T extends texture2dArray>(\n texture: T,\n sampler: sampler,\n coords: v2f,\n arrayIndex: number,\n level: number,\n): v4f;\nfunction sampleLevelCpu<T extends texture2dArray>(\n texture: T,\n sampler: sampler,\n coords: v2f,\n arrayIndex: number,\n level: number,\n offset: v2i,\n): v4f;\nfunction sampleLevelCpu<T extends texture3d | textureCube>(\n texture: T,\n sampler: sampler,\n coords: v3f,\n level: number,\n): v4f;\nfunction sampleLevelCpu<T extends texture3d>(\n texture: T,\n sampler: sampler,\n coords: v3f,\n level: number,\n offset: v3i,\n): v4f;\nfunction sampleLevelCpu<T extends textureCubeArray>(\n texture: T,\n sampler: sampler,\n coords: v3f,\n arrayIndex: number,\n level: number,\n): v4f;\nfunction sampleLevelCpu<T extends textureDepth2d>(\n texture: T,\n sampler: sampler,\n coords: v2f,\n level: number,\n): number;\nfunction sampleLevelCpu<T extends textureDepth2d>(\n texture: T,\n sampler: sampler,\n coords: v2f,\n level: number,\n offset: v2i,\n): number;\nfunction sampleLevelCpu<T extends textureDepth2dArray>(\n texture: T,\n sampler: sampler,\n coords: v2f,\n arrayIndex: number,\n level: number,\n): number;\nfunction sampleLevelCpu<T extends textureDepth2dArray>(\n texture: T,\n sampler: sampler,\n coords: v2f,\n arrayIndex: number,\n level: number,\n offset: v2i,\n): number;\nfunction sampleLevelCpu<T extends textureDepthCube>(\n texture: T,\n sampler: sampler,\n coords: v3f,\n level: number,\n): number;\nfunction sampleLevelCpu<T extends textureCubeArray>(\n texture: T,\n sampler: sampler,\n coords: v3f,\n arrayIndex: number,\n level: number,\n): number;\nfunction sampleLevelCpu(\n _texture: WgslTexture,\n _sampler: sampler,\n _coords: number | v2f | v3f,\n _level: number,\n _offsetOrArrayIndex?: v2i | v3i | number,\n _maybeOffset?: v2i | v3i,\n): v4f | number {\n throw new Error(\n 'Texture sampling relies on GPU resources and cannot be executed outside of a draw call',\n );\n}\n\nexport const textureSampleLevel = dualImpl({\n name: 'textureSampleLevel',\n normalImpl: sampleLevelCpu,\n codegenImpl: (...args) => stitch`textureSampleLevel(${args})`,\n signature: (...args) => {\n const isDepth = (args[0] as WgslTexture).type.startsWith('texture_depth');\n return {\n argTypes: args,\n returnType: isDepth ? f32 : vec4f,\n };\n },\n});\n\ntype PrimitiveToLoadedType = {\n f32: v4f;\n i32: v4i;\n u32: v4u;\n};\n\ntype TexelFormatToInstanceType<T extends StorageTextureFormats> =\n TextureFormats[T]['vectorType'][typeof $repr];\n\nfunction textureLoadCpu<T extends texture1d>(\n texture: T,\n coords: number,\n level: number,\n): PrimitiveToLoadedType[T[typeof $internal]['type']];\nfunction textureLoadCpu<T extends texture2d>(\n texture: T,\n coords: v2i | v2u,\n level: number,\n): PrimitiveToLoadedType[T[typeof $internal]['type']];\nfunction textureLoadCpu<T extends texture2dArray>(\n texture: T,\n coords: v2i | v2u,\n arrayIndex: number,\n level: number,\n): PrimitiveToLoadedType[T[typeof $internal]['type']];\nfunction textureLoadCpu<T extends texture3d>(\n texture: T,\n coords: v3i | v3u,\n level: number,\n): PrimitiveToLoadedType[T[typeof $internal]['type']];\nfunction textureLoadCpu<T extends textureMultisampled2d>(\n texture: T,\n coords: v2i | v2u,\n sampleIndex: number,\n): PrimitiveToLoadedType[T[typeof $internal]['type']];\nfunction textureLoadCpu<T extends textureStorage1d>(\n texture: T,\n coords: number,\n): TexelFormatToInstanceType<T[typeof $internal][0]>;\nfunction textureLoadCpu<T extends textureStorage2d>(\n texture: T,\n coords: v2i | v2u,\n): TexelFormatToInstanceType<T[typeof $internal][0]>;\nfunction textureLoadCpu<T extends textureStorage2dArray>(\n texture: T,\n coords: v2i | v2u,\n arrayIndex: number,\n): TexelFormatToInstanceType<T[typeof $internal][0]>;\nfunction textureLoadCpu<T extends textureStorage3d>(\n texture: T,\n coords: v3i | v3u,\n): TexelFormatToInstanceType<T[typeof $internal][0]>;\nfunction textureLoadCpu(\n _texture: WgslTexture | WgslStorageTexture,\n _coords: number | v2i | v2u | v3i | v3u,\n _levelOrArrayIndex?: number,\n): TexelData {\n throw new Error(\n '`textureLoad` relies on GPU resources and cannot be executed outside of a draw call',\n );\n}\n\nexport const textureLoad = dualImpl({\n name: 'textureLoad',\n normalImpl: textureLoadCpu,\n codegenImpl: (...args) => stitch`textureLoad(${args})`,\n signature: (...args) => {\n const texture = args[0] as WgslTexture | WgslStorageTexture;\n if (isWgslTexture(texture)) {\n const isDepth = texture.type.startsWith('texture_depth');\n const sampleType = texture.sampleType;\n return {\n argTypes: args,\n returnType: isDepth\n ? f32\n : sampleType.type === 'f32'\n ? vec4f\n : sampleType.type === 'u32'\n ? vec4u\n : vec4i,\n };\n }\n const format = texture.format;\n const dataType = textureFormats[format].vectorType;\n return {\n argTypes: args,\n returnType: dataType,\n };\n },\n});\n\nfunction textureStoreCpu<T extends textureStorage1d>(\n texture: T,\n coords: number,\n value: TexelFormatToInstanceType<T[typeof $internal][0]>,\n): void;\nfunction textureStoreCpu<T extends textureStorage2d>(\n texture: T,\n coords: v2i | v2u,\n value: TexelFormatToInstanceType<T[typeof $internal][0]>,\n): void;\nfunction textureStoreCpu<T extends textureStorage2dArray>(\n texture: T,\n coords: v2i | v2u,\n arrayIndex: number,\n value: TexelFormatToInstanceType<T[typeof $internal][0]>,\n): void;\nfunction textureStoreCpu<T extends textureStorage3d>(\n texture: T,\n coords: v3i | v3u,\n value: TexelFormatToInstanceType<T[typeof $internal][0]>,\n): void;\nfunction textureStoreCpu(\n _texture: WgslStorageTexture,\n _coords: number | v2i | v2u | v3i | v3u,\n _arrayIndexOrValue?: number | TexelData,\n _maybeValue?: TexelData,\n): void {\n throw new Error(\n '`textureStore` relies on GPU resources and cannot be executed outside of a draw call',\n );\n}\n\nexport const textureStore = dualImpl({\n name: 'textureStore',\n normalImpl: textureStoreCpu,\n codegenImpl: (...args) => stitch`textureStore(${args})`,\n signature: (...args) => ({ argTypes: args, returnType: Void }),\n});\n\nfunction textureDimensionsCpu<T extends texture1d | textureStorage1d>(\n texture: T,\n): number;\nfunction textureDimensionsCpu<T extends texture1d>(\n texture: T,\n level: number,\n): number;\nfunction textureDimensionsCpu<\n T extends\n | texture2d\n | texture2dArray\n | textureCube\n | textureCubeArray\n | textureStorage2d\n | textureStorage2dArray\n | textureExternal,\n>(texture: T): v2u;\nfunction textureDimensionsCpu<\n T extends\n | texture2d\n | texture2dArray\n | textureCube\n | textureCubeArray,\n>(texture: T, level: number): v2u;\nfunction textureDimensionsCpu<T extends texture3d | textureStorage3d>(\n texture: T,\n): v3u;\nfunction textureDimensionsCpu<T extends texture3d>(\n texture: T,\n level: number,\n): v3u;\nfunction textureDimensionsCpu(\n _texture: WgslTexture | WgslStorageTexture | WgslExternalTexture,\n _level?: number,\n): number | v2u | v3u {\n throw new Error(\n '`textureDimensions` relies on GPU resources and cannot be executed outside of a draw call',\n );\n}\n\nexport const textureDimensions = dualImpl({\n name: 'textureDimensions',\n normalImpl: textureDimensionsCpu,\n codegenImpl: (...args) => stitch`textureDimensions(${args})`,\n signature: (...args) => {\n const dim = (\n args[0] as WgslTexture | WgslStorageTexture | WgslExternalTexture\n ).dimension;\n if (dim === '1d') {\n return {\n argTypes: args,\n returnType: u32,\n };\n }\n if (dim === '3d') {\n return {\n argTypes: args,\n returnType: vec3u,\n };\n }\n return {\n argTypes: args,\n returnType: vec2u,\n };\n },\n});\n\nfunction textureSampleCompareCpu<T extends textureDepth2d>(\n texture: T,\n sampler: comparisonSampler,\n coords: v2f,\n depthRef: number,\n): number;\nfunction textureSampleCompareCpu<T extends textureDepth2d>(\n texture: T,\n sampler: comparisonSampler,\n coords: v2f,\n depthRef: number,\n offset: v2i,\n): number;\nfunction textureSampleCompareCpu<T extends textureDepth2dArray>(\n texture: T,\n sampler: comparisonSampler,\n coords: v2f,\n arrayIndex: number,\n depthRef: number,\n): number;\nfunction textureSampleCompareCpu<T extends textureDepth2dArray>(\n texture: T,\n sampler: comparisonSampler,\n coords: v2f,\n arrayIndex: number,\n depthRef: number,\n offset: v2i,\n): number;\nfunction textureSampleCompareCpu<T extends textureDepthCube>(\n texture: T,\n sampler: comparisonSampler,\n coords: v3f,\n depthRef: number,\n): number;\nfunction textureSampleCompareCpu<T extends textureCubeArray>(\n texture: T,\n sampler: comparisonSampler,\n coords: v3f,\n arrayIndex: number,\n depthRef: number,\n): number;\nfunction textureSampleCompareCpu(\n _texture: WgslTexture,\n _sampler: comparisonSampler,\n _coords: v2f | v3f,\n _depthRefOrArrayIndex: number,\n _depthRefOrOffset?: number | v2i,\n _maybeOffset?: v2i,\n): number {\n throw new Error(\n 'Texture comparison sampling relies on GPU resources and cannot be executed outside of a draw call',\n );\n}\n\nexport const textureSampleCompare = dualImpl({\n name: 'textureSampleCompare',\n normalImpl: textureSampleCompareCpu,\n codegenImpl: (...args) => stitch`textureSampleCompare(${args})`,\n signature: (...args) => ({\n argTypes: args,\n returnType: f32,\n }),\n});\n\nfunction textureSampleBaseClampToEdgeCpu<\n T extends texture2d | textureExternal,\n>(texture: T, sampler: sampler, coords: v2f): v4f {\n throw new Error(\n 'Texture sampling with base clamp to edge is not supported outside of GPU mode.',\n );\n}\n\nexport const textureSampleBaseClampToEdge = dualImpl({\n name: 'textureSampleBaseClampToEdge',\n normalImpl: textureSampleBaseClampToEdgeCpu,\n codegenImpl: (...args) => stitch`textureSampleBaseClampToEdge(${args})`,\n signature: (...args) => ({\n argTypes: args,\n returnType: vec4f,\n }),\n});\n","import { dualImpl } from '../core/function/dualImpl.ts';\nimport { stitch } from '../core/resolve/stitch.ts';\nimport { bool, i32, u32 } from '../data/numeric.ts';\nimport { vec4u } from '../data/vector.ts';\nimport type {\n AnyIntegerVecInstance,\n AnyNumericVecInstance,\n AnyWgslData,\n v4u,\n} from '../data/wgslTypes.ts';\nimport { unify } from '../tgsl/conversion.ts';\n\ninterface IdentityNumOrVec {\n (e: number): number;\n <T extends AnyNumericVecInstance>(e: T): T;\n}\n\ninterface IdentityIntNumOrVec {\n (e: number): number;\n <T extends AnyIntegerVecInstance>(e: T): T;\n}\n\ninterface IdentityNumOrVecWithIdx {\n (e: number, index: number): number;\n <T extends AnyNumericVecInstance>(e: T, index: number): T;\n}\n\ninterface IdentityNumOrVecWithDelta {\n (e: number, delta: number): number;\n <T extends AnyNumericVecInstance>(e: T, delta: number): T;\n}\n\ninterface IdentityNumOrVecWithMask {\n (e: number, mask: number): number;\n <T extends AnyNumericVecInstance>(e: T, mask: number): T;\n}\n\nconst errorMessage = 'Subgroup operations can only be used in the GPU context.';\n\nexport const subgroupAdd = dualImpl<IdentityNumOrVec>({\n name: 'subgroupAdd',\n signature: (arg) => ({ argTypes: [arg], returnType: arg }),\n normalImpl: errorMessage,\n codegenImpl: (arg) => stitch`subgroupAdd(${arg})`,\n});\n\nexport const subgroupExclusiveAdd = dualImpl<IdentityNumOrVec>({\n name: 'subgroupExclusiveAdd',\n signature: (arg) => ({ argTypes: [arg], returnType: arg }),\n normalImpl: errorMessage,\n codegenImpl: (arg) => stitch`subgroupExclusiveAdd(${arg})`,\n});\n\nexport const subgroupInclusiveAdd = dualImpl<IdentityNumOrVec>({\n name: 'subgroupInclusiveAdd',\n signature: (arg) => ({ argTypes: [arg], returnType: arg }),\n normalImpl: errorMessage,\n codegenImpl: (arg) => stitch`subgroupInclusiveAdd(${arg})`,\n});\n\nexport const subgroupAll = dualImpl<(e: boolean) => boolean>({\n name: 'subgroupAll',\n signature: { argTypes: [bool], returnType: bool },\n normalImpl: errorMessage,\n codegenImpl: (e) => stitch`subgroupAll(${e})`,\n});\n\nexport const subgroupAnd = dualImpl<IdentityIntNumOrVec>({\n name: 'subgroupAnd',\n signature: (arg) => ({ argTypes: [arg], returnType: arg }),\n normalImpl: errorMessage,\n codegenImpl: (e) => stitch`subgroupAnd(${e})`,\n});\n\nexport const subgroupAny = dualImpl<(e: boolean) => boolean>({\n name: 'subgroupAny',\n signature: { argTypes: [bool], returnType: bool },\n normalImpl: errorMessage,\n codegenImpl: (e) => stitch`subgroupAny(${e})`,\n});\n\nexport const subgroupBallot = dualImpl<(e: boolean) => v4u>({\n name: 'subgroupBallot',\n signature: { argTypes: [bool], returnType: vec4u },\n normalImpl: errorMessage,\n codegenImpl: (e) => stitch`subgroupBallot(${e})`,\n});\n\nexport const subgroupBroadcast = dualImpl<IdentityNumOrVecWithIdx>({\n name: 'subgroupBroadcast',\n signature: (...args) => {\n const id = unify([args[1]] as [AnyWgslData], [i32, u32]);\n if (!id) {\n throw new Error(\n `subgroupBroadcast's second argument has to be compatible with i32 or u32. Got: ${\n args[1].type\n }`,\n );\n }\n return { argTypes: [args[0], id[0]], returnType: args[0] };\n },\n normalImpl: errorMessage,\n codegenImpl: (e, index) => stitch`subgroupBroadcast(${e}, ${index})`,\n});\n\nexport const subgroupBroadcastFirst = dualImpl<IdentityNumOrVec>({\n name: 'subgroupBroadcastFirst',\n signature: (arg) => ({ argTypes: [arg], returnType: arg }),\n normalImpl: errorMessage,\n codegenImpl: (e) => stitch`subgroupBroadcastFirst(${e})`,\n});\n\nexport const subgroupElect = dualImpl<() => boolean>({\n name: 'subgroupElect',\n signature: { argTypes: [], returnType: bool },\n normalImpl: errorMessage,\n codegenImpl: () => stitch`subgroupElect()`,\n});\n\nexport const subgroupMax = dualImpl<IdentityNumOrVec>({\n name: 'subgroupMax',\n signature: (arg) => ({ argTypes: [arg], returnType: arg }),\n normalImpl: errorMessage,\n codegenImpl: (arg) => stitch`subgroupMax(${arg})`,\n});\n\nexport const subgroupMin = dualImpl<IdentityNumOrVec>({\n name: 'subgroupMin',\n signature: (arg) => ({ argTypes: [arg], returnType: arg }),\n normalImpl: errorMessage,\n codegenImpl: (arg) => stitch`subgroupMin(${arg})`,\n});\n\nexport const subgroupMul = dualImpl<IdentityNumOrVec>({\n name: 'subgroupMul',\n signature: (arg) => ({ argTypes: [arg], returnType: arg }),\n normalImpl: errorMessage,\n codegenImpl: (arg) => stitch`subgroupMul(${arg})`,\n});\n\nexport const subgroupExclusiveMul = dualImpl<IdentityNumOrVec>({\n name: 'subgroupExclusiveMul',\n signature: (arg) => ({ argTypes: [arg], returnType: arg }),\n normalImpl: errorMessage,\n codegenImpl: (arg) => stitch`subgroupExclusiveMul(${arg})`,\n});\n\nexport const subgroupInclusiveMul = dualImpl<IdentityNumOrVec>({\n name: 'subgroupInclusiveMul',\n signature: (arg) => ({ argTypes: [arg], returnType: arg }),\n normalImpl: errorMessage,\n codegenImpl: (arg) => stitch`subgroupInclusiveMul(${arg})`,\n});\n\nexport const subgroupOr = dualImpl<IdentityIntNumOrVec>({\n name: 'subgroupOr',\n signature: (arg) => ({ argTypes: [arg], returnType: arg }),\n normalImpl: errorMessage,\n codegenImpl: (e) => stitch`subgroupOr(${e})`,\n});\n\nexport const subgroupShuffle = dualImpl<IdentityNumOrVecWithIdx>({\n name: 'subgroupShuffle',\n signature: (...args) => {\n const id = unify([args[1]] as [AnyWgslData], [i32, u32]);\n if (!id) {\n throw new Error(\n `subgroupShuffle's second argument has to be compatible with i32 or u32. Got: ${\n args[1].type\n }`,\n );\n }\n return { argTypes: [args[0], id[0]], returnType: args[0] };\n },\n normalImpl: errorMessage,\n codegenImpl: (e, index) => stitch`subgroupShuffle(${e}, ${index})`,\n});\n\nexport const subgroupShuffleDown = dualImpl<IdentityNumOrVecWithDelta>({\n name: 'subgroupShuffleDown',\n signature: (...args) => {\n const delta = unify([args[1]] as [AnyWgslData], [u32]);\n if (!delta) {\n throw new Error(\n `subgroupShuffleDown's second argument has to be compatible with u32. Got: ${\n args[1].type\n }`,\n );\n }\n return { argTypes: [args[0], delta[0]], returnType: args[0] };\n },\n normalImpl: errorMessage,\n codegenImpl: (e, delta) => stitch`subgroupShuffleDown(${e}, ${delta})`,\n});\n\nexport const subgroupShuffleUp = dualImpl<IdentityNumOrVecWithDelta>({\n name: 'subgroupShuffleUp',\n signature: (...args) => {\n const delta = unify([args[1]] as [AnyWgslData], [u32]);\n if (!delta) {\n throw new Error(\n `subgroupShuffleUp's second argument has to be compatible with u32. Got: ${\n args[1].type\n }`,\n );\n }\n return { argTypes: [args[0], delta[0]], returnType: args[0] };\n },\n normalImpl: errorMessage,\n codegenImpl: (e, delta) => stitch`subgroupShuffleUp(${e}, ${delta})`,\n});\n\nexport const subgroupShuffleXor = dualImpl<IdentityNumOrVecWithMask>({\n name: 'subgroupShuffleXor',\n signature: (...args) => {\n const mask = unify([args[1]] as [AnyWgslData], [u32]);\n if (!mask) {\n throw new Error(\n `subgroupShuffleXor's second argument has to be compatible with u32. Got: ${\n args[1].type\n }`,\n );\n }\n return { argTypes: [args[0], mask[0]], returnType: args[0] };\n },\n normalImpl: errorMessage,\n codegenImpl: (e, mask) => stitch`subgroupShuffleXor(${e}, ${mask})`,\n});\n\nexport const subgroupXor = dualImpl<IdentityIntNumOrVec>({\n name: 'subgroupXor',\n signature: (arg) => ({ argTypes: [arg], returnType: arg }),\n normalImpl: errorMessage,\n codegenImpl: (e) => stitch`subgroupXor(${e})`,\n});\n","import type { DualFn } from '../data/dualFn.ts';\nimport { bool } from '../data/index.ts';\nimport { snip, type Snippet } from '../data/snippet.ts';\nimport { getResolutionCtx, inCodegenMode } from '../execMode.ts';\nimport { $internal } from '../shared/symbols.ts';\nimport { type WgslExtension, wgslExtensions } from '../wgslExtensions.ts';\n\nexport const extensionEnabled: DualFn<\n (extensionName: WgslExtension) => boolean\n> = (() => {\n const jsImpl = (extensionName: WgslExtension) => {\n const resolutionCtx = getResolutionCtx();\n if (!resolutionCtx) {\n throw new Error(\n 'extensionEnabled can only be called in a GPU codegen context.',\n );\n }\n\n return (resolutionCtx.enableExtensions ?? []).includes(extensionName);\n };\n const gpuImpl = (extensionNameSnippet: Snippet) => {\n const { value } = extensionNameSnippet;\n if (\n typeof value !== 'string' ||\n !(wgslExtensions.includes(value as WgslExtension))\n ) {\n throw new Error(\n `extensionEnabled has to be called with a string literal representing a valid WGSL extension name. Got: ${value}`,\n );\n }\n return snip(jsImpl(value as WgslExtension), bool);\n };\n\n const impl = (extensionName: WgslExtension) => {\n if (inCodegenMode()) {\n return gpuImpl(extensionName as unknown as Snippet);\n }\n throw new Error(\n 'extensionEnabled can only be called in a GPU codegen context.',\n );\n };\n\n Object.defineProperty(impl, $internal, {\n value: {\n jsImpl,\n gpuImpl,\n argConversionHint: 'keep' as const,\n },\n });\n return impl;\n})() as unknown as DualFn<\n (extensionName: WgslExtension) => boolean\n>;\n"],"mappings":"unCAIO,IAAMA,GAAUC,EAErB,IAAa,CACX,MAAM,IAAI,MACR,iFACF,CACF,EAEA,IAAMC,EAAK,WAAYC,CAAI,EAC3B,SACF,ECAA,IAAMC,EAASC,EAAIC,CAAS,EAAE,OAExBC,GAAkBC,EAAaF,CAAS,EAAE,OAC1CG,GAAkBD,EAAaF,CAAS,EAAE,QAE1CI,GAAcC,EAASL,CAAS,EAAE,OAClCM,GAAcD,EAASL,CAAS,EAAE,QAElCO,GAAgBC,EAAWR,CAAS,EAAE,OACtCS,GAAgBD,EAAWR,CAAS,EAAE,QAEtCU,GAAgBC,EAAWX,CAAS,EAAE,OACtCY,GAAgBD,EAAWX,CAAS,EAAE,QAEtCa,GAAgBC,EAAWd,CAAS,EAAE,OACtCe,GAAgBD,EAAWd,CAAS,EAAE,QAQ/BgB,GAAaC,EAExB,CAACC,EAAeC,IAAgBrB,EAAOG,G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CAAsB,EAEhD,MAAM,IAAI,MACR,0GAA0GA,CAAK,EACjH,EAEF,OAAOE,EAAKR,EAAOM,CAAsB,EAAGG,CAAI,CAClD,EAEMC,EAAQT,GAAiC,CAC7C,GAAIU,EAAc,EAChB,OAAOP,EAAQH,CAAmC,EAEpD,MAAM,IAAI,MACR,+DACF,CACF,EAEA,cAAO,eAAeS,EAAME,EAAW,CACrC,MAAO,CACL,OAAAZ,EACA,QAAAI,EACA,kBAAmB,MACrB,CACF,CAAC,EACMM,CACT,GAAG","names":["discard","createDualImpl","snip","Void","cpuMul","mul","$internal","cpuTranslation4","translation4","gpuTranslation4","cpuScaling4","scaling4","gpuScaling4","cpuRotationX4","rotationX4","gpuRotationX4","cpuRotationY4","rotationY4","gpuRotationY4","cpuRotationZ4","rotationZ4","gpuRotationZ4","translate4","createDualImpl","matrix","vector","snip","stitch","scale4","rotateX4","angle","rotateY4","rotateZ4","workgroupBarrier","createDualImpl","snip","Void","storageBarrier","textureBarrier","atomicLoad","a","isWgslData","stitch","safeStringify","atomicStore","value","atomicTypeFn","_value","i32","u32","atomicAdd","atomicSub","atomicMax","atomicMin","atomicAnd","atomicOr","atomicXor","cpuDpdx","value","dpdx","createDualImpl","snip","stitch","cpuDpdxCoarse","dpdxCoarse","cpuDpdxFine","dpdxFine","cpuDpdy","dpdy","cpuDpdyCoarse","dpdyCoarse","cpuDpdyFine","dpdyFine","cpuFwidth","fwidth","cpuFwidthCoarse","fwidthCoarse","cpuFwidthFine","fwidthFine","sizeOfPointedToArray","dataType","isPtr","isWgslArray","arrayLength","dualImpl","arg","ptrArg","ptrFn","abstractInt","u32","a","length","stitch","sampleCpu","_texture","_sampler","_coords","_offsetOrArrayIndex","_maybeOffset","textureSample","dualImpl","args","stitch","isDepth","f32","vec4f","sampleBiasCpu","_biasOrArrayIndex","_biasOrOffset","textureSampleBias","sampleLevelCpu","_level","textureSampleLevel","textureLoadCpu","_levelOrArrayIndex","textureLoad","texture","isWgslTexture","sampleType","vec4u","vec4i","format","dataType","textureFormats","textureStoreCpu","_arrayIndexOrValue","_maybeValue","textureStore","Void","textureDimensionsCpu","textureDimensions","dim","u32","vec3u","vec2u","textureSampleCompareCpu","_depthRefOrArrayIndex","_depthRefOrOffset","textureSampleCompare","textureSampleBaseClampToEdgeCpu","sampler","coords","textureSampleBaseClampToEdge","errorMessage","subgroupAdd","dualImpl","arg","stitch","subgroupExclusiveAdd","subgroupInclusiveAdd","subgroupAll","bool","subgroupAnd","subgroupAny","subgroupBallot","vec4u","subgroupBroadcast","args","id","unify","i32","u32","index","subgroupBroadcastFirst","subgroupElect","subgroupMax","subgroupMin","subgroupMul","subgroupExclusiveMul","subgroupInclusiveMul","subgroupOr","subgroupShuffle","subgroupShuffleDown","delta","subgroupShuffleUp","subgroupShuffleXor","mask","subgroupXor","extensionEnabled","jsImpl","extensionName","resolutionCtx","getResolutionCtx","gpuImpl","extensionNameSnippet","value","wgslExtensions","snip","bool","impl","inCodegenMode","$internal"]}
1
+ {"version":3,"sources":["../../src/std/discard.ts","../../src/std/matrix.ts","../../src/std/atomic.ts","../../src/std/derivative.ts","../../src/std/array.ts","../../src/std/texture.ts","../../src/std/subgroup.ts","../../src/std/extensions.ts"],"sourcesContent":["import { dualImpl } from '../core/function/dualImpl.ts';\nimport { Void } from '../data/wgslTypes.ts';\n\nexport const discard = dualImpl<() => never>({\n name: 'discard',\n normalImpl:\n '`discard` relies on GPU resources and cannot be executed outside of a draw call',\n signature: { argTypes: [], returnType: Void },\n codegenImpl: () => 'discard;',\n});\n","import { stitch } from '../core/resolve/stitch.ts';\nimport {\n mat4x4f,\n rotationX4,\n rotationY4,\n rotationZ4,\n scaling4,\n translation4,\n} from '../data/matrix.ts';\nimport type { m4x4f, v3f } from '../data/wgslTypes.ts';\nimport { dualImpl } from '../core/function/dualImpl.ts';\nimport { mul } from './operators.ts';\nimport { $internal } from '../shared/symbols.ts';\nimport { vec3f } from '../data/vector.ts';\nimport { f32 } from '../data/numeric.ts';\n\nconst cpuMul = mul[$internal].jsImpl;\n\nconst cpuTranslation4 = translation4[$internal].jsImpl;\nconst gpuTranslation4 = translation4[$internal].gpuImpl;\n\nconst cpuScaling4 = scaling4[$internal].jsImpl;\nconst gpuScaling4 = scaling4[$internal].gpuImpl;\n\nconst cpuRotationX4 = rotationX4[$internal].jsImpl;\nconst gpuRotationX4 = rotationX4[$internal].gpuImpl;\n\nconst cpuRotationY4 = rotationY4[$internal].jsImpl;\nconst gpuRotationY4 = rotationY4[$internal].gpuImpl;\n\nconst cpuRotationZ4 = rotationZ4[$internal].jsImpl;\nconst gpuRotationZ4 = rotationZ4[$internal].gpuImpl;\n\n/**\n * Translates the given 4-by-4 matrix by the given vector.\n * @param {m4x4f} matrix - The matrix to be modified.\n * @param {v3f} vector - The vector by which to translate the matrix.\n * @returns {m4x4f} The translated matrix.\n */\nexport const translate4 = dualImpl({\n name: 'translate4',\n normalImpl: (matrix: m4x4f, vector: v3f) =>\n cpuMul(cpuTranslation4(vector), matrix),\n signature: { argTypes: [mat4x4f, vec3f], returnType: mat4x4f },\n codegenImpl: (matrix, vector) =>\n stitch`(${gpuTranslation4(vector)} * ${matrix})`,\n});\n\n/**\n * Scales the given 4-by-4 matrix in each dimension by an amount given by the corresponding entry in the given vector.\n * @param {m4x4f} matrix - The matrix to be modified.\n * @param {v3f} vector - A vector of three entries specifying the factor by which to scale in each dimension.\n * @returns {m4x4f} The scaled matrix.\n */\nexport const scale4 = dualImpl({\n name: 'scale4',\n normalImpl: (matrix: m4x4f, vector: v3f) =>\n cpuMul(cpuScaling4(vector), matrix),\n signature: { argTypes: [mat4x4f, vec3f], returnType: mat4x4f },\n codegenImpl: (matrix, vector) =>\n stitch`(${(gpuScaling4(vector))} * ${matrix})`,\n});\n\nconst rotateSignature = { argTypes: [mat4x4f, f32], returnType: mat4x4f };\n\n/**\n * Rotates the given 4-by-4 matrix around the x-axis by the given angle.\n * @param {m4x4f} matrix - The matrix to be modified.\n * @param {number} angle - The angle by which to rotate (in radians).\n * @returns {m4x4f} The rotated matrix.\n */\nexport const rotateX4 = dualImpl({\n name: 'rotateX4',\n normalImpl: (matrix: m4x4f, angle: number) =>\n cpuMul(cpuRotationX4(angle), matrix),\n signature: rotateSignature,\n codegenImpl: (matrix, angle) =>\n stitch`(${(gpuRotationX4(angle))} * ${matrix})`,\n});\n\n/**\n * Rotates the given 4-by-4 matrix around the y-axis by the given angle.\n * @param {m4x4f} matrix - The matrix to be modified.\n * @param {number} angle - The angle by which to rotate (in radians).\n * @returns {m4x4f} The rotated matrix.\n */\nexport const rotateY4 = dualImpl({\n name: 'rotateY4',\n normalImpl: (matrix: m4x4f, angle: number) =>\n cpuMul(cpuRotationY4(angle), matrix),\n signature: rotateSignature,\n codegenImpl: (matrix, angle) =>\n stitch`(${(gpuRotationY4(angle))} * ${matrix})`,\n});\n\n/**\n * Rotates the given 4-by-4 matrix around the z-axis by the given angle.\n * @param {m4x4f} matrix - The matrix to be modified.\n * @param {number} angle - The angle by which to rotate (in radians).\n * @returns {m4x4f} The rotated matrix.\n */\nexport const rotateZ4 = dualImpl({\n name: 'rotateZ4',\n normalImpl: (matrix: m4x4f, angle: number) =>\n cpuMul(cpuRotationZ4(angle), matrix),\n signature: rotateSignature,\n codegenImpl: (matrix, angle) =>\n stitch`(${(gpuRotationZ4(angle))} * ${matrix})`,\n});\n","import { dualImpl } from '../core/function/dualImpl.ts';\nimport { stitch } from '../core/resolve/stitch.ts';\nimport type { AnyData } from '../data/dataTypes.ts';\nimport { i32, u32 } from '../data/numeric.ts';\nimport { type atomicI32, type atomicU32, Void } from '../data/wgslTypes.ts';\nimport { safeStringify } from '../shared/stringify.ts';\ntype AnyAtomic = atomicI32 | atomicU32;\n\nexport const workgroupBarrier = dualImpl({\n name: 'workgroupBarrier',\n normalImpl: 'workgroupBarrier is a no-op outside of CODEGEN mode.',\n signature: { argTypes: [], returnType: Void },\n codegenImpl: () => 'workgroupBarrier()',\n});\n\nexport const storageBarrier = dualImpl({\n name: 'storageBarrier',\n normalImpl: 'storageBarrier is a no-op outside of CODEGEN mode.',\n signature: { argTypes: [], returnType: Void },\n codegenImpl: () => 'storageBarrier()',\n});\n\nexport const textureBarrier = dualImpl({\n name: 'textureBarrier',\n normalImpl: 'textureBarrier is a no-op outside of CODEGEN mode.',\n signature: { argTypes: [], returnType: Void },\n codegenImpl: () => 'textureBarrier()',\n});\n\nconst atomicNormalError =\n 'Atomic operations are not supported outside of CODEGEN mode.';\n\nexport const atomicLoad = dualImpl<<T extends AnyAtomic>(a: T) => number>({\n name: 'atomicLoad',\n normalImpl: atomicNormalError,\n signature: (a) => {\n if (a.type !== 'atomic') {\n throw new Error(`Invalid atomic type: ${safeStringify(a)}`);\n }\n return { argTypes: [a], returnType: a.inner };\n },\n codegenImpl: (a) => stitch`atomicLoad(&${a})`,\n});\n\nconst atomicActionSignature = (a: AnyData, param: AnyData) => {\n if (a.type !== 'atomic') {\n throw new Error(`Invalid atomic type: ${safeStringify(a)}`);\n }\n return {\n argTypes: [a, a.inner.type === 'u32' ? u32 : i32],\n returnType: Void,\n };\n};\n\nconst atomicOpSignature = (a: AnyData, param: AnyData) => {\n if (a.type !== 'atomic') {\n throw new Error(`Invalid atomic type: ${safeStringify(a)}`);\n }\n const paramType = a.inner.type === 'u32' ? u32 : i32;\n return {\n argTypes: [a, paramType],\n returnType: paramType,\n };\n};\n\nexport const atomicStore = dualImpl<\n <T extends AnyAtomic>(a: T, value: number) => void\n>({\n name: 'atomicStore',\n normalImpl: atomicNormalError,\n signature: atomicActionSignature,\n codegenImpl: (a, value) => stitch`atomicStore(&${a}, ${value})`,\n});\n\nexport const atomicAdd = dualImpl<\n <T extends AnyAtomic>(a: T, value: number) => number\n>({\n name: 'atomicAdd',\n normalImpl: atomicNormalError,\n signature: atomicOpSignature,\n codegenImpl: (a, value) => stitch`atomicAdd(&${a}, ${value})`,\n});\n\nexport const atomicSub = dualImpl<\n <T extends AnyAtomic>(a: T, value: number) => number\n>({\n name: 'atomicSub',\n normalImpl: atomicNormalError,\n signature: atomicOpSignature,\n codegenImpl: (a, value) => stitch`atomicSub(&${a}, ${value})`,\n});\n\nexport const atomicMax = dualImpl<\n <T extends AnyAtomic>(a: T, value: number) => number\n>({\n name: 'atomicMax',\n normalImpl: atomicNormalError,\n signature: atomicOpSignature,\n codegenImpl: (a, value) => stitch`atomicMax(&${a}, ${value})`,\n});\n\nexport const atomicMin = dualImpl<\n <T extends AnyAtomic>(a: T, value: number) => number\n>({\n name: 'atomicMin',\n normalImpl: atomicNormalError,\n signature: atomicOpSignature,\n codegenImpl: (a, value) => stitch`atomicMin(&${a}, ${value})`,\n});\n\nexport const atomicAnd = dualImpl<\n <T extends AnyAtomic>(a: T, value: number) => number\n>({\n name: 'atomicAnd',\n normalImpl: atomicNormalError,\n signature: atomicOpSignature,\n codegenImpl: (a, value) => stitch`atomicAnd(&${a}, ${value})`,\n});\n\nexport const atomicOr = dualImpl<\n <T extends AnyAtomic>(a: T, value: number) => number\n>({\n name: 'atomicOr',\n normalImpl: atomicNormalError,\n signature: atomicOpSignature,\n codegenImpl: (a, value) => stitch`atomicOr(&${a}, ${value})`,\n});\n\nexport const atomicXor = dualImpl<\n <T extends AnyAtomic>(a: T, value: number) => number\n>({\n name: 'atomicXor',\n normalImpl: atomicNormalError,\n signature: atomicOpSignature,\n codegenImpl: (a, value) => stitch`atomicXor(&${a}, ${value})`,\n});\n","import { dualImpl } from '../core/function/dualImpl.ts';\nimport { stitch } from '../core/resolve/stitch.ts';\nimport type { AnyFloat32VecInstance } from '../data/wgslTypes.ts';\n\ntype DerivativeSignature =\n & ((value: number) => number)\n & (<T extends AnyFloat32VecInstance>(value: T) => T);\n\nconst derivativeNormalError = 'Derivative builtins are not allowed on the CPU';\n\nexport const dpdx = dualImpl<DerivativeSignature>({\n name: 'dpdx',\n normalImpl: derivativeNormalError,\n signature: (value) => ({ argTypes: [value], returnType: value }),\n codegenImpl: (value) => stitch`dpdx(${value})`,\n});\n\nexport const dpdxCoarse = dualImpl<DerivativeSignature>({\n name: 'dpdxCoarse',\n normalImpl: derivativeNormalError,\n signature: (value) => ({ argTypes: [value], returnType: value }),\n codegenImpl: (value) => stitch`dpdxCoarse(${value})`,\n});\n\nexport const dpdxFine = dualImpl<DerivativeSignature>({\n name: 'dpdxFine',\n normalImpl: derivativeNormalError,\n signature: (value) => ({ argTypes: [value], returnType: value }),\n codegenImpl: (value) => stitch`dpdxFine(${value})`,\n});\n\nexport const dpdy = dualImpl<DerivativeSignature>({\n name: 'dpdy',\n normalImpl: derivativeNormalError,\n signature: (value) => ({ argTypes: [value], returnType: value }),\n codegenImpl: (value) => stitch`dpdy(${value})`,\n});\n\nexport const dpdyCoarse = dualImpl<DerivativeSignature>({\n name: 'dpdyCoarse',\n normalImpl: derivativeNormalError,\n signature: (value) => ({ argTypes: [value], returnType: value }),\n codegenImpl: (value) => stitch`dpdyCoarse(${value})`,\n});\n\nexport const dpdyFine = dualImpl<DerivativeSignature>({\n name: 'dpdyFine',\n normalImpl: derivativeNormalError,\n signature: (value) => ({ argTypes: [value], returnType: value }),\n codegenImpl: (value) => stitch`dpdyFine(${value})`,\n});\n\nexport const fwidth = dualImpl<DerivativeSignature>({\n name: 'fwidth',\n normalImpl: derivativeNormalError,\n signature: (value) => ({ argTypes: [value], returnType: value }),\n codegenImpl: (value) => stitch`fwidth(${value})`,\n});\n\nexport const fwidthCoarse = dualImpl<DerivativeSignature>({\n name: 'fwidthCoarse',\n normalImpl: derivativeNormalError,\n signature: (value) => ({ argTypes: [value], returnType: value }),\n codegenImpl: (value) => stitch`fwidthCoarse(${value})`,\n});\n\nexport const fwidthFine = dualImpl<DerivativeSignature>({\n name: 'fwidthFine',\n normalImpl: derivativeNormalError,\n signature: (value) => ({ argTypes: [value], returnType: value }),\n codegenImpl: (value) => stitch`fwidthFine(${value})`,\n});\n","import { dualImpl } from '../core/function/dualImpl.ts';\nimport { stitch } from '../core/resolve/stitch.ts';\nimport { abstractInt, u32 } from '../data/numeric.ts';\nimport { ptrFn } from '../data/ptr.ts';\nimport { isRef, type ref } from '../data/ref.ts';\nimport { isPtr, isWgslArray, type StorableData } from '../data/wgslTypes.ts';\n\nconst sizeOfPointedToArray = (dataType: unknown) =>\n isPtr(dataType) && isWgslArray(dataType.inner)\n ? dataType.inner.elementCount\n : 0;\n\nexport const arrayLength = dualImpl({\n name: 'arrayLength',\n signature: (arg) => {\n const ptrArg = isPtr(arg) ? arg : ptrFn(arg as StorableData);\n return ({\n argTypes: [ptrArg],\n returnType: sizeOfPointedToArray(ptrArg) > 0 ? abstractInt : u32,\n });\n },\n normalImpl: (a: unknown[] | ref<unknown[]>) =>\n isRef(a) ? a.$.length : a.length,\n codegenImpl(a) {\n const length = sizeOfPointedToArray(a.dataType);\n return length > 0 ? String(length) : stitch`arrayLength(${a})`;\n },\n});\n","import { stitch } from '../core/resolve/stitch.ts';\nimport {\n isWgslTexture,\n type WgslExternalTexture,\n type WgslStorageTexture,\n type WgslTexture,\n} from '../data/texture.ts';\nimport type { TexelData } from '../core/texture/texture.ts';\nimport { dualImpl } from '../core/function/dualImpl.ts';\nimport { f32, u32 } from '../data/numeric.ts';\nimport { vec2u, vec3u, vec4f, vec4i, vec4u } from '../data/vector.ts';\nimport {\n type v2f,\n type v2i,\n type v2u,\n type v3f,\n type v3i,\n type v3u,\n type v4f,\n type v4i,\n type v4u,\n Void,\n} from '../data/wgslTypes.ts';\nimport {\n getTextureFormatInfo,\n type StorageTextureFormats,\n type TextureFormats,\n} from '../core/texture/textureFormats.ts';\nimport type { $internal, $repr } from '../shared/symbols.ts';\nimport type {\n texture1d,\n texture2d,\n texture2dArray,\n texture3d,\n textureCube,\n textureCubeArray,\n textureDepth2d,\n textureDepth2dArray,\n textureDepthCube,\n textureExternal,\n textureMultisampled2d,\n textureStorage1d,\n textureStorage2d,\n textureStorage2dArray,\n textureStorage3d,\n} from '../data/texture.ts';\n\nimport type { AnyData } from '../data/dataTypes.ts';\nimport type { comparisonSampler, sampler } from '../data/sampler.ts';\n\nfunction sampleCpu<T extends texture1d>(\n texture: T,\n sampler: sampler,\n coords: number,\n): v4f;\nfunction sampleCpu<T extends texture2d>(\n texture: T,\n sampler: sampler,\n coords: v2f,\n offset?: v2i,\n): v4f;\nfunction sampleCpu<T extends texture2dArray>(\n texture: T,\n sampler: sampler,\n coords: v2f,\n arrayIndex: number,\n offset?: v2i,\n): v4f;\nfunction sampleCpu<T extends texture3d | textureCube>(\n texture: T,\n sampler: sampler,\n coords: v3f,\n): v4f;\nfunction sampleCpu<T extends texture3d>(\n texture: T,\n sampler: sampler,\n coords: v3f,\n offset: v3i,\n): v4f;\nfunction sampleCpu<T extends textureCubeArray>(\n texture: T,\n sampler: sampler,\n coords: v3f,\n arrayIndex: number,\n): v4f;\nfunction sampleCpu<T extends textureDepth2d>(\n texture: T,\n sampler: sampler,\n coords: v2f,\n offset?: v2i,\n): number;\nfunction sampleCpu<T extends textureDepth2dArray>(\n texture: T,\n sampler: sampler,\n coords: v2f,\n arrayIndex: number,\n offset?: v2i,\n): number;\nfunction sampleCpu<T extends textureDepthCube>(\n texture: T,\n sampler: sampler,\n coords: v3f,\n arrayIndex?: number,\n): number;\nfunction sampleCpu(\n _texture: WgslTexture,\n _sampler: sampler,\n _coords: number | v2f | v3f,\n _offsetOrArrayIndex?: v2i | v3i | number,\n _maybeOffset?: v2i | v3i,\n): v4f | number {\n throw new Error(\n 'Texture sampling relies on GPU resources and cannot be executed outside of a draw call',\n );\n}\n\nexport const textureSample = dualImpl({\n name: 'textureSample',\n normalImpl: sampleCpu,\n codegenImpl: (...args) => stitch`textureSample(${args})`,\n signature: (...args) => {\n const isDepth = (args[0] as WgslTexture).type.startsWith('texture_depth');\n return {\n argTypes: args as AnyData[],\n returnType: isDepth ? f32 : vec4f,\n };\n },\n});\n\nfunction sampleBiasCpu<T extends texture1d>(\n texture: T,\n sampler: sampler,\n coords: number,\n bias: number,\n): v4f;\nfunction sampleBiasCpu<T extends texture2d>(\n texture: T,\n sampler: sampler,\n coords: v2f,\n bias: number,\n offset?: v2i,\n): v4f;\nfunction sampleBiasCpu<T extends texture2dArray>(\n texture: T,\n sampler: sampler,\n coords: v2f,\n arrayIndex: number,\n bias: number,\n offset?: v2i,\n): v4f;\nfunction sampleBiasCpu<T extends texture3d | textureCube>(\n texture: T,\n sampler: sampler,\n coords: v3f,\n bias: number,\n offset?: v3i,\n): v4f;\nfunction sampleBiasCpu<T extends textureCubeArray>(\n texture: T,\n sampler: sampler,\n coords: v3f,\n arrayIndex: number,\n bias: number,\n): v4f;\nfunction sampleBiasCpu(\n _texture: WgslTexture,\n _sampler: sampler,\n _coords: number | v2f | v3f,\n _biasOrArrayIndex: number,\n _biasOrOffset?: number | v2i | v3i,\n _maybeOffset?: v2i | v3i,\n): v4f {\n throw new Error(\n 'Texture sampling with bias relies on GPU resources and cannot be executed outside of a draw call',\n );\n}\n\nexport const textureSampleBias = dualImpl({\n name: 'textureSampleBias',\n normalImpl: sampleBiasCpu,\n codegenImpl: (...args) => stitch`textureSampleBias(${args})`,\n signature: (...args) => ({\n argTypes: args as AnyData[],\n returnType: vec4f,\n }),\n});\n\nfunction sampleLevelCpu<T extends texture1d>(\n texture: T,\n sampler: sampler,\n coords: number,\n level: number,\n): v4f;\nfunction sampleLevelCpu<T extends texture2d>(\n texture: T,\n sampler: sampler,\n coords: v2f,\n level: number,\n): v4f;\nfunction sampleLevelCpu<T extends texture2d>(\n texture: T,\n sampler: sampler,\n coords: v2f,\n level: number,\n offset: v2i,\n): v4f;\nfunction sampleLevelCpu<T extends texture2dArray>(\n texture: T,\n sampler: sampler,\n coords: v2f,\n arrayIndex: number,\n level: number,\n): v4f;\nfunction sampleLevelCpu<T extends texture2dArray>(\n texture: T,\n sampler: sampler,\n coords: v2f,\n arrayIndex: number,\n level: number,\n offset: v2i,\n): v4f;\nfunction sampleLevelCpu<T extends texture3d | textureCube>(\n texture: T,\n sampler: sampler,\n coords: v3f,\n level: number,\n): v4f;\nfunction sampleLevelCpu<T extends texture3d>(\n texture: T,\n sampler: sampler,\n coords: v3f,\n level: number,\n offset: v3i,\n): v4f;\nfunction sampleLevelCpu<T extends textureCubeArray>(\n texture: T,\n sampler: sampler,\n coords: v3f,\n arrayIndex: number,\n level: number,\n): v4f;\nfunction sampleLevelCpu<T extends textureDepth2d>(\n texture: T,\n sampler: sampler,\n coords: v2f,\n level: number,\n): number;\nfunction sampleLevelCpu<T extends textureDepth2d>(\n texture: T,\n sampler: sampler,\n coords: v2f,\n level: number,\n offset: v2i,\n): number;\nfunction sampleLevelCpu<T extends textureDepth2dArray>(\n texture: T,\n sampler: sampler,\n coords: v2f,\n arrayIndex: number,\n level: number,\n): number;\nfunction sampleLevelCpu<T extends textureDepth2dArray>(\n texture: T,\n sampler: sampler,\n coords: v2f,\n arrayIndex: number,\n level: number,\n offset: v2i,\n): number;\nfunction sampleLevelCpu<T extends textureDepthCube>(\n texture: T,\n sampler: sampler,\n coords: v3f,\n level: number,\n): number;\nfunction sampleLevelCpu<T extends textureCubeArray>(\n texture: T,\n sampler: sampler,\n coords: v3f,\n arrayIndex: number,\n level: number,\n): number;\nfunction sampleLevelCpu(\n _texture: WgslTexture,\n _sampler: sampler,\n _coords: number | v2f | v3f,\n _level: number,\n _offsetOrArrayIndex?: v2i | v3i | number,\n _maybeOffset?: v2i | v3i,\n): v4f | number {\n throw new Error(\n 'Texture sampling relies on GPU resources and cannot be executed outside of a draw call',\n );\n}\n\nexport const textureSampleLevel = dualImpl({\n name: 'textureSampleLevel',\n normalImpl: sampleLevelCpu,\n codegenImpl: (...args) => stitch`textureSampleLevel(${args})`,\n signature: (...args) => {\n const isDepth = (args[0] as WgslTexture).type.startsWith('texture_depth');\n return {\n argTypes: args,\n returnType: isDepth ? f32 : vec4f,\n };\n },\n});\n\ntype PrimitiveToLoadedType = {\n f32: v4f;\n i32: v4i;\n u32: v4u;\n};\n\ntype TexelFormatToInstanceType<T extends StorageTextureFormats> =\n TextureFormats[T]['vectorType'][typeof $repr];\n\nfunction textureLoadCpu<T extends texture1d>(\n texture: T,\n coords: number,\n level: number,\n): PrimitiveToLoadedType[T[typeof $internal]['type']];\nfunction textureLoadCpu<T extends texture2d>(\n texture: T,\n coords: v2i | v2u,\n level: number,\n): PrimitiveToLoadedType[T[typeof $internal]['type']];\nfunction textureLoadCpu<T extends texture2dArray>(\n texture: T,\n coords: v2i | v2u,\n arrayIndex: number,\n level: number,\n): PrimitiveToLoadedType[T[typeof $internal]['type']];\nfunction textureLoadCpu<T extends texture3d>(\n texture: T,\n coords: v3i | v3u,\n level: number,\n): PrimitiveToLoadedType[T[typeof $internal]['type']];\nfunction textureLoadCpu<T extends textureMultisampled2d>(\n texture: T,\n coords: v2i | v2u,\n sampleIndex: number,\n): PrimitiveToLoadedType[T[typeof $internal]['type']];\nfunction textureLoadCpu<T extends textureStorage1d>(\n texture: T,\n coords: number,\n): TexelFormatToInstanceType<T[typeof $internal][0]>;\nfunction textureLoadCpu<T extends textureStorage2d>(\n texture: T,\n coords: v2i | v2u,\n): TexelFormatToInstanceType<T[typeof $internal][0]>;\nfunction textureLoadCpu<T extends textureStorage2dArray>(\n texture: T,\n coords: v2i | v2u,\n arrayIndex: number,\n): TexelFormatToInstanceType<T[typeof $internal][0]>;\nfunction textureLoadCpu<T extends textureStorage3d>(\n texture: T,\n coords: v3i | v3u,\n): TexelFormatToInstanceType<T[typeof $internal][0]>;\nfunction textureLoadCpu(\n _texture: WgslTexture | WgslStorageTexture,\n _coords: number | v2i | v2u | v3i | v3u,\n _levelOrArrayIndex?: number,\n): TexelData {\n throw new Error(\n '`textureLoad` relies on GPU resources and cannot be executed outside of a draw call',\n );\n}\n\nexport const textureLoad = dualImpl({\n name: 'textureLoad',\n normalImpl: textureLoadCpu,\n codegenImpl: (...args) => stitch`textureLoad(${args})`,\n signature: (...args) => {\n const texture = args[0] as WgslTexture | WgslStorageTexture;\n if (isWgslTexture(texture)) {\n const isDepth = texture.type.startsWith('texture_depth');\n const sampleType = texture.sampleType;\n return {\n argTypes: args,\n returnType: isDepth\n ? f32\n : sampleType.type === 'f32'\n ? vec4f\n : sampleType.type === 'u32'\n ? vec4u\n : vec4i,\n };\n }\n const format = texture.format;\n const dataType = getTextureFormatInfo(format).vectorType;\n return {\n argTypes: args,\n returnType: dataType,\n };\n },\n});\n\nfunction textureStoreCpu<T extends textureStorage1d>(\n texture: T,\n coords: number,\n value: TexelFormatToInstanceType<T[typeof $internal][0]>,\n): void;\nfunction textureStoreCpu<T extends textureStorage2d>(\n texture: T,\n coords: v2i | v2u,\n value: TexelFormatToInstanceType<T[typeof $internal][0]>,\n): void;\nfunction textureStoreCpu<T extends textureStorage2dArray>(\n texture: T,\n coords: v2i | v2u,\n arrayIndex: number,\n value: TexelFormatToInstanceType<T[typeof $internal][0]>,\n): void;\nfunction textureStoreCpu<T extends textureStorage3d>(\n texture: T,\n coords: v3i | v3u,\n value: TexelFormatToInstanceType<T[typeof $internal][0]>,\n): void;\nfunction textureStoreCpu(\n _texture: WgslStorageTexture,\n _coords: number | v2i | v2u | v3i | v3u,\n _arrayIndexOrValue?: number | TexelData,\n _maybeValue?: TexelData,\n): void {\n throw new Error(\n '`textureStore` relies on GPU resources and cannot be executed outside of a draw call',\n );\n}\n\nexport const textureStore = dualImpl({\n name: 'textureStore',\n normalImpl: textureStoreCpu,\n codegenImpl: (...args) => stitch`textureStore(${args})`,\n signature: (...args) => ({ argTypes: args, returnType: Void }),\n});\n\nfunction textureDimensionsCpu<T extends texture1d | textureStorage1d>(\n texture: T,\n): number;\nfunction textureDimensionsCpu<T extends texture1d>(\n texture: T,\n level: number,\n): number;\nfunction textureDimensionsCpu<\n T extends\n | texture2d\n | texture2dArray\n | textureCube\n | textureCubeArray\n | textureStorage2d\n | textureStorage2dArray\n | textureExternal,\n>(texture: T): v2u;\nfunction textureDimensionsCpu<\n T extends\n | texture2d\n | texture2dArray\n | textureCube\n | textureCubeArray,\n>(texture: T, level: number): v2u;\nfunction textureDimensionsCpu<T extends texture3d | textureStorage3d>(\n texture: T,\n): v3u;\nfunction textureDimensionsCpu<T extends texture3d>(\n texture: T,\n level: number,\n): v3u;\nfunction textureDimensionsCpu(\n _texture: WgslTexture | WgslStorageTexture | WgslExternalTexture,\n _level?: number,\n): number | v2u | v3u {\n throw new Error(\n '`textureDimensions` relies on GPU resources and cannot be executed outside of a draw call',\n );\n}\n\nexport const textureDimensions = dualImpl({\n name: 'textureDimensions',\n normalImpl: textureDimensionsCpu,\n codegenImpl: (...args) => stitch`textureDimensions(${args})`,\n signature: (...args) => {\n const dim = (\n args[0] as WgslTexture | WgslStorageTexture | WgslExternalTexture\n ).dimension;\n if (dim === '1d') {\n return {\n argTypes: args,\n returnType: u32,\n };\n }\n if (dim === '3d') {\n return {\n argTypes: args,\n returnType: vec3u,\n };\n }\n return {\n argTypes: args,\n returnType: vec2u,\n };\n },\n});\n\nfunction textureSampleCompareCpu<T extends textureDepth2d>(\n texture: T,\n sampler: comparisonSampler,\n coords: v2f,\n depthRef: number,\n): number;\nfunction textureSampleCompareCpu<T extends textureDepth2d>(\n texture: T,\n sampler: comparisonSampler,\n coords: v2f,\n depthRef: number,\n offset: v2i,\n): number;\nfunction textureSampleCompareCpu<T extends textureDepth2dArray>(\n texture: T,\n sampler: comparisonSampler,\n coords: v2f,\n arrayIndex: number,\n depthRef: number,\n): number;\nfunction textureSampleCompareCpu<T extends textureDepth2dArray>(\n texture: T,\n sampler: comparisonSampler,\n coords: v2f,\n arrayIndex: number,\n depthRef: number,\n offset: v2i,\n): number;\nfunction textureSampleCompareCpu<T extends textureDepthCube>(\n texture: T,\n sampler: comparisonSampler,\n coords: v3f,\n depthRef: number,\n): number;\nfunction textureSampleCompareCpu<T extends textureCubeArray>(\n texture: T,\n sampler: comparisonSampler,\n coords: v3f,\n arrayIndex: number,\n depthRef: number,\n): number;\nfunction textureSampleCompareCpu(\n _texture: WgslTexture,\n _sampler: comparisonSampler,\n _coords: v2f | v3f,\n _depthRefOrArrayIndex: number,\n _depthRefOrOffset?: number | v2i,\n _maybeOffset?: v2i,\n): number {\n throw new Error(\n 'Texture comparison sampling relies on GPU resources and cannot be executed outside of a draw call',\n );\n}\n\nexport const textureSampleCompare = dualImpl({\n name: 'textureSampleCompare',\n normalImpl: textureSampleCompareCpu,\n codegenImpl: (...args) => stitch`textureSampleCompare(${args})`,\n signature: (...args) => ({\n argTypes: args,\n returnType: f32,\n }),\n});\n\nfunction textureSampleBaseClampToEdgeCpu<\n T extends texture2d | textureExternal,\n>(texture: T, sampler: sampler, coords: v2f): v4f {\n throw new Error(\n 'Texture sampling with base clamp to edge is not supported outside of GPU mode.',\n );\n}\n\nexport const textureSampleBaseClampToEdge = dualImpl({\n name: 'textureSampleBaseClampToEdge',\n normalImpl: textureSampleBaseClampToEdgeCpu,\n codegenImpl: (...args) => stitch`textureSampleBaseClampToEdge(${args})`,\n signature: (...args) => ({\n argTypes: args,\n returnType: vec4f,\n }),\n});\n","import { dualImpl } from '../core/function/dualImpl.ts';\nimport { stitch } from '../core/resolve/stitch.ts';\nimport { bool, i32, u32 } from '../data/numeric.ts';\nimport { vec4u } from '../data/vector.ts';\nimport type {\n AnyIntegerVecInstance,\n AnyNumericVecInstance,\n AnyWgslData,\n v4u,\n} from '../data/wgslTypes.ts';\nimport { unify } from '../tgsl/conversion.ts';\n\ninterface IdentityNumOrVec {\n (e: number): number;\n <T extends AnyNumericVecInstance>(e: T): T;\n}\n\ninterface IdentityIntNumOrVec {\n (e: number): number;\n <T extends AnyIntegerVecInstance>(e: T): T;\n}\n\ninterface IdentityNumOrVecWithIdx {\n (e: number, index: number): number;\n <T extends AnyNumericVecInstance>(e: T, index: number): T;\n}\n\ninterface IdentityNumOrVecWithDelta {\n (e: number, delta: number): number;\n <T extends AnyNumericVecInstance>(e: T, delta: number): T;\n}\n\ninterface IdentityNumOrVecWithMask {\n (e: number, mask: number): number;\n <T extends AnyNumericVecInstance>(e: T, mask: number): T;\n}\n\nconst errorMessage = 'Subgroup operations can only be used in the GPU context.';\n\nexport const subgroupAdd = dualImpl<IdentityNumOrVec>({\n name: 'subgroupAdd',\n signature: (arg) => ({ argTypes: [arg], returnType: arg }),\n normalImpl: errorMessage,\n codegenImpl: (arg) => stitch`subgroupAdd(${arg})`,\n});\n\nexport const subgroupExclusiveAdd = dualImpl<IdentityNumOrVec>({\n name: 'subgroupExclusiveAdd',\n signature: (arg) => ({ argTypes: [arg], returnType: arg }),\n normalImpl: errorMessage,\n codegenImpl: (arg) => stitch`subgroupExclusiveAdd(${arg})`,\n});\n\nexport const subgroupInclusiveAdd = dualImpl<IdentityNumOrVec>({\n name: 'subgroupInclusiveAdd',\n signature: (arg) => ({ argTypes: [arg], returnType: arg }),\n normalImpl: errorMessage,\n codegenImpl: (arg) => stitch`subgroupInclusiveAdd(${arg})`,\n});\n\nexport const subgroupAll = dualImpl<(e: boolean) => boolean>({\n name: 'subgroupAll',\n signature: { argTypes: [bool], returnType: bool },\n normalImpl: errorMessage,\n codegenImpl: (e) => stitch`subgroupAll(${e})`,\n});\n\nexport const subgroupAnd = dualImpl<IdentityIntNumOrVec>({\n name: 'subgroupAnd',\n signature: (arg) => ({ argTypes: [arg], returnType: arg }),\n normalImpl: errorMessage,\n codegenImpl: (e) => stitch`subgroupAnd(${e})`,\n});\n\nexport const subgroupAny = dualImpl<(e: boolean) => boolean>({\n name: 'subgroupAny',\n signature: { argTypes: [bool], returnType: bool },\n normalImpl: errorMessage,\n codegenImpl: (e) => stitch`subgroupAny(${e})`,\n});\n\nexport const subgroupBallot = dualImpl<(e: boolean) => v4u>({\n name: 'subgroupBallot',\n signature: { argTypes: [bool], returnType: vec4u },\n normalImpl: errorMessage,\n codegenImpl: (e) => stitch`subgroupBallot(${e})`,\n});\n\nexport const subgroupBroadcast = dualImpl<IdentityNumOrVecWithIdx>({\n name: 'subgroupBroadcast',\n signature: (...args) => {\n const id = unify([args[1]] as [AnyWgslData], [i32, u32]);\n if (!id) {\n throw new Error(\n `subgroupBroadcast's second argument has to be compatible with i32 or u32. Got: ${\n args[1].type\n }`,\n );\n }\n return { argTypes: [args[0], id[0]], returnType: args[0] };\n },\n normalImpl: errorMessage,\n codegenImpl: (e, index) => stitch`subgroupBroadcast(${e}, ${index})`,\n});\n\nexport const subgroupBroadcastFirst = dualImpl<IdentityNumOrVec>({\n name: 'subgroupBroadcastFirst',\n signature: (arg) => ({ argTypes: [arg], returnType: arg }),\n normalImpl: errorMessage,\n codegenImpl: (e) => stitch`subgroupBroadcastFirst(${e})`,\n});\n\nexport const subgroupElect = dualImpl<() => boolean>({\n name: 'subgroupElect',\n signature: { argTypes: [], returnType: bool },\n normalImpl: errorMessage,\n codegenImpl: () => stitch`subgroupElect()`,\n});\n\nexport const subgroupMax = dualImpl<IdentityNumOrVec>({\n name: 'subgroupMax',\n signature: (arg) => ({ argTypes: [arg], returnType: arg }),\n normalImpl: errorMessage,\n codegenImpl: (arg) => stitch`subgroupMax(${arg})`,\n});\n\nexport const subgroupMin = dualImpl<IdentityNumOrVec>({\n name: 'subgroupMin',\n signature: (arg) => ({ argTypes: [arg], returnType: arg }),\n normalImpl: errorMessage,\n codegenImpl: (arg) => stitch`subgroupMin(${arg})`,\n});\n\nexport const subgroupMul = dualImpl<IdentityNumOrVec>({\n name: 'subgroupMul',\n signature: (arg) => ({ argTypes: [arg], returnType: arg }),\n normalImpl: errorMessage,\n codegenImpl: (arg) => stitch`subgroupMul(${arg})`,\n});\n\nexport const subgroupExclusiveMul = dualImpl<IdentityNumOrVec>({\n name: 'subgroupExclusiveMul',\n signature: (arg) => ({ argTypes: [arg], returnType: arg }),\n normalImpl: errorMessage,\n codegenImpl: (arg) => stitch`subgroupExclusiveMul(${arg})`,\n});\n\nexport const subgroupInclusiveMul = dualImpl<IdentityNumOrVec>({\n name: 'subgroupInclusiveMul',\n signature: (arg) => ({ argTypes: [arg], returnType: arg }),\n normalImpl: errorMessage,\n codegenImpl: (arg) => stitch`subgroupInclusiveMul(${arg})`,\n});\n\nexport const subgroupOr = dualImpl<IdentityIntNumOrVec>({\n name: 'subgroupOr',\n signature: (arg) => ({ argTypes: [arg], returnType: arg }),\n normalImpl: errorMessage,\n codegenImpl: (e) => stitch`subgroupOr(${e})`,\n});\n\nexport const subgroupShuffle = dualImpl<IdentityNumOrVecWithIdx>({\n name: 'subgroupShuffle',\n signature: (...args) => {\n const id = unify([args[1]] as [AnyWgslData], [i32, u32]);\n if (!id) {\n throw new Error(\n `subgroupShuffle's second argument has to be compatible with i32 or u32. Got: ${\n args[1].type\n }`,\n );\n }\n return { argTypes: [args[0], id[0]], returnType: args[0] };\n },\n normalImpl: errorMessage,\n codegenImpl: (e, index) => stitch`subgroupShuffle(${e}, ${index})`,\n});\n\nexport const subgroupShuffleDown = dualImpl<IdentityNumOrVecWithDelta>({\n name: 'subgroupShuffleDown',\n signature: (...args) => {\n const delta = unify([args[1]] as [AnyWgslData], [u32]);\n if (!delta) {\n throw new Error(\n `subgroupShuffleDown's second argument has to be compatible with u32. Got: ${\n args[1].type\n }`,\n );\n }\n return { argTypes: [args[0], delta[0]], returnType: args[0] };\n },\n normalImpl: errorMessage,\n codegenImpl: (e, delta) => stitch`subgroupShuffleDown(${e}, ${delta})`,\n});\n\nexport const subgroupShuffleUp = dualImpl<IdentityNumOrVecWithDelta>({\n name: 'subgroupShuffleUp',\n signature: (...args) => {\n const delta = unify([args[1]] as [AnyWgslData], [u32]);\n if (!delta) {\n throw new Error(\n `subgroupShuffleUp's second argument has to be compatible with u32. Got: ${\n args[1].type\n }`,\n );\n }\n return { argTypes: [args[0], delta[0]], returnType: args[0] };\n },\n normalImpl: errorMessage,\n codegenImpl: (e, delta) => stitch`subgroupShuffleUp(${e}, ${delta})`,\n});\n\nexport const subgroupShuffleXor = dualImpl<IdentityNumOrVecWithMask>({\n name: 'subgroupShuffleXor',\n signature: (...args) => {\n const mask = unify([args[1]] as [AnyWgslData], [u32]);\n if (!mask) {\n throw new Error(\n `subgroupShuffleXor's second argument has to be compatible with u32. Got: ${\n args[1].type\n }`,\n );\n }\n return { argTypes: [args[0], mask[0]], returnType: args[0] };\n },\n normalImpl: errorMessage,\n codegenImpl: (e, mask) => stitch`subgroupShuffleXor(${e}, ${mask})`,\n});\n\nexport const subgroupXor = dualImpl<IdentityIntNumOrVec>({\n name: 'subgroupXor',\n signature: (arg) => ({ argTypes: [arg], returnType: arg }),\n normalImpl: errorMessage,\n codegenImpl: (e) => stitch`subgroupXor(${e})`,\n});\n","import { comptime } from '../core/function/comptime.ts';\nimport { getResolutionCtx } from '../execMode.ts';\nimport { type WgslExtension, wgslExtensions } from '../wgslExtensions.ts';\n\nexport const extensionEnabled = comptime(\n (extensionName: WgslExtension): boolean => {\n const resolutionCtx = getResolutionCtx();\n if (!resolutionCtx) {\n throw new Error(\n \"Functions using `extensionEnabled` cannot be called directly. Either generate WGSL from them, or use tgpu['~unstable'].simulate(...)\",\n );\n }\n\n if (\n typeof extensionName !== 'string' ||\n !(wgslExtensions.includes(extensionName as WgslExtension))\n ) {\n throw new Error(\n `extensionEnabled has to be called with a string literal representing a valid WGSL extension name. Got: '${extensionName}'`,\n );\n }\n\n return (resolutionCtx.enableExtensions ?? []).includes(extensionName);\n },\n);\n"],"mappings":"ojCAGO,IAAMA,GAAUC,EAAsB,CAC3C,KAAM,UACN,WACE,kFACF,UAAW,CAAE,SAAU,CAAC,EAAG,WAAYC,CAAK,EAC5C,YAAa,IAAM,UACrB,CAAC,ECOD,IAAMC,EAASC,EAAIC,CAAS,EAAE,OAExBC,GAAkBC,EAAaF,CAAS,EAAE,OAC1CG,GAAkBD,EAAaF,CAAS,EAAE,QAE1CI,GAAcC,EAASL,CAAS,EAAE,OAClCM,GAAcD,EAASL,CAAS,EAAE,QAElCO,GAAgBC,EAAWR,CAAS,EAAE,OACtCS,GAAgBD,EAAWR,CAAS,EAAE,QAEtCU,GAAgBC,EAAWX,CAAS,EAAE,OACtCY,GAAgBD,EAAWX,CAAS,EAAE,QAEtCa,GAAgBC,EAAWd,CAAS,EAAE,OACtCe,GAAgBD,EAAWd,CAAS,EAAE,QAQ/BgB,GAAaC,EAAS,CACjC,KAAM,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AAE,SAAU,CAACA,CAAG,EAAG,WAAYA,CAAI,GACxD,WAAYH,EACZ,YAAc,GAAMI,gBAAqB,CAAC,GAC5C,CAAC,ECtOM,IAAM+B,GAAmBC,EAC7BC,GAA0C,CACzC,IAAMC,EAAgBC,EAAiB,EACvC,GAAI,CAACD,EACH,MAAM,IAAI,MACR,sIACF,EAGF,GACE,OAAOD,GAAkB,UACzB,CAAEG,EAAe,SAASH,CAA8B,EAExD,MAAM,IAAI,MACR,2GAA2GA,CAAa,GAC1H,EAGF,OAAQC,EAAc,kBAAoB,CAAC,GAAG,SAASD,CAAa,CACtE,CACF","names":["discard","dualImpl","Void","cpuMul","mul","$internal","cpuTranslation4","translation4","gpuTranslation4","cpuScaling4","scaling4","gpuScaling4","cpuRotationX4","rotationX4","gpuRotationX4","cpuRotationY4","rotationY4","gpuRotationY4","cpuRotationZ4","rotationZ4","gpuRotationZ4","translate4","dualImpl","matrix","vector","mat4x4f","vec3f","stitch","scale4","rotateSignature","f32","rotateX4","angle","rotateY4","rotateZ4","workgroupBarrier","dualImpl","Void","storageBarrier","textureBarrier","atomicNormalError","atomicLoad","a","safeStringify","stitch","atomicActionSignature","param","u32","i32","atomicOpSignature","paramType","atomicStore","value","atomicAdd","atomicSub","atomicMax","atomicMin","atomicAnd","atomicOr","atomicXor","derivativeNormalError","dpdx","dualImpl","value","stitch","dpdxCoarse","dpdxFine","dpdy","dpdyCoarse","dpdyFine","fwidth","fwidthCoarse","fwidthFine","sizeOfPointedToArray","dataType","isPtr","isWgslArray","arrayLength","dualImpl","arg","ptrArg","ptrFn","abstractInt","u32","a","isRef","length","stitch","sampleCpu","_texture","_sampler","_coords","_offsetOrArrayIndex","_maybeOffset","textureSample","dualImpl","args","stitch","isDepth","f32","vec4f","sampleBiasCpu","_biasOrArrayIndex","_biasOrOffset","textureSampleBias","sampleLevelCpu","_level","textureSampleLevel","textureLoadCpu","_levelOrArrayIndex","textureLoad","texture","isWgslTexture","sampleType","vec4u","vec4i","format","dataType","getTextureFormatInfo","textureStoreCpu","_arrayIndexOrValue","_maybeValue","textureStore","Void","textureDimensionsCpu","textureDimensions","dim","u32","vec3u","vec2u","textureSampleCompareCpu","_depthRefOrArrayIndex","_depthRefOrOffset","textureSampleCompare","textureSampleBaseClampToEdgeCpu","sampler","coords","textureSampleBaseClampToEdge","errorMessage","subgroupAdd","dualImpl","arg","stitch","subgroupExclusiveAdd","subgroupInclusiveAdd","subgroupAll","bool","subgroupAnd","subgroupAny","subgroupBallot","vec4u","subgroupBroadcast","args","id","unify","i32","u32","index","subgroupBroadcastFirst","subgroupElect","subgroupMax","subgroupMin","subgroupMul","subgroupExclusiveMul","subgroupInclusiveMul","subgroupOr","subgroupShuffle","subgroupShuffleDown","delta","subgroupShuffleUp","subgroupShuffleXor","mask","subgroupXor","extensionEnabled","comptime","extensionName","resolutionCtx","getResolutionCtx","wgslExtensions"]}