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.
- package/common/attachAutoResizer.d.ts +33 -0
- package/common/attachAutoResizer.js +83 -0
- package/common/index.d.ts +1 -0
- package/common/index.js +1 -0
- package/common/writeSoA.js +4 -3
- package/core/commandEncoder/commandEncoder.d.ts +1 -1
- package/core/declare/tgpuDeclare.d.ts +10 -7
- package/core/declare/tgpuDeclare.js +25 -10
- package/core/function/comptime.d.ts +2 -0
- package/core/function/comptime.js +29 -24
- package/core/function/createCallableSchema.js +32 -37
- package/core/function/dualImpl.js +44 -44
- package/core/function/tgpuComputeFn.d.ts +0 -3
- package/core/function/tgpuFn.js +4 -4
- package/core/function/tgpuFragmentFn.d.ts +1 -1
- package/core/function/tgpuVertexFn.d.ts +1 -1
- package/core/pipeline/drawState.js +1 -1
- package/core/pipeline/webgpuLimitations.js +2 -1
- package/core/resolve/externals.js +4 -0
- package/core/resolve/namespace.d.ts +4 -0
- package/core/resolve/namespace.js +1 -2
- package/core/resolve/stitch.js +13 -8
- package/core/root/rootTypes.d.ts +40 -36
- package/core/slot/accessor.js +1 -1
- package/core/texture/texture.d.ts +1 -2
- package/core/texture/texture.js +37 -20
- package/core/texture/textureFormats.d.ts +4 -3
- package/core/texture/textureFormats.js +17 -6
- package/core/texture/textureWrite.d.ts +9 -0
- package/core/texture/textureWrite.js +21 -0
- package/core/unroll/tgpuUnroll.js +2 -4
- package/core/vertexLayout/vertexAttribute.d.ts +1 -4
- package/core/vertexLayout/vertexLayout.js +11 -30
- package/data/alignmentOf.d.ts +1 -1
- package/data/alignmentOf.js +5 -12
- package/data/array.js +34 -2
- package/data/attributes.d.ts +16 -3
- package/data/attributes.js +11 -2
- package/data/compiledIO.js +2 -2
- package/data/dataIO.js +61 -95
- package/data/dataTypes.d.ts +0 -2
- package/data/dataTypes.js +3 -3
- package/data/disarray.js +2 -0
- package/data/offsetUtils.js +23 -13
- package/data/offsets.js +1 -2
- package/data/partialIO.js +2 -3
- package/data/ref.js +35 -37
- package/data/schemaCallWrapper.js +2 -2
- package/data/schemaMemoryLayout.d.ts +6 -1
- package/data/schemaMemoryLayout.js +23 -14
- package/data/schemasEqual.js +6 -15
- package/data/sizeOf.d.ts +1 -1
- package/data/sizeOf.js +2 -3
- package/data/snippet.d.ts +1 -1
- package/data/struct.js +25 -1
- package/data/unstruct.js +2 -0
- package/data/vectorImpl.js +45 -21
- package/data/vertexFormatData.js +7 -9
- package/data/wgslTypes.d.ts +27 -12
- package/data/wgslTypes.js +33 -39
- package/extension.d.ts +0 -4
- package/package.json +1 -1
- package/resolutionCtx.d.ts +1 -1
- package/resolutionCtx.js +26 -7
- package/serial/restore.d.ts +1 -1
- package/shared/meta.js +1 -1
- package/shared/symbols.d.ts +5 -0
- package/shared/symbols.js +6 -1
- package/shared/utilityTypes.d.ts +0 -6
- package/std/bitcast.d.ts +1 -1
- package/std/comptime.js +10 -12
- package/std/environment.js +2 -4
- package/std/matrix.js +5 -5
- package/std/numeric.d.ts +1 -0
- package/std/numeric.js +35 -1
- package/std/typeOf.js +12 -14
- package/tgpu.d.ts +1 -1
- package/tgpu.js +1 -1
- package/tgpuBindGroupLayout.d.ts +6 -3
- package/tgpuBindGroupLayout.js +15 -2
- package/tgpuUnstableNamespace.d.ts +1 -0
- package/tgpuUnstableNamespace.js +5 -0
- package/tgsl/accessIndex.js +10 -7
- package/tgsl/accessProp.js +5 -57
- package/tgsl/consoleLog/types.d.ts +1 -1
- package/tgsl/conversion.js +21 -0
- package/tgsl/forOfUtils.js +1 -1
- package/tgsl/generationHelpers.d.ts +0 -1
- package/tgsl/generationHelpers.js +1 -4
- package/tgsl/shaderGenerator.d.ts +5 -0
- package/tgsl/swizzle.d.ts +24 -0
- package/tgsl/swizzle.js +112 -0
- package/tgsl/wgslGenerator.d.ts +13 -3
- package/tgsl/wgslGenerator.js +149 -151
- package/types.d.ts +10 -10
- package/types.js +1 -1
- package/taskQueue.d.ts +0 -6
- 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
|
-
|
|
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
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
|
-
}
|