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
@@ -1,5 +1,9 @@
1
+ import "../../data/snippet.js";
1
2
  import { TgpuAccessor, TgpuMutableAccessor } from "./slotTypes.js";
2
3
  import { UnwrapRuntimeConstructor } from "../../tgpuBindGroupLayout.js";
4
+ import "../../types.js";
5
+ import "../../data/wgslTypes.js";
6
+ import "../../shared/repr.js";
3
7
  import { AnyData } from "../../data/dataTypes.js";
4
8
 
5
9
  //#region src/core/slot/accessor.d.ts
@@ -8,6 +8,7 @@ import { schemaCallWrapper } from "../../data/schemaCallWrapper.js";
8
8
  import { getGpuValueRecursively, valueProxyHandler } from "../valueProxyUtils.js";
9
9
  import { isTgpuFn } from "../function/tgpuFn.js";
10
10
  import { slot } from "./slot.js";
11
+
11
12
  //#region src/core/slot/accessor.ts
12
13
  function accessor(schemaOrConstructor, defaultValue) {
13
14
  return new TgpuAccessorImpl(schemaOrConstructor, defaultValue);
@@ -91,5 +92,6 @@ var TgpuMutableAccessorImpl = class extends AccessorBase {
91
92
  throw new Error("`tgpu.mutableAccessor` relies on GPU resources and cannot be accessed outside of a compute dispatch or draw call");
92
93
  }
93
94
  };
95
+
94
96
  //#endregion
95
- export { accessor, mutableAccessor };
97
+ export { accessor, mutableAccessor };
@@ -1,5 +1,7 @@
1
1
  import { slot } from "./slot.js";
2
+
2
3
  //#region src/core/slot/internalSlots.ts
3
4
  const shaderStageSlot = slot(void 0);
5
+
4
6
  //#endregion
5
- export { shaderStageSlot };
7
+ export { shaderStageSlot };
package/core/slot/lazy.js CHANGED
@@ -2,6 +2,7 @@ import { $gpuValueOf, $internal, $providing } from "../../shared/symbols.js";
2
2
  import { isAccessor, isMutableAccessor } from "./slotTypes.js";
3
3
  import { getResolutionCtx } from "../../execMode.js";
4
4
  import { getGpuValueRecursively } from "../valueProxyUtils.js";
5
+
5
6
  //#region src/core/slot/lazy.ts
6
7
  function lazy(compute) {
7
8
  if (getResolutionCtx()) throw new Error("Cannot create tgpu.lazy objects during shader resolution.");
@@ -36,5 +37,6 @@ var TgpuLazyImpl = class TgpuLazyImpl {
36
37
  }
37
38
  };
38
39
  TgpuLazyImpl.prototype.resourceType = "lazy";
40
+
39
41
  //#endregion
40
- export { lazy };
42
+ export { lazy };
package/core/slot/slot.js CHANGED
@@ -2,6 +2,7 @@ import { $gpuValueOf, $internal } from "../../shared/symbols.js";
2
2
  import { getName, setName } from "../../shared/meta.js";
3
3
  import { getResolutionCtx } from "../../execMode.js";
4
4
  import { getGpuValueRecursively } from "../valueProxyUtils.js";
5
+
5
6
  //#region src/core/slot/slot.ts
6
7
  function slot(defaultValue) {
7
8
  return new TgpuSlotImpl(defaultValue);
@@ -35,5 +36,6 @@ var TgpuSlotImpl = class {
35
36
  return this.value;
36
37
  }
37
38
  };
39
+
38
40
  //#endregion
39
- export { slot };
41
+ export { slot };
@@ -1,4 +1,5 @@
1
1
  import { $providing } from "../../shared/symbols.js";
2
+
2
3
  //#region src/core/slot/slotTypes.ts
3
4
  function isSlot(value) {
4
5
  return value?.resourceType === "slot";
@@ -15,5 +16,6 @@ function isAccessor(value) {
15
16
  function isMutableAccessor(value) {
16
17
  return value?.resourceType === "mutable-accessor";
17
18
  }
19
+
18
20
  //#endregion
19
- export { isAccessor, isLazy, isMutableAccessor, isProviding, isSlot };
21
+ export { isAccessor, isLazy, isMutableAccessor, isProviding, isSlot };
@@ -1,3 +1,9 @@
1
+ import "../../data/snippet.js";
2
+ import "../../tgpuBindGroupLayout.js";
3
+ import "../../types.js";
4
+ import "../../data/texture.js";
5
+ import "../../shared/repr.js";
6
+
1
7
  //#region src/core/texture/externalTexture.d.ts
2
8
  interface TgpuExternalTexture {
3
9
  readonly resourceType: 'external-texture';
@@ -4,6 +4,7 @@ import { snip } from "../../data/snippet.js";
4
4
  import { inCodegenMode } from "../../execMode.js";
5
5
  import { valueProxyHandler } from "../valueProxyUtils.js";
6
6
  import { textureExternal } from "../../data/texture.js";
7
+
7
8
  //#region src/core/texture/externalTexture.ts
8
9
  var TgpuExternalTextureImpl = class {
9
10
  resourceType = "external-texture";
@@ -43,5 +44,6 @@ var TgpuExternalTextureImpl = class {
43
44
  return `textureExternal:${getName(this) ?? "<unnamed>"}`;
44
45
  }
45
46
  };
47
+
46
48
  //#endregion
47
- export { TgpuExternalTextureImpl };
49
+ export { TgpuExternalTextureImpl };
@@ -1,8 +1,12 @@
1
1
  import { TgpuNamable } from "../../shared/meta.js";
2
2
  import { $gpuValueOf, $internal } from "../../shared/symbols.js";
3
3
  import { Default, TypedArray, UnionToIntersection } from "../../shared/utilityTypes.js";
4
+ import "../../data/snippet.js";
4
5
  import { TextureProps } from "./textureProps.js";
5
6
  import { AllowedUsages, LiteralToExtensionMap } from "./usageExtension.js";
7
+ import "../../tgpuBindGroupLayout.js";
8
+ import "../root/rootTypes.js";
9
+ import "../../types.js";
6
10
  import { F32 } from "../../data/wgslTypes.js";
7
11
  import { TextureFormats, ViewDimensionToDimension } from "./textureFormats.js";
8
12
  import { TextureSchemaForDescriptor, WgslStorageTexture, WgslTexture } from "../../data/texture.js";
@@ -6,6 +6,7 @@ import { valueProxyHandler } from "../valueProxyUtils.js";
6
6
  import { isWgslStorageTexture, textureDescriptorToSchema } from "../../data/texture.js";
7
7
  import { getTextureFormatInfo } from "./textureFormats.js";
8
8
  import { generateTextureMipmaps, getImageSourceDimensions, resampleImage } from "./textureUtils.js";
9
+
9
10
  //#region src/core/texture/texture.ts
10
11
  function getDescriptorForProps(props) {
11
12
  return {
@@ -203,13 +204,13 @@ var TgpuFixedTextureViewImpl = class {
203
204
  this.#descriptor = descriptor;
204
205
  this[$internal] = { unwrap: () => {
205
206
  if (!this.#view) {
206
- const schema = this.schema;
207
- const format = isWgslStorageTexture(schema) ? schema.format : this.#baseTexture.props.format;
207
+ const schema$1 = this.schema;
208
+ const format = isWgslStorageTexture(schema$1) ? schema$1.format : this.#baseTexture.props.format;
208
209
  this.#view = this.#baseTexture[$internal].unwrap().createView({
209
210
  ...this.#descriptor,
210
211
  label: getName(this) ?? "<unnamed>",
211
212
  format: this.#descriptor?.format ?? format,
212
- dimension: schema.dimension
213
+ dimension: schema$1.dimension
213
214
  });
214
215
  }
215
216
  return this.#view;
@@ -310,5 +311,6 @@ var TgpuTextureRenderViewImpl = class {
310
311
  } };
311
312
  }
312
313
  };
314
+
313
315
  //#endregion
314
- export { INTERNAL_createTexture, TgpuLaidOutTextureViewImpl, isTexture, isTextureView };
316
+ export { INTERNAL_createTexture, TgpuLaidOutTextureViewImpl, isTexture, isTextureView };
@@ -1,5 +1,6 @@
1
1
  import { f32, i32, u32 } from "../../data/numeric.js";
2
2
  import { vec4f, vec4i, vec4u } from "../../data/vector.js";
3
+
3
4
  //#region src/core/texture/textureFormats.ts
4
5
  const DEPTH_ASPECT_NON_COPYABLE = {
5
6
  channelType: f32,
@@ -93,5 +94,6 @@ function getEffectiveSampleTypes(device, format) {
93
94
  if (FLOAT32_FORMATS.has(format) && !device.features.has("float32-filterable")) return ["unfilterable-float"];
94
95
  return getTextureFormatInfo(format).sampleTypes;
95
96
  }
97
+
96
98
  //#endregion
97
- export { getEffectiveSampleTypes, getTextureFormatInfo };
99
+ export { getEffectiveSampleTypes, getTextureFormatInfo };
@@ -1,4 +1,5 @@
1
1
  import { getEffectiveSampleTypes, getTextureFormatInfo } from "./textureFormats.js";
2
+
2
3
  //#region src/core/texture/textureUtils.ts
3
4
  function getImageSourceDimensions(source) {
4
5
  const { videoWidth, videoHeight } = source;
@@ -218,5 +219,6 @@ function resampleImage(device, targetTexture, image, layer = 0) {
218
219
  inputTexture.destroy();
219
220
  renderTexture.destroy();
220
221
  }
222
+
221
223
  //#endregion
222
- export { clearTextureUtilsCache, generateTextureMipmaps, getImageSourceDimensions, resampleImage };
224
+ export { clearTextureUtilsCache, generateTextureMipmaps, getImageSourceDimensions, resampleImage };
@@ -1,4 +1,5 @@
1
1
  import { getName } from "../../shared/meta.js";
2
+
2
3
  //#region src/core/texture/usageExtension.ts
3
4
  function isUsableAsSampled(value) {
4
5
  return !!value?.usableAsSampled;
@@ -15,5 +16,6 @@ var NotSampledError = class NotSampledError extends Error {
15
16
  Object.setPrototypeOf(this, NotSampledError.prototype);
16
17
  }
17
18
  };
19
+
18
20
  //#endregion
19
- export { NotSampledError, isUsableAsRender, isUsableAsSampled };
21
+ export { NotSampledError, isUsableAsRender, isUsableAsSampled };
@@ -1,7 +1,9 @@
1
1
  import { $internal } from "../../shared/symbols.js";
2
+ import "../../data/snippet.js";
2
3
  import { GPUCallable } from "../../types.js";
3
4
 
4
5
  //#region src/core/unroll/tgpuUnroll.d.ts
6
+
5
7
  /**
6
8
  * Marks an iterable to be unrolled by the shader generator when used in a for loop.
7
9
  *
@@ -61,7 +63,7 @@ import { GPUCallable } from "../../types.js";
61
63
  * }
62
64
  * ```
63
65
  */
64
- declare const unroll: (<T extends Iterable<unknown>>(iterable: T) => T) & GPUCallable & {
66
+ declare const unroll: (<T extends Iterable<unknown>>(iterable: T) => T) & GPUCallable<[iterable: Iterable<unknown>]> & {
65
67
  [$internal]: true;
66
68
  };
67
69
  //#endregion
@@ -2,6 +2,7 @@ import { $gpuCallable, $internal, $resolve } from "../../shared/symbols.js";
2
2
  import { setName } from "../../shared/meta.js";
3
3
  import { snip } from "../../data/snippet.js";
4
4
  import { stitch } from "../resolve/stitch.js";
5
+
5
6
  //#region src/core/unroll/tgpuUnroll.ts
6
7
  /**
7
8
  * The result of calling `tgpu.unroll(...)`. The code responsible for
@@ -90,5 +91,6 @@ const unroll = (() => {
90
91
  } };
91
92
  return impl;
92
93
  })();
94
+
93
95
  //#endregion
94
- export { UnrollableIterable, unroll };
96
+ export { UnrollableIterable, unroll };
@@ -3,6 +3,7 @@ import { getOwnSnippet } from "../types.js";
3
3
  import { getGPUValue } from "../getGPUValue.js";
4
4
  import { accessProp } from "../tgsl/accessProp.js";
5
5
  import { accessIndex } from "../tgsl/accessIndex.js";
6
+
6
7
  //#region src/core/valueProxyUtils.ts
7
8
  const valueProxyHandler = { get(target, prop) {
8
9
  if (prop in target) return Reflect.get(target, prop);
@@ -11,12 +12,12 @@ const valueProxyHandler = { get(target, prop) {
11
12
  const targetSnippet = getOwnSnippet(target);
12
13
  const index = Number(prop);
13
14
  if (!Number.isNaN(index)) {
14
- const accessed = accessIndex(targetSnippet, index);
15
- if (!accessed) return;
15
+ const accessed$1 = accessIndex(targetSnippet, index);
16
+ if (!accessed$1) return;
16
17
  return new Proxy({
17
18
  [$internal]: true,
18
- [$resolve]: (ctx) => ctx.resolve(accessed.value, accessed.dataType),
19
- [$ownSnippet]: accessed,
19
+ [$resolve]: (ctx) => ctx.resolve(accessed$1.value, accessed$1.dataType),
20
+ [$ownSnippet]: accessed$1,
20
21
  toString: () => `${String(target)}[${prop}]`
21
22
  }, valueProxyHandler);
22
23
  }
@@ -38,5 +39,6 @@ function getGpuValueRecursively(value) {
38
39
  }
39
40
  return unwrapped;
40
41
  }
42
+
41
43
  //#endregion
42
- export { getGpuValueRecursively, valueProxyHandler };
44
+ export { getGpuValueRecursively, valueProxyHandler };
@@ -15,7 +15,9 @@ interface TgpuVar<TScope extends VariableScope = VariableScope, TDataType extend
15
15
  value: InferGPU<TDataType>;
16
16
  $: InferGPU<TDataType>;
17
17
  readonly [$internal]: {
18
- /** Makes it differentiable on the type level. Does not exist at runtime. */dataType?: TDataType; /** Makes it differentiable on the type level. Does not exist at runtime. */
18
+ /** Makes it differentiable on the type level. Does not exist at runtime. */
19
+ dataType?: TDataType;
20
+ /** Makes it differentiable on the type level. Does not exist at runtime. */
19
21
  scope?: TScope;
20
22
  };
21
23
  }
@@ -6,6 +6,7 @@ import { IllegalVarAccessError } from "../../errors.js";
6
6
  import { getExecMode, isInsideTgpuFn } from "../../execMode.js";
7
7
  import { assertExhaustive } from "../../shared/utilityTypes.js";
8
8
  import { valueProxyHandler } from "../valueProxyUtils.js";
9
+
9
10
  //#region src/core/variable/tgpuVariable.ts
10
11
  /**
11
12
  * Defines a variable scoped to each entry function (private).
@@ -95,5 +96,6 @@ var TgpuVarImpl = class {
95
96
  this.$ = v;
96
97
  }
97
98
  };
99
+
98
100
  //#endregion
99
- export { isVariable, privateVar, workgroupVar };
101
+ export { isVariable, privateVar, workgroupVar };
@@ -1,5 +1,6 @@
1
1
  import { getCustomLocation, isData } from "../../data/dataTypes.js";
2
2
  import { isBuiltin } from "../../data/attributes.js";
3
+
3
4
  //#region src/core/vertexLayout/connectAttributesToShader.ts
4
5
  function isAttribute(value) {
5
6
  return typeof value?.format === "string";
@@ -53,5 +54,6 @@ function connectAttributesToShader(shaderInputLayout, attributes) {
53
54
  bufferDefinitions
54
55
  };
55
56
  }
57
+
56
58
  //#endregion
57
- export { connectAttributesToShader, isAttribute };
59
+ export { connectAttributesToShader, isAttribute };
@@ -4,6 +4,7 @@ import { Decorated, WgslArray, WgslStruct } from "../../data/wgslTypes.js";
4
4
  import { Disarray, LooseDecorated, Unstruct } from "../../data/dataTypes.js";
5
5
 
6
6
  //#region src/core/vertexLayout/vertexAttribute.d.ts
7
+
7
8
  /**
8
9
  * The array can hold T, where T is a single/multi-component numeric, or a struct with members of type T.
9
10
  * Examples of valid array members:
@@ -6,6 +6,7 @@ import { getCustomLocation, isLooseDecorated, isUnstruct } from "../../data/data
6
6
  import { alignmentOf, customAlignmentOf } from "../../data/alignmentOf.js";
7
7
  import { roundUp } from "../../mathUtils.js";
8
8
  import { sizeOf } from "../../data/sizeOf.js";
9
+
9
10
  //#region src/core/vertexLayout/vertexLayout.ts
10
11
  function vertexLayout(schemaForCount, stepMode = "vertex") {
11
12
  return new TgpuVertexLayoutImpl(schemaForCount, stepMode);
@@ -23,9 +24,9 @@ function dataToContainedAttribs(layout, data, offset, customLocationMap, key) {
23
24
  if (isWgslStruct(data)) {
24
25
  let memberOffset = offset;
25
26
  const propTypes = data.propTypes;
26
- return Object.fromEntries(Object.entries(propTypes).map(([key, value]) => {
27
+ return Object.fromEntries(Object.entries(propTypes).map(([key$1, value]) => {
27
28
  memberOffset = roundUp(memberOffset, alignmentOf(value));
28
- const attrib = [key, dataToContainedAttribs(layout, value, memberOffset, customLocationMap, key)];
29
+ const attrib = [key$1, dataToContainedAttribs(layout, value, memberOffset, customLocationMap, key$1)];
29
30
  memberOffset += sizeOf(value);
30
31
  return attrib;
31
32
  }));
@@ -33,9 +34,9 @@ function dataToContainedAttribs(layout, data, offset, customLocationMap, key) {
33
34
  if (isUnstruct(data)) {
34
35
  let memberOffset = offset;
35
36
  const propTypes = data.propTypes;
36
- return Object.fromEntries(Object.entries(propTypes).map(([key, value]) => {
37
+ return Object.fromEntries(Object.entries(propTypes).map(([key$1, value]) => {
37
38
  memberOffset = roundUp(memberOffset, customAlignmentOf(value));
38
- const attrib = [key, dataToContainedAttribs(layout, value, memberOffset, customLocationMap, key)];
39
+ const attrib = [key$1, dataToContainedAttribs(layout, value, memberOffset, customLocationMap, key$1)];
39
40
  memberOffset += sizeOf(value);
40
41
  return attrib;
41
42
  }));
@@ -99,5 +100,6 @@ var TgpuVertexLayoutImpl = class {
99
100
  return this;
100
101
  }
101
102
  };
103
+
102
104
  //#endregion
103
- export { isVertexLayout, vertexLayout };
105
+ export { isVertexLayout, vertexLayout };
package/data/alignIO.js CHANGED
@@ -10,5 +10,7 @@ function alignIO(io, baseAlignment) {
10
10
  if ("skipBytes" in io) io.skipBytes(baseAlignment - offset & bitMask);
11
11
  else io.add(baseAlignment - offset & bitMask);
12
12
  }
13
+ var alignIO_default = alignIO;
14
+
13
15
  //#endregion
14
- export { alignIO as default };
16
+ export { alignIO_default as default };
@@ -1,6 +1,8 @@
1
+ import "./wgslTypes.js";
1
2
  import { AnyData } from "./dataTypes.js";
2
3
 
3
4
  //#region src/data/alignmentOf.d.ts
5
+
4
6
  /**
5
7
  * Returns the alignment (in bytes) of data represented by the `schema`.
6
8
  */
@@ -2,6 +2,7 @@ import { isDecorated, isWgslArray, isWgslStruct } from "./wgslTypes.js";
2
2
  import { getCustomAlignment, isDisarray, isLooseDecorated, isUnstruct } from "./dataTypes.js";
3
3
  import { safeStringify } from "../shared/stringify.js";
4
4
  import { packedFormats } from "./vertexFormatData.js";
5
+
5
6
  //#region src/data/alignmentOf.ts
6
7
  const knownAlignmentMap = {
7
8
  f32: 4,
@@ -82,5 +83,6 @@ function customAlignmentOf(data) {
82
83
  function PUBLIC_alignmentOf(schema) {
83
84
  return alignmentOf(schema);
84
85
  }
86
+
85
87
  //#endregion
86
- export { PUBLIC_alignmentOf, alignmentOf, customAlignmentOf };
88
+ export { PUBLIC_alignmentOf, alignmentOf, customAlignmentOf };
package/data/array.js CHANGED
@@ -2,6 +2,7 @@ import { $internal } from "../shared/symbols.js";
2
2
  import { schemaCallWrapper } from "./schemaCallWrapper.js";
3
3
  import { sizeOf } from "./sizeOf.js";
4
4
  import { comptime } from "../core/function/comptime.js";
5
+
5
6
  //#region src/data/array.ts
6
7
  /**
7
8
  * Creates an array schema that can be used to construct gpu buffers.
@@ -42,5 +43,6 @@ const WgslArrayImpl = {
42
43
  return `arrayOf(${String(this.elementType)}, ${this.elementCount})`;
43
44
  }
44
45
  };
46
+
45
47
  //#endregion
46
- export { arrayOf };
48
+ export { arrayOf };
package/data/atomic.d.ts CHANGED
@@ -1,6 +1,7 @@
1
1
  import { Atomic, I32, U32 } from "./wgslTypes.js";
2
2
 
3
3
  //#region src/data/atomic.d.ts
4
+
4
5
  /**
5
6
  * Marks a concrete integer scalar type schema (u32 or i32) as a WGSL atomic.
6
7
  *
package/data/atomic.js CHANGED
@@ -1,4 +1,5 @@
1
1
  import { $internal } from "../shared/symbols.js";
2
+
2
3
  //#region src/data/atomic.ts
3
4
  /**
4
5
  * Marks a concrete integer scalar type schema (u32 or i32) as a WGSL atomic.
@@ -20,5 +21,6 @@ var AtomicImpl = class {
20
21
  this.inner = inner;
21
22
  }
22
23
  };
24
+
23
25
  //#endregion
24
- export { atomic };
26
+ export { atomic };
@@ -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 };