typegpu 0.11.1 → 0.11.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (216) hide show
  1. package/_virtual/{_rolldown/runtime.js → rolldown_runtime.js} +4 -4
  2. package/builtin.js +3 -1
  3. package/common/fullScreenTriangle.d.ts +6 -1
  4. package/common/fullScreenTriangle.js +3 -1
  5. package/common/index.js +5 -3
  6. package/common/writeSoA.js +3 -1
  7. package/core/buffer/buffer.d.ts +3 -0
  8. package/core/buffer/buffer.js +5 -3
  9. package/core/buffer/bufferShorthand.d.ts +2 -0
  10. package/core/buffer/bufferShorthand.js +3 -1
  11. package/core/buffer/bufferUsage.d.ts +2 -0
  12. package/core/buffer/bufferUsage.js +3 -1
  13. package/core/constant/tgpuConstant.d.ts +2 -1
  14. package/core/constant/tgpuConstant.js +3 -1
  15. package/core/declare/tgpuDeclare.js +3 -1
  16. package/core/function/autoIO.d.ts +3 -0
  17. package/core/function/autoIO.js +5 -3
  18. package/core/function/comptime.js +3 -1
  19. package/core/function/createCallableSchema.js +3 -1
  20. package/core/function/dualImpl.js +3 -1
  21. package/core/function/entryInputRouter.js +13 -17
  22. package/core/function/extractArgs.js +2 -1
  23. package/core/function/fnCore.js +17 -11
  24. package/core/function/fnTypes.d.ts +2 -0
  25. package/core/function/ioSchema.d.ts +1 -0
  26. package/core/function/ioSchema.js +3 -1
  27. package/core/function/shelllessImpl.d.ts +1 -0
  28. package/core/function/shelllessImpl.js +4 -2
  29. package/core/function/templateUtils.js +2 -1
  30. package/core/function/tgpuComputeFn.d.ts +1 -0
  31. package/core/function/tgpuComputeFn.js +4 -2
  32. package/core/function/tgpuFn.d.ts +1 -0
  33. package/core/function/tgpuFn.js +17 -15
  34. package/core/function/tgpuFragmentFn.js +4 -2
  35. package/core/function/tgpuVertexFn.js +4 -2
  36. package/core/pipeline/applyPipelineState.js +3 -1
  37. package/core/pipeline/computePipeline.d.ts +4 -0
  38. package/core/pipeline/computePipeline.js +8 -6
  39. package/core/pipeline/connectAttachmentToShader.js +3 -1
  40. package/core/pipeline/connectTargetsToShader.js +3 -1
  41. package/core/pipeline/limitsOverflow.js +2 -1
  42. package/core/pipeline/pipelineUtils.js +6 -4
  43. package/core/pipeline/renderPipeline.js +21 -19
  44. package/core/pipeline/timeable.d.ts +2 -0
  45. package/core/pipeline/timeable.js +3 -1
  46. package/core/pipeline/typeGuards.js +3 -1
  47. package/core/querySet/querySet.d.ts +2 -0
  48. package/core/querySet/querySet.js +3 -1
  49. package/core/rawCodeSnippet/tgpuRawCodeSnippet.d.ts +1 -0
  50. package/core/rawCodeSnippet/tgpuRawCodeSnippet.js +3 -1
  51. package/core/resolve/externals.d.ts +3 -0
  52. package/core/resolve/externals.js +7 -5
  53. package/core/resolve/namespace.js +6 -4
  54. package/core/resolve/resolveData.js +3 -1
  55. package/core/resolve/stitch.js +3 -1
  56. package/core/resolve/tgpuResolve.js +7 -5
  57. package/core/root/configurableImpl.js +3 -1
  58. package/core/root/init.d.ts +10 -2
  59. package/core/root/init.js +4 -2
  60. package/core/root/rootTypes.d.ts +11 -11
  61. package/core/sampler/sampler.d.ts +4 -0
  62. package/core/sampler/sampler.js +3 -1
  63. package/core/simulate/tgpuSimulate.js +6 -4
  64. package/core/slot/accessor.d.ts +4 -0
  65. package/core/slot/accessor.js +3 -1
  66. package/core/slot/internalSlots.js +3 -1
  67. package/core/slot/lazy.js +3 -1
  68. package/core/slot/slot.js +3 -1
  69. package/core/slot/slotTypes.js +3 -1
  70. package/core/texture/externalTexture.d.ts +6 -0
  71. package/core/texture/externalTexture.js +3 -1
  72. package/core/texture/texture.d.ts +4 -0
  73. package/core/texture/texture.js +6 -4
  74. package/core/texture/textureFormats.js +3 -1
  75. package/core/texture/textureUtils.js +3 -1
  76. package/core/texture/usageExtension.js +3 -1
  77. package/core/unroll/tgpuUnroll.d.ts +3 -1
  78. package/core/unroll/tgpuUnroll.js +3 -1
  79. package/core/valueProxyUtils.js +7 -5
  80. package/core/variable/tgpuVariable.d.ts +3 -1
  81. package/core/variable/tgpuVariable.js +3 -1
  82. package/core/vertexLayout/connectAttributesToShader.js +3 -1
  83. package/core/vertexLayout/vertexAttribute.d.ts +1 -0
  84. package/core/vertexLayout/vertexLayout.js +7 -5
  85. package/data/alignIO.js +3 -1
  86. package/data/alignmentOf.d.ts +2 -0
  87. package/data/alignmentOf.js +3 -1
  88. package/data/array.js +3 -1
  89. package/data/atomic.d.ts +1 -0
  90. package/data/atomic.js +3 -1
  91. package/data/attributes.js +7 -5
  92. package/data/autoStruct.d.ts +3 -1
  93. package/data/autoStruct.js +3 -1
  94. package/data/compiledIO.js +39 -37
  95. package/data/dataIO.js +22 -20
  96. package/data/dataTypes.d.ts +9 -4
  97. package/data/dataTypes.js +3 -1
  98. package/data/deepEqual.d.ts +1 -0
  99. package/data/deepEqual.js +3 -1
  100. package/data/disarray.d.ts +3 -1
  101. package/data/disarray.js +3 -1
  102. package/data/getLongestContiguousPrefix.d.ts +2 -0
  103. package/data/getLongestContiguousPrefix.js +3 -1
  104. package/data/index.d.ts +3 -3
  105. package/data/index.js +5 -6
  106. package/data/isContiguous.d.ts +2 -0
  107. package/data/isContiguous.js +3 -1
  108. package/data/matrix.d.ts +11 -8
  109. package/data/matrix.js +3 -1
  110. package/data/numberOps.js +2 -1
  111. package/data/numeric.d.ts +1 -0
  112. package/data/numeric.js +19 -15
  113. package/data/offsetUtils.d.ts +1 -0
  114. package/data/offsetUtils.js +3 -1
  115. package/data/offsets.js +5 -3
  116. package/data/partialIO.js +3 -1
  117. package/data/ptr.d.ts +1 -0
  118. package/data/ptr.js +3 -1
  119. package/data/ref.d.ts +3 -0
  120. package/data/ref.js +5 -3
  121. package/data/sampler.js +3 -1
  122. package/data/schemaCallWrapper.js +3 -1
  123. package/data/schemaMemoryLayout.js +3 -1
  124. package/data/sizeOf.d.ts +2 -0
  125. package/data/sizeOf.js +3 -1
  126. package/data/snippet.d.ts +1 -6
  127. package/data/snippet.js +3 -1
  128. package/data/struct.d.ts +1 -0
  129. package/data/struct.js +3 -1
  130. package/data/texture.js +3 -1
  131. package/data/unstruct.d.ts +1 -0
  132. package/data/unstruct.js +3 -1
  133. package/data/vector.d.ts +1 -0
  134. package/data/vector.js +3 -1
  135. package/data/vectorImpl.js +3 -1
  136. package/data/vectorOps.js +3 -1
  137. package/data/vertexFormatData.js +3 -1
  138. package/data/wgslTypes.d.ts +4 -0
  139. package/data/wgslTypes.js +3 -1
  140. package/errors.d.ts +1 -0
  141. package/errors.js +3 -1
  142. package/execMode.js +3 -1
  143. package/extension.d.ts +1 -0
  144. package/extension.js +3 -1
  145. package/getGPUValue.js +3 -1
  146. package/index.js +3 -4
  147. package/indexNamedExports.d.ts +1 -0
  148. package/mathUtils.js +2 -1
  149. package/memo.js +2 -1
  150. package/nameRegistry.js +3 -1
  151. package/package.js +3 -2
  152. package/package.json +1 -1
  153. package/resolutionCtx.d.ts +11 -0
  154. package/resolutionCtx.js +86 -87
  155. package/shared/env.js +2 -1
  156. package/shared/generators.js +2 -1
  157. package/shared/meta.js +3 -1
  158. package/shared/repr.d.ts +1 -0
  159. package/shared/stringify.js +3 -1
  160. package/shared/symbols.js +42 -10
  161. package/shared/utilityTypes.js +2 -1
  162. package/shared/vertexFormat.js +2 -1
  163. package/std/array.d.ts +1 -1
  164. package/std/array.js +3 -1
  165. package/std/atomic.d.ts +12 -12
  166. package/std/atomic.js +3 -1
  167. package/std/bitcast.d.ts +2 -2
  168. package/std/bitcast.js +3 -1
  169. package/std/boolean.d.ts +15 -14
  170. package/std/boolean.js +3 -1
  171. package/std/derivative.d.ts +9 -9
  172. package/std/derivative.js +3 -1
  173. package/std/discard.d.ts +1 -1
  174. package/std/discard.js +3 -1
  175. package/std/extensions.d.ts +3 -1
  176. package/std/extensions.js +3 -1
  177. package/std/index.js +5 -3
  178. package/std/matrix.d.ts +6 -5
  179. package/std/matrix.js +3 -1
  180. package/std/numeric.d.ts +132 -78
  181. package/std/numeric.js +7 -5
  182. package/std/operators.d.ts +8 -8
  183. package/std/operators.js +7 -5
  184. package/std/packing.d.ts +5 -4
  185. package/std/packing.js +3 -1
  186. package/std/range.d.ts +3 -1
  187. package/std/range.js +3 -1
  188. package/std/subgroup.d.ts +21 -21
  189. package/std/subgroup.js +3 -1
  190. package/std/texture.d.ts +11 -11
  191. package/std/texture.js +9 -7
  192. package/tgpu.js +5 -3
  193. package/tgpuBindGroupLayout.d.ts +11 -7
  194. package/tgpuBindGroupLayout.js +3 -1
  195. package/tgpuUnstable.js +5 -3
  196. package/tgsl/accessIndex.js +5 -3
  197. package/tgsl/accessProp.js +10 -3
  198. package/tgsl/consoleLog/deserializers.js +3 -1
  199. package/tgsl/consoleLog/logGenerator.js +18 -9
  200. package/tgsl/consoleLog/serializers.js +3 -1
  201. package/tgsl/consoleLog/types.d.ts +3 -0
  202. package/tgsl/consoleLog/types.js +2 -1
  203. package/tgsl/conversion.js +18 -6
  204. package/tgsl/forOfUtils.js +17 -7
  205. package/tgsl/generationHelpers.d.ts +1 -0
  206. package/tgsl/generationHelpers.js +3 -4
  207. package/tgsl/math.js +3 -1
  208. package/tgsl/shaderGenerator.d.ts +3 -2
  209. package/tgsl/shaderGenerator_members.d.ts +15 -2
  210. package/tgsl/shaderGenerator_members.js +5 -3
  211. package/tgsl/shellless.js +3 -1
  212. package/tgsl/wgslGenerator.d.ts +3 -1
  213. package/tgsl/wgslGenerator.js +54 -44
  214. package/types.d.ts +11 -7
  215. package/types.js +3 -1
  216. package/wgslExtensions.js +2 -1
@@ -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, []);
@@ -39,7 +40,7 @@ function createFn(shell, _implementation) {
39
40
  pairs = _implementation[$providing]?.pairs ?? [];
40
41
  implementation = _implementation[$internal].inner;
41
42
  } else implementation = _implementation;
42
- const core = createFnCore(implementation, "");
43
+ const core = createFnCore(implementation, "normal");
43
44
  const fnBase = {
44
45
  shell,
45
46
  resourceType: "function",
@@ -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
@@ -31,7 +32,7 @@ function isTgpuFragmentFn(value) {
31
32
  return value?.shell?.entryPoint === "fragment";
32
33
  }
33
34
  function createFragmentFn(shell, implementation) {
34
- const core = createFnCore(implementation, "@fragment ");
35
+ const core = createFnCore(implementation, "fragment");
35
36
  const outputType = shell.returnType;
36
37
  if (typeof implementation === "string") addReturnTypeToExternals(implementation, outputType, (externals) => core.applyExternals(externals));
37
38
  return {
@@ -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
@@ -31,7 +32,7 @@ function isTgpuVertexFn(value) {
31
32
  return value?.shell?.entryPoint === "vertex";
32
33
  }
33
34
  function createVertexFn(shell, implementation) {
34
- const core = createFnCore(implementation, "@vertex ");
35
+ const core = createFnCore(implementation, "vertex");
35
36
  const entryInput = separateAllAsPositional(shell.in ?? {});
36
37
  return {
37
38
  shell,
@@ -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";
@@ -12,6 +12,7 @@ import { logDataFromGPU } from "../../tgsl/consoleLog/deserializers.js";
12
12
  import { wgslExtensionToFeatureName, wgslExtensions } from "../../wgslExtensions.js";
13
13
  import { resolveIndirectOffset } from "./pipelineUtils.js";
14
14
  import { createWithPerformanceCallback, createWithTimestampWrites, setupTimestampWrites, triggerPerformanceCallback } from "./timeable.js";
15
+
15
16
  //#region src/core/pipeline/computePipeline.ts
16
17
  function INTERNAL_createComputePipeline(branch, slotBindings, descriptor) {
17
18
  return new TgpuComputePipelineImpl(new ComputePipelineCore(branch, slotBindings, descriptor), {});
@@ -111,14 +112,14 @@ var TgpuComputePipelineImpl = class TgpuComputePipelineImpl {
111
112
  return;
112
113
  }
113
114
  if (this.#priors.externalEncoder) {
114
- const passDescriptor = {
115
+ const passDescriptor$1 = {
115
116
  label: getName(this.#core) ?? "<unnamed>",
116
117
  ...setupTimestampWrites(this.#priors, root)
117
118
  };
118
- const pass = this.#priors.externalEncoder.beginComputePass(passDescriptor);
119
- this._applyComputeState(pass);
120
- dispatch(pass);
121
- pass.end();
119
+ const pass$1 = this.#priors.externalEncoder.beginComputePass(passDescriptor$1);
120
+ this._applyComputeState(pass$1);
121
+ dispatch(pass$1);
122
+ pass$1.end();
122
123
  return;
123
124
  }
124
125
  const memo = this.#core.unwrap();
@@ -223,5 +224,6 @@ var ComputePipelineCore = class {
223
224
  return this._memo;
224
225
  }
225
226
  };
227
+
226
228
  //#endregion
227
- export { INTERNAL_createComputePipeline };
229
+ export { INTERNAL_createComputePipeline };
@@ -1,5 +1,6 @@
1
1
  import { isWgslStruct } from "../../data/wgslTypes.js";
2
2
  import { isBuiltin } from "../../data/attributes.js";
3
+
3
4
  //#region src/core/pipeline/connectAttachmentToShader.ts
4
5
  function isColorAttachment(value) {
5
6
  return !!value?.view;
@@ -20,5 +21,6 @@ function connectAttachmentToShader(fragmentOut, attachment) {
20
21
  if (!isColorAttachment(attachment)) throw new Error("Expected a single color attachment, not a record.");
21
22
  return [attachment];
22
23
  }
24
+
23
25
  //#endregion
24
- export { connectAttachmentToShader };
26
+ export { connectAttachmentToShader };
@@ -1,5 +1,6 @@
1
1
  import { isVoid, isWgslStruct } from "../../data/wgslTypes.js";
2
2
  import { isBuiltin } from "../../data/attributes.js";
3
+
3
4
  //#region src/core/pipeline/connectTargetsToShader.ts
4
5
  function connectTargetsToShader(fragmentOut, targets) {
5
6
  let presentationFormat;
@@ -23,5 +24,6 @@ function connectTargetsToShader(fragmentOut, targets) {
23
24
  format: singleTarget?.format ?? (presentationFormat ??= navigator.gpu.getPreferredCanvasFormat())
24
25
  }];
25
26
  }
27
+
26
28
  //#endregion
27
- export { connectTargetsToShader };
29
+ export { connectTargetsToShader };
@@ -8,5 +8,6 @@ function warnIfOverflow(layouts, limits) {
8
8
  2. Increasing the limit when requesting a device or creating a root.`);
9
9
  if (storage > limits.maxStorageBuffersPerShaderStage) console.warn(`Total number of storage buffers (${storage}) exceeds maxStorageBuffersPerShaderStage (${limits.maxStorageBuffersPerShaderStage}).`);
10
10
  }
11
+
11
12
  //#endregion
12
- export { warnIfOverflow };
13
+ export { warnIfOverflow };
@@ -1,6 +1,7 @@
1
1
  import { isGPUBuffer } from "../../types.js";
2
2
  import { sizeOf } from "../../data/sizeOf.js";
3
3
  import { memoryLayoutOf } from "../../data/offsetUtils.js";
4
+
4
5
  //#region src/core/pipeline/pipelineUtils.ts
5
6
  const IndirectOperationToRequiredData = {
6
7
  dispatchWorkgroupsIndirect: "3 x u32",
@@ -13,9 +14,9 @@ function validateIndirectBufferSize(bufferSize, offset, requiredBytes, operation
13
14
  }
14
15
  function resolveIndirectOffset(indirectBuffer, start, requiredSize, operation) {
15
16
  if (isGPUBuffer(indirectBuffer)) {
16
- const offset = typeof start === "number" ? start : start?.offset ?? 0;
17
- validateIndirectBufferSize(indirectBuffer.size, offset, requiredSize, operation);
18
- return offset;
17
+ const offset$1 = typeof start === "number" ? start : start?.offset ?? 0;
18
+ validateIndirectBufferSize(indirectBuffer.size, offset$1, requiredSize, operation);
19
+ return offset$1;
19
20
  }
20
21
  const { offset, contiguous } = start ? typeof start === "number" ? {
21
22
  offset: start,
@@ -25,5 +26,6 @@ function resolveIndirectOffset(indirectBuffer, start, requiredSize, operation) {
25
26
  if (contiguous < requiredSize) console.warn(`${operation}: Starting at offset ${offset}, only ${contiguous} contiguous bytes are available before padding. '${operation}' requires ${requiredSize} bytes (${IndirectOperationToRequiredData[operation]}). Reading across padding may result in undefined behavior.`);
26
27
  return offset;
27
28
  }
29
+
28
30
  //#endregion
29
- export { resolveIndirectOffset };
31
+ export { resolveIndirectOffset };
@@ -22,6 +22,7 @@ import { AutoFragmentFn, AutoVertexFn } from "../function/autoIO.js";
22
22
  import { isVertexLayout } from "../vertexLayout/vertexLayout.js";
23
23
  import { connectAttachmentToShader } from "./connectAttachmentToShader.js";
24
24
  import { connectTargetsToShader } from "./connectTargetsToShader.js";
25
+
25
26
  //#region src/core/pipeline/renderPipeline.ts
26
27
  const DRAW_INDIRECT_SIZE = 16;
27
28
  const DRAW_INDEXED_INDIRECT_SIZE = 20;
@@ -212,10 +213,10 @@ var TgpuRenderPipelineImpl = class TgpuRenderPipelineImpl {
212
213
  return;
213
214
  }
214
215
  if (internals.priors.externalEncoder) {
215
- const pass = this._createRenderPass(internals.priors.externalEncoder);
216
- this._applyRenderState(pass);
217
- pass.draw(vertexCount, instanceCount, firstVertex, firstInstance);
218
- pass.end();
216
+ const pass$1 = this._createRenderPass(internals.priors.externalEncoder);
217
+ this._applyRenderState(pass$1);
218
+ pass$1.draw(vertexCount, instanceCount, firstVertex, firstInstance);
219
+ pass$1.end();
219
220
  return;
220
221
  }
221
222
  const { logResources } = internals.core.unwrap();
@@ -244,11 +245,11 @@ var TgpuRenderPipelineImpl = class TgpuRenderPipelineImpl {
244
245
  return;
245
246
  }
246
247
  if (internals.priors.externalEncoder) {
247
- const pass = this._createRenderPass(internals.priors.externalEncoder);
248
- this._applyRenderState(pass);
249
- this._setIndexBuffer(pass);
250
- pass.drawIndexed(indexCount, instanceCount, firstIndex, baseVertex, firstInstance);
251
- pass.end();
248
+ const pass$1 = this._createRenderPass(internals.priors.externalEncoder);
249
+ this._applyRenderState(pass$1);
250
+ this._setIndexBuffer(pass$1);
251
+ pass$1.drawIndexed(indexCount, instanceCount, firstIndex, baseVertex, firstInstance);
252
+ pass$1.end();
252
253
  return;
253
254
  }
254
255
  const { logResources } = internals.core.unwrap();
@@ -279,10 +280,10 @@ var TgpuRenderPipelineImpl = class TgpuRenderPipelineImpl {
279
280
  return;
280
281
  }
281
282
  if (internals.priors.externalEncoder) {
282
- const pass = this._createRenderPass(internals.priors.externalEncoder);
283
- this._applyRenderState(pass);
284
- pass.drawIndirect(rawBuffer, offset);
285
- pass.end();
283
+ const pass$1 = this._createRenderPass(internals.priors.externalEncoder);
284
+ this._applyRenderState(pass$1);
285
+ pass$1.drawIndirect(rawBuffer, offset);
286
+ pass$1.end();
286
287
  return;
287
288
  }
288
289
  const { logResources } = internals.core.unwrap();
@@ -313,11 +314,11 @@ var TgpuRenderPipelineImpl = class TgpuRenderPipelineImpl {
313
314
  return;
314
315
  }
315
316
  if (internals.priors.externalEncoder) {
316
- const pass = this._createRenderPass(internals.priors.externalEncoder);
317
- this._applyRenderState(pass);
318
- this._setIndexBuffer(pass);
319
- pass.drawIndexedIndirect(rawBuffer, offset);
320
- pass.end();
317
+ const pass$1 = this._createRenderPass(internals.priors.externalEncoder);
318
+ this._applyRenderState(pass$1);
319
+ this._setIndexBuffer(pass$1);
320
+ pass$1.drawIndexedIndirect(rawBuffer, offset);
321
+ pass$1.end();
321
322
  return;
322
323
  }
323
324
  const { logResources } = internals.core.unwrap();
@@ -485,5 +486,6 @@ function matchUpVaryingLocations(vertexOut = {}, fragmentIn = {}, vertexFnName,
485
486
  function isGPUCanvasContext(value) {
486
487
  return typeof value?.getCurrentTexture === "function";
487
488
  }
489
+
488
490
  //#endregion
489
- export { INTERNAL_createRenderPipeline };
491
+ export { INTERNAL_createRenderPipeline };
@@ -1,4 +1,6 @@
1
1
  import { TgpuQuerySet } from "../querySet/querySet.js";
2
+ import "../root/rootTypes.js";
3
+
2
4
  //#region src/core/pipeline/timeable.d.ts
3
5
  interface Timeable {
4
6
  withPerformanceCallback(callback: (start: bigint, end: bigint) => void | Promise<void>): this;
@@ -1,5 +1,6 @@
1
1
  import { $internal } from "../../shared/symbols.js";
2
2
  import { isQuerySet } from "../querySet/querySet.js";
3
+
3
4
  //#region src/core/pipeline/timeable.ts
4
5
  function createWithPerformanceCallback(currentPriors, callback, querySet) {
5
6
  if (!currentPriors.timestampWrites) return {
@@ -51,5 +52,6 @@ function triggerPerformanceCallback({ root, priors }) {
51
52
  await callback(start, end);
52
53
  });
53
54
  }
55
+
54
56
  //#endregion
55
- export { createWithPerformanceCallback, createWithTimestampWrites, setupTimestampWrites, triggerPerformanceCallback };
57
+ export { createWithPerformanceCallback, createWithTimestampWrites, setupTimestampWrites, triggerPerformanceCallback };
@@ -1,4 +1,5 @@
1
1
  import { $internal } from "../../shared/symbols.js";
2
+
2
3
  //#region src/core/pipeline/typeGuards.ts
3
4
  function isComputePipeline(value) {
4
5
  const maybe = value;
@@ -23,5 +24,6 @@ function isGPURenderPassEncoder(value) {
23
24
  function isGPURenderBundleEncoder(value) {
24
25
  return !!value && typeof value === "object" && "draw" in value && "finish" in value && !("executeBundles" in value) && !("beginRenderPass" in value) && !("dispatchWorkgroups" in value);
25
26
  }
27
+
26
28
  //#endregion
27
- export { isComputePipeline, isGPUCommandEncoder, isGPUComputePassEncoder, isGPURenderBundleEncoder, isGPURenderPassEncoder, isPipeline, isRenderPipeline };
29
+ export { isComputePipeline, isGPUCommandEncoder, isGPUComputePassEncoder, isGPURenderBundleEncoder, isGPURenderPassEncoder, isPipeline, isRenderPipeline };
@@ -1,5 +1,7 @@
1
1
  import { TgpuNamable } from "../../shared/meta.js";
2
2
  import { $internal } from "../../shared/symbols.js";
3
+ import "../root/rootTypes.js";
4
+
3
5
  //#region src/core/querySet/querySet.d.ts
4
6
  interface TgpuQuerySet<T extends GPUQueryType> extends TgpuNamable {
5
7
  readonly resourceType: 'query-set';
@@ -1,5 +1,6 @@
1
1
  import { $internal } from "../../shared/symbols.js";
2
2
  import { setName } from "../../shared/meta.js";
3
+
3
4
  //#region src/core/querySet/querySet.ts
4
5
  function INTERNAL_createQuerySet(group, type, count, rawQuerySet) {
5
6
  return new TgpuQuerySetImpl(group, type, count, rawQuerySet);
@@ -100,5 +101,6 @@ var TgpuQuerySetImpl = class {
100
101
  this.#readBuffer = this.#resolveBuffer = void 0;
101
102
  }
102
103
  };
104
+
103
105
  //#endregion
104
- export { INTERNAL_createQuerySet, isQuerySet };
106
+ export { INTERNAL_createQuerySet, isQuerySet };
@@ -5,6 +5,7 @@ import { InferGPU } from "../../shared/repr.js";
5
5
  import { AnyData } from "../../data/dataTypes.js";
6
6
 
7
7
  //#region src/core/rawCodeSnippet/tgpuRawCodeSnippet.d.ts
8
+
8
9
  /**
9
10
  * Extra declaration that will be included in final WGSL code
10
11
  * when resolving objects that use it.
@@ -3,6 +3,7 @@ import { snip } from "../../data/snippet.js";
3
3
  import { inCodegenMode } from "../../execMode.js";
4
4
  import { valueProxyHandler } from "../valueProxyUtils.js";
5
5
  import { applyExternals, replaceExternalsInWgsl } from "../resolve/externals.js";
6
+
6
7
  //#region src/core/rawCodeSnippet/tgpuRawCodeSnippet.ts
7
8
  /**
8
9
  * An advanced API that creates a typed shader expression which
@@ -90,5 +91,6 @@ var TgpuRawCodeSnippetImpl = class {
90
91
  return this.$;
91
92
  }
92
93
  };
94
+
93
95
  //#endregion
94
- export { rawCodeSnippet };
96
+ export { rawCodeSnippet };
@@ -1,4 +1,7 @@
1
+ import "../../types.js";
2
+
1
3
  //#region src/core/resolve/externals.d.ts
4
+
2
5
  /**
3
6
  * A key-value mapping where keys represent identifiers within shader code,
4
7
  * and values can be any type that can be resolved to a code string.
@@ -2,6 +2,7 @@ import { getName, hasTinyestMetadata, setName } from "../../shared/meta.js";
2
2
  import { isWgslStruct } from "../../data/wgslTypes.js";
3
3
  import { isLooseData } from "../../data/dataTypes.js";
4
4
  import { isWgsl } from "../../types.js";
5
+
5
6
  //#region src/core/resolve/externals.ts
6
7
  /**
7
8
  * Merges two external maps into one. If a key is present in both maps, the value from the new map is used.
@@ -15,17 +16,17 @@ function applyExternals(existing, newExternals) {
15
16
  if (value && (typeof value === "object" || typeof value === "function") && getName(value) === void 0) setName(value, key);
16
17
  }
17
18
  }
18
- function addArgTypesToExternals(implementation, argTypes, applyExternals) {
19
+ function addArgTypesToExternals(implementation, argTypes, applyExternals$1) {
19
20
  const argTypeNames = [...implementation.matchAll(/:\s*(?<arg>.*?)\s*[,)]/g)].map((found) => found ? found[1] : void 0);
20
- applyExternals(Object.fromEntries(argTypes.flatMap((argType, i) => {
21
+ applyExternals$1(Object.fromEntries(argTypes.flatMap((argType, i) => {
21
22
  const argTypeName = argTypeNames ? argTypeNames[i] : void 0;
22
23
  return isWgslStruct(argType) && argTypeName !== void 0 ? [[argTypeName, argType]] : [];
23
24
  })));
24
25
  }
25
- function addReturnTypeToExternals(implementation, returnType, applyExternals) {
26
+ function addReturnTypeToExternals(implementation, returnType, applyExternals$1) {
26
27
  const matched = implementation.match(/->\s(?<output>[\w\d_]+)\s{/);
27
28
  const outputName = matched ? matched[1]?.trim() : void 0;
28
- if (isWgslStruct(returnType) && outputName && !/\s/g.test(outputName)) applyExternals({ [outputName]: returnType });
29
+ if (isWgslStruct(returnType) && outputName && !/\s/g.test(outputName)) applyExternals$1({ [outputName]: returnType });
29
30
  }
30
31
  function identifierRegex(name) {
31
32
  return new RegExp(`(?<![\\w\\$_.])${name.replaceAll(".", "\\.").replaceAll("$", "\\$")}(?![\\w\\$_])`, "g");
@@ -52,5 +53,6 @@ function replaceExternalsInWgsl(ctx, externalMap, wgsl) {
52
53
  return acc;
53
54
  }, wgsl);
54
55
  }
56
+
55
57
  //#endregion
56
- export { addArgTypesToExternals, addReturnTypeToExternals, applyExternals, replaceExternalsInWgsl };
58
+ export { addArgTypesToExternals, addReturnTypeToExternals, applyExternals, replaceExternalsInWgsl };
@@ -2,6 +2,7 @@ import { $internal } from "../../shared/symbols.js";
2
2
  import { getName } from "../../shared/meta.js";
3
3
  import { RandomNameRegistry, StrictNameRegistry } from "../../nameRegistry.js";
4
4
  import { ShelllessRepository } from "../../tgsl/shellless.js";
5
+
5
6
  //#region src/core/resolve/namespace.ts
6
7
  var NamespaceImpl = class {
7
8
  [$internal];
@@ -23,9 +24,9 @@ var NamespaceImpl = class {
23
24
  throw new Error(`Unsupported event: ${event}`);
24
25
  }
25
26
  };
26
- function getUniqueName(namespace, resource) {
27
- const name = namespace.nameRegistry.makeUnique(getName(resource), true);
28
- for (const listener of namespace.listeners.name) listener({
27
+ function getUniqueName(namespace$1, resource) {
28
+ const name = namespace$1.nameRegistry.makeUnique(getName(resource), true);
29
+ for (const listener of namespace$1.listeners.name) listener({
29
30
  target: resource,
30
31
  name
31
32
  });
@@ -35,5 +36,6 @@ function namespace(options) {
35
36
  const { names = "strict" } = options ?? {};
36
37
  return new NamespaceImpl(names === "strict" ? new StrictNameRegistry() : new RandomNameRegistry());
37
38
  }
39
+
38
40
  //#endregion
39
- export { getUniqueName, namespace };
41
+ export { getUniqueName, namespace };
@@ -6,6 +6,7 @@ import { getAttributesString } from "../../data/attributes.js";
6
6
  import { isWgslComparisonSampler, isWgslSampler } from "../../data/sampler.js";
7
7
  import { accessModeMap, isWgslStorageTexture, isWgslTexture } from "../../data/texture.js";
8
8
  import { isAttribute } from "../vertexLayout/connectAttributesToShader.js";
9
+
9
10
  //#region src/core/resolve/resolveData.ts
10
11
  /**
11
12
  * Schemas for which their `type` property directly
@@ -140,5 +141,6 @@ function resolveData(ctx, data) {
140
141
  if (isWgslComparisonSampler(data) || isWgslSampler(data)) return data.type;
141
142
  assertExhaustive(data, "resolveData");
142
143
  }
144
+
143
145
  //#endregion
144
- export { resolveData };
146
+ export { resolveData };
@@ -1,5 +1,6 @@
1
1
  import { isSnippet } from "../../data/snippet.js";
2
2
  import { getResolutionCtx } from "../../execMode.js";
3
+
3
4
  //#region src/core/resolve/stitch.ts
4
5
  /**
5
6
  * "The reverse of snipping"
@@ -19,5 +20,6 @@ function stitch(strings, ...snippets) {
19
20
  }
20
21
  return result;
21
22
  }
23
+
22
24
  //#endregion
23
- export { stitch };
25
+ export { stitch };
@@ -4,14 +4,15 @@ import { snip } from "../../data/snippet.js";
4
4
  import { applyExternals, replaceExternalsInWgsl } from "./externals.js";
5
5
  import { namespace } from "./namespace.js";
6
6
  import { isBindGroupLayout } from "../../tgpuBindGroupLayout.js";
7
- import { resolve as resolve$1 } from "../../resolutionCtx.js";
7
+ import { resolve } from "../../resolutionCtx.js";
8
8
  import { isPipeline } from "../pipeline/typeGuards.js";
9
+
9
10
  //#region src/core/resolve/tgpuResolve.ts
10
11
  function resolveWithContext(arg0, options) {
11
12
  if (Array.isArray(arg0)) return resolveFromArray(arg0, options);
12
13
  return resolveFromTemplate(arg0);
13
14
  }
14
- function resolve(arg, options) {
15
+ function resolve$1(arg, options) {
15
16
  if (Array.isArray(arg)) return resolveWithContext(arg, options).code;
16
17
  return resolveWithContext(arg).code;
17
18
  }
@@ -20,7 +21,7 @@ function resolveFromTemplate(options) {
20
21
  if (!template) console.warn("Calling resolve with an empty template is deprecated and will soon return an empty string. Consider using the 'tgpu.resolve(resolvableArray, options)' API instead.");
21
22
  const dependencies = {};
22
23
  applyExternals(dependencies, externals ?? {});
23
- return resolve$1({
24
+ return resolve({
24
25
  [$internal]: true,
25
26
  [$resolve](ctx) {
26
27
  return snip(replaceExternalsInWgsl(ctx, dependencies, template ?? ""), Void, "runtime");
@@ -36,7 +37,7 @@ function resolveFromTemplate(options) {
36
37
  }
37
38
  function resolveFromArray(items, options) {
38
39
  const { unstable_shaderGenerator: shaderGenerator, names = "strict", config, enableExtensions } = options ?? {};
39
- return resolve$1({
40
+ return resolve({
40
41
  [$internal]: true,
41
42
  [$resolve](ctx) {
42
43
  for (const item of items) if (isBindGroupLayout(item)) for (const binding of Object.values(item[$internal].bound)) ctx.resolve(binding);
@@ -62,5 +63,6 @@ function tryFindRoot(items) {
62
63
  if (pipelines.length > 1) throw new Error(`Found ${pipelines.length} pipelines but can only resolve one at a time.`);
63
64
  return pipelines[0]?.[$internal].root;
64
65
  }
66
+
65
67
  //#endregion
66
- export { resolve, resolveWithContext };
68
+ export { resolve$1 as resolve, resolveWithContext };
@@ -1,4 +1,5 @@
1
1
  import { isAccessor, isMutableAccessor } from "../slot/slotTypes.js";
2
+
2
3
  //#region src/core/root/configurableImpl.ts
3
4
  var ConfigurableImpl = class ConfigurableImpl {
4
5
  bindings;
@@ -13,5 +14,6 @@ var ConfigurableImpl = class ConfigurableImpl {
13
14
  return new ConfigurableImpl([...this.bindings, ...newCfg.bindings]);
14
15
  }
15
16
  };
17
+
16
18
  //#endregion
17
- export { ConfigurableImpl };
19
+ export { ConfigurableImpl };
@@ -1,7 +1,13 @@
1
+ import "../buffer/bufferShorthand.js";
1
2
  import { LogGeneratorOptions } from "../../tgsl/consoleLog/types.js";
3
+ import "../pipeline/computePipeline.js";
4
+ import "../../tgpuBindGroupLayout.js";
2
5
  import { ShaderGenerator } from "../../tgsl/shaderGenerator.js";
3
6
  import { TgpuRoot } from "./rootTypes.js";
7
+ import "../../data/wgslTypes.js";
8
+
4
9
  //#region src/core/root/init.d.ts
10
+
5
11
  /**
6
12
  * Options passed into {@link init}.
7
13
  */
@@ -9,7 +15,8 @@ type InitOptions = {
9
15
  adapter?: GPURequestAdapterOptions | undefined;
10
16
  device?: (GPUDeviceDescriptor & {
11
17
  optionalFeatures?: Iterable<GPUFeatureName>;
12
- }) | undefined; /** @default 'random' */
18
+ }) | undefined;
19
+ /** @default 'random' */
13
20
  unstable_names?: 'random' | 'strict' | undefined;
14
21
  /**
15
22
  * A custom shader code generator, used when resolving TypeGPU functions.
@@ -22,7 +29,8 @@ type InitOptions = {
22
29
  * Options passed into {@link initFromDevice}.
23
30
  */
24
31
  type InitFromDeviceOptions = {
25
- device: GPUDevice; /** @default 'random' */
32
+ device: GPUDevice;
33
+ /** @default 'random' */
26
34
  unstable_names?: 'random' | 'strict' | undefined;
27
35
  /**
28
36
  * A custom shader code generator, used when resolving TypeGPU functions.