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.
- package/README.md +1 -1
- package/core/buffer/buffer.js +17 -53
- package/core/function/autoIO.js +2 -2
- package/core/function/entryInputRouter.js +10 -16
- package/core/function/fnCore.js +16 -12
- package/core/function/shelllessImpl.js +1 -1
- package/core/function/tgpuComputeFn.js +1 -1
- package/core/function/tgpuFn.js +1 -1
- package/core/function/tgpuFragmentFn.d.ts +1 -1
- package/core/function/tgpuFragmentFn.js +1 -1
- package/core/function/tgpuVertexFn.js +1 -1
- package/core/pipeline/computePipeline.d.ts +1 -1
- package/core/root/init.d.ts +1 -0
- package/core/root/init.js +6 -0
- package/core/root/rootTypes.d.ts +21 -15
- package/core/slot/accessor.js +1 -1
- package/data/dataIO.d.ts +11 -0
- package/data/dataIO.js +45 -1
- package/data/dataTypes.js +2 -11
- package/data/index.d.ts +3 -3
- package/data/numeric.js +16 -14
- package/data/partialIO.d.ts +8 -0
- package/data/partialIO.js +6 -1
- package/data/snippet.d.ts +1 -6
- package/data/wgslTypes.d.ts +2 -0
- package/index.d.ts +3 -1
- package/index.js +3 -1
- package/indexNamedExports.d.ts +2 -0
- package/package.js +1 -1
- package/package.json +1 -1
- package/resolutionCtx.js +82 -86
- package/shared/stringify.js +1 -0
- package/shared/tseynit.js +90 -0
- package/tgsl/accessIndex.js +4 -3
- package/tgsl/accessProp.js +7 -2
- package/tgsl/consoleLog/deserializers.js +1 -1
- package/tgsl/consoleLog/logGenerator.js +16 -14
- package/tgsl/consoleLog/types.d.ts +4 -5
- package/tgsl/conversion.js +15 -5
- package/tgsl/forOfUtils.js +14 -6
- package/tgsl/generationHelpers.d.ts +2 -1
- package/tgsl/generationHelpers.js +1 -4
- package/tgsl/jsPolyfills.d.ts +25 -0
- package/tgsl/jsPolyfills.js +44 -0
- package/tgsl/shaderGenerator.d.ts +2 -3
- package/tgsl/shaderGenerator_members.d.ts +15 -2
- package/tgsl/wgslGenerator.d.ts +3 -1
- package/tgsl/wgslGenerator.js +64 -59
- package/types.d.ts +11 -6
- package/tgsl/consoleLog/types.js +0 -12
- package/tgsl/math.js +0 -45
package/README.md
CHANGED
package/core/buffer/buffer.js
CHANGED
|
@@ -1,15 +1,12 @@
|
|
|
1
1
|
import { $internal } from "../../shared/symbols.js";
|
|
2
2
|
import { getName, setName } from "../../shared/meta.js";
|
|
3
|
-
import {
|
|
3
|
+
import { isWgslData } from "../../data/wgslTypes.js";
|
|
4
4
|
import { isGPUBuffer } from "../../types.js";
|
|
5
|
-
import { alignmentOf } from "../../data/alignmentOf.js";
|
|
6
|
-
import { roundUp } from "../../mathUtils.js";
|
|
7
5
|
import { sizeOf } from "../../data/sizeOf.js";
|
|
8
6
|
import { getCompiledWriter } from "../../data/compiledIO.js";
|
|
9
|
-
import {
|
|
10
|
-
import { convertPartialToPatch, getPatchInstructions } from "../../data/partialIO.js";
|
|
7
|
+
import { calculateOffsets, readFromArrayBuffer, writeToArrayBuffer } from "../../data/dataIO.js";
|
|
8
|
+
import { convertPartialToPatch, getPatchInstructions, patchArrayBuffer } from "../../data/partialIO.js";
|
|
11
9
|
import { mutable, readonly, uniform } from "./bufferUsage.js";
|
|
12
|
-
import { BufferReader, BufferWriter, getSystemEndianness } from "typed-binary";
|
|
13
10
|
|
|
14
11
|
//#region src/core/buffer/buffer.ts
|
|
15
12
|
const usageToUsageConstructor = {
|
|
@@ -27,7 +24,6 @@ function isBuffer(value) {
|
|
|
27
24
|
function isUsableAsVertex(buffer) {
|
|
28
25
|
return !!buffer.usableAsVertex;
|
|
29
26
|
}
|
|
30
|
-
const endianness = getSystemEndianness();
|
|
31
27
|
var TgpuBufferImpl = class {
|
|
32
28
|
[$internal] = true;
|
|
33
29
|
resourceType = "buffer";
|
|
@@ -74,7 +70,7 @@ var TgpuBufferImpl = class {
|
|
|
74
70
|
});
|
|
75
71
|
if (this.initial || this.#initialCallback) {
|
|
76
72
|
if (this.#initialCallback) this.#initialCallback(this);
|
|
77
|
-
else if (this.initial)
|
|
73
|
+
else if (this.initial) writeToArrayBuffer(this.#getMappedRange(), this.dataType, this.initial);
|
|
78
74
|
this.#unmapBuffer();
|
|
79
75
|
}
|
|
80
76
|
}
|
|
@@ -134,62 +130,30 @@ var TgpuBufferImpl = class {
|
|
|
134
130
|
compileWriter() {
|
|
135
131
|
getCompiledWriter(this.dataType);
|
|
136
132
|
}
|
|
137
|
-
#writeToTarget(target, data, options) {
|
|
138
|
-
const startOffset = options?.startOffset ?? 0;
|
|
139
|
-
const endOffset = options?.endOffset ?? target.byteLength;
|
|
140
|
-
if (data instanceof ArrayBuffer || ArrayBuffer.isView(data)) {
|
|
141
|
-
const src = data instanceof ArrayBuffer ? new Uint8Array(data) : new Uint8Array(data.buffer, data.byteOffset, data.byteLength);
|
|
142
|
-
const regionSize = endOffset - startOffset;
|
|
143
|
-
if (src.byteLength !== regionSize) console.warn(`Buffer size mismatch: expected ${regionSize} bytes, got ${src.byteLength}. ` + (src.byteLength < regionSize ? "Data truncated." : "Excess ignored."));
|
|
144
|
-
const copyLen = Math.min(src.byteLength, regionSize);
|
|
145
|
-
new Uint8Array(target).set(src.subarray(0, copyLen), startOffset);
|
|
146
|
-
return;
|
|
147
|
-
}
|
|
148
|
-
const dataView = new DataView(target);
|
|
149
|
-
const isLittleEndian = endianness === "little";
|
|
150
|
-
const compiledWriter = getCompiledWriter(this.dataType);
|
|
151
|
-
if (compiledWriter) try {
|
|
152
|
-
compiledWriter(dataView, startOffset, data, isLittleEndian, endOffset);
|
|
153
|
-
return;
|
|
154
|
-
} catch (error) {
|
|
155
|
-
console.error(`Error when using compiled writer for buffer ${getName(this) ?? "<unnamed>"} - this is likely a bug, please submit an issue at https://github.com/software-mansion/TypeGPU/issues\nUsing fallback writer instead.`, error);
|
|
156
|
-
}
|
|
157
|
-
const writer = new BufferWriter(target);
|
|
158
|
-
writer.seekTo(startOffset);
|
|
159
|
-
writeData(writer, this.dataType, data);
|
|
160
|
-
}
|
|
161
133
|
write(data, options) {
|
|
162
134
|
const gpuBuffer = this.buffer;
|
|
163
|
-
const bufferSize = sizeOf(this.dataType);
|
|
164
|
-
const startOffset = options?.startOffset ?? 0;
|
|
165
|
-
let naturalSize = void 0;
|
|
166
|
-
if (isWgslArray(this.dataType) && Array.isArray(data)) naturalSize = data.length * roundUp(sizeOf(this.dataType.elementType), alignmentOf(this.dataType.elementType));
|
|
167
|
-
else if (ArrayBuffer.isView(data) || data instanceof ArrayBuffer) naturalSize = data.byteLength;
|
|
168
|
-
const naturalEndOffset = naturalSize !== void 0 ? Math.min(startOffset + naturalSize, bufferSize) : void 0;
|
|
169
|
-
const size = (options?.endOffset ?? naturalEndOffset ?? bufferSize) - startOffset;
|
|
170
135
|
if (gpuBuffer.mapState === "mapped") {
|
|
171
136
|
const mapped = this.#getMappedRange();
|
|
172
137
|
if (data instanceof ArrayBuffer && data === mapped) return;
|
|
173
|
-
|
|
138
|
+
writeToArrayBuffer(mapped, this.dataType, data, options);
|
|
174
139
|
return;
|
|
175
140
|
}
|
|
176
|
-
if (!(data instanceof ArrayBuffer && data === this.#hostBuffer))
|
|
141
|
+
if (!(data instanceof ArrayBuffer && data === this.#hostBuffer)) writeToArrayBuffer(this.#hostBuffer, this.dataType, data, options);
|
|
142
|
+
const { startOffset, endOffset } = calculateOffsets(options, this.dataType, data);
|
|
143
|
+
const size = endOffset - startOffset;
|
|
177
144
|
this.#device.queue.writeBuffer(gpuBuffer, startOffset, this.#hostBuffer, startOffset, size);
|
|
178
145
|
}
|
|
179
146
|
/** @deprecated Use {@link patch} instead. */
|
|
180
147
|
writePartial(data) {
|
|
181
|
-
this
|
|
148
|
+
this.patch(convertPartialToPatch(this.dataType, data));
|
|
182
149
|
}
|
|
183
150
|
patch(data) {
|
|
184
|
-
this.#applyInstructions(getPatchInstructions(this.dataType, data, this.#hostBuffer));
|
|
185
|
-
}
|
|
186
|
-
#applyInstructions(instructions) {
|
|
187
151
|
const gpuBuffer = this.buffer;
|
|
188
|
-
if (gpuBuffer.mapState === "mapped")
|
|
189
|
-
|
|
190
|
-
const
|
|
191
|
-
for (const { data, gpuOffset } of instructions)
|
|
192
|
-
}
|
|
152
|
+
if (gpuBuffer.mapState === "mapped") patchArrayBuffer(this.#getMappedRange(), this.dataType, data);
|
|
153
|
+
else {
|
|
154
|
+
const instructions = getPatchInstructions(this.dataType, data, this.#hostBuffer);
|
|
155
|
+
for (const { data: data$1, gpuOffset } of instructions) this.#device.queue.writeBuffer(gpuBuffer, gpuOffset, data$1);
|
|
156
|
+
}
|
|
193
157
|
}
|
|
194
158
|
clear() {
|
|
195
159
|
const gpuBuffer = this.buffer;
|
|
@@ -210,10 +174,10 @@ var TgpuBufferImpl = class {
|
|
|
210
174
|
}
|
|
211
175
|
async read() {
|
|
212
176
|
const gpuBuffer = this.buffer;
|
|
213
|
-
if (gpuBuffer.mapState === "mapped") return
|
|
177
|
+
if (gpuBuffer.mapState === "mapped") return readFromArrayBuffer(this.#getMappedRange(), this.dataType);
|
|
214
178
|
if (gpuBuffer.usage & GPUBufferUsage.MAP_READ) {
|
|
215
179
|
await gpuBuffer.mapAsync(GPUMapMode.READ);
|
|
216
|
-
const res$1 =
|
|
180
|
+
const res$1 = readFromArrayBuffer(this.#getMappedRange(), this.dataType);
|
|
217
181
|
this.#unmapBuffer();
|
|
218
182
|
return res$1;
|
|
219
183
|
}
|
|
@@ -225,7 +189,7 @@ var TgpuBufferImpl = class {
|
|
|
225
189
|
commandEncoder.copyBufferToBuffer(gpuBuffer, 0, stagingBuffer, 0, sizeOf(this.dataType));
|
|
226
190
|
this.#device.queue.submit([commandEncoder.finish()]);
|
|
227
191
|
await stagingBuffer.mapAsync(GPUMapMode.READ, 0, sizeOf(this.dataType));
|
|
228
|
-
const res =
|
|
192
|
+
const res = readFromArrayBuffer(stagingBuffer.getMappedRange(), this.dataType);
|
|
229
193
|
stagingBuffer.unmap();
|
|
230
194
|
stagingBuffer.destroy();
|
|
231
195
|
return res;
|
package/core/function/autoIO.js
CHANGED
|
@@ -37,7 +37,7 @@ var AutoFragmentFn = class {
|
|
|
37
37
|
autoOut;
|
|
38
38
|
constructor(impl, varyings, locations) {
|
|
39
39
|
if (!getName(impl)) setName(impl, "fragmentFn");
|
|
40
|
-
this.#core = createFnCore(impl, "
|
|
40
|
+
this.#core = createFnCore(impl, "fragment");
|
|
41
41
|
this.autoIn = new AutoStruct({
|
|
42
42
|
...builtinFragmentIn,
|
|
43
43
|
...varyings
|
|
@@ -64,7 +64,7 @@ var AutoVertexFn = class {
|
|
|
64
64
|
autoOut;
|
|
65
65
|
constructor(impl, attribs, locations) {
|
|
66
66
|
if (!getName(impl)) setName(impl, "vertexFn");
|
|
67
|
-
this.#core = createFnCore(impl, "
|
|
67
|
+
this.#core = createFnCore(impl, "vertex");
|
|
68
68
|
this.autoIn = new AutoStruct({
|
|
69
69
|
...builtinVertexIn,
|
|
70
70
|
...attribs
|
|
@@ -1,7 +1,5 @@
|
|
|
1
1
|
import { $internal } from "../../shared/symbols.js";
|
|
2
2
|
import { isWgslStruct } from "../../data/wgslTypes.js";
|
|
3
|
-
import { undecorate } from "../../data/dataTypes.js";
|
|
4
|
-
import { snip } from "../../data/snippet.js";
|
|
5
3
|
|
|
6
4
|
//#region src/core/function/entryInputRouter.ts
|
|
7
5
|
/**
|
|
@@ -12,28 +10,24 @@ import { snip } from "../../data/snippet.js";
|
|
|
12
10
|
var EntryInputRouter = class {
|
|
13
11
|
[$internal] = {};
|
|
14
12
|
type = "entry-input-router";
|
|
15
|
-
|
|
16
|
-
dataSchema;
|
|
13
|
+
structArg;
|
|
17
14
|
/** Maps schemaKey → { WGSL arg name, type } */
|
|
18
15
|
positionalArgsMap;
|
|
19
|
-
constructor(
|
|
20
|
-
this.
|
|
21
|
-
this.
|
|
22
|
-
this.positionalArgsMap = new Map(positionalArgs.map((a) => [a.schemaKey, {
|
|
23
|
-
argName: a.argName,
|
|
24
|
-
type: a.type
|
|
25
|
-
}]));
|
|
16
|
+
constructor(structArg, positionalArgs) {
|
|
17
|
+
this.structArg = structArg;
|
|
18
|
+
this.positionalArgsMap = new Map(positionalArgs.map((a) => [a.schemaKey, a.arg]));
|
|
26
19
|
}
|
|
27
20
|
toString() {
|
|
28
21
|
return "entry-input-router";
|
|
29
22
|
}
|
|
30
23
|
accessProp(propName) {
|
|
31
24
|
const positionalEntry = this.positionalArgsMap.get(propName);
|
|
32
|
-
if (positionalEntry) return
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
25
|
+
if (positionalEntry) return positionalEntry();
|
|
26
|
+
const structSnippet = this.structArg?.();
|
|
27
|
+
if (structSnippet && isWgslStruct(structSnippet.dataType)) return {
|
|
28
|
+
target: structSnippet,
|
|
29
|
+
prop: propName
|
|
30
|
+
};
|
|
37
31
|
}
|
|
38
32
|
};
|
|
39
33
|
|
package/core/function/fnCore.js
CHANGED
|
@@ -9,7 +9,7 @@ import { applyExternals, replaceExternalsInWgsl } from "../resolve/externals.js"
|
|
|
9
9
|
import { extractArgs } from "./extractArgs.js";
|
|
10
10
|
|
|
11
11
|
//#region src/core/function/fnCore.ts
|
|
12
|
-
function createFnCore(implementation,
|
|
12
|
+
function createFnCore(implementation, functionType, workgroupSize) {
|
|
13
13
|
/**
|
|
14
14
|
* External application has to be deferred until resolution because
|
|
15
15
|
* some externals can reference the owner function which has not been
|
|
@@ -24,6 +24,10 @@ function createFnCore(implementation, fnAttribute = "") {
|
|
|
24
24
|
},
|
|
25
25
|
resolve(ctx, argTypes, returnType, entryInput) {
|
|
26
26
|
const externalMap = {};
|
|
27
|
+
let attributes = "";
|
|
28
|
+
if (functionType === "compute") attributes = `@compute @workgroup_size(${workgroupSize?.join(", ")}) `;
|
|
29
|
+
else if (functionType === "vertex") attributes = `@vertex `;
|
|
30
|
+
else if (functionType === "fragment") attributes = `@fragment `;
|
|
27
31
|
for (const externals of externalsToApply) applyExternals(externalMap, externals);
|
|
28
32
|
const id = ctx.getUniqueName(this);
|
|
29
33
|
if (typeof implementation === "string") {
|
|
@@ -32,8 +36,8 @@ function createFnCore(implementation, fnAttribute = "") {
|
|
|
32
36
|
if (validArgNames && Object.keys(validArgNames).length > 0) applyExternals(externalMap, { in: validArgNames });
|
|
33
37
|
const replacedImpl = replaceExternalsInWgsl(ctx, externalMap, implementation);
|
|
34
38
|
let header = "";
|
|
35
|
-
let body
|
|
36
|
-
if (
|
|
39
|
+
let body = "";
|
|
40
|
+
if (functionType !== "normal" && entryInput && validArgNames) {
|
|
37
41
|
const { dataSchema, positionalArgs } = entryInput;
|
|
38
42
|
const parts = [];
|
|
39
43
|
if (dataSchema && isArgUsedInBody("in", replacedImpl)) parts.push(`in: ${ctx.resolve(dataSchema).value}`);
|
|
@@ -42,16 +46,16 @@ function createFnCore(implementation, fnAttribute = "") {
|
|
|
42
46
|
if (argName !== "" && isArgUsedInBody(argName, replacedImpl)) parts.push(`${getAttributesString(a.type)}${argName}: ${ctx.resolve(a.type).value}`);
|
|
43
47
|
}
|
|
44
48
|
const input = `(${parts.join(", ")})`;
|
|
45
|
-
const attributes = isWgslData(returnType) ? getAttributesString(returnType) : "";
|
|
46
|
-
header = `${input}${returnType !== Void ? isWgslStruct(returnType) ? ` -> ${ctx.resolve(returnType).value} ` : ` -> ${attributes !== "" ? attributes : "@location(0)"} ${ctx.resolve(returnType).value} ` : " "}`;
|
|
47
|
-
body
|
|
49
|
+
const attributes$1 = isWgslData(returnType) ? getAttributesString(returnType) : "";
|
|
50
|
+
header = `${input}${returnType !== Void ? isWgslStruct(returnType) ? ` -> ${ctx.resolve(returnType).value} ` : ` -> ${attributes$1 !== "" ? attributes$1 : "@location(0)"} ${ctx.resolve(returnType).value} ` : " "}`;
|
|
51
|
+
body = replacedImpl;
|
|
48
52
|
} else {
|
|
49
53
|
const providedArgs = extractArgs(replacedImpl);
|
|
50
54
|
if (providedArgs.args.length !== argTypes.length) throw new Error(`WGSL implementation has ${providedArgs.args.length} arguments, while the shell has ${argTypes.length} arguments.`);
|
|
51
55
|
header = `(${providedArgs.args.map((argInfo, i) => `${argInfo.identifier}: ${checkAndReturnType(ctx, `parameter ${argInfo.identifier}`, argInfo.type, argTypes[i])}`).join(", ")})${returnType === Void ? " " : ` -> ${checkAndReturnType(ctx, "return type", providedArgs.ret?.type, returnType)} `}`;
|
|
52
|
-
body
|
|
56
|
+
body = replacedImpl.slice(providedArgs.range.end);
|
|
53
57
|
}
|
|
54
|
-
ctx.addDeclaration(`${
|
|
58
|
+
ctx.addDeclaration(`${attributes}fn ${id}${header}${body}`);
|
|
55
59
|
return snip(id, returnType, "runtime");
|
|
56
60
|
}
|
|
57
61
|
const pluginData = getMetaData(implementation);
|
|
@@ -62,9 +66,9 @@ function createFnCore(implementation, fnAttribute = "") {
|
|
|
62
66
|
const missingExternals = ast.externalNames.filter((name) => !(name in externalMap));
|
|
63
67
|
if (missingExternals.length > 0) throw new MissingLinksError(getName(this), missingExternals);
|
|
64
68
|
const maybeSecondArg = ast.params[1];
|
|
65
|
-
if (maybeSecondArg && maybeSecondArg.type === "i" &&
|
|
66
|
-
const {
|
|
67
|
-
functionType
|
|
69
|
+
if (maybeSecondArg && maybeSecondArg.type === "i" && functionType !== "normal") applyExternals(externalMap, { [maybeSecondArg.name]: undecorate(returnType) });
|
|
70
|
+
const { code, returnType: actualReturnType } = ctx.fnToWgsl({
|
|
71
|
+
functionType,
|
|
68
72
|
argTypes,
|
|
69
73
|
entryInput,
|
|
70
74
|
params: ast.params,
|
|
@@ -72,7 +76,7 @@ function createFnCore(implementation, fnAttribute = "") {
|
|
|
72
76
|
body: ast.body,
|
|
73
77
|
externalMap
|
|
74
78
|
});
|
|
75
|
-
ctx.addDeclaration(`${
|
|
79
|
+
ctx.addDeclaration(`${attributes}fn ${id}${code}`);
|
|
76
80
|
return snip(id, actualReturnType, "runtime");
|
|
77
81
|
}
|
|
78
82
|
};
|
|
@@ -4,7 +4,7 @@ import { createFnCore } from "./fnCore.js";
|
|
|
4
4
|
|
|
5
5
|
//#region src/core/function/shelllessImpl.ts
|
|
6
6
|
function createShelllessImpl(argTypes, implementation) {
|
|
7
|
-
const core = createFnCore(implementation, "");
|
|
7
|
+
const core = createFnCore(implementation, "normal");
|
|
8
8
|
return {
|
|
9
9
|
[$internal]: true,
|
|
10
10
|
[$getNameForward]: core,
|
|
@@ -31,7 +31,7 @@ function isTgpuComputeFn(value) {
|
|
|
31
31
|
return value?.shell?.entryPoint === "compute";
|
|
32
32
|
}
|
|
33
33
|
function createComputeFn(shell, workgroupSize, implementation, entryInput) {
|
|
34
|
-
const core = createFnCore(implementation,
|
|
34
|
+
const core = createFnCore(implementation, "compute", workgroupSize);
|
|
35
35
|
return {
|
|
36
36
|
shell,
|
|
37
37
|
$uses(newExternals) {
|
package/core/function/tgpuFn.js
CHANGED
|
@@ -40,7 +40,7 @@ function createFn(shell, _implementation) {
|
|
|
40
40
|
pairs = _implementation[$providing]?.pairs ?? [];
|
|
41
41
|
implementation = _implementation[$internal].inner;
|
|
42
42
|
} else implementation = _implementation;
|
|
43
|
-
const core = createFnCore(implementation, "");
|
|
43
|
+
const core = createFnCore(implementation, "normal");
|
|
44
44
|
const fnBase = {
|
|
45
45
|
shell,
|
|
46
46
|
resourceType: "function",
|
|
@@ -2,9 +2,9 @@ import { TgpuNamable } from "../../shared/meta.js";
|
|
|
2
2
|
import { $internal } from "../../shared/symbols.js";
|
|
3
3
|
import { Prettify } from "../../shared/utilityTypes.js";
|
|
4
4
|
import { AnyFragmentInputBuiltin, AnyFragmentOutputBuiltin, OmitBuiltins } from "../../builtin.js";
|
|
5
|
+
import { InstanceToSchema } from "../../data/instanceToSchema.js";
|
|
5
6
|
import { BaseIOData, IOLayout, IORecord, InferIO } from "./fnTypes.js";
|
|
6
7
|
import { AnyAutoCustoms, AutoFragmentIn, AutoFragmentOut } from "./autoIO.js";
|
|
7
|
-
import { InstanceToSchema } from "../../data/instanceToSchema.js";
|
|
8
8
|
import { IOLayoutToSchema } from "./ioSchema.js";
|
|
9
9
|
import { BaseData, Decorated, Interpolate, Location, Vec4f, Vec4i, Vec4u, WgslStruct } from "../../data/wgslTypes.js";
|
|
10
10
|
import { UndecorateRecord } from "../../data/dataTypes.js";
|
|
@@ -32,7 +32,7 @@ function isTgpuFragmentFn(value) {
|
|
|
32
32
|
return value?.shell?.entryPoint === "fragment";
|
|
33
33
|
}
|
|
34
34
|
function createFragmentFn(shell, implementation) {
|
|
35
|
-
const core = createFnCore(implementation, "
|
|
35
|
+
const core = createFnCore(implementation, "fragment");
|
|
36
36
|
const outputType = shell.returnType;
|
|
37
37
|
if (typeof implementation === "string") addReturnTypeToExternals(implementation, outputType, (externals) => core.applyExternals(externals));
|
|
38
38
|
return {
|
|
@@ -32,7 +32,7 @@ function isTgpuVertexFn(value) {
|
|
|
32
32
|
return value?.shell?.entryPoint === "vertex";
|
|
33
33
|
}
|
|
34
34
|
function createVertexFn(shell, implementation) {
|
|
35
|
-
const core = createFnCore(implementation, "
|
|
35
|
+
const core = createFnCore(implementation, "vertex");
|
|
36
36
|
const entryInput = separateAllAsPositional(shell.in ?? {});
|
|
37
37
|
return {
|
|
38
38
|
shell,
|
|
@@ -3,8 +3,8 @@ import { $internal } from "../../shared/symbols.js";
|
|
|
3
3
|
import { AnyComputeBuiltin } from "../../builtin.js";
|
|
4
4
|
import "../querySet/querySet.js";
|
|
5
5
|
import "../../data/snippet.js";
|
|
6
|
-
import "../../tgsl/consoleLog/types.js";
|
|
7
6
|
import { IORecord } from "../function/fnTypes.js";
|
|
7
|
+
import "../../tgsl/consoleLog/types.js";
|
|
8
8
|
import { TgpuComputeFn } from "../function/tgpuComputeFn.js";
|
|
9
9
|
import "../slot/slotTypes.js";
|
|
10
10
|
import { PrimitiveOffsetInfo } from "../../data/offsetUtils.js";
|
package/core/root/init.d.ts
CHANGED
package/core/root/init.js
CHANGED
|
@@ -54,6 +54,12 @@ var TgpuGuardedComputePipelineImpl = class TgpuGuardedComputePipelineImpl {
|
|
|
54
54
|
with(bindGroupOrEncoder) {
|
|
55
55
|
return new TgpuGuardedComputePipelineImpl(this.#root, this.#pipeline.with(bindGroupOrEncoder), this.#sizeUniform, this.#workgroupSize);
|
|
56
56
|
}
|
|
57
|
+
withPerformanceCallback(callback) {
|
|
58
|
+
return new TgpuGuardedComputePipelineImpl(this.#root, this.#pipeline.withPerformanceCallback(callback), this.#sizeUniform, this.#workgroupSize);
|
|
59
|
+
}
|
|
60
|
+
withTimestampWrites(options) {
|
|
61
|
+
return new TgpuGuardedComputePipelineImpl(this.#root, this.#pipeline.withTimestampWrites(options), this.#sizeUniform, this.#workgroupSize);
|
|
62
|
+
}
|
|
57
63
|
dispatchThreads(...threads) {
|
|
58
64
|
const sanitizedSize = toVec3(threads);
|
|
59
65
|
const workgroupCount = ceil(vec3f(sanitizedSize).div(vec3f(this.#workgroupSize)));
|
package/core/root/rootTypes.d.ts
CHANGED
|
@@ -4,14 +4,14 @@ import { Assume, Mutable, OmitProps, Prettify } from "../../shared/utilityTypes.
|
|
|
4
4
|
import { WgslComparisonSamplerProps, WgslSamplerProps } from "../../data/sampler.js";
|
|
5
5
|
import { AnyComputeBuiltin, AnyFragmentInputBuiltin, OmitBuiltins } from "../../builtin.js";
|
|
6
6
|
import { TgpuQuerySet } from "../querySet/querySet.js";
|
|
7
|
+
import { InstanceToSchema } from "../../data/instanceToSchema.js";
|
|
7
8
|
import { TgpuMutable, TgpuReadonly, TgpuUniform } from "../buffer/bufferShorthand.js";
|
|
8
|
-
import { LogGeneratorOptions } from "../../tgsl/consoleLog/types.js";
|
|
9
9
|
import { IORecord } from "../function/fnTypes.js";
|
|
10
|
+
import { LogGeneratorOptions } from "../../tgsl/consoleLog/types.js";
|
|
10
11
|
import { TgpuComputeFn } from "../function/tgpuComputeFn.js";
|
|
11
12
|
import { Eventual, TgpuAccessor, TgpuMutableAccessor, TgpuSlot } from "../slot/slotTypes.js";
|
|
12
13
|
import { TgpuComputePipeline } from "../pipeline/computePipeline.js";
|
|
13
14
|
import { AnyAutoCustoms, AutoFragmentIn, AutoFragmentOut, AutoVertexIn, AutoVertexOut } from "../function/autoIO.js";
|
|
14
|
-
import { InstanceToSchema } from "../../data/instanceToSchema.js";
|
|
15
15
|
import { FragmentInConstrained, FragmentOutConstrained, TgpuFragmentFn, VertexOutToVarying } from "../function/tgpuFragmentFn.js";
|
|
16
16
|
import { TgpuVertexFn } from "../function/tgpuVertexFn.js";
|
|
17
17
|
import { AttribRecordToDefaultDataTypes, LayoutToAllowedAttribs } from "../vertexLayout/vertexAttribute.js";
|
|
@@ -40,6 +40,20 @@ interface TgpuGuardedComputePipeline<TArgs extends number[] = number[]> extends
|
|
|
40
40
|
* Analogous to `TgpuComputePipeline.with(encoder)`.
|
|
41
41
|
*/
|
|
42
42
|
with(encoder: GPUCommandEncoder): TgpuGuardedComputePipeline<TArgs>;
|
|
43
|
+
/**
|
|
44
|
+
* Returns a pipeline wrapper with the given performance callback attached.
|
|
45
|
+
* Analogous to `TgpuComputePipeline.withPerformanceCallback(callback)`.
|
|
46
|
+
*/
|
|
47
|
+
withPerformanceCallback(callback: (start: bigint, end: bigint) => void | Promise<void>): TgpuGuardedComputePipeline<TArgs>;
|
|
48
|
+
/**
|
|
49
|
+
* Returns a pipeline wrapper with the given timestamp writes configuration.
|
|
50
|
+
* Analogous to `TgpuComputePipeline.withTimestampWrites(options)`.
|
|
51
|
+
*/
|
|
52
|
+
withTimestampWrites(options: {
|
|
53
|
+
querySet: TgpuQuerySet<'timestamp'> | GPUQuerySet;
|
|
54
|
+
beginningOfPassWriteIndex?: number;
|
|
55
|
+
endOfPassWriteIndex?: number;
|
|
56
|
+
}): TgpuGuardedComputePipeline<TArgs>;
|
|
43
57
|
/**
|
|
44
58
|
* Dispatches the pipeline.
|
|
45
59
|
* Unlike `TgpuComputePipeline.dispatchWorkgroups()`, this method takes in the
|
|
@@ -166,7 +180,7 @@ interface WithBinding extends Withable<WithBinding> {
|
|
|
166
180
|
})): TgpuRenderPipeline<NormalizeOutput<TFragmentOut>> | TgpuRenderPipeline<Void>;
|
|
167
181
|
/**
|
|
168
182
|
* Creates a compute pipeline that executes the given callback in an exact number of threads.
|
|
169
|
-
* This is different from `
|
|
183
|
+
* This is different from `createComputePipeline()` in that it does a bounds check on the
|
|
170
184
|
* thread id, where as regular pipelines do not and work in units of workgroups.
|
|
171
185
|
*
|
|
172
186
|
* @param callback A function converted to WGSL and executed on the GPU.
|
|
@@ -473,10 +487,8 @@ interface TgpuRoot extends Unwrapper, WithBinding {
|
|
|
473
487
|
* Typed wrapper around a GPUBuffer.
|
|
474
488
|
*
|
|
475
489
|
* @param typeSchema The type of data that this buffer will hold.
|
|
476
|
-
* @param initial
|
|
490
|
+
* @param initial Either initial value of the buffer, or an initializer to execute on the mapped buffer. (optional)
|
|
477
491
|
*/
|
|
478
|
-
createBuffer<TData extends AnyData>(typeSchema: ValidateBufferSchema<TData>, initializer: (buffer: TgpuBuffer<NoInfer<TData>>) => void): TgpuBuffer<TData>;
|
|
479
|
-
createBuffer<TData extends AnyData>(typeSchema: ValidateBufferSchema<TData>, initial?: InferInput<NoInfer<TData>>): TgpuBuffer<TData>;
|
|
480
492
|
createBuffer<TData extends AnyData>(typeSchema: ValidateBufferSchema<TData>, initial?: ((buffer: TgpuBuffer<NoInfer<TData>>) => void) | InferInput<NoInfer<TData>>): TgpuBuffer<TData>;
|
|
481
493
|
/**
|
|
482
494
|
* Allocates memory on the GPU, allows passing data between host and shader.
|
|
@@ -494,10 +506,8 @@ interface TgpuRoot extends Unwrapper, WithBinding {
|
|
|
494
506
|
* use {@link TgpuRoot.createBuffer}.
|
|
495
507
|
*
|
|
496
508
|
* @param typeSchema The type of data that this buffer will hold.
|
|
497
|
-
* @param initial
|
|
509
|
+
* @param initial Either initial value of the buffer, or an initializer to execute on the mapped buffer. (optional)
|
|
498
510
|
*/
|
|
499
|
-
createUniform<TData extends AnyWgslData>(typeSchema: ValidateUniformSchema<TData>, initializer: (buffer: TgpuBuffer<NoInfer<TData>>) => void): TgpuUniform<TData>;
|
|
500
|
-
createUniform<TData extends AnyWgslData>(typeSchema: ValidateUniformSchema<TData>, initial?: InferInput<NoInfer<TData>>): TgpuUniform<TData>;
|
|
501
511
|
createUniform<TData extends AnyWgslData>(typeSchema: ValidateUniformSchema<TData>, initial?: ((buffer: TgpuBuffer<NoInfer<TData>>) => void) | InferInput<NoInfer<TData>>): TgpuUniform<TData>;
|
|
502
512
|
/**
|
|
503
513
|
* Allocates memory on the GPU, allows passing data between host and shader.
|
|
@@ -514,10 +524,8 @@ interface TgpuRoot extends Unwrapper, WithBinding {
|
|
|
514
524
|
* use {@link TgpuRoot.createBuffer}.
|
|
515
525
|
*
|
|
516
526
|
* @param typeSchema The type of data that this buffer will hold.
|
|
517
|
-
* @param initial
|
|
527
|
+
* @param initial Either initial value of the buffer, or an initializer to execute on the mapped buffer. (optional)
|
|
518
528
|
*/
|
|
519
|
-
createMutable<TData extends AnyWgslData>(typeSchema: ValidateStorageSchema<TData>, initializer: (buffer: TgpuBuffer<NoInfer<TData>>) => void): TgpuMutable<TData>;
|
|
520
|
-
createMutable<TData extends AnyWgslData>(typeSchema: ValidateStorageSchema<TData>, initial?: InferInput<NoInfer<TData>>): TgpuMutable<TData>;
|
|
521
529
|
createMutable<TData extends AnyWgslData>(typeSchema: ValidateStorageSchema<TData>, initial?: ((buffer: TgpuBuffer<NoInfer<TData>>) => void) | InferInput<NoInfer<TData>>): TgpuMutable<TData>;
|
|
522
530
|
/**
|
|
523
531
|
* Allocates memory on the GPU, allows passing data between host and shader.
|
|
@@ -534,10 +542,8 @@ interface TgpuRoot extends Unwrapper, WithBinding {
|
|
|
534
542
|
* use {@link TgpuRoot.createBuffer}.
|
|
535
543
|
*
|
|
536
544
|
* @param typeSchema The type of data that this buffer will hold.
|
|
537
|
-
* @param initial
|
|
545
|
+
* @param initial Either initial value of the buffer, or an initializer to execute on the mapped buffer. (optional)
|
|
538
546
|
*/
|
|
539
|
-
createReadonly<TData extends AnyWgslData>(typeSchema: ValidateStorageSchema<TData>, initializer: (buffer: TgpuBuffer<NoInfer<TData>>) => void): TgpuReadonly<TData>;
|
|
540
|
-
createReadonly<TData extends AnyWgslData>(typeSchema: ValidateStorageSchema<TData>, initial?: InferInput<NoInfer<TData>>): TgpuReadonly<TData>;
|
|
541
547
|
createReadonly<TData extends AnyWgslData>(typeSchema: ValidateStorageSchema<TData>, initial?: ((buffer: TgpuBuffer<NoInfer<TData>>) => void) | InferInput<NoInfer<TData>>): TgpuReadonly<TData>;
|
|
542
548
|
/**
|
|
543
549
|
* Allocates memory on the GPU, allows passing data between host and shader.
|
package/core/slot/accessor.js
CHANGED
|
@@ -25,7 +25,7 @@ var AccessorBase = class {
|
|
|
25
25
|
constructor(schemaOrConstructor, defaultValue = void 0) {
|
|
26
26
|
this.schema = isData(schemaOrConstructor) ? schemaOrConstructor : schemaOrConstructor(0);
|
|
27
27
|
this.defaultValue = defaultValue;
|
|
28
|
-
this.slot = slot(defaultValue);
|
|
28
|
+
this.slot = (() => slot(defaultValue))();
|
|
29
29
|
this[$getNameForward] = this.slot;
|
|
30
30
|
}
|
|
31
31
|
get [$gpuValueOf]() {
|
package/data/dataIO.d.ts
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { BufferWriteOptions } from "../core/buffer/buffer.js";
|
|
2
|
+
import { BaseData } from "./wgslTypes.js";
|
|
3
|
+
import { Infer, InferInput } from "../shared/repr.js";
|
|
4
|
+
import "typed-binary";
|
|
5
|
+
|
|
6
|
+
//#region src/data/dataIO.d.ts
|
|
7
|
+
|
|
8
|
+
declare function writeToArrayBuffer<T extends BaseData>(buffer: ArrayBuffer, schema: T, data: InferInput<T> | ArrayBuffer, options?: BufferWriteOptions): void;
|
|
9
|
+
declare function readFromArrayBuffer<T extends BaseData>(buffer: ArrayBuffer, schema: T): Infer<T>;
|
|
10
|
+
//#endregion
|
|
11
|
+
export { readFromArrayBuffer, writeToArrayBuffer };
|
package/data/dataIO.js
CHANGED
|
@@ -1,8 +1,13 @@
|
|
|
1
|
+
import { getName } from "../shared/meta.js";
|
|
2
|
+
import { isWgslArray } from "./wgslTypes.js";
|
|
1
3
|
import { vec2f, vec2h, vec2i, vec2u, vec3f, vec3h, vec3i, vec3u, vec4f, vec4h, vec4i, vec4u } from "./vector.js";
|
|
2
4
|
import { alignmentOf, customAlignmentOf } from "./alignmentOf.js";
|
|
5
|
+
import { roundUp } from "../mathUtils.js";
|
|
3
6
|
import { sizeOf } from "./sizeOf.js";
|
|
4
7
|
import { mat2x2f, mat3x3f, mat4x4f } from "./matrix.js";
|
|
5
8
|
import alignIO_default from "./alignIO.js";
|
|
9
|
+
import { getCompiledWriter } from "./compiledIO.js";
|
|
10
|
+
import { BufferReader, BufferWriter, getSystemEndianness } from "typed-binary";
|
|
6
11
|
|
|
7
12
|
//#region src/data/dataIO.ts
|
|
8
13
|
const dataWriters = {
|
|
@@ -553,6 +558,45 @@ function readData(input, schema) {
|
|
|
553
558
|
if (!reader) throw new Error(`Cannot read data of type '${schema.type}'.`);
|
|
554
559
|
return reader(input, schema);
|
|
555
560
|
}
|
|
561
|
+
const endianness = getSystemEndianness();
|
|
562
|
+
function calculateOffsets(options, schema, data) {
|
|
563
|
+
const bufferSize = sizeOf(schema);
|
|
564
|
+
const startOffset = options?.startOffset ?? 0;
|
|
565
|
+
let naturalSize = void 0;
|
|
566
|
+
if (isWgslArray(schema) && Array.isArray(data)) naturalSize = data.length * roundUp(sizeOf(schema.elementType), alignmentOf(schema.elementType));
|
|
567
|
+
else if (ArrayBuffer.isView(data) || data instanceof ArrayBuffer) naturalSize = data.byteLength;
|
|
568
|
+
const naturalEndOffset = naturalSize !== void 0 ? Math.min(startOffset + naturalSize, bufferSize) : void 0;
|
|
569
|
+
return {
|
|
570
|
+
startOffset,
|
|
571
|
+
endOffset: options?.endOffset ?? naturalEndOffset ?? bufferSize
|
|
572
|
+
};
|
|
573
|
+
}
|
|
574
|
+
function writeToArrayBuffer(buffer, schema, data, options) {
|
|
575
|
+
const { startOffset, endOffset } = calculateOffsets(options, schema, data);
|
|
576
|
+
if (data instanceof ArrayBuffer || ArrayBuffer.isView(data)) {
|
|
577
|
+
const src = data instanceof ArrayBuffer ? new Uint8Array(data) : new Uint8Array(data.buffer, data.byteOffset, data.byteLength);
|
|
578
|
+
const regionSize = endOffset - startOffset;
|
|
579
|
+
if (src.byteLength !== regionSize) console.warn(`Buffer size mismatch: expected ${regionSize} bytes, got ${src.byteLength}. ` + (src.byteLength < regionSize ? "Data truncated." : "Excess ignored."));
|
|
580
|
+
const copyLen = Math.min(src.byteLength, regionSize);
|
|
581
|
+
new Uint8Array(buffer).set(src.subarray(0, copyLen), startOffset);
|
|
582
|
+
return;
|
|
583
|
+
}
|
|
584
|
+
const dataView = new DataView(buffer);
|
|
585
|
+
const isLittleEndian = endianness === "little";
|
|
586
|
+
const compiledWriter = getCompiledWriter(schema);
|
|
587
|
+
if (compiledWriter) try {
|
|
588
|
+
compiledWriter(dataView, startOffset, data, isLittleEndian, endOffset);
|
|
589
|
+
return;
|
|
590
|
+
} catch (error) {
|
|
591
|
+
console.error(`Error when using compiled writer for data type '${schema.type}' (${getName(schema) ?? "unnamed"}) - this is likely a bug, please submit an issue at https://github.com/software-mansion/TypeGPU/issues\nUsing fallback writer instead.`, error);
|
|
592
|
+
}
|
|
593
|
+
const writer = new BufferWriter(buffer);
|
|
594
|
+
writer.seekTo(startOffset);
|
|
595
|
+
writeData(writer, schema, data);
|
|
596
|
+
}
|
|
597
|
+
function readFromArrayBuffer(buffer, schema) {
|
|
598
|
+
return readData(new BufferReader(buffer), schema);
|
|
599
|
+
}
|
|
556
600
|
|
|
557
601
|
//#endregion
|
|
558
|
-
export {
|
|
602
|
+
export { calculateOffsets, readFromArrayBuffer, writeData, writeToArrayBuffer };
|
package/data/dataTypes.js
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { setName } from "../shared/meta.js";
|
|
1
|
+
import { isMarkedInternal } from "../shared/symbols.js";
|
|
3
2
|
import { vertexFormats } from "../shared/vertexFormat.js";
|
|
4
3
|
import { isAlignAttrib, isDecorated, isLocationAttrib, isPtr, isSizeAttrib, isWgslData } from "./wgslTypes.js";
|
|
5
4
|
|
|
@@ -89,14 +88,6 @@ var MatrixColumnsAccess = class {
|
|
|
89
88
|
this.matrix = matrix;
|
|
90
89
|
}
|
|
91
90
|
};
|
|
92
|
-
var ConsoleLog = class {
|
|
93
|
-
[$internal] = true;
|
|
94
|
-
op;
|
|
95
|
-
constructor(op) {
|
|
96
|
-
this.op = op;
|
|
97
|
-
setName(this, "consoleLog");
|
|
98
|
-
}
|
|
99
|
-
};
|
|
100
91
|
|
|
101
92
|
//#endregion
|
|
102
|
-
export {
|
|
93
|
+
export { InfixDispatch, MatrixColumnsAccess, UnknownData, getCustomAlignment, getCustomLocation, getCustomSize, isData, isDisarray, isLooseData, isLooseDecorated, isUnstruct, undecorate, unptr };
|
package/data/index.d.ts
CHANGED
|
@@ -4,7 +4,7 @@ import { AnyAttribute, HasCustomLocation, IsBuiltin, align, interpolate, invaria
|
|
|
4
4
|
import { memoryLayoutOf } from "./offsetUtils.js";
|
|
5
5
|
import { FormatToAcceptedData, FormatToWGSLType, PackedData, TgpuVertexFormatData, float16, float16x2, float16x4, float32, float32x2, float32x3, float32x4, formatToWGSLType, isPackedData, packedFormats, sint16, sint16x2, sint16x4, sint32, sint32x2, sint32x3, sint32x4, sint8, sint8x2, sint8x4, snorm16, snorm16x2, snorm16x4, snorm8, snorm8x2, snorm8x4, uint16, uint16x2, uint16x4, uint32, uint32x2, uint32x3, uint32x4, uint8, uint8x2, uint8x4, unorm10_10_10_2, unorm16, unorm16x2, unorm16x4, unorm8, unorm8x2, unorm8x4, unorm8x4_bgra } from "./vertexFormatData.js";
|
|
6
6
|
import { _ref } from "./ref.js";
|
|
7
|
-
import { Align, AnyVecInstance, AnyWgslData, AnyWgslStruct, Atomic, BaseData, Bool, Builtin, Decorated, F16, F32, I32, Interpolate, Location, Mat2x2f, Mat3x3f, Mat4x4f, Ptr, Size, StorableData, U16, U32, Vec2b, Vec2f, Vec2h, Vec2i, Vec2u, Vec3b, Vec3f, Vec3h, Vec3i, Vec3u, Vec4b, Vec4f, Vec4h, Vec4i, Vec4u, Void, WgslArray, WgslStruct, atomicI32, atomicU32, isAlignAttrib, isAtomic, isBuiltinAttrib, isDecorated, isInterpolateAttrib, isLocationAttrib, isPtr, isSizeAttrib, isWgslArray, isWgslData, isWgslStruct, m2x2f, m3x3f, m4x4f, matBase, v2b, v2f, v2i, v2u, v3b, v3f, v3i, v3u, v4b, v4f, v4i, v4u, vecBase } from "./wgslTypes.js";
|
|
7
|
+
import { Align, AnyVecInstance, AnyWgslData, AnyWgslStruct, Atomic, BaseData, Bool, Builtin, Decorated, F16, F32, I32, Interpolate, Location, Mat2x2f, Mat3x3f, Mat4x4f, Ptr, Size, StorableData, U16, U32, Vec2b, Vec2f, Vec2h, Vec2i, Vec2u, Vec3b, Vec3f, Vec3h, Vec3i, Vec3u, Vec4b, Vec4f, Vec4h, Vec4i, Vec4u, Void, WgslArray, WgslStruct, atomicI32, atomicU32, isAlignAttrib, isAtomic, isBuiltinAttrib, isDecorated, isInterpolateAttrib, isLocationAttrib, isPtr, isSizeAttrib, isWgslArray, isWgslData, isWgslStruct, m2x2f, m3x3f, m4x4f, matBase, v2b, v2f, v2h, v2i, v2u, v3b, v3f, v3h, v3i, v3u, v4b, v4f, v4h, v4i, v4u, vecBase } from "./wgslTypes.js";
|
|
8
8
|
import { WgslExternalTexture, WgslStorageTexture, WgslStorageTexture1d, WgslStorageTexture2d, WgslStorageTexture2dArray, WgslStorageTexture3d, WgslStorageTextureProps, WgslTexture, WgslTexture1d, WgslTexture2d, WgslTexture2dArray, WgslTexture3d, WgslTextureCube, WgslTextureCubeArray, WgslTextureDepth2d, WgslTextureDepth2dArray, WgslTextureDepthCube, WgslTextureDepthCubeArray, WgslTextureDepthMultisampled2d, WgslTextureMultisampled2d, texture1d, texture2d, texture2dArray, texture3d, textureCube, textureCubeArray, textureDepth2d, textureDepth2dArray, textureDepthCube, textureDepthCubeArray, textureDepthMultisampled2d, textureExternal, textureMultisampled2d, textureStorage1d, textureStorage2d, textureStorage2dArray, textureStorage3d } from "./texture.js";
|
|
9
9
|
import { Infer, InferGPU, InferInput, InferPartial, InferPatch } from "../shared/repr.js";
|
|
10
10
|
import { AnyData, AnyLooseData, Disarray, LooseDecorated, Unstruct, isData, isDisarray, isLooseData, isLooseDecorated, isUnstruct } from "./dataTypes.js";
|
|
@@ -25,7 +25,7 @@ import { deepEqual } from "./deepEqual.js";
|
|
|
25
25
|
|
|
26
26
|
//#region src/data/index.d.ts
|
|
27
27
|
declare namespace index_d_exports {
|
|
28
|
-
export { Align, AnyAttribute, AnyBuiltin, AnyData, AnyLooseData, AnyVecInstance, AnyWgslData, AnyWgslStruct, Atomic, BaseData, BaseData as BaseWgslData, Bool, Builtin, BuiltinClipDistances, BuiltinFragDepth, BuiltinFrontFacing, BuiltinGlobalInvocationId, BuiltinInstanceIndex, BuiltinLocalInvocationId, BuiltinLocalInvocationIndex, BuiltinNumWorkgroups, BuiltinPosition, BuiltinSampleIndex, BuiltinSampleMask, BuiltinVertexIndex, BuiltinWorkgroupId, Decorated, Disarray, F16, F32, FormatToAcceptedData, FormatToWGSLType, HasCustomLocation, I32, Infer, InferGPU, InferInput, InferPartial, InferPatch, Interpolate, IsBuiltin, Location, LooseDecorated, Mat2x2f, Mat3x3f, Mat4x4f, PackedData, Ptr, Size, StorableData, TgpuVertexFormatData, U16, U32, Unstruct, Vec2b, Vec2f, Vec2h, Vec2i, Vec2u, Vec3b, Vec3f, Vec3h, Vec3i, Vec3u, Vec4b, Vec4f, Vec4h, Vec4i, Vec4u, Void, WgslArray, WgslComparisonSampler, WgslExternalTexture, WgslSampler, WgslStorageTexture, WgslStorageTexture1d, WgslStorageTexture2d, WgslStorageTexture2dArray, WgslStorageTexture3d, WgslStorageTextureProps, WgslStruct, WgslTexture, WgslTexture1d, WgslTexture2d, WgslTexture2dArray, WgslTexture3d, WgslTextureCube, WgslTextureCubeArray, WgslTextureDepth2d, WgslTextureDepth2dArray, WgslTextureDepthCube, WgslTextureDepthCubeArray, WgslTextureDepthMultisampled2d, WgslTextureMultisampled2d, align, PUBLIC_alignmentOf as alignmentOf, arrayOf, atomic, atomicI32, atomicU32, bool, builtin, comparisonSampler, deepEqual, disarrayOf, f16, f32, float16, float16x2, float16x4, float32, float32x2, float32x3, float32x4, formatToWGSLType, PUBLIC_getLongestContiguousPrefix as getLongestContiguousPrefix, i32, interpolate, invariant, isAlignAttrib, isAtomic, isBuiltin, isBuiltinAttrib, PUBLIC_isContiguous as isContiguous, isData, isDecorated, isDisarray, isInterpolateAttrib, isLocationAttrib, isLooseData, isLooseDecorated, isPackedData, isPtr, isSizeAttrib, isUnstruct, isWgslArray, isWgslData, isWgslStruct, location, m2x2f, m3x3f, m4x4f, mat2x2f, mat3x3f, mat4x4f, matBase, matToArray, memoryLayoutOf, packedFormats, ptrFn, ptrHandle, ptrPrivate, ptrStorage, ptrUniform, ptrWorkgroup, _ref as ref, sampler, sint16, sint16x2, sint16x4, sint32, sint32x2, sint32x3, sint32x4, sint8, sint8x2, sint8x4, size, PUBLIC_sizeOf as sizeOf, snorm16, snorm16x2, snorm16x4, snorm8, snorm8x2, snorm8x4, struct, texture1d, texture2d, texture2dArray, texture3d, textureCube, textureCubeArray, textureDepth2d, textureDepth2dArray, textureDepthCube, textureDepthCubeArray, textureDepthMultisampled2d, textureExternal, textureMultisampled2d, textureStorage1d, textureStorage2d, textureStorage2dArray, textureStorage3d, u16, u32, uint16, uint16x2, uint16x4, uint32, uint32x2, uint32x3, uint32x4, uint8, uint8x2, uint8x4, unorm10_10_10_2, unorm16, unorm16x2, unorm16x4, unorm8, unorm8x2, unorm8x4, unorm8x4_bgra, unstruct, v2b, v2f, v2i, v2u, v3b, v3f, v3i, v3u, v4b, v4f, v4i, v4u, vec2b, vec2f, vec2h, vec2i, vec2u, vec3b, vec3f, vec3h, vec3i, vec3u, vec4b, vec4f, vec4h, vec4i, vec4u, vecBase };
|
|
28
|
+
export { Align, AnyAttribute, AnyBuiltin, AnyData, AnyLooseData, AnyVecInstance, AnyWgslData, AnyWgslStruct, Atomic, BaseData, BaseData as BaseWgslData, Bool, Builtin, BuiltinClipDistances, BuiltinFragDepth, BuiltinFrontFacing, BuiltinGlobalInvocationId, BuiltinInstanceIndex, BuiltinLocalInvocationId, BuiltinLocalInvocationIndex, BuiltinNumWorkgroups, BuiltinPosition, BuiltinSampleIndex, BuiltinSampleMask, BuiltinVertexIndex, BuiltinWorkgroupId, Decorated, Disarray, F16, F32, FormatToAcceptedData, FormatToWGSLType, HasCustomLocation, I32, Infer, InferGPU, InferInput, InferPartial, InferPatch, Interpolate, IsBuiltin, Location, LooseDecorated, Mat2x2f, Mat3x3f, Mat4x4f, PackedData, Ptr, Size, StorableData, TgpuVertexFormatData, U16, U32, Unstruct, Vec2b, Vec2f, Vec2h, Vec2i, Vec2u, Vec3b, Vec3f, Vec3h, Vec3i, Vec3u, Vec4b, Vec4f, Vec4h, Vec4i, Vec4u, Void, WgslArray, WgslComparisonSampler, WgslExternalTexture, WgslSampler, WgslStorageTexture, WgslStorageTexture1d, WgslStorageTexture2d, WgslStorageTexture2dArray, WgslStorageTexture3d, WgslStorageTextureProps, WgslStruct, WgslTexture, WgslTexture1d, WgslTexture2d, WgslTexture2dArray, WgslTexture3d, WgslTextureCube, WgslTextureCubeArray, WgslTextureDepth2d, WgslTextureDepth2dArray, WgslTextureDepthCube, WgslTextureDepthCubeArray, WgslTextureDepthMultisampled2d, WgslTextureMultisampled2d, align, PUBLIC_alignmentOf as alignmentOf, arrayOf, atomic, atomicI32, atomicU32, bool, builtin, comparisonSampler, deepEqual, disarrayOf, f16, f32, float16, float16x2, float16x4, float32, float32x2, float32x3, float32x4, formatToWGSLType, PUBLIC_getLongestContiguousPrefix as getLongestContiguousPrefix, i32, interpolate, invariant, isAlignAttrib, isAtomic, isBuiltin, isBuiltinAttrib, PUBLIC_isContiguous as isContiguous, isData, isDecorated, isDisarray, isInterpolateAttrib, isLocationAttrib, isLooseData, isLooseDecorated, isPackedData, isPtr, isSizeAttrib, isUnstruct, isWgslArray, isWgslData, isWgslStruct, location, m2x2f, m3x3f, m4x4f, mat2x2f, mat3x3f, mat4x4f, matBase, matToArray, memoryLayoutOf, packedFormats, ptrFn, ptrHandle, ptrPrivate, ptrStorage, ptrUniform, ptrWorkgroup, _ref as ref, sampler, sint16, sint16x2, sint16x4, sint32, sint32x2, sint32x3, sint32x4, sint8, sint8x2, sint8x4, size, PUBLIC_sizeOf as sizeOf, snorm16, snorm16x2, snorm16x4, snorm8, snorm8x2, snorm8x4, struct, texture1d, texture2d, texture2dArray, texture3d, textureCube, textureCubeArray, textureDepth2d, textureDepth2dArray, textureDepthCube, textureDepthCubeArray, textureDepthMultisampled2d, textureExternal, textureMultisampled2d, textureStorage1d, textureStorage2d, textureStorage2dArray, textureStorage3d, u16, u32, uint16, uint16x2, uint16x4, uint32, uint32x2, uint32x3, uint32x4, uint8, uint8x2, uint8x4, unorm10_10_10_2, unorm16, unorm16x2, unorm16x4, unorm8, unorm8x2, unorm8x4, unorm8x4_bgra, unstruct, v2b, v2f, v2h, v2i, v2u, v3b, v3f, v3h, v3i, v3u, v4b, v4f, v4h, v4i, v4u, vec2b, vec2f, vec2h, vec2i, vec2u, vec3b, vec3f, vec3h, vec3i, vec3u, vec4b, vec4f, vec4h, vec4i, vec4u, vecBase };
|
|
29
29
|
}
|
|
30
30
|
//#endregion
|
|
31
|
-
export { type Align, type AnyAttribute, type AnyBuiltin, type AnyData, type AnyLooseData, type AnyVecInstance, type AnyWgslData, type AnyWgslStruct, type Atomic, type BaseData, type BaseData as BaseWgslData, type Bool, type Builtin, type BuiltinClipDistances, type BuiltinFragDepth, type BuiltinFrontFacing, type BuiltinGlobalInvocationId, type BuiltinInstanceIndex, type BuiltinLocalInvocationId, type BuiltinLocalInvocationIndex, type BuiltinNumWorkgroups, type BuiltinPosition, type BuiltinSampleIndex, type BuiltinSampleMask, type BuiltinVertexIndex, type BuiltinWorkgroupId, type Decorated, type Disarray, type F16, type F32, FormatToAcceptedData, FormatToWGSLType, type HasCustomLocation, type I32, type Infer, type InferGPU, type InferInput, type InferPartial, type InferPatch, type Interpolate, type IsBuiltin, type Location, type LooseDecorated, type Mat2x2f, type Mat3x3f, type Mat4x4f, PackedData, type Ptr, type Size, type StorableData, TgpuVertexFormatData, type U16, type U32, type Unstruct, type Vec2b, type Vec2f, type Vec2h, type Vec2i, type Vec2u, type Vec3b, type Vec3f, type Vec3h, type Vec3i, type Vec3u, type Vec4b, type Vec4f, type Vec4h, type Vec4i, type Vec4u, Void, type WgslArray, type WgslComparisonSampler, type WgslExternalTexture, type WgslSampler, type WgslStorageTexture, type WgslStorageTexture1d, type WgslStorageTexture2d, type WgslStorageTexture2dArray, type WgslStorageTexture3d, type WgslStorageTextureProps, type WgslStruct, type WgslTexture, type WgslTexture1d, type WgslTexture2d, type WgslTexture2dArray, type WgslTexture3d, type WgslTextureCube, type WgslTextureCubeArray, type WgslTextureDepth2d, type WgslTextureDepth2dArray, type WgslTextureDepthCube, type WgslTextureDepthCubeArray, type WgslTextureDepthMultisampled2d, type WgslTextureMultisampled2d, align, PUBLIC_alignmentOf as alignmentOf, arrayOf, atomic, type atomicI32, type atomicU32, bool, builtin, comparisonSampler, deepEqual, disarrayOf, f16, f32, float16, float16x2, float16x4, float32, float32x2, float32x3, float32x4, formatToWGSLType, PUBLIC_getLongestContiguousPrefix as getLongestContiguousPrefix, i32, index_d_exports, interpolate, invariant, isAlignAttrib, isAtomic, isBuiltin, isBuiltinAttrib, PUBLIC_isContiguous as isContiguous, isData, isDecorated, isDisarray, isInterpolateAttrib, isLocationAttrib, isLooseData, isLooseDecorated, isPackedData, isPtr, isSizeAttrib, isUnstruct, isWgslArray, isWgslData, isWgslStruct, location, type m2x2f, type m3x3f, type m4x4f, mat2x2f, mat3x3f, mat4x4f, type matBase, matToArray, memoryLayoutOf, packedFormats, ptrFn, ptrHandle, ptrPrivate, ptrStorage, ptrUniform, ptrWorkgroup, _ref as ref, sampler, sint16, sint16x2, sint16x4, sint32, sint32x2, sint32x3, sint32x4, sint8, sint8x2, sint8x4, size, PUBLIC_sizeOf as sizeOf, snorm16, snorm16x2, snorm16x4, snorm8, snorm8x2, snorm8x4, struct, texture1d, texture2d, texture2dArray, texture3d, textureCube, textureCubeArray, textureDepth2d, textureDepth2dArray, textureDepthCube, textureDepthCubeArray, textureDepthMultisampled2d, textureExternal, textureMultisampled2d, textureStorage1d, textureStorage2d, textureStorage2dArray, textureStorage3d, u16, u32, uint16, uint16x2, uint16x4, uint32, uint32x2, uint32x3, uint32x4, uint8, uint8x2, uint8x4, unorm10_10_10_2, unorm16, unorm16x2, unorm16x4, unorm8, unorm8x2, unorm8x4, unorm8x4_bgra, unstruct, type v2b, type v2f, type v2i, type v2u, type v3b, type v3f, type v3i, type v3u, type v4b, type v4f, type v4i, type v4u, vec2b, vec2f, vec2h, vec2i, vec2u, vec3b, vec3f, vec3h, vec3i, vec3u, vec4b, vec4f, vec4h, vec4i, vec4u, type vecBase };
|
|
31
|
+
export { type Align, type AnyAttribute, type AnyBuiltin, type AnyData, type AnyLooseData, type AnyVecInstance, type AnyWgslData, type AnyWgslStruct, type Atomic, type BaseData, type BaseData as BaseWgslData, type Bool, type Builtin, type BuiltinClipDistances, type BuiltinFragDepth, type BuiltinFrontFacing, type BuiltinGlobalInvocationId, type BuiltinInstanceIndex, type BuiltinLocalInvocationId, type BuiltinLocalInvocationIndex, type BuiltinNumWorkgroups, type BuiltinPosition, type BuiltinSampleIndex, type BuiltinSampleMask, type BuiltinVertexIndex, type BuiltinWorkgroupId, type Decorated, type Disarray, type F16, type F32, FormatToAcceptedData, FormatToWGSLType, type HasCustomLocation, type I32, type Infer, type InferGPU, type InferInput, type InferPartial, type InferPatch, type Interpolate, type IsBuiltin, type Location, type LooseDecorated, type Mat2x2f, type Mat3x3f, type Mat4x4f, PackedData, type Ptr, type Size, type StorableData, TgpuVertexFormatData, type U16, type U32, type Unstruct, type Vec2b, type Vec2f, type Vec2h, type Vec2i, type Vec2u, type Vec3b, type Vec3f, type Vec3h, type Vec3i, type Vec3u, type Vec4b, type Vec4f, type Vec4h, type Vec4i, type Vec4u, Void, type WgslArray, type WgslComparisonSampler, type WgslExternalTexture, type WgslSampler, type WgslStorageTexture, type WgslStorageTexture1d, type WgslStorageTexture2d, type WgslStorageTexture2dArray, type WgslStorageTexture3d, type WgslStorageTextureProps, type WgslStruct, type WgslTexture, type WgslTexture1d, type WgslTexture2d, type WgslTexture2dArray, type WgslTexture3d, type WgslTextureCube, type WgslTextureCubeArray, type WgslTextureDepth2d, type WgslTextureDepth2dArray, type WgslTextureDepthCube, type WgslTextureDepthCubeArray, type WgslTextureDepthMultisampled2d, type WgslTextureMultisampled2d, align, PUBLIC_alignmentOf as alignmentOf, arrayOf, atomic, type atomicI32, type atomicU32, bool, builtin, comparisonSampler, deepEqual, disarrayOf, f16, f32, float16, float16x2, float16x4, float32, float32x2, float32x3, float32x4, formatToWGSLType, PUBLIC_getLongestContiguousPrefix as getLongestContiguousPrefix, i32, index_d_exports, interpolate, invariant, isAlignAttrib, isAtomic, isBuiltin, isBuiltinAttrib, PUBLIC_isContiguous as isContiguous, isData, isDecorated, isDisarray, isInterpolateAttrib, isLocationAttrib, isLooseData, isLooseDecorated, isPackedData, isPtr, isSizeAttrib, isUnstruct, isWgslArray, isWgslData, isWgslStruct, location, type m2x2f, type m3x3f, type m4x4f, mat2x2f, mat3x3f, mat4x4f, type matBase, matToArray, memoryLayoutOf, packedFormats, ptrFn, ptrHandle, ptrPrivate, ptrStorage, ptrUniform, ptrWorkgroup, _ref as ref, sampler, sint16, sint16x2, sint16x4, sint32, sint32x2, sint32x3, sint32x4, sint8, sint8x2, sint8x4, size, PUBLIC_sizeOf as sizeOf, snorm16, snorm16x2, snorm16x4, snorm8, snorm8x2, snorm8x4, struct, texture1d, texture2d, texture2dArray, texture3d, textureCube, textureCubeArray, textureDepth2d, textureDepth2dArray, textureDepthCube, textureDepthCubeArray, textureDepthMultisampled2d, textureExternal, textureMultisampled2d, textureStorage1d, textureStorage2d, textureStorage2dArray, textureStorage3d, u16, u32, uint16, uint16x2, uint16x4, uint32, uint32x2, uint32x3, uint32x4, uint8, uint8x2, uint8x4, unorm10_10_10_2, unorm16, unorm16x2, unorm16x4, unorm8, unorm8x2, unorm8x4, unorm8x4_bgra, unstruct, type v2b, type v2f, type v2h, type v2i, type v2u, type v3b, type v3f, type v3h, type v3i, type v3u, type v4b, type v4f, type v4h, type v4i, type v4u, vec2b, vec2f, vec2h, vec2i, vec2u, vec3b, vec3f, vec3h, vec3i, vec3u, vec4b, vec4f, vec4h, vec4i, vec4u, type vecBase };
|