typegpu 0.10.2 → 0.11.0
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 +7 -7
- 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 +144 -81
- package/types.d.ts +14 -4
- package/types.js +3 -3
- package/wgslExtensions.js +1 -2
package/data/autoStruct.d.ts
CHANGED
package/data/autoStruct.js
CHANGED
|
@@ -2,7 +2,6 @@ import { $internal, $resolve } from "../shared/symbols.js";
|
|
|
2
2
|
import { getName, setName } from "../shared/meta.js";
|
|
3
3
|
import { isValidProp } from "../nameRegistry.js";
|
|
4
4
|
import { createIoSchema } from "../core/function/ioSchema.js";
|
|
5
|
-
|
|
6
5
|
//#region src/data/autoStruct.ts
|
|
7
6
|
/**
|
|
8
7
|
* A requirement for the generated struct is that non-builtin properties need to
|
|
@@ -78,6 +77,5 @@ var AutoStruct = class {
|
|
|
78
77
|
};
|
|
79
78
|
AutoStruct.prototype[$internal] = {};
|
|
80
79
|
AutoStruct.prototype.type = "auto-struct";
|
|
81
|
-
|
|
82
80
|
//#endregion
|
|
83
|
-
export { AutoStruct };
|
|
81
|
+
export { AutoStruct };
|
package/data/compiledIO.js
CHANGED
|
@@ -5,7 +5,6 @@ import { alignmentOf } from "./alignmentOf.js";
|
|
|
5
5
|
import { roundUp } from "../mathUtils.js";
|
|
6
6
|
import { sizeOf } from "./sizeOf.js";
|
|
7
7
|
import { offsetsForProps } from "./offsets.js";
|
|
8
|
-
|
|
9
8
|
//#region src/data/compiledIO.ts
|
|
10
9
|
const EVAL_ALLOWED_IN_ENV = (() => {
|
|
11
10
|
try {
|
|
@@ -115,117 +114,115 @@ const specialPackedFormats = {
|
|
|
115
114
|
"unorm8x4-bgra": {
|
|
116
115
|
writeFunction: "setUint8",
|
|
117
116
|
generator: (offsetExpr, valueExpr) => {
|
|
118
|
-
|
|
117
|
+
return [
|
|
119
118
|
"z",
|
|
120
119
|
"y",
|
|
121
120
|
"x",
|
|
122
121
|
"w"
|
|
123
|
-
];
|
|
124
|
-
let code = "";
|
|
125
|
-
for (let idx = 0; idx < 4; idx++) code += `output.setUint8((${offsetExpr} + ${idx}), Math.round(${valueExpr}.${bgraComponents[idx]} * 255), littleEndian);\n`;
|
|
126
|
-
return code;
|
|
122
|
+
].map((c, idx) => `output.setUint8((${offsetExpr} + ${idx}), Math.round(${valueExpr}.${c} * 255), littleEndian);\n`).join("");
|
|
127
123
|
}
|
|
128
124
|
}
|
|
129
125
|
};
|
|
130
|
-
function buildWriter(node, offsetExpr, valueExpr, depth = 0) {
|
|
131
|
-
const
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
126
|
+
function buildWriter(node, offsetExpr, valueExpr, depth = 0, partial = false) {
|
|
127
|
+
const emitWrite = (writeFunc, addr, value) => partial ? `if (${addr} < endOffset) { output.${writeFunc}(${addr}, ${value}, littleEndian); }\n` : `output.${writeFunc}(${addr}, ${value}, littleEndian);\n`;
|
|
128
|
+
const emitBlock = (addr, block) => partial ? `if (${addr} < endOffset) {\n${block}}\n` : block;
|
|
129
|
+
function go(node, offsetExpr, valueExpr, depth) {
|
|
130
|
+
const loopVar = [
|
|
131
|
+
"i",
|
|
132
|
+
"j",
|
|
133
|
+
"k"
|
|
134
|
+
][depth] || `i${depth}`;
|
|
135
|
+
if (isAtomic(node) || isDecorated(node)) return go(node.inner, offsetExpr, valueExpr, depth);
|
|
136
|
+
if (isWgslStruct(node) || isUnstruct(node)) return Object.entries(offsetsForProps(node)).map(([key, propOffset]) => {
|
|
141
137
|
const subSchema = node.propTypes[key];
|
|
142
|
-
|
|
143
|
-
|
|
138
|
+
return subSchema ? go(subSchema, `(${offsetExpr} + ${propOffset.offset})`, `${valueExpr}.${key}`, depth) : "";
|
|
139
|
+
}).join("");
|
|
140
|
+
if (isWgslArray(node) || isDisarray(node)) {
|
|
141
|
+
const elementSize = roundUp(sizeOf(node.elementType), alignmentOf(node));
|
|
142
|
+
const totalSize = node.elementCount * elementSize;
|
|
143
|
+
const copyLen = partial ? `Math.min(${valueExpr}.byteLength, Math.max(0, endOffset - (${offsetExpr})))` : `Math.min(${valueExpr}.byteLength, ${totalSize})`;
|
|
144
|
+
let code = `if (ArrayBuffer.isView(${valueExpr})) {\n`;
|
|
145
|
+
code += ` new Uint8Array(output.buffer).set(new Uint8Array(${valueExpr}.buffer, ${valueExpr}.byteOffset, ${copyLen}), output.byteOffset + (${offsetExpr}));\n`;
|
|
146
|
+
code += `} else {\n`;
|
|
147
|
+
code += `for (let ${loopVar} = 0; ${loopVar} < ${node.elementCount}; ${loopVar}++) {\n`;
|
|
148
|
+
if (partial) code += `if ((${offsetExpr} + ${loopVar} * ${elementSize}) >= endOffset) return;\n`;
|
|
149
|
+
code += go(node.elementType, `(${offsetExpr} + ${loopVar} * ${elementSize})`, `${valueExpr}[${loopVar}]`, depth + 1);
|
|
150
|
+
code += "}\n";
|
|
151
|
+
code += "}\n";
|
|
152
|
+
return code;
|
|
144
153
|
}
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
const primitive = typeToPrimitive[node.type];
|
|
158
|
-
let code = "";
|
|
159
|
-
const writeFunc = primitiveToWriteFunction[primitive];
|
|
160
|
-
const components = [
|
|
161
|
-
"x",
|
|
162
|
-
"y",
|
|
163
|
-
"z",
|
|
164
|
-
"w"
|
|
165
|
-
];
|
|
166
|
-
for (let i = 0; i < node.componentCount; i++) code += `output.${writeFunc}((${offsetExpr} + ${i * 4}), ${valueExpr}.${components[i]}, littleEndian);\n`;
|
|
167
|
-
return code;
|
|
168
|
-
}
|
|
169
|
-
if (isMat(node)) {
|
|
170
|
-
const writeFunc = primitiveToWriteFunction[typeToPrimitive[node.type]];
|
|
171
|
-
const matSize = isMat2x2f(node) ? 2 : isMat3x3f(node) ? 3 : 4;
|
|
172
|
-
const elementCount = matSize * matSize;
|
|
173
|
-
const rowStride = roundUp(matSize * 4, 8);
|
|
174
|
-
let code = "";
|
|
175
|
-
for (let idx = 0; idx < elementCount; idx++) {
|
|
176
|
-
const colIndex = Math.floor(idx / matSize);
|
|
177
|
-
const rowIndex = idx % matSize;
|
|
178
|
-
const byteOffset = colIndex * rowStride + rowIndex * 4;
|
|
179
|
-
code += `output.${writeFunc}((${offsetExpr} + ${byteOffset}), ${valueExpr}.columns[${colIndex}].${[
|
|
154
|
+
if (isVec(node)) {
|
|
155
|
+
if (isVecBool(node)) throw new Error("Compiled writers do not support boolean vectors");
|
|
156
|
+
const primitive = typeToPrimitive[node.type];
|
|
157
|
+
const componentSize = sizeOf(node.primitive);
|
|
158
|
+
const writeFunc = primitiveToWriteFunction[primitive];
|
|
159
|
+
return Array.from({ length: node.componentCount }, (_, i) => emitWrite(writeFunc, `(${offsetExpr} + ${i * componentSize})`, `${valueExpr}[${i}]`)).join("");
|
|
160
|
+
}
|
|
161
|
+
if (isMat(node)) {
|
|
162
|
+
const writeFunc = primitiveToWriteFunction[typeToPrimitive[node.type]];
|
|
163
|
+
const matSize = isMat2x2f(node) ? 2 : isMat3x3f(node) ? 3 : 4;
|
|
164
|
+
const rowStride = roundUp(matSize * 4, 8);
|
|
165
|
+
const components = [
|
|
180
166
|
"x",
|
|
181
167
|
"y",
|
|
182
168
|
"z",
|
|
183
169
|
"w"
|
|
184
|
-
]
|
|
170
|
+
];
|
|
171
|
+
const wgslElementStride = rowStride / 4;
|
|
172
|
+
return Array.from({ length: matSize * matSize }, (_, idx) => {
|
|
173
|
+
const col = Math.floor(idx / matSize);
|
|
174
|
+
const row = idx % matSize;
|
|
175
|
+
const packedIndex = col * matSize + row;
|
|
176
|
+
const wgslIndex = col * wgslElementStride + row;
|
|
177
|
+
return emitWrite(writeFunc, `(${offsetExpr} + ${col * rowStride + row * 4})`, `ArrayBuffer.isView(${valueExpr}) ? ${valueExpr}[${wgslIndex}] : Array.isArray(${valueExpr}) ? ${valueExpr}[${packedIndex}] : ${valueExpr}.columns[${col}].${components[row]}`);
|
|
178
|
+
}).join("");
|
|
185
179
|
}
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
180
|
+
if (isPackedData(node)) {
|
|
181
|
+
const formatName = node.type;
|
|
182
|
+
if (formatName in specialPackedFormats) {
|
|
183
|
+
const handler = specialPackedFormats[formatName];
|
|
184
|
+
return emitBlock(`(${offsetExpr})`, handler.generator(offsetExpr, valueExpr));
|
|
185
|
+
}
|
|
186
|
+
const primitive = vertexFormatToPrimitive[formatName];
|
|
187
|
+
const writeFunc = primitiveToWriteFunction[primitive];
|
|
188
|
+
const wgslType = formatToWGSLType[formatName];
|
|
189
|
+
const componentCount = isVec(wgslType) ? wgslType.componentCount : 1;
|
|
190
|
+
const componentSize = primitive === "u8" || primitive === "i8" ? 1 : primitive === "u16" || primitive === "i16" || primitive === "f16" ? 2 : 4;
|
|
191
|
+
const components = [
|
|
192
|
+
"x",
|
|
193
|
+
"y",
|
|
194
|
+
"z",
|
|
195
|
+
"w"
|
|
196
|
+
];
|
|
197
|
+
const transform = vertexFormatValueTransform[formatName];
|
|
198
|
+
return Array.from({ length: componentCount }, (_, idx) => {
|
|
199
|
+
const accessor = componentCount === 1 ? valueExpr : `${valueExpr}.${components[idx]}`;
|
|
200
|
+
const value = transform ? transform(accessor) : accessor;
|
|
201
|
+
return emitWrite(writeFunc, `(${offsetExpr} + ${idx * componentSize})`, value);
|
|
202
|
+
}).join("");
|
|
208
203
|
}
|
|
209
|
-
|
|
204
|
+
if (!Object.hasOwn(typeToPrimitive, node.type)) throw new Error(`Primitive ${node.type} is unsupported by compiled writer`);
|
|
205
|
+
const primitive = typeToPrimitive[node.type];
|
|
206
|
+
return emitWrite(primitiveToWriteFunction[primitive], offsetExpr, valueExpr);
|
|
210
207
|
}
|
|
211
|
-
|
|
212
|
-
return `output.${primitiveToWriteFunction[typeToPrimitive[node.type]]}(${offsetExpr}, ${valueExpr}, littleEndian);\n`;
|
|
208
|
+
return go(node, offsetExpr, valueExpr, depth);
|
|
213
209
|
}
|
|
214
|
-
function
|
|
210
|
+
function getCompiledWriter(schema) {
|
|
215
211
|
if (!EVAL_ALLOWED_IN_ENV) {
|
|
216
212
|
console.warn("This environment does not allow eval - using default writer as fallback");
|
|
217
213
|
return;
|
|
218
214
|
}
|
|
219
|
-
|
|
215
|
+
const cached = compiledWriters.get(schema);
|
|
216
|
+
if (cached) return cached;
|
|
220
217
|
try {
|
|
221
|
-
const
|
|
222
|
-
const
|
|
218
|
+
const fullBody = buildWriter(schema, "offset", "value", 0, false);
|
|
219
|
+
const body = `if (offset > 0 || endOffset < output.byteLength) {\n${buildWriter(schema, "offset", "value", 0, true)}} else {\n${fullBody}}\n`;
|
|
220
|
+
const fn = new Function("output", "offset", "value", "littleEndian=true", "endOffset=output.byteLength", body);
|
|
223
221
|
compiledWriters.set(schema, fn);
|
|
224
222
|
return fn;
|
|
225
223
|
} catch (error) {
|
|
226
224
|
console.warn(`Failed to compile writer for schema: ${schema}\nReason: ${error instanceof Error ? error.message : String(error)}\nFalling back to default writer`);
|
|
227
225
|
}
|
|
228
226
|
}
|
|
229
|
-
|
|
230
227
|
//#endregion
|
|
231
|
-
export {
|
|
228
|
+
export { getCompiledWriter };
|
package/data/dataIO.js
CHANGED
|
@@ -3,7 +3,6 @@ import { alignmentOf, customAlignmentOf } from "./alignmentOf.js";
|
|
|
3
3
|
import { sizeOf } from "./sizeOf.js";
|
|
4
4
|
import { mat2x2f, mat3x3f, mat4x4f } from "./matrix.js";
|
|
5
5
|
import alignIO from "./alignIO.js";
|
|
6
|
-
|
|
7
6
|
//#region src/data/dataIO.ts
|
|
8
7
|
const dataWriters = {
|
|
9
8
|
bool() {
|
|
@@ -25,70 +24,70 @@ const dataWriters = {
|
|
|
25
24
|
output.writeUint16(value);
|
|
26
25
|
},
|
|
27
26
|
vec2f(output, _, value) {
|
|
28
|
-
output.writeFloat32(value
|
|
29
|
-
output.writeFloat32(value
|
|
27
|
+
output.writeFloat32(value[0]);
|
|
28
|
+
output.writeFloat32(value[1]);
|
|
30
29
|
},
|
|
31
30
|
vec2h(output, _, value) {
|
|
32
|
-
output.writeFloat16(value
|
|
33
|
-
output.writeFloat16(value
|
|
31
|
+
output.writeFloat16(value[0]);
|
|
32
|
+
output.writeFloat16(value[1]);
|
|
34
33
|
},
|
|
35
34
|
vec2i(output, _, value) {
|
|
36
|
-
output.writeInt32(value
|
|
37
|
-
output.writeInt32(value
|
|
35
|
+
output.writeInt32(value[0]);
|
|
36
|
+
output.writeInt32(value[1]);
|
|
38
37
|
},
|
|
39
38
|
vec2u(output, _, value) {
|
|
40
|
-
output.writeUint32(value
|
|
41
|
-
output.writeUint32(value
|
|
39
|
+
output.writeUint32(value[0]);
|
|
40
|
+
output.writeUint32(value[1]);
|
|
42
41
|
},
|
|
43
42
|
"vec2<bool>"() {
|
|
44
43
|
throw new Error("Booleans are not host-shareable");
|
|
45
44
|
},
|
|
46
45
|
vec3f(output, _, value) {
|
|
47
|
-
output.writeFloat32(value
|
|
48
|
-
output.writeFloat32(value
|
|
49
|
-
output.writeFloat32(value
|
|
46
|
+
output.writeFloat32(value[0]);
|
|
47
|
+
output.writeFloat32(value[1]);
|
|
48
|
+
output.writeFloat32(value[2]);
|
|
50
49
|
},
|
|
51
50
|
vec3h(output, _, value) {
|
|
52
|
-
output.writeFloat16(value
|
|
53
|
-
output.writeFloat16(value
|
|
54
|
-
output.writeFloat16(value
|
|
51
|
+
output.writeFloat16(value[0]);
|
|
52
|
+
output.writeFloat16(value[1]);
|
|
53
|
+
output.writeFloat16(value[2]);
|
|
55
54
|
},
|
|
56
55
|
vec3i(output, _, value) {
|
|
57
|
-
output.writeInt32(value
|
|
58
|
-
output.writeInt32(value
|
|
59
|
-
output.writeInt32(value
|
|
56
|
+
output.writeInt32(value[0]);
|
|
57
|
+
output.writeInt32(value[1]);
|
|
58
|
+
output.writeInt32(value[2]);
|
|
60
59
|
},
|
|
61
60
|
vec3u(output, _, value) {
|
|
62
|
-
output.writeUint32(value
|
|
63
|
-
output.writeUint32(value
|
|
64
|
-
output.writeUint32(value
|
|
61
|
+
output.writeUint32(value[0]);
|
|
62
|
+
output.writeUint32(value[1]);
|
|
63
|
+
output.writeUint32(value[2]);
|
|
65
64
|
},
|
|
66
65
|
"vec3<bool>"() {
|
|
67
66
|
throw new Error("Booleans are not host-shareable");
|
|
68
67
|
},
|
|
69
68
|
vec4f(output, _, value) {
|
|
70
|
-
output.writeFloat32(value
|
|
71
|
-
output.writeFloat32(value
|
|
72
|
-
output.writeFloat32(value
|
|
73
|
-
output.writeFloat32(value
|
|
69
|
+
output.writeFloat32(value[0]);
|
|
70
|
+
output.writeFloat32(value[1]);
|
|
71
|
+
output.writeFloat32(value[2]);
|
|
72
|
+
output.writeFloat32(value[3]);
|
|
74
73
|
},
|
|
75
74
|
vec4h(output, _, value) {
|
|
76
|
-
output.writeFloat16(value
|
|
77
|
-
output.writeFloat16(value
|
|
78
|
-
output.writeFloat16(value
|
|
79
|
-
output.writeFloat16(value
|
|
75
|
+
output.writeFloat16(value[0]);
|
|
76
|
+
output.writeFloat16(value[1]);
|
|
77
|
+
output.writeFloat16(value[2]);
|
|
78
|
+
output.writeFloat16(value[3]);
|
|
80
79
|
},
|
|
81
80
|
vec4i(output, _, value) {
|
|
82
|
-
output.writeInt32(value
|
|
83
|
-
output.writeInt32(value
|
|
84
|
-
output.writeInt32(value
|
|
85
|
-
output.writeInt32(value
|
|
81
|
+
output.writeInt32(value[0]);
|
|
82
|
+
output.writeInt32(value[1]);
|
|
83
|
+
output.writeInt32(value[2]);
|
|
84
|
+
output.writeInt32(value[3]);
|
|
86
85
|
},
|
|
87
86
|
vec4u(output, _, value) {
|
|
88
|
-
output.writeUint32(value
|
|
89
|
-
output.writeUint32(value
|
|
90
|
-
output.writeUint32(value
|
|
91
|
-
output.writeUint32(value
|
|
87
|
+
output.writeUint32(value[0]);
|
|
88
|
+
output.writeUint32(value[1]);
|
|
89
|
+
output.writeUint32(value[2]);
|
|
90
|
+
output.writeUint32(value[3]);
|
|
92
91
|
},
|
|
93
92
|
"vec4<bool>"() {
|
|
94
93
|
throw new Error("Booleans are not host-shareable");
|
|
@@ -343,6 +342,15 @@ const dataWriters = {
|
|
|
343
342
|
}
|
|
344
343
|
};
|
|
345
344
|
function writeData(output, schema, value) {
|
|
345
|
+
if (ArrayBuffer.isView(value)) {
|
|
346
|
+
const src = value;
|
|
347
|
+
const expected = sizeOf(schema);
|
|
348
|
+
if (src.byteLength !== expected) console.warn(`TypedArray size mismatch: schema expects ${expected} bytes, got ${src.byteLength}. ` + (src.byteLength < expected ? "Data truncated." : "Excess ignored."));
|
|
349
|
+
const start = output.currentByteOffset;
|
|
350
|
+
output.writeSlice(new Uint8Array(src.buffer, src.byteOffset, Math.min(src.byteLength, expected)));
|
|
351
|
+
output.seekTo(start + expected);
|
|
352
|
+
return;
|
|
353
|
+
}
|
|
346
354
|
const writer = dataWriters[schema.type];
|
|
347
355
|
if (!writer) throw new Error(`Cannot write data of type '${schema.type}'.`);
|
|
348
356
|
writer(output, schema, value);
|
|
@@ -544,6 +552,5 @@ function readData(input, schema) {
|
|
|
544
552
|
if (!reader) throw new Error(`Cannot read data of type '${schema.type}'.`);
|
|
545
553
|
return reader(input, schema);
|
|
546
554
|
}
|
|
547
|
-
|
|
548
555
|
//#endregion
|
|
549
|
-
export { readData, writeData };
|
|
556
|
+
export { readData, writeData };
|
package/data/dataTypes.d.ts
CHANGED
|
@@ -1,13 +1,9 @@
|
|
|
1
1
|
import { TgpuNamable } from "../shared/meta.js";
|
|
2
|
-
import { $gpuRepr, $invalidSchemaReason, $memIdent, $repr, $reprPartial, $validVertexSchema } from "../shared/symbols.js";
|
|
2
|
+
import { $gpuRepr, $inRepr, $invalidSchemaReason, $memIdent, $repr, $reprPartial, $reprPatch, $validVertexSchema } from "../shared/symbols.js";
|
|
3
3
|
import { Prettify } from "../shared/utilityTypes.js";
|
|
4
|
-
import "./sampler.js";
|
|
5
|
-
import "./snippet.js";
|
|
6
4
|
import { PackedData } from "./vertexFormatData.js";
|
|
7
|
-
import "
|
|
8
|
-
import {
|
|
9
|
-
import "./texture.js";
|
|
10
|
-
import { Infer, InferGPURecord, InferPartial, InferPartialRecord, InferRecord, IsValidVertexSchema, MemIdentityRecord } from "../shared/repr.js";
|
|
5
|
+
import { AnyWgslData, BaseData, TypedArrayFor } from "./wgslTypes.js";
|
|
6
|
+
import { Infer, InferGPURecord, InferInput, InferInputRecord, InferPartial, InferPartialRecord, InferPatch, InferPatchRecord, InferRecord, IsValidVertexSchema, MemIdentityRecord } from "../shared/repr.js";
|
|
11
7
|
|
|
12
8
|
//#region src/data/dataTypes.d.ts
|
|
13
9
|
/**
|
|
@@ -25,10 +21,12 @@ interface Disarray<out TElement extends BaseData = BaseData> extends BaseData {
|
|
|
25
21
|
readonly elementCount: number;
|
|
26
22
|
readonly elementType: TElement;
|
|
27
23
|
readonly [$repr]: Infer<TElement>[];
|
|
24
|
+
readonly [$inRepr]: InferInput<TElement>[] | TypedArrayFor<TElement>;
|
|
28
25
|
readonly [$reprPartial]: {
|
|
29
26
|
idx: number;
|
|
30
27
|
value: InferPartial<TElement>;
|
|
31
28
|
}[] | undefined;
|
|
29
|
+
readonly [$reprPatch]: Record<number, InferPatch<TElement>> | InferInput<TElement>[] | TypedArrayFor<TElement> | undefined;
|
|
32
30
|
readonly [$validVertexSchema]: IsValidVertexSchema<TElement>;
|
|
33
31
|
readonly [$invalidSchemaReason]: 'Disarrays are not host-shareable, use arrays instead';
|
|
34
32
|
}
|
|
@@ -46,9 +44,11 @@ interface Unstruct<out TProps extends Record<string, BaseData> = Record<string,
|
|
|
46
44
|
readonly type: 'unstruct';
|
|
47
45
|
readonly propTypes: TProps;
|
|
48
46
|
readonly [$repr]: Prettify<InferRecord<TProps>>;
|
|
47
|
+
readonly [$inRepr]: Prettify<InferInputRecord<TProps>>;
|
|
49
48
|
readonly [$gpuRepr]: Prettify<InferGPURecord<TProps>>;
|
|
50
49
|
readonly [$memIdent]: Unstruct<Prettify<MemIdentityRecord<TProps>>>;
|
|
51
50
|
readonly [$reprPartial]: Prettify<Partial<InferPartialRecord<TProps>>> | undefined;
|
|
51
|
+
readonly [$reprPatch]: Prettify<Partial<InferPatchRecord<TProps>>> | undefined;
|
|
52
52
|
readonly [$validVertexSchema]: { [K in keyof TProps]: IsValidVertexSchema<TProps[K]> }[keyof TProps] extends true ? true : false;
|
|
53
53
|
readonly [$invalidSchemaReason]: 'Unstructs are not host-shareable, use structs instead';
|
|
54
54
|
}
|
package/data/dataTypes.js
CHANGED
|
@@ -2,7 +2,6 @@ import { $internal, isMarkedInternal } from "../shared/symbols.js";
|
|
|
2
2
|
import { setName } from "../shared/meta.js";
|
|
3
3
|
import { vertexFormats } from "../shared/vertexFormat.js";
|
|
4
4
|
import { isAlignAttrib, isDecorated, isLocationAttrib, isPtr, isSizeAttrib, isWgslData } from "./wgslTypes.js";
|
|
5
|
-
|
|
6
5
|
//#region src/data/dataTypes.ts
|
|
7
6
|
/**
|
|
8
7
|
* Runtime function to extract the inner data type from decorated types.
|
|
@@ -74,6 +73,9 @@ function isData(value) {
|
|
|
74
73
|
}
|
|
75
74
|
const UnknownData = Symbol("UNKNOWN");
|
|
76
75
|
var InfixDispatch = class {
|
|
76
|
+
name;
|
|
77
|
+
lhs;
|
|
78
|
+
operator;
|
|
77
79
|
constructor(name, lhs, operator) {
|
|
78
80
|
this.name = name;
|
|
79
81
|
this.lhs = lhs;
|
|
@@ -81,17 +83,18 @@ var InfixDispatch = class {
|
|
|
81
83
|
}
|
|
82
84
|
};
|
|
83
85
|
var MatrixColumnsAccess = class {
|
|
86
|
+
matrix;
|
|
84
87
|
constructor(matrix) {
|
|
85
88
|
this.matrix = matrix;
|
|
86
89
|
}
|
|
87
90
|
};
|
|
88
91
|
var ConsoleLog = class {
|
|
89
92
|
[$internal] = true;
|
|
93
|
+
op;
|
|
90
94
|
constructor(op) {
|
|
91
95
|
this.op = op;
|
|
92
96
|
setName(this, "consoleLog");
|
|
93
97
|
}
|
|
94
98
|
};
|
|
95
|
-
|
|
96
99
|
//#endregion
|
|
97
|
-
export { ConsoleLog, InfixDispatch, MatrixColumnsAccess, UnknownData, getCustomAlignment, getCustomLocation, getCustomSize, isData, isDisarray, isLooseData, isLooseDecorated, isUnstruct, undecorate, unptr };
|
|
100
|
+
export { ConsoleLog, InfixDispatch, MatrixColumnsAccess, UnknownData, getCustomAlignment, getCustomLocation, getCustomSize, isData, isDisarray, isLooseData, isLooseDecorated, isUnstruct, undecorate, unptr };
|
package/data/deepEqual.js
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { isAtomic, isDecorated, isPtr, isWgslArray, isWgslStruct } from "./wgslTypes.js";
|
|
2
2
|
import { isDisarray, isLooseDecorated, isUnstruct } from "./dataTypes.js";
|
|
3
|
-
|
|
4
3
|
//#region src/data/deepEqual.ts
|
|
5
4
|
/**
|
|
6
5
|
* Performs a deep comparison of two TypeGPU data schemas.
|
|
@@ -53,6 +52,5 @@ function deepEqual(a, b) {
|
|
|
53
52
|
}
|
|
54
53
|
return true;
|
|
55
54
|
}
|
|
56
|
-
|
|
57
55
|
//#endregion
|
|
58
|
-
export { deepEqual };
|
|
56
|
+
export { deepEqual };
|
package/data/disarray.d.ts
CHANGED
|
@@ -1,7 +1,5 @@
|
|
|
1
1
|
import { AnyData, Disarray } from "./dataTypes.js";
|
|
2
2
|
import { TgpuComptime } from "../core/function/comptime.js";
|
|
3
|
-
import "../indexNamedExports.js";
|
|
4
|
-
|
|
5
3
|
//#region src/data/disarray.d.ts
|
|
6
4
|
interface DisarrayConstructor {
|
|
7
5
|
<TElement extends AnyData>(elementType: TElement): (elementCount: number) => Disarray<TElement>;
|
|
@@ -29,6 +27,6 @@ interface DisarrayConstructor {
|
|
|
29
27
|
* @param elementType The type of elements in the array.
|
|
30
28
|
* @param elementCount The number of elements in the array.
|
|
31
29
|
*/
|
|
32
|
-
declare const disarrayOf: TgpuComptime
|
|
30
|
+
declare const disarrayOf: TgpuComptime;
|
|
33
31
|
//#endregion
|
|
34
32
|
export { disarrayOf };
|
package/data/disarray.js
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { $internal } from "../shared/symbols.js";
|
|
2
2
|
import { schemaCallWrapper } from "./schemaCallWrapper.js";
|
|
3
3
|
import { comptime } from "../core/function/comptime.js";
|
|
4
|
-
|
|
5
4
|
//#region src/data/disarray.ts
|
|
6
5
|
/**
|
|
7
6
|
* Creates an array schema that can be used to construct vertex buffers.
|
|
@@ -47,6 +46,5 @@ const DisarrayImpl = {
|
|
|
47
46
|
return `disarrayOf(${this.elementType}, ${this.elementCount})`;
|
|
48
47
|
}
|
|
49
48
|
};
|
|
50
|
-
|
|
51
49
|
//#endregion
|
|
52
|
-
export { disarrayOf };
|
|
50
|
+
export { disarrayOf };
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { getLayoutInfo } from "./schemaMemoryLayout.js";
|
|
2
|
-
|
|
3
2
|
//#region src/data/getLongestContiguousPrefix.ts
|
|
4
3
|
function getLongestContiguousPrefix(schema) {
|
|
5
4
|
return getLayoutInfo(schema, "longestContiguousPrefix");
|
|
@@ -10,6 +9,5 @@ function getLongestContiguousPrefix(schema) {
|
|
|
10
9
|
function PUBLIC_getLongestContiguousPrefix(schema) {
|
|
11
10
|
return getLongestContiguousPrefix(schema);
|
|
12
11
|
}
|
|
13
|
-
|
|
14
12
|
//#endregion
|
|
15
|
-
export { PUBLIC_getLongestContiguousPrefix, getLongestContiguousPrefix };
|
|
13
|
+
export { PUBLIC_getLongestContiguousPrefix, getLongestContiguousPrefix };
|
package/data/index.d.ts
CHANGED
|
@@ -6,7 +6,7 @@ import { FormatToAcceptedData, FormatToWGSLType, PackedData, TgpuVertexFormatDat
|
|
|
6
6
|
import { _ref } from "./ref.js";
|
|
7
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";
|
|
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
|
-
import { Infer, InferGPU, InferPartial } from "../shared/repr.js";
|
|
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";
|
|
11
11
|
import { bool, f16, f32, i32, u16, u32 } from "./numeric.js";
|
|
12
12
|
import { struct } from "./struct.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, InferPartial, 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, 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 };
|
|
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 InferPartial, 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 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 };
|
package/data/index.js
CHANGED
|
@@ -25,7 +25,6 @@ import { disarrayOf } from "./disarray.js";
|
|
|
25
25
|
import { unstruct } from "./unstruct.js";
|
|
26
26
|
import { deepEqual } from "./deepEqual.js";
|
|
27
27
|
import { Operator } from "tsover-runtime";
|
|
28
|
-
|
|
29
28
|
//#region src/data/index.ts
|
|
30
29
|
/**
|
|
31
30
|
* @module typegpu/data
|
|
@@ -180,6 +179,14 @@ assignInfixOperator(VecBase, "mod", Operator.percent);
|
|
|
180
179
|
assignInfixOperator(MatBase, "add", Operator.plus);
|
|
181
180
|
assignInfixOperator(MatBase, "sub", Operator.minus);
|
|
182
181
|
assignInfixOperator(MatBase, "mul", Operator.star);
|
|
183
|
-
|
|
182
|
+
{
|
|
183
|
+
const proto = VecBase.prototype;
|
|
184
|
+
proto.bitShiftLeft = function(other) {
|
|
185
|
+
return infixOperators.bitShiftLeft(this, other);
|
|
186
|
+
};
|
|
187
|
+
proto.bitShiftRight = function(other) {
|
|
188
|
+
return infixOperators.bitShiftRight(this, other);
|
|
189
|
+
};
|
|
190
|
+
}
|
|
184
191
|
//#endregion
|
|
185
|
-
export { Void, align, PUBLIC_alignmentOf as alignmentOf, arrayOf, atomic, bool, builtin, comparisonSampler, data_exports, 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, mat2x2f, mat3x3f, mat4x4f, 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, vec2b, vec2f, vec2h, vec2i, vec2u, vec3b, vec3f, vec3h, vec3i, vec3u, vec4b, vec4f, vec4h, vec4i, vec4u };
|
|
192
|
+
export { Void, align, PUBLIC_alignmentOf as alignmentOf, arrayOf, atomic, bool, builtin, comparisonSampler, data_exports, 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, mat2x2f, mat3x3f, mat4x4f, 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, vec2b, vec2f, vec2h, vec2i, vec2u, vec3b, vec3f, vec3h, vec3i, vec3u, vec4b, vec4f, vec4h, vec4i, vec4u };
|
package/data/isContiguous.d.ts
CHANGED
package/data/isContiguous.js
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { getLayoutInfo } from "./schemaMemoryLayout.js";
|
|
2
|
-
|
|
3
2
|
//#region src/data/isContiguous.ts
|
|
4
3
|
function isContiguous(schema) {
|
|
5
4
|
return getLayoutInfo(schema, "isContiguous");
|
|
@@ -10,6 +9,5 @@ function isContiguous(schema) {
|
|
|
10
9
|
function PUBLIC_isContiguous(schema) {
|
|
11
10
|
return isContiguous(schema);
|
|
12
11
|
}
|
|
13
|
-
|
|
14
12
|
//#endregion
|
|
15
|
-
export { PUBLIC_isContiguous, isContiguous };
|
|
13
|
+
export { PUBLIC_isContiguous, isContiguous };
|