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,13 +1,13 @@
1
- //#region \0rolldown/runtime.js
1
+ //#region rolldown:runtime
2
2
  var __defProp = Object.defineProperty;
3
- var __exportAll = (all, no_symbols) => {
3
+ var __export = (all) => {
4
4
  let target = {};
5
5
  for (var name in all) __defProp(target, name, {
6
6
  get: all[name],
7
7
  enumerable: true
8
8
  });
9
- if (!no_symbols) __defProp(target, Symbol.toStringTag, { value: "Module" });
10
9
  return target;
11
10
  };
11
+
12
12
  //#endregion
13
- export { __exportAll };
13
+ export { __export };
package/builtin.js CHANGED
@@ -3,6 +3,7 @@ import { bool, f32, u32 } from "./data/numeric.js";
3
3
  import { vec3u, vec4f } from "./data/vector.js";
4
4
  import { attribute } from "./data/attributes.js";
5
5
  import { arrayOf } from "./data/array.js";
6
+
6
7
  //#region src/builtin.ts
7
8
  function defineBuiltin(dataType, value) {
8
9
  return attribute(dataType, {
@@ -31,5 +32,6 @@ const builtin = {
31
32
  subgroupId: defineBuiltin(u32, "subgroup_id"),
32
33
  numSubgroups: defineBuiltin(u32, "num_subgroups")
33
34
  };
35
+
34
36
  //#endregion
35
- export { builtin };
37
+ export { builtin };
@@ -1,6 +1,9 @@
1
1
  import { TgpuVertexFn } from "../core/function/tgpuVertexFn.js";
2
2
  import { Vec2f } from "../data/wgslTypes.js";
3
+ import "../indexNamedExports.js";
4
+
3
5
  //#region src/common/fullScreenTriangle.d.ts
6
+
4
7
  /**
5
8
  * A vertex function that defines a single full-screen triangle out
6
9
  * of three points.
@@ -17,6 +20,8 @@ import { Vec2f } from "../data/wgslTypes.js";
17
20
  * pipeline.draw(3);
18
21
  * ```
19
22
  */
20
- declare const fullScreenTriangle: TgpuVertexFn;
23
+ declare const fullScreenTriangle: TgpuVertexFn<{}, {
24
+ uv: Vec2f;
25
+ }>;
21
26
  //#endregion
22
27
  export { fullScreenTriangle };
@@ -1,6 +1,7 @@
1
1
  import { vec2f } from "../data/vector.js";
2
2
  import { builtin } from "../builtin.js";
3
3
  import { vertexFn } from "../core/function/tgpuVertexFn.js";
4
+
4
5
  //#region src/common/fullScreenTriangle.ts
5
6
  /**
6
7
  * A vertex function that defines a single full-screen triangle out
@@ -30,5 +31,6 @@ const fullScreenTriangle = vertexFn({
30
31
 
31
32
  return Out(vec4f(pos[in.vertexIndex], 0, 1), uv[in.vertexIndex]);
32
33
  }`;
34
+
33
35
  //#endregion
34
- export { fullScreenTriangle };
36
+ export { fullScreenTriangle };
package/common/index.js CHANGED
@@ -1,10 +1,12 @@
1
- import { __exportAll } from "../_virtual/_rolldown/runtime.js";
1
+ import { __export } from "../_virtual/rolldown_runtime.js";
2
2
  import { fullScreenTriangle } from "./fullScreenTriangle.js";
3
3
  import { writeSoA } from "./writeSoA.js";
4
+
4
5
  //#region src/common/index.ts
5
- var common_exports = /* @__PURE__ */ __exportAll({
6
+ var common_exports = /* @__PURE__ */ __export({
6
7
  fullScreenTriangle: () => fullScreenTriangle,
7
8
  writeSoA: () => writeSoA
8
9
  });
10
+
9
11
  //#endregion
10
- export { common_exports, fullScreenTriangle, writeSoA };
12
+ export { common_exports, fullScreenTriangle, writeSoA };
@@ -5,6 +5,7 @@ import { alignmentOf } from "../data/alignmentOf.js";
5
5
  import { roundUp } from "../mathUtils.js";
6
6
  import { sizeOf } from "../data/sizeOf.js";
7
7
  import { offsetsForProps } from "../data/offsets.js";
8
+
8
9
  //#region src/common/writeSoA.ts
9
10
  function packedSchemaOf(schema) {
10
11
  const unpackedSchema = undecorate(schema);
@@ -86,5 +87,6 @@ function writeSoA(buffer, data, options) {
86
87
  endOffset
87
88
  });
88
89
  }
90
+
89
91
  //#endregion
90
- export { writeSoA };
92
+ export { writeSoA };
@@ -3,8 +3,11 @@ import { $internal } from "../../shared/symbols.js";
3
3
  import { Prettify, UnionToIntersection } from "../../shared/utilityTypes.js";
4
4
  import { StorageFlag } from "../../extension.js";
5
5
  import { TgpuBufferMutable, TgpuBufferReadonly, TgpuBufferUniform, TgpuFixedBufferUsage } from "./bufferUsage.js";
6
+ import "../root/rootTypes.js";
6
7
  import { BaseData } from "../../data/wgslTypes.js";
7
8
  import { Infer, InferInput, InferPartial, InferPatch, IsValidIndexSchema, IsValidStorageSchema, IsValidUniformSchema, IsValidVertexSchema, MemIdentity } from "../../shared/repr.js";
9
+ import "../../data/dataTypes.js";
10
+
8
11
  //#region src/core/buffer/buffer.d.ts
9
12
  interface UniformFlag {
10
13
  usableAsUniform: true;
@@ -10,6 +10,7 @@ import { readData, writeData } from "../../data/dataIO.js";
10
10
  import { convertPartialToPatch, getPatchInstructions } from "../../data/partialIO.js";
11
11
  import { mutable, readonly, uniform } from "./bufferUsage.js";
12
12
  import { BufferReader, BufferWriter, getSystemEndianness } from "typed-binary";
13
+
13
14
  //#region src/core/buffer/buffer.ts
14
15
  const usageToUsageConstructor = {
15
16
  uniform,
@@ -212,9 +213,9 @@ var TgpuBufferImpl = class {
212
213
  if (gpuBuffer.mapState === "mapped") return readData(new BufferReader(this.#getMappedRange()), this.dataType);
213
214
  if (gpuBuffer.usage & GPUBufferUsage.MAP_READ) {
214
215
  await gpuBuffer.mapAsync(GPUMapMode.READ);
215
- const res = readData(new BufferReader(this.#getMappedRange()), this.dataType);
216
+ const res$1 = readData(new BufferReader(this.#getMappedRange()), this.dataType);
216
217
  this.#unmapBuffer();
217
- return res;
218
+ return res$1;
218
219
  }
219
220
  const stagingBuffer = this.#device.createBuffer({
220
221
  size: sizeOf(this.dataType),
@@ -242,5 +243,6 @@ var TgpuBufferImpl = class {
242
243
  return `buffer:${getName(this) ?? "<unnamed>"}`;
243
244
  }
244
245
  };
246
+
245
247
  //#endregion
246
- export { INTERNAL_createBuffer, isBuffer, isUsableAsVertex };
248
+ export { INTERNAL_createBuffer, isBuffer, isUsableAsVertex };
@@ -1,7 +1,9 @@
1
1
  import { TgpuNamable } from "../../shared/meta.js";
2
2
  import { $gpuValueOf, $internal } from "../../shared/symbols.js";
3
3
  import { StorageFlag } from "../../extension.js";
4
+ import "../../data/snippet.js";
4
5
  import { BufferWriteOptions, TgpuBuffer, UniformFlag } from "./buffer.js";
6
+ import "../../types.js";
5
7
  import { BaseData } from "../../data/wgslTypes.js";
6
8
  import { Infer, InferGPU, InferInput, InferPartial, InferPatch } from "../../shared/repr.js";
7
9
 
@@ -1,5 +1,6 @@
1
1
  import { $getNameForward, $gpuValueOf, $internal, $resolve } from "../../shared/symbols.js";
2
2
  import { getName, setName } from "../../shared/meta.js";
3
+
3
4
  //#region src/core/buffer/bufferShorthand.ts
4
5
  function isBufferShorthand(value) {
5
6
  return value instanceof TgpuBufferShorthandImpl;
@@ -49,5 +50,6 @@ var TgpuBufferShorthandImpl = class {
49
50
  return ctx.resolve(this.#usage);
50
51
  }
51
52
  };
53
+
52
54
  //#endregion
53
- export { TgpuBufferShorthandImpl, isBufferShorthand };
55
+ export { TgpuBufferShorthandImpl, isBufferShorthand };
@@ -1,5 +1,7 @@
1
1
  import { TgpuNamable } from "../../shared/meta.js";
2
2
  import { $gpuValueOf, $internal, $repr } from "../../shared/symbols.js";
3
+ import "../../data/snippet.js";
4
+ import "../../tgpuBindGroupLayout.js";
3
5
  import { TgpuBuffer, UniformFlag } from "./buffer.js";
4
6
  import { BindableBufferUsage } from "../../types.js";
5
7
  import { BaseData } from "../../data/wgslTypes.js";
@@ -8,6 +8,7 @@ import { schemaCallWrapper } from "../../data/schemaCallWrapper.js";
8
8
  import { assertExhaustive } from "../../shared/utilityTypes.js";
9
9
  import { valueProxyHandler } from "../valueProxyUtils.js";
10
10
  import { isUsableAsStorage } from "../../extension.js";
11
+
11
12
  //#region src/core/buffer/bufferUsage.ts
12
13
  function isUsableAsUniform(buffer) {
13
14
  return !!buffer.usableAsUniform;
@@ -161,5 +162,6 @@ function uniform(buffer) {
161
162
  }
162
163
  return usage;
163
164
  }
165
+
164
166
  //#endregion
165
- export { TgpuLaidOutBufferImpl, isUsableAsUniform, mutable, readonly, uniform };
167
+ export { TgpuLaidOutBufferImpl, isUsableAsUniform, mutable, readonly, uniform };
@@ -17,7 +17,8 @@ interface TgpuConst<TDataType extends BaseData = BaseData> extends TgpuNamable {
17
17
  readonly value: DeepReadonly<InferGPU<TDataType>>;
18
18
  readonly $: DeepReadonly<InferGPU<TDataType>>;
19
19
  readonly [$internal]: {
20
- /** Makes it differentiable on the type level. Does not exist at runtime. */dataType?: TDataType;
20
+ /** Makes it differentiable on the type level. Does not exist at runtime. */
21
+ dataType?: TDataType;
21
22
  };
22
23
  }
23
24
  /**
@@ -5,6 +5,7 @@ import { isData } from "../../data/dataTypes.js";
5
5
  import { snip } from "../../data/snippet.js";
6
6
  import { inCodegenMode } from "../../execMode.js";
7
7
  import { valueProxyHandler } from "../valueProxyUtils.js";
8
+
8
9
  //#region src/core/constant/tgpuConstant.ts
9
10
  function constant(dataType, value) {
10
11
  if (!isData(dataType)) {
@@ -64,5 +65,6 @@ var TgpuConstImpl = class {
64
65
  return this.$;
65
66
  }
66
67
  };
68
+
67
69
  //#endregion
68
- export { constant };
70
+ export { constant };
@@ -2,6 +2,7 @@ import { $internal, $resolve } from "../../shared/symbols.js";
2
2
  import { Void } from "../../data/wgslTypes.js";
3
3
  import { snip } from "../../data/snippet.js";
4
4
  import { applyExternals, replaceExternalsInWgsl } from "../resolve/externals.js";
5
+
5
6
  //#region src/core/declare/tgpuDeclare.ts
6
7
  /**
7
8
  * Allows defining extra declarations that shall be included in the final WGSL code,
@@ -35,5 +36,6 @@ var TgpuDeclareImpl = class {
35
36
  return `declare: ${this.#declaration}`;
36
37
  }
37
38
  };
39
+
38
40
  //#endregion
39
- export { declare };
41
+ export { declare };
@@ -1,8 +1,11 @@
1
1
  import { Assume, RemoveIndexSignature } from "../../shared/utilityTypes.js";
2
2
  import { BuiltinClipDistances, BuiltinFragDepth, BuiltinFrontFacing, BuiltinInstanceIndex, BuiltinPosition, BuiltinPrimitiveIndex, BuiltinSampleIndex, BuiltinSampleMask, BuiltinSubgroupInvocationId, BuiltinSubgroupSize, BuiltinVertexIndex, OmitBuiltins } from "../../builtin.js";
3
+ import "../../data/snippet.js";
3
4
  import { BaseIOData } from "./fnTypes.js";
4
5
  import { TgpuVertexAttrib } from "../../shared/vertexFormat.js";
6
+ import "../../data/autoStruct.js";
5
7
  import { FormatToWGSLType } from "../../data/vertexFormatData.js";
8
+ import "../../types.js";
6
9
  import { v4f } from "../../data/wgslTypes.js";
7
10
  import { InferGPU, InferGPURecord, InferRecord } from "../../shared/repr.js";
8
11
 
@@ -5,6 +5,7 @@ import { AutoStruct } from "../../data/autoStruct.js";
5
5
  import { createFnCore } from "./fnCore.js";
6
6
  import { shaderStageSlot } from "../slot/internalSlots.js";
7
7
  import { builtin } from "../../builtin.js";
8
+
8
9
  //#region src/core/function/autoIO.ts
9
10
  const builtinVertexIn = {
10
11
  $vertexIndex: builtin.vertexIndex,
@@ -81,5 +82,6 @@ var AutoVertexFn = class {
81
82
  };
82
83
  AutoVertexFn.prototype[$internal] = true;
83
84
  AutoVertexFn.prototype.resourceType = "auto-vertex-fn";
85
+
84
86
  //#endregion
85
- export { AutoFragmentFn, AutoVertexFn };
87
+ export { AutoFragmentFn, AutoVertexFn };
@@ -3,6 +3,7 @@ import { setName } from "../../shared/meta.js";
3
3
  import { WgslTypeError } from "../../errors.js";
4
4
  import { isKnownAtComptime } from "../../types.js";
5
5
  import { coerceToSnippet } from "../../tgsl/generationHelpers.js";
6
+
6
7
  //#region src/core/function/comptime.ts
7
8
  /**
8
9
  * Creates a version of `func` that can called safely in a TypeGPU function to
@@ -45,5 +46,6 @@ function comptime(func) {
45
46
  Object.defineProperty(impl, $internal, { value: { isComptime: true } });
46
47
  return impl;
47
48
  }
49
+
48
50
  //#endregion
49
- export { comptime };
51
+ export { comptime };
@@ -4,6 +4,7 @@ import { isPtr } from "../../data/wgslTypes.js";
4
4
  import { snip } from "../../data/snippet.js";
5
5
  import { NormalState, isKnownAtComptime } from "../../types.js";
6
6
  import { tryConvertSnippet } from "../../tgsl/conversion.js";
7
+
7
8
  //#region src/core/function/createCallableSchema.ts
8
9
  function callableSchema(options) {
9
10
  const impl = ((...args) => {
@@ -36,5 +37,6 @@ function callableSchema(options) {
36
37
  };
37
38
  return impl;
38
39
  }
40
+
39
41
  //#endregion
40
- export { callableSchema };
42
+ export { callableSchema };
@@ -5,6 +5,7 @@ import { snip } from "../../data/snippet.js";
5
5
  import { NormalState, isKnownAtComptime } from "../../types.js";
6
6
  import { tryConvertSnippet } from "../../tgsl/conversion.js";
7
7
  import { concretize } from "../../tgsl/generationHelpers.js";
8
+
8
9
  //#region src/core/function/dualImpl.ts
9
10
  var MissingCpuImplError = class extends Error {
10
11
  constructor(message) {
@@ -48,5 +49,6 @@ function dualImpl(options) {
48
49
  };
49
50
  return impl;
50
51
  }
52
+
51
53
  //#endregion
52
- export { MissingCpuImplError, dualImpl };
54
+ export { MissingCpuImplError, dualImpl };
@@ -2,6 +2,7 @@ import { $internal } from "../../shared/symbols.js";
2
2
  import { isWgslStruct } from "../../data/wgslTypes.js";
3
3
  import { undecorate } from "../../data/dataTypes.js";
4
4
  import { snip } from "../../data/snippet.js";
5
+
5
6
  //#region src/core/function/entryInputRouter.ts
6
7
  /**
7
8
  * Routes `(input) => { input.x }` style property access to the correct WGSL
@@ -35,5 +36,6 @@ var EntryInputRouter = class {
35
36
  }
36
37
  }
37
38
  };
39
+
38
40
  //#endregion
39
- export { EntryInputRouter };
41
+ export { EntryInputRouter };
@@ -200,5 +200,6 @@ const openingCommentBlock = new Set(["*/"]);
200
200
  const parentheses = ["(", ")"];
201
201
  const angleBrackets = ["<", ">"];
202
202
  const commentBlocks = ["/*", "*/"];
203
+
203
204
  //#endregion
204
- export { extractArgs };
205
+ export { extractArgs };
@@ -7,6 +7,7 @@ import { MissingLinksError } from "../../errors.js";
7
7
  import { getAttributesString } from "../../data/attributes.js";
8
8
  import { applyExternals, replaceExternalsInWgsl } from "../resolve/externals.js";
9
9
  import { extractArgs } from "./extractArgs.js";
10
+
10
11
  //#region src/core/function/fnCore.ts
11
12
  function createFnCore(implementation, fnAttribute = "") {
12
13
  /**
@@ -31,7 +32,7 @@ function createFnCore(implementation, fnAttribute = "") {
31
32
  if (validArgNames && Object.keys(validArgNames).length > 0) applyExternals(externalMap, { in: validArgNames });
32
33
  const replacedImpl = replaceExternalsInWgsl(ctx, externalMap, implementation);
33
34
  let header = "";
34
- let body = "";
35
+ let body$1 = "";
35
36
  if (fnAttribute !== "" && entryInput && validArgNames) {
36
37
  const { dataSchema, positionalArgs } = entryInput;
37
38
  const parts = [];
@@ -43,14 +44,14 @@ function createFnCore(implementation, fnAttribute = "") {
43
44
  const input = `(${parts.join(", ")})`;
44
45
  const attributes = isWgslData(returnType) ? getAttributesString(returnType) : "";
45
46
  header = `${input}${returnType !== Void ? isWgslStruct(returnType) ? ` -> ${ctx.resolve(returnType).value} ` : ` -> ${attributes !== "" ? attributes : "@location(0)"} ${ctx.resolve(returnType).value} ` : " "}`;
46
- body = replacedImpl;
47
+ body$1 = replacedImpl;
47
48
  } else {
48
49
  const providedArgs = extractArgs(replacedImpl);
49
50
  if (providedArgs.args.length !== argTypes.length) throw new Error(`WGSL implementation has ${providedArgs.args.length} arguments, while the shell has ${argTypes.length} arguments.`);
50
51
  header = `(${providedArgs.args.map((argInfo, i) => `${argInfo.identifier}: ${checkAndReturnType(ctx, `parameter ${argInfo.identifier}`, argInfo.type, argTypes[i])}`).join(", ")})${returnType === Void ? " " : ` -> ${checkAndReturnType(ctx, "return type", providedArgs.ret?.type, returnType)} `}`;
51
- body = replacedImpl.slice(providedArgs.range.end);
52
+ body$1 = replacedImpl.slice(providedArgs.range.end);
52
53
  }
53
- ctx.addDeclaration(`${fnAttribute}fn ${id}${header}${body}`);
54
+ ctx.addDeclaration(`${fnAttribute}fn ${id}${header}${body$1}`);
54
55
  return snip(id, returnType, "runtime");
55
56
  }
56
57
  const pluginData = getMetaData(implementation);
@@ -77,7 +78,7 @@ function createFnCore(implementation, fnAttribute = "") {
77
78
  };
78
79
  }
79
80
  function isArgUsedInBody(argName, body) {
80
- return new RegExp(`\\b${argName}\\b`).test(body);
81
+ return (/* @__PURE__ */ new RegExp(`\\b${argName}\\b`)).test(body);
81
82
  }
82
83
  function checkAndReturnType(ctx, name, wgslType, jsType) {
83
84
  const resolvedJsType = ctx.resolve(jsType).value.replace(/\s/g, "");
@@ -86,5 +87,6 @@ function checkAndReturnType(ctx, name, wgslType, jsType) {
86
87
  if (resolvedWgslType !== resolvedJsType) throw new Error(`Type mismatch between TGPU shell and WGSL code string: ${name}, JS type "${resolvedJsType}", WGSL type "${resolvedWgslType}".`);
87
88
  return wgslType;
88
89
  }
90
+
89
91
  //#endregion
90
- export { createFnCore };
92
+ export { createFnCore };
@@ -2,6 +2,8 @@ import { BuiltinClipDistances } from "../../builtin.js";
2
2
  import { AnyAttribute } from "../../data/attributes.js";
3
3
  import { BaseData, Bool, Decorated, F16, F32, I32, U32, Vec2f, Vec2h, Vec2i, Vec2u, Vec3f, Vec3h, Vec3i, Vec3u, Vec4f, Vec4h, Vec4i, Vec4u, Void } from "../../data/wgslTypes.js";
4
4
  import { InferGPU } from "../../shared/repr.js";
5
+ import "tinyest";
6
+
5
7
  //#region src/core/function/fnTypes.d.ts
6
8
  type AnyFn = (...args: never[]) => unknown;
7
9
  type InferArgs<T extends unknown[]> = { [Idx in keyof T]: InferGPU<T[Idx]> };
@@ -1,4 +1,5 @@
1
1
  import { Decorate, HasCustomLocation, IsBuiltin } from "../../data/attributes.js";
2
+ import "./fnTypes.js";
2
3
  import { BaseData, Location, WgslStruct } from "../../data/wgslTypes.js";
3
4
 
4
5
  //#region src/core/function/ioSchema.d.ts
@@ -2,6 +2,7 @@ import { isVoid } from "../../data/wgslTypes.js";
2
2
  import { getCustomLocation, isData } from "../../data/dataTypes.js";
3
3
  import { isBuiltin, location } from "../../data/attributes.js";
4
4
  import { INTERNAL_createStruct } from "../../data/struct.js";
5
+
5
6
  //#region src/core/function/ioSchema.ts
6
7
  function withLocations(members, locations = {}) {
7
8
  let nextLocation = 0;
@@ -47,5 +48,6 @@ function separateAllAsPositional(schema) {
47
48
  function createIoSchema(layout, locations = {}) {
48
49
  return isData(layout) ? isVoid(layout) ? layout : isBuiltin(layout) ? layout : getCustomLocation(layout) !== void 0 ? layout : location(0, layout) : INTERNAL_createStruct(withLocations(layout, locations), false);
49
50
  }
51
+
50
52
  //#endregion
51
- export { createIoSchema, separateAllAsPositional, separateBuiltins };
53
+ export { createIoSchema, separateAllAsPositional, separateBuiltins };
@@ -3,6 +3,7 @@ import { SelfResolvable } from "../../types.js";
3
3
  import { BaseData } from "../../data/wgslTypes.js";
4
4
 
5
5
  //#region src/core/function/shelllessImpl.d.ts
6
+
6
7
  /**
7
8
  * Shell-less functions are possible because we can infer the signature based solely on the context
8
9
  * around the function.
@@ -1,6 +1,7 @@
1
1
  import { $getNameForward, $internal, $resolve } from "../../shared/symbols.js";
2
2
  import { getName } from "../../shared/meta.js";
3
3
  import { createFnCore } from "./fnCore.js";
4
+
4
5
  //#region src/core/function/shelllessImpl.ts
5
6
  function createShelllessImpl(argTypes, implementation) {
6
7
  const core = createFnCore(implementation, "");
@@ -17,5 +18,6 @@ function createShelllessImpl(argTypes, implementation) {
17
18
  }
18
19
  };
19
20
  }
21
+
20
22
  //#endregion
21
- export { createShelllessImpl };
23
+ export { createShelllessImpl };
@@ -8,5 +8,6 @@ function isTemplateStringsArray(value) {
8
8
  function templateLiteralIdentity(strings, ...values) {
9
9
  return strings.slice(1).reduce((acc, elem, index) => `${acc}${values[index]}${elem}`, strings[0]);
10
10
  }
11
+
11
12
  //#endregion
12
- export { stripTemplate };
13
+ export { stripTemplate };
@@ -5,6 +5,7 @@ import { IORecord, InferIO } from "./fnTypes.js";
5
5
  import { Void } from "../../data/wgslTypes.js";
6
6
 
7
7
  //#region src/core/function/tgpuComputeFn.d.ts
8
+
8
9
  /**
9
10
  * Describes a compute entry function signature (its arguments, return type and workgroup size)
10
11
  */
@@ -5,6 +5,7 @@ import { separateBuiltins } from "./ioSchema.js";
5
5
  import { createFnCore } from "./fnCore.js";
6
6
  import { stripTemplate } from "./templateUtils.js";
7
7
  import { shaderStageSlot } from "../slot/internalSlots.js";
8
+
8
9
  //#region src/core/function/tgpuComputeFn.ts
9
10
  /**
10
11
  * Creates a shell of a typed entry function for the compute shader stage. Any function
@@ -51,5 +52,6 @@ function createComputeFn(shell, workgroupSize, implementation, entryInput) {
51
52
  }
52
53
  };
53
54
  }
55
+
54
56
  //#endregion
55
- export { computeFn, isTgpuComputeFn };
57
+ export { computeFn, isTgpuComputeFn };
@@ -9,6 +9,7 @@ import { BaseData, Void } from "../../data/wgslTypes.js";
9
9
  import { InferGPU } from "../../shared/repr.js";
10
10
 
11
11
  //#region src/core/function/tgpuFn.d.ts
12
+
12
13
  /**
13
14
  * Describes a function signature (its arguments and return type)
14
15
  */
@@ -11,6 +11,7 @@ import { comptime } from "./comptime.js";
11
11
  import { addArgTypesToExternals, addReturnTypeToExternals } from "../resolve/externals.js";
12
12
  import { createFnCore } from "./fnCore.js";
13
13
  import { stripTemplate } from "./templateUtils.js";
14
+
14
15
  //#region src/core/function/tgpuFn.ts
15
16
  function fn(argTypesOrCallback, returnType) {
16
17
  if (typeof argTypesOrCallback === "function") return createGenericFn(argTypesOrCallback, []);
@@ -54,7 +55,7 @@ function createFn(shell, _implementation) {
54
55
  return this;
55
56
  },
56
57
  with: comptime((slot, value) => {
57
- return createBoundFunction(fn, [[isAccessor(slot) || isMutableAccessor(slot) ? slot.slot : slot, value]]);
58
+ return createBoundFunction(fn$1, [[isAccessor(slot) || isMutableAccessor(slot) ? slot.slot : slot, value]]);
58
59
  }),
59
60
  [$resolve](ctx) {
60
61
  if (typeof implementation === "string") {
@@ -78,18 +79,18 @@ function createFn(shell, _implementation) {
78
79
  const result = implementation(...castAndCopiedArgs);
79
80
  return schemaCallWrapper(shell.returnType, result);
80
81
  } catch (err) {
81
- if (err instanceof ExecutionError) throw err.appendToTrace(fn);
82
- throw new ExecutionError(err, [fn]);
82
+ if (err instanceof ExecutionError) throw err.appendToTrace(fn$1);
83
+ throw new ExecutionError(err, [fn$1]);
83
84
  }
84
85
  }),
85
- codegenImpl: (ctx, args) => ctx.withResetIndentLevel(() => stitch`${ctx.resolve(fn).value}(${args})`)
86
+ codegenImpl: (ctx, args) => ctx.withResetIndentLevel(() => stitch`${ctx.resolve(fn$1).value}(${args})`)
86
87
  });
87
- const fn = Object.assign(call, fnBase);
88
- Object.defineProperty(fn, "toString", { value() {
88
+ const fn$1 = Object.assign(call, fnBase);
89
+ Object.defineProperty(fn$1, "toString", { value() {
89
90
  return `fn:${getName(core) ?? "<unnamed>"}`;
90
91
  } });
91
- if (pairs.length > 0) return createBoundFunction(fn, pairs);
92
- return fn;
92
+ if (pairs.length > 0) return createBoundFunction(fn$1, pairs);
93
+ return fn$1;
93
94
  }
94
95
  function createBoundFunction(innerFn, pairs) {
95
96
  const fnBase = {
@@ -121,15 +122,15 @@ function createBoundFunction(innerFn, pairs) {
121
122
  returnType: innerFn.shell.returnType
122
123
  },
123
124
  normalImpl: innerFn,
124
- codegenImpl: (ctx, args) => ctx.withResetIndentLevel(() => stitch`${ctx.resolve(fn).value}(${args})`)
125
+ codegenImpl: (ctx, args) => ctx.withResetIndentLevel(() => stitch`${ctx.resolve(fn$1).value}(${args})`)
125
126
  });
126
- const fn = Object.assign(call, fnBase);
127
- Object.defineProperty(fn, "toString", { value() {
127
+ const fn$1 = Object.assign(call, fnBase);
128
+ Object.defineProperty(fn$1, "toString", { value() {
128
129
  return `fn:${getName(this) ?? "<unnamed>"}[${pairs.map(stringifyPair).join(", ")}]`;
129
130
  } });
130
131
  const innerName = getName(innerFn);
131
- if (innerName) setName(fn, innerName);
132
- return fn;
132
+ if (innerName) setName(fn$1, innerName);
133
+ return fn$1;
133
134
  }
134
135
  function createGenericFn(inner, pairs) {
135
136
  const fnBase = {
@@ -164,5 +165,6 @@ function createGenericFn(inner, pairs) {
164
165
  } });
165
166
  return genericFn;
166
167
  }
168
+
167
169
  //#endregion
168
- export { fn, isGenericFn, isTgpuFn };
170
+ export { fn, isGenericFn, isTgpuFn };
@@ -5,6 +5,7 @@ import { addReturnTypeToExternals } from "../resolve/externals.js";
5
5
  import { createFnCore } from "./fnCore.js";
6
6
  import { stripTemplate } from "./templateUtils.js";
7
7
  import { shaderStageSlot } from "../slot/internalSlots.js";
8
+
8
9
  //#region src/core/function/tgpuFragmentFn.ts
9
10
  /**
10
11
  * Creates a shell of a typed entry function for the fragment shader stage. Any function
@@ -59,5 +60,6 @@ function createFragmentFn(shell, implementation) {
59
60
  }
60
61
  };
61
62
  }
63
+
62
64
  //#endregion
63
- export { fragmentFn, isTgpuFragmentFn };
65
+ export { fragmentFn, isTgpuFragmentFn };
@@ -4,6 +4,7 @@ import { createIoSchema, separateAllAsPositional } from "./ioSchema.js";
4
4
  import { createFnCore } from "./fnCore.js";
5
5
  import { stripTemplate } from "./templateUtils.js";
6
6
  import { shaderStageSlot } from "../slot/internalSlots.js";
7
+
7
8
  //#region src/core/function/tgpuVertexFn.ts
8
9
  /**
9
10
  * Creates a shell of a typed entry function for the vertex shader stage. Any function
@@ -55,5 +56,6 @@ function createVertexFn(shell, implementation) {
55
56
  }
56
57
  };
57
58
  }
59
+
58
60
  //#endregion
59
- export { isTgpuVertexFn, vertexFn };
61
+ export { isTgpuVertexFn, vertexFn };
@@ -2,6 +2,7 @@ import { MissingBindGroupsError, MissingVertexBuffersError } from "../../errors.
2
2
  import { isBuffer } from "../buffer/buffer.js";
3
3
  import { isBindGroup } from "../../tgpuBindGroupLayout.js";
4
4
  import { warnIfOverflow } from "./limitsOverflow.js";
5
+
5
6
  //#region src/core/pipeline/applyPipelineState.ts
6
7
  function applyBindGroups(encoder, root, usedBindGroupLayouts, catchall, resolveBindGroup) {
7
8
  const missingBindGroups = new Set(usedBindGroupLayouts);
@@ -31,5 +32,6 @@ function applyVertexBuffers(encoder, root, usedVertexLayouts, resolveVertexBuffe
31
32
  });
32
33
  if (missingVertexLayouts.size > 0) throw new MissingVertexBuffersError(missingVertexLayouts);
33
34
  }
35
+
34
36
  //#endregion
35
- export { applyBindGroups, applyVertexBuffers };
37
+ export { applyBindGroups, applyVertexBuffers };
@@ -1,8 +1,12 @@
1
1
  import { TgpuNamable } from "../../shared/meta.js";
2
2
  import { $internal } from "../../shared/symbols.js";
3
3
  import { AnyComputeBuiltin } from "../../builtin.js";
4
+ import "../querySet/querySet.js";
5
+ import "../../data/snippet.js";
6
+ import "../../tgsl/consoleLog/types.js";
4
7
  import { IORecord } from "../function/fnTypes.js";
5
8
  import { TgpuComputeFn } from "../function/tgpuComputeFn.js";
9
+ import "../slot/slotTypes.js";
6
10
  import { PrimitiveOffsetInfo } from "../../data/offsetUtils.js";
7
11
  import { Timeable, TimestampWritesPriors } from "./timeable.js";
8
12
  import { TgpuBindGroup, TgpuBindGroupLayout, TgpuLayoutEntry } from "../../tgpuBindGroupLayout.js";