typegpu 0.10.2 → 0.11.0-rc.1
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/_virtual/_rolldown/runtime.js +6 -11
- package/builtin.js +1 -3
- package/common/fullScreenTriangle.d.ts +1 -5
- package/common/fullScreenTriangle.js +1 -3
- package/common/index.d.ts +3 -2
- package/common/index.js +6 -4
- package/common/writeSoA.d.ts +16 -0
- package/common/writeSoA.js +90 -0
- package/core/buffer/buffer.d.ts +12 -7
- package/core/buffer/buffer.js +102 -53
- package/core/buffer/bufferShorthand.d.ts +5 -5
- package/core/buffer/bufferShorthand.js +9 -5
- package/core/buffer/bufferUsage.d.ts +0 -2
- package/core/buffer/bufferUsage.js +6 -4
- package/core/constant/tgpuConstant.d.ts +2 -1
- package/core/constant/tgpuConstant.js +8 -7
- package/core/declare/tgpuDeclare.js +8 -9
- package/core/function/autoIO.d.ts +7 -6
- package/core/function/autoIO.js +1 -3
- package/core/function/comptime.js +1 -3
- package/core/function/createCallableSchema.js +4 -6
- package/core/function/dualImpl.js +1 -3
- package/core/function/entryInputRouter.js +39 -0
- package/core/function/extractArgs.js +2 -2
- package/core/function/fnCore.js +19 -8
- package/core/function/fnTypes.d.ts +14 -8
- package/core/function/ioSchema.js +24 -3
- package/core/function/shelllessImpl.js +1 -3
- package/core/function/templateUtils.js +1 -2
- package/core/function/tgpuComputeFn.d.ts +2 -3
- package/core/function/tgpuComputeFn.js +9 -16
- package/core/function/tgpuFn.d.ts +2 -2
- package/core/function/tgpuFn.js +1 -3
- package/core/function/tgpuFragmentFn.d.ts +5 -1
- package/core/function/tgpuFragmentFn.js +5 -10
- package/core/function/tgpuVertexFn.d.ts +4 -0
- package/core/function/tgpuVertexFn.js +6 -12
- package/core/pipeline/applyPipelineState.js +1 -3
- package/core/pipeline/computePipeline.d.ts +2 -6
- package/core/pipeline/computePipeline.js +64 -63
- package/core/pipeline/connectAttachmentToShader.js +1 -3
- package/core/pipeline/connectTargetsToShader.js +1 -3
- package/core/pipeline/limitsOverflow.js +1 -2
- package/core/pipeline/pipelineUtils.js +29 -0
- package/core/pipeline/renderPipeline.d.ts +23 -5
- package/core/pipeline/renderPipeline.js +32 -14
- package/core/pipeline/timeable.d.ts +0 -3
- package/core/pipeline/timeable.js +3 -9
- package/core/pipeline/typeGuards.js +1 -3
- package/core/querySet/querySet.d.ts +0 -2
- package/core/querySet/querySet.js +37 -36
- package/core/rawCodeSnippet/tgpuRawCodeSnippet.js +1 -3
- package/core/resolve/externals.d.ts +0 -2
- package/core/resolve/externals.js +2 -4
- package/core/resolve/namespace.js +1 -3
- package/core/resolve/resolveData.js +1 -3
- package/core/resolve/stitch.js +1 -3
- package/core/resolve/tgpuResolve.d.ts +3 -1
- package/core/resolve/tgpuResolve.js +3 -5
- package/core/root/configurableImpl.js +2 -3
- package/core/root/init.d.ts +0 -5
- package/core/root/init.js +35 -28
- package/core/root/rootTypes.d.ts +25 -5
- package/core/sampler/sampler.d.ts +0 -4
- package/core/sampler/sampler.js +3 -3
- package/core/simulate/tgpuSimulate.js +1 -3
- package/core/slot/accessor.d.ts +0 -4
- package/core/slot/accessor.js +1 -3
- package/core/slot/internalSlots.js +1 -3
- package/core/slot/lazy.js +1 -3
- package/core/slot/slot.js +2 -3
- package/core/slot/slotTypes.js +1 -3
- package/core/texture/externalTexture.d.ts +0 -6
- package/core/texture/externalTexture.js +2 -3
- package/core/texture/texture.d.ts +0 -4
- package/core/texture/texture.js +5 -3
- package/core/texture/textureFormats.js +1 -3
- package/core/texture/textureUtils.js +1 -3
- package/core/texture/usageExtension.js +1 -3
- package/core/unroll/tgpuUnroll.d.ts +58 -3
- package/core/unroll/tgpuUnroll.js +63 -5
- package/core/valueProxyUtils.js +1 -3
- package/core/variable/tgpuVariable.js +1 -3
- package/core/vertexLayout/connectAttributesToShader.js +1 -3
- package/core/vertexLayout/vertexLayout.js +9 -9
- package/data/alignIO.js +1 -2
- package/data/alignmentOf.d.ts +0 -1
- package/data/alignmentOf.js +1 -3
- package/data/array.d.ts +1 -3
- package/data/array.js +2 -4
- package/data/atomic.js +2 -3
- package/data/attributes.js +3 -3
- package/data/autoStruct.d.ts +1 -3
- package/data/autoStruct.js +1 -3
- package/data/compiledIO.js +83 -86
- package/data/dataIO.js +46 -39
- package/data/dataTypes.d.ts +7 -7
- package/data/dataTypes.js +6 -3
- package/data/deepEqual.js +1 -3
- package/data/disarray.d.ts +1 -3
- package/data/disarray.js +1 -3
- package/data/getLongestContiguousPrefix.d.ts +0 -1
- package/data/getLongestContiguousPrefix.js +1 -3
- package/data/index.d.ts +3 -3
- package/data/index.js +10 -3
- package/data/isContiguous.d.ts +0 -1
- package/data/isContiguous.js +1 -3
- package/data/matrix.d.ts +8 -10
- package/data/matrix.js +32 -18
- package/data/numberOps.js +1 -2
- package/data/numeric.js +16 -29
- package/data/offsetUtils.d.ts +2 -2
- package/data/offsetUtils.js +3 -5
- package/data/offsets.js +1 -3
- package/data/partialIO.js +84 -39
- package/data/ptr.d.ts +0 -1
- package/data/ptr.js +1 -3
- package/data/ref.d.ts +0 -3
- package/data/ref.js +1 -3
- package/data/sampler.js +1 -3
- package/data/schemaCallWrapper.js +1 -3
- package/data/schemaMemoryLayout.js +1 -3
- package/data/sizeOf.d.ts +0 -1
- package/data/sizeOf.js +1 -3
- package/data/snippet.js +12 -3
- package/data/struct.js +1 -3
- package/data/texture.js +1 -3
- package/data/unstruct.js +1 -3
- package/data/vector.js +4 -12
- package/data/vectorImpl.js +27 -28
- package/data/vectorOps.js +20 -3
- package/data/vertexFormatData.js +2 -3
- package/data/wgslTypes.d.ts +39 -11
- package/data/wgslTypes.js +10 -3
- package/errors.js +6 -3
- package/execMode.js +1 -3
- package/extension.js +1 -3
- package/getGPUValue.js +1 -3
- package/index.d.ts +4 -2
- package/index.js +3 -3
- package/indexNamedExports.d.ts +3 -1
- package/mathUtils.js +1 -2
- package/memo.js +8 -8
- package/nameRegistry.js +1 -3
- package/package.js +2 -3
- package/package.json +5 -5
- package/resolutionCtx.d.ts +0 -10
- package/resolutionCtx.js +84 -18
- package/shared/env.js +1 -2
- package/shared/generators.js +1 -2
- package/shared/meta.js +1 -3
- package/shared/repr.d.ts +32 -2
- package/shared/stringify.js +1 -3
- package/shared/symbols.d.ts +10 -1
- package/shared/symbols.js +10 -33
- package/shared/utilityTypes.d.ts +6 -2
- package/shared/utilityTypes.js +1 -2
- package/shared/vertexFormat.js +1 -2
- package/std/array.d.ts +1 -1
- package/std/array.js +1 -3
- package/std/atomic.d.ts +12 -12
- package/std/atomic.js +1 -3
- package/std/bitcast.d.ts +2 -2
- package/std/bitcast.js +1 -3
- package/std/boolean.d.ts +30 -16
- package/std/boolean.js +37 -12
- package/std/derivative.d.ts +9 -9
- package/std/derivative.js +1 -3
- package/std/discard.d.ts +1 -1
- package/std/discard.js +1 -3
- package/std/extensions.d.ts +1 -3
- package/std/extensions.js +1 -3
- package/std/index.d.ts +5 -4
- package/std/index.js +8 -5
- package/std/matrix.d.ts +5 -5
- package/std/matrix.js +1 -3
- package/std/numeric.d.ts +78 -132
- package/std/numeric.js +1 -3
- package/std/operators.d.ts +16 -8
- package/std/operators.js +80 -6
- package/std/packing.d.ts +4 -4
- package/std/packing.js +1 -3
- package/std/range.d.ts +24 -0
- package/std/range.js +38 -0
- package/std/subgroup.d.ts +21 -21
- package/std/subgroup.js +1 -3
- package/std/texture.d.ts +20 -11
- package/std/texture.js +13 -3
- package/tgpu.js +1 -3
- package/tgpuBindGroupLayout.js +9 -8
- package/tgpuUnstable.js +1 -3
- package/tgsl/accessIndex.js +2 -4
- package/tgsl/accessProp.js +8 -6
- package/tgsl/consoleLog/deserializers.js +1 -3
- package/tgsl/consoleLog/logGenerator.js +2 -4
- package/tgsl/consoleLog/serializers.js +24 -26
- package/tgsl/consoleLog/types.d.ts +0 -2
- package/tgsl/consoleLog/types.js +1 -2
- package/tgsl/conversion.js +1 -3
- package/tgsl/forOfUtils.js +35 -9
- package/tgsl/generationHelpers.js +3 -3
- package/tgsl/math.js +1 -3
- package/tgsl/shaderGenerator.d.ts +10 -8
- package/tgsl/shaderGenerator_members.d.ts +2 -0
- package/tgsl/shaderGenerator_members.js +6 -0
- package/tgsl/shellless.js +1 -8
- package/tgsl/wgslGenerator.d.ts +36 -0
- package/tgsl/wgslGenerator.js +135 -81
- package/types.d.ts +14 -4
- package/types.js +3 -3
- package/wgslExtensions.js +1 -2
|
@@ -1,15 +1,12 @@
|
|
|
1
1
|
import { $internal } from "../../shared/symbols.js";
|
|
2
2
|
import { isQuerySet } from "../querySet/querySet.js";
|
|
3
|
-
|
|
4
3
|
//#region src/core/pipeline/timeable.ts
|
|
5
|
-
function createWithPerformanceCallback(currentPriors, callback,
|
|
6
|
-
if (!root.enabledFeatures.has("timestamp-query")) throw new Error("Performance callback requires the \"timestamp-query\" feature to be enabled on GPU device.");
|
|
4
|
+
function createWithPerformanceCallback(currentPriors, callback, querySet) {
|
|
7
5
|
if (!currentPriors.timestampWrites) return {
|
|
8
6
|
...currentPriors,
|
|
9
7
|
performanceCallback: callback,
|
|
10
|
-
hasAutoQuerySet: true,
|
|
11
8
|
timestampWrites: {
|
|
12
|
-
querySet
|
|
9
|
+
querySet,
|
|
13
10
|
beginningOfPassWriteIndex: 0,
|
|
14
11
|
endOfPassWriteIndex: 1
|
|
15
12
|
}
|
|
@@ -21,13 +18,11 @@ function createWithPerformanceCallback(currentPriors, callback, root) {
|
|
|
21
18
|
}
|
|
22
19
|
function createWithTimestampWrites(currentPriors, options, root) {
|
|
23
20
|
if (!root.enabledFeatures.has("timestamp-query")) throw new Error("Timestamp writes require the \"timestamp-query\" feature to be enabled on GPU device.");
|
|
24
|
-
if (currentPriors.hasAutoQuerySet && currentPriors.timestampWrites) currentPriors.timestampWrites.querySet.destroy();
|
|
25
21
|
const timestampWrites = { querySet: options.querySet };
|
|
26
22
|
if (options.beginningOfPassWriteIndex !== void 0) timestampWrites.beginningOfPassWriteIndex = options.beginningOfPassWriteIndex;
|
|
27
23
|
if (options.endOfPassWriteIndex !== void 0) timestampWrites.endOfPassWriteIndex = options.endOfPassWriteIndex;
|
|
28
24
|
return {
|
|
29
25
|
...currentPriors,
|
|
30
|
-
hasAutoQuerySet: false,
|
|
31
26
|
timestampWrites
|
|
32
27
|
};
|
|
33
28
|
}
|
|
@@ -56,6 +51,5 @@ function triggerPerformanceCallback({ root, priors }) {
|
|
|
56
51
|
await callback(start, end);
|
|
57
52
|
});
|
|
58
53
|
}
|
|
59
|
-
|
|
60
54
|
//#endregion
|
|
61
|
-
export { createWithPerformanceCallback, createWithTimestampWrites, setupTimestampWrites, triggerPerformanceCallback };
|
|
55
|
+
export { createWithPerformanceCallback, createWithTimestampWrites, setupTimestampWrites, triggerPerformanceCallback };
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { $internal } from "../../shared/symbols.js";
|
|
2
|
-
|
|
3
2
|
//#region src/core/pipeline/typeGuards.ts
|
|
4
3
|
function isComputePipeline(value) {
|
|
5
4
|
const maybe = value;
|
|
@@ -24,6 +23,5 @@ function isGPURenderPassEncoder(value) {
|
|
|
24
23
|
function isGPURenderBundleEncoder(value) {
|
|
25
24
|
return !!value && typeof value === "object" && "draw" in value && "finish" in value && !("executeBundles" in value) && !("beginRenderPass" in value) && !("dispatchWorkgroups" in value);
|
|
26
25
|
}
|
|
27
|
-
|
|
28
26
|
//#endregion
|
|
29
|
-
export { isComputePipeline, isGPUCommandEncoder, isGPUComputePassEncoder, isGPURenderBundleEncoder, isGPURenderPassEncoder, isPipeline, isRenderPipeline };
|
|
27
|
+
export { isComputePipeline, isGPUCommandEncoder, isGPUComputePassEncoder, isGPURenderBundleEncoder, isGPURenderPassEncoder, isPipeline, isRenderPipeline };
|
|
@@ -1,7 +1,5 @@
|
|
|
1
1
|
import { TgpuNamable } from "../../shared/meta.js";
|
|
2
2
|
import { $internal } from "../../shared/symbols.js";
|
|
3
|
-
import "../root/rootTypes.js";
|
|
4
|
-
|
|
5
3
|
//#region src/core/querySet/querySet.d.ts
|
|
6
4
|
interface TgpuQuerySet<T extends GPUQueryType> extends TgpuNamable {
|
|
7
5
|
readonly resourceType: 'query-set';
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { $internal } from "../../shared/symbols.js";
|
|
2
2
|
import { setName } from "../../shared/meta.js";
|
|
3
|
-
|
|
4
3
|
//#region src/core/querySet/querySet.ts
|
|
5
4
|
function INTERNAL_createQuerySet(group, type, count, rawQuerySet) {
|
|
6
5
|
return new TgpuQuerySetImpl(group, type, count, rawQuerySet);
|
|
@@ -11,71 +10,74 @@ function isQuerySet(value) {
|
|
|
11
10
|
}
|
|
12
11
|
var TgpuQuerySetImpl = class {
|
|
13
12
|
resourceType = "query-set";
|
|
13
|
+
type;
|
|
14
|
+
count;
|
|
15
|
+
#rawQuerySet;
|
|
14
16
|
#device;
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
17
|
+
#querySet;
|
|
18
|
+
#ownQuerySet;
|
|
19
|
+
#destroyed = false;
|
|
20
|
+
#available = true;
|
|
21
|
+
#readBuffer = void 0;
|
|
22
|
+
#resolveBuffer = void 0;
|
|
21
23
|
constructor(root, type, count, rawQuerySet) {
|
|
24
|
+
this.#device = root.device;
|
|
22
25
|
this.type = type;
|
|
23
26
|
this.count = count;
|
|
24
|
-
this
|
|
25
|
-
this.#
|
|
26
|
-
this
|
|
27
|
-
this._querySet = rawQuerySet || null;
|
|
27
|
+
this.#rawQuerySet = rawQuerySet;
|
|
28
|
+
this.#ownQuerySet = !rawQuerySet;
|
|
29
|
+
this.#querySet = rawQuerySet;
|
|
28
30
|
}
|
|
29
31
|
get querySet() {
|
|
30
|
-
if (this
|
|
31
|
-
if (this
|
|
32
|
-
if (this
|
|
33
|
-
this
|
|
32
|
+
if (this.#destroyed) throw new Error("This QuerySet has been destroyed.");
|
|
33
|
+
if (this.#rawQuerySet) return this.#rawQuerySet;
|
|
34
|
+
if (this.#querySet) return this.#querySet;
|
|
35
|
+
this.#querySet = this.#device.createQuerySet({
|
|
34
36
|
type: this.type,
|
|
35
37
|
count: this.count
|
|
36
38
|
});
|
|
37
|
-
return this
|
|
39
|
+
return this.#querySet;
|
|
38
40
|
}
|
|
39
41
|
get destroyed() {
|
|
40
|
-
return this
|
|
42
|
+
return this.#destroyed;
|
|
41
43
|
}
|
|
42
44
|
get available() {
|
|
43
|
-
return this
|
|
45
|
+
return this.#available;
|
|
44
46
|
}
|
|
45
47
|
get [$internal]() {
|
|
46
48
|
const self = this;
|
|
47
49
|
return {
|
|
48
50
|
get readBuffer() {
|
|
49
|
-
if (!self
|
|
51
|
+
if (!self.#readBuffer) self.#readBuffer = self.#device.createBuffer({
|
|
50
52
|
size: self.count * BigUint64Array.BYTES_PER_ELEMENT,
|
|
51
53
|
usage: GPUBufferUsage.COPY_DST | GPUBufferUsage.MAP_READ
|
|
52
54
|
});
|
|
53
|
-
return self
|
|
55
|
+
return self.#readBuffer;
|
|
54
56
|
},
|
|
55
57
|
get resolveBuffer() {
|
|
56
|
-
if (!self
|
|
58
|
+
if (!self.#resolveBuffer) self.#resolveBuffer = self.#device.createBuffer({
|
|
57
59
|
size: self.count * BigUint64Array.BYTES_PER_ELEMENT,
|
|
58
60
|
usage: GPUBufferUsage.QUERY_RESOLVE | GPUBufferUsage.COPY_SRC
|
|
59
61
|
});
|
|
60
|
-
return self
|
|
62
|
+
return self.#resolveBuffer;
|
|
61
63
|
}
|
|
62
64
|
};
|
|
63
65
|
}
|
|
64
66
|
$name(label) {
|
|
65
67
|
setName(this, label);
|
|
66
|
-
if (this
|
|
68
|
+
if (this.#querySet) this.#querySet.label = label;
|
|
67
69
|
return this;
|
|
68
70
|
}
|
|
69
71
|
resolve() {
|
|
70
|
-
if (this
|
|
71
|
-
if (!this
|
|
72
|
+
if (this.#destroyed) throw new Error("This QuerySet has been destroyed.");
|
|
73
|
+
if (!this.#available) throw new Error("This QuerySet is busy resolving or reading.");
|
|
72
74
|
const commandEncoder = this.#device.createCommandEncoder();
|
|
73
75
|
commandEncoder.resolveQuerySet(this.querySet, 0, this.count, this[$internal].resolveBuffer, 0);
|
|
74
76
|
this.#device.queue.submit([commandEncoder.finish()]);
|
|
75
77
|
}
|
|
76
78
|
async read() {
|
|
77
|
-
if (!this
|
|
78
|
-
this
|
|
79
|
+
if (!this.#resolveBuffer) throw new Error("QuerySet must be resolved before reading.");
|
|
80
|
+
this.#available = false;
|
|
79
81
|
try {
|
|
80
82
|
const commandEncoder = this.#device.createCommandEncoder();
|
|
81
83
|
commandEncoder.copyBufferToBuffer(this[$internal].resolveBuffer, 0, this[$internal].readBuffer, 0, this.count * BigUint64Array.BYTES_PER_ELEMENT);
|
|
@@ -86,18 +88,17 @@ var TgpuQuerySetImpl = class {
|
|
|
86
88
|
readBuffer.unmap();
|
|
87
89
|
return Array.from(data);
|
|
88
90
|
} finally {
|
|
89
|
-
this
|
|
91
|
+
this.#available = true;
|
|
90
92
|
}
|
|
91
93
|
}
|
|
92
94
|
destroy() {
|
|
93
|
-
if (this
|
|
94
|
-
this
|
|
95
|
-
if (this
|
|
96
|
-
this
|
|
97
|
-
this
|
|
98
|
-
this
|
|
95
|
+
if (this.#destroyed) return;
|
|
96
|
+
this.#destroyed = true;
|
|
97
|
+
if (this.#querySet && this.#ownQuerySet) this.#querySet.destroy();
|
|
98
|
+
this.#readBuffer?.destroy();
|
|
99
|
+
this.#resolveBuffer?.destroy();
|
|
100
|
+
this.#readBuffer = this.#resolveBuffer = void 0;
|
|
99
101
|
}
|
|
100
102
|
};
|
|
101
|
-
|
|
102
103
|
//#endregion
|
|
103
|
-
export { INTERNAL_createQuerySet, isQuerySet };
|
|
104
|
+
export { INTERNAL_createQuerySet, isQuerySet };
|
|
@@ -3,7 +3,6 @@ import { snip } from "../../data/snippet.js";
|
|
|
3
3
|
import { inCodegenMode } from "../../execMode.js";
|
|
4
4
|
import { valueProxyHandler } from "../valueProxyUtils.js";
|
|
5
5
|
import { applyExternals, replaceExternalsInWgsl } from "../resolve/externals.js";
|
|
6
|
-
|
|
7
6
|
//#region src/core/rawCodeSnippet/tgpuRawCodeSnippet.ts
|
|
8
7
|
/**
|
|
9
8
|
* An advanced API that creates a typed shader expression which
|
|
@@ -91,6 +90,5 @@ var TgpuRawCodeSnippetImpl = class {
|
|
|
91
90
|
return this.$;
|
|
92
91
|
}
|
|
93
92
|
};
|
|
94
|
-
|
|
95
93
|
//#endregion
|
|
96
|
-
export { rawCodeSnippet };
|
|
94
|
+
export { rawCodeSnippet };
|
|
@@ -2,7 +2,6 @@ import { getName, hasTinyestMetadata, setName } from "../../shared/meta.js";
|
|
|
2
2
|
import { isWgslStruct } from "../../data/wgslTypes.js";
|
|
3
3
|
import { isLooseData } from "../../data/dataTypes.js";
|
|
4
4
|
import { isWgsl } from "../../types.js";
|
|
5
|
-
|
|
6
5
|
//#region src/core/resolve/externals.ts
|
|
7
6
|
/**
|
|
8
7
|
* Merges two external maps into one. If a key is present in both maps, the value from the new map is used.
|
|
@@ -43,7 +42,7 @@ function identifierRegex(name) {
|
|
|
43
42
|
function replaceExternalsInWgsl(ctx, externalMap, wgsl) {
|
|
44
43
|
return Object.entries(externalMap).reduce((acc, [externalName, external]) => {
|
|
45
44
|
const externalRegex = identifierRegex(externalName);
|
|
46
|
-
if (wgsl && externalName !== "Out" && externalName !== "
|
|
45
|
+
if (wgsl && externalName !== "Out" && externalName !== "in" && !externalRegex.test(wgsl)) console.warn(`The external '${externalName}' wasn't used in the resolved template.`);
|
|
47
46
|
if (isWgsl(external) || isLooseData(external) || hasTinyestMetadata(external)) return acc.replaceAll(externalRegex, ctx.resolve(external).value);
|
|
48
47
|
if (external !== null && typeof external === "object") {
|
|
49
48
|
const foundProperties = [...wgsl.matchAll(new RegExp(`${externalName.replaceAll(".", "\\.").replaceAll("$", "\\$")}\\.(?<prop>.*?)(?![\\w\\$_])`, "g"))].map((found) => found[1]);
|
|
@@ -53,6 +52,5 @@ function replaceExternalsInWgsl(ctx, externalMap, wgsl) {
|
|
|
53
52
|
return acc;
|
|
54
53
|
}, wgsl);
|
|
55
54
|
}
|
|
56
|
-
|
|
57
55
|
//#endregion
|
|
58
|
-
export { addArgTypesToExternals, addReturnTypeToExternals, applyExternals, replaceExternalsInWgsl };
|
|
56
|
+
export { addArgTypesToExternals, addReturnTypeToExternals, applyExternals, replaceExternalsInWgsl };
|
|
@@ -2,7 +2,6 @@ import { $internal } from "../../shared/symbols.js";
|
|
|
2
2
|
import { getName } from "../../shared/meta.js";
|
|
3
3
|
import { RandomNameRegistry, StrictNameRegistry } from "../../nameRegistry.js";
|
|
4
4
|
import { ShelllessRepository } from "../../tgsl/shellless.js";
|
|
5
|
-
|
|
6
5
|
//#region src/core/resolve/namespace.ts
|
|
7
6
|
var NamespaceImpl = class {
|
|
8
7
|
[$internal];
|
|
@@ -36,6 +35,5 @@ function namespace(options) {
|
|
|
36
35
|
const { names = "strict" } = options ?? {};
|
|
37
36
|
return new NamespaceImpl(names === "strict" ? new StrictNameRegistry() : new RandomNameRegistry());
|
|
38
37
|
}
|
|
39
|
-
|
|
40
38
|
//#endregion
|
|
41
|
-
export { getUniqueName, namespace };
|
|
39
|
+
export { getUniqueName, namespace };
|
|
@@ -6,7 +6,6 @@ import { getAttributesString } from "../../data/attributes.js";
|
|
|
6
6
|
import { isWgslComparisonSampler, isWgslSampler } from "../../data/sampler.js";
|
|
7
7
|
import { accessModeMap, isWgslStorageTexture, isWgslTexture } from "../../data/texture.js";
|
|
8
8
|
import { isAttribute } from "../vertexLayout/connectAttributesToShader.js";
|
|
9
|
-
|
|
10
9
|
//#region src/core/resolve/resolveData.ts
|
|
11
10
|
/**
|
|
12
11
|
* Schemas for which their `type` property directly
|
|
@@ -141,6 +140,5 @@ function resolveData(ctx, data) {
|
|
|
141
140
|
if (isWgslComparisonSampler(data) || isWgslSampler(data)) return data.type;
|
|
142
141
|
assertExhaustive(data, "resolveData");
|
|
143
142
|
}
|
|
144
|
-
|
|
145
143
|
//#endregion
|
|
146
|
-
export { resolveData };
|
|
144
|
+
export { resolveData };
|
package/core/resolve/stitch.js
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { isSnippet } from "../../data/snippet.js";
|
|
2
2
|
import { getResolutionCtx } from "../../execMode.js";
|
|
3
|
-
|
|
4
3
|
//#region src/core/resolve/stitch.ts
|
|
5
4
|
/**
|
|
6
5
|
* "The reverse of snipping"
|
|
@@ -20,6 +19,5 @@ function stitch(strings, ...snippets) {
|
|
|
20
19
|
}
|
|
21
20
|
return result;
|
|
22
21
|
}
|
|
23
|
-
|
|
24
22
|
//#endregion
|
|
25
|
-
export { stitch };
|
|
23
|
+
export { stitch };
|
|
@@ -29,10 +29,12 @@ interface TgpuResolveOptions {
|
|
|
29
29
|
*/
|
|
30
30
|
enableExtensions?: WgslExtension[] | undefined;
|
|
31
31
|
/**
|
|
32
|
+
* **NOTE: This is an unstable API and may change in the future.**
|
|
33
|
+
*
|
|
32
34
|
* A custom shader code generator, used when resolving TypeGPU functions.
|
|
33
35
|
* If not provided, the default WGSL generator will be used.
|
|
34
36
|
*/
|
|
35
|
-
|
|
37
|
+
unstable_shaderGenerator?: ShaderGenerator | undefined;
|
|
36
38
|
}
|
|
37
39
|
interface TgpuExtendedResolveOptions extends TgpuResolveOptions {
|
|
38
40
|
/**
|
|
@@ -6,7 +6,6 @@ import { namespace } from "./namespace.js";
|
|
|
6
6
|
import { isBindGroupLayout } from "../../tgpuBindGroupLayout.js";
|
|
7
7
|
import { resolve as resolve$1 } from "../../resolutionCtx.js";
|
|
8
8
|
import { isPipeline } from "../pipeline/typeGuards.js";
|
|
9
|
-
|
|
10
9
|
//#region src/core/resolve/tgpuResolve.ts
|
|
11
10
|
function resolveWithContext(arg0, options) {
|
|
12
11
|
if (Array.isArray(arg0)) return resolveFromArray(arg0, options);
|
|
@@ -17,7 +16,7 @@ function resolve(arg, options) {
|
|
|
17
16
|
return resolveWithContext(arg).code;
|
|
18
17
|
}
|
|
19
18
|
function resolveFromTemplate(options) {
|
|
20
|
-
const { template, externals, shaderGenerator, names = "strict", config, enableExtensions } = options;
|
|
19
|
+
const { template, externals, unstable_shaderGenerator: shaderGenerator, names = "strict", config, enableExtensions } = options;
|
|
21
20
|
if (!template) console.warn("Calling resolve with an empty template is deprecated and will soon return an empty string. Consider using the 'tgpu.resolve(resolvableArray, options)' API instead.");
|
|
22
21
|
const dependencies = {};
|
|
23
22
|
applyExternals(dependencies, externals ?? {});
|
|
@@ -36,7 +35,7 @@ function resolveFromTemplate(options) {
|
|
|
36
35
|
});
|
|
37
36
|
}
|
|
38
37
|
function resolveFromArray(items, options) {
|
|
39
|
-
const { shaderGenerator, names = "strict", config, enableExtensions } = options ?? {};
|
|
38
|
+
const { unstable_shaderGenerator: shaderGenerator, names = "strict", config, enableExtensions } = options ?? {};
|
|
40
39
|
return resolve$1({
|
|
41
40
|
[$internal]: true,
|
|
42
41
|
[$resolve](ctx) {
|
|
@@ -63,6 +62,5 @@ function tryFindRoot(items) {
|
|
|
63
62
|
if (pipelines.length > 1) throw new Error(`Found ${pipelines.length} pipelines but can only resolve one at a time.`);
|
|
64
63
|
return pipelines[0]?.[$internal].root;
|
|
65
64
|
}
|
|
66
|
-
|
|
67
65
|
//#endregion
|
|
68
|
-
export { resolve, resolveWithContext };
|
|
66
|
+
export { resolve, resolveWithContext };
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { isAccessor, isMutableAccessor } from "../slot/slotTypes.js";
|
|
2
|
-
|
|
3
2
|
//#region src/core/root/configurableImpl.ts
|
|
4
3
|
var ConfigurableImpl = class ConfigurableImpl {
|
|
4
|
+
bindings;
|
|
5
5
|
constructor(bindings) {
|
|
6
6
|
this.bindings = bindings;
|
|
7
7
|
}
|
|
@@ -13,6 +13,5 @@ var ConfigurableImpl = class ConfigurableImpl {
|
|
|
13
13
|
return new ConfigurableImpl([...this.bindings, ...newCfg.bindings]);
|
|
14
14
|
}
|
|
15
15
|
};
|
|
16
|
-
|
|
17
16
|
//#endregion
|
|
18
|
-
export { ConfigurableImpl };
|
|
17
|
+
export { ConfigurableImpl };
|
package/core/root/init.d.ts
CHANGED
|
@@ -1,11 +1,6 @@
|
|
|
1
|
-
import "../buffer/bufferShorthand.js";
|
|
2
1
|
import { LogGeneratorOptions } from "../../tgsl/consoleLog/types.js";
|
|
3
|
-
import "../pipeline/computePipeline.js";
|
|
4
|
-
import "../../tgpuBindGroupLayout.js";
|
|
5
2
|
import { ShaderGenerator } from "../../tgsl/shaderGenerator.js";
|
|
6
3
|
import { TgpuRoot } from "./rootTypes.js";
|
|
7
|
-
import "../../data/wgslTypes.js";
|
|
8
|
-
|
|
9
4
|
//#region src/core/root/init.d.ts
|
|
10
5
|
/**
|
|
11
6
|
* Options passed into {@link init}.
|
package/core/root/init.js
CHANGED
|
@@ -23,7 +23,6 @@ import { INTERNAL_createComputePipeline } from "../pipeline/computePipeline.js";
|
|
|
23
23
|
import { isVertexLayout } from "../vertexLayout/vertexLayout.js";
|
|
24
24
|
import { INTERNAL_createRenderPipeline } from "../pipeline/renderPipeline.js";
|
|
25
25
|
import { allEq } from "../../std/boolean.js";
|
|
26
|
-
|
|
27
26
|
//#region src/core/root/init.ts
|
|
28
27
|
/**
|
|
29
28
|
* Changes the given array to a vec of 3 numbers, filling missing values with 1.
|
|
@@ -51,8 +50,8 @@ var TgpuGuardedComputePipelineImpl = class TgpuGuardedComputePipelineImpl {
|
|
|
51
50
|
this.#workgroupSize = workgroupSize;
|
|
52
51
|
this.#lastSize = vec3u();
|
|
53
52
|
}
|
|
54
|
-
with(
|
|
55
|
-
return new TgpuGuardedComputePipelineImpl(this.#root, this.#pipeline.with(
|
|
53
|
+
with(bindGroupOrEncoder) {
|
|
54
|
+
return new TgpuGuardedComputePipelineImpl(this.#root, this.#pipeline.with(bindGroupOrEncoder), this.#sizeUniform, this.#workgroupSize);
|
|
56
55
|
}
|
|
57
56
|
dispatchThreads(...threads) {
|
|
58
57
|
const sanitizedSize = toVec3(threads);
|
|
@@ -79,28 +78,30 @@ var TgpuGuardedComputePipelineImpl = class TgpuGuardedComputePipelineImpl {
|
|
|
79
78
|
}
|
|
80
79
|
};
|
|
81
80
|
var WithBindingImpl = class WithBindingImpl {
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
81
|
+
#getRoot;
|
|
82
|
+
#slotBindings;
|
|
83
|
+
constructor(getRoot, slotBindings) {
|
|
84
|
+
this.#getRoot = getRoot;
|
|
85
|
+
this.#slotBindings = slotBindings;
|
|
85
86
|
}
|
|
86
87
|
with(slot, value) {
|
|
87
|
-
return new WithBindingImpl(this
|
|
88
|
+
return new WithBindingImpl(this.#getRoot, [...this.#slotBindings, [isAccessor(slot) || isMutableAccessor(slot) ? slot.slot : slot, value]]);
|
|
88
89
|
}
|
|
89
90
|
withCompute(entryFn) {
|
|
90
|
-
return new WithComputeImpl(this
|
|
91
|
+
return new WithComputeImpl(this.#getRoot(), this.#slotBindings, entryFn);
|
|
91
92
|
}
|
|
92
93
|
createComputePipeline(descriptor) {
|
|
93
|
-
return INTERNAL_createComputePipeline(this
|
|
94
|
+
return INTERNAL_createComputePipeline(this.#getRoot(), this.#slotBindings, descriptor);
|
|
94
95
|
}
|
|
95
96
|
createRenderPipeline(descriptor) {
|
|
96
97
|
return INTERNAL_createRenderPipeline({
|
|
97
|
-
root: this
|
|
98
|
-
slotBindings: this
|
|
98
|
+
root: this.#getRoot(),
|
|
99
|
+
slotBindings: this.#slotBindings,
|
|
99
100
|
descriptor
|
|
100
101
|
});
|
|
101
102
|
}
|
|
102
103
|
createGuardedComputePipeline(callback) {
|
|
103
|
-
const root = this
|
|
104
|
+
const root = this.#getRoot();
|
|
104
105
|
if (callback.length >= 4) throw new Error("Guarded compute callback only supports up to three dimensions.");
|
|
105
106
|
const workgroupSize = workgroupSizeConfigs[callback.length];
|
|
106
107
|
const wrappedCallback = fn([
|
|
@@ -124,24 +125,27 @@ var WithBindingImpl = class WithBindingImpl {
|
|
|
124
125
|
return new TgpuGuardedComputePipelineImpl(root, this.createComputePipeline({ compute: mainCompute }), sizeUniform, workgroupSize);
|
|
125
126
|
}
|
|
126
127
|
withVertex(entryFn, attribs) {
|
|
127
|
-
return new WithVertexImpl(this
|
|
128
|
+
return new WithVertexImpl(this.#getRoot(), this.#slotBindings, {
|
|
128
129
|
vertex: entryFn,
|
|
129
130
|
attribs
|
|
130
131
|
});
|
|
131
132
|
}
|
|
132
133
|
pipe(transform) {
|
|
133
134
|
const newCfg = transform(new ConfigurableImpl([]));
|
|
134
|
-
return new WithBindingImpl(this
|
|
135
|
+
return new WithBindingImpl(this.#getRoot, [...this.#slotBindings, ...newCfg.bindings]);
|
|
135
136
|
}
|
|
136
137
|
};
|
|
137
138
|
var WithComputeImpl = class {
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
139
|
+
#root;
|
|
140
|
+
#slotBindings;
|
|
141
|
+
#entryFn;
|
|
142
|
+
constructor(root, slotBindings, entryFn) {
|
|
143
|
+
this.#root = root;
|
|
144
|
+
this.#slotBindings = slotBindings;
|
|
145
|
+
this.#entryFn = entryFn;
|
|
142
146
|
}
|
|
143
147
|
createPipeline() {
|
|
144
|
-
return INTERNAL_createComputePipeline(this
|
|
148
|
+
return INTERNAL_createComputePipeline(this.#root, this.#slotBindings, { compute: this.#entryFn });
|
|
145
149
|
}
|
|
146
150
|
};
|
|
147
151
|
var WithVertexImpl = class WithVertexImpl {
|
|
@@ -229,14 +233,18 @@ var WithFragmentImpl = class WithFragmentImpl {
|
|
|
229
233
|
*/
|
|
230
234
|
var TgpuRootImpl = class extends WithBindingImpl {
|
|
231
235
|
"~unstable";
|
|
232
|
-
|
|
233
|
-
|
|
236
|
+
device;
|
|
237
|
+
nameRegistrySetting;
|
|
238
|
+
shaderGenerator;
|
|
239
|
+
#unwrappedBindGroupLayouts = new WeakMemo((key) => key.unwrap(this));
|
|
240
|
+
#unwrappedBindGroups = new WeakMemo((key) => key.unwrap(this));
|
|
241
|
+
#ownDevice;
|
|
234
242
|
[$internal];
|
|
235
|
-
constructor(device, nameRegistrySetting,
|
|
243
|
+
constructor(device, nameRegistrySetting, ownDevice, logOptions, shaderGenerator) {
|
|
236
244
|
super(() => this, []);
|
|
237
245
|
this.device = device;
|
|
238
246
|
this.nameRegistrySetting = nameRegistrySetting;
|
|
239
|
-
this
|
|
247
|
+
this.#ownDevice = ownDevice;
|
|
240
248
|
this.shaderGenerator = shaderGenerator;
|
|
241
249
|
this["~unstable"] = this;
|
|
242
250
|
this[$internal] = { logOptions };
|
|
@@ -274,7 +282,7 @@ var TgpuRootImpl = class extends WithBindingImpl {
|
|
|
274
282
|
}
|
|
275
283
|
destroy() {
|
|
276
284
|
clearTextureUtilsCache(this.device);
|
|
277
|
-
if (this
|
|
285
|
+
if (this.#ownDevice) this.device.destroy();
|
|
278
286
|
}
|
|
279
287
|
createTexture(props) {
|
|
280
288
|
return INTERNAL_createTexture(props, this);
|
|
@@ -288,8 +296,8 @@ var TgpuRootImpl = class extends WithBindingImpl {
|
|
|
288
296
|
unwrap(resource) {
|
|
289
297
|
if (isComputePipeline(resource)) return resource[$internal].rawPipeline;
|
|
290
298
|
if (isRenderPipeline(resource)) return resource[$internal].core.unwrap().pipeline;
|
|
291
|
-
if (isBindGroupLayout(resource)) return this.
|
|
292
|
-
if (isBindGroup(resource)) return this.
|
|
299
|
+
if (isBindGroupLayout(resource)) return this.#unwrappedBindGroupLayouts.getOrMake(resource);
|
|
300
|
+
if (isBindGroup(resource)) return this.#unwrappedBindGroups.getOrMake(resource);
|
|
293
301
|
if (isBuffer(resource)) return resource.buffer;
|
|
294
302
|
if (isTexture(resource)) return resource[$internal].unwrap();
|
|
295
303
|
if (isTextureView(resource)) {
|
|
@@ -452,6 +460,5 @@ function initFromDevice(options) {
|
|
|
452
460
|
const { device, unstable_names: names = "strict", unstable_logOptions } = options ?? {};
|
|
453
461
|
return new TgpuRootImpl(device, names, false, unstable_logOptions ?? {}, options?.shaderGenerator);
|
|
454
462
|
}
|
|
455
|
-
|
|
456
463
|
//#endregion
|
|
457
|
-
export { init, initFromDevice };
|
|
464
|
+
export { init, initFromDevice };
|
package/core/root/rootTypes.d.ts
CHANGED
|
@@ -24,7 +24,7 @@ import { ShaderGenerator } from "../../tgsl/shaderGenerator.js";
|
|
|
24
24
|
import { TgpuBuffer, VertexFlag } from "../buffer/buffer.js";
|
|
25
25
|
import { AnyWgslData, BaseData, U16, U32, Vec3u, Void, WgslArray, v4f } from "../../data/wgslTypes.js";
|
|
26
26
|
import { TgpuTexture } from "../texture/texture.js";
|
|
27
|
-
import { ExtractInvalidSchemaError,
|
|
27
|
+
import { ExtractInvalidSchemaError, InferGPURecord, InferInput, IsValidBufferSchema, IsValidStorageSchema, IsValidUniformSchema } from "../../shared/repr.js";
|
|
28
28
|
import { AnyData, Disarray, UndecorateRecord } from "../../data/dataTypes.js";
|
|
29
29
|
|
|
30
30
|
//#region src/core/root/rootTypes.d.ts
|
|
@@ -34,6 +34,12 @@ interface TgpuGuardedComputePipeline<TArgs extends number[] = number[]> extends
|
|
|
34
34
|
* Analogous to `TgpuComputePipeline.with(bindGroup)`.
|
|
35
35
|
*/
|
|
36
36
|
with(bindGroup: TgpuBindGroup): TgpuGuardedComputePipeline<TArgs>;
|
|
37
|
+
/**
|
|
38
|
+
* Returns a pipeline wrapper that encodes dispatches into the provided
|
|
39
|
+
* command encoder instead of submitting them immediately.
|
|
40
|
+
* Analogous to `TgpuComputePipeline.with(encoder)`.
|
|
41
|
+
*/
|
|
42
|
+
with(encoder: GPUCommandEncoder): TgpuGuardedComputePipeline<TArgs>;
|
|
37
43
|
/**
|
|
38
44
|
* Dispatches the pipeline.
|
|
39
45
|
* Unlike `TgpuComputePipeline.dispatchWorkgroups()`, this method takes in the
|
|
@@ -469,7 +475,9 @@ interface TgpuRoot extends Unwrapper, WithBinding {
|
|
|
469
475
|
* @param typeSchema The type of data that this buffer will hold.
|
|
470
476
|
* @param initial The initial value of the buffer. (optional)
|
|
471
477
|
*/
|
|
472
|
-
createBuffer<TData extends AnyData>(typeSchema: ValidateBufferSchema<TData>,
|
|
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
|
+
createBuffer<TData extends AnyData>(typeSchema: ValidateBufferSchema<TData>, initial?: ((buffer: TgpuBuffer<NoInfer<TData>>) => void) | InferInput<NoInfer<TData>>): TgpuBuffer<TData>;
|
|
473
481
|
/**
|
|
474
482
|
* Allocates memory on the GPU, allows passing data between host and shader.
|
|
475
483
|
*
|
|
@@ -488,7 +496,9 @@ interface TgpuRoot extends Unwrapper, WithBinding {
|
|
|
488
496
|
* @param typeSchema The type of data that this buffer will hold.
|
|
489
497
|
* @param initial The initial value of the buffer. (optional)
|
|
490
498
|
*/
|
|
491
|
-
createUniform<TData extends AnyWgslData>(typeSchema: ValidateUniformSchema<TData>,
|
|
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
|
+
createUniform<TData extends AnyWgslData>(typeSchema: ValidateUniformSchema<TData>, initial?: ((buffer: TgpuBuffer<NoInfer<TData>>) => void) | InferInput<NoInfer<TData>>): TgpuUniform<TData>;
|
|
492
502
|
/**
|
|
493
503
|
* Allocates memory on the GPU, allows passing data between host and shader.
|
|
494
504
|
* Read-only on the GPU, optimized for small data. For a general-purpose buffer,
|
|
@@ -506,7 +516,9 @@ interface TgpuRoot extends Unwrapper, WithBinding {
|
|
|
506
516
|
* @param typeSchema The type of data that this buffer will hold.
|
|
507
517
|
* @param initial The initial value of the buffer. (optional)
|
|
508
518
|
*/
|
|
509
|
-
createMutable<TData extends AnyWgslData>(typeSchema: ValidateStorageSchema<TData>,
|
|
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
|
+
createMutable<TData extends AnyWgslData>(typeSchema: ValidateStorageSchema<TData>, initial?: ((buffer: TgpuBuffer<NoInfer<TData>>) => void) | InferInput<NoInfer<TData>>): TgpuMutable<TData>;
|
|
510
522
|
/**
|
|
511
523
|
* Allocates memory on the GPU, allows passing data between host and shader.
|
|
512
524
|
* Can be mutated in-place on the GPU. For a general-purpose buffer,
|
|
@@ -524,7 +536,9 @@ interface TgpuRoot extends Unwrapper, WithBinding {
|
|
|
524
536
|
* @param typeSchema The type of data that this buffer will hold.
|
|
525
537
|
* @param initial The initial value of the buffer. (optional)
|
|
526
538
|
*/
|
|
527
|
-
createReadonly<TData extends AnyWgslData>(typeSchema: ValidateStorageSchema<TData>,
|
|
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
|
+
createReadonly<TData extends AnyWgslData>(typeSchema: ValidateStorageSchema<TData>, initial?: ((buffer: TgpuBuffer<NoInfer<TData>>) => void) | InferInput<NoInfer<TData>>): TgpuReadonly<TData>;
|
|
528
542
|
/**
|
|
529
543
|
* Allocates memory on the GPU, allows passing data between host and shader.
|
|
530
544
|
* Read-only on the GPU, optimized for large data. For a general-purpose buffer,
|
|
@@ -534,6 +548,9 @@ interface TgpuRoot extends Unwrapper, WithBinding {
|
|
|
534
548
|
* @param gpuBuffer A vanilla WebGPU buffer.
|
|
535
549
|
*/
|
|
536
550
|
createReadonly<TData extends AnyWgslData>(typeSchema: ValidateStorageSchema<TData>, gpuBuffer: GPUBuffer): TgpuReadonly<TData>;
|
|
551
|
+
createTexture<TWidth extends number, THeight extends number, TDepth extends number, TSize extends readonly [TWidth] | readonly [TWidth, THeight] | readonly [TWidth, THeight, TDepth], TFormat extends GPUTextureFormat, TMipLevelCount extends number, TSampleCount extends number, TViewFormats extends GPUTextureFormat[], TDimension extends GPUTextureDimension>(props: CreateTextureOptions<TSize, TFormat, TMipLevelCount, TSampleCount, TViewFormats, TDimension>): TgpuTexture<CreateTextureResult<TSize, TFormat, TMipLevelCount, TSampleCount, TViewFormats, TDimension>>;
|
|
552
|
+
createSampler(props: WgslSamplerProps): TgpuFixedSampler;
|
|
553
|
+
createComparisonSampler(props: WgslComparisonSamplerProps): TgpuFixedComparisonSampler;
|
|
537
554
|
/**
|
|
538
555
|
* Creates a query set for collecting timestamps or occlusion queries.
|
|
539
556
|
*
|
|
@@ -586,6 +603,7 @@ interface TgpuRoot extends Unwrapper, WithBinding {
|
|
|
586
603
|
interface ExperimentalTgpuRoot extends Omit<TgpuRoot, 'with'>, Withable_Deprecated<WithBinding> {
|
|
587
604
|
readonly nameRegistrySetting: 'strict' | 'random';
|
|
588
605
|
readonly shaderGenerator?: ShaderGenerator | undefined;
|
|
606
|
+
/** @deprecated Use `root.createTexture` instead. */
|
|
589
607
|
createTexture<TWidth extends number, THeight extends number, TDepth extends number, TSize extends readonly [TWidth] | readonly [TWidth, THeight] | readonly [TWidth, THeight, TDepth], TFormat extends GPUTextureFormat, TMipLevelCount extends number, TSampleCount extends number, TViewFormats extends GPUTextureFormat[], TDimension extends GPUTextureDimension>(props: CreateTextureOptions<TSize, TFormat, TMipLevelCount, TSampleCount, TViewFormats, TDimension>): TgpuTexture<CreateTextureResult<TSize, TFormat, TMipLevelCount, TSampleCount, TViewFormats, TDimension>>;
|
|
590
608
|
beginRenderPass(descriptor: GPURenderPassDescriptor, callback: (pass: RenderPass) => void): void;
|
|
591
609
|
/**
|
|
@@ -601,7 +619,9 @@ interface ExperimentalTgpuRoot extends Omit<TgpuRoot, 'with'>, Withable_Deprecat
|
|
|
601
619
|
* @param callback - A function that records draw commands into the bundle.
|
|
602
620
|
*/
|
|
603
621
|
beginRenderBundleEncoder(descriptor: GPURenderBundleEncoderDescriptor, callback: (pass: RenderBundleEncoderPass) => void): GPURenderBundle;
|
|
622
|
+
/** @deprecated Use `root.createSampler` instead. */
|
|
604
623
|
createSampler(props: WgslSamplerProps): TgpuFixedSampler;
|
|
624
|
+
/** @deprecated Use `root.createComparisonSampler` instead. */
|
|
605
625
|
createComparisonSampler(props: WgslComparisonSamplerProps): TgpuFixedComparisonSampler;
|
|
606
626
|
/**
|
|
607
627
|
* @deprecated Used to cause all commands enqueued by pipelines to be
|
|
@@ -1,10 +1,6 @@
|
|
|
1
1
|
import { TgpuNamable } from "../../shared/meta.js";
|
|
2
2
|
import { $gpuValueOf, $internal } from "../../shared/symbols.js";
|
|
3
3
|
import { WgslComparisonSampler, WgslSampler } from "../../data/sampler.js";
|
|
4
|
-
import "../../data/snippet.js";
|
|
5
|
-
import "../../unwrapper.js";
|
|
6
|
-
import "../../tgpuBindGroupLayout.js";
|
|
7
|
-
import "../../types.js";
|
|
8
4
|
import { Infer } from "../../shared/repr.js";
|
|
9
5
|
|
|
10
6
|
//#region src/core/sampler/sampler.d.ts
|