typegpu 0.11.1-rc.1 → 0.11.2
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 → rolldown_runtime.js} +4 -4
- package/builtin.js +3 -1
- package/common/fullScreenTriangle.d.ts +6 -1
- package/common/fullScreenTriangle.js +3 -1
- package/common/index.js +5 -3
- package/common/writeSoA.js +3 -1
- package/core/buffer/buffer.d.ts +3 -0
- package/core/buffer/buffer.js +5 -3
- package/core/buffer/bufferShorthand.d.ts +2 -0
- package/core/buffer/bufferShorthand.js +3 -1
- package/core/buffer/bufferUsage.d.ts +2 -0
- package/core/buffer/bufferUsage.js +3 -1
- package/core/constant/tgpuConstant.d.ts +2 -1
- package/core/constant/tgpuConstant.js +3 -1
- package/core/declare/tgpuDeclare.js +3 -1
- package/core/function/autoIO.d.ts +3 -0
- package/core/function/autoIO.js +3 -1
- package/core/function/comptime.js +3 -1
- package/core/function/createCallableSchema.js +3 -1
- package/core/function/dualImpl.js +3 -1
- package/core/function/entryInputRouter.js +3 -1
- package/core/function/extractArgs.js +2 -1
- package/core/function/fnCore.js +8 -6
- package/core/function/fnTypes.d.ts +2 -0
- package/core/function/ioSchema.d.ts +1 -0
- package/core/function/ioSchema.js +3 -1
- package/core/function/shelllessImpl.d.ts +1 -0
- package/core/function/shelllessImpl.js +3 -1
- package/core/function/templateUtils.js +2 -1
- package/core/function/tgpuComputeFn.d.ts +1 -0
- package/core/function/tgpuComputeFn.js +3 -1
- package/core/function/tgpuFn.d.ts +1 -0
- package/core/function/tgpuFn.js +16 -14
- package/core/function/tgpuFragmentFn.js +3 -1
- package/core/function/tgpuVertexFn.js +3 -1
- package/core/pipeline/applyPipelineState.js +3 -1
- package/core/pipeline/computePipeline.d.ts +4 -0
- package/core/pipeline/computePipeline.js +8 -6
- package/core/pipeline/connectAttachmentToShader.js +3 -1
- package/core/pipeline/connectTargetsToShader.js +3 -1
- package/core/pipeline/limitsOverflow.js +2 -1
- package/core/pipeline/pipelineUtils.js +6 -4
- package/core/pipeline/renderPipeline.js +21 -19
- package/core/pipeline/timeable.d.ts +2 -0
- package/core/pipeline/timeable.js +3 -1
- package/core/pipeline/typeGuards.js +3 -1
- package/core/querySet/querySet.d.ts +2 -0
- package/core/querySet/querySet.js +3 -1
- package/core/rawCodeSnippet/tgpuRawCodeSnippet.d.ts +1 -0
- package/core/rawCodeSnippet/tgpuRawCodeSnippet.js +3 -1
- package/core/resolve/externals.d.ts +3 -0
- package/core/resolve/externals.js +7 -5
- package/core/resolve/namespace.js +6 -4
- package/core/resolve/resolveData.js +3 -1
- package/core/resolve/stitch.js +3 -1
- package/core/resolve/tgpuResolve.js +7 -5
- package/core/root/configurableImpl.js +3 -1
- package/core/root/init.d.ts +10 -2
- package/core/root/init.js +4 -2
- package/core/root/rootTypes.d.ts +11 -11
- package/core/sampler/sampler.d.ts +4 -0
- package/core/sampler/sampler.js +3 -1
- package/core/simulate/tgpuSimulate.js +6 -4
- package/core/slot/accessor.d.ts +4 -0
- package/core/slot/accessor.js +3 -1
- package/core/slot/internalSlots.js +3 -1
- package/core/slot/lazy.js +3 -1
- package/core/slot/slot.js +3 -1
- package/core/slot/slotTypes.js +3 -1
- package/core/texture/externalTexture.d.ts +6 -0
- package/core/texture/externalTexture.js +3 -1
- package/core/texture/texture.d.ts +4 -0
- package/core/texture/texture.js +6 -4
- package/core/texture/textureFormats.js +3 -1
- package/core/texture/textureUtils.js +3 -1
- package/core/texture/usageExtension.js +3 -1
- package/core/unroll/tgpuUnroll.d.ts +3 -1
- package/core/unroll/tgpuUnroll.js +3 -1
- package/core/valueProxyUtils.js +7 -5
- package/core/variable/tgpuVariable.d.ts +3 -1
- package/core/variable/tgpuVariable.js +3 -1
- package/core/vertexLayout/connectAttributesToShader.js +3 -1
- package/core/vertexLayout/vertexAttribute.d.ts +1 -0
- package/core/vertexLayout/vertexLayout.js +7 -5
- package/data/alignIO.js +3 -1
- package/data/alignmentOf.d.ts +2 -0
- package/data/alignmentOf.js +3 -1
- package/data/array.js +3 -1
- package/data/atomic.d.ts +1 -0
- package/data/atomic.js +3 -1
- package/data/attributes.js +7 -5
- package/data/autoStruct.d.ts +3 -1
- package/data/autoStruct.js +3 -1
- package/data/compiledIO.js +39 -37
- package/data/dataIO.js +22 -20
- package/data/dataTypes.d.ts +9 -4
- package/data/dataTypes.js +3 -1
- package/data/deepEqual.d.ts +1 -0
- package/data/deepEqual.js +3 -1
- package/data/disarray.d.ts +3 -1
- package/data/disarray.js +3 -1
- package/data/getLongestContiguousPrefix.d.ts +2 -0
- package/data/getLongestContiguousPrefix.js +3 -1
- package/data/index.js +5 -6
- package/data/isContiguous.d.ts +2 -0
- package/data/isContiguous.js +3 -1
- package/data/matrix.d.ts +11 -8
- package/data/matrix.js +3 -1
- package/data/numberOps.js +2 -1
- package/data/numeric.d.ts +1 -0
- package/data/numeric.js +3 -1
- package/data/offsetUtils.d.ts +1 -0
- package/data/offsetUtils.js +3 -1
- package/data/offsets.js +5 -3
- package/data/partialIO.js +3 -1
- package/data/ptr.d.ts +1 -0
- package/data/ptr.js +3 -1
- package/data/ref.d.ts +3 -0
- package/data/ref.js +5 -3
- package/data/sampler.js +3 -1
- package/data/schemaCallWrapper.js +3 -1
- package/data/schemaMemoryLayout.js +3 -1
- package/data/sizeOf.d.ts +2 -0
- package/data/sizeOf.js +3 -1
- package/data/snippet.js +3 -1
- package/data/struct.d.ts +1 -0
- package/data/struct.js +3 -1
- package/data/texture.js +3 -1
- package/data/unstruct.d.ts +1 -0
- package/data/unstruct.js +3 -1
- package/data/vector.d.ts +1 -0
- package/data/vector.js +3 -1
- package/data/vectorImpl.js +3 -1
- package/data/vectorOps.js +3 -1
- package/data/vertexFormatData.js +3 -1
- package/data/wgslTypes.d.ts +2 -0
- package/data/wgslTypes.js +3 -1
- package/errors.d.ts +1 -0
- package/errors.js +3 -1
- package/execMode.js +3 -1
- package/extension.d.ts +1 -0
- package/extension.js +3 -1
- package/getGPUValue.js +3 -1
- package/index.js +3 -4
- package/indexNamedExports.d.ts +1 -0
- package/mathUtils.js +2 -1
- package/memo.js +2 -1
- package/nameRegistry.js +3 -1
- package/package.js +3 -2
- package/package.json +1 -1
- package/resolutionCtx.d.ts +11 -0
- package/resolutionCtx.js +6 -4
- package/shared/env.js +2 -1
- package/shared/generators.js +2 -1
- package/shared/meta.js +3 -1
- package/shared/repr.d.ts +1 -0
- package/shared/stringify.js +3 -1
- package/shared/symbols.js +42 -10
- package/shared/utilityTypes.js +2 -1
- package/shared/vertexFormat.js +2 -1
- package/std/array.d.ts +1 -1
- package/std/array.js +3 -1
- package/std/atomic.d.ts +12 -12
- package/std/atomic.js +3 -1
- package/std/bitcast.d.ts +2 -2
- package/std/bitcast.js +3 -1
- package/std/boolean.d.ts +15 -14
- package/std/boolean.js +3 -1
- package/std/derivative.d.ts +9 -9
- package/std/derivative.js +3 -1
- package/std/discard.d.ts +1 -1
- package/std/discard.js +3 -1
- package/std/extensions.d.ts +3 -1
- package/std/extensions.js +3 -1
- package/std/index.js +5 -3
- package/std/matrix.d.ts +6 -5
- package/std/matrix.js +3 -1
- package/std/numeric.d.ts +132 -78
- package/std/numeric.js +7 -5
- package/std/operators.d.ts +8 -8
- package/std/operators.js +7 -5
- package/std/packing.d.ts +5 -4
- package/std/packing.js +3 -1
- package/std/range.d.ts +3 -1
- package/std/range.js +3 -1
- package/std/subgroup.d.ts +21 -21
- package/std/subgroup.js +3 -1
- package/std/texture.d.ts +11 -11
- package/std/texture.js +9 -7
- package/tgpu.js +5 -3
- package/tgpuBindGroupLayout.d.ts +11 -7
- package/tgpuBindGroupLayout.js +3 -1
- package/tgpuUnstable.js +5 -3
- package/tgsl/accessIndex.js +3 -1
- package/tgsl/accessProp.js +3 -1
- package/tgsl/consoleLog/deserializers.js +3 -1
- package/tgsl/consoleLog/logGenerator.js +3 -1
- package/tgsl/consoleLog/serializers.js +3 -1
- package/tgsl/consoleLog/types.d.ts +3 -0
- package/tgsl/consoleLog/types.js +2 -1
- package/tgsl/conversion.js +3 -1
- package/tgsl/forOfUtils.js +3 -1
- package/tgsl/generationHelpers.d.ts +1 -0
- package/tgsl/generationHelpers.js +3 -1
- package/tgsl/math.js +3 -1
- package/tgsl/shaderGenerator.d.ts +2 -0
- package/tgsl/shaderGenerator_members.js +5 -3
- package/tgsl/shellless.js +3 -1
- package/tgsl/wgslGenerator.js +21 -18
- package/types.d.ts +0 -1
- package/types.js +3 -1
- package/wgslExtensions.js +2 -1
|
@@ -12,6 +12,7 @@ import { logDataFromGPU } from "../../tgsl/consoleLog/deserializers.js";
|
|
|
12
12
|
import { wgslExtensionToFeatureName, wgslExtensions } from "../../wgslExtensions.js";
|
|
13
13
|
import { resolveIndirectOffset } from "./pipelineUtils.js";
|
|
14
14
|
import { createWithPerformanceCallback, createWithTimestampWrites, setupTimestampWrites, triggerPerformanceCallback } from "./timeable.js";
|
|
15
|
+
|
|
15
16
|
//#region src/core/pipeline/computePipeline.ts
|
|
16
17
|
function INTERNAL_createComputePipeline(branch, slotBindings, descriptor) {
|
|
17
18
|
return new TgpuComputePipelineImpl(new ComputePipelineCore(branch, slotBindings, descriptor), {});
|
|
@@ -111,14 +112,14 @@ var TgpuComputePipelineImpl = class TgpuComputePipelineImpl {
|
|
|
111
112
|
return;
|
|
112
113
|
}
|
|
113
114
|
if (this.#priors.externalEncoder) {
|
|
114
|
-
const passDescriptor = {
|
|
115
|
+
const passDescriptor$1 = {
|
|
115
116
|
label: getName(this.#core) ?? "<unnamed>",
|
|
116
117
|
...setupTimestampWrites(this.#priors, root)
|
|
117
118
|
};
|
|
118
|
-
const pass = this.#priors.externalEncoder.beginComputePass(passDescriptor);
|
|
119
|
-
this._applyComputeState(pass);
|
|
120
|
-
dispatch(pass);
|
|
121
|
-
pass.end();
|
|
119
|
+
const pass$1 = this.#priors.externalEncoder.beginComputePass(passDescriptor$1);
|
|
120
|
+
this._applyComputeState(pass$1);
|
|
121
|
+
dispatch(pass$1);
|
|
122
|
+
pass$1.end();
|
|
122
123
|
return;
|
|
123
124
|
}
|
|
124
125
|
const memo = this.#core.unwrap();
|
|
@@ -223,5 +224,6 @@ var ComputePipelineCore = class {
|
|
|
223
224
|
return this._memo;
|
|
224
225
|
}
|
|
225
226
|
};
|
|
227
|
+
|
|
226
228
|
//#endregion
|
|
227
|
-
export { INTERNAL_createComputePipeline };
|
|
229
|
+
export { INTERNAL_createComputePipeline };
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { isWgslStruct } from "../../data/wgslTypes.js";
|
|
2
2
|
import { isBuiltin } from "../../data/attributes.js";
|
|
3
|
+
|
|
3
4
|
//#region src/core/pipeline/connectAttachmentToShader.ts
|
|
4
5
|
function isColorAttachment(value) {
|
|
5
6
|
return !!value?.view;
|
|
@@ -20,5 +21,6 @@ function connectAttachmentToShader(fragmentOut, attachment) {
|
|
|
20
21
|
if (!isColorAttachment(attachment)) throw new Error("Expected a single color attachment, not a record.");
|
|
21
22
|
return [attachment];
|
|
22
23
|
}
|
|
24
|
+
|
|
23
25
|
//#endregion
|
|
24
|
-
export { connectAttachmentToShader };
|
|
26
|
+
export { connectAttachmentToShader };
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { isVoid, isWgslStruct } from "../../data/wgslTypes.js";
|
|
2
2
|
import { isBuiltin } from "../../data/attributes.js";
|
|
3
|
+
|
|
3
4
|
//#region src/core/pipeline/connectTargetsToShader.ts
|
|
4
5
|
function connectTargetsToShader(fragmentOut, targets) {
|
|
5
6
|
let presentationFormat;
|
|
@@ -23,5 +24,6 @@ function connectTargetsToShader(fragmentOut, targets) {
|
|
|
23
24
|
format: singleTarget?.format ?? (presentationFormat ??= navigator.gpu.getPreferredCanvasFormat())
|
|
24
25
|
}];
|
|
25
26
|
}
|
|
27
|
+
|
|
26
28
|
//#endregion
|
|
27
|
-
export { connectTargetsToShader };
|
|
29
|
+
export { connectTargetsToShader };
|
|
@@ -8,5 +8,6 @@ function warnIfOverflow(layouts, limits) {
|
|
|
8
8
|
2. Increasing the limit when requesting a device or creating a root.`);
|
|
9
9
|
if (storage > limits.maxStorageBuffersPerShaderStage) console.warn(`Total number of storage buffers (${storage}) exceeds maxStorageBuffersPerShaderStage (${limits.maxStorageBuffersPerShaderStage}).`);
|
|
10
10
|
}
|
|
11
|
+
|
|
11
12
|
//#endregion
|
|
12
|
-
export { warnIfOverflow };
|
|
13
|
+
export { warnIfOverflow };
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { isGPUBuffer } from "../../types.js";
|
|
2
2
|
import { sizeOf } from "../../data/sizeOf.js";
|
|
3
3
|
import { memoryLayoutOf } from "../../data/offsetUtils.js";
|
|
4
|
+
|
|
4
5
|
//#region src/core/pipeline/pipelineUtils.ts
|
|
5
6
|
const IndirectOperationToRequiredData = {
|
|
6
7
|
dispatchWorkgroupsIndirect: "3 x u32",
|
|
@@ -13,9 +14,9 @@ function validateIndirectBufferSize(bufferSize, offset, requiredBytes, operation
|
|
|
13
14
|
}
|
|
14
15
|
function resolveIndirectOffset(indirectBuffer, start, requiredSize, operation) {
|
|
15
16
|
if (isGPUBuffer(indirectBuffer)) {
|
|
16
|
-
const offset = typeof start === "number" ? start : start?.offset ?? 0;
|
|
17
|
-
validateIndirectBufferSize(indirectBuffer.size, offset, requiredSize, operation);
|
|
18
|
-
return offset;
|
|
17
|
+
const offset$1 = typeof start === "number" ? start : start?.offset ?? 0;
|
|
18
|
+
validateIndirectBufferSize(indirectBuffer.size, offset$1, requiredSize, operation);
|
|
19
|
+
return offset$1;
|
|
19
20
|
}
|
|
20
21
|
const { offset, contiguous } = start ? typeof start === "number" ? {
|
|
21
22
|
offset: start,
|
|
@@ -25,5 +26,6 @@ function resolveIndirectOffset(indirectBuffer, start, requiredSize, operation) {
|
|
|
25
26
|
if (contiguous < requiredSize) console.warn(`${operation}: Starting at offset ${offset}, only ${contiguous} contiguous bytes are available before padding. '${operation}' requires ${requiredSize} bytes (${IndirectOperationToRequiredData[operation]}). Reading across padding may result in undefined behavior.`);
|
|
26
27
|
return offset;
|
|
27
28
|
}
|
|
29
|
+
|
|
28
30
|
//#endregion
|
|
29
|
-
export { resolveIndirectOffset };
|
|
31
|
+
export { resolveIndirectOffset };
|
|
@@ -22,6 +22,7 @@ import { AutoFragmentFn, AutoVertexFn } from "../function/autoIO.js";
|
|
|
22
22
|
import { isVertexLayout } from "../vertexLayout/vertexLayout.js";
|
|
23
23
|
import { connectAttachmentToShader } from "./connectAttachmentToShader.js";
|
|
24
24
|
import { connectTargetsToShader } from "./connectTargetsToShader.js";
|
|
25
|
+
|
|
25
26
|
//#region src/core/pipeline/renderPipeline.ts
|
|
26
27
|
const DRAW_INDIRECT_SIZE = 16;
|
|
27
28
|
const DRAW_INDEXED_INDIRECT_SIZE = 20;
|
|
@@ -212,10 +213,10 @@ var TgpuRenderPipelineImpl = class TgpuRenderPipelineImpl {
|
|
|
212
213
|
return;
|
|
213
214
|
}
|
|
214
215
|
if (internals.priors.externalEncoder) {
|
|
215
|
-
const pass = this._createRenderPass(internals.priors.externalEncoder);
|
|
216
|
-
this._applyRenderState(pass);
|
|
217
|
-
pass.draw(vertexCount, instanceCount, firstVertex, firstInstance);
|
|
218
|
-
pass.end();
|
|
216
|
+
const pass$1 = this._createRenderPass(internals.priors.externalEncoder);
|
|
217
|
+
this._applyRenderState(pass$1);
|
|
218
|
+
pass$1.draw(vertexCount, instanceCount, firstVertex, firstInstance);
|
|
219
|
+
pass$1.end();
|
|
219
220
|
return;
|
|
220
221
|
}
|
|
221
222
|
const { logResources } = internals.core.unwrap();
|
|
@@ -244,11 +245,11 @@ var TgpuRenderPipelineImpl = class TgpuRenderPipelineImpl {
|
|
|
244
245
|
return;
|
|
245
246
|
}
|
|
246
247
|
if (internals.priors.externalEncoder) {
|
|
247
|
-
const pass = this._createRenderPass(internals.priors.externalEncoder);
|
|
248
|
-
this._applyRenderState(pass);
|
|
249
|
-
this._setIndexBuffer(pass);
|
|
250
|
-
pass.drawIndexed(indexCount, instanceCount, firstIndex, baseVertex, firstInstance);
|
|
251
|
-
pass.end();
|
|
248
|
+
const pass$1 = this._createRenderPass(internals.priors.externalEncoder);
|
|
249
|
+
this._applyRenderState(pass$1);
|
|
250
|
+
this._setIndexBuffer(pass$1);
|
|
251
|
+
pass$1.drawIndexed(indexCount, instanceCount, firstIndex, baseVertex, firstInstance);
|
|
252
|
+
pass$1.end();
|
|
252
253
|
return;
|
|
253
254
|
}
|
|
254
255
|
const { logResources } = internals.core.unwrap();
|
|
@@ -279,10 +280,10 @@ var TgpuRenderPipelineImpl = class TgpuRenderPipelineImpl {
|
|
|
279
280
|
return;
|
|
280
281
|
}
|
|
281
282
|
if (internals.priors.externalEncoder) {
|
|
282
|
-
const pass = this._createRenderPass(internals.priors.externalEncoder);
|
|
283
|
-
this._applyRenderState(pass);
|
|
284
|
-
pass.drawIndirect(rawBuffer, offset);
|
|
285
|
-
pass.end();
|
|
283
|
+
const pass$1 = this._createRenderPass(internals.priors.externalEncoder);
|
|
284
|
+
this._applyRenderState(pass$1);
|
|
285
|
+
pass$1.drawIndirect(rawBuffer, offset);
|
|
286
|
+
pass$1.end();
|
|
286
287
|
return;
|
|
287
288
|
}
|
|
288
289
|
const { logResources } = internals.core.unwrap();
|
|
@@ -313,11 +314,11 @@ var TgpuRenderPipelineImpl = class TgpuRenderPipelineImpl {
|
|
|
313
314
|
return;
|
|
314
315
|
}
|
|
315
316
|
if (internals.priors.externalEncoder) {
|
|
316
|
-
const pass = this._createRenderPass(internals.priors.externalEncoder);
|
|
317
|
-
this._applyRenderState(pass);
|
|
318
|
-
this._setIndexBuffer(pass);
|
|
319
|
-
pass.drawIndexedIndirect(rawBuffer, offset);
|
|
320
|
-
pass.end();
|
|
317
|
+
const pass$1 = this._createRenderPass(internals.priors.externalEncoder);
|
|
318
|
+
this._applyRenderState(pass$1);
|
|
319
|
+
this._setIndexBuffer(pass$1);
|
|
320
|
+
pass$1.drawIndexedIndirect(rawBuffer, offset);
|
|
321
|
+
pass$1.end();
|
|
321
322
|
return;
|
|
322
323
|
}
|
|
323
324
|
const { logResources } = internals.core.unwrap();
|
|
@@ -485,5 +486,6 @@ function matchUpVaryingLocations(vertexOut = {}, fragmentIn = {}, vertexFnName,
|
|
|
485
486
|
function isGPUCanvasContext(value) {
|
|
486
487
|
return typeof value?.getCurrentTexture === "function";
|
|
487
488
|
}
|
|
489
|
+
|
|
488
490
|
//#endregion
|
|
489
|
-
export { INTERNAL_createRenderPipeline };
|
|
491
|
+
export { INTERNAL_createRenderPipeline };
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { $internal } from "../../shared/symbols.js";
|
|
2
2
|
import { isQuerySet } from "../querySet/querySet.js";
|
|
3
|
+
|
|
3
4
|
//#region src/core/pipeline/timeable.ts
|
|
4
5
|
function createWithPerformanceCallback(currentPriors, callback, querySet) {
|
|
5
6
|
if (!currentPriors.timestampWrites) return {
|
|
@@ -51,5 +52,6 @@ function triggerPerformanceCallback({ root, priors }) {
|
|
|
51
52
|
await callback(start, end);
|
|
52
53
|
});
|
|
53
54
|
}
|
|
55
|
+
|
|
54
56
|
//#endregion
|
|
55
|
-
export { createWithPerformanceCallback, createWithTimestampWrites, setupTimestampWrites, triggerPerformanceCallback };
|
|
57
|
+
export { createWithPerformanceCallback, createWithTimestampWrites, setupTimestampWrites, triggerPerformanceCallback };
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { $internal } from "../../shared/symbols.js";
|
|
2
|
+
|
|
2
3
|
//#region src/core/pipeline/typeGuards.ts
|
|
3
4
|
function isComputePipeline(value) {
|
|
4
5
|
const maybe = value;
|
|
@@ -23,5 +24,6 @@ function isGPURenderPassEncoder(value) {
|
|
|
23
24
|
function isGPURenderBundleEncoder(value) {
|
|
24
25
|
return !!value && typeof value === "object" && "draw" in value && "finish" in value && !("executeBundles" in value) && !("beginRenderPass" in value) && !("dispatchWorkgroups" in value);
|
|
25
26
|
}
|
|
27
|
+
|
|
26
28
|
//#endregion
|
|
27
|
-
export { isComputePipeline, isGPUCommandEncoder, isGPUComputePassEncoder, isGPURenderBundleEncoder, isGPURenderPassEncoder, isPipeline, isRenderPipeline };
|
|
29
|
+
export { isComputePipeline, isGPUCommandEncoder, isGPUComputePassEncoder, isGPURenderBundleEncoder, isGPURenderPassEncoder, isPipeline, isRenderPipeline };
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import { TgpuNamable } from "../../shared/meta.js";
|
|
2
2
|
import { $internal } from "../../shared/symbols.js";
|
|
3
|
+
import "../root/rootTypes.js";
|
|
4
|
+
|
|
3
5
|
//#region src/core/querySet/querySet.d.ts
|
|
4
6
|
interface TgpuQuerySet<T extends GPUQueryType> extends TgpuNamable {
|
|
5
7
|
readonly resourceType: 'query-set';
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { $internal } from "../../shared/symbols.js";
|
|
2
2
|
import { setName } from "../../shared/meta.js";
|
|
3
|
+
|
|
3
4
|
//#region src/core/querySet/querySet.ts
|
|
4
5
|
function INTERNAL_createQuerySet(group, type, count, rawQuerySet) {
|
|
5
6
|
return new TgpuQuerySetImpl(group, type, count, rawQuerySet);
|
|
@@ -100,5 +101,6 @@ var TgpuQuerySetImpl = class {
|
|
|
100
101
|
this.#readBuffer = this.#resolveBuffer = void 0;
|
|
101
102
|
}
|
|
102
103
|
};
|
|
104
|
+
|
|
103
105
|
//#endregion
|
|
104
|
-
export { INTERNAL_createQuerySet, isQuerySet };
|
|
106
|
+
export { INTERNAL_createQuerySet, isQuerySet };
|
|
@@ -5,6 +5,7 @@ import { InferGPU } from "../../shared/repr.js";
|
|
|
5
5
|
import { AnyData } from "../../data/dataTypes.js";
|
|
6
6
|
|
|
7
7
|
//#region src/core/rawCodeSnippet/tgpuRawCodeSnippet.d.ts
|
|
8
|
+
|
|
8
9
|
/**
|
|
9
10
|
* Extra declaration that will be included in final WGSL code
|
|
10
11
|
* when resolving objects that use it.
|
|
@@ -3,6 +3,7 @@ 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
|
+
|
|
6
7
|
//#region src/core/rawCodeSnippet/tgpuRawCodeSnippet.ts
|
|
7
8
|
/**
|
|
8
9
|
* An advanced API that creates a typed shader expression which
|
|
@@ -90,5 +91,6 @@ var TgpuRawCodeSnippetImpl = class {
|
|
|
90
91
|
return this.$;
|
|
91
92
|
}
|
|
92
93
|
};
|
|
94
|
+
|
|
93
95
|
//#endregion
|
|
94
|
-
export { rawCodeSnippet };
|
|
96
|
+
export { rawCodeSnippet };
|
|
@@ -2,6 +2,7 @@ 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
|
+
|
|
5
6
|
//#region src/core/resolve/externals.ts
|
|
6
7
|
/**
|
|
7
8
|
* Merges two external maps into one. If a key is present in both maps, the value from the new map is used.
|
|
@@ -15,17 +16,17 @@ function applyExternals(existing, newExternals) {
|
|
|
15
16
|
if (value && (typeof value === "object" || typeof value === "function") && getName(value) === void 0) setName(value, key);
|
|
16
17
|
}
|
|
17
18
|
}
|
|
18
|
-
function addArgTypesToExternals(implementation, argTypes, applyExternals) {
|
|
19
|
+
function addArgTypesToExternals(implementation, argTypes, applyExternals$1) {
|
|
19
20
|
const argTypeNames = [...implementation.matchAll(/:\s*(?<arg>.*?)\s*[,)]/g)].map((found) => found ? found[1] : void 0);
|
|
20
|
-
applyExternals(Object.fromEntries(argTypes.flatMap((argType, i) => {
|
|
21
|
+
applyExternals$1(Object.fromEntries(argTypes.flatMap((argType, i) => {
|
|
21
22
|
const argTypeName = argTypeNames ? argTypeNames[i] : void 0;
|
|
22
23
|
return isWgslStruct(argType) && argTypeName !== void 0 ? [[argTypeName, argType]] : [];
|
|
23
24
|
})));
|
|
24
25
|
}
|
|
25
|
-
function addReturnTypeToExternals(implementation, returnType, applyExternals) {
|
|
26
|
+
function addReturnTypeToExternals(implementation, returnType, applyExternals$1) {
|
|
26
27
|
const matched = implementation.match(/->\s(?<output>[\w\d_]+)\s{/);
|
|
27
28
|
const outputName = matched ? matched[1]?.trim() : void 0;
|
|
28
|
-
if (isWgslStruct(returnType) && outputName && !/\s/g.test(outputName)) applyExternals({ [outputName]: returnType });
|
|
29
|
+
if (isWgslStruct(returnType) && outputName && !/\s/g.test(outputName)) applyExternals$1({ [outputName]: returnType });
|
|
29
30
|
}
|
|
30
31
|
function identifierRegex(name) {
|
|
31
32
|
return new RegExp(`(?<![\\w\\$_.])${name.replaceAll(".", "\\.").replaceAll("$", "\\$")}(?![\\w\\$_])`, "g");
|
|
@@ -52,5 +53,6 @@ function replaceExternalsInWgsl(ctx, externalMap, wgsl) {
|
|
|
52
53
|
return acc;
|
|
53
54
|
}, wgsl);
|
|
54
55
|
}
|
|
56
|
+
|
|
55
57
|
//#endregion
|
|
56
|
-
export { addArgTypesToExternals, addReturnTypeToExternals, applyExternals, replaceExternalsInWgsl };
|
|
58
|
+
export { addArgTypesToExternals, addReturnTypeToExternals, applyExternals, replaceExternalsInWgsl };
|
|
@@ -2,6 +2,7 @@ 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
|
+
|
|
5
6
|
//#region src/core/resolve/namespace.ts
|
|
6
7
|
var NamespaceImpl = class {
|
|
7
8
|
[$internal];
|
|
@@ -23,9 +24,9 @@ var NamespaceImpl = class {
|
|
|
23
24
|
throw new Error(`Unsupported event: ${event}`);
|
|
24
25
|
}
|
|
25
26
|
};
|
|
26
|
-
function getUniqueName(namespace, resource) {
|
|
27
|
-
const name = namespace.nameRegistry.makeUnique(getName(resource), true);
|
|
28
|
-
for (const listener of namespace.listeners.name) listener({
|
|
27
|
+
function getUniqueName(namespace$1, resource) {
|
|
28
|
+
const name = namespace$1.nameRegistry.makeUnique(getName(resource), true);
|
|
29
|
+
for (const listener of namespace$1.listeners.name) listener({
|
|
29
30
|
target: resource,
|
|
30
31
|
name
|
|
31
32
|
});
|
|
@@ -35,5 +36,6 @@ function namespace(options) {
|
|
|
35
36
|
const { names = "strict" } = options ?? {};
|
|
36
37
|
return new NamespaceImpl(names === "strict" ? new StrictNameRegistry() : new RandomNameRegistry());
|
|
37
38
|
}
|
|
39
|
+
|
|
38
40
|
//#endregion
|
|
39
|
-
export { getUniqueName, namespace };
|
|
41
|
+
export { getUniqueName, namespace };
|
|
@@ -6,6 +6,7 @@ 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
|
+
|
|
9
10
|
//#region src/core/resolve/resolveData.ts
|
|
10
11
|
/**
|
|
11
12
|
* Schemas for which their `type` property directly
|
|
@@ -140,5 +141,6 @@ function resolveData(ctx, data) {
|
|
|
140
141
|
if (isWgslComparisonSampler(data) || isWgslSampler(data)) return data.type;
|
|
141
142
|
assertExhaustive(data, "resolveData");
|
|
142
143
|
}
|
|
144
|
+
|
|
143
145
|
//#endregion
|
|
144
|
-
export { resolveData };
|
|
146
|
+
export { resolveData };
|
package/core/resolve/stitch.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { isSnippet } from "../../data/snippet.js";
|
|
2
2
|
import { getResolutionCtx } from "../../execMode.js";
|
|
3
|
+
|
|
3
4
|
//#region src/core/resolve/stitch.ts
|
|
4
5
|
/**
|
|
5
6
|
* "The reverse of snipping"
|
|
@@ -19,5 +20,6 @@ function stitch(strings, ...snippets) {
|
|
|
19
20
|
}
|
|
20
21
|
return result;
|
|
21
22
|
}
|
|
23
|
+
|
|
22
24
|
//#endregion
|
|
23
|
-
export { stitch };
|
|
25
|
+
export { stitch };
|
|
@@ -4,14 +4,15 @@ import { snip } from "../../data/snippet.js";
|
|
|
4
4
|
import { applyExternals, replaceExternalsInWgsl } from "./externals.js";
|
|
5
5
|
import { namespace } from "./namespace.js";
|
|
6
6
|
import { isBindGroupLayout } from "../../tgpuBindGroupLayout.js";
|
|
7
|
-
import { resolve
|
|
7
|
+
import { resolve } from "../../resolutionCtx.js";
|
|
8
8
|
import { isPipeline } from "../pipeline/typeGuards.js";
|
|
9
|
+
|
|
9
10
|
//#region src/core/resolve/tgpuResolve.ts
|
|
10
11
|
function resolveWithContext(arg0, options) {
|
|
11
12
|
if (Array.isArray(arg0)) return resolveFromArray(arg0, options);
|
|
12
13
|
return resolveFromTemplate(arg0);
|
|
13
14
|
}
|
|
14
|
-
function resolve(arg, options) {
|
|
15
|
+
function resolve$1(arg, options) {
|
|
15
16
|
if (Array.isArray(arg)) return resolveWithContext(arg, options).code;
|
|
16
17
|
return resolveWithContext(arg).code;
|
|
17
18
|
}
|
|
@@ -20,7 +21,7 @@ function resolveFromTemplate(options) {
|
|
|
20
21
|
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.");
|
|
21
22
|
const dependencies = {};
|
|
22
23
|
applyExternals(dependencies, externals ?? {});
|
|
23
|
-
return resolve
|
|
24
|
+
return resolve({
|
|
24
25
|
[$internal]: true,
|
|
25
26
|
[$resolve](ctx) {
|
|
26
27
|
return snip(replaceExternalsInWgsl(ctx, dependencies, template ?? ""), Void, "runtime");
|
|
@@ -36,7 +37,7 @@ function resolveFromTemplate(options) {
|
|
|
36
37
|
}
|
|
37
38
|
function resolveFromArray(items, options) {
|
|
38
39
|
const { unstable_shaderGenerator: shaderGenerator, names = "strict", config, enableExtensions } = options ?? {};
|
|
39
|
-
return resolve
|
|
40
|
+
return resolve({
|
|
40
41
|
[$internal]: true,
|
|
41
42
|
[$resolve](ctx) {
|
|
42
43
|
for (const item of items) if (isBindGroupLayout(item)) for (const binding of Object.values(item[$internal].bound)) ctx.resolve(binding);
|
|
@@ -62,5 +63,6 @@ function tryFindRoot(items) {
|
|
|
62
63
|
if (pipelines.length > 1) throw new Error(`Found ${pipelines.length} pipelines but can only resolve one at a time.`);
|
|
63
64
|
return pipelines[0]?.[$internal].root;
|
|
64
65
|
}
|
|
66
|
+
|
|
65
67
|
//#endregion
|
|
66
|
-
export { resolve, resolveWithContext };
|
|
68
|
+
export { resolve$1 as resolve, resolveWithContext };
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { isAccessor, isMutableAccessor } from "../slot/slotTypes.js";
|
|
2
|
+
|
|
2
3
|
//#region src/core/root/configurableImpl.ts
|
|
3
4
|
var ConfigurableImpl = class ConfigurableImpl {
|
|
4
5
|
bindings;
|
|
@@ -13,5 +14,6 @@ var ConfigurableImpl = class ConfigurableImpl {
|
|
|
13
14
|
return new ConfigurableImpl([...this.bindings, ...newCfg.bindings]);
|
|
14
15
|
}
|
|
15
16
|
};
|
|
17
|
+
|
|
16
18
|
//#endregion
|
|
17
|
-
export { ConfigurableImpl };
|
|
19
|
+
export { ConfigurableImpl };
|
package/core/root/init.d.ts
CHANGED
|
@@ -1,7 +1,13 @@
|
|
|
1
|
+
import "../buffer/bufferShorthand.js";
|
|
1
2
|
import { LogGeneratorOptions } from "../../tgsl/consoleLog/types.js";
|
|
3
|
+
import "../pipeline/computePipeline.js";
|
|
4
|
+
import "../../tgpuBindGroupLayout.js";
|
|
2
5
|
import { ShaderGenerator } from "../../tgsl/shaderGenerator.js";
|
|
3
6
|
import { TgpuRoot } from "./rootTypes.js";
|
|
7
|
+
import "../../data/wgslTypes.js";
|
|
8
|
+
|
|
4
9
|
//#region src/core/root/init.d.ts
|
|
10
|
+
|
|
5
11
|
/**
|
|
6
12
|
* Options passed into {@link init}.
|
|
7
13
|
*/
|
|
@@ -9,7 +15,8 @@ type InitOptions = {
|
|
|
9
15
|
adapter?: GPURequestAdapterOptions | undefined;
|
|
10
16
|
device?: (GPUDeviceDescriptor & {
|
|
11
17
|
optionalFeatures?: Iterable<GPUFeatureName>;
|
|
12
|
-
}) | undefined;
|
|
18
|
+
}) | undefined;
|
|
19
|
+
/** @default 'random' */
|
|
13
20
|
unstable_names?: 'random' | 'strict' | undefined;
|
|
14
21
|
/**
|
|
15
22
|
* A custom shader code generator, used when resolving TypeGPU functions.
|
|
@@ -22,7 +29,8 @@ type InitOptions = {
|
|
|
22
29
|
* Options passed into {@link initFromDevice}.
|
|
23
30
|
*/
|
|
24
31
|
type InitFromDeviceOptions = {
|
|
25
|
-
device: GPUDevice;
|
|
32
|
+
device: GPUDevice;
|
|
33
|
+
/** @default 'random' */
|
|
26
34
|
unstable_names?: 'random' | 'strict' | undefined;
|
|
27
35
|
/**
|
|
28
36
|
* A custom shader code generator, used when resolving TypeGPU functions.
|
package/core/root/init.js
CHANGED
|
@@ -23,6 +23,7 @@ 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
|
+
|
|
26
27
|
//#region src/core/root/init.ts
|
|
27
28
|
/**
|
|
28
29
|
* Changes the given array to a vec of 3 numbers, filling missing values with 1.
|
|
@@ -122,7 +123,7 @@ var WithBindingImpl = class WithBindingImpl {
|
|
|
122
123
|
sizeUniform,
|
|
123
124
|
wrappedCallback
|
|
124
125
|
});
|
|
125
|
-
return new TgpuGuardedComputePipelineImpl(root, this.createComputePipeline({ compute: mainCompute }), sizeUniform, workgroupSize);
|
|
126
|
+
return new TgpuGuardedComputePipelineImpl(root, (() => this.createComputePipeline({ compute: mainCompute }))(), sizeUniform, workgroupSize);
|
|
126
127
|
}
|
|
127
128
|
withVertex(entryFn, attribs) {
|
|
128
129
|
return new WithVertexImpl(this.#getRoot(), this.#slotBindings, {
|
|
@@ -460,5 +461,6 @@ function initFromDevice(options) {
|
|
|
460
461
|
const { device, unstable_names: names = "strict", unstable_logOptions } = options ?? {};
|
|
461
462
|
return new TgpuRootImpl(device, names, false, unstable_logOptions ?? {}, options?.shaderGenerator);
|
|
462
463
|
}
|
|
464
|
+
|
|
463
465
|
//#endregion
|
|
464
|
-
export { init, initFromDevice };
|
|
466
|
+
export { init, initFromDevice };
|
package/core/root/rootTypes.d.ts
CHANGED
|
@@ -62,7 +62,7 @@ interface TgpuGuardedComputePipeline<TArgs extends number[] = number[]> extends
|
|
|
62
62
|
interface WithCompute {
|
|
63
63
|
createPipeline(): TgpuComputePipeline;
|
|
64
64
|
}
|
|
65
|
-
type OptionalArgs<T> = T extends Record<string, never> | undefined ? [] | [T] : [T];
|
|
65
|
+
type OptionalArgs<T$1> = T$1 extends Record<string, never> | undefined ? [] | [T$1] : [T$1];
|
|
66
66
|
/**
|
|
67
67
|
* TODO: Remove in favor of createRenderPipeline's validation
|
|
68
68
|
*/
|
|
@@ -100,9 +100,9 @@ interface WithFragment<Targets extends FragmentOutConstrained = FragmentOutConst
|
|
|
100
100
|
createPipeline(): TgpuRenderPipeline<Targets>;
|
|
101
101
|
}
|
|
102
102
|
interface Withable<TSelf> {
|
|
103
|
-
with<T>(slot: TgpuSlot<T>, value: Eventual<T>): TSelf;
|
|
104
|
-
with<T extends BaseData>(accessor: TgpuAccessor<T>, value: TgpuAccessor.In<NoInfer<T>>): TSelf;
|
|
105
|
-
with<T extends BaseData>(accessor: TgpuMutableAccessor<T>, value: TgpuMutableAccessor.In<NoInfer<T>>): TSelf;
|
|
103
|
+
with<T$1>(slot: TgpuSlot<T$1>, value: Eventual<T$1>): TSelf;
|
|
104
|
+
with<T$1 extends BaseData>(accessor: TgpuAccessor<T$1>, value: TgpuAccessor.In<NoInfer<T$1>>): TSelf;
|
|
105
|
+
with<T$1 extends BaseData>(accessor: TgpuMutableAccessor<T$1>, value: TgpuMutableAccessor.In<NoInfer<T$1>>): TSelf;
|
|
106
106
|
}
|
|
107
107
|
interface Withable_Deprecated<TSelf> {
|
|
108
108
|
/**
|
|
@@ -110,19 +110,19 @@ interface Withable_Deprecated<TSelf> {
|
|
|
110
110
|
* @param slot
|
|
111
111
|
* @param value
|
|
112
112
|
*/
|
|
113
|
-
with<T>(slot: TgpuSlot<T>, value: Eventual<T>): TSelf;
|
|
113
|
+
with<T$1>(slot: TgpuSlot<T$1>, value: Eventual<T$1>): TSelf;
|
|
114
114
|
/**
|
|
115
115
|
* @deprecated This feature is stable, remove the `['~unstable']`
|
|
116
116
|
* @param slot
|
|
117
117
|
* @param value
|
|
118
118
|
*/
|
|
119
|
-
with<T extends BaseData>(accessor: TgpuAccessor<T>, value: TgpuAccessor.In<NoInfer<T>>): TSelf;
|
|
119
|
+
with<T$1 extends BaseData>(accessor: TgpuAccessor<T$1>, value: TgpuAccessor.In<NoInfer<T$1>>): TSelf;
|
|
120
120
|
/**
|
|
121
121
|
* @deprecated This feature is stable, remove the `['~unstable']`
|
|
122
122
|
* @param slot
|
|
123
123
|
* @param value
|
|
124
124
|
*/
|
|
125
|
-
with<T extends BaseData>(accessor: TgpuMutableAccessor<T>, value: TgpuMutableAccessor.In<NoInfer<T>>): TSelf;
|
|
125
|
+
with<T$1 extends BaseData>(accessor: TgpuMutableAccessor<T$1>, value: TgpuMutableAccessor.In<NoInfer<T$1>>): TSelf;
|
|
126
126
|
}
|
|
127
127
|
interface Configurable extends Withable<Configurable> {
|
|
128
128
|
readonly bindings: [slot: TgpuSlot<unknown>, value: unknown][];
|
|
@@ -134,9 +134,9 @@ interface Configurable extends Withable<Configurable> {
|
|
|
134
134
|
* @example d.builtin.position => d.Void
|
|
135
135
|
* @example { a: d.v4f, $fragDepth: number } => { a: d.Vec4f }
|
|
136
136
|
*/
|
|
137
|
-
type NormalizeOutput<T> = T extends {
|
|
137
|
+
type NormalizeOutput<T$1> = T$1 extends {
|
|
138
138
|
readonly [$internal]: unknown;
|
|
139
|
-
} | number | boolean ? [OmitBuiltins<InstanceToSchema<T>>] extends [never] ? Void : OmitBuiltins<InstanceToSchema<T>> : { [K in keyof OmitBuiltins<T>]: InstanceToSchema<OmitBuiltins<T>[K]> };
|
|
139
|
+
} | number | boolean ? [OmitBuiltins<InstanceToSchema<T$1>>] extends [never] ? Void : OmitBuiltins<InstanceToSchema<T$1>> : { [K in keyof OmitBuiltins<T$1>]: InstanceToSchema<OmitBuiltins<T$1>[K]> };
|
|
140
140
|
interface WithBinding extends Withable<WithBinding> {
|
|
141
141
|
/** @deprecated Use `root.createComputePipeline` instead. */
|
|
142
142
|
withCompute<ComputeIn extends IORecord<AnyComputeBuiltin>>(entryFn: TgpuComputeFn<ComputeIn>): WithCompute;
|
|
@@ -241,7 +241,7 @@ type SrgbVariants = {
|
|
|
241
241
|
'astc-12x10-unorm': 'astc-12x10-unorm-srgb';
|
|
242
242
|
'astc-12x12-unorm': 'astc-12x12-unorm-srgb';
|
|
243
243
|
};
|
|
244
|
-
type SrgbVariantOrSelf<T extends GPUTextureFormat> = T extends keyof SrgbVariants ? (SrgbVariants[T] | T)[] | undefined : T extends `${infer Base}-srgb` ? Base extends keyof SrgbVariants ? (T | SrgbVariants[Base])[] | undefined : T[] | undefined : T[] | undefined;
|
|
244
|
+
type SrgbVariantOrSelf<T$1 extends GPUTextureFormat> = T$1 extends keyof SrgbVariants ? (SrgbVariants[T$1] | T$1)[] | undefined : T$1 extends `${infer Base}-srgb` ? Base extends keyof SrgbVariants ? (T$1 | SrgbVariants[Base])[] | undefined : T$1[] | undefined : T$1[] | undefined;
|
|
245
245
|
type CreateTextureOptions<TSize, TFormat extends GPUTextureFormat, TMipLevelCount extends number, TSampleCount extends number, TViewFormats extends GPUTextureFormat[], TDimension extends GPUTextureDimension> = {
|
|
246
246
|
/**
|
|
247
247
|
* The width, height, and depth or layer count of the texture.
|
|
@@ -561,7 +561,7 @@ interface TgpuRoot extends Unwrapper, WithBinding {
|
|
|
561
561
|
* @param count The number of queries in the set.
|
|
562
562
|
* @param rawQuerySet An optional pre-existing GPUQuerySet to use instead of creating a new one.
|
|
563
563
|
*/
|
|
564
|
-
createQuerySet<T extends GPUQueryType>(type: T, count: number, rawQuerySet?: GPUQuerySet): TgpuQuerySet<T>;
|
|
564
|
+
createQuerySet<T$1 extends GPUQueryType>(type: T$1, count: number, rawQuerySet?: GPUQuerySet): TgpuQuerySet<T$1>;
|
|
565
565
|
/**
|
|
566
566
|
* Creates a group of resources that can be bound to a shader based on a specified layout.
|
|
567
567
|
*
|
|
@@ -1,6 +1,10 @@
|
|
|
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";
|
|
4
8
|
import { Infer } from "../../shared/repr.js";
|
|
5
9
|
|
|
6
10
|
//#region src/core/sampler/sampler.d.ts
|
package/core/sampler/sampler.js
CHANGED
|
@@ -4,6 +4,7 @@ import { snip } from "../../data/snippet.js";
|
|
|
4
4
|
import { inCodegenMode } from "../../execMode.js";
|
|
5
5
|
import { valueProxyHandler } from "../valueProxyUtils.js";
|
|
6
6
|
import { comparisonSampler, sampler } from "../../data/sampler.js";
|
|
7
|
+
|
|
7
8
|
//#region src/core/sampler/sampler.ts
|
|
8
9
|
function INTERNAL_createSampler(props, branch) {
|
|
9
10
|
return new TgpuFixedSamplerImpl(sampler(), props, branch);
|
|
@@ -112,5 +113,6 @@ var TgpuFixedSamplerImpl = class {
|
|
|
112
113
|
return `${this.resourceType}:${getName(this) ?? "<unnamed>"}`;
|
|
113
114
|
}
|
|
114
115
|
};
|
|
116
|
+
|
|
115
117
|
//#endregion
|
|
116
|
-
export { INTERNAL_createComparisonSampler, INTERNAL_createSampler, TgpuLaidOutSamplerImpl, isComparisonSampler, isSampler };
|
|
118
|
+
export { INTERNAL_createComparisonSampler, INTERNAL_createSampler, TgpuLaidOutSamplerImpl, isComparisonSampler, isSampler };
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { SimulationState } from "../../types.js";
|
|
2
2
|
import { getResolutionCtx, provideCtx } from "../../execMode.js";
|
|
3
3
|
import { namespace } from "../resolve/namespace.js";
|
|
4
|
-
import
|
|
4
|
+
import wgslGenerator_default from "../../tgsl/wgslGenerator.js";
|
|
5
5
|
import { ResolutionCtxImpl } from "../../resolutionCtx.js";
|
|
6
|
+
|
|
6
7
|
//#region src/core/simulate/tgpuSimulate.ts
|
|
7
8
|
/**
|
|
8
9
|
* Runs the provided callback in a simulated environment, giving
|
|
@@ -29,7 +30,7 @@ import { ResolutionCtxImpl } from "../../resolutionCtx.js";
|
|
|
29
30
|
function simulate(callback) {
|
|
30
31
|
const ctx = getResolutionCtx() ?? new ResolutionCtxImpl({
|
|
31
32
|
namespace: namespace(),
|
|
32
|
-
shaderGenerator:
|
|
33
|
+
shaderGenerator: wgslGenerator_default
|
|
33
34
|
});
|
|
34
35
|
const workgroups = [
|
|
35
36
|
1,
|
|
@@ -49,7 +50,7 @@ function simulate(callback) {
|
|
|
49
50
|
const buffers = /* @__PURE__ */ new Map();
|
|
50
51
|
const workgroupVars = Array.from({ length: workgroups[0] }, () => Array.from({ length: workgroups[1] }, () => Array.from({ length: workgroups[2] }, () => /* @__PURE__ */ new Map())));
|
|
51
52
|
const privateVars = Array.from({ length: threads[0] }, () => Array.from({ length: threads[1] }, () => Array.from({ length: threads[2] }, () => /* @__PURE__ */ new Map())));
|
|
52
|
-
const simStates = Array.from({ length: threads[0] }, (_, i) => Array.from({ length: threads[1] }, (_, j) => Array.from({ length: threads[2] }, (_, k) => {
|
|
53
|
+
const simStates = Array.from({ length: threads[0] }, (_, i) => Array.from({ length: threads[1] }, (_$1, j) => Array.from({ length: threads[2] }, (_$2, k) => {
|
|
53
54
|
const wi = Math.floor(i / workgroupSize[0]);
|
|
54
55
|
const wj = Math.floor(j / workgroupSize[1]);
|
|
55
56
|
const wk = Math.floor(k / workgroupSize[2]);
|
|
@@ -70,5 +71,6 @@ function simulate(callback) {
|
|
|
70
71
|
ctx.popMode("simulate");
|
|
71
72
|
}
|
|
72
73
|
}
|
|
74
|
+
|
|
73
75
|
//#endregion
|
|
74
|
-
export { simulate };
|
|
76
|
+
export { simulate };
|