typegpu 0.6.0 → 0.7.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 (42) hide show
  1. package/chunk-3K53YJSU.cjs +10 -0
  2. package/chunk-3K53YJSU.cjs.map +1 -0
  3. package/chunk-BF35NEOX.cjs +43 -0
  4. package/chunk-BF35NEOX.cjs.map +1 -0
  5. package/chunk-IH2QU6TV.js +43 -0
  6. package/chunk-IH2QU6TV.js.map +1 -0
  7. package/chunk-S27MYQ6U.js +10 -0
  8. package/chunk-S27MYQ6U.js.map +1 -0
  9. package/data/index.cjs +1 -1
  10. package/data/index.cjs.map +1 -1
  11. package/data/index.d.cts +3 -3
  12. package/data/index.d.ts +3 -3
  13. package/data/index.js +1 -1
  14. package/index.cjs +18 -29
  15. package/index.cjs.map +1 -1
  16. package/index.d.cts +38 -3
  17. package/index.d.ts +38 -3
  18. package/index.js +18 -29
  19. package/index.js.map +1 -1
  20. package/{matrix-S8W4dk8I.d.ts → matrix-BXuR-7-A.d.ts} +1 -1
  21. package/{matrix-BN6ObiMv.d.cts → matrix-DzXuhOr3.d.cts} +1 -1
  22. package/package.json +1 -1
  23. package/std/index.cjs +1 -1
  24. package/std/index.cjs.map +1 -1
  25. package/std/index.d.cts +22 -9
  26. package/std/index.d.ts +22 -9
  27. package/std/index.js +1 -1
  28. package/std/index.js.map +1 -1
  29. package/{tgpuComputeFn-DOUjhQua.d.ts → tgpuConstant-BAmV6caN.d.cts} +3171 -2970
  30. package/{tgpuComputeFn-DOUjhQua.d.cts → tgpuConstant-BAmV6caN.d.ts} +3171 -2970
  31. package/chunk-APTRHY5Y.js +0 -41
  32. package/chunk-APTRHY5Y.js.map +0 -1
  33. package/chunk-RC26P3MP.cjs +0 -2
  34. package/chunk-RC26P3MP.cjs.map +0 -1
  35. package/chunk-RK6TMFVW.js +0 -2
  36. package/chunk-RK6TMFVW.js.map +0 -1
  37. package/chunk-S62QJDM6.js +0 -2
  38. package/chunk-S62QJDM6.js.map +0 -1
  39. package/chunk-TG4A6AM3.cjs +0 -2
  40. package/chunk-TG4A6AM3.cjs.map +0 -1
  41. package/chunk-UMHCZDPA.cjs +0 -41
  42. package/chunk-UMHCZDPA.cjs.map +0 -1
package/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- import { T as TgpuBindGroupLayout, a as TgpuBindGroup, W as Wgsl, b as TgpuRoot, A as AnyWgslData, c as TgpuFn, d as TgpuBufferUsage, I as Infer, e as TgpuAccessor, f as TgpuDerived, g as TgpuSlot, h as TgpuVertexLayout, i as WgslArray, D as Disarray, j as TgpuBuffer, k as AnyData, l as fn, m as bindGroupLayout, v as vertexLayout, n as fragmentFn, o as vertexFn, p as computeFn, q as privateVar, w as workgroupVar, r as constant, s as declare, t as sampler, u as comparisonSampler } from './tgpuComputeFn-DOUjhQua.js';
2
- export { as as BindLayoutEntry, V as Configurable, ae as Eventual, at as ExtractBindGroupInputFromLayout, aL as INTERNAL_GlobalExt, a3 as IndexFlag, au as LayoutEntryToInput, R as RandomNameRegistry, am as Render, an as Sampled, $ as Storage, a0 as StorageFlag, S as StrictNameRegistry, al as TextureProps, af as TgpuAnyTextureView, a8 as TgpuBufferMutable, a9 as TgpuBufferReadonly, aa as TgpuBufferUniform, aI as TgpuComputeFn, aJ as TgpuComputeFnShell, a2 as TgpuComputePipeline, ao as TgpuConst, aK as TgpuDeclare, aD as TgpuFnShell, aG as TgpuFragmentFn, aH as TgpuFragmentFnShell, av as TgpuLayoutComparisonSampler, aw as TgpuLayoutEntry, ax as TgpuLayoutExternalTexture, ay as TgpuLayoutSampler, az as TgpuLayoutStorage, aA as TgpuLayoutStorageTexture, aB as TgpuLayoutTexture, aC as TgpuLayoutUniform, ab as TgpuMutable, ag as TgpuMutableTexture, ac as TgpuReadonly, ah as TgpuReadonlyTexture, a1 as TgpuRenderPipeline, ai as TgpuSampledTexture, ar as TgpuSampler, aj as TgpuTexture, ad as TgpuUniform, ap as TgpuVar, aE as TgpuVertexFn, aF as TgpuVertexFnShell, ak as TgpuWriteonlyTexture, a4 as Uniform, a5 as UniformFlag, aq as VariableScope, a6 as Vertex, a7 as VertexFlag, X as WithBinding, Y as WithCompute, Z as WithFragment, _ as WithVertex, x as isBuffer, Q as isBufferShorthand, C as isComparisonSampler, z as isDerived, F as isSampledTextureView, E as isSampler, B as isSlot, G as isStorageTextureView, H as isTexture, U as isTgpuFn, J as isUsableAsRender, K as isUsableAsSampled, L as isUsableAsStorage, P as isUsableAsUniform, y as isUsableAsVertex, M as unstable_asMutable, N as unstable_asReadonly, O as unstable_asUniform } from './tgpuComputeFn-DOUjhQua.js';
1
+ import { T as TgpuBindGroupLayout, a as TgpuBindGroup, W as Wgsl, C as Configurable, b as TgpuBuffer, A as AnyData, c as TgpuVar, d as TgpuRoot, e as AnyWgslData, f as TgpuFn, g as TgpuBufferUsage, I as Infer, h as TgpuAccessor, i as TgpuDerived, j as TgpuSlot, k as TgpuVertexLayout, l as WgslArray, D as Disarray, m as fn, n as bindGroupLayout, v as vertexLayout, o as fragmentFn, p as vertexFn, q as computeFn, r as privateVar, w as workgroupVar, s as constant, t as declare, u as sampler, x as comparisonSampler } from './tgpuConstant-BAmV6caN.js';
2
+ export { aq as BindLayoutEntry, ac as Eventual, ar as ExtractBindGroupInputFromLayout, aJ as INTERNAL_GlobalExt, a0 as IndexFlag, as as LayoutEntryToInput, ak as Render, al as Sampled, Y as Storage, Z as StorageFlag, aj as TextureProps, ad as TgpuAnyTextureView, a6 as TgpuBufferMutable, a7 as TgpuBufferReadonly, a8 as TgpuBufferUniform, aG as TgpuComputeFn, aH as TgpuComputeFnShell, $ as TgpuComputePipeline, am as TgpuConst, aI as TgpuDeclare, aB as TgpuFnShell, aE as TgpuFragmentFn, aF as TgpuFragmentFnShell, at as TgpuLayoutComparisonSampler, au as TgpuLayoutEntry, av as TgpuLayoutExternalTexture, aw as TgpuLayoutSampler, ax as TgpuLayoutStorage, ay as TgpuLayoutStorageTexture, az as TgpuLayoutTexture, aA as TgpuLayoutUniform, a9 as TgpuMutable, ae as TgpuMutableTexture, ap as TgpuQuerySet, aa as TgpuReadonly, af as TgpuReadonlyTexture, _ as TgpuRenderPipeline, ag as TgpuSampledTexture, ao as TgpuSampler, ah as TgpuTexture, ab as TgpuUniform, aC as TgpuVertexFn, aD as TgpuVertexFnShell, ai as TgpuWriteonlyTexture, a1 as Uniform, a2 as UniformFlag, a3 as ValidUsagesFor, V as ValidateBufferSchema, an as VariableScope, a4 as Vertex, a5 as VertexFlag, R as WithBinding, S as WithCompute, U as WithFragment, X as WithVertex, y as isBuffer, P as isBufferShorthand, F as isComparisonSampler, B as isDerived, H as isSampledTextureView, G as isSampler, E as isSlot, J as isStorageTextureView, K as isTexture, Q as isTgpuFn, L as isUsableAsRender, M as isUsableAsSampled, N as isUsableAsStorage, O as isUsableAsUniform, z as isUsableAsVertex } from './tgpuConstant-BAmV6caN.js';
3
3
  import 'tinyest';
4
4
 
5
5
  /**
@@ -30,6 +30,10 @@ interface TgpuResolveOptions {
30
30
  * @default 'random'
31
31
  */
32
32
  names?: 'strict' | 'random' | undefined;
33
+ /**
34
+ * A function to configure the resolution context.
35
+ */
36
+ config?: ((cfg: Configurable) => Configurable) | undefined;
33
37
  }
34
38
  /**
35
39
  * Resolves a template with external values. Each external will get resolved to a code string and replaced in the template.
@@ -104,6 +108,36 @@ declare function resolveWithContext(options: TgpuResolveOptions): ResolutionResu
104
108
  */
105
109
  declare function resolve(options: TgpuResolveOptions): string;
106
110
 
111
+ interface SimulationResult<T> {
112
+ value: T;
113
+ buffers: Map<TgpuBuffer<AnyData>, unknown>;
114
+ privateVars: Map<TgpuVar<'private', AnyData>, unknown>[][][];
115
+ workgroupVars: Map<TgpuVar<'workgroup', AnyData>, unknown>[][][];
116
+ }
117
+ /**
118
+ * Runs the provided callback in a simulated environment, giving
119
+ * it access to buffers and variables as if it were running on the GPU.
120
+ *
121
+ * The result of the simulation is returned, and does not affect the actual GPU state,
122
+ * nor does it carry over to other simulations.
123
+ *
124
+ * @param callback The callback to run in the simulated environment.
125
+ * @returns An object containing the result of the simulation, and
126
+ * the final state of the environment.
127
+ *
128
+ * @example
129
+ * const counter = tgpu.privateVar(d.u32);
130
+ *
131
+ * const result = tgpu.simulate(() => {
132
+ * counter.$ += 1;
133
+ * counter.$ += 2;
134
+ * return counter.$;
135
+ * });
136
+ *
137
+ * console.log(result.value); // 3
138
+ */
139
+ declare function simulate<T>(callback: () => T): SimulationResult<T>;
140
+
107
141
  /**
108
142
  * Options passed into {@link init}.
109
143
  */
@@ -232,7 +266,8 @@ declare const tgpu: {
232
266
  declare: typeof declare;
233
267
  sampler: typeof sampler;
234
268
  comparisonSampler: typeof comparisonSampler;
269
+ simulate: typeof simulate;
235
270
  };
236
271
  };
237
272
 
238
- export { type InitFromDeviceOptions, type InitOptions, MissingBindGroupsError, MissingLinksError, MissingSlotValueError, MissingVertexBuffersError, NotUniformError, ResolutionError, TgpuAccessor, TgpuBindGroup, TgpuBindGroupLayout, TgpuBuffer, TgpuDerived, TgpuFn, TgpuRoot, TgpuSlot, TgpuVertexLayout, tgpu as default, tgpu };
273
+ export { Configurable, type InitFromDeviceOptions, type InitOptions, MissingBindGroupsError, MissingLinksError, MissingSlotValueError, MissingVertexBuffersError, NotUniformError, ResolutionError, TgpuAccessor, TgpuBindGroup, TgpuBindGroupLayout, TgpuBuffer, TgpuDerived, TgpuFn, TgpuRoot, TgpuSlot, TgpuVar, TgpuVertexLayout, tgpu as default, tgpu };