typegpu 0.12.9 → 0.12.10

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 (98) hide show
  1. package/common/attachAutoResizer.d.ts +33 -0
  2. package/common/attachAutoResizer.js +83 -0
  3. package/common/index.d.ts +1 -0
  4. package/common/index.js +1 -0
  5. package/common/writeSoA.js +4 -3
  6. package/core/commandEncoder/commandEncoder.d.ts +1 -1
  7. package/core/declare/tgpuDeclare.d.ts +10 -7
  8. package/core/declare/tgpuDeclare.js +25 -10
  9. package/core/function/comptime.d.ts +2 -0
  10. package/core/function/comptime.js +29 -24
  11. package/core/function/createCallableSchema.js +32 -37
  12. package/core/function/dualImpl.js +44 -44
  13. package/core/function/tgpuComputeFn.d.ts +0 -3
  14. package/core/function/tgpuFn.js +4 -4
  15. package/core/function/tgpuFragmentFn.d.ts +1 -1
  16. package/core/function/tgpuVertexFn.d.ts +1 -1
  17. package/core/pipeline/drawState.js +1 -1
  18. package/core/pipeline/webgpuLimitations.js +2 -1
  19. package/core/resolve/externals.js +4 -0
  20. package/core/resolve/namespace.d.ts +4 -0
  21. package/core/resolve/namespace.js +1 -2
  22. package/core/resolve/stitch.js +13 -8
  23. package/core/root/rootTypes.d.ts +40 -36
  24. package/core/slot/accessor.js +1 -1
  25. package/core/texture/texture.d.ts +1 -2
  26. package/core/texture/texture.js +37 -20
  27. package/core/texture/textureFormats.d.ts +4 -3
  28. package/core/texture/textureFormats.js +17 -6
  29. package/core/texture/textureWrite.d.ts +9 -0
  30. package/core/texture/textureWrite.js +21 -0
  31. package/core/unroll/tgpuUnroll.js +2 -4
  32. package/core/vertexLayout/vertexAttribute.d.ts +1 -4
  33. package/core/vertexLayout/vertexLayout.js +11 -30
  34. package/data/alignmentOf.d.ts +1 -1
  35. package/data/alignmentOf.js +5 -12
  36. package/data/array.js +34 -2
  37. package/data/attributes.d.ts +16 -3
  38. package/data/attributes.js +11 -2
  39. package/data/compiledIO.js +2 -2
  40. package/data/dataIO.js +61 -95
  41. package/data/dataTypes.d.ts +0 -2
  42. package/data/dataTypes.js +3 -3
  43. package/data/disarray.js +2 -0
  44. package/data/offsetUtils.js +23 -13
  45. package/data/offsets.js +1 -2
  46. package/data/partialIO.js +2 -3
  47. package/data/ref.js +35 -37
  48. package/data/schemaCallWrapper.js +2 -2
  49. package/data/schemaMemoryLayout.d.ts +6 -1
  50. package/data/schemaMemoryLayout.js +23 -14
  51. package/data/schemasEqual.js +6 -15
  52. package/data/sizeOf.d.ts +1 -1
  53. package/data/sizeOf.js +2 -3
  54. package/data/snippet.d.ts +1 -1
  55. package/data/struct.js +25 -1
  56. package/data/unstruct.js +2 -0
  57. package/data/vectorImpl.js +45 -21
  58. package/data/vertexFormatData.js +7 -9
  59. package/data/wgslTypes.d.ts +27 -12
  60. package/data/wgslTypes.js +33 -39
  61. package/extension.d.ts +0 -4
  62. package/package.json +1 -1
  63. package/resolutionCtx.d.ts +1 -1
  64. package/resolutionCtx.js +26 -7
  65. package/serial/restore.d.ts +1 -1
  66. package/shared/meta.js +1 -1
  67. package/shared/symbols.d.ts +5 -0
  68. package/shared/symbols.js +6 -1
  69. package/shared/utilityTypes.d.ts +0 -6
  70. package/std/bitcast.d.ts +1 -1
  71. package/std/comptime.js +10 -12
  72. package/std/environment.js +2 -4
  73. package/std/matrix.js +5 -5
  74. package/std/numeric.d.ts +1 -0
  75. package/std/numeric.js +35 -1
  76. package/std/typeOf.js +12 -14
  77. package/tgpu.d.ts +1 -1
  78. package/tgpu.js +1 -1
  79. package/tgpuBindGroupLayout.d.ts +6 -3
  80. package/tgpuBindGroupLayout.js +15 -2
  81. package/tgpuUnstableNamespace.d.ts +1 -0
  82. package/tgpuUnstableNamespace.js +5 -0
  83. package/tgsl/accessIndex.js +10 -7
  84. package/tgsl/accessProp.js +5 -57
  85. package/tgsl/consoleLog/types.d.ts +1 -1
  86. package/tgsl/conversion.js +21 -0
  87. package/tgsl/forOfUtils.js +1 -1
  88. package/tgsl/generationHelpers.d.ts +0 -1
  89. package/tgsl/generationHelpers.js +1 -4
  90. package/tgsl/shaderGenerator.d.ts +5 -0
  91. package/tgsl/swizzle.d.ts +24 -0
  92. package/tgsl/swizzle.js +112 -0
  93. package/tgsl/wgslGenerator.d.ts +13 -3
  94. package/tgsl/wgslGenerator.js +149 -151
  95. package/types.d.ts +10 -10
  96. package/types.js +1 -1
  97. package/taskQueue.d.ts +0 -6
  98. package/taskQueue.js +0 -30
package/types.d.ts CHANGED
@@ -18,7 +18,7 @@ import type { TgpuVar } from './core/variable/tgpuVariable.ts';
18
18
  import { type AnyData, UnknownData } from './data/dataTypes.ts';
19
19
  import type { MapValueToSnippet, ResolvedSnippet, Snippet } from './data/snippet.ts';
20
20
  import { type AnyMatInstance, type AnyVecInstance, type BaseData } from './data/wgslTypes.ts';
21
- import { $cast, $comptimeValueOf, $gpuCallable, $gpuValueOf, $internal, $ownSnippet, $resolve } from './shared/symbols.ts';
21
+ import { $cast, $comptimeValueOf, $gpuCallable, $gpuCallableStrictSignature, $gpuValueOf, $internal, $ownSnippet, $resolve } from './shared/symbols.ts';
22
22
  import type { TgpuBindGroupLayout, TgpuLayoutEntry } from './tgpuBindGroupLayout.ts';
23
23
  import type { WgslEnableExtension } from './wgslExtensions.ts';
24
24
  import type { Infer } from './shared/repr.ts';
@@ -65,6 +65,8 @@ export type FunctionScopeLayer = {
65
65
  functionType: 'normal' | 'compute' | 'vertex' | 'fragment';
66
66
  argAccess: Record<string, FunctionArgumentAccess>;
67
67
  externalMap: Record<string, unknown>;
68
+ /** Snippets of externals already looked up in this function, so each is only coerced once */
69
+ externalSnippets: Map<string, Snippet>;
68
70
  /**
69
71
  * The return type of the function. If undefined, the type should be inferred
70
72
  * from the implementation (relevant for shellless functions).
@@ -312,7 +314,7 @@ export interface ResolutionCtx {
312
314
  getDedented(code: string): string;
313
315
  pushBlockScope(): void;
314
316
  popBlockScope(): void;
315
- generateLog(op: SupportedLogOp, args: Snippet[]): Snippet;
317
+ generateLog(op: SupportedLogOp, args: readonly Snippet[]): Snippet;
316
318
  getById(id: string): Snippet | null;
317
319
  defineVariable(id: string, snippet: Snippet): void;
318
320
  setBlockExternals(externals: Record<string, Snippet>): void;
@@ -359,14 +361,13 @@ export interface WithComptimeValue {
359
361
  * A `[$comptimeValueOf]` implementation for resources that are only known at runtime
360
362
  */
361
363
  export declare function runtimeOnly(): ComptimeValue;
364
+ export type GPUCallableStrictSignature = {
365
+ argTypes: (BaseData | BaseData[])[];
366
+ returnType: BaseData;
367
+ };
362
368
  export interface GPUCallable<TArgs extends unknown[] = unknown[]> {
363
- [$gpuCallable]: {
364
- strictSignature?: {
365
- argTypes: (BaseData | BaseData[])[];
366
- returnType: BaseData;
367
- } | undefined;
368
- call(ctx: ResolutionCtx, args: MapValueToSnippet<TArgs>): Snippet;
369
- };
369
+ [$gpuCallable](ctx: ResolutionCtx, args: MapValueToSnippet<TArgs>): Snippet;
370
+ [$gpuCallableStrictSignature]?: GPUCallableStrictSignature | undefined;
370
371
  }
371
372
  export declare function isGPUCallable(value: unknown): value is GPUCallable;
372
373
  export type WithCast<T = BaseData> = GPUCallable<[v?: Infer<T>]> & {
@@ -383,7 +384,6 @@ export declare function asComptime(snippet: Snippet): Snippet | undefined;
383
384
  export declare function isConstant(snippet: Snippet): boolean;
384
385
  export declare function isWgsl(value: unknown): value is Wgsl;
385
386
  export type BindableBufferUsage = 'uniform' | 'readonly' | 'mutable';
386
- export type BufferUsage = 'uniform' | 'readonly' | 'mutable' | 'vertex';
387
387
  export declare function isGPUBuffer(value: unknown): value is GPUBuffer;
388
388
  export declare function isBuffer(value: unknown): value is TgpuBuffer<BaseData>;
389
389
  export declare function isUsableAsVertex<T extends TgpuBuffer<BaseData>>(buffer: T): buffer is T & VertexFlag;
package/types.js CHANGED
@@ -2,7 +2,7 @@ import { isLazy, isProviding, isSlot, } from "./core/slot/slotTypes.js";
2
2
  import { UnknownData } from "./data/dataTypes.js";
3
3
  import { withValue } from "./data/snippet.js";
4
4
  import { isWgslData, } from "./data/wgslTypes.js";
5
- import { $cast, $comptimeValueOf, $gpuCallable, $gpuValueOf, $internal, $ownSnippet, $resolve, } from "./shared/symbols.js";
5
+ import { $cast, $comptimeValueOf, $gpuCallable, $gpuCallableStrictSignature, $gpuValueOf, $internal, $ownSnippet, $resolve, } from "./shared/symbols.js";
6
6
  export class NormalState {
7
7
  type = 'normal';
8
8
  }
package/taskQueue.d.ts DELETED
@@ -1,6 +0,0 @@
1
- export declare class TaskQueue {
2
- private _queue;
3
- private _pending;
4
- enqueue<T>(task: () => Promise<T>): Promise<T>;
5
- private _processQueue;
6
- }
package/taskQueue.js DELETED
@@ -1,30 +0,0 @@
1
- export class TaskQueue {
2
- _queue = [];
3
- _pending = false;
4
- enqueue(task) {
5
- return new Promise((resolve, reject) => {
6
- this._queue.push(async () => {
7
- try {
8
- resolve(await task());
9
- }
10
- catch (e) {
11
- reject(e);
12
- }
13
- });
14
- void this._processQueue();
15
- });
16
- }
17
- async _processQueue() {
18
- if (this._pending) {
19
- return;
20
- }
21
- this._pending = true;
22
- while (this._queue.length > 0) {
23
- const task = this._queue.shift();
24
- if (task) {
25
- await task();
26
- }
27
- }
28
- this._pending = false;
29
- }
30
- }