typegpu 0.11.2 → 0.11.4

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 (51) hide show
  1. package/README.md +1 -1
  2. package/core/buffer/buffer.js +17 -53
  3. package/core/function/autoIO.js +2 -2
  4. package/core/function/entryInputRouter.js +10 -16
  5. package/core/function/fnCore.js +16 -12
  6. package/core/function/shelllessImpl.js +1 -1
  7. package/core/function/tgpuComputeFn.js +1 -1
  8. package/core/function/tgpuFn.js +1 -1
  9. package/core/function/tgpuFragmentFn.d.ts +1 -1
  10. package/core/function/tgpuFragmentFn.js +1 -1
  11. package/core/function/tgpuVertexFn.js +1 -1
  12. package/core/pipeline/computePipeline.d.ts +1 -1
  13. package/core/root/init.d.ts +1 -0
  14. package/core/root/init.js +6 -0
  15. package/core/root/rootTypes.d.ts +21 -15
  16. package/core/slot/accessor.js +1 -1
  17. package/data/dataIO.d.ts +11 -0
  18. package/data/dataIO.js +45 -1
  19. package/data/dataTypes.js +2 -11
  20. package/data/index.d.ts +3 -3
  21. package/data/numeric.js +16 -14
  22. package/data/partialIO.d.ts +8 -0
  23. package/data/partialIO.js +6 -1
  24. package/data/snippet.d.ts +1 -6
  25. package/data/wgslTypes.d.ts +2 -0
  26. package/index.d.ts +3 -1
  27. package/index.js +3 -1
  28. package/indexNamedExports.d.ts +2 -0
  29. package/package.js +1 -1
  30. package/package.json +1 -1
  31. package/resolutionCtx.js +82 -86
  32. package/shared/stringify.js +1 -0
  33. package/shared/tseynit.js +90 -0
  34. package/tgsl/accessIndex.js +4 -3
  35. package/tgsl/accessProp.js +7 -2
  36. package/tgsl/consoleLog/deserializers.js +1 -1
  37. package/tgsl/consoleLog/logGenerator.js +16 -14
  38. package/tgsl/consoleLog/types.d.ts +4 -5
  39. package/tgsl/conversion.js +15 -5
  40. package/tgsl/forOfUtils.js +14 -6
  41. package/tgsl/generationHelpers.d.ts +2 -1
  42. package/tgsl/generationHelpers.js +1 -4
  43. package/tgsl/jsPolyfills.d.ts +25 -0
  44. package/tgsl/jsPolyfills.js +44 -0
  45. package/tgsl/shaderGenerator.d.ts +2 -3
  46. package/tgsl/shaderGenerator_members.d.ts +15 -2
  47. package/tgsl/wgslGenerator.d.ts +3 -1
  48. package/tgsl/wgslGenerator.js +64 -59
  49. package/types.d.ts +11 -6
  50. package/tgsl/consoleLog/types.js +0 -12
  51. package/tgsl/math.js +0 -45
package/types.d.ts CHANGED
@@ -49,11 +49,17 @@ type ItemLayer = {
49
49
  type: 'item';
50
50
  usedSlots: Set<TgpuSlot<unknown>>;
51
51
  };
52
+ type FunctionArgumentAccess = () => Snippet | undefined;
53
+ interface FunctionArgument {
54
+ name: string;
55
+ access: FunctionArgumentAccess;
56
+ decoratedType: BaseData;
57
+ used: boolean;
58
+ }
52
59
  type FunctionScopeLayer = {
53
60
  type: 'functionScope';
54
61
  functionType: 'normal' | 'compute' | 'vertex' | 'fragment';
55
- args: Snippet[];
56
- argAliases: Record<string, Snippet>;
62
+ argAccess: Record<string, FunctionArgumentAccess>;
57
63
  externalMap: Record<string, unknown>;
58
64
  /**
59
65
  * The return type of the function. If undefined, the type should be inferred
@@ -81,7 +87,7 @@ interface ItemStateStack {
81
87
  readonly topFunctionScope: FunctionScopeLayer | undefined;
82
88
  pushItem(): void;
83
89
  pushSlotBindings(pairs: SlotValuePair[]): void;
84
- pushFunctionScope(functionType: 'normal' | TgpuShaderStage, args: Snippet[], argAliases: Record<string, Snippet>,
90
+ pushFunctionScope(functionType: 'normal' | TgpuShaderStage, argAccess: Record<string, FunctionArgumentAccess>,
85
91
  /**
86
92
  * The return type of the function. If undefined, the type should be inferred
87
93
  * from the implementation (relevant for shellless functions).
@@ -217,8 +223,7 @@ interface ResolutionCtx {
217
223
  */
218
224
  resolveSnippet(snippet: Snippet): ResolvedSnippet;
219
225
  fnToWgsl(options: FnToWgslOptions): {
220
- head: Wgsl;
221
- body: Wgsl;
226
+ code: string;
222
227
  returnType: BaseData;
223
228
  };
224
229
  withVaryingLocations<T>(locations: Record<string, number>, callback: () => T): T;
@@ -261,4 +266,4 @@ type AnyFn = (...args: never[]) => unknown;
261
266
  type DualFn<T extends AnyFn> = T & GPUCallable<Parameters<T>>;
262
267
  type BindableBufferUsage = 'uniform' | 'readonly' | 'mutable';
263
268
  //#endregion
264
- export { BindableBufferUsage, DualFn, FunctionScopeLayer, GPUCallable, ResolutionCtx, ResolvableObject, SelfResolvable, TgpuShaderStage, Wgsl, WithCast };
269
+ export { BindableBufferUsage, DualFn, FunctionArgument, FunctionScopeLayer, GPUCallable, ResolutionCtx, ResolvableObject, SelfResolvable, TgpuShaderStage, Wgsl, WithCast };
@@ -1,12 +0,0 @@
1
- //#region src/tgsl/consoleLog/types.ts
2
- const supportedLogOps = [
3
- "log",
4
- "debug",
5
- "info",
6
- "warn",
7
- "error",
8
- "clear"
9
- ];
10
-
11
- //#endregion
12
- export { supportedLogOps };
package/tgsl/math.js DELETED
@@ -1,45 +0,0 @@
1
- import { f32 } from "../data/numeric.js";
2
- import { abs, acos, acosh, asin, asinh, atan, atan2, atanh, ceil, cos, cosh, countLeadingZeros, exp, floor, log, log2, max, min, pow, sign, sin, sinh, sqrt, tan, tanh, trunc } from "../std/numeric.js";
3
-
4
- //#region src/tgsl/math.ts
5
- const mathToStd = {
6
- abs,
7
- acos,
8
- acosh,
9
- asin,
10
- asinh,
11
- atan,
12
- atan2,
13
- atanh,
14
- ceil,
15
- cos,
16
- cosh,
17
- exp,
18
- floor,
19
- fround: f32,
20
- clz32: countLeadingZeros,
21
- trunc,
22
- log,
23
- log2,
24
- pow,
25
- sign,
26
- sin,
27
- sinh,
28
- sqrt,
29
- tan,
30
- tanh,
31
- max,
32
- min,
33
- cbrt: void 0,
34
- log10: void 0,
35
- log1p: void 0,
36
- f16round: void 0,
37
- hypot: void 0,
38
- expm1: void 0,
39
- random: void 0,
40
- imul: void 0,
41
- round: void 0
42
- };
43
-
44
- //#endregion
45
- export { mathToStd };