typegpu 0.10.2 → 0.11.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (211) hide show
  1. package/_virtual/_rolldown/runtime.js +6 -11
  2. package/builtin.js +1 -3
  3. package/common/fullScreenTriangle.d.ts +1 -5
  4. package/common/fullScreenTriangle.js +1 -3
  5. package/common/index.d.ts +3 -2
  6. package/common/index.js +6 -4
  7. package/common/writeSoA.d.ts +16 -0
  8. package/common/writeSoA.js +90 -0
  9. package/core/buffer/buffer.d.ts +12 -7
  10. package/core/buffer/buffer.js +102 -53
  11. package/core/buffer/bufferShorthand.d.ts +5 -5
  12. package/core/buffer/bufferShorthand.js +9 -5
  13. package/core/buffer/bufferUsage.d.ts +0 -2
  14. package/core/buffer/bufferUsage.js +6 -4
  15. package/core/constant/tgpuConstant.d.ts +2 -1
  16. package/core/constant/tgpuConstant.js +8 -7
  17. package/core/declare/tgpuDeclare.js +8 -9
  18. package/core/function/autoIO.d.ts +7 -6
  19. package/core/function/autoIO.js +1 -3
  20. package/core/function/comptime.js +1 -3
  21. package/core/function/createCallableSchema.js +4 -6
  22. package/core/function/dualImpl.js +1 -3
  23. package/core/function/entryInputRouter.js +39 -0
  24. package/core/function/extractArgs.js +2 -2
  25. package/core/function/fnCore.js +19 -8
  26. package/core/function/fnTypes.d.ts +14 -8
  27. package/core/function/ioSchema.js +24 -3
  28. package/core/function/shelllessImpl.js +1 -3
  29. package/core/function/templateUtils.js +1 -2
  30. package/core/function/tgpuComputeFn.d.ts +2 -3
  31. package/core/function/tgpuComputeFn.js +9 -16
  32. package/core/function/tgpuFn.d.ts +2 -2
  33. package/core/function/tgpuFn.js +1 -3
  34. package/core/function/tgpuFragmentFn.d.ts +5 -1
  35. package/core/function/tgpuFragmentFn.js +5 -10
  36. package/core/function/tgpuVertexFn.d.ts +4 -0
  37. package/core/function/tgpuVertexFn.js +6 -12
  38. package/core/pipeline/applyPipelineState.js +1 -3
  39. package/core/pipeline/computePipeline.d.ts +2 -6
  40. package/core/pipeline/computePipeline.js +64 -63
  41. package/core/pipeline/connectAttachmentToShader.js +1 -3
  42. package/core/pipeline/connectTargetsToShader.js +1 -3
  43. package/core/pipeline/limitsOverflow.js +1 -2
  44. package/core/pipeline/pipelineUtils.js +29 -0
  45. package/core/pipeline/renderPipeline.d.ts +23 -5
  46. package/core/pipeline/renderPipeline.js +32 -14
  47. package/core/pipeline/timeable.d.ts +0 -3
  48. package/core/pipeline/timeable.js +3 -9
  49. package/core/pipeline/typeGuards.js +1 -3
  50. package/core/querySet/querySet.d.ts +0 -2
  51. package/core/querySet/querySet.js +37 -36
  52. package/core/rawCodeSnippet/tgpuRawCodeSnippet.js +1 -3
  53. package/core/resolve/externals.d.ts +0 -2
  54. package/core/resolve/externals.js +2 -4
  55. package/core/resolve/namespace.js +1 -3
  56. package/core/resolve/resolveData.js +1 -3
  57. package/core/resolve/stitch.js +1 -3
  58. package/core/resolve/tgpuResolve.d.ts +3 -1
  59. package/core/resolve/tgpuResolve.js +3 -5
  60. package/core/root/configurableImpl.js +2 -3
  61. package/core/root/init.d.ts +0 -5
  62. package/core/root/init.js +35 -28
  63. package/core/root/rootTypes.d.ts +25 -5
  64. package/core/sampler/sampler.d.ts +0 -4
  65. package/core/sampler/sampler.js +3 -3
  66. package/core/simulate/tgpuSimulate.js +1 -3
  67. package/core/slot/accessor.d.ts +0 -4
  68. package/core/slot/accessor.js +1 -3
  69. package/core/slot/internalSlots.js +1 -3
  70. package/core/slot/lazy.js +1 -3
  71. package/core/slot/slot.js +2 -3
  72. package/core/slot/slotTypes.js +1 -3
  73. package/core/texture/externalTexture.d.ts +0 -6
  74. package/core/texture/externalTexture.js +2 -3
  75. package/core/texture/texture.d.ts +0 -4
  76. package/core/texture/texture.js +5 -3
  77. package/core/texture/textureFormats.js +1 -3
  78. package/core/texture/textureUtils.js +1 -3
  79. package/core/texture/usageExtension.js +1 -3
  80. package/core/unroll/tgpuUnroll.d.ts +58 -3
  81. package/core/unroll/tgpuUnroll.js +63 -5
  82. package/core/valueProxyUtils.js +1 -3
  83. package/core/variable/tgpuVariable.js +1 -3
  84. package/core/vertexLayout/connectAttributesToShader.js +1 -3
  85. package/core/vertexLayout/vertexLayout.js +9 -9
  86. package/data/alignIO.js +1 -2
  87. package/data/alignmentOf.d.ts +0 -1
  88. package/data/alignmentOf.js +1 -3
  89. package/data/array.d.ts +1 -3
  90. package/data/array.js +2 -4
  91. package/data/atomic.js +2 -3
  92. package/data/attributes.js +3 -3
  93. package/data/autoStruct.d.ts +1 -3
  94. package/data/autoStruct.js +1 -3
  95. package/data/compiledIO.js +83 -86
  96. package/data/dataIO.js +46 -39
  97. package/data/dataTypes.d.ts +7 -7
  98. package/data/dataTypes.js +6 -3
  99. package/data/deepEqual.js +1 -3
  100. package/data/disarray.d.ts +1 -3
  101. package/data/disarray.js +1 -3
  102. package/data/getLongestContiguousPrefix.d.ts +0 -1
  103. package/data/getLongestContiguousPrefix.js +1 -3
  104. package/data/index.d.ts +3 -3
  105. package/data/index.js +10 -3
  106. package/data/isContiguous.d.ts +0 -1
  107. package/data/isContiguous.js +1 -3
  108. package/data/matrix.d.ts +8 -10
  109. package/data/matrix.js +32 -18
  110. package/data/numberOps.js +1 -2
  111. package/data/numeric.js +16 -29
  112. package/data/offsetUtils.d.ts +2 -2
  113. package/data/offsetUtils.js +3 -5
  114. package/data/offsets.js +1 -3
  115. package/data/partialIO.js +84 -39
  116. package/data/ptr.d.ts +0 -1
  117. package/data/ptr.js +1 -3
  118. package/data/ref.d.ts +0 -3
  119. package/data/ref.js +1 -3
  120. package/data/sampler.js +1 -3
  121. package/data/schemaCallWrapper.js +1 -3
  122. package/data/schemaMemoryLayout.js +1 -3
  123. package/data/sizeOf.d.ts +0 -1
  124. package/data/sizeOf.js +1 -3
  125. package/data/snippet.js +12 -3
  126. package/data/struct.js +1 -3
  127. package/data/texture.js +1 -3
  128. package/data/unstruct.js +1 -3
  129. package/data/vector.js +4 -12
  130. package/data/vectorImpl.js +27 -28
  131. package/data/vectorOps.js +20 -3
  132. package/data/vertexFormatData.js +2 -3
  133. package/data/wgslTypes.d.ts +39 -11
  134. package/data/wgslTypes.js +10 -3
  135. package/errors.js +6 -3
  136. package/execMode.js +1 -3
  137. package/extension.js +1 -3
  138. package/getGPUValue.js +1 -3
  139. package/index.d.ts +4 -2
  140. package/index.js +3 -3
  141. package/indexNamedExports.d.ts +3 -1
  142. package/mathUtils.js +1 -2
  143. package/memo.js +8 -8
  144. package/nameRegistry.js +1 -3
  145. package/package.js +2 -3
  146. package/package.json +7 -7
  147. package/resolutionCtx.d.ts +0 -10
  148. package/resolutionCtx.js +84 -18
  149. package/shared/env.js +1 -2
  150. package/shared/generators.js +1 -2
  151. package/shared/meta.js +1 -3
  152. package/shared/repr.d.ts +32 -2
  153. package/shared/stringify.js +1 -3
  154. package/shared/symbols.d.ts +10 -1
  155. package/shared/symbols.js +10 -33
  156. package/shared/utilityTypes.d.ts +6 -2
  157. package/shared/utilityTypes.js +1 -2
  158. package/shared/vertexFormat.js +1 -2
  159. package/std/array.d.ts +1 -1
  160. package/std/array.js +1 -3
  161. package/std/atomic.d.ts +12 -12
  162. package/std/atomic.js +1 -3
  163. package/std/bitcast.d.ts +2 -2
  164. package/std/bitcast.js +1 -3
  165. package/std/boolean.d.ts +30 -16
  166. package/std/boolean.js +37 -12
  167. package/std/derivative.d.ts +9 -9
  168. package/std/derivative.js +1 -3
  169. package/std/discard.d.ts +1 -1
  170. package/std/discard.js +1 -3
  171. package/std/extensions.d.ts +1 -3
  172. package/std/extensions.js +1 -3
  173. package/std/index.d.ts +5 -4
  174. package/std/index.js +8 -5
  175. package/std/matrix.d.ts +5 -5
  176. package/std/matrix.js +1 -3
  177. package/std/numeric.d.ts +78 -132
  178. package/std/numeric.js +1 -3
  179. package/std/operators.d.ts +16 -8
  180. package/std/operators.js +80 -6
  181. package/std/packing.d.ts +4 -4
  182. package/std/packing.js +1 -3
  183. package/std/range.d.ts +24 -0
  184. package/std/range.js +38 -0
  185. package/std/subgroup.d.ts +21 -21
  186. package/std/subgroup.js +1 -3
  187. package/std/texture.d.ts +20 -11
  188. package/std/texture.js +13 -3
  189. package/tgpu.js +1 -3
  190. package/tgpuBindGroupLayout.js +9 -8
  191. package/tgpuUnstable.js +1 -3
  192. package/tgsl/accessIndex.js +2 -4
  193. package/tgsl/accessProp.js +8 -6
  194. package/tgsl/consoleLog/deserializers.js +1 -3
  195. package/tgsl/consoleLog/logGenerator.js +2 -4
  196. package/tgsl/consoleLog/serializers.js +24 -26
  197. package/tgsl/consoleLog/types.d.ts +0 -2
  198. package/tgsl/consoleLog/types.js +1 -2
  199. package/tgsl/conversion.js +1 -3
  200. package/tgsl/forOfUtils.js +35 -9
  201. package/tgsl/generationHelpers.js +3 -3
  202. package/tgsl/math.js +1 -3
  203. package/tgsl/shaderGenerator.d.ts +10 -8
  204. package/tgsl/shaderGenerator_members.d.ts +2 -0
  205. package/tgsl/shaderGenerator_members.js +6 -0
  206. package/tgsl/shellless.js +1 -8
  207. package/tgsl/wgslGenerator.d.ts +36 -0
  208. package/tgsl/wgslGenerator.js +144 -81
  209. package/types.d.ts +14 -4
  210. package/types.js +3 -3
  211. package/wgslExtensions.js +1 -2
@@ -4,7 +4,6 @@ import { snip } from "../../data/snippet.js";
4
4
  import { inCodegenMode } from "../../execMode.js";
5
5
  import { valueProxyHandler } from "../valueProxyUtils.js";
6
6
  import { comparisonSampler, sampler } from "../../data/sampler.js";
7
-
8
7
  //#region src/core/sampler/sampler.ts
9
8
  function INTERNAL_createSampler(props, branch) {
10
9
  return new TgpuFixedSamplerImpl(sampler(), props, branch);
@@ -23,6 +22,7 @@ function isComparisonSampler(resource) {
23
22
  var TgpuLaidOutSamplerImpl = class {
24
23
  [$internal] = { unwrap: void 0 };
25
24
  resourceType;
25
+ schema;
26
26
  #membership;
27
27
  constructor(schema, membership) {
28
28
  this.schema = schema;
@@ -61,6 +61,7 @@ var TgpuLaidOutSamplerImpl = class {
61
61
  var TgpuFixedSamplerImpl = class {
62
62
  [$internal];
63
63
  resourceType;
64
+ schema;
64
65
  #filtering;
65
66
  #sampler = null;
66
67
  #props;
@@ -111,6 +112,5 @@ var TgpuFixedSamplerImpl = class {
111
112
  return `${this.resourceType}:${getName(this) ?? "<unnamed>"}`;
112
113
  }
113
114
  };
114
-
115
115
  //#endregion
116
- export { INTERNAL_createComparisonSampler, INTERNAL_createSampler, TgpuLaidOutSamplerImpl, isComparisonSampler, isSampler };
116
+ export { INTERNAL_createComparisonSampler, INTERNAL_createSampler, TgpuLaidOutSamplerImpl, isComparisonSampler, isSampler };
@@ -3,7 +3,6 @@ import { getResolutionCtx, provideCtx } from "../../execMode.js";
3
3
  import { namespace } from "../resolve/namespace.js";
4
4
  import wgslGenerator from "../../tgsl/wgslGenerator.js";
5
5
  import { ResolutionCtxImpl } from "../../resolutionCtx.js";
6
-
7
6
  //#region src/core/simulate/tgpuSimulate.ts
8
7
  /**
9
8
  * Runs the provided callback in a simulated environment, giving
@@ -71,6 +70,5 @@ function simulate(callback) {
71
70
  ctx.popMode("simulate");
72
71
  }
73
72
  }
74
-
75
73
  //#endregion
76
- export { simulate };
74
+ export { simulate };
@@ -1,9 +1,5 @@
1
- import "../../data/snippet.js";
2
1
  import { TgpuAccessor, TgpuMutableAccessor } from "./slotTypes.js";
3
2
  import { UnwrapRuntimeConstructor } from "../../tgpuBindGroupLayout.js";
4
- import "../../types.js";
5
- import "../../data/wgslTypes.js";
6
- import "../../shared/repr.js";
7
3
  import { AnyData } from "../../data/dataTypes.js";
8
4
 
9
5
  //#region src/core/slot/accessor.d.ts
@@ -8,7 +8,6 @@ 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
-
12
11
  //#region src/core/slot/accessor.ts
13
12
  function accessor(schemaOrConstructor, defaultValue) {
14
13
  return new TgpuAccessorImpl(schemaOrConstructor, defaultValue);
@@ -92,6 +91,5 @@ var TgpuMutableAccessorImpl = class extends AccessorBase {
92
91
  throw new Error("`tgpu.mutableAccessor` relies on GPU resources and cannot be accessed outside of a compute dispatch or draw call");
93
92
  }
94
93
  };
95
-
96
94
  //#endregion
97
- export { accessor, mutableAccessor };
95
+ export { accessor, mutableAccessor };
@@ -1,7 +1,5 @@
1
1
  import { slot } from "./slot.js";
2
-
3
2
  //#region src/core/slot/internalSlots.ts
4
3
  const shaderStageSlot = slot(void 0);
5
-
6
4
  //#endregion
7
- export { shaderStageSlot };
5
+ export { shaderStageSlot };
package/core/slot/lazy.js CHANGED
@@ -2,7 +2,6 @@ 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
-
6
5
  //#region src/core/slot/lazy.ts
7
6
  function lazy(compute) {
8
7
  if (getResolutionCtx()) throw new Error("Cannot create tgpu.lazy objects during shader resolution.");
@@ -37,6 +36,5 @@ var TgpuLazyImpl = class TgpuLazyImpl {
37
36
  }
38
37
  };
39
38
  TgpuLazyImpl.prototype.resourceType = "lazy";
40
-
41
39
  //#endregion
42
- export { lazy };
40
+ export { lazy };
package/core/slot/slot.js CHANGED
@@ -2,7 +2,6 @@ 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
-
6
5
  //#region src/core/slot/slot.ts
7
6
  function slot(defaultValue) {
8
7
  return new TgpuSlotImpl(defaultValue);
@@ -10,6 +9,7 @@ function slot(defaultValue) {
10
9
  var TgpuSlotImpl = class {
11
10
  [$internal] = true;
12
11
  resourceType = "slot";
12
+ defaultValue;
13
13
  constructor(defaultValue = void 0) {
14
14
  this.defaultValue = defaultValue;
15
15
  }
@@ -35,6 +35,5 @@ var TgpuSlotImpl = class {
35
35
  return this.value;
36
36
  }
37
37
  };
38
-
39
38
  //#endregion
40
- export { slot };
39
+ export { slot };
@@ -1,5 +1,4 @@
1
1
  import { $providing } from "../../shared/symbols.js";
2
-
3
2
  //#region src/core/slot/slotTypes.ts
4
3
  function isSlot(value) {
5
4
  return value?.resourceType === "slot";
@@ -16,6 +15,5 @@ function isAccessor(value) {
16
15
  function isMutableAccessor(value) {
17
16
  return value?.resourceType === "mutable-accessor";
18
17
  }
19
-
20
18
  //#endregion
21
- export { isAccessor, isLazy, isMutableAccessor, isProviding, isSlot };
19
+ export { isAccessor, isLazy, isMutableAccessor, isProviding, isSlot };
@@ -1,9 +1,3 @@
1
- import "../../data/snippet.js";
2
- import "../../tgpuBindGroupLayout.js";
3
- import "../../types.js";
4
- import "../../data/texture.js";
5
- import "../../shared/repr.js";
6
-
7
1
  //#region src/core/texture/externalTexture.d.ts
8
2
  interface TgpuExternalTexture {
9
3
  readonly resourceType: 'external-texture';
@@ -4,11 +4,11 @@ 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
-
8
7
  //#region src/core/texture/externalTexture.ts
9
8
  var TgpuExternalTextureImpl = class {
10
9
  resourceType = "external-texture";
11
10
  [$internal] = true;
11
+ schema;
12
12
  #membership;
13
13
  constructor(schema, membership) {
14
14
  this.schema = schema;
@@ -43,6 +43,5 @@ var TgpuExternalTextureImpl = class {
43
43
  return `textureExternal:${getName(this) ?? "<unnamed>"}`;
44
44
  }
45
45
  };
46
-
47
46
  //#endregion
48
- export { TgpuExternalTextureImpl };
47
+ export { TgpuExternalTextureImpl };
@@ -1,12 +1,8 @@
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";
5
4
  import { TextureProps } from "./textureProps.js";
6
5
  import { AllowedUsages, LiteralToExtensionMap } from "./usageExtension.js";
7
- import "../../tgpuBindGroupLayout.js";
8
- import "../root/rootTypes.js";
9
- import "../../types.js";
10
6
  import { F32 } from "../../data/wgslTypes.js";
11
7
  import { TextureFormats, ViewDimensionToDimension } from "./textureFormats.js";
12
8
  import { TextureSchemaForDescriptor, WgslStorageTexture, WgslTexture } from "../../data/texture.js";
@@ -6,7 +6,6 @@ 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
-
10
9
  //#region src/core/texture/texture.ts
11
10
  function getDescriptorForProps(props) {
12
11
  return {
@@ -27,6 +26,7 @@ function isTextureView(value) {
27
26
  var TgpuTextureImpl = class {
28
27
  [$internal];
29
28
  resourceType = "texture";
29
+ props;
30
30
  usableAsSampled = false;
31
31
  usableAsStorage = false;
32
32
  usableAsRender = false;
@@ -193,6 +193,7 @@ var TgpuTextureImpl = class {
193
193
  var TgpuFixedTextureViewImpl = class {
194
194
  [$internal];
195
195
  resourceType = "texture-view";
196
+ schema;
196
197
  #baseTexture;
197
198
  #view;
198
199
  #descriptor;
@@ -257,6 +258,7 @@ var TgpuLaidOutTextureViewImpl = class {
257
258
  [$internal] = { unwrap: void 0 };
258
259
  resourceType = "texture-view";
259
260
  #membership;
261
+ schema;
260
262
  constructor(schema, membership) {
261
263
  this.schema = schema;
262
264
  this.#membership = membership;
@@ -297,6 +299,7 @@ var TgpuLaidOutTextureViewImpl = class {
297
299
  var TgpuTextureRenderViewImpl = class {
298
300
  [$internal];
299
301
  resourceType = "texture-view";
302
+ descriptor;
300
303
  constructor(baseTexture, descriptor = {}) {
301
304
  this.descriptor = descriptor;
302
305
  this[$internal] = { unwrap: () => {
@@ -307,6 +310,5 @@ var TgpuTextureRenderViewImpl = class {
307
310
  } };
308
311
  }
309
312
  };
310
-
311
313
  //#endregion
312
- export { INTERNAL_createTexture, TgpuLaidOutTextureViewImpl, isTexture, isTextureView };
314
+ export { INTERNAL_createTexture, TgpuLaidOutTextureViewImpl, isTexture, isTextureView };
@@ -1,6 +1,5 @@
1
1
  import { f32, i32, u32 } from "../../data/numeric.js";
2
2
  import { vec4f, vec4i, vec4u } from "../../data/vector.js";
3
-
4
3
  //#region src/core/texture/textureFormats.ts
5
4
  const DEPTH_ASPECT_NON_COPYABLE = {
6
5
  channelType: f32,
@@ -94,6 +93,5 @@ function getEffectiveSampleTypes(device, format) {
94
93
  if (FLOAT32_FORMATS.has(format) && !device.features.has("float32-filterable")) return ["unfilterable-float"];
95
94
  return getTextureFormatInfo(format).sampleTypes;
96
95
  }
97
-
98
96
  //#endregion
99
- export { getEffectiveSampleTypes, getTextureFormatInfo };
97
+ export { getEffectiveSampleTypes, getTextureFormatInfo };
@@ -1,5 +1,4 @@
1
1
  import { getEffectiveSampleTypes, getTextureFormatInfo } from "./textureFormats.js";
2
-
3
2
  //#region src/core/texture/textureUtils.ts
4
3
  function getImageSourceDimensions(source) {
5
4
  const { videoWidth, videoHeight } = source;
@@ -219,6 +218,5 @@ function resampleImage(device, targetTexture, image, layer = 0) {
219
218
  inputTexture.destroy();
220
219
  renderTexture.destroy();
221
220
  }
222
-
223
221
  //#endregion
224
- export { clearTextureUtilsCache, generateTextureMipmaps, getImageSourceDimensions, resampleImage };
222
+ export { clearTextureUtilsCache, generateTextureMipmaps, getImageSourceDimensions, resampleImage };
@@ -1,5 +1,4 @@
1
1
  import { getName } from "../../shared/meta.js";
2
-
3
2
  //#region src/core/texture/usageExtension.ts
4
3
  function isUsableAsSampled(value) {
5
4
  return !!value?.usableAsSampled;
@@ -16,6 +15,5 @@ var NotSampledError = class NotSampledError extends Error {
16
15
  Object.setPrototypeOf(this, NotSampledError.prototype);
17
16
  }
18
17
  };
19
-
20
18
  //#endregion
21
- export { NotSampledError, isUsableAsRender, isUsableAsSampled };
19
+ export { NotSampledError, isUsableAsRender, isUsableAsSampled };
@@ -1,12 +1,67 @@
1
1
  import { $internal } from "../../shared/symbols.js";
2
- import "../../data/snippet.js";
3
2
  import { GPUCallable } from "../../types.js";
4
3
 
5
4
  //#region src/core/unroll/tgpuUnroll.d.ts
6
5
  /**
7
- * Marks an iterable to be unrolled by the wgslGenerator.
6
+ * Marks an iterable to be unrolled by the shader generator when used in a for loop.
7
+ *
8
+ * @example
9
+ * ```ts
10
+ * const neighborOffsets = [d.vec2i(0, 1), d.vec2i(0, -1), d.vec2i(1, 0), d.vec2i(-1, 0)];
11
+ *
12
+ * // Unrolls into 4 blocks of code, one for each offset.
13
+ * for (const offset of tgpu.unroll(neighborOffsets)) {
14
+ * // ...
15
+ * }
16
+ * ```
17
+ *
18
+ * If you'd like to unroll over a range of numbers, use `tgpu.unroll(std.range(n))`.
19
+ *
20
+ * @example
21
+ * ```ts
22
+ * // (...)
23
+ * const FBM_OCTAVES = 3;
24
+ *
25
+ * function fbm(pos: d.v3f): number {
26
+ * 'use gpu';
27
+ * let sum = d.f32();
28
+ *
29
+ * // i = 0, 1, 2
30
+ * for (const i of tgpu.unroll(std.range(FBM_OCTAVES))) {
31
+ * sum +=
32
+ * noise3d(pos * (CLOUD_FREQUENCY * FBM_LACUNARITY ** i)) *
33
+ * (CLOUD_AMPLITUDE * FBM_PERSISTENCE ** i);
34
+ * }
35
+ *
36
+ * return sum;
37
+ * }
38
+ *
39
+ * ```
40
+ *
41
+ * Generates:
42
+ *
43
+ * ```wgsl
44
+ * // (...)
45
+ *
46
+ * fn fbm(pos: vec3f) -> f32 {
47
+ * var sum = 0f;
48
+ * // unrolled iteration #0
49
+ * {
50
+ * sum += noise3d(pos * 1.4f) * 1f;
51
+ * }
52
+ * // unrolled iteration #1
53
+ * {
54
+ * sum += noise3d(pos * 2.8f) * 0.5f;
55
+ * }
56
+ * // unrolled iteration #2
57
+ * {
58
+ * sum += noise3d(pos * 5.6f) * 0.25f;
59
+ * }
60
+ * return sum;
61
+ * }
62
+ * ```
8
63
  */
9
- declare const unroll: (<T extends Iterable<unknown>>(value: T) => T) & GPUCallable<[value: Iterable<unknown>]> & {
64
+ declare const unroll: (<T extends Iterable<unknown>>(iterable: T) => T) & GPUCallable & {
10
65
  [$internal]: true;
11
66
  };
12
67
  //#endregion
@@ -2,7 +2,6 @@ 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
-
6
5
  //#region src/core/unroll/tgpuUnroll.ts
7
6
  /**
8
7
  * The result of calling `tgpu.unroll(...)`. The code responsible for
@@ -11,6 +10,7 @@ import { stitch } from "../resolve/stitch.js";
11
10
  */
12
11
  var UnrollableIterable = class {
13
12
  [$internal] = true;
13
+ snippet;
14
14
  constructor(snippet) {
15
15
  this.snippet = snippet;
16
16
  }
@@ -19,10 +19,69 @@ var UnrollableIterable = class {
19
19
  }
20
20
  };
21
21
  /**
22
- * Marks an iterable to be unrolled by the wgslGenerator.
22
+ * Marks an iterable to be unrolled by the shader generator when used in a for loop.
23
+ *
24
+ * @example
25
+ * ```ts
26
+ * const neighborOffsets = [d.vec2i(0, 1), d.vec2i(0, -1), d.vec2i(1, 0), d.vec2i(-1, 0)];
27
+ *
28
+ * // Unrolls into 4 blocks of code, one for each offset.
29
+ * for (const offset of tgpu.unroll(neighborOffsets)) {
30
+ * // ...
31
+ * }
32
+ * ```
33
+ *
34
+ * If you'd like to unroll over a range of numbers, use `tgpu.unroll(std.range(n))`.
35
+ *
36
+ * @example
37
+ * ```ts
38
+ * // (...)
39
+ * const FBM_OCTAVES = 3;
40
+ *
41
+ * function fbm(pos: d.v3f): number {
42
+ * 'use gpu';
43
+ * let sum = d.f32();
44
+ *
45
+ * // i = 0, 1, 2
46
+ * for (const i of tgpu.unroll(std.range(FBM_OCTAVES))) {
47
+ * sum +=
48
+ * noise3d(pos * (CLOUD_FREQUENCY * FBM_LACUNARITY ** i)) *
49
+ * (CLOUD_AMPLITUDE * FBM_PERSISTENCE ** i);
50
+ * }
51
+ *
52
+ * return sum;
53
+ * }
54
+ *
55
+ * ```
56
+ *
57
+ * Generates:
58
+ *
59
+ * ```wgsl
60
+ * // (...)
61
+ *
62
+ * fn fbm(pos: vec3f) -> f32 {
63
+ * var sum = 0f;
64
+ * // unrolled iteration #0
65
+ * {
66
+ * sum += noise3d(pos * 1.4f) * 1f;
67
+ * }
68
+ * // unrolled iteration #1
69
+ * {
70
+ * sum += noise3d(pos * 2.8f) * 0.5f;
71
+ * }
72
+ * // unrolled iteration #2
73
+ * {
74
+ * sum += noise3d(pos * 5.6f) * 0.25f;
75
+ * }
76
+ * return sum;
77
+ * }
78
+ * ```
23
79
  */
24
80
  const unroll = (() => {
25
- const impl = ((value) => value);
81
+ function jsImpl(iterable) {
82
+ return iterable;
83
+ }
84
+ const impl = jsImpl;
26
85
  setName(impl, "unroll");
27
86
  impl.toString = () => "unroll";
28
87
  impl[$internal] = true;
@@ -31,6 +90,5 @@ const unroll = (() => {
31
90
  } };
32
91
  return impl;
33
92
  })();
34
-
35
93
  //#endregion
36
- export { UnrollableIterable, unroll };
94
+ export { UnrollableIterable, unroll };
@@ -3,7 +3,6 @@ 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
-
7
6
  //#region src/core/valueProxyUtils.ts
8
7
  const valueProxyHandler = { get(target, prop) {
9
8
  if (prop in target) return Reflect.get(target, prop);
@@ -39,6 +38,5 @@ function getGpuValueRecursively(value) {
39
38
  }
40
39
  return unwrapped;
41
40
  }
42
-
43
41
  //#endregion
44
- export { getGpuValueRecursively, valueProxyHandler };
42
+ export { getGpuValueRecursively, valueProxyHandler };
@@ -6,7 +6,6 @@ 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
-
10
9
  //#region src/core/variable/tgpuVariable.ts
11
10
  /**
12
11
  * Defines a variable scoped to each entry function (private).
@@ -96,6 +95,5 @@ var TgpuVarImpl = class {
96
95
  this.$ = v;
97
96
  }
98
97
  };
99
-
100
98
  //#endregion
101
- export { isVariable, privateVar, workgroupVar };
99
+ export { isVariable, privateVar, workgroupVar };
@@ -1,6 +1,5 @@
1
1
  import { getCustomLocation, isData } from "../../data/dataTypes.js";
2
2
  import { isBuiltin } from "../../data/attributes.js";
3
-
4
3
  //#region src/core/vertexLayout/connectAttributesToShader.ts
5
4
  function isAttribute(value) {
6
5
  return typeof value?.format === "string";
@@ -54,6 +53,5 @@ function connectAttributesToShader(shaderInputLayout, attributes) {
54
53
  bufferDefinitions
55
54
  };
56
55
  }
57
-
58
56
  //#endregion
59
- export { connectAttributesToShader, isAttribute };
57
+ export { connectAttributesToShader, isAttribute };
@@ -6,7 +6,6 @@ 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
-
10
9
  //#region src/core/vertexLayout/vertexLayout.ts
11
10
  function vertexLayout(schemaForCount, stepMode = "vertex") {
12
11
  return new TgpuVertexLayoutImpl(schemaForCount, stepMode);
@@ -61,16 +60,18 @@ var TgpuVertexLayoutImpl = class {
61
60
  resourceType = "vertex-layout";
62
61
  stride;
63
62
  attrib;
64
- _customLocationMap = {};
63
+ schemaForCount;
64
+ stepMode;
65
+ #customLocationMap = {};
65
66
  constructor(schemaForCount, stepMode) {
66
67
  this.schemaForCount = schemaForCount;
67
68
  this.stepMode = stepMode;
68
69
  const arraySchema = schemaForCount(0);
69
70
  this.stride = roundUp(sizeOf(arraySchema.elementType), alignmentOf(arraySchema));
70
- this.attrib = dataToContainedAttribs(this, arraySchema.elementType, 0, this._customLocationMap);
71
+ this.attrib = dataToContainedAttribs(this, arraySchema.elementType, 0, this.#customLocationMap);
71
72
  }
72
73
  get vertexLayout() {
73
- if (this._customLocationMap[defaultAttribEntry] !== void 0) {
74
+ if (this.#customLocationMap[defaultAttribEntry] !== void 0) {
74
75
  if (typeof this.attrib.format !== "string" || typeof this.attrib.offset !== "number") throw new Error("Single attribute vertex layouts must have a format and offset.");
75
76
  return {
76
77
  arrayStride: this.stride,
@@ -78,18 +79,18 @@ var TgpuVertexLayoutImpl = class {
78
79
  attributes: [{
79
80
  format: this.attrib.format,
80
81
  offset: this.attrib.offset,
81
- shaderLocation: this._customLocationMap[defaultAttribEntry]
82
+ shaderLocation: this.#customLocationMap[defaultAttribEntry]
82
83
  }]
83
84
  };
84
85
  }
85
- if (!Object.keys(this.attrib).every((key) => this._customLocationMap[key] !== void 0)) throw new Error("All attributes must have custom locations in order to unwrap a vertex layout.");
86
+ if (!Object.keys(this.attrib).every((key) => this.#customLocationMap[key] !== void 0)) throw new Error("All attributes must have custom locations in order to unwrap a vertex layout.");
86
87
  return {
87
88
  arrayStride: this.stride,
88
89
  stepMode: this.stepMode,
89
90
  attributes: Object.entries(this.attrib).map(([key, attrib]) => ({
90
91
  format: attrib.format,
91
92
  offset: attrib.offset,
92
- shaderLocation: this._customLocationMap[key]
93
+ shaderLocation: this.#customLocationMap[key]
93
94
  }))
94
95
  };
95
96
  }
@@ -98,6 +99,5 @@ var TgpuVertexLayoutImpl = class {
98
99
  return this;
99
100
  }
100
101
  };
101
-
102
102
  //#endregion
103
- export { isVertexLayout, vertexLayout };
103
+ export { isVertexLayout, vertexLayout };
package/data/alignIO.js CHANGED
@@ -10,6 +10,5 @@ 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
-
14
13
  //#endregion
15
- export { alignIO as default };
14
+ export { alignIO as default };
@@ -1,4 +1,3 @@
1
- import "./wgslTypes.js";
2
1
  import { AnyData } from "./dataTypes.js";
3
2
 
4
3
  //#region src/data/alignmentOf.d.ts
@@ -2,7 +2,6 @@ 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
-
6
5
  //#region src/data/alignmentOf.ts
7
6
  const knownAlignmentMap = {
8
7
  f32: 4,
@@ -83,6 +82,5 @@ function customAlignmentOf(data) {
83
82
  function PUBLIC_alignmentOf(schema) {
84
83
  return alignmentOf(schema);
85
84
  }
86
-
87
85
  //#endregion
88
- export { PUBLIC_alignmentOf, alignmentOf, customAlignmentOf };
86
+ export { PUBLIC_alignmentOf, alignmentOf, customAlignmentOf };
package/data/array.d.ts CHANGED
@@ -1,7 +1,5 @@
1
1
  import { AnyWgslData, WgslArray } from "./wgslTypes.js";
2
2
  import { TgpuComptime } from "../core/function/comptime.js";
3
- import "../indexNamedExports.js";
4
-
5
3
  //#region src/data/array.d.ts
6
4
  interface WgslArrayConstructor {
7
5
  <TElement extends AnyWgslData>(elementType: TElement): (elementCount: number) => WgslArray<TElement>;
@@ -23,6 +21,6 @@ interface WgslArrayConstructor {
23
21
  * @param elementType The type of elements in the array.
24
22
  * @param elementCount The number of elements in the array.
25
23
  */
26
- declare const arrayOf: TgpuComptime<WgslArrayConstructor>;
24
+ declare const arrayOf: TgpuComptime;
27
25
  //#endregion
28
26
  export { arrayOf };
package/data/array.js CHANGED
@@ -2,7 +2,6 @@ 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
-
6
5
  //#region src/data/array.ts
7
6
  /**
8
7
  * Creates an array schema that can be used to construct gpu buffers.
@@ -40,9 +39,8 @@ const WgslArrayImpl = {
40
39
  [$internal]: true,
41
40
  type: "array",
42
41
  toString() {
43
- return `arrayOf(${this.elementType}, ${this.elementCount})`;
42
+ return `arrayOf(${String(this.elementType)}, ${this.elementCount})`;
44
43
  }
45
44
  };
46
-
47
45
  //#endregion
48
- export { arrayOf };
46
+ export { arrayOf };
package/data/atomic.js CHANGED
@@ -1,5 +1,4 @@
1
1
  import { $internal } from "../shared/symbols.js";
2
-
3
2
  //#region src/data/atomic.ts
4
3
  /**
5
4
  * Marks a concrete integer scalar type schema (u32 or i32) as a WGSL atomic.
@@ -16,10 +15,10 @@ function atomic(data) {
16
15
  var AtomicImpl = class {
17
16
  [$internal] = {};
18
17
  type = "atomic";
18
+ inner;
19
19
  constructor(inner) {
20
20
  this.inner = inner;
21
21
  }
22
22
  };
23
-
24
23
  //#endregion
25
- export { atomic };
24
+ export { atomic };
@@ -3,7 +3,6 @@ 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
-
7
6
  //#region src/data/attributes.ts
8
7
  function attribute(data, attrib) {
9
8
  if (isDecorated(data)) return new DecoratedImpl(data.inner, [attrib, ...data.attribs]);
@@ -114,6 +113,8 @@ function getAttributesString(field) {
114
113
  }
115
114
  var BaseDecoratedImpl = class {
116
115
  [$internal] = {};
116
+ inner;
117
+ attribs;
117
118
  constructor(inner, attribs) {
118
119
  this.inner = inner;
119
120
  this.attribs = attribs;
@@ -140,6 +141,5 @@ var LooseDecoratedImpl = class extends BaseDecoratedImpl {
140
141
  [$internal] = {};
141
142
  type = "loose-decorated";
142
143
  };
143
-
144
144
  //#endregion
145
- export { align, attribute, getAttributesString, interpolate, invariant, isBuiltin, location, size };
145
+ export { align, attribute, getAttributesString, interpolate, invariant, isBuiltin, location, size };