typegpu 0.8.0 → 0.8.2

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 (52) hide show
  1. package/{chunk-6WF2EZIT.js → chunk-6U5HPHCJ.js} +2 -2
  2. package/{chunk-B254XDWG.js → chunk-CGQB3SER.js} +2 -2
  3. package/{chunk-XEUNEHAZ.js → chunk-CRZWTZM2.js} +6 -6
  4. package/chunk-CRZWTZM2.js.map +1 -0
  5. package/chunk-ECR2EGZX.js +7 -0
  6. package/chunk-ECR2EGZX.js.map +1 -0
  7. package/chunk-PWBIFP67.js +2 -0
  8. package/chunk-PWBIFP67.js.map +1 -0
  9. package/common/index.d.ts +1 -1
  10. package/common/index.js +1 -1
  11. package/data/index.d.ts +3 -3
  12. package/data/index.js +1 -1
  13. package/index.d.ts +2 -2
  14. package/index.js +40 -40
  15. package/index.js.map +1 -1
  16. package/{matrix-C6mMH7pB.d.ts → matrix-DIfOiRyz.d.ts} +1 -1
  17. package/package.json +5 -13
  18. package/std/index.d.ts +2 -2
  19. package/std/index.js +1 -1
  20. package/std/index.js.map +1 -1
  21. package/{tgpuConstant-DzGgwe0I.d.ts → tgpuConstant-BTQFNlQH.d.ts} +13 -8
  22. package/chunk-A5APHF7K.cjs +0 -10
  23. package/chunk-A5APHF7K.cjs.map +0 -1
  24. package/chunk-LL6NPRFE.cjs +0 -7
  25. package/chunk-LL6NPRFE.cjs.map +0 -1
  26. package/chunk-M2P3FJT7.cjs +0 -2
  27. package/chunk-M2P3FJT7.cjs.map +0 -1
  28. package/chunk-PO6SIMTQ.js +0 -2
  29. package/chunk-PO6SIMTQ.js.map +0 -1
  30. package/chunk-T2GBOTUH.js +0 -7
  31. package/chunk-T2GBOTUH.js.map +0 -1
  32. package/chunk-TRAG63HY.cjs +0 -3
  33. package/chunk-TRAG63HY.cjs.map +0 -1
  34. package/chunk-U3CXOCRG.cjs +0 -2
  35. package/chunk-U3CXOCRG.cjs.map +0 -1
  36. package/chunk-XEUNEHAZ.js.map +0 -1
  37. package/common/index.cjs +0 -7
  38. package/common/index.cjs.map +0 -1
  39. package/common/index.d.cts +0 -24
  40. package/data/index.cjs +0 -2
  41. package/data/index.cjs.map +0 -1
  42. package/data/index.d.cts +0 -402
  43. package/index.cjs +0 -192
  44. package/index.cjs.map +0 -1
  45. package/index.d.cts +0 -369
  46. package/matrix-Cn2jQILV.d.cts +0 -122
  47. package/std/index.cjs +0 -2
  48. package/std/index.cjs.map +0 -1
  49. package/std/index.d.cts +0 -639
  50. package/tgpuConstant-DzGgwe0I.d.cts +0 -5196
  51. /package/{chunk-6WF2EZIT.js.map → chunk-6U5HPHCJ.js.map} +0 -0
  52. /package/{chunk-B254XDWG.js.map → chunk-CGQB3SER.js.map} +0 -0
package/index.d.cts DELETED
@@ -1,369 +0,0 @@
1
- import { $ as $internal, S as ShelllessRepository, T as TgpuSlot, R as ResolvedSnippet, a as TgpuDerived, b as TgpuBindGroupLayout, c as TgpuBindGroup, L as LogResources, W as Wgsl, C as Configurable, d as WgslExtension, e as ShaderGenerator, f as TgpuBuffer, A as AnyData, g as TgpuVar, h as LogGeneratorOptions, i as TgpuRoot, j as AnyWgslData, k as TgpuFn, l as TgpuBufferUsage, I as Infer, m as TgpuAccessor, n as TgpuVertexLayout, o as WgslArray, D as Disarray, p as fn, q as bindGroupLayout, v as vertexLayout, r as privateVar, w as workgroupVar, s as constant, t as fragmentFn, u as vertexFn, x as computeFn, y as declare } from './tgpuConstant-DzGgwe0I.cjs';
2
- export { aw as BindLayoutEntry, aj as Eventual, ax as ExtractBindGroupInputFromLayout, aO as INTERNAL_GlobalExt, a7 as IndexFlag, ay as LayoutEntryToInput, an as RenderFlag, ao as SampledFlag, a3 as Storage, a4 as StorageFlag, am as TextureProps, ad as TgpuBufferMutable, ae as TgpuBufferReadonly, af as TgpuBufferUniform, ar as TgpuComparisonSampler, aL as TgpuComputeFn, aM as TgpuComputeFnShell, a6 as TgpuComputePipeline, ap as TgpuConst, aN as TgpuDeclare, as as TgpuFixedComparisonSampler, at as TgpuFixedSampler, aG as TgpuFnShell, aJ as TgpuFragmentFn, aK as TgpuFragmentFnShell, V as TgpuGuardedComputePipeline, az as TgpuLayoutComparisonSampler, aA as TgpuLayoutEntry, aB as TgpuLayoutExternalTexture, aC as TgpuLayoutSampler, aD as TgpuLayoutStorage, aE as TgpuLayoutTexture, aF as TgpuLayoutUniform, ag as TgpuMutable, av as TgpuQuerySet, ah as TgpuReadonly, a5 as TgpuRenderPipeline, au as TgpuSampler, ak as TgpuTexture, al as TgpuTextureView, ai as TgpuUniform, aH as TgpuVertexFn, aI as TgpuVertexFnShell, a8 as Uniform, a9 as UniformFlag, aa as ValidUsagesFor, X as ValidateBufferSchema, Y as ValidateStorageSchema, Z as ValidateUniformSchema, aq as VariableScope, ab as Vertex, ac as VertexFlag, _ as WithBinding, a0 as WithCompute, a1 as WithFragment, a2 as WithVertex, z as isBuffer, P as isBufferShorthand, G as isComparisonSampler, E as isDerived, H as isSampler, F as isSlot, J as isTexture, Q as isTgpuFn, K as isUsableAsRender, M as isUsableAsSampled, N as isUsableAsStorage, O as isUsableAsUniform, B as isUsableAsVertex, U as isVariable } from './tgpuConstant-DzGgwe0I.cjs';
3
- import 'tinyest';
4
-
5
- interface NameRegistry {
6
- /**
7
- * Creates a valid WGSL identifier, each guaranteed to be unique
8
- * in the lifetime of a single resolution process.
9
- * Should append "_" to primer, followed by some id.
10
- * @param primer Used in the generation process, makes the identifier more recognizable.
11
- */
12
- makeUnique(primer?: string): string;
13
- /**
14
- * Creates a valid WGSL identifier.
15
- * Renames identifiers that are WGSL reserved words.
16
- * @param primer Used in the generation process.
17
- *
18
- * @example
19
- * makeValid("notAKeyword"); // "notAKeyword"
20
- * makeValid("struct"); // makeUnique("struct")
21
- * makeValid("struct_1"); // makeUnique("struct_1") (to avoid potential name collisions)
22
- * makeValid("_"); // ERROR (too difficult to make valid to care)
23
- */
24
- makeValid(primer: string): string;
25
- }
26
-
27
- type SlotToValueMap = Map<TgpuSlot<unknown>, unknown>;
28
- interface NamespaceInternal {
29
- readonly nameRegistry: NameRegistry;
30
- readonly shelllessRepo: ShelllessRepository;
31
- memoizedResolves: WeakMap<object, {
32
- slotToValueMap: SlotToValueMap;
33
- result: ResolvedSnippet;
34
- }[]>;
35
- memoizedDerived: WeakMap<TgpuDerived<unknown>, {
36
- slotToValueMap: SlotToValueMap;
37
- result: unknown;
38
- }[]>;
39
- listeners: {
40
- [K in keyof NamespaceEventMap]: Set<(event: NamespaceEventMap[K]) => void>;
41
- };
42
- }
43
- type NamespaceEventMap = {
44
- 'name': {
45
- target: object;
46
- name: string;
47
- };
48
- };
49
- type DetachListener = () => void;
50
- interface Namespace {
51
- readonly [$internal]: NamespaceInternal;
52
- on<TEvent extends keyof NamespaceEventMap>(event: TEvent, listener: (event: NamespaceEventMap[TEvent]) => void): DetachListener;
53
- }
54
- interface NamespaceOptions {
55
- names?: 'random' | 'strict' | undefined;
56
- }
57
- declare function namespace(options?: NamespaceOptions | undefined): Namespace;
58
-
59
- /**
60
- * The results of a WGSL resolution.
61
- *
62
- * @param code - The resolved code.
63
- * @param usedBindGroupLayouts - List of used `tgpu.bindGroupLayout`s.
64
- * @param catchall - Automatically constructed bind group for buffer usages and buffer shorthands, preceded by its index.
65
- * @param logResources - Buffers and information about used console.logs needed to decode the raw data.
66
- */
67
- interface ResolutionResult {
68
- code: string;
69
- usedBindGroupLayouts: TgpuBindGroupLayout[];
70
- catchall: [number, TgpuBindGroup] | undefined;
71
- logResources: LogResources | undefined;
72
- }
73
-
74
- interface TgpuResolveOptions {
75
- /**
76
- * Map of external names to their resolvable values.
77
- */
78
- externals: Record<string, Wgsl | object>;
79
- /**
80
- * The code template to use for the resolution. All external names will be replaced with their resolved values.
81
- * @default ''
82
- */
83
- template?: string | undefined;
84
- /**
85
- * The naming strategy used for generating identifiers for resolved externals and their dependencies.
86
- *
87
- * ## Namespaces
88
- * Each call to `tgpu.resolve` uses it's own namespace by default, but a
89
- * custom namespace can be created with `tgpu.namespace` and passed in.
90
- *
91
- * This allows tracking the behavior of the resolution process, as well as
92
- * sharing state between calls to `tgpu.resolve`.
93
- *
94
- * @default 'random'
95
- */
96
- names?: 'strict' | 'random' | Namespace | undefined;
97
- /**
98
- * A function to configure the resolution context.
99
- */
100
- config?: ((cfg: Configurable) => Configurable) | undefined;
101
- /**
102
- * List of WGSL shader extensions to enable.
103
- */
104
- enableExtensions?: WgslExtension[] | undefined;
105
- /**
106
- * A custom shader code generator, used when resolving TGSL.
107
- * If not provided, the default WGSL generator will be used.
108
- */
109
- shaderGenerator?: ShaderGenerator | undefined;
110
- }
111
- /**
112
- * Resolves a template with external values. Each external will get resolved to a code string and replaced in the template.
113
- * Any dependencies of the externals will also be resolved and included in the output.
114
- * @param options - The options for the resolution.
115
- *
116
- * @returns {ResolutionResult}
117
- *
118
- * @example
119
- * ```ts
120
- * const Gradient = d.struct({
121
- * from: d.vec3f,
122
- * to: d.vec3f,
123
- * });
124
- *
125
- * const { code, usedBindGroupLayouts, catchall } = tgpu.resolveWithContext({
126
- * template: `
127
- * fn getGradientAngle(gradient: Gradient) -> f32 {
128
- * return atan(gradient.to.y - gradient.from.y, gradient.to.x - gradient.from.x);
129
- * }
130
- * `,
131
- * externals: {
132
- * Gradient,
133
- * },
134
- * });
135
- *
136
- * console.log(code);
137
- * // struct Gradient_0 {
138
- * // from: vec3f,
139
- * // to: vec3f,
140
- * // }
141
- * // fn getGradientAngle(gradient: Gradient_0) -> f32 {
142
- * // return atan(gradient.to.y - gradient.from.y, gradient.to.x - gradient.from.x);
143
- * // }
144
- * ```
145
- */
146
- declare function resolveWithContext(options: TgpuResolveOptions): ResolutionResult;
147
- /**
148
- * Resolves a template with external values. Each external will get resolved to a code string and replaced in the template.
149
- * Any dependencies of the externals will also be resolved and included in the output.
150
- * @param options - The options for the resolution.
151
- *
152
- * @returns The resolved code.
153
- *
154
- * @example
155
- * ```ts
156
- * const Gradient = d.struct({
157
- * from: d.vec3f,
158
- * to: d.vec3f,
159
- * });
160
- *
161
- * const resolved = tgpu.resolve({
162
- * template: `
163
- * fn getGradientAngle(gradient: Gradient) -> f32 {
164
- * return atan(gradient.to.y - gradient.from.y, gradient.to.x - gradient.from.x);
165
- * }
166
- * `,
167
- * externals: {
168
- * Gradient,
169
- * },
170
- * });
171
- *
172
- * console.log(resolved);
173
- * // struct Gradient_0 {
174
- * // from: vec3f,
175
- * // to: vec3f,
176
- * // }
177
- * // fn getGradientAngle(gradient: Gradient_0) -> f32 {
178
- * // return atan(gradient.to.y - gradient.from.y, gradient.to.x - gradient.from.x);
179
- * // }
180
- * ```
181
- */
182
- declare function resolve(options: TgpuResolveOptions): string;
183
-
184
- interface SimulationResult<T> {
185
- value: T;
186
- buffers: Map<TgpuBuffer<AnyData>, unknown>;
187
- privateVars: Map<TgpuVar<'private', AnyData>, unknown>[][][];
188
- workgroupVars: Map<TgpuVar<'workgroup', AnyData>, unknown>[][][];
189
- }
190
- /**
191
- * Runs the provided callback in a simulated environment, giving
192
- * it access to buffers and variables as if it were running on the GPU.
193
- *
194
- * The result of the simulation is returned, and does not affect the actual GPU state,
195
- * nor does it carry over to other simulations.
196
- *
197
- * @param callback The callback to run in the simulated environment.
198
- * @returns An object containing the result of the simulation, and
199
- * the final state of the environment.
200
- *
201
- * @example
202
- * const counter = tgpu.privateVar(d.u32);
203
- *
204
- * const result = tgpu.simulate(() => {
205
- * counter.$ += 1;
206
- * counter.$ += 2;
207
- * return counter.$;
208
- * });
209
- *
210
- * console.log(result.value); // 3
211
- */
212
- declare function simulate<T>(callback: () => T): SimulationResult<T>;
213
-
214
- /**
215
- * Options passed into {@link init}.
216
- */
217
- type InitOptions = {
218
- adapter?: GPURequestAdapterOptions | undefined;
219
- device?: GPUDeviceDescriptor & {
220
- optionalFeatures?: Iterable<GPUFeatureName>;
221
- } | undefined;
222
- /** @default 'random' */
223
- unstable_names?: 'random' | 'strict' | undefined;
224
- /**
225
- * A custom shader code generator, used when resolving TGSL.
226
- * If not provided, the default WGSL generator will be used.
227
- */
228
- shaderGenerator?: ShaderGenerator | undefined;
229
- unstable_logOptions?: LogGeneratorOptions;
230
- };
231
- /**
232
- * Options passed into {@link initFromDevice}.
233
- */
234
- type InitFromDeviceOptions = {
235
- device: GPUDevice;
236
- /** @default 'random' */
237
- unstable_names?: 'random' | 'strict' | undefined;
238
- /**
239
- * A custom shader code generator, used when resolving TGSL.
240
- * If not provided, the default WGSL generator will be used.
241
- */
242
- shaderGenerator?: ShaderGenerator | undefined;
243
- unstable_logOptions?: LogGeneratorOptions;
244
- };
245
- /**
246
- * Requests a new GPU device and creates a root around it.
247
- * If a specific device should be used instead, use @see initFromDevice.
248
- *
249
- * @example
250
- * When given no options, the function will ask the browser for a suitable GPU device.
251
- * ```ts
252
- * const root = await tgpu.init();
253
- * ```
254
- *
255
- * @example
256
- * If there are specific options that should be used when requesting a device, you can pass those in.
257
- * ```ts
258
- * const adapterOptions: GPURequestAdapterOptions = ...;
259
- * const deviceDescriptor: GPUDeviceDescriptor = ...;
260
- * const root = await tgpu.init({ adapter: adapterOptions, device: deviceDescriptor });
261
- * ```
262
- */
263
- declare function init(options?: InitOptions): Promise<TgpuRoot>;
264
- /**
265
- * Creates a root from the given device, instead of requesting it like @see init.
266
- *
267
- * @example
268
- * ```ts
269
- * const device: GPUDevice = ...;
270
- * const root = tgpu.initFromDevice({ device });
271
- * ```
272
- */
273
- declare function initFromDevice(options: InitFromDeviceOptions): TgpuRoot;
274
-
275
- declare function accessor<T extends AnyWgslData>(schema: T, defaultValue?: TgpuFn<() => T> | TgpuBufferUsage<T> | Infer<T>): TgpuAccessor<T>;
276
-
277
- declare function derived<T>(compute: () => T): TgpuDerived<T>;
278
-
279
- declare function slot<T>(defaultValue?: T): TgpuSlot<T>;
280
-
281
- /**
282
- * An error that happens during resolution of WGSL code.
283
- * Contains a trace of all ancestor resolvables in
284
- * which this error originated.
285
- *
286
- * @category Errors
287
- */
288
- declare class ResolutionError extends Error {
289
- readonly cause: unknown;
290
- readonly trace: unknown[];
291
- constructor(cause: unknown, trace: unknown[]);
292
- appendToTrace(ancestor: unknown): ResolutionError;
293
- }
294
- /**
295
- * @category Errors
296
- */
297
- declare class MissingSlotValueError extends Error {
298
- readonly slot: TgpuSlot<unknown>;
299
- constructor(slot: TgpuSlot<unknown>);
300
- }
301
- /**
302
- * @category Errors
303
- */
304
- declare class NotUniformError extends Error {
305
- constructor(value: TgpuBuffer<AnyData>);
306
- }
307
- declare class MissingLinksError extends Error {
308
- constructor(fnLabel: string | undefined, externalNames: string[]);
309
- }
310
- declare class MissingBindGroupsError extends Error {
311
- constructor(layouts: Iterable<TgpuBindGroupLayout>);
312
- }
313
- declare class MissingVertexBuffersError extends Error {
314
- constructor(layouts: Iterable<TgpuVertexLayout<WgslArray | Disarray>>);
315
- }
316
-
317
- /**
318
- * @module typegpu
319
- */
320
-
321
- declare const tgpu: {
322
- fn: typeof fn;
323
- bindGroupLayout: typeof bindGroupLayout;
324
- vertexLayout: typeof vertexLayout;
325
- slot: typeof slot;
326
- init: typeof init;
327
- initFromDevice: typeof initFromDevice;
328
- resolve: typeof resolve;
329
- resolveWithContext: typeof resolveWithContext;
330
- privateVar: typeof privateVar;
331
- workgroupVar: typeof workgroupVar;
332
- const: typeof constant;
333
- '~unstable': {
334
- /**
335
- * @deprecated This feature is now stable, use tgpu.fn.
336
- */
337
- fn: typeof fn;
338
- fragmentFn: typeof fragmentFn;
339
- vertexFn: typeof vertexFn;
340
- computeFn: typeof computeFn;
341
- /**
342
- * @deprecated This feature is now stable, use tgpu.vertexLayout.
343
- */
344
- vertexLayout: typeof vertexLayout;
345
- namespace: typeof namespace;
346
- derived: typeof derived;
347
- /**
348
- * @deprecated This feature is now stable, use tgpu.slot.
349
- */
350
- slot: typeof slot;
351
- accessor: typeof accessor;
352
- /**
353
- * @deprecated This feature is now stable, use tgpu.privateVar.
354
- */
355
- privateVar: typeof privateVar;
356
- /**
357
- * @deprecated This feature is now stable, use tgpu.workgroupVar.
358
- */
359
- workgroupVar: typeof workgroupVar;
360
- /**
361
- * @deprecated This feature is now stable, use tgpu.const.
362
- */
363
- const: typeof constant;
364
- declare: typeof declare;
365
- simulate: typeof simulate;
366
- };
367
- };
368
-
369
- export { Configurable, type InitFromDeviceOptions, type InitOptions, MissingBindGroupsError, MissingLinksError, MissingSlotValueError, MissingVertexBuffersError, type Namespace, NotUniformError, ResolutionError, TgpuAccessor, TgpuBindGroup, TgpuBindGroupLayout, TgpuBuffer, TgpuDerived, TgpuFn, TgpuRoot, TgpuSlot, TgpuVar, TgpuVertexLayout, tgpu as default, tgpu };
@@ -1,122 +0,0 @@
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-DzGgwe0I.cjs';
2
-
3
- /**
4
- * Returns a 2-by-2 identity matrix.
5
- * @returns {m2x2f} The result matrix.
6
- */
7
- declare const identity2: DualFn<() => m2x2f>;
8
- /**
9
- * Returns a 3-by-3 identity matrix.
10
- * @returns {m3x3f} The result matrix.
11
- */
12
- declare const identity3: DualFn<() => m3x3f>;
13
- /**
14
- * Returns a 4-by-4 identity matrix.
15
- * @returns {m4x4f} The result matrix.
16
- */
17
- declare const identity4: DualFn<() => m4x4f>;
18
- /**
19
- * Creates a 4-by-4 matrix which translates by the given vector v.
20
- * @param {v3f} vector - The vector by which to translate.
21
- * @returns {m4x4f} The translation matrix.
22
- */
23
- declare const translation4: DualFn<(vector: v3f) => m4x4f>;
24
- /**
25
- * Creates a 4-by-4 matrix which scales in each dimension by an amount given by the corresponding entry in the given vector.
26
- * @param {v3f} vector - A vector of three entries specifying the factor by which to scale in each dimension.
27
- * @returns {m4x4f} The scaling matrix.
28
- */
29
- declare const scaling4: DualFn<(vector: v3f) => m4x4f>;
30
- /**
31
- * Creates a 4-by-4 matrix which rotates around the x-axis by the given angle.
32
- * @param {number} angle - The angle by which to rotate (in radians).
33
- * @returns {m4x4f} The rotation matrix.
34
- */
35
- declare const rotationX4: DualFn<(a: number) => m4x4f>;
36
- /**
37
- * Creates a 4-by-4 matrix which rotates around the y-axis by the given angle.
38
- * @param {number} angle - The angle by which to rotate (in radians).
39
- * @returns {m4x4f} The rotation matrix.
40
- */
41
- declare const rotationY4: DualFn<(a: number) => m4x4f>;
42
- /**
43
- * Creates a 4-by-4 matrix which rotates around the z-axis by the given angle.
44
- * @param {number} angle - The angle by which to rotate (in radians).
45
- * @returns {m4x4f} The rotation matrix.
46
- */
47
- declare const rotationZ4: DualFn<(a: number) => m4x4f>;
48
- /**
49
- * Schema representing mat2x2f - a matrix with 2 rows and 2 columns, with elements of type f32.
50
- * Also a constructor function for this matrix type.
51
- *
52
- * @example
53
- * const zero2x2 = mat2x2f(); // filled with zeros
54
- *
55
- * @example
56
- * const mat = mat2x2f(0, 1, 2, 3);
57
- * mat.columns[0] // vec2f(0, 1)
58
- * mat.columns[1] // vec2f(2, 3)
59
- *
60
- * @example
61
- * const mat = mat2x2f(
62
- * vec2f(0, 1), // column 0
63
- * vec2f(1, 2), // column 1
64
- * );
65
- *
66
- * @example
67
- * const buffer = root.createBuffer(d.mat2x2f, d.mat2x2f(0, 1, 2, 3)); // buffer holding a d.mat2x2f value, with an initial value of ((0, 1), (2, 3))
68
- */
69
- declare const mat2x2f: Mat2x2f;
70
- /**
71
- * Schema representing mat3x3f - a matrix with 3 rows and 3 columns, with elements of type f32.
72
- * Also a constructor function for this matrix type.
73
- *
74
- * @example
75
- * const zero3x3 = mat3x3f(); // filled with zeros
76
- *
77
- * @example
78
- * const mat = mat3x3f(0, 1, 2, 3, 4, 5, 6, 7, 8);
79
- * mat.columns[0] // vec3f(0, 1, 2)
80
- * mat.columns[1] // vec3f(3, 4, 5)
81
- * mat.columns[2] // vec3f(6, 7, 8)
82
- *
83
- * @example
84
- * const mat = mat3x3f(
85
- * vec3f(0, 1, 2), // column 0
86
- * vec3f(2, 3, 4), // column 1
87
- * vec3f(5, 6, 7), // column 2
88
- * );
89
- *
90
- * @example
91
- * const buffer = root.createBuffer(d.mat3x3f, d.mat3x3f()); // buffer holding a d.mat3x3f value, with an initial value of mat3x3f filled with zeros
92
- */
93
- declare const mat3x3f: Mat3x3f;
94
- /**
95
- * Schema representing mat4x4f - a matrix with 4 rows and 4 columns, with elements of type f32.
96
- * Also a constructor function for this matrix type.
97
- *
98
- * @example
99
- * const zero4x4 = mat4x4f(); // filled with zeros
100
- *
101
- * @example
102
- * const mat = mat4x4f(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15);
103
- * mat.columns[0] // vec4f(0, 1, 2, 3)
104
- * mat.columns[1] // vec4f(4, 5, 6, 7)
105
- * mat.columns[2] // vec4f(8, 9, 10, 11)
106
- * mat.columns[3] // vec4f(12, 13, 14, 15)
107
- *
108
- * @example
109
- * const mat = mat4x4f(
110
- * vec4f(0, 1, 2, 3), // column 0
111
- * vec4f(4, 5, 6, 7), // column 1
112
- * vec4f(8, 9, 10, 11), // column 2
113
- * vec4f(12, 13, 14, 15), // column 3
114
- * );
115
- *
116
- * @example
117
- * const buffer = root.createBuffer(d.mat4x4f, d.mat4x4f()); // buffer holding a d.mat4x4f value, with an initial value of mat4x4f filled with zeros
118
- */
119
- declare const mat4x4f: Mat4x4f;
120
- declare function matToArray(mat: m2x2f | m3x3f | m4x4f): number[];
121
-
122
- export { mat3x3f as a, mat4x4f as b, matToArray as c, identity3 as d, identity4 as e, rotationY4 as f, rotationZ4 as g, identity2 as i, mat2x2f as m, rotationX4 as r, scaling4 as s, translation4 as t };
package/std/index.cjs DELETED
@@ -1,2 +0,0 @@
1
- "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } }var _chunkU3CXOCRGcjs = require('../chunk-U3CXOCRG.cjs');var _chunkM2P3FJT7cjs = require('../chunk-M2P3FJT7.cjs');var _chunkLL6NPRFEcjs = require('../chunk-LL6NPRFE.cjs');var _chunkA5APHF7Kcjs = require('../chunk-A5APHF7K.cjs');var Ct=_chunkA5APHF7Kcjs.Ma.call(void 0, ()=>{throw new Error("`discard` relies on GPU resources and cannot be executed outside of a draw call")},()=>_chunkA5APHF7Kcjs.aa.call(void 0, "discard;",_chunkA5APHF7Kcjs.q),"discard");var h=_chunkLL6NPRFEcjs.X[_chunkA5APHF7Kcjs.a].jsImpl,At=_chunkLL6NPRFEcjs.e[_chunkA5APHF7Kcjs.a].jsImpl,St=_chunkLL6NPRFEcjs.e[_chunkA5APHF7Kcjs.a].gpuImpl,Et=_chunkLL6NPRFEcjs.f[_chunkA5APHF7Kcjs.a].jsImpl,Dt=_chunkLL6NPRFEcjs.f[_chunkA5APHF7Kcjs.a].gpuImpl,$t=_chunkLL6NPRFEcjs.g[_chunkA5APHF7Kcjs.a].jsImpl,Ft=_chunkLL6NPRFEcjs.g[_chunkA5APHF7Kcjs.a].gpuImpl,Ot=_chunkLL6NPRFEcjs.h[_chunkA5APHF7Kcjs.a].jsImpl,Vt=_chunkLL6NPRFEcjs.h[_chunkA5APHF7Kcjs.a].gpuImpl,Lt=_chunkLL6NPRFEcjs.i[_chunkA5APHF7Kcjs.a].jsImpl,Wt=_chunkLL6NPRFEcjs.i[_chunkA5APHF7Kcjs.a].gpuImpl,Bt= exports.translate4 =_chunkA5APHF7Kcjs.Ma.call(void 0, (e,t)=>h(At(t),e),(e,t)=>_chunkA5APHF7Kcjs.aa.call(void 0, _chunkA5APHF7Kcjs.Ea`(${St(t)} * ${e})`,e.dataType),"translate4"),Nt= exports.scale4 =_chunkA5APHF7Kcjs.Ma.call(void 0, (e,t)=>h(Et(t),e),(e,t)=>_chunkA5APHF7Kcjs.aa.call(void 0, _chunkA5APHF7Kcjs.Ea`(${Dt(t)} * ${e})`,e.dataType),"scale4"),_t= exports.rotateX4 =_chunkA5APHF7Kcjs.Ma.call(void 0, (e,t)=>h($t(t),e),(e,t)=>_chunkA5APHF7Kcjs.aa.call(void 0, _chunkA5APHF7Kcjs.Ea`(${Ft(t)} * ${e})`,e.dataType),"rotateX4"),Mt= exports.rotateY4 =_chunkA5APHF7Kcjs.Ma.call(void 0, (e,t)=>h(Ot(t),e),(e,t)=>_chunkA5APHF7Kcjs.aa.call(void 0, _chunkA5APHF7Kcjs.Ea`(${Vt(t)} * ${e})`,e.dataType),"rotateY4"),Gt= exports.rotateZ4 =_chunkA5APHF7Kcjs.Ma.call(void 0, (e,t)=>h(Lt(t),e),(e,t)=>_chunkA5APHF7Kcjs.aa.call(void 0, _chunkA5APHF7Kcjs.Ea`(${Wt(t)} * ${e})`,e.dataType),"rotateZ4");var Pt=_chunkA5APHF7Kcjs.Ma.call(void 0, ()=>console.warn("workgroupBarrier is a no-op outside of CODEGEN mode."),()=>_chunkA5APHF7Kcjs.aa.call(void 0, "workgroupBarrier()",_chunkA5APHF7Kcjs.q),"workgroupBarrier"),Ut= exports.storageBarrier =_chunkA5APHF7Kcjs.Ma.call(void 0, ()=>console.warn("storageBarrier is a no-op outside of CODEGEN mode."),()=>_chunkA5APHF7Kcjs.aa.call(void 0, "storageBarrier()",_chunkA5APHF7Kcjs.q),"storageBarrier"),kt= exports.textureBarrier =_chunkA5APHF7Kcjs.Ma.call(void 0, ()=>console.warn("textureBarrier is a no-op outside of CODEGEN mode."),()=>_chunkA5APHF7Kcjs.aa.call(void 0, "textureBarrier()",_chunkA5APHF7Kcjs.q),"textureBarrier"),Xt= exports.atomicLoad =_chunkA5APHF7Kcjs.Ma.call(void 0, e=>{throw new Error("Atomic operations are not supported outside of CODEGEN mode.")},e=>{if(_chunkA5APHF7Kcjs.B.call(void 0, e.dataType)&&e.dataType.type==="atomic")return _chunkA5APHF7Kcjs.aa.call(void 0, _chunkA5APHF7Kcjs.Ea`atomicLoad(&${e})`,e.dataType.inner);throw new Error(`Invalid atomic type: ${_chunkA5APHF7Kcjs.mb.call(void 0, e.dataType)}`)},"atomicLoad"),Rt= exports.atomicStore =_chunkA5APHF7Kcjs.Ma.call(void 0, (e,t)=>{throw new Error("Atomic operations are not supported outside of CODEGEN mode.")},(e,t)=>{if(!_chunkA5APHF7Kcjs.B.call(void 0, e.dataType)||e.dataType.type!=="atomic")throw new Error(`Invalid atomic type: ${_chunkA5APHF7Kcjs.mb.call(void 0, e.dataType)}`);return _chunkA5APHF7Kcjs.aa.call(void 0, _chunkA5APHF7Kcjs.Ea`atomicStore(&${e}, ${t})`,_chunkA5APHF7Kcjs.q)},"atomicStore"),f=(e,t)=>e.dataType.type==="atomic"&&e.dataType.inner.type==="i32"?[e.dataType,_chunkA5APHF7Kcjs.Ua]:[e.dataType,_chunkA5APHF7Kcjs.Sa],Zt= exports.atomicAdd =_chunkA5APHF7Kcjs.Ma.call(void 0, (e,t)=>{throw new Error("Atomic operations are not supported outside of CODEGEN mode.")},(e,t)=>{if(_chunkA5APHF7Kcjs.B.call(void 0, e.dataType)&&e.dataType.type==="atomic")return _chunkA5APHF7Kcjs.aa.call(void 0, _chunkA5APHF7Kcjs.Ea`atomicAdd(&${e}, ${t})`,e.dataType.inner);throw new Error(`Invalid atomic type: ${_chunkA5APHF7Kcjs.mb.call(void 0, e.dataType)}`)},"atomicAdd",f),jt= exports.atomicSub =_chunkA5APHF7Kcjs.Ma.call(void 0, (e,t)=>{throw new Error("Atomic operations are not supported outside of CODEGEN mode.")},(e,t)=>{if(_chunkA5APHF7Kcjs.B.call(void 0, e.dataType)&&e.dataType.type==="atomic")return _chunkA5APHF7Kcjs.aa.call(void 0, _chunkA5APHF7Kcjs.Ea`atomicSub(&${e}, ${t})`,e.dataType.inner);throw new Error(`Invalid atomic type: ${_chunkA5APHF7Kcjs.mb.call(void 0, e.dataType)}`)},"atomicSub",f),Yt= exports.atomicMax =_chunkA5APHF7Kcjs.Ma.call(void 0, (e,t)=>{throw new Error("Atomic operations are not supported outside of CODEGEN mode.")},(e,t)=>{if(_chunkA5APHF7Kcjs.B.call(void 0, e.dataType)&&e.dataType.type==="atomic")return _chunkA5APHF7Kcjs.aa.call(void 0, _chunkA5APHF7Kcjs.Ea`atomicMax(&${e}, ${t})`,e.dataType.inner);throw new Error(`Invalid atomic type: ${_chunkA5APHF7Kcjs.mb.call(void 0, e.dataType)}`)},"atomicMax",f),qt= exports.atomicMin =_chunkA5APHF7Kcjs.Ma.call(void 0, (e,t)=>{throw new Error("Atomic operations are not supported outside of CODEGEN mode.")},(e,t)=>{if(_chunkA5APHF7Kcjs.B.call(void 0, e.dataType)&&e.dataType.type==="atomic")return _chunkA5APHF7Kcjs.aa.call(void 0, _chunkA5APHF7Kcjs.Ea`atomicMin(&${e}, ${t})`,e.dataType.inner);throw new Error(`Invalid atomic type: ${_chunkA5APHF7Kcjs.mb.call(void 0, e.dataType)}`)},"atomicMin",f),zt= exports.atomicAnd =_chunkA5APHF7Kcjs.Ma.call(void 0, (e,t)=>{throw new Error("Atomic operations are not supported outside of CODEGEN mode.")},(e,t)=>{if(_chunkA5APHF7Kcjs.B.call(void 0, e.dataType)&&e.dataType.type==="atomic")return _chunkA5APHF7Kcjs.aa.call(void 0, _chunkA5APHF7Kcjs.Ea`atomicAnd(&${e}, ${t})`,e.dataType.inner);throw new Error(`Invalid atomic type: ${_chunkA5APHF7Kcjs.mb.call(void 0, e.dataType)}`)},"atomicAnd",f),Ht= exports.atomicOr =_chunkA5APHF7Kcjs.Ma.call(void 0, (e,t)=>{throw new Error("Atomic operations are not supported outside of CODEGEN mode.")},(e,t)=>{if(_chunkA5APHF7Kcjs.B.call(void 0, e.dataType)&&e.dataType.type==="atomic")return _chunkA5APHF7Kcjs.aa.call(void 0, _chunkA5APHF7Kcjs.Ea`atomicOr(&${e}, ${t})`,e.dataType.inner);throw new Error(`Invalid atomic type: ${_chunkA5APHF7Kcjs.mb.call(void 0, e.dataType)}`)},"atomicOr",f),Jt= exports.atomicXor =_chunkA5APHF7Kcjs.Ma.call(void 0, (e,t)=>{throw new Error("Atomic operations are not supported outside of CODEGEN mode.")},(e,t)=>{if(_chunkA5APHF7Kcjs.B.call(void 0, e.dataType)&&e.dataType.type==="atomic")return _chunkA5APHF7Kcjs.aa.call(void 0, _chunkA5APHF7Kcjs.Ea`atomicXor(&${e}, ${t})`,e.dataType.inner);throw new Error(`Invalid atomic type: ${_chunkA5APHF7Kcjs.mb.call(void 0, e.dataType)}`)},"atomicXor",f);function Kt(e){throw new Error("Derivative builtins are not allowed on the cpu")}var Qt=_chunkA5APHF7Kcjs.Ma.call(void 0, Kt,e=>_chunkA5APHF7Kcjs.aa.call(void 0, _chunkA5APHF7Kcjs.Ea`dpdx(${e})`,e.dataType),"dpdx");function er(e){throw new Error("Derivative builtins are not allowed on the cpu")}var tr=_chunkA5APHF7Kcjs.Ma.call(void 0, er,e=>_chunkA5APHF7Kcjs.aa.call(void 0, _chunkA5APHF7Kcjs.Ea`dpdxCoarse(${e})`,e.dataType),"dpdxCoarse");function rr(e){throw new Error("Derivative builtins are not allowed on the cpu")}var or=_chunkA5APHF7Kcjs.Ma.call(void 0, rr,e=>_chunkA5APHF7Kcjs.aa.call(void 0, _chunkA5APHF7Kcjs.Ea`dpdxFine(${e})`,e.dataType),"dpdxFine");function nr(e){throw new Error("Derivative builtins are not allowed on the cpu")}var ur=_chunkA5APHF7Kcjs.Ma.call(void 0, nr,e=>_chunkA5APHF7Kcjs.aa.call(void 0, _chunkA5APHF7Kcjs.Ea`dpdy(${e})`,e.dataType),"dpdy");function ar(e){throw new Error("Derivative builtins are not allowed on the cpu")}var pr=_chunkA5APHF7Kcjs.Ma.call(void 0, ar,e=>_chunkA5APHF7Kcjs.aa.call(void 0, _chunkA5APHF7Kcjs.Ea`dpdyCoarse(${e})`,e.dataType),"dpdyCoarse");function sr(e){throw new Error("Derivative builtins are not allowed on the cpu")}var ir=_chunkA5APHF7Kcjs.Ma.call(void 0, sr,e=>_chunkA5APHF7Kcjs.aa.call(void 0, _chunkA5APHF7Kcjs.Ea`dpdyFine(${e})`,e.dataType),"dpdyFine");function mr(e){throw new Error("Derivative builtins are not allowed on the cpu")}var dr=_chunkA5APHF7Kcjs.Ma.call(void 0, mr,e=>_chunkA5APHF7Kcjs.aa.call(void 0, _chunkA5APHF7Kcjs.Ea`fwidth(${e})`,e.dataType),"fwidth");function lr(e){throw new Error("Derivative builtins are not allowed on the cpu")}var cr=_chunkA5APHF7Kcjs.Ma.call(void 0, lr,e=>_chunkA5APHF7Kcjs.aa.call(void 0, _chunkA5APHF7Kcjs.Ea`fwidthCoarse(${e})`,e.dataType),"fwidthCoarse");function xr(e){throw new Error("Derivative builtins are not allowed on the cpu")}var Tr=_chunkA5APHF7Kcjs.Ma.call(void 0, xr,e=>_chunkA5APHF7Kcjs.aa.call(void 0, _chunkA5APHF7Kcjs.Ea`fwidthFine(${e})`,e.dataType),"fwidthFine");var k=e=>_chunkA5APHF7Kcjs.E.call(void 0, e)&&_chunkA5APHF7Kcjs.C.call(void 0, e.inner)?e.inner.elementCount:0,fr= exports.arrayLength =_chunkA5APHF7Kcjs.Oa.call(void 0, {name:"arrayLength",signature:e=>{let t=_chunkA5APHF7Kcjs.E.call(void 0, e)?e:_chunkM2P3FJT7cjs.a.call(void 0, e);return{argTypes:[t],returnType:k(t)>0?_chunkA5APHF7Kcjs.Pa:_chunkA5APHF7Kcjs.Sa}},normalImpl:e=>e.length,codegenImpl(e){let t=k(e.dataType);return t>0?String(t):_chunkA5APHF7Kcjs.Ea`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=_chunkA5APHF7Kcjs.Oa.call(void 0, {name:"textureSample",normalImpl:yr,codegenImpl:(...e)=>_chunkA5APHF7Kcjs.Ea`textureSample(${e})`,signature:(...e)=>{let t=e[0].type.startsWith("texture_depth");return{argTypes:e,returnType:t?_chunkA5APHF7Kcjs.Va:_chunkA5APHF7Kcjs.gb}}});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=_chunkA5APHF7Kcjs.Oa.call(void 0, {name:"textureSampleBias",normalImpl:vr,codegenImpl:(...e)=>_chunkA5APHF7Kcjs.Ea`textureSampleBias(${e})`,signature:(...e)=>({argTypes:e,returnType:_chunkA5APHF7Kcjs.gb})});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=_chunkA5APHF7Kcjs.Oa.call(void 0, {name:"textureSampleLevel",normalImpl:Ir,codegenImpl:(...e)=>_chunkA5APHF7Kcjs.Ea`textureSampleLevel(${e})`,signature:(...e)=>{let t=e[0].type.startsWith("texture_depth");return{argTypes:e,returnType:t?_chunkA5APHF7Kcjs.Va:_chunkA5APHF7Kcjs.gb}}});function wr(e,t,d){throw new Error("`textureLoad` relies on GPU resources and cannot be executed outside of a draw call")}var Cr=_chunkA5APHF7Kcjs.Oa.call(void 0, {name:"textureLoad",normalImpl:wr,codegenImpl:(...e)=>_chunkA5APHF7Kcjs.Ea`textureLoad(${e})`,signature:(...e)=>{let t=e[0];if(_chunkLL6NPRFEcjs.P.call(void 0, t)){let s=t.type.startsWith("texture_depth"),v=t.sampleType;return{argTypes:e,returnType:s?_chunkA5APHF7Kcjs.Va:v.type==="f32"?_chunkA5APHF7Kcjs.gb:v.type==="u32"?_chunkA5APHF7Kcjs.jb:_chunkA5APHF7Kcjs.ib}}let d=t.format,i=_chunkU3CXOCRGcjs.a[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=_chunkA5APHF7Kcjs.Oa.call(void 0, {name:"textureStore",normalImpl:Ar,codegenImpl:(...e)=>_chunkA5APHF7Kcjs.Ea`textureStore(${e})`,signature:(...e)=>({argTypes:e,returnType:_chunkA5APHF7Kcjs.q})});function Er(e,t){throw new Error("`textureDimensions` relies on GPU resources and cannot be executed outside of a draw call")}var Dr=_chunkA5APHF7Kcjs.Oa.call(void 0, {name:"textureDimensions",normalImpl:Er,codegenImpl:(...e)=>_chunkA5APHF7Kcjs.Ea`textureDimensions(${e})`,signature:(...e)=>{let t=e[0].dimension;return t==="1d"?{argTypes:e,returnType:_chunkA5APHF7Kcjs.Sa}:t==="3d"?{argTypes:e,returnType:_chunkA5APHF7Kcjs.eb}:{argTypes:e,returnType:_chunkA5APHF7Kcjs.$a}}});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=_chunkA5APHF7Kcjs.Oa.call(void 0, {name:"textureSampleCompare",normalImpl:$r,codegenImpl:(...e)=>_chunkA5APHF7Kcjs.Ea`textureSampleCompare(${e})`,signature:(...e)=>({argTypes:e,returnType:_chunkA5APHF7Kcjs.Va})});function Or(e,t,d){throw new Error("Texture sampling with base clamp to edge is not supported outside of GPU mode.")}var Vr=_chunkA5APHF7Kcjs.Oa.call(void 0, {name:"textureSampleBaseClampToEdge",normalImpl:Or,codegenImpl:(...e)=>_chunkA5APHF7Kcjs.Ea`textureSampleBaseClampToEdge(${e})`,signature:(...e)=>({argTypes:e,returnType:_chunkA5APHF7Kcjs.gb})});var a="Subgroup operations can only be used in the GPU context.",Lr= exports.subgroupAdd =_chunkA5APHF7Kcjs.Oa.call(void 0, {name:"subgroupAdd",signature:e=>({argTypes:[e],returnType:e}),normalImpl:a,codegenImpl:e=>_chunkA5APHF7Kcjs.Ea`subgroupAdd(${e})`}),Wr= exports.subgroupExclusiveAdd =_chunkA5APHF7Kcjs.Oa.call(void 0, {name:"subgroupExclusiveAdd",signature:e=>({argTypes:[e],returnType:e}),normalImpl:a,codegenImpl:e=>_chunkA5APHF7Kcjs.Ea`subgroupExclusiveAdd(${e})`}),Br= exports.subgroupInclusiveAdd =_chunkA5APHF7Kcjs.Oa.call(void 0, {name:"subgroupInclusiveAdd",signature:e=>({argTypes:[e],returnType:e}),normalImpl:a,codegenImpl:e=>_chunkA5APHF7Kcjs.Ea`subgroupInclusiveAdd(${e})`}),Nr= exports.subgroupAll =_chunkA5APHF7Kcjs.Oa.call(void 0, {name:"subgroupAll",signature:{argTypes:[_chunkA5APHF7Kcjs.Ra],returnType:_chunkA5APHF7Kcjs.Ra},normalImpl:a,codegenImpl:e=>_chunkA5APHF7Kcjs.Ea`subgroupAll(${e})`}),_r= exports.subgroupAnd =_chunkA5APHF7Kcjs.Oa.call(void 0, {name:"subgroupAnd",signature:e=>({argTypes:[e],returnType:e}),normalImpl:a,codegenImpl:e=>_chunkA5APHF7Kcjs.Ea`subgroupAnd(${e})`}),Mr= exports.subgroupAny =_chunkA5APHF7Kcjs.Oa.call(void 0, {name:"subgroupAny",signature:{argTypes:[_chunkA5APHF7Kcjs.Ra],returnType:_chunkA5APHF7Kcjs.Ra},normalImpl:a,codegenImpl:e=>_chunkA5APHF7Kcjs.Ea`subgroupAny(${e})`}),Gr= exports.subgroupBallot =_chunkA5APHF7Kcjs.Oa.call(void 0, {name:"subgroupBallot",signature:{argTypes:[_chunkA5APHF7Kcjs.Ra],returnType:_chunkA5APHF7Kcjs.jb},normalImpl:a,codegenImpl:e=>_chunkA5APHF7Kcjs.Ea`subgroupBallot(${e})`}),Pr= exports.subgroupBroadcast =_chunkA5APHF7Kcjs.Oa.call(void 0, {name:"subgroupBroadcast",signature:(...e)=>{let t=_chunkA5APHF7Kcjs.Ia.call(void 0, [e[1]],[_chunkA5APHF7Kcjs.Ua,_chunkA5APHF7Kcjs.Sa]);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)=>_chunkA5APHF7Kcjs.Ea`subgroupBroadcast(${e}, ${t})`}),Ur= exports.subgroupBroadcastFirst =_chunkA5APHF7Kcjs.Oa.call(void 0, {name:"subgroupBroadcastFirst",signature:e=>({argTypes:[e],returnType:e}),normalImpl:a,codegenImpl:e=>_chunkA5APHF7Kcjs.Ea`subgroupBroadcastFirst(${e})`}),kr= exports.subgroupElect =_chunkA5APHF7Kcjs.Oa.call(void 0, {name:"subgroupElect",signature:{argTypes:[],returnType:_chunkA5APHF7Kcjs.Ra},normalImpl:a,codegenImpl:()=>_chunkA5APHF7Kcjs.Ea`subgroupElect()`}),Xr= exports.subgroupMax =_chunkA5APHF7Kcjs.Oa.call(void 0, {name:"subgroupMax",signature:e=>({argTypes:[e],returnType:e}),normalImpl:a,codegenImpl:e=>_chunkA5APHF7Kcjs.Ea`subgroupMax(${e})`}),Rr= exports.subgroupMin =_chunkA5APHF7Kcjs.Oa.call(void 0, {name:"subgroupMin",signature:e=>({argTypes:[e],returnType:e}),normalImpl:a,codegenImpl:e=>_chunkA5APHF7Kcjs.Ea`subgroupMin(${e})`}),Zr= exports.subgroupMul =_chunkA5APHF7Kcjs.Oa.call(void 0, {name:"subgroupMul",signature:e=>({argTypes:[e],returnType:e}),normalImpl:a,codegenImpl:e=>_chunkA5APHF7Kcjs.Ea`subgroupMul(${e})`}),jr= exports.subgroupExclusiveMul =_chunkA5APHF7Kcjs.Oa.call(void 0, {name:"subgroupExclusiveMul",signature:e=>({argTypes:[e],returnType:e}),normalImpl:a,codegenImpl:e=>_chunkA5APHF7Kcjs.Ea`subgroupExclusiveMul(${e})`}),Yr= exports.subgroupInclusiveMul =_chunkA5APHF7Kcjs.Oa.call(void 0, {name:"subgroupInclusiveMul",signature:e=>({argTypes:[e],returnType:e}),normalImpl:a,codegenImpl:e=>_chunkA5APHF7Kcjs.Ea`subgroupInclusiveMul(${e})`}),qr= exports.subgroupOr =_chunkA5APHF7Kcjs.Oa.call(void 0, {name:"subgroupOr",signature:e=>({argTypes:[e],returnType:e}),normalImpl:a,codegenImpl:e=>_chunkA5APHF7Kcjs.Ea`subgroupOr(${e})`}),zr= exports.subgroupShuffle =_chunkA5APHF7Kcjs.Oa.call(void 0, {name:"subgroupShuffle",signature:(...e)=>{let t=_chunkA5APHF7Kcjs.Ia.call(void 0, [e[1]],[_chunkA5APHF7Kcjs.Ua,_chunkA5APHF7Kcjs.Sa]);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)=>_chunkA5APHF7Kcjs.Ea`subgroupShuffle(${e}, ${t})`}),Hr= exports.subgroupShuffleDown =_chunkA5APHF7Kcjs.Oa.call(void 0, {name:"subgroupShuffleDown",signature:(...e)=>{let t=_chunkA5APHF7Kcjs.Ia.call(void 0, [e[1]],[_chunkA5APHF7Kcjs.Sa]);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)=>_chunkA5APHF7Kcjs.Ea`subgroupShuffleDown(${e}, ${t})`}),Jr= exports.subgroupShuffleUp =_chunkA5APHF7Kcjs.Oa.call(void 0, {name:"subgroupShuffleUp",signature:(...e)=>{let t=_chunkA5APHF7Kcjs.Ia.call(void 0, [e[1]],[_chunkA5APHF7Kcjs.Sa]);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)=>_chunkA5APHF7Kcjs.Ea`subgroupShuffleUp(${e}, ${t})`}),Kr= exports.subgroupShuffleXor =_chunkA5APHF7Kcjs.Oa.call(void 0, {name:"subgroupShuffleXor",signature:(...e)=>{let t=_chunkA5APHF7Kcjs.Ia.call(void 0, [e[1]],[_chunkA5APHF7Kcjs.Sa]);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)=>_chunkA5APHF7Kcjs.Ea`subgroupShuffleXor(${e}, ${t})`}),Qr= exports.subgroupXor =_chunkA5APHF7Kcjs.Oa.call(void 0, {name:"subgroupXor",signature:e=>({argTypes:[e],returnType:e}),normalImpl:a,codegenImpl:e=>_chunkA5APHF7Kcjs.Ea`subgroupXor(${e})`});var eo=(()=>{let e=i=>{let s=_chunkA5APHF7Kcjs.Aa.call(void 0, );if(!s)throw new Error("extensionEnabled can only be called in a GPU codegen context.");return(_nullishCoalesce(s.enableExtensions, () => ([]))).includes(i)},t=i=>{let{value:s}=i;if(typeof s!="string"||!_chunkU3CXOCRGcjs.i.includes(s))throw new Error(`extensionEnabled has to be called with a string literal representing a valid WGSL extension name. Got: ${s}`);return _chunkA5APHF7Kcjs.aa.call(void 0, e(s),_chunkA5APHF7Kcjs.Ra)},d=i=>{if(_chunkA5APHF7Kcjs.Da.call(void 0, ))return t(i);throw new Error("extensionEnabled can only be called in a GPU codegen context.")};return Object.defineProperty(d,_chunkA5APHF7Kcjs.a,{value:{jsImpl:e,gpuImpl:t,argConversionHint:"keep"}}),d})();exports.abs = _chunkLL6NPRFEcjs.$; exports.acos = _chunkLL6NPRFEcjs.aa; exports.acosh = _chunkLL6NPRFEcjs.ba; exports.add = _chunkLL6NPRFEcjs.V; exports.all = _chunkU3CXOCRGcjs.u; exports.allEq = _chunkU3CXOCRGcjs.k; exports.and = _chunkU3CXOCRGcjs.t; exports.any = _chunkU3CXOCRGcjs.v; exports.arrayLength = fr; exports.asin = _chunkLL6NPRFEcjs.ca; exports.asinh = _chunkLL6NPRFEcjs.da; exports.atan = _chunkLL6NPRFEcjs.ea; exports.atan2 = _chunkLL6NPRFEcjs.ga; exports.atanh = _chunkLL6NPRFEcjs.fa; exports.atomicAdd = Zt; exports.atomicAnd = zt; exports.atomicLoad = Xt; exports.atomicMax = Yt; exports.atomicMin = qt; exports.atomicOr = Ht; exports.atomicStore = Rt; exports.atomicSub = jt; exports.atomicXor = Jt; exports.bitcastU32toF32 = _chunkU3CXOCRGcjs.c; exports.bitcastU32toI32 = _chunkU3CXOCRGcjs.d; exports.ceil = _chunkLL6NPRFEcjs.ha; exports.clamp = _chunkLL6NPRFEcjs.ia; exports.cos = _chunkLL6NPRFEcjs.ja; exports.cosh = _chunkLL6NPRFEcjs.ka; exports.countLeadingZeros = _chunkLL6NPRFEcjs.la; exports.countOneBits = _chunkLL6NPRFEcjs.ma; exports.countTrailingZeros = _chunkLL6NPRFEcjs.na; exports.cross = _chunkLL6NPRFEcjs.oa; exports.degrees = _chunkLL6NPRFEcjs.pa; exports.determinant = _chunkLL6NPRFEcjs.qa; exports.discard = Ct; exports.distance = _chunkLL6NPRFEcjs.ra; exports.div = _chunkLL6NPRFEcjs.Y; exports.dot = _chunkLL6NPRFEcjs.sa; exports.dot4I8Packed = _chunkLL6NPRFEcjs.ua; exports.dot4U8Packed = _chunkLL6NPRFEcjs.ta; exports.dpdx = Qt; exports.dpdxCoarse = tr; exports.dpdxFine = or; exports.dpdy = ur; exports.dpdyCoarse = pr; exports.dpdyFine = ir; exports.eq = _chunkU3CXOCRGcjs.l; exports.exp = _chunkLL6NPRFEcjs.va; exports.exp2 = _chunkLL6NPRFEcjs.wa; exports.extensionEnabled = eo; exports.extractBits = _chunkLL6NPRFEcjs.xa; exports.faceForward = _chunkLL6NPRFEcjs.ya; exports.firstLeadingBit = _chunkLL6NPRFEcjs.za; exports.firstTrailingBit = _chunkLL6NPRFEcjs.Aa; exports.floor = _chunkLL6NPRFEcjs.Ba; exports.fma = _chunkLL6NPRFEcjs.Ca; exports.fract = _chunkLL6NPRFEcjs.Da; exports.frexp = _chunkLL6NPRFEcjs.Ea; exports.fwidth = dr; exports.fwidthCoarse = cr; exports.fwidthFine = Tr; exports.ge = _chunkU3CXOCRGcjs.q; exports.gt = _chunkU3CXOCRGcjs.p; exports.identity2 = _chunkLL6NPRFEcjs.b; exports.identity3 = _chunkLL6NPRFEcjs.c; exports.identity4 = _chunkLL6NPRFEcjs.d; exports.insertBits = _chunkLL6NPRFEcjs.Fa; exports.inverseSqrt = _chunkLL6NPRFEcjs.Ga; exports.isCloseTo = _chunkU3CXOCRGcjs.w; exports.ldexp = _chunkLL6NPRFEcjs.Ha; exports.le = _chunkU3CXOCRGcjs.o; exports.length = _chunkLL6NPRFEcjs.Ia; exports.log = _chunkLL6NPRFEcjs.Ja; exports.log2 = _chunkLL6NPRFEcjs.Ka; exports.lt = _chunkU3CXOCRGcjs.n; exports.max = _chunkLL6NPRFEcjs.La; exports.min = _chunkLL6NPRFEcjs.Ma; exports.mix = _chunkLL6NPRFEcjs.Na; exports.mod = _chunkLL6NPRFEcjs.Z; exports.modf = _chunkLL6NPRFEcjs.Oa; exports.mul = _chunkLL6NPRFEcjs.X; exports.ne = _chunkU3CXOCRGcjs.m; exports.neg = _chunkLL6NPRFEcjs._; exports.normalize = _chunkLL6NPRFEcjs.Pa; exports.not = _chunkU3CXOCRGcjs.r; exports.or = _chunkU3CXOCRGcjs.s; exports.pack2x16float = _chunkU3CXOCRGcjs.f; exports.pack4x8unorm = _chunkU3CXOCRGcjs.h; exports.pow = _chunkLL6NPRFEcjs.Qa; exports.quantizeToF16 = _chunkLL6NPRFEcjs.Ra; exports.radians = _chunkLL6NPRFEcjs.Sa; exports.reflect = _chunkLL6NPRFEcjs.Ta; exports.refract = _chunkLL6NPRFEcjs.Ua; exports.reverseBits = _chunkLL6NPRFEcjs.Va; exports.rotateX4 = _t; exports.rotateY4 = Mt; exports.rotateZ4 = Gt; exports.rotationX4 = _chunkLL6NPRFEcjs.g; exports.rotationY4 = _chunkLL6NPRFEcjs.h; exports.rotationZ4 = _chunkLL6NPRFEcjs.i; exports.round = _chunkLL6NPRFEcjs.Wa; exports.saturate = _chunkLL6NPRFEcjs.Xa; exports.scale4 = Nt; exports.scaling4 = _chunkLL6NPRFEcjs.f; exports.select = _chunkU3CXOCRGcjs.x; exports.sign = _chunkLL6NPRFEcjs.Ya; exports.sin = _chunkLL6NPRFEcjs.Za; exports.sinh = _chunkLL6NPRFEcjs._a; exports.smoothstep = _chunkLL6NPRFEcjs.$a; exports.sqrt = _chunkLL6NPRFEcjs.ab; exports.step = _chunkLL6NPRFEcjs.bb; exports.storageBarrier = Ut; exports.sub = _chunkLL6NPRFEcjs.W; exports.subgroupAdd = Lr; exports.subgroupAll = Nr; exports.subgroupAnd = _r; exports.subgroupAny = Mr; exports.subgroupBallot = Gr; exports.subgroupBroadcast = Pr; exports.subgroupBroadcastFirst = Ur; exports.subgroupElect = kr; exports.subgroupExclusiveAdd = Wr; exports.subgroupExclusiveMul = jr; exports.subgroupInclusiveAdd = Br; exports.subgroupInclusiveMul = Yr; exports.subgroupMax = Xr; exports.subgroupMin = Rr; exports.subgroupMul = Zr; exports.subgroupOr = qr; exports.subgroupShuffle = zr; exports.subgroupShuffleDown = Hr; exports.subgroupShuffleUp = Jr; exports.subgroupShuffleXor = Kr; exports.subgroupXor = Qr; exports.tan = _chunkLL6NPRFEcjs.cb; exports.tanh = _chunkLL6NPRFEcjs.db; exports.textureBarrier = kt; exports.textureDimensions = Dr; exports.textureLoad = Cr; exports.textureSample = br; exports.textureSampleBaseClampToEdge = Vr; exports.textureSampleBias = gr; exports.textureSampleCompare = Fr; exports.textureSampleLevel = hr; exports.textureStore = Sr; exports.translate4 = Bt; exports.translation4 = _chunkLL6NPRFEcjs.e; exports.transpose = _chunkLL6NPRFEcjs.eb; exports.trunc = _chunkLL6NPRFEcjs.fb; exports.unpack2x16float = _chunkU3CXOCRGcjs.e; exports.unpack4x8unorm = _chunkU3CXOCRGcjs.g; exports.workgroupBarrier = Pt;
2
- //# sourceMappingURL=index.cjs.map
package/std/index.cjs.map DELETED
@@ -1 +0,0 @@
1
- {"version":3,"sources":["/Users/iwo/Projects/wigsill/packages/typegpu/dist/std/index.cjs","../../src/std/discard.ts","../../src/std/matrix.ts","../../src/std/atomic.ts"],"names":["discard","createDualImpl","snip","Void","cpuMul","mul","$internal","cpuTranslation4","translation4","gpuTranslation4","cpuScaling4","scaling4","gpuScaling4","cpuRotationX4","rotationX4","gpuRotationX4","cpuRotationY4","rotationY4","gpuRotationY4","cpuRotationZ4","rotationZ4","gpuRotationZ4","translate4","matrix","vector","stitch","scale4","rotateX4","angle","rotateY4","rotateZ4","workgroupBarrier","storageBarrier","textureBarrier","atomicLoad","a","isWgslData","safeStringify"],"mappings":"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","file":"/Users/iwo/Projects/wigsill/packages/typegpu/dist/std/index.cjs","sourcesContent":[null,"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"]}