typegpu 0.12.8 → 0.12.9
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/core/function/dualImpl.js +1 -0
- package/core/function/tgpuFn.d.ts +1 -0
- package/core/function/tgpuFn.js +10 -0
- package/core/pipeline/computePipeline.js +5 -2
- package/core/pipeline/renderPipeline.js +5 -2
- package/core/pipeline/webgpuLimitations.js +9 -2
- package/core/root/init.d.ts +3 -3
- package/core/root/init.js +12 -13
- package/core/root/rootTypes.d.ts +4 -1
- package/core/slot/accessor.js +3 -3
- package/core/texture/texture.d.ts +2 -1
- package/core/texture/texture.js +23 -24
- package/data/compiledIO.js +1 -1
- package/data/dataIO.js +16 -16
- package/data/index.d.ts +4 -3
- package/data/index.js +3 -2
- package/data/schemasEqual.d.ts +37 -0
- package/data/schemasEqual.js +131 -0
- package/data/struct.js +2 -0
- package/data/wgslTypes.d.ts +1 -1
- package/package.json +2 -2
- package/serial/restore.d.ts +3 -2
- package/serial/restore.js +2 -1
- package/shared/meta.js +1 -1
- package/shared/symbols.js +1 -1
- package/std/comptime.d.ts +67 -0
- package/std/comptime.js +90 -0
- package/std/index.d.ts +2 -0
- package/std/index.js +2 -0
- package/std/numeric.d.ts +1 -1
- package/std/numeric.js +12 -9
- package/std/typeOf.d.ts +31 -0
- package/std/typeOf.js +56 -0
- package/tgpuLogger.d.ts +3 -0
- package/tgpuLogger.js +3 -0
- package/tgsl/consoleLog/serializers.d.ts +1 -8
- package/tgsl/consoleLog/serializers.js +53 -37
- package/tgsl/shellless.js +3 -20
- package/tgsl/wgslGenerator.js +1 -1
- package/unwrapper.d.ts +2 -2
- package/data/deepEqual.d.ts +0 -21
- package/data/deepEqual.js +0 -93
package/tgsl/shellless.js
CHANGED
|
@@ -1,27 +1,10 @@
|
|
|
1
1
|
import { createShelllessImpl } from "../core/function/shelllessImpl.js";
|
|
2
2
|
import { UnknownData } from "../data/dataTypes.js";
|
|
3
|
-
import {
|
|
3
|
+
import { schemasEqualNominally } from "../data/schemasEqual.js";
|
|
4
|
+
import { isPtr } from "../data/wgslTypes.js";
|
|
4
5
|
import { getFunctionMetadata, getName } from "../shared/meta.js";
|
|
5
6
|
import { concretize } from "./generationHelpers.js";
|
|
6
7
|
import { stringifySnippet } from "./stringifySnippet.js";
|
|
7
|
-
function shallowEqualSchemas(a, b) {
|
|
8
|
-
if (a.type !== b.type)
|
|
9
|
-
return false;
|
|
10
|
-
if (isPtr(a) && isPtr(b)) {
|
|
11
|
-
return (a.access === b.access &&
|
|
12
|
-
a.addressSpace === b.addressSpace &&
|
|
13
|
-
a.implicit === b.implicit &&
|
|
14
|
-
shallowEqualSchemas(a.inner, b.inner));
|
|
15
|
-
}
|
|
16
|
-
if (isWgslArray(a) && isWgslArray(b)) {
|
|
17
|
-
return a.elementCount === b.elementCount && shallowEqualSchemas(a.elementType, b.elementType);
|
|
18
|
-
}
|
|
19
|
-
if (isWgslStruct(a) && isWgslStruct(b)) {
|
|
20
|
-
// Only structs with the same identity are considered equal
|
|
21
|
-
return a === b;
|
|
22
|
-
}
|
|
23
|
-
return true;
|
|
24
|
-
}
|
|
25
8
|
export class ShelllessRepository {
|
|
26
9
|
cache = new Map();
|
|
27
10
|
get(fn, argSnippets) {
|
|
@@ -58,7 +41,7 @@ export class ShelllessRepository {
|
|
|
58
41
|
let cache = this.cache.get(fn);
|
|
59
42
|
if (cache) {
|
|
60
43
|
const variant = cache.find((v) => v.argTypes.length === argTypes.length &&
|
|
61
|
-
v.argTypes.every((t, i) =>
|
|
44
|
+
v.argTypes.every((t, i) => schemasEqualNominally(t, argTypes[i])));
|
|
62
45
|
if (variant) {
|
|
63
46
|
return variant;
|
|
64
47
|
}
|
package/tgsl/wgslGenerator.js
CHANGED
|
@@ -1327,7 +1327,7 @@ ${this.ctx.pre}else ${alternate}`,
|
|
|
1327
1327
|
? value.map((i) => coerceToSnippet(i))
|
|
1328
1328
|
: value instanceof ArrayExpression
|
|
1329
1329
|
? value.elements
|
|
1330
|
-
: Array.from({ length: knownEnd.value }, (_, i) => forOfUtils.getElementSnippet(iterableSnippet, snip(i, u32, 'constant')));
|
|
1330
|
+
: Array.from({ length: knownEnd.value }, (_, i) => forOfUtils.getElementSnippet(iterableSnippet, snip(i, u32, 'constant', false)));
|
|
1331
1331
|
if (elements.length === 0) {
|
|
1332
1332
|
return { code: '', definesInNearestScope: false };
|
|
1333
1333
|
}
|
package/unwrapper.d.ts
CHANGED
|
@@ -6,7 +6,7 @@ import type { TgpuRenderBundleEncoder, TgpuRenderPass } from './core/commandEnco
|
|
|
6
6
|
import type { TgpuComputePipeline } from './core/pipeline/computePipeline.ts';
|
|
7
7
|
import type { TgpuRenderPipeline } from './core/pipeline/renderPipeline.ts';
|
|
8
8
|
import type { TgpuComparisonSampler, TgpuSampler } from './core/sampler/sampler.ts';
|
|
9
|
-
import type { TgpuTexture, TgpuTextureView } from './core/texture/texture.ts';
|
|
9
|
+
import type { TgpuTexture, TgpuTextureRenderView, TgpuTextureView } from './core/texture/texture.ts';
|
|
10
10
|
import type { TgpuVertexLayout } from './core/vertexLayout/vertexLayout.ts';
|
|
11
11
|
import type { TgpuBindGroup, TgpuBindGroupLayout } from './tgpuBindGroupLayout.ts';
|
|
12
12
|
import type { BaseData } from './data/wgslTypes.ts';
|
|
@@ -23,7 +23,7 @@ export interface Unwrapper {
|
|
|
23
23
|
unwrap(resource: TgpuBindGroup): GPUBindGroup;
|
|
24
24
|
unwrap(resource: TgpuBuffer<BaseData>): GPUBuffer;
|
|
25
25
|
unwrap(resource: TgpuBufferBinding<BaseData>): GPUBuffer;
|
|
26
|
-
unwrap(resource: TgpuTextureView): GPUTextureView;
|
|
26
|
+
unwrap(resource: TgpuTextureView | TgpuTextureRenderView): GPUTextureView;
|
|
27
27
|
unwrap(resource: TgpuVertexLayout): GPUVertexBufferLayout;
|
|
28
28
|
unwrap(resource: TgpuSampler): GPUSampler;
|
|
29
29
|
unwrap(resource: TgpuComparisonSampler): GPUSampler;
|
package/data/deepEqual.d.ts
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import type { AnyData } from './dataTypes.ts';
|
|
2
|
-
/**
|
|
3
|
-
* Performs a deep comparison of two TypeGPU data schemas.
|
|
4
|
-
*
|
|
5
|
-
* @param a The first data schema to compare.
|
|
6
|
-
* @param b The second data schema to compare.
|
|
7
|
-
* @returns `true` if the schemas are deeply equal, `false` otherwise.
|
|
8
|
-
*
|
|
9
|
-
* @example
|
|
10
|
-
* ```ts
|
|
11
|
-
* import { vec3f, struct, deepEqual } from 'typegpu/data';
|
|
12
|
-
*
|
|
13
|
-
* const schema1 = struct({ a: vec3f });
|
|
14
|
-
* const schema2 = struct({ a: vec3f });
|
|
15
|
-
* const schema3 = struct({ b: vec3f });
|
|
16
|
-
*
|
|
17
|
-
* console.log(deepEqual(schema1, schema2)); // true
|
|
18
|
-
* console.log(deepEqual(schema1, schema3)); // false
|
|
19
|
-
* ```
|
|
20
|
-
*/
|
|
21
|
-
export declare function deepEqual(a: AnyData, b: AnyData): boolean;
|
package/data/deepEqual.js
DELETED
|
@@ -1,93 +0,0 @@
|
|
|
1
|
-
import { isDisarray, isLooseDecorated, isUnstruct } from "./dataTypes.js";
|
|
2
|
-
import { isWgslStorageTexture, isWgslTexture } from "./texture.js";
|
|
3
|
-
import { isAtomic, isDecorated, isPtr, isWgslArray, isWgslStruct } from "./wgslTypes.js";
|
|
4
|
-
/**
|
|
5
|
-
* Performs a deep comparison of two TypeGPU data schemas.
|
|
6
|
-
*
|
|
7
|
-
* @param a The first data schema to compare.
|
|
8
|
-
* @param b The second data schema to compare.
|
|
9
|
-
* @returns `true` if the schemas are deeply equal, `false` otherwise.
|
|
10
|
-
*
|
|
11
|
-
* @example
|
|
12
|
-
* ```ts
|
|
13
|
-
* import { vec3f, struct, deepEqual } from 'typegpu/data';
|
|
14
|
-
*
|
|
15
|
-
* const schema1 = struct({ a: vec3f });
|
|
16
|
-
* const schema2 = struct({ a: vec3f });
|
|
17
|
-
* const schema3 = struct({ b: vec3f });
|
|
18
|
-
*
|
|
19
|
-
* console.log(deepEqual(schema1, schema2)); // true
|
|
20
|
-
* console.log(deepEqual(schema1, schema3)); // false
|
|
21
|
-
* ```
|
|
22
|
-
*/
|
|
23
|
-
export function deepEqual(a, b) {
|
|
24
|
-
if (a === b) {
|
|
25
|
-
return true;
|
|
26
|
-
}
|
|
27
|
-
if (a.type !== b.type) {
|
|
28
|
-
return false;
|
|
29
|
-
}
|
|
30
|
-
if ((isWgslStruct(a) && isWgslStruct(b)) || (isUnstruct(a) && isUnstruct(b))) {
|
|
31
|
-
const aProps = a.propTypes;
|
|
32
|
-
const bProps = b.propTypes;
|
|
33
|
-
const aKeys = Object.keys(aProps);
|
|
34
|
-
const bKeys = Object.keys(bProps);
|
|
35
|
-
if (aKeys.length !== bKeys.length) {
|
|
36
|
-
return false;
|
|
37
|
-
}
|
|
38
|
-
for (let i = 0; i < aKeys.length; i++) {
|
|
39
|
-
const keyA = aKeys[i];
|
|
40
|
-
const keyB = bKeys[i];
|
|
41
|
-
if (keyA !== keyB ||
|
|
42
|
-
!keyA ||
|
|
43
|
-
!keyB ||
|
|
44
|
-
!deepEqual(aProps[keyA], bProps[keyB])) {
|
|
45
|
-
return false;
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
return true;
|
|
49
|
-
}
|
|
50
|
-
if ((isWgslArray(a) && isWgslArray(b)) || (isDisarray(a) && isDisarray(b))) {
|
|
51
|
-
return (a.elementCount === b.elementCount &&
|
|
52
|
-
deepEqual(a.elementType, b.elementType));
|
|
53
|
-
}
|
|
54
|
-
if (isPtr(a) && isPtr(b)) {
|
|
55
|
-
return (a.addressSpace === b.addressSpace &&
|
|
56
|
-
a.access === b.access &&
|
|
57
|
-
a.implicit === b.implicit &&
|
|
58
|
-
deepEqual(a.inner, b.inner));
|
|
59
|
-
}
|
|
60
|
-
if (isAtomic(a) && isAtomic(b)) {
|
|
61
|
-
return deepEqual(a.inner, b.inner);
|
|
62
|
-
}
|
|
63
|
-
if (isWgslTexture(a) && isWgslTexture(b)) {
|
|
64
|
-
// Dimension and multisampling are already encoded in the type
|
|
65
|
-
return deepEqual(a.sampleType, b.sampleType);
|
|
66
|
-
}
|
|
67
|
-
if (isWgslStorageTexture(a) && isWgslStorageTexture(b)) {
|
|
68
|
-
// Dimension is already encoded in the type
|
|
69
|
-
return a.format === b.format && a.access === b.access;
|
|
70
|
-
}
|
|
71
|
-
if ((isDecorated(a) && isDecorated(b)) || (isLooseDecorated(a) && isLooseDecorated(b))) {
|
|
72
|
-
if (!deepEqual(a.inner, b.inner)) {
|
|
73
|
-
return false;
|
|
74
|
-
}
|
|
75
|
-
if (a.attribs.length !== b.attribs.length) {
|
|
76
|
-
return false;
|
|
77
|
-
}
|
|
78
|
-
for (let i = 0; i < a.attribs.length; i++) {
|
|
79
|
-
const attrA = a.attribs[i];
|
|
80
|
-
const attrB = b.attribs[i];
|
|
81
|
-
const paramsA = attrA.params ?? [];
|
|
82
|
-
const paramsB = attrB.params ?? [];
|
|
83
|
-
if (attrA.type !== attrB.type ||
|
|
84
|
-
paramsA.length !== paramsB.length ||
|
|
85
|
-
paramsA.some((param, idx) => param !== paramsB[idx])) {
|
|
86
|
-
return false;
|
|
87
|
-
}
|
|
88
|
-
}
|
|
89
|
-
return true;
|
|
90
|
-
}
|
|
91
|
-
// All other types have been checked for equality at the start
|
|
92
|
-
return true;
|
|
93
|
-
}
|