typegpu 0.11.1 → 0.11.3

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 (216) hide show
  1. package/_virtual/{_rolldown/runtime.js → rolldown_runtime.js} +4 -4
  2. package/builtin.js +3 -1
  3. package/common/fullScreenTriangle.d.ts +6 -1
  4. package/common/fullScreenTriangle.js +3 -1
  5. package/common/index.js +5 -3
  6. package/common/writeSoA.js +3 -1
  7. package/core/buffer/buffer.d.ts +3 -0
  8. package/core/buffer/buffer.js +5 -3
  9. package/core/buffer/bufferShorthand.d.ts +2 -0
  10. package/core/buffer/bufferShorthand.js +3 -1
  11. package/core/buffer/bufferUsage.d.ts +2 -0
  12. package/core/buffer/bufferUsage.js +3 -1
  13. package/core/constant/tgpuConstant.d.ts +2 -1
  14. package/core/constant/tgpuConstant.js +3 -1
  15. package/core/declare/tgpuDeclare.js +3 -1
  16. package/core/function/autoIO.d.ts +3 -0
  17. package/core/function/autoIO.js +5 -3
  18. package/core/function/comptime.js +3 -1
  19. package/core/function/createCallableSchema.js +3 -1
  20. package/core/function/dualImpl.js +3 -1
  21. package/core/function/entryInputRouter.js +13 -17
  22. package/core/function/extractArgs.js +2 -1
  23. package/core/function/fnCore.js +17 -11
  24. package/core/function/fnTypes.d.ts +2 -0
  25. package/core/function/ioSchema.d.ts +1 -0
  26. package/core/function/ioSchema.js +3 -1
  27. package/core/function/shelllessImpl.d.ts +1 -0
  28. package/core/function/shelllessImpl.js +4 -2
  29. package/core/function/templateUtils.js +2 -1
  30. package/core/function/tgpuComputeFn.d.ts +1 -0
  31. package/core/function/tgpuComputeFn.js +4 -2
  32. package/core/function/tgpuFn.d.ts +1 -0
  33. package/core/function/tgpuFn.js +17 -15
  34. package/core/function/tgpuFragmentFn.js +4 -2
  35. package/core/function/tgpuVertexFn.js +4 -2
  36. package/core/pipeline/applyPipelineState.js +3 -1
  37. package/core/pipeline/computePipeline.d.ts +4 -0
  38. package/core/pipeline/computePipeline.js +8 -6
  39. package/core/pipeline/connectAttachmentToShader.js +3 -1
  40. package/core/pipeline/connectTargetsToShader.js +3 -1
  41. package/core/pipeline/limitsOverflow.js +2 -1
  42. package/core/pipeline/pipelineUtils.js +6 -4
  43. package/core/pipeline/renderPipeline.js +21 -19
  44. package/core/pipeline/timeable.d.ts +2 -0
  45. package/core/pipeline/timeable.js +3 -1
  46. package/core/pipeline/typeGuards.js +3 -1
  47. package/core/querySet/querySet.d.ts +2 -0
  48. package/core/querySet/querySet.js +3 -1
  49. package/core/rawCodeSnippet/tgpuRawCodeSnippet.d.ts +1 -0
  50. package/core/rawCodeSnippet/tgpuRawCodeSnippet.js +3 -1
  51. package/core/resolve/externals.d.ts +3 -0
  52. package/core/resolve/externals.js +7 -5
  53. package/core/resolve/namespace.js +6 -4
  54. package/core/resolve/resolveData.js +3 -1
  55. package/core/resolve/stitch.js +3 -1
  56. package/core/resolve/tgpuResolve.js +7 -5
  57. package/core/root/configurableImpl.js +3 -1
  58. package/core/root/init.d.ts +10 -2
  59. package/core/root/init.js +4 -2
  60. package/core/root/rootTypes.d.ts +11 -11
  61. package/core/sampler/sampler.d.ts +4 -0
  62. package/core/sampler/sampler.js +3 -1
  63. package/core/simulate/tgpuSimulate.js +6 -4
  64. package/core/slot/accessor.d.ts +4 -0
  65. package/core/slot/accessor.js +3 -1
  66. package/core/slot/internalSlots.js +3 -1
  67. package/core/slot/lazy.js +3 -1
  68. package/core/slot/slot.js +3 -1
  69. package/core/slot/slotTypes.js +3 -1
  70. package/core/texture/externalTexture.d.ts +6 -0
  71. package/core/texture/externalTexture.js +3 -1
  72. package/core/texture/texture.d.ts +4 -0
  73. package/core/texture/texture.js +6 -4
  74. package/core/texture/textureFormats.js +3 -1
  75. package/core/texture/textureUtils.js +3 -1
  76. package/core/texture/usageExtension.js +3 -1
  77. package/core/unroll/tgpuUnroll.d.ts +3 -1
  78. package/core/unroll/tgpuUnroll.js +3 -1
  79. package/core/valueProxyUtils.js +7 -5
  80. package/core/variable/tgpuVariable.d.ts +3 -1
  81. package/core/variable/tgpuVariable.js +3 -1
  82. package/core/vertexLayout/connectAttributesToShader.js +3 -1
  83. package/core/vertexLayout/vertexAttribute.d.ts +1 -0
  84. package/core/vertexLayout/vertexLayout.js +7 -5
  85. package/data/alignIO.js +3 -1
  86. package/data/alignmentOf.d.ts +2 -0
  87. package/data/alignmentOf.js +3 -1
  88. package/data/array.js +3 -1
  89. package/data/atomic.d.ts +1 -0
  90. package/data/atomic.js +3 -1
  91. package/data/attributes.js +7 -5
  92. package/data/autoStruct.d.ts +3 -1
  93. package/data/autoStruct.js +3 -1
  94. package/data/compiledIO.js +39 -37
  95. package/data/dataIO.js +22 -20
  96. package/data/dataTypes.d.ts +9 -4
  97. package/data/dataTypes.js +3 -1
  98. package/data/deepEqual.d.ts +1 -0
  99. package/data/deepEqual.js +3 -1
  100. package/data/disarray.d.ts +3 -1
  101. package/data/disarray.js +3 -1
  102. package/data/getLongestContiguousPrefix.d.ts +2 -0
  103. package/data/getLongestContiguousPrefix.js +3 -1
  104. package/data/index.d.ts +3 -3
  105. package/data/index.js +5 -6
  106. package/data/isContiguous.d.ts +2 -0
  107. package/data/isContiguous.js +3 -1
  108. package/data/matrix.d.ts +11 -8
  109. package/data/matrix.js +3 -1
  110. package/data/numberOps.js +2 -1
  111. package/data/numeric.d.ts +1 -0
  112. package/data/numeric.js +19 -15
  113. package/data/offsetUtils.d.ts +1 -0
  114. package/data/offsetUtils.js +3 -1
  115. package/data/offsets.js +5 -3
  116. package/data/partialIO.js +3 -1
  117. package/data/ptr.d.ts +1 -0
  118. package/data/ptr.js +3 -1
  119. package/data/ref.d.ts +3 -0
  120. package/data/ref.js +5 -3
  121. package/data/sampler.js +3 -1
  122. package/data/schemaCallWrapper.js +3 -1
  123. package/data/schemaMemoryLayout.js +3 -1
  124. package/data/sizeOf.d.ts +2 -0
  125. package/data/sizeOf.js +3 -1
  126. package/data/snippet.d.ts +1 -6
  127. package/data/snippet.js +3 -1
  128. package/data/struct.d.ts +1 -0
  129. package/data/struct.js +3 -1
  130. package/data/texture.js +3 -1
  131. package/data/unstruct.d.ts +1 -0
  132. package/data/unstruct.js +3 -1
  133. package/data/vector.d.ts +1 -0
  134. package/data/vector.js +3 -1
  135. package/data/vectorImpl.js +3 -1
  136. package/data/vectorOps.js +3 -1
  137. package/data/vertexFormatData.js +3 -1
  138. package/data/wgslTypes.d.ts +4 -0
  139. package/data/wgslTypes.js +3 -1
  140. package/errors.d.ts +1 -0
  141. package/errors.js +3 -1
  142. package/execMode.js +3 -1
  143. package/extension.d.ts +1 -0
  144. package/extension.js +3 -1
  145. package/getGPUValue.js +3 -1
  146. package/index.js +3 -4
  147. package/indexNamedExports.d.ts +1 -0
  148. package/mathUtils.js +2 -1
  149. package/memo.js +2 -1
  150. package/nameRegistry.js +3 -1
  151. package/package.js +3 -2
  152. package/package.json +1 -1
  153. package/resolutionCtx.d.ts +11 -0
  154. package/resolutionCtx.js +86 -87
  155. package/shared/env.js +2 -1
  156. package/shared/generators.js +2 -1
  157. package/shared/meta.js +3 -1
  158. package/shared/repr.d.ts +1 -0
  159. package/shared/stringify.js +3 -1
  160. package/shared/symbols.js +42 -10
  161. package/shared/utilityTypes.js +2 -1
  162. package/shared/vertexFormat.js +2 -1
  163. package/std/array.d.ts +1 -1
  164. package/std/array.js +3 -1
  165. package/std/atomic.d.ts +12 -12
  166. package/std/atomic.js +3 -1
  167. package/std/bitcast.d.ts +2 -2
  168. package/std/bitcast.js +3 -1
  169. package/std/boolean.d.ts +15 -14
  170. package/std/boolean.js +3 -1
  171. package/std/derivative.d.ts +9 -9
  172. package/std/derivative.js +3 -1
  173. package/std/discard.d.ts +1 -1
  174. package/std/discard.js +3 -1
  175. package/std/extensions.d.ts +3 -1
  176. package/std/extensions.js +3 -1
  177. package/std/index.js +5 -3
  178. package/std/matrix.d.ts +6 -5
  179. package/std/matrix.js +3 -1
  180. package/std/numeric.d.ts +132 -78
  181. package/std/numeric.js +7 -5
  182. package/std/operators.d.ts +8 -8
  183. package/std/operators.js +7 -5
  184. package/std/packing.d.ts +5 -4
  185. package/std/packing.js +3 -1
  186. package/std/range.d.ts +3 -1
  187. package/std/range.js +3 -1
  188. package/std/subgroup.d.ts +21 -21
  189. package/std/subgroup.js +3 -1
  190. package/std/texture.d.ts +11 -11
  191. package/std/texture.js +9 -7
  192. package/tgpu.js +5 -3
  193. package/tgpuBindGroupLayout.d.ts +11 -7
  194. package/tgpuBindGroupLayout.js +3 -1
  195. package/tgpuUnstable.js +5 -3
  196. package/tgsl/accessIndex.js +5 -3
  197. package/tgsl/accessProp.js +10 -3
  198. package/tgsl/consoleLog/deserializers.js +3 -1
  199. package/tgsl/consoleLog/logGenerator.js +18 -9
  200. package/tgsl/consoleLog/serializers.js +3 -1
  201. package/tgsl/consoleLog/types.d.ts +3 -0
  202. package/tgsl/consoleLog/types.js +2 -1
  203. package/tgsl/conversion.js +18 -6
  204. package/tgsl/forOfUtils.js +17 -7
  205. package/tgsl/generationHelpers.d.ts +1 -0
  206. package/tgsl/generationHelpers.js +3 -4
  207. package/tgsl/math.js +3 -1
  208. package/tgsl/shaderGenerator.d.ts +3 -2
  209. package/tgsl/shaderGenerator_members.d.ts +15 -2
  210. package/tgsl/shaderGenerator_members.js +5 -3
  211. package/tgsl/shellless.js +3 -1
  212. package/tgsl/wgslGenerator.d.ts +3 -1
  213. package/tgsl/wgslGenerator.js +54 -44
  214. package/types.d.ts +11 -7
  215. package/types.js +3 -1
  216. package/wgslExtensions.js +2 -1
@@ -3,6 +3,7 @@ import { isAlignAttrib, isBuiltinAttrib, isDecorated, isSizeAttrib, isWgslData }
3
3
  import { isLooseData, isLooseDecorated } from "./dataTypes.js";
4
4
  import { alignmentOf } from "./alignmentOf.js";
5
5
  import { sizeOf } from "./sizeOf.js";
6
+
6
7
  //#region src/data/attributes.ts
7
8
  function attribute(data, attrib) {
8
9
  if (isDecorated(data)) return new DecoratedImpl(data.inner, [attrib, ...data.attribs]);
@@ -43,11 +44,11 @@ function align(alignment, data) {
43
44
  * @param size The amount of bytes that should be reserved for this data-type.
44
45
  * @param data The data-type to wrap.
45
46
  */
46
- function size(size, data) {
47
+ function size(size$1, data) {
47
48
  return attribute(data, {
48
49
  [$internal]: true,
49
50
  type: "@size",
50
- params: [size]
51
+ params: [size$1]
51
52
  });
52
53
  }
53
54
  /**
@@ -63,11 +64,11 @@ function size(size, data) {
63
64
  * @param location The explicit numeric location.
64
65
  * @param data The data-type to wrap.
65
66
  */
66
- function location(location, data) {
67
+ function location(location$1, data) {
67
68
  return attribute(data, {
68
69
  [$internal]: true,
69
70
  type: "@location",
70
- params: [location]
71
+ params: [location$1]
71
72
  });
72
73
  }
73
74
  function interpolate(interpolationType, data) {
@@ -141,5 +142,6 @@ var LooseDecoratedImpl = class extends BaseDecoratedImpl {
141
142
  [$internal] = {};
142
143
  type = "loose-decorated";
143
144
  };
145
+
144
146
  //#endregion
145
- export { align, attribute, getAttributesString, interpolate, invariant, isBuiltin, location, size };
147
+ export { align, attribute, getAttributesString, interpolate, invariant, isBuiltin, location, size };
@@ -1 +1,3 @@
1
- export { };
1
+ import "./snippet.js";
2
+ import "../types.js";
3
+ import "./wgslTypes.js";
@@ -2,6 +2,7 @@ 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
+
5
6
  //#region src/data/autoStruct.ts
6
7
  /**
7
8
  * A requirement for the generated struct is that non-builtin properties need to
@@ -77,5 +78,6 @@ var AutoStruct = class {
77
78
  };
78
79
  AutoStruct.prototype[$internal] = {};
79
80
  AutoStruct.prototype.type = "auto-struct";
81
+
80
82
  //#endregion
81
- export { AutoStruct };
83
+ export { AutoStruct };
@@ -5,6 +5,7 @@ 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
+
8
9
  //#region src/data/compiledIO.ts
9
10
  const EVAL_ALLOWED_IN_ENV = (() => {
10
11
  try {
@@ -126,41 +127,41 @@ const specialPackedFormats = {
126
127
  function buildWriter(node, offsetExpr, valueExpr, depth = 0, partial = false) {
127
128
  const emitWrite = (writeFunc, addr, value) => partial ? `if (${addr} < endOffset) { output.${writeFunc}(${addr}, ${value}, littleEndian); }\n` : `output.${writeFunc}(${addr}, ${value}, littleEndian);\n`;
128
129
  const emitBlock = (addr, block) => partial ? `if (${addr} < endOffset) {\n${block}}\n` : block;
129
- function go(node, offsetExpr, valueExpr, depth) {
130
+ function go(node$1, offsetExpr$1, valueExpr$1, depth$1) {
130
131
  const loopVar = [
131
132
  "i",
132
133
  "j",
133
134
  "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]) => {
137
- const subSchema = node.propTypes[key];
138
- return subSchema ? go(subSchema, `(${offsetExpr} + ${propOffset.offset})`, `${valueExpr}.${key}`, depth) : "";
135
+ ][depth$1] || `i${depth$1}`;
136
+ if (isAtomic(node$1) || isDecorated(node$1)) return go(node$1.inner, offsetExpr$1, valueExpr$1, depth$1);
137
+ if (isWgslStruct(node$1) || isUnstruct(node$1)) return Object.entries(offsetsForProps(node$1)).map(([key, propOffset]) => {
138
+ const subSchema = node$1.propTypes[key];
139
+ return subSchema ? go(subSchema, `(${offsetExpr$1} + ${propOffset.offset})`, `${valueExpr$1}.${key}`, depth$1) : "";
139
140
  }).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`;
141
+ if (isWgslArray(node$1) || isDisarray(node$1)) {
142
+ const elementSize = roundUp(sizeOf(node$1.elementType), alignmentOf(node$1));
143
+ const totalSize = node$1.elementCount * elementSize;
144
+ const copyLen = partial ? `Math.min(${valueExpr$1}.byteLength, Math.max(0, endOffset - (${offsetExpr$1})))` : `Math.min(${valueExpr$1}.byteLength, ${totalSize})`;
145
+ let code = `if (ArrayBuffer.isView(${valueExpr$1})) {\n`;
146
+ code += ` new Uint8Array(output.buffer).set(new Uint8Array(${valueExpr$1}.buffer, ${valueExpr$1}.byteOffset, ${copyLen}), output.byteOffset + (${offsetExpr$1}));\n`;
146
147
  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);
148
+ code += `for (let ${loopVar} = 0; ${loopVar} < ${node$1.elementCount}; ${loopVar}++) {\n`;
149
+ if (partial) code += `if ((${offsetExpr$1} + ${loopVar} * ${elementSize}) >= endOffset) return;\n`;
150
+ code += go(node$1.elementType, `(${offsetExpr$1} + ${loopVar} * ${elementSize})`, `${valueExpr$1}[${loopVar}]`, depth$1 + 1);
150
151
  code += "}\n";
151
152
  code += "}\n";
152
153
  return code;
153
154
  }
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("");
155
+ if (isVec(node$1)) {
156
+ if (isVecBool(node$1)) throw new Error("Compiled writers do not support boolean vectors");
157
+ const primitive$1 = typeToPrimitive[node$1.type];
158
+ const componentSize = sizeOf(node$1.primitive);
159
+ const writeFunc = primitiveToWriteFunction[primitive$1];
160
+ return Array.from({ length: node$1.componentCount }, (_, i) => emitWrite(writeFunc, `(${offsetExpr$1} + ${i * componentSize})`, `${valueExpr$1}[${i}]`)).join("");
160
161
  }
161
- if (isMat(node)) {
162
- const writeFunc = primitiveToWriteFunction[typeToPrimitive[node.type]];
163
- const matSize = isMat2x2f(node) ? 2 : isMat3x3f(node) ? 3 : 4;
162
+ if (isMat(node$1)) {
163
+ const writeFunc = primitiveToWriteFunction[typeToPrimitive[node$1.type]];
164
+ const matSize = isMat2x2f(node$1) ? 2 : isMat3x3f(node$1) ? 3 : 4;
164
165
  const rowStride = roundUp(matSize * 4, 8);
165
166
  const components = [
166
167
  "x",
@@ -174,20 +175,20 @@ function buildWriter(node, offsetExpr, valueExpr, depth = 0, partial = false) {
174
175
  const row = idx % matSize;
175
176
  const packedIndex = col * matSize + row;
176
177
  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
+ return emitWrite(writeFunc, `(${offsetExpr$1} + ${col * rowStride + row * 4})`, `ArrayBuffer.isView(${valueExpr$1}) ? ${valueExpr$1}[${wgslIndex}] : Array.isArray(${valueExpr$1}) ? ${valueExpr$1}[${packedIndex}] : ${valueExpr$1}.columns[${col}].${components[row]}`);
178
179
  }).join("");
179
180
  }
180
- if (isPackedData(node)) {
181
- const formatName = node.type;
181
+ if (isPackedData(node$1)) {
182
+ const formatName = node$1.type;
182
183
  if (formatName in specialPackedFormats) {
183
184
  const handler = specialPackedFormats[formatName];
184
- return emitBlock(`(${offsetExpr})`, handler.generator(offsetExpr, valueExpr));
185
+ return emitBlock(`(${offsetExpr$1})`, handler.generator(offsetExpr$1, valueExpr$1));
185
186
  }
186
- const primitive = vertexFormatToPrimitive[formatName];
187
- const writeFunc = primitiveToWriteFunction[primitive];
187
+ const primitive$1 = vertexFormatToPrimitive[formatName];
188
+ const writeFunc = primitiveToWriteFunction[primitive$1];
188
189
  const wgslType = formatToWGSLType[formatName];
189
190
  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 componentSize = primitive$1 === "u8" || primitive$1 === "i8" ? 1 : primitive$1 === "u16" || primitive$1 === "i16" || primitive$1 === "f16" ? 2 : 4;
191
192
  const components = [
192
193
  "x",
193
194
  "y",
@@ -196,14 +197,14 @@ function buildWriter(node, offsetExpr, valueExpr, depth = 0, partial = false) {
196
197
  ];
197
198
  const transform = vertexFormatValueTransform[formatName];
198
199
  return Array.from({ length: componentCount }, (_, idx) => {
199
- const accessor = componentCount === 1 ? valueExpr : `${valueExpr}.${components[idx]}`;
200
+ const accessor = componentCount === 1 ? valueExpr$1 : `${valueExpr$1}.${components[idx]}`;
200
201
  const value = transform ? transform(accessor) : accessor;
201
- return emitWrite(writeFunc, `(${offsetExpr} + ${idx * componentSize})`, value);
202
+ return emitWrite(writeFunc, `(${offsetExpr$1} + ${idx * componentSize})`, value);
202
203
  }).join("");
203
204
  }
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);
205
+ if (!Object.hasOwn(typeToPrimitive, node$1.type)) throw new Error(`Primitive ${node$1.type} is unsupported by compiled writer`);
206
+ const primitive = typeToPrimitive[node$1.type];
207
+ return emitWrite(primitiveToWriteFunction[primitive], offsetExpr$1, valueExpr$1);
207
208
  }
208
209
  return go(node, offsetExpr, valueExpr, depth);
209
210
  }
@@ -224,5 +225,6 @@ function getCompiledWriter(schema) {
224
225
  console.warn(`Failed to compile writer for schema: ${schema}\nReason: ${error instanceof Error ? error.message : String(error)}\nFalling back to default writer`);
225
226
  }
226
227
  }
228
+
227
229
  //#endregion
228
- export { getCompiledWriter };
230
+ export { getCompiledWriter };
package/data/dataIO.js CHANGED
@@ -2,7 +2,8 @@ import { vec2f, vec2h, vec2i, vec2u, vec3f, vec3h, vec3i, vec3u, vec4f, vec4h, v
2
2
  import { alignmentOf, customAlignmentOf } from "./alignmentOf.js";
3
3
  import { sizeOf } from "./sizeOf.js";
4
4
  import { mat2x2f, mat3x3f, mat4x4f } from "./matrix.js";
5
- import alignIO from "./alignIO.js";
5
+ import alignIO_default from "./alignIO.js";
6
+
6
7
  //#region src/data/dataIO.ts
7
8
  const dataWriters = {
8
9
  bool() {
@@ -103,20 +104,20 @@ const dataWriters = {
103
104
  },
104
105
  struct(output, schema, value) {
105
106
  const alignment = alignmentOf(schema);
106
- alignIO(output, alignment);
107
+ alignIO_default(output, alignment);
107
108
  for (const [key, property] of Object.entries(schema.propTypes)) {
108
- alignIO(output, alignmentOf(property));
109
+ alignIO_default(output, alignmentOf(property));
109
110
  writeData(output, property, value[key]);
110
111
  }
111
- alignIO(output, alignment);
112
+ alignIO_default(output, alignment);
112
113
  },
113
114
  array(output, schema, value) {
114
115
  if (schema.elementCount === 0) throw new Error("Cannot write using a runtime-sized schema.");
115
116
  const alignment = alignmentOf(schema);
116
- alignIO(output, alignment);
117
+ alignIO_default(output, alignment);
117
118
  const beginning = output.currentByteOffset;
118
119
  for (let i = 0; i < Math.min(schema.elementCount, value.length); i++) {
119
- alignIO(output, alignment);
120
+ alignIO_default(output, alignment);
120
121
  writeData(output, schema.elementType, value[i]);
121
122
  }
122
123
  output.seekTo(beginning + sizeOf(schema));
@@ -128,7 +129,7 @@ const dataWriters = {
128
129
  dataWriters[schema.inner.type]?.(output, schema, value);
129
130
  },
130
131
  decorated(output, schema, value) {
131
- alignIO(output, customAlignmentOf(schema));
132
+ alignIO_default(output, customAlignmentOf(schema));
132
133
  const beginning = output.currentByteOffset;
133
134
  dataWriters[schema.inner?.type]?.(output, schema.inner, value);
134
135
  output.seekTo(beginning + sizeOf(schema));
@@ -320,10 +321,10 @@ const dataWriters = {
320
321
  },
321
322
  disarray(output, schema, value) {
322
323
  const alignment = alignmentOf(schema);
323
- alignIO(output, alignment);
324
+ alignIO_default(output, alignment);
324
325
  const beginning = output.currentByteOffset;
325
326
  for (let i = 0; i < Math.min(schema.elementCount, value.length); i++) {
326
- alignIO(output, alignment);
327
+ alignIO_default(output, alignment);
327
328
  dataWriters[schema.elementType?.type]?.(output, schema.elementType, value[i]);
328
329
  }
329
330
  output.seekTo(beginning + sizeOf(schema));
@@ -333,7 +334,7 @@ const dataWriters = {
333
334
  for (const [key, property] of Object.entries(propTypes)) dataWriters[property.type]?.(output, property, value[key]);
334
335
  },
335
336
  "loose-decorated"(output, schema, value) {
336
- alignIO(output, customAlignmentOf(schema));
337
+ alignIO_default(output, customAlignmentOf(schema));
337
338
  const beginning = output.currentByteOffset;
338
339
  const writer = dataWriters[schema.inner?.type];
339
340
  writer?.(output, schema.inner, value);
@@ -435,14 +436,14 @@ const dataReaders = {
435
436
  },
436
437
  struct(input, schema) {
437
438
  const alignment = alignmentOf(schema);
438
- alignIO(input, alignment);
439
+ alignIO_default(input, alignment);
439
440
  const result = {};
440
441
  const propTypes = schema.propTypes;
441
442
  for (const [key, property] of Object.entries(propTypes)) {
442
- alignIO(input, alignmentOf(property));
443
+ alignIO_default(input, alignmentOf(property));
443
444
  result[key] = readData(input, property);
444
445
  }
445
- alignIO(input, alignment);
446
+ alignIO_default(input, alignment);
446
447
  return result;
447
448
  },
448
449
  array(input, schema) {
@@ -450,12 +451,12 @@ const dataReaders = {
450
451
  const alignment = alignmentOf(schema);
451
452
  const elements = [];
452
453
  for (let i = 0; i < schema.elementCount; i++) {
453
- alignIO(input, alignment);
454
+ alignIO_default(input, alignment);
454
455
  const elementType = schema.elementType;
455
456
  const value = readData(input, elementType);
456
457
  elements.push(value);
457
458
  }
458
- alignIO(input, alignment);
459
+ alignIO_default(input, alignment);
459
460
  return elements;
460
461
  },
461
462
  ptr() {
@@ -465,7 +466,7 @@ const dataReaders = {
465
466
  return readData(input, schema.inner);
466
467
  },
467
468
  decorated(input, schema) {
468
- alignIO(input, customAlignmentOf(schema));
469
+ alignIO_default(input, customAlignmentOf(schema));
469
470
  const beginning = input.currentByteOffset;
470
471
  const value = readData(input, schema.inner);
471
472
  input.seekTo(beginning + sizeOf(schema));
@@ -533,14 +534,14 @@ const dataReaders = {
533
534
  const alignment = alignmentOf(schema);
534
535
  const elements = [];
535
536
  for (let i = 0; i < schema.elementCount; i++) {
536
- alignIO(input, alignment);
537
+ alignIO_default(input, alignment);
537
538
  elements.push(readData(input, schema.elementType));
538
539
  }
539
- alignIO(input, alignment);
540
+ alignIO_default(input, alignment);
540
541
  return elements;
541
542
  },
542
543
  "loose-decorated"(input, schema) {
543
- alignIO(input, customAlignmentOf(schema));
544
+ alignIO_default(input, customAlignmentOf(schema));
544
545
  const beginning = input.currentByteOffset;
545
546
  const value = readData(input, schema.inner);
546
547
  input.seekTo(beginning + sizeOf(schema));
@@ -552,5 +553,6 @@ function readData(input, schema) {
552
553
  if (!reader) throw new Error(`Cannot read data of type '${schema.type}'.`);
553
554
  return reader(input, schema);
554
555
  }
556
+
555
557
  //#endregion
556
- export { readData, writeData };
558
+ export { readData, writeData };
@@ -1,11 +1,16 @@
1
1
  import { TgpuNamable } from "../shared/meta.js";
2
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";
4
6
  import { PackedData } from "./vertexFormatData.js";
7
+ import "../types.js";
5
8
  import { AnyWgslData, BaseData, TypedArrayFor } from "./wgslTypes.js";
9
+ import "./texture.js";
6
10
  import { Infer, InferGPURecord, InferInput, InferInputRecord, InferPartial, InferPartialRecord, InferPatch, InferPatchRecord, InferRecord, IsValidVertexSchema, MemIdentityRecord } from "../shared/repr.js";
7
11
 
8
12
  //#region src/data/dataTypes.d.ts
13
+
9
14
  /**
10
15
  * Array schema constructed via `d.disarrayOf` function.
11
16
  *
@@ -52,13 +57,13 @@ interface Unstruct<out TProps extends Record<string, BaseData> = Record<string,
52
57
  readonly [$validVertexSchema]: { [K in keyof TProps]: IsValidVertexSchema<TProps[K]> }[keyof TProps] extends true ? true : false;
53
58
  readonly [$invalidSchemaReason]: 'Unstructs are not host-shareable, use structs instead';
54
59
  }
55
- interface LooseDecorated<out TInner extends BaseData = BaseData, out TAttribs extends unknown[] = unknown[]> extends BaseData {
60
+ interface LooseDecorated<out TInner$1 extends BaseData = BaseData, out TAttribs extends unknown[] = unknown[]> extends BaseData {
56
61
  readonly type: 'loose-decorated';
57
- readonly inner: TInner;
62
+ readonly inner: TInner$1;
58
63
  readonly attribs: TAttribs;
59
- readonly [$repr]: Infer<TInner>;
64
+ readonly [$repr]: Infer<TInner$1>;
60
65
  readonly [$invalidSchemaReason]: 'Loosely decorated schemas are not host-shareable';
61
- readonly [$validVertexSchema]: IsValidVertexSchema<TInner>;
66
+ readonly [$validVertexSchema]: IsValidVertexSchema<TInner$1>;
62
67
  }
63
68
  /**
64
69
  * Type utility to extract the inner type from decorated types.
package/data/dataTypes.js CHANGED
@@ -2,6 +2,7 @@ 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
+
5
6
  //#region src/data/dataTypes.ts
6
7
  /**
7
8
  * Runtime function to extract the inner data type from decorated types.
@@ -96,5 +97,6 @@ var ConsoleLog = class {
96
97
  setName(this, "consoleLog");
97
98
  }
98
99
  };
100
+
99
101
  //#endregion
100
- export { ConsoleLog, InfixDispatch, MatrixColumnsAccess, UnknownData, getCustomAlignment, getCustomLocation, getCustomSize, isData, isDisarray, isLooseData, isLooseDecorated, isUnstruct, undecorate, unptr };
102
+ export { ConsoleLog, InfixDispatch, MatrixColumnsAccess, UnknownData, getCustomAlignment, getCustomLocation, getCustomSize, isData, isDisarray, isLooseData, isLooseDecorated, isUnstruct, undecorate, unptr };
@@ -1,6 +1,7 @@
1
1
  import { AnyData } from "./dataTypes.js";
2
2
 
3
3
  //#region src/data/deepEqual.d.ts
4
+
4
5
  /**
5
6
  * Performs a deep comparison of two TypeGPU data schemas.
6
7
  *
package/data/deepEqual.js CHANGED
@@ -1,5 +1,6 @@
1
1
  import { isAtomic, isDecorated, isPtr, isWgslArray, isWgslStruct } from "./wgslTypes.js";
2
2
  import { isDisarray, isLooseDecorated, isUnstruct } from "./dataTypes.js";
3
+
3
4
  //#region src/data/deepEqual.ts
4
5
  /**
5
6
  * Performs a deep comparison of two TypeGPU data schemas.
@@ -52,5 +53,6 @@ function deepEqual(a, b) {
52
53
  }
53
54
  return true;
54
55
  }
56
+
55
57
  //#endregion
56
- export { deepEqual };
58
+ export { deepEqual };
@@ -1,5 +1,7 @@
1
1
  import { AnyData, Disarray } from "./dataTypes.js";
2
2
  import { TgpuComptime } from "../core/function/comptime.js";
3
+ import "../indexNamedExports.js";
4
+
3
5
  //#region src/data/disarray.d.ts
4
6
  interface DisarrayConstructor {
5
7
  <TElement extends AnyData>(elementType: TElement): (elementCount: number) => Disarray<TElement>;
@@ -27,6 +29,6 @@ interface DisarrayConstructor {
27
29
  * @param elementType The type of elements in the array.
28
30
  * @param elementCount The number of elements in the array.
29
31
  */
30
- declare const disarrayOf: TgpuComptime;
32
+ declare const disarrayOf: TgpuComptime<DisarrayConstructor>;
31
33
  //#endregion
32
34
  export { disarrayOf };
package/data/disarray.js CHANGED
@@ -1,6 +1,7 @@
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
+
4
5
  //#region src/data/disarray.ts
5
6
  /**
6
7
  * Creates an array schema that can be used to construct vertex buffers.
@@ -46,5 +47,6 @@ const DisarrayImpl = {
46
47
  return `disarrayOf(${this.elementType}, ${this.elementCount})`;
47
48
  }
48
49
  };
50
+
49
51
  //#endregion
50
- export { disarrayOf };
52
+ export { disarrayOf };
@@ -1,6 +1,8 @@
1
+ import "./wgslTypes.js";
1
2
  import { AnyData } from "./dataTypes.js";
2
3
 
3
4
  //#region src/data/getLongestContiguousPrefix.d.ts
5
+
4
6
  /**
5
7
  * Returns the size (in bytes) of the longest contiguous memory prefix of data represented by the `schema`.
6
8
  */
@@ -1,4 +1,5 @@
1
1
  import { getLayoutInfo } from "./schemaMemoryLayout.js";
2
+
2
3
  //#region src/data/getLongestContiguousPrefix.ts
3
4
  function getLongestContiguousPrefix(schema) {
4
5
  return getLayoutInfo(schema, "longestContiguousPrefix");
@@ -9,5 +10,6 @@ function getLongestContiguousPrefix(schema) {
9
10
  function PUBLIC_getLongestContiguousPrefix(schema) {
10
11
  return getLongestContiguousPrefix(schema);
11
12
  }
13
+
12
14
  //#endregion
13
- export { PUBLIC_getLongestContiguousPrefix, getLongestContiguousPrefix };
15
+ export { PUBLIC_getLongestContiguousPrefix, getLongestContiguousPrefix };
package/data/index.d.ts CHANGED
@@ -4,7 +4,7 @@ import { AnyAttribute, HasCustomLocation, IsBuiltin, align, interpolate, invaria
4
4
  import { memoryLayoutOf } from "./offsetUtils.js";
5
5
  import { FormatToAcceptedData, FormatToWGSLType, PackedData, TgpuVertexFormatData, float16, float16x2, float16x4, float32, float32x2, float32x3, float32x4, formatToWGSLType, isPackedData, packedFormats, sint16, sint16x2, sint16x4, sint32, sint32x2, sint32x3, sint32x4, sint8, sint8x2, sint8x4, snorm16, snorm16x2, snorm16x4, snorm8, snorm8x2, snorm8x4, uint16, uint16x2, uint16x4, uint32, uint32x2, uint32x3, uint32x4, uint8, uint8x2, uint8x4, unorm10_10_10_2, unorm16, unorm16x2, unorm16x4, unorm8, unorm8x2, unorm8x4, unorm8x4_bgra } from "./vertexFormatData.js";
6
6
  import { _ref } from "./ref.js";
7
- import { Align, AnyVecInstance, AnyWgslData, AnyWgslStruct, Atomic, BaseData, Bool, Builtin, Decorated, F16, F32, I32, Interpolate, Location, Mat2x2f, Mat3x3f, Mat4x4f, Ptr, Size, StorableData, U16, U32, Vec2b, Vec2f, Vec2h, Vec2i, Vec2u, Vec3b, Vec3f, Vec3h, Vec3i, Vec3u, Vec4b, Vec4f, Vec4h, Vec4i, Vec4u, Void, WgslArray, WgslStruct, atomicI32, atomicU32, isAlignAttrib, isAtomic, isBuiltinAttrib, isDecorated, isInterpolateAttrib, isLocationAttrib, isPtr, isSizeAttrib, isWgslArray, isWgslData, isWgslStruct, m2x2f, m3x3f, m4x4f, matBase, v2b, v2f, v2i, v2u, v3b, v3f, v3i, v3u, v4b, v4f, v4i, v4u, vecBase } from "./wgslTypes.js";
7
+ import { Align, AnyVecInstance, AnyWgslData, AnyWgslStruct, Atomic, BaseData, Bool, Builtin, Decorated, F16, F32, I32, Interpolate, Location, Mat2x2f, Mat3x3f, Mat4x4f, Ptr, Size, StorableData, U16, U32, Vec2b, Vec2f, Vec2h, Vec2i, Vec2u, Vec3b, Vec3f, Vec3h, Vec3i, Vec3u, Vec4b, Vec4f, Vec4h, Vec4i, Vec4u, Void, WgslArray, WgslStruct, atomicI32, atomicU32, isAlignAttrib, isAtomic, isBuiltinAttrib, isDecorated, isInterpolateAttrib, isLocationAttrib, isPtr, isSizeAttrib, isWgslArray, isWgslData, isWgslStruct, m2x2f, m3x3f, m4x4f, matBase, v2b, v2f, v2h, v2i, v2u, v3b, v3f, v3h, v3i, v3u, v4b, v4f, v4h, v4i, v4u, vecBase } from "./wgslTypes.js";
8
8
  import { WgslExternalTexture, WgslStorageTexture, WgslStorageTexture1d, WgslStorageTexture2d, WgslStorageTexture2dArray, WgslStorageTexture3d, WgslStorageTextureProps, WgslTexture, WgslTexture1d, WgslTexture2d, WgslTexture2dArray, WgslTexture3d, WgslTextureCube, WgslTextureCubeArray, WgslTextureDepth2d, WgslTextureDepth2dArray, WgslTextureDepthCube, WgslTextureDepthCubeArray, WgslTextureDepthMultisampled2d, WgslTextureMultisampled2d, texture1d, texture2d, texture2dArray, texture3d, textureCube, textureCubeArray, textureDepth2d, textureDepth2dArray, textureDepthCube, textureDepthCubeArray, textureDepthMultisampled2d, textureExternal, textureMultisampled2d, textureStorage1d, textureStorage2d, textureStorage2dArray, textureStorage3d } from "./texture.js";
9
9
  import { Infer, InferGPU, InferInput, InferPartial, InferPatch } from "../shared/repr.js";
10
10
  import { AnyData, AnyLooseData, Disarray, LooseDecorated, Unstruct, isData, isDisarray, isLooseData, isLooseDecorated, isUnstruct } from "./dataTypes.js";
@@ -25,7 +25,7 @@ import { deepEqual } from "./deepEqual.js";
25
25
 
26
26
  //#region src/data/index.d.ts
27
27
  declare namespace index_d_exports {
28
- export { Align, AnyAttribute, AnyBuiltin, AnyData, AnyLooseData, AnyVecInstance, AnyWgslData, AnyWgslStruct, Atomic, BaseData, BaseData as BaseWgslData, Bool, Builtin, BuiltinClipDistances, BuiltinFragDepth, BuiltinFrontFacing, BuiltinGlobalInvocationId, BuiltinInstanceIndex, BuiltinLocalInvocationId, BuiltinLocalInvocationIndex, BuiltinNumWorkgroups, BuiltinPosition, BuiltinSampleIndex, BuiltinSampleMask, BuiltinVertexIndex, BuiltinWorkgroupId, Decorated, Disarray, F16, F32, FormatToAcceptedData, FormatToWGSLType, HasCustomLocation, I32, Infer, InferGPU, InferInput, InferPartial, InferPatch, Interpolate, IsBuiltin, Location, LooseDecorated, Mat2x2f, Mat3x3f, Mat4x4f, PackedData, Ptr, Size, StorableData, TgpuVertexFormatData, U16, U32, Unstruct, Vec2b, Vec2f, Vec2h, Vec2i, Vec2u, Vec3b, Vec3f, Vec3h, Vec3i, Vec3u, Vec4b, Vec4f, Vec4h, Vec4i, Vec4u, Void, WgslArray, WgslComparisonSampler, WgslExternalTexture, WgslSampler, WgslStorageTexture, WgslStorageTexture1d, WgslStorageTexture2d, WgslStorageTexture2dArray, WgslStorageTexture3d, WgslStorageTextureProps, WgslStruct, WgslTexture, WgslTexture1d, WgslTexture2d, WgslTexture2dArray, WgslTexture3d, WgslTextureCube, WgslTextureCubeArray, WgslTextureDepth2d, WgslTextureDepth2dArray, WgslTextureDepthCube, WgslTextureDepthCubeArray, WgslTextureDepthMultisampled2d, WgslTextureMultisampled2d, align, PUBLIC_alignmentOf as alignmentOf, arrayOf, atomic, atomicI32, atomicU32, bool, builtin, comparisonSampler, deepEqual, disarrayOf, f16, f32, float16, float16x2, float16x4, float32, float32x2, float32x3, float32x4, formatToWGSLType, PUBLIC_getLongestContiguousPrefix as getLongestContiguousPrefix, i32, interpolate, invariant, isAlignAttrib, isAtomic, isBuiltin, isBuiltinAttrib, PUBLIC_isContiguous as isContiguous, isData, isDecorated, isDisarray, isInterpolateAttrib, isLocationAttrib, isLooseData, isLooseDecorated, isPackedData, isPtr, isSizeAttrib, isUnstruct, isWgslArray, isWgslData, isWgslStruct, location, m2x2f, m3x3f, m4x4f, mat2x2f, mat3x3f, mat4x4f, matBase, matToArray, memoryLayoutOf, packedFormats, ptrFn, ptrHandle, ptrPrivate, ptrStorage, ptrUniform, ptrWorkgroup, _ref as ref, sampler, sint16, sint16x2, sint16x4, sint32, sint32x2, sint32x3, sint32x4, sint8, sint8x2, sint8x4, size, PUBLIC_sizeOf as sizeOf, snorm16, snorm16x2, snorm16x4, snorm8, snorm8x2, snorm8x4, struct, texture1d, texture2d, texture2dArray, texture3d, textureCube, textureCubeArray, textureDepth2d, textureDepth2dArray, textureDepthCube, textureDepthCubeArray, textureDepthMultisampled2d, textureExternal, textureMultisampled2d, textureStorage1d, textureStorage2d, textureStorage2dArray, textureStorage3d, u16, u32, uint16, uint16x2, uint16x4, uint32, uint32x2, uint32x3, uint32x4, uint8, uint8x2, uint8x4, unorm10_10_10_2, unorm16, unorm16x2, unorm16x4, unorm8, unorm8x2, unorm8x4, unorm8x4_bgra, unstruct, v2b, v2f, v2i, v2u, v3b, v3f, v3i, v3u, v4b, v4f, v4i, v4u, vec2b, vec2f, vec2h, vec2i, vec2u, vec3b, vec3f, vec3h, vec3i, vec3u, vec4b, vec4f, vec4h, vec4i, vec4u, vecBase };
28
+ export { Align, AnyAttribute, AnyBuiltin, AnyData, AnyLooseData, AnyVecInstance, AnyWgslData, AnyWgslStruct, Atomic, BaseData, BaseData as BaseWgslData, Bool, Builtin, BuiltinClipDistances, BuiltinFragDepth, BuiltinFrontFacing, BuiltinGlobalInvocationId, BuiltinInstanceIndex, BuiltinLocalInvocationId, BuiltinLocalInvocationIndex, BuiltinNumWorkgroups, BuiltinPosition, BuiltinSampleIndex, BuiltinSampleMask, BuiltinVertexIndex, BuiltinWorkgroupId, Decorated, Disarray, F16, F32, FormatToAcceptedData, FormatToWGSLType, HasCustomLocation, I32, Infer, InferGPU, InferInput, InferPartial, InferPatch, Interpolate, IsBuiltin, Location, LooseDecorated, Mat2x2f, Mat3x3f, Mat4x4f, PackedData, Ptr, Size, StorableData, TgpuVertexFormatData, U16, U32, Unstruct, Vec2b, Vec2f, Vec2h, Vec2i, Vec2u, Vec3b, Vec3f, Vec3h, Vec3i, Vec3u, Vec4b, Vec4f, Vec4h, Vec4i, Vec4u, Void, WgslArray, WgslComparisonSampler, WgslExternalTexture, WgslSampler, WgslStorageTexture, WgslStorageTexture1d, WgslStorageTexture2d, WgslStorageTexture2dArray, WgslStorageTexture3d, WgslStorageTextureProps, WgslStruct, WgslTexture, WgslTexture1d, WgslTexture2d, WgslTexture2dArray, WgslTexture3d, WgslTextureCube, WgslTextureCubeArray, WgslTextureDepth2d, WgslTextureDepth2dArray, WgslTextureDepthCube, WgslTextureDepthCubeArray, WgslTextureDepthMultisampled2d, WgslTextureMultisampled2d, align, PUBLIC_alignmentOf as alignmentOf, arrayOf, atomic, atomicI32, atomicU32, bool, builtin, comparisonSampler, deepEqual, disarrayOf, f16, f32, float16, float16x2, float16x4, float32, float32x2, float32x3, float32x4, formatToWGSLType, PUBLIC_getLongestContiguousPrefix as getLongestContiguousPrefix, i32, interpolate, invariant, isAlignAttrib, isAtomic, isBuiltin, isBuiltinAttrib, PUBLIC_isContiguous as isContiguous, isData, isDecorated, isDisarray, isInterpolateAttrib, isLocationAttrib, isLooseData, isLooseDecorated, isPackedData, isPtr, isSizeAttrib, isUnstruct, isWgslArray, isWgslData, isWgslStruct, location, m2x2f, m3x3f, m4x4f, mat2x2f, mat3x3f, mat4x4f, matBase, matToArray, memoryLayoutOf, packedFormats, ptrFn, ptrHandle, ptrPrivate, ptrStorage, ptrUniform, ptrWorkgroup, _ref as ref, sampler, sint16, sint16x2, sint16x4, sint32, sint32x2, sint32x3, sint32x4, sint8, sint8x2, sint8x4, size, PUBLIC_sizeOf as sizeOf, snorm16, snorm16x2, snorm16x4, snorm8, snorm8x2, snorm8x4, struct, texture1d, texture2d, texture2dArray, texture3d, textureCube, textureCubeArray, textureDepth2d, textureDepth2dArray, textureDepthCube, textureDepthCubeArray, textureDepthMultisampled2d, textureExternal, textureMultisampled2d, textureStorage1d, textureStorage2d, textureStorage2dArray, textureStorage3d, u16, u32, uint16, uint16x2, uint16x4, uint32, uint32x2, uint32x3, uint32x4, uint8, uint8x2, uint8x4, unorm10_10_10_2, unorm16, unorm16x2, unorm16x4, unorm8, unorm8x2, unorm8x4, unorm8x4_bgra, unstruct, v2b, v2f, v2h, v2i, v2u, v3b, v3f, v3h, v3i, v3u, v4b, v4f, v4h, v4i, v4u, vec2b, vec2f, vec2h, vec2i, vec2u, vec3b, vec3f, vec3h, vec3i, vec3u, vec4b, vec4f, vec4h, vec4i, vec4u, vecBase };
29
29
  }
30
30
  //#endregion
31
- export { type Align, type AnyAttribute, type AnyBuiltin, type AnyData, type AnyLooseData, type AnyVecInstance, type AnyWgslData, type AnyWgslStruct, type Atomic, type BaseData, type BaseData as BaseWgslData, type Bool, type Builtin, type BuiltinClipDistances, type BuiltinFragDepth, type BuiltinFrontFacing, type BuiltinGlobalInvocationId, type BuiltinInstanceIndex, type BuiltinLocalInvocationId, type BuiltinLocalInvocationIndex, type BuiltinNumWorkgroups, type BuiltinPosition, type BuiltinSampleIndex, type BuiltinSampleMask, type BuiltinVertexIndex, type BuiltinWorkgroupId, type Decorated, type Disarray, type F16, type F32, FormatToAcceptedData, FormatToWGSLType, type HasCustomLocation, type I32, type Infer, type InferGPU, type InferInput, type InferPartial, type InferPatch, type Interpolate, type IsBuiltin, type Location, type LooseDecorated, type Mat2x2f, type Mat3x3f, type Mat4x4f, PackedData, type Ptr, type Size, type StorableData, TgpuVertexFormatData, type U16, type U32, type Unstruct, type Vec2b, type Vec2f, type Vec2h, type Vec2i, type Vec2u, type Vec3b, type Vec3f, type Vec3h, type Vec3i, type Vec3u, type Vec4b, type Vec4f, type Vec4h, type Vec4i, type Vec4u, Void, type WgslArray, type WgslComparisonSampler, type WgslExternalTexture, type WgslSampler, type WgslStorageTexture, type WgslStorageTexture1d, type WgslStorageTexture2d, type WgslStorageTexture2dArray, type WgslStorageTexture3d, type WgslStorageTextureProps, type WgslStruct, type WgslTexture, type WgslTexture1d, type WgslTexture2d, type WgslTexture2dArray, type WgslTexture3d, type WgslTextureCube, type WgslTextureCubeArray, type WgslTextureDepth2d, type WgslTextureDepth2dArray, type WgslTextureDepthCube, type WgslTextureDepthCubeArray, type WgslTextureDepthMultisampled2d, type WgslTextureMultisampled2d, align, PUBLIC_alignmentOf as alignmentOf, arrayOf, atomic, type atomicI32, type atomicU32, bool, builtin, comparisonSampler, deepEqual, disarrayOf, f16, f32, float16, float16x2, float16x4, float32, float32x2, float32x3, float32x4, formatToWGSLType, PUBLIC_getLongestContiguousPrefix as getLongestContiguousPrefix, i32, index_d_exports, interpolate, invariant, isAlignAttrib, isAtomic, isBuiltin, isBuiltinAttrib, PUBLIC_isContiguous as isContiguous, isData, isDecorated, isDisarray, isInterpolateAttrib, isLocationAttrib, isLooseData, isLooseDecorated, isPackedData, isPtr, isSizeAttrib, isUnstruct, isWgslArray, isWgslData, isWgslStruct, location, type m2x2f, type m3x3f, type m4x4f, mat2x2f, mat3x3f, mat4x4f, type matBase, matToArray, memoryLayoutOf, packedFormats, ptrFn, ptrHandle, ptrPrivate, ptrStorage, ptrUniform, ptrWorkgroup, _ref as ref, sampler, sint16, sint16x2, sint16x4, sint32, sint32x2, sint32x3, sint32x4, sint8, sint8x2, sint8x4, size, PUBLIC_sizeOf as sizeOf, snorm16, snorm16x2, snorm16x4, snorm8, snorm8x2, snorm8x4, struct, texture1d, texture2d, texture2dArray, texture3d, textureCube, textureCubeArray, textureDepth2d, textureDepth2dArray, textureDepthCube, textureDepthCubeArray, textureDepthMultisampled2d, textureExternal, textureMultisampled2d, textureStorage1d, textureStorage2d, textureStorage2dArray, textureStorage3d, u16, u32, uint16, uint16x2, uint16x4, uint32, uint32x2, uint32x3, uint32x4, uint8, uint8x2, uint8x4, unorm10_10_10_2, unorm16, unorm16x2, unorm16x4, unorm8, unorm8x2, unorm8x4, unorm8x4_bgra, unstruct, type v2b, type v2f, type v2i, type v2u, type v3b, type v3f, type v3i, type v3u, type v4b, type v4f, type v4i, type v4u, vec2b, vec2f, vec2h, vec2i, vec2u, vec3b, vec3f, vec3h, vec3i, vec3u, vec4b, vec4f, vec4h, vec4i, vec4u, type vecBase };
31
+ export { type Align, type AnyAttribute, type AnyBuiltin, type AnyData, type AnyLooseData, type AnyVecInstance, type AnyWgslData, type AnyWgslStruct, type Atomic, type BaseData, type BaseData as BaseWgslData, type Bool, type Builtin, type BuiltinClipDistances, type BuiltinFragDepth, type BuiltinFrontFacing, type BuiltinGlobalInvocationId, type BuiltinInstanceIndex, type BuiltinLocalInvocationId, type BuiltinLocalInvocationIndex, type BuiltinNumWorkgroups, type BuiltinPosition, type BuiltinSampleIndex, type BuiltinSampleMask, type BuiltinVertexIndex, type BuiltinWorkgroupId, type Decorated, type Disarray, type F16, type F32, FormatToAcceptedData, FormatToWGSLType, type HasCustomLocation, type I32, type Infer, type InferGPU, type InferInput, type InferPartial, type InferPatch, type Interpolate, type IsBuiltin, type Location, type LooseDecorated, type Mat2x2f, type Mat3x3f, type Mat4x4f, PackedData, type Ptr, type Size, type StorableData, TgpuVertexFormatData, type U16, type U32, type Unstruct, type Vec2b, type Vec2f, type Vec2h, type Vec2i, type Vec2u, type Vec3b, type Vec3f, type Vec3h, type Vec3i, type Vec3u, type Vec4b, type Vec4f, type Vec4h, type Vec4i, type Vec4u, Void, type WgslArray, type WgslComparisonSampler, type WgslExternalTexture, type WgslSampler, type WgslStorageTexture, type WgslStorageTexture1d, type WgslStorageTexture2d, type WgslStorageTexture2dArray, type WgslStorageTexture3d, type WgslStorageTextureProps, type WgslStruct, type WgslTexture, type WgslTexture1d, type WgslTexture2d, type WgslTexture2dArray, type WgslTexture3d, type WgslTextureCube, type WgslTextureCubeArray, type WgslTextureDepth2d, type WgslTextureDepth2dArray, type WgslTextureDepthCube, type WgslTextureDepthCubeArray, type WgslTextureDepthMultisampled2d, type WgslTextureMultisampled2d, align, PUBLIC_alignmentOf as alignmentOf, arrayOf, atomic, type atomicI32, type atomicU32, bool, builtin, comparisonSampler, deepEqual, disarrayOf, f16, f32, float16, float16x2, float16x4, float32, float32x2, float32x3, float32x4, formatToWGSLType, PUBLIC_getLongestContiguousPrefix as getLongestContiguousPrefix, i32, index_d_exports, interpolate, invariant, isAlignAttrib, isAtomic, isBuiltin, isBuiltinAttrib, PUBLIC_isContiguous as isContiguous, isData, isDecorated, isDisarray, isInterpolateAttrib, isLocationAttrib, isLooseData, isLooseDecorated, isPackedData, isPtr, isSizeAttrib, isUnstruct, isWgslArray, isWgslData, isWgslStruct, location, type m2x2f, type m3x3f, type m4x4f, mat2x2f, mat3x3f, mat4x4f, type matBase, matToArray, memoryLayoutOf, packedFormats, ptrFn, ptrHandle, ptrPrivate, ptrStorage, ptrUniform, ptrWorkgroup, _ref as ref, sampler, sint16, sint16x2, sint16x4, sint32, sint32x2, sint32x3, sint32x4, sint8, sint8x2, sint8x4, size, PUBLIC_sizeOf as sizeOf, snorm16, snorm16x2, snorm16x4, snorm8, snorm8x2, snorm8x4, struct, texture1d, texture2d, texture2dArray, texture3d, textureCube, textureCubeArray, textureDepth2d, textureDepth2dArray, textureDepthCube, textureDepthCubeArray, textureDepthMultisampled2d, textureExternal, textureMultisampled2d, textureStorage1d, textureStorage2d, textureStorage2dArray, textureStorage3d, u16, u32, uint16, uint16x2, uint16x4, uint32, uint32x2, uint32x3, uint32x4, uint8, uint8x2, uint8x4, unorm10_10_10_2, unorm16, unorm16x2, unorm16x4, unorm8, unorm8x2, unorm8x4, unorm8x4_bgra, unstruct, type v2b, type v2f, type v2h, type v2i, type v2u, type v3b, type v3f, type v3h, type v3i, type v3u, type v4b, type v4f, type v4h, type v4i, type v4u, vec2b, vec2f, vec2h, vec2i, vec2u, vec3b, vec3f, vec3h, vec3i, vec3u, vec4b, vec4f, vec4h, vec4i, vec4u, type vecBase };
package/data/index.js CHANGED
@@ -1,4 +1,4 @@
1
- import { __exportAll } from "../_virtual/_rolldown/runtime.js";
1
+ import { __export } from "../_virtual/rolldown_runtime.js";
2
2
  import { Void, isAlignAttrib, isAtomic, isBuiltinAttrib, isDecorated, isInterpolateAttrib, isLocationAttrib, isPtr, isSizeAttrib, isWgslArray, isWgslData, isWgslStruct } from "./wgslTypes.js";
3
3
  import { isData, isDisarray, isLooseData, isLooseDecorated, isUnstruct } from "./dataTypes.js";
4
4
  import { ptrFn, ptrHandle, ptrPrivate, ptrStorage, ptrUniform, ptrWorkgroup } from "./ptr.js";
@@ -25,11 +25,9 @@ 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
+
28
29
  //#region src/data/index.ts
29
- /**
30
- * @module typegpu/data
31
- */
32
- var data_exports = /* @__PURE__ */ __exportAll({
30
+ var data_exports = /* @__PURE__ */ __export({
33
31
  Void: () => Void,
34
32
  align: () => align,
35
33
  alignmentOf: () => PUBLIC_alignmentOf,
@@ -188,5 +186,6 @@ assignInfixOperator(MatBase, "mul", Operator.star);
188
186
  return infixOperators.bitShiftRight(this, other);
189
187
  };
190
188
  }
189
+
191
190
  //#endregion
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 };
191
+ 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,6 +1,8 @@
1
+ import "./wgslTypes.js";
1
2
  import { AnyData } from "./dataTypes.js";
2
3
 
3
4
  //#region src/data/isContiguous.d.ts
5
+
4
6
  /**
5
7
  * Returns `true` if data represented by the `schema` doesn't have padding.
6
8
  */
@@ -1,4 +1,5 @@
1
1
  import { getLayoutInfo } from "./schemaMemoryLayout.js";
2
+
2
3
  //#region src/data/isContiguous.ts
3
4
  function isContiguous(schema) {
4
5
  return getLayoutInfo(schema, "isContiguous");
@@ -9,5 +10,6 @@ function isContiguous(schema) {
9
10
  function PUBLIC_isContiguous(schema) {
10
11
  return isContiguous(schema);
11
12
  }
13
+
12
14
  //#endregion
13
- export { PUBLIC_isContiguous, isContiguous };
15
+ export { PUBLIC_isContiguous, isContiguous };
package/data/matrix.d.ts CHANGED
@@ -1,52 +1,55 @@
1
1
  import { DualFn } from "../types.js";
2
2
  import { Mat2x2f, Mat3x3f, Mat4x4f, m2x2f, m3x3f, m4x4f, v3f } from "./wgslTypes.js";
3
3
  import { TgpuComptime } from "../core/function/comptime.js";
4
+ import "../indexNamedExports.js";
5
+
4
6
  //#region src/data/matrix.d.ts
7
+
5
8
  /**
6
9
  * Returns a 2-by-2 identity matrix.
7
10
  * @returns {m2x2f} The result matrix.
8
11
  */
9
- declare const identity2: TgpuComptime;
12
+ declare const identity2: TgpuComptime<() => m2x2f>;
10
13
  /**
11
14
  * Returns a 3-by-3 identity matrix.
12
15
  * @returns {m3x3f} The result matrix.
13
16
  */
14
- declare const identity3: TgpuComptime;
17
+ declare const identity3: TgpuComptime<() => m3x3f>;
15
18
  /**
16
19
  * Returns a 4-by-4 identity matrix.
17
20
  * @returns {m4x4f} The result matrix.
18
21
  */
19
- declare const identity4: TgpuComptime;
22
+ declare const identity4: TgpuComptime<() => m4x4f>;
20
23
  /**
21
24
  * Creates a 4-by-4 matrix which translates by the given vector v.
22
25
  * @param {v3f} vector - The vector by which to translate.
23
26
  * @returns {m4x4f} The translation matrix.
24
27
  */
25
- declare const translation4: DualFn;
28
+ declare const translation4: DualFn<(vector: v3f) => m4x4f>;
26
29
  /**
27
30
  * Creates a 4-by-4 matrix which scales in each dimension by an amount given by the corresponding entry in the given vector.
28
31
  * @param {v3f} vector - A vector of three entries specifying the factor by which to scale in each dimension.
29
32
  * @returns {m4x4f} The scaling matrix.
30
33
  */
31
- declare const scaling4: DualFn;
34
+ declare const scaling4: DualFn<(vector: v3f) => m4x4f>;
32
35
  /**
33
36
  * Creates a 4-by-4 matrix which rotates around the x-axis by the given angle.
34
37
  * @param {number} angle - The angle by which to rotate (in radians).
35
38
  * @returns {m4x4f} The rotation matrix.
36
39
  */
37
- declare const rotationX4: DualFn;
40
+ declare const rotationX4: DualFn<(a: number) => m4x4f>;
38
41
  /**
39
42
  * Creates a 4-by-4 matrix which rotates around the y-axis by the given angle.
40
43
  * @param {number} angle - The angle by which to rotate (in radians).
41
44
  * @returns {m4x4f} The rotation matrix.
42
45
  */
43
- declare const rotationY4: DualFn;
46
+ declare const rotationY4: DualFn<(a: number) => m4x4f>;
44
47
  /**
45
48
  * Creates a 4-by-4 matrix which rotates around the z-axis by the given angle.
46
49
  * @param {number} angle - The angle by which to rotate (in radians).
47
50
  * @returns {m4x4f} The rotation matrix.
48
51
  */
49
- declare const rotationZ4: DualFn;
52
+ declare const rotationZ4: DualFn<(a: number) => m4x4f>;
50
53
  /**
51
54
  * Schema representing mat2x2f - a matrix with 2 rows and 2 columns, with elements of type f32.
52
55
  * Also a constructor function for this matrix type.