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.
Files changed (211) hide show
  1. package/_virtual/_rolldown/runtime.js +6 -11
  2. package/builtin.js +1 -3
  3. package/common/fullScreenTriangle.d.ts +1 -5
  4. package/common/fullScreenTriangle.js +1 -3
  5. package/common/index.d.ts +3 -2
  6. package/common/index.js +6 -4
  7. package/common/writeSoA.d.ts +16 -0
  8. package/common/writeSoA.js +90 -0
  9. package/core/buffer/buffer.d.ts +12 -7
  10. package/core/buffer/buffer.js +102 -53
  11. package/core/buffer/bufferShorthand.d.ts +5 -5
  12. package/core/buffer/bufferShorthand.js +9 -5
  13. package/core/buffer/bufferUsage.d.ts +0 -2
  14. package/core/buffer/bufferUsage.js +6 -4
  15. package/core/constant/tgpuConstant.d.ts +2 -1
  16. package/core/constant/tgpuConstant.js +8 -7
  17. package/core/declare/tgpuDeclare.js +8 -9
  18. package/core/function/autoIO.d.ts +7 -6
  19. package/core/function/autoIO.js +1 -3
  20. package/core/function/comptime.js +1 -3
  21. package/core/function/createCallableSchema.js +4 -6
  22. package/core/function/dualImpl.js +1 -3
  23. package/core/function/entryInputRouter.js +39 -0
  24. package/core/function/extractArgs.js +2 -2
  25. package/core/function/fnCore.js +19 -8
  26. package/core/function/fnTypes.d.ts +14 -8
  27. package/core/function/ioSchema.js +24 -3
  28. package/core/function/shelllessImpl.js +1 -3
  29. package/core/function/templateUtils.js +1 -2
  30. package/core/function/tgpuComputeFn.d.ts +2 -3
  31. package/core/function/tgpuComputeFn.js +9 -16
  32. package/core/function/tgpuFn.d.ts +2 -2
  33. package/core/function/tgpuFn.js +1 -3
  34. package/core/function/tgpuFragmentFn.d.ts +5 -1
  35. package/core/function/tgpuFragmentFn.js +5 -10
  36. package/core/function/tgpuVertexFn.d.ts +4 -0
  37. package/core/function/tgpuVertexFn.js +6 -12
  38. package/core/pipeline/applyPipelineState.js +1 -3
  39. package/core/pipeline/computePipeline.d.ts +2 -6
  40. package/core/pipeline/computePipeline.js +64 -63
  41. package/core/pipeline/connectAttachmentToShader.js +1 -3
  42. package/core/pipeline/connectTargetsToShader.js +1 -3
  43. package/core/pipeline/limitsOverflow.js +1 -2
  44. package/core/pipeline/pipelineUtils.js +29 -0
  45. package/core/pipeline/renderPipeline.d.ts +23 -5
  46. package/core/pipeline/renderPipeline.js +32 -14
  47. package/core/pipeline/timeable.d.ts +0 -3
  48. package/core/pipeline/timeable.js +3 -9
  49. package/core/pipeline/typeGuards.js +1 -3
  50. package/core/querySet/querySet.d.ts +0 -2
  51. package/core/querySet/querySet.js +37 -36
  52. package/core/rawCodeSnippet/tgpuRawCodeSnippet.js +1 -3
  53. package/core/resolve/externals.d.ts +0 -2
  54. package/core/resolve/externals.js +2 -4
  55. package/core/resolve/namespace.js +1 -3
  56. package/core/resolve/resolveData.js +1 -3
  57. package/core/resolve/stitch.js +1 -3
  58. package/core/resolve/tgpuResolve.d.ts +3 -1
  59. package/core/resolve/tgpuResolve.js +3 -5
  60. package/core/root/configurableImpl.js +2 -3
  61. package/core/root/init.d.ts +0 -5
  62. package/core/root/init.js +35 -28
  63. package/core/root/rootTypes.d.ts +25 -5
  64. package/core/sampler/sampler.d.ts +0 -4
  65. package/core/sampler/sampler.js +3 -3
  66. package/core/simulate/tgpuSimulate.js +1 -3
  67. package/core/slot/accessor.d.ts +0 -4
  68. package/core/slot/accessor.js +1 -3
  69. package/core/slot/internalSlots.js +1 -3
  70. package/core/slot/lazy.js +1 -3
  71. package/core/slot/slot.js +2 -3
  72. package/core/slot/slotTypes.js +1 -3
  73. package/core/texture/externalTexture.d.ts +0 -6
  74. package/core/texture/externalTexture.js +2 -3
  75. package/core/texture/texture.d.ts +0 -4
  76. package/core/texture/texture.js +5 -3
  77. package/core/texture/textureFormats.js +1 -3
  78. package/core/texture/textureUtils.js +1 -3
  79. package/core/texture/usageExtension.js +1 -3
  80. package/core/unroll/tgpuUnroll.d.ts +58 -3
  81. package/core/unroll/tgpuUnroll.js +63 -5
  82. package/core/valueProxyUtils.js +1 -3
  83. package/core/variable/tgpuVariable.js +1 -3
  84. package/core/vertexLayout/connectAttributesToShader.js +1 -3
  85. package/core/vertexLayout/vertexLayout.js +9 -9
  86. package/data/alignIO.js +1 -2
  87. package/data/alignmentOf.d.ts +0 -1
  88. package/data/alignmentOf.js +1 -3
  89. package/data/array.d.ts +1 -3
  90. package/data/array.js +2 -4
  91. package/data/atomic.js +2 -3
  92. package/data/attributes.js +3 -3
  93. package/data/autoStruct.d.ts +1 -3
  94. package/data/autoStruct.js +1 -3
  95. package/data/compiledIO.js +83 -86
  96. package/data/dataIO.js +46 -39
  97. package/data/dataTypes.d.ts +7 -7
  98. package/data/dataTypes.js +6 -3
  99. package/data/deepEqual.js +1 -3
  100. package/data/disarray.d.ts +1 -3
  101. package/data/disarray.js +1 -3
  102. package/data/getLongestContiguousPrefix.d.ts +0 -1
  103. package/data/getLongestContiguousPrefix.js +1 -3
  104. package/data/index.d.ts +3 -3
  105. package/data/index.js +10 -3
  106. package/data/isContiguous.d.ts +0 -1
  107. package/data/isContiguous.js +1 -3
  108. package/data/matrix.d.ts +8 -10
  109. package/data/matrix.js +32 -18
  110. package/data/numberOps.js +1 -2
  111. package/data/numeric.js +16 -29
  112. package/data/offsetUtils.d.ts +2 -2
  113. package/data/offsetUtils.js +3 -5
  114. package/data/offsets.js +1 -3
  115. package/data/partialIO.js +84 -39
  116. package/data/ptr.d.ts +0 -1
  117. package/data/ptr.js +1 -3
  118. package/data/ref.d.ts +0 -3
  119. package/data/ref.js +1 -3
  120. package/data/sampler.js +1 -3
  121. package/data/schemaCallWrapper.js +1 -3
  122. package/data/schemaMemoryLayout.js +1 -3
  123. package/data/sizeOf.d.ts +0 -1
  124. package/data/sizeOf.js +1 -3
  125. package/data/snippet.js +12 -3
  126. package/data/struct.js +1 -3
  127. package/data/texture.js +1 -3
  128. package/data/unstruct.js +1 -3
  129. package/data/vector.js +4 -12
  130. package/data/vectorImpl.js +27 -28
  131. package/data/vectorOps.js +20 -3
  132. package/data/vertexFormatData.js +2 -3
  133. package/data/wgslTypes.d.ts +39 -11
  134. package/data/wgslTypes.js +10 -3
  135. package/errors.js +6 -3
  136. package/execMode.js +1 -3
  137. package/extension.js +1 -3
  138. package/getGPUValue.js +1 -3
  139. package/index.d.ts +4 -2
  140. package/index.js +3 -3
  141. package/indexNamedExports.d.ts +3 -1
  142. package/mathUtils.js +1 -2
  143. package/memo.js +8 -8
  144. package/nameRegistry.js +1 -3
  145. package/package.js +2 -3
  146. package/package.json +7 -7
  147. package/resolutionCtx.d.ts +0 -10
  148. package/resolutionCtx.js +84 -18
  149. package/shared/env.js +1 -2
  150. package/shared/generators.js +1 -2
  151. package/shared/meta.js +1 -3
  152. package/shared/repr.d.ts +32 -2
  153. package/shared/stringify.js +1 -3
  154. package/shared/symbols.d.ts +10 -1
  155. package/shared/symbols.js +10 -33
  156. package/shared/utilityTypes.d.ts +6 -2
  157. package/shared/utilityTypes.js +1 -2
  158. package/shared/vertexFormat.js +1 -2
  159. package/std/array.d.ts +1 -1
  160. package/std/array.js +1 -3
  161. package/std/atomic.d.ts +12 -12
  162. package/std/atomic.js +1 -3
  163. package/std/bitcast.d.ts +2 -2
  164. package/std/bitcast.js +1 -3
  165. package/std/boolean.d.ts +30 -16
  166. package/std/boolean.js +37 -12
  167. package/std/derivative.d.ts +9 -9
  168. package/std/derivative.js +1 -3
  169. package/std/discard.d.ts +1 -1
  170. package/std/discard.js +1 -3
  171. package/std/extensions.d.ts +1 -3
  172. package/std/extensions.js +1 -3
  173. package/std/index.d.ts +5 -4
  174. package/std/index.js +8 -5
  175. package/std/matrix.d.ts +5 -5
  176. package/std/matrix.js +1 -3
  177. package/std/numeric.d.ts +78 -132
  178. package/std/numeric.js +1 -3
  179. package/std/operators.d.ts +16 -8
  180. package/std/operators.js +80 -6
  181. package/std/packing.d.ts +4 -4
  182. package/std/packing.js +1 -3
  183. package/std/range.d.ts +24 -0
  184. package/std/range.js +38 -0
  185. package/std/subgroup.d.ts +21 -21
  186. package/std/subgroup.js +1 -3
  187. package/std/texture.d.ts +20 -11
  188. package/std/texture.js +13 -3
  189. package/tgpu.js +1 -3
  190. package/tgpuBindGroupLayout.js +9 -8
  191. package/tgpuUnstable.js +1 -3
  192. package/tgsl/accessIndex.js +2 -4
  193. package/tgsl/accessProp.js +8 -6
  194. package/tgsl/consoleLog/deserializers.js +1 -3
  195. package/tgsl/consoleLog/logGenerator.js +2 -4
  196. package/tgsl/consoleLog/serializers.js +24 -26
  197. package/tgsl/consoleLog/types.d.ts +0 -2
  198. package/tgsl/consoleLog/types.js +1 -2
  199. package/tgsl/conversion.js +1 -3
  200. package/tgsl/forOfUtils.js +35 -9
  201. package/tgsl/generationHelpers.js +3 -3
  202. package/tgsl/math.js +1 -3
  203. package/tgsl/shaderGenerator.d.ts +10 -8
  204. package/tgsl/shaderGenerator_members.d.ts +2 -0
  205. package/tgsl/shaderGenerator_members.js +6 -0
  206. package/tgsl/shellless.js +1 -8
  207. package/tgsl/wgslGenerator.d.ts +36 -0
  208. package/tgsl/wgslGenerator.js +144 -81
  209. package/types.d.ts +14 -4
  210. package/types.js +3 -3
  211. package/wgslExtensions.js +1 -2
@@ -1,3 +1 @@
1
- import "./snippet.js";
2
- import "../types.js";
3
- import "./wgslTypes.js";
1
+ export { };
@@ -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 };
@@ -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
- const bgraComponents = [
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 loopVar = [
132
- "i",
133
- "j",
134
- "k"
135
- ][depth] || `i${depth}`;
136
- if (isAtomic(node) || isDecorated(node)) return buildWriter(node.inner, offsetExpr, valueExpr, depth);
137
- if (isWgslStruct(node) || isUnstruct(node)) {
138
- const propOffsets = offsetsForProps(node);
139
- let code = "";
140
- for (const [key, propOffset] of Object.entries(propOffsets)) {
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
- if (!subSchema) continue;
143
- code += buildWriter(subSchema, `(${offsetExpr} + ${propOffset.offset})`, `${valueExpr}.${key}`, depth);
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
- return code;
146
- }
147
- if (isWgslArray(node) || isDisarray(node)) {
148
- const elementSize = roundUp(sizeOf(node.elementType), alignmentOf(node));
149
- let code = "";
150
- code += `for (let ${loopVar} = 0; ${loopVar} < ${node.elementCount}; ${loopVar}++) {\n`;
151
- code += buildWriter(node.elementType, `(${offsetExpr} + ${loopVar} * ${elementSize})`, `${valueExpr}[${loopVar}]`, depth + 1);
152
- code += "}\n";
153
- return code;
154
- }
155
- if (isVec(node)) {
156
- if (isVecBool(node)) throw new Error("Compiled writers do not support boolean vectors");
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
- ][rowIndex]}, littleEndian);\n`;
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
- return code;
187
- }
188
- if (isPackedData(node)) {
189
- const formatName = node.type;
190
- if (formatName in specialPackedFormats) return specialPackedFormats[formatName].generator(offsetExpr, valueExpr);
191
- const primitive = vertexFormatToPrimitive[formatName];
192
- const writeFunc = primitiveToWriteFunction[primitive];
193
- const wgslType = formatToWGSLType[formatName];
194
- const componentCount = isVec(wgslType) ? wgslType.componentCount : 1;
195
- const componentSize = primitive === "u8" || primitive === "i8" ? 1 : primitive === "u16" || primitive === "i16" || primitive === "f16" ? 2 : 4;
196
- const components = [
197
- "x",
198
- "y",
199
- "z",
200
- "w"
201
- ];
202
- const transform = vertexFormatValueTransform[formatName];
203
- let code = "";
204
- for (let idx = 0; idx < componentCount; idx++) {
205
- const accessor = componentCount === 1 ? valueExpr : `${valueExpr}.${components[idx]}`;
206
- const value = transform ? transform(accessor) : accessor;
207
- code += `output.${writeFunc}((${offsetExpr} + ${idx * componentSize}), ${value}, littleEndian);\n`;
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
- return code;
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
- if (!Object.hasOwn(typeToPrimitive, node.type)) throw new Error(`Primitive ${node.type} is unsupported by compiled writer`);
212
- return `output.${primitiveToWriteFunction[typeToPrimitive[node.type]]}(${offsetExpr}, ${valueExpr}, littleEndian);\n`;
208
+ return go(node, offsetExpr, valueExpr, depth);
213
209
  }
214
- function getCompiledWriterForSchema(schema) {
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
- if (compiledWriters.has(schema)) return compiledWriters.get(schema);
215
+ const cached = compiledWriters.get(schema);
216
+ if (cached) return cached;
220
217
  try {
221
- const body = buildWriter(schema, "offset", "value", 0);
222
- const fn = new Function("output", "offset", "value", "littleEndian=true", body);
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 { getCompiledWriterForSchema };
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.x);
29
- output.writeFloat32(value.y);
27
+ output.writeFloat32(value[0]);
28
+ output.writeFloat32(value[1]);
30
29
  },
31
30
  vec2h(output, _, value) {
32
- output.writeFloat16(value.x);
33
- output.writeFloat16(value.y);
31
+ output.writeFloat16(value[0]);
32
+ output.writeFloat16(value[1]);
34
33
  },
35
34
  vec2i(output, _, value) {
36
- output.writeInt32(value.x);
37
- output.writeInt32(value.y);
35
+ output.writeInt32(value[0]);
36
+ output.writeInt32(value[1]);
38
37
  },
39
38
  vec2u(output, _, value) {
40
- output.writeUint32(value.x);
41
- output.writeUint32(value.y);
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.x);
48
- output.writeFloat32(value.y);
49
- output.writeFloat32(value.z);
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.x);
53
- output.writeFloat16(value.y);
54
- output.writeFloat16(value.z);
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.x);
58
- output.writeInt32(value.y);
59
- output.writeInt32(value.z);
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.x);
63
- output.writeUint32(value.y);
64
- output.writeUint32(value.z);
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.x);
71
- output.writeFloat32(value.y);
72
- output.writeFloat32(value.z);
73
- output.writeFloat32(value.w);
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.x);
77
- output.writeFloat16(value.y);
78
- output.writeFloat16(value.z);
79
- output.writeFloat16(value.w);
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.x);
83
- output.writeInt32(value.y);
84
- output.writeInt32(value.z);
85
- output.writeInt32(value.w);
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.x);
89
- output.writeUint32(value.y);
90
- output.writeUint32(value.z);
91
- output.writeUint32(value.w);
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 };
@@ -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 "../types.js";
8
- import { AnyWgslData, BaseData } from "./wgslTypes.js";
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 };
@@ -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<DisarrayConstructor>;
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,4 +1,3 @@
1
- import "./wgslTypes.js";
2
1
  import { AnyData } from "./dataTypes.js";
3
2
 
4
3
  //#region src/data/getLongestContiguousPrefix.d.ts
@@ -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 };
@@ -1,4 +1,3 @@
1
- import "./wgslTypes.js";
2
1
  import { AnyData } from "./dataTypes.js";
3
2
 
4
3
  //#region src/data/isContiguous.d.ts
@@ -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 };