typegpu 0.11.1 → 0.11.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (212) 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 +3 -1
  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 +3 -1
  22. package/core/function/extractArgs.js +2 -1
  23. package/core/function/fnCore.js +8 -6
  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 +3 -1
  29. package/core/function/templateUtils.js +2 -1
  30. package/core/function/tgpuComputeFn.d.ts +1 -0
  31. package/core/function/tgpuComputeFn.js +3 -1
  32. package/core/function/tgpuFn.d.ts +1 -0
  33. package/core/function/tgpuFn.js +16 -14
  34. package/core/function/tgpuFragmentFn.js +3 -1
  35. package/core/function/tgpuVertexFn.js +3 -1
  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.js +5 -6
  105. package/data/isContiguous.d.ts +2 -0
  106. package/data/isContiguous.js +3 -1
  107. package/data/matrix.d.ts +11 -8
  108. package/data/matrix.js +3 -1
  109. package/data/numberOps.js +2 -1
  110. package/data/numeric.d.ts +1 -0
  111. package/data/numeric.js +3 -1
  112. package/data/offsetUtils.d.ts +1 -0
  113. package/data/offsetUtils.js +3 -1
  114. package/data/offsets.js +5 -3
  115. package/data/partialIO.js +3 -1
  116. package/data/ptr.d.ts +1 -0
  117. package/data/ptr.js +3 -1
  118. package/data/ref.d.ts +3 -0
  119. package/data/ref.js +5 -3
  120. package/data/sampler.js +3 -1
  121. package/data/schemaCallWrapper.js +3 -1
  122. package/data/schemaMemoryLayout.js +3 -1
  123. package/data/sizeOf.d.ts +2 -0
  124. package/data/sizeOf.js +3 -1
  125. package/data/snippet.js +3 -1
  126. package/data/struct.d.ts +1 -0
  127. package/data/struct.js +3 -1
  128. package/data/texture.js +3 -1
  129. package/data/unstruct.d.ts +1 -0
  130. package/data/unstruct.js +3 -1
  131. package/data/vector.d.ts +1 -0
  132. package/data/vector.js +3 -1
  133. package/data/vectorImpl.js +3 -1
  134. package/data/vectorOps.js +3 -1
  135. package/data/vertexFormatData.js +3 -1
  136. package/data/wgslTypes.d.ts +2 -0
  137. package/data/wgslTypes.js +3 -1
  138. package/errors.d.ts +1 -0
  139. package/errors.js +3 -1
  140. package/execMode.js +3 -1
  141. package/extension.d.ts +1 -0
  142. package/extension.js +3 -1
  143. package/getGPUValue.js +3 -1
  144. package/index.js +3 -4
  145. package/indexNamedExports.d.ts +1 -0
  146. package/mathUtils.js +2 -1
  147. package/memo.js +2 -1
  148. package/nameRegistry.js +3 -1
  149. package/package.js +3 -2
  150. package/package.json +1 -1
  151. package/resolutionCtx.d.ts +11 -0
  152. package/resolutionCtx.js +6 -4
  153. package/shared/env.js +2 -1
  154. package/shared/generators.js +2 -1
  155. package/shared/meta.js +3 -1
  156. package/shared/repr.d.ts +1 -0
  157. package/shared/stringify.js +3 -1
  158. package/shared/symbols.js +42 -10
  159. package/shared/utilityTypes.js +2 -1
  160. package/shared/vertexFormat.js +2 -1
  161. package/std/array.d.ts +1 -1
  162. package/std/array.js +3 -1
  163. package/std/atomic.d.ts +12 -12
  164. package/std/atomic.js +3 -1
  165. package/std/bitcast.d.ts +2 -2
  166. package/std/bitcast.js +3 -1
  167. package/std/boolean.d.ts +15 -14
  168. package/std/boolean.js +3 -1
  169. package/std/derivative.d.ts +9 -9
  170. package/std/derivative.js +3 -1
  171. package/std/discard.d.ts +1 -1
  172. package/std/discard.js +3 -1
  173. package/std/extensions.d.ts +3 -1
  174. package/std/extensions.js +3 -1
  175. package/std/index.js +5 -3
  176. package/std/matrix.d.ts +6 -5
  177. package/std/matrix.js +3 -1
  178. package/std/numeric.d.ts +132 -78
  179. package/std/numeric.js +7 -5
  180. package/std/operators.d.ts +8 -8
  181. package/std/operators.js +7 -5
  182. package/std/packing.d.ts +5 -4
  183. package/std/packing.js +3 -1
  184. package/std/range.d.ts +3 -1
  185. package/std/range.js +3 -1
  186. package/std/subgroup.d.ts +21 -21
  187. package/std/subgroup.js +3 -1
  188. package/std/texture.d.ts +11 -11
  189. package/std/texture.js +9 -7
  190. package/tgpu.js +5 -3
  191. package/tgpuBindGroupLayout.d.ts +11 -7
  192. package/tgpuBindGroupLayout.js +3 -1
  193. package/tgpuUnstable.js +5 -3
  194. package/tgsl/accessIndex.js +3 -1
  195. package/tgsl/accessProp.js +3 -1
  196. package/tgsl/consoleLog/deserializers.js +3 -1
  197. package/tgsl/consoleLog/logGenerator.js +3 -1
  198. package/tgsl/consoleLog/serializers.js +3 -1
  199. package/tgsl/consoleLog/types.d.ts +3 -0
  200. package/tgsl/consoleLog/types.js +2 -1
  201. package/tgsl/conversion.js +3 -1
  202. package/tgsl/forOfUtils.js +3 -1
  203. package/tgsl/generationHelpers.d.ts +1 -0
  204. package/tgsl/generationHelpers.js +3 -1
  205. package/tgsl/math.js +3 -1
  206. package/tgsl/shaderGenerator.d.ts +2 -0
  207. package/tgsl/shaderGenerator_members.js +5 -3
  208. package/tgsl/shellless.js +3 -1
  209. package/tgsl/wgslGenerator.js +21 -18
  210. package/types.d.ts +0 -1
  211. package/types.js +3 -1
  212. package/wgslExtensions.js +2 -1
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.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.
package/data/matrix.js CHANGED
@@ -7,6 +7,7 @@ import { numericLiteralToSnippet } from "../tgsl/generationHelpers.js";
7
7
  import { vec2f, vec3f, vec4f } from "./vector.js";
8
8
  import { dualImpl } from "../core/function/dualImpl.js";
9
9
  import { comptime } from "../core/function/comptime.js";
10
+
10
11
  //#region src/data/matrix.ts
11
12
  var MatBase = class {};
12
13
  function createMatSchema(options) {
@@ -527,5 +528,6 @@ function matToArray(mat) {
527
528
  ];
528
529
  return Array.from({ length: mat.length }).map((_, idx) => mat[idx]);
529
530
  }
531
+
530
532
  //#endregion
531
- export { MatBase, identity2, identity3, identity4, mat2x2f, mat3x3f, mat4x4f, matToArray, rotationX4, rotationY4, rotationZ4, scaling4, translation4 };
533
+ export { MatBase, identity2, identity3, identity4, mat2x2f, mat3x3f, mat4x4f, matToArray, rotationX4, rotationY4, rotationZ4, scaling4, translation4 };
package/data/numberOps.js CHANGED
@@ -19,5 +19,6 @@ function bitcastU32toI32Impl(n) {
19
19
  dataView.setUint32(0, n, true);
20
20
  return dataView.getInt32(0, true);
21
21
  }
22
+
22
23
  //#endregion
23
- export { bitcastU32toF32Impl, bitcastU32toI32Impl, clamp, divInteger, smoothstepScalar };
24
+ export { bitcastU32toF32Impl, bitcastU32toI32Impl, clamp, divInteger, smoothstepScalar };
package/data/numeric.d.ts CHANGED
@@ -1,6 +1,7 @@
1
1
  import { Bool, F16, F32, I32, U16, U32 } from "./wgslTypes.js";
2
2
 
3
3
  //#region src/data/numeric.d.ts
4
+
4
5
  /**
5
6
  * A schema that represents a boolean value. (equivalent to `bool` in WGSL)
6
7
  *
package/data/numeric.js CHANGED
@@ -1,5 +1,6 @@
1
1
  import { $internal } from "../shared/symbols.js";
2
2
  import { callableSchema } from "../core/function/createCallableSchema.js";
3
+
3
4
  //#region src/data/numeric.ts
4
5
  const abstractInt = {
5
6
  [$internal]: {},
@@ -217,5 +218,6 @@ const f16 = Object.assign(f16Cast, {
217
218
  [$internal]: {},
218
219
  type: "f16"
219
220
  });
221
+
220
222
  //#endregion
221
- export { abstractFloat, abstractInt, bool, f16, f32, i32, u16, u32 };
223
+ export { abstractFloat, abstractInt, bool, f16, f32, i32, u16, u32 };
@@ -2,6 +2,7 @@ import { BaseData } from "./wgslTypes.js";
2
2
  import { Infer } from "../shared/repr.js";
3
3
 
4
4
  //#region src/data/offsetUtils.d.ts
5
+
5
6
  /**
6
7
  * Interface containing information about the offset and the available contiguous after a selected primitive.
7
8
  */
@@ -6,6 +6,7 @@ import { sizeOf } from "./sizeOf.js";
6
6
  import { offsetsForProps } from "./offsets.js";
7
7
  import { isContiguous } from "./isContiguous.js";
8
8
  import { getLongestContiguousPrefix } from "./getLongestContiguousPrefix.js";
9
+
9
10
  //#region src/data/offsetUtils.ts
10
11
  const OFFSET_MARKER = Symbol("indirectOffset");
11
12
  const CONTIGUOUS_MARKER = Symbol("indirectContiguous");
@@ -161,5 +162,6 @@ function memoryLayoutOf(schema, accessor) {
161
162
  };
162
163
  throw new Error("memoryLayoutOf: accessor did not return a schema element. Make sure the accessor navigates to a field or element of the schema (e.g. `(s) => s.position.x`).");
163
164
  }
165
+
164
166
  //#endregion
165
- export { memoryLayoutOf };
167
+ export { memoryLayoutOf };
package/data/offsets.js CHANGED
@@ -2,8 +2,9 @@ import { isUnstruct } from "./dataTypes.js";
2
2
  import { alignmentOf, customAlignmentOf } from "./alignmentOf.js";
3
3
  import { roundUp } from "../mathUtils.js";
4
4
  import { sizeOf } from "./sizeOf.js";
5
- import alignIO from "./alignIO.js";
5
+ import alignIO_default from "./alignIO.js";
6
6
  import { Measurer } from "typed-binary";
7
+
7
8
  //#region src/data/offsets.ts
8
9
  const cachedOffsets = /* @__PURE__ */ new WeakMap();
9
10
  function offsetsForProps(struct) {
@@ -16,7 +17,7 @@ function offsetsForProps(struct) {
16
17
  const prop = struct.propTypes[key];
17
18
  if (prop === void 0) throw new Error(`Property ${key} is undefined in struct`);
18
19
  const beforeAlignment = measurer.size;
19
- alignIO(measurer, isUnstruct(struct) ? customAlignmentOf(prop) : alignmentOf(prop));
20
+ alignIO_default(measurer, isUnstruct(struct) ? customAlignmentOf(prop) : alignmentOf(prop));
20
21
  if (lastEntry) lastEntry.padding = measurer.size - beforeAlignment;
21
22
  const propSize = sizeOf(prop);
22
23
  offsets[key] = {
@@ -30,5 +31,6 @@ function offsetsForProps(struct) {
30
31
  cachedOffsets.set(struct, offsets);
31
32
  return offsets;
32
33
  }
34
+
33
35
  //#endregion
34
- export { offsetsForProps };
36
+ export { offsetsForProps };
package/data/partialIO.js CHANGED
@@ -7,6 +7,7 @@ import { offsetsForProps } from "./offsets.js";
7
7
  import { getCompiledWriter } from "./compiledIO.js";
8
8
  import { writeData } from "./dataIO.js";
9
9
  import { BufferWriter, getSystemEndianness } from "typed-binary";
10
+
10
11
  //#region src/data/partialIO.ts
11
12
  /**
12
13
  * Converts `{idx, value}[]` sparse arrays into `Record<number, T>` format.
@@ -109,5 +110,6 @@ function getPatchInstructions(schema, data, targetBuffer) {
109
110
  });
110
111
  return instructions;
111
112
  }
113
+
112
114
  //#endregion
113
- export { convertPartialToPatch, getPatchInstructions };
115
+ export { convertPartialToPatch, getPatchInstructions };
package/data/ptr.d.ts CHANGED
@@ -1,3 +1,4 @@
1
+ import "./snippet.js";
1
2
  import { Ptr, StorableData } from "./wgslTypes.js";
2
3
 
3
4
  //#region src/data/ptr.d.ts
package/data/ptr.js CHANGED
@@ -1,5 +1,6 @@
1
1
  import { $internal } from "../shared/symbols.js";
2
2
  import { originToPtrParams } from "./snippet.js";
3
+
3
4
  //#region src/data/ptr.ts
4
5
  function ptrFn(inner) {
5
6
  return INTERNAL_createPtr("function", inner, "read-write");
@@ -40,5 +41,6 @@ function implicitFrom(ptr) {
40
41
  function explicitFrom(ptr) {
41
42
  return INTERNAL_createPtr(ptr.addressSpace, ptr.inner, ptr.access, false);
42
43
  }
44
+
43
45
  //#endregion
44
- export { createPtrFromOrigin, explicitFrom, implicitFrom, ptrFn, ptrHandle, ptrPrivate, ptrStorage, ptrUniform, ptrWorkgroup };
46
+ export { createPtrFromOrigin, explicitFrom, implicitFrom, ptrFn, ptrHandle, ptrPrivate, ptrStorage, ptrUniform, ptrWorkgroup };
package/data/ref.d.ts CHANGED
@@ -1,5 +1,8 @@
1
1
  import { $internal } from "../shared/symbols.js";
2
+ import "./snippet.js";
2
3
  import { DualFn } from "../types.js";
4
+ import "./wgslTypes.js";
5
+
3
6
  //#region src/data/ref.d.ts
4
7
  interface ref<T> {
5
8
  readonly [$internal]: {
package/data/ref.js CHANGED
@@ -6,6 +6,7 @@ import { snip } from "./snippet.js";
6
6
  import { WgslTypeError } from "../errors.js";
7
7
  import { stitch } from "../core/resolve/stitch.js";
8
8
  import { createPtrFromOrigin, explicitFrom } from "./ptr.js";
9
+
9
10
  //#region src/data/ref.ts
10
11
  const _ref = (() => {
11
12
  const impl = ((value) => INTERNAL_createRef(value));
@@ -45,8 +46,8 @@ function INTERNAL_createRef(value) {
45
46
  };
46
47
  if (value === void 0 || value === null) throw new Error("Cannot create a ref from undefined or null");
47
48
  if (typeof value === "object") return new Proxy(target, {
48
- get(target, prop) {
49
- if (prop in target) return target[prop];
49
+ get(target$1, prop) {
50
+ if (prop in target$1) return target$1[prop];
50
51
  return value[prop];
51
52
  },
52
53
  set(_target, prop, propValue) {
@@ -90,5 +91,6 @@ function derefSnippet(snippet) {
90
91
  if (snippet.value instanceof RefOperator) return snip(stitch`${snippet.value.snippet}`, innerType, origin);
91
92
  return snip(stitch`(*${snippet})`, innerType, origin);
92
93
  }
94
+
93
95
  //#endregion
94
- export { RefOperator, _ref, derefSnippet, isRef };
96
+ export { RefOperator, _ref, derefSnippet, isRef };
package/data/sampler.js CHANGED
@@ -1,4 +1,5 @@
1
1
  import { $internal, $repr } from "../shared/symbols.js";
2
+
2
3
  //#region src/data/sampler.ts
3
4
  function sampler() {
4
5
  return {
@@ -20,5 +21,6 @@ function isWgslSampler(value) {
20
21
  function isWgslComparisonSampler(value) {
21
22
  return !!value[$internal] && value.type === "sampler_comparison";
22
23
  }
24
+
23
25
  //#endregion
24
- export { comparisonSampler, isWgslComparisonSampler, isWgslSampler, sampler };
26
+ export { comparisonSampler, isWgslComparisonSampler, isWgslSampler, sampler };
@@ -1,5 +1,6 @@
1
1
  import { $cast, $gpuCallable } from "../shared/symbols.js";
2
2
  import { hasCast, isGPUCallable } from "../types.js";
3
+
3
4
  //#region src/data/schemaCallWrapper.ts
4
5
  /**
5
6
  * A wrapper for `schema(item)` or `schema()` call on JS side.
@@ -26,5 +27,6 @@ function schemaCallWrapperGPU(ctx, schema, item) {
26
27
  const callSchema = schema;
27
28
  return item === void 0 || item.value === void 0 ? callSchema[$gpuCallable].call(ctx, []) : callSchema[$gpuCallable].call(ctx, [item]);
28
29
  }
30
+
29
31
  //#endregion
30
- export { schemaCallWrapper, schemaCallWrapperGPU };
32
+ export { schemaCallWrapper, schemaCallWrapperGPU };
@@ -2,6 +2,7 @@ import { isDecorated, isWgslArray, isWgslStruct } from "./wgslTypes.js";
2
2
  import { getCustomSize, isDisarray, isLooseDecorated, isUnstruct, undecorate } from "./dataTypes.js";
3
3
  import { alignmentOf, customAlignmentOf } from "./alignmentOf.js";
4
4
  import { roundUp } from "../mathUtils.js";
5
+
5
6
  //#region src/data/schemaMemoryLayout.ts
6
7
  const knownSizesMap = {
7
8
  bool: 4,
@@ -194,5 +195,6 @@ function getLayoutInfo(schema, key) {
194
195
  }
195
196
  return layout[key];
196
197
  }
198
+
197
199
  //#endregion
198
- export { getLayoutInfo };
200
+ export { getLayoutInfo };
package/data/sizeOf.d.ts CHANGED
@@ -1,6 +1,8 @@
1
+ import "./wgslTypes.js";
1
2
  import { AnyData } from "./dataTypes.js";
2
3
 
3
4
  //#region src/data/sizeOf.d.ts
5
+
4
6
  /**
5
7
  * Returns the size (in bytes) of data represented by the `schema`.
6
8
  */
package/data/sizeOf.js CHANGED
@@ -1,4 +1,5 @@
1
1
  import { getLayoutInfo } from "./schemaMemoryLayout.js";
2
+
2
3
  //#region src/data/sizeOf.ts
3
4
  function sizeOf(schema) {
4
5
  return getLayoutInfo(schema, "size");
@@ -9,5 +10,6 @@ function sizeOf(schema) {
9
10
  function PUBLIC_sizeOf(schema) {
10
11
  return sizeOf(schema);
11
12
  }
13
+
12
14
  //#endregion
13
- export { PUBLIC_sizeOf, sizeOf };
15
+ export { PUBLIC_sizeOf, sizeOf };