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
package/data/snippet.js CHANGED
@@ -1,11 +1,18 @@
1
1
  import { DEV } from "../shared/env.js";
2
2
  import { isNumericSchema } from "./wgslTypes.js";
3
3
  import { undecorate } from "./dataTypes.js";
4
-
5
4
  //#region src/data/snippet.ts
6
5
  function isEphemeralOrigin(space) {
7
6
  return space === "runtime" || space === "constant" || space === "argument";
8
7
  }
8
+ /**
9
+ * What happens to a snippet's origin when it's deep copied in JS, and left as is in WGSL?
10
+ * e.g. `vec3f(vec3f(0, 1, 2))`
11
+ */
12
+ function fallthroughCopyOrigin(origin) {
13
+ if (origin === "runtime" || origin === "constant") return origin;
14
+ return "runtime";
15
+ }
9
16
  function isEphemeralSnippet(snippet) {
10
17
  return isEphemeralOrigin(snippet.origin);
11
18
  }
@@ -40,6 +47,9 @@ const originToPtrParams = {
40
47
  }
41
48
  };
42
49
  var SnippetImpl = class {
50
+ value;
51
+ dataType;
52
+ origin;
43
53
  constructor(value, dataType, origin) {
44
54
  this.value = value;
45
55
  this.dataType = dataType;
@@ -56,6 +66,5 @@ function snip(value, dataType, origin) {
56
66
  if (DEV && isSnippet(value)) throw new Error("Cannot nest snippets");
57
67
  return new SnippetImpl(value, undecorate(dataType), origin);
58
68
  }
59
-
60
69
  //#endregion
61
- export { isEphemeralOrigin, isEphemeralSnippet, isSnippet, isSnippetNumeric, originToPtrParams, snip };
70
+ export { fallthroughCopyOrigin, isEphemeralOrigin, isEphemeralSnippet, isSnippet, isSnippetNumeric, originToPtrParams, snip };
package/data/struct.js CHANGED
@@ -2,7 +2,6 @@ import { $internal } from "../shared/symbols.js";
2
2
  import { getName, setName } from "../shared/meta.js";
3
3
  import { schemaCallWrapper } from "./schemaCallWrapper.js";
4
4
  import { isValidProp } from "../nameRegistry.js";
5
-
6
5
  //#region src/data/struct.ts
7
6
  /**
8
7
  * Creates a struct schema that can be used to construct GPU buffers.
@@ -41,6 +40,5 @@ const WgslStructImpl = {
41
40
  return `struct:${getName(this) ?? "<unnamed>"}`;
42
41
  }
43
42
  };
44
-
45
43
  //#endregion
46
- export { INTERNAL_createStruct, abstruct, struct };
44
+ export { INTERNAL_createStruct, abstruct, struct };
package/data/texture.js CHANGED
@@ -1,6 +1,5 @@
1
1
  import { $internal, $repr } from "../shared/symbols.js";
2
2
  import { f32 } from "./numeric.js";
3
-
4
3
  //#region src/data/texture.ts
5
4
  function textureDescriptorToSchema(desc) {
6
5
  if ("multisampled" in desc) {
@@ -203,6 +202,5 @@ function isWgslStorageTexture(value) {
203
202
  function isWgslExternalTexture(value) {
204
203
  return !!value[$internal] && value.type === "texture_external";
205
204
  }
206
-
207
205
  //#endregion
208
- export { accessModeMap, isWgslExternalTexture, isWgslStorageTexture, isWgslTexture, texture1d, texture2d, texture2dArray, texture3d, textureCube, textureCubeArray, textureDepth2d, textureDepth2dArray, textureDepthCube, textureDepthCubeArray, textureDepthMultisampled2d, textureDescriptorToSchema, textureExternal, textureMultisampled2d, textureStorage1d, textureStorage2d, textureStorage2dArray, textureStorage3d };
206
+ export { accessModeMap, isWgslExternalTexture, isWgslStorageTexture, isWgslTexture, texture1d, texture2d, texture2dArray, texture3d, textureCube, textureCubeArray, textureDepth2d, textureDepth2dArray, textureDepthCube, textureDepthCubeArray, textureDepthMultisampled2d, textureDescriptorToSchema, textureExternal, textureMultisampled2d, textureStorage1d, textureStorage2d, textureStorage2dArray, textureStorage3d };
package/data/unstruct.js CHANGED
@@ -1,7 +1,6 @@
1
1
  import { $internal } from "../shared/symbols.js";
2
2
  import { getName, setName } from "../shared/meta.js";
3
3
  import { schemaCallWrapper } from "./schemaCallWrapper.js";
4
-
5
4
  //#region src/data/unstruct.ts
6
5
  /**
7
6
  * Creates a loose struct schema that can be used to construct vertex buffers.
@@ -38,6 +37,5 @@ const UnstructImpl = {
38
37
  return `unstruct:${getName(this) ?? "<unnamed>"}`;
39
38
  }
40
39
  };
41
-
42
40
  //#endregion
43
- export { unstruct };
41
+ export { unstruct };
package/data/vector.js CHANGED
@@ -1,10 +1,8 @@
1
1
  import { $internal, $repr } from "../shared/symbols.js";
2
2
  import { isVec } from "./wgslTypes.js";
3
- import { stitch } from "../core/resolve/stitch.js";
4
3
  import { callableSchema } from "../core/function/createCallableSchema.js";
5
4
  import { bool, f16, f32, i32, u32 } from "./numeric.js";
6
5
  import { Vec2bImpl, Vec2fImpl, Vec2hImpl, Vec2iImpl, Vec2uImpl, Vec3bImpl, Vec3fImpl, Vec3hImpl, Vec3iImpl, Vec3uImpl, Vec4bImpl, Vec4fImpl, Vec4hImpl, Vec4iImpl, Vec4uImpl } from "./vectorImpl.js";
7
-
8
6
  //#region src/data/vector.ts
9
7
  /**
10
8
  * Schema representing vec2f - a vector with 2 elements of type f32.
@@ -222,15 +220,10 @@ function makeVecSchema(VecImpl, primitive) {
222
220
  };
223
221
  const construct = callableSchema({
224
222
  name: type,
225
- signature: (...args) => ({
226
- argTypes: args.map((arg) => isVec(arg) ? arg : primitive),
227
- returnType: schema
228
- }),
223
+ schema: () => schema,
224
+ argTypes: (...args) => args.map((arg) => isVec(arg) ? arg : primitive),
229
225
  normalImpl: cpuConstruct,
230
- codegenImpl: (_ctx, args) => {
231
- if (args.length === 1 && args[0]?.dataType === schema) return stitch`${args[0]}`;
232
- return stitch`${type}(${args})`;
233
- }
226
+ codegenImpl: (ctx, args) => ctx.gen.typeInstantiation(schema, args)
234
227
  });
235
228
  const schema = Object.assign(construct, {
236
229
  [$internal]: {},
@@ -242,6 +235,5 @@ function makeVecSchema(VecImpl, primitive) {
242
235
  VecImpl.prototype.schema = schema;
243
236
  return schema;
244
237
  }
245
-
246
238
  //#endregion
247
- export { vec2b, vec2f, vec2h, vec2i, vec2u, vec3b, vec3f, vec3h, vec3i, vec3u, vec4b, vec4f, vec4h, vec4i, vec4u, vecTypeToConstructor };
239
+ export { vec2b, vec2f, vec2h, vec2i, vec2u, vec3b, vec3f, vec3h, vec3i, vec3u, vec4b, vec4f, vec4h, vec4i, vec4u, vecTypeToConstructor };
@@ -1,7 +1,7 @@
1
1
  import { $internal, $resolve } from "../shared/symbols.js";
2
- import { snip } from "./snippet.js";
2
+ import { WORKAROUND_getSchema } from "./wgslTypes.js";
3
3
  import { bool, f16, f32, i32, u32 } from "./numeric.js";
4
-
4
+ import { numericLiteralToSnippet } from "../tgsl/generationHelpers.js";
5
5
  //#region src/data/vectorImpl.ts
6
6
  const XYZW = [
7
7
  "x",
@@ -51,14 +51,14 @@ var VecBase = class VecBase extends Array {
51
51
  castElement() {
52
52
  return this[$internal].elementSchema;
53
53
  }
54
- [$resolve]() {
55
- const schema = this[$internal].elementSchema;
56
- if (this.every((e) => !e)) return snip(`${this.kind}()`, schema, "constant");
57
- if (this.every((e) => this[0] === e)) return snip(`${this.kind}(${this[0]})`, schema, "runtime");
58
- return snip(`${this.kind}(${this.join(", ")})`, schema, "runtime");
54
+ [$resolve](ctx) {
55
+ const vecSchema = WORKAROUND_getSchema(this);
56
+ if (this.every((e) => !e)) return ctx.gen.typeInstantiation(vecSchema, []);
57
+ if (this.every((e) => this[0] === e)) return ctx.gen.typeInstantiation(vecSchema, [numericLiteralToSnippet(this[0])]);
58
+ return ctx.gen.typeInstantiation(vecSchema, this.map((e) => numericLiteralToSnippet(e)));
59
59
  }
60
60
  toString() {
61
- return this[$resolve]().value;
61
+ return `${this.kind}(${this.join(", ")})`;
62
62
  }
63
63
  };
64
64
  var Vec2 = class extends VecBase {
@@ -213,46 +213,46 @@ var Vec4 = class extends VecBase {
213
213
  get y() {
214
214
  return this[1];
215
215
  }
216
- get r() {
217
- return this[0];
218
- }
219
- get g() {
220
- return this[1];
221
- }
222
- get b() {
216
+ get z() {
223
217
  return this[2];
224
218
  }
225
- get a() {
219
+ get w() {
226
220
  return this[3];
227
221
  }
228
- set r(value) {
222
+ set x(value) {
229
223
  this[0] = value;
230
224
  }
231
- set g(value) {
225
+ set y(value) {
232
226
  this[1] = value;
233
227
  }
234
- set b(value) {
228
+ set z(value) {
235
229
  this[2] = value;
236
230
  }
237
- set a(value) {
231
+ set w(value) {
238
232
  this[3] = value;
239
233
  }
240
- get z() {
234
+ get r() {
235
+ return this[0];
236
+ }
237
+ get g() {
238
+ return this[1];
239
+ }
240
+ get b() {
241
241
  return this[2];
242
242
  }
243
- get w() {
243
+ get a() {
244
244
  return this[3];
245
245
  }
246
- set x(value) {
246
+ set r(value) {
247
247
  this[0] = value;
248
248
  }
249
- set y(value) {
249
+ set g(value) {
250
250
  this[1] = value;
251
251
  }
252
- set z(value) {
252
+ set b(value) {
253
253
  this[2] = value;
254
254
  }
255
- set w(value) {
255
+ set a(value) {
256
256
  this[3] = value;
257
257
  }
258
258
  };
@@ -511,6 +511,5 @@ var Vec4bImpl = class Vec4bImpl extends Vec4 {
511
511
  return Vec4bImpl;
512
512
  }
513
513
  };
514
-
515
514
  //#endregion
516
- export { Vec2bImpl, Vec2fImpl, Vec2hImpl, Vec2iImpl, Vec2uImpl, Vec3bImpl, Vec3fImpl, Vec3hImpl, Vec3iImpl, Vec3uImpl, Vec4bImpl, Vec4fImpl, Vec4hImpl, Vec4iImpl, Vec4uImpl, VecBase };
515
+ export { Vec2bImpl, Vec2fImpl, Vec2hImpl, Vec2iImpl, Vec2uImpl, Vec3bImpl, Vec3fImpl, Vec3hImpl, Vec3iImpl, Vec3uImpl, Vec4bImpl, Vec4fImpl, Vec4hImpl, Vec4iImpl, Vec4uImpl, VecBase };
package/data/vectorOps.js CHANGED
@@ -1,7 +1,6 @@
1
1
  import { vec2b as vec2b$1, vec2f as vec2f$1, vec2h as vec2h$1, vec2i as vec2i$1, vec2u as vec2u$1, vec3b as vec3b$1, vec3f as vec3f$1, vec3h as vec3h$1, vec3i as vec3i$1, vec3u as vec3u$1, vec4b as vec4b$1, vec4f as vec4f$1, vec4h as vec4h$1, vec4i as vec4i$1, vec4u as vec4u$1 } from "./vector.js";
2
2
  import { mat2x2f, mat3x3f, mat4x4f } from "./matrix.js";
3
3
  import { bitcastU32toF32Impl, bitcastU32toI32Impl, clamp, divInteger, smoothstepScalar } from "./numberOps.js";
4
-
5
4
  //#region src/data/vectorOps.ts
6
5
  const vec2b = vec2b$1;
7
6
  const vec2f = vec2f$1;
@@ -60,6 +59,9 @@ const binaryComponentWise4f = (op) => (a, b) => vec4f(op(a.x, b.x), op(a.y, b.y)
60
59
  const binaryComponentWise4h = (op) => (a, b) => vec4h(op(a.x, b.x), op(a.y, b.y), op(a.z, b.z), op(a.w, b.w));
61
60
  const binaryComponentWise4i = (op) => (a, b) => vec4i(op(a.x, b.x), op(a.y, b.y), op(a.z, b.z), op(a.w, b.w));
62
61
  const binaryComponentWise4u = (op) => (a, b) => vec4u(op(a.x, b.x), op(a.y, b.y), op(a.z, b.z), op(a.w, b.w));
62
+ const binaryComponentWise2i2u = (op) => (a, b) => vec2i(op(a.x, b.x), op(a.y, b.y));
63
+ const binaryComponentWise3i3u = (op) => (a, b) => vec3i(op(a.x, b.x), op(a.y, b.y), op(a.z, b.z));
64
+ const binaryComponentWise4i4u = (op) => (a, b) => vec4i(op(a.x, b.x), op(a.y, b.y), op(a.z, b.z), op(a.w, b.w));
63
65
  const binaryComponentWise2x2f = (op) => (a, b) => {
64
66
  const a_ = a.columns;
65
67
  const b_ = b.columns;
@@ -648,6 +650,22 @@ const VectorOps = {
648
650
  vec4f: unary4f(Math.tanh),
649
651
  vec4h: unary4h(Math.tanh)
650
652
  },
653
+ bitShiftLeft: {
654
+ vec2i: binaryComponentWise2i2u((a, b) => a << b),
655
+ vec2u: binaryComponentWise2u((a, b) => a << b),
656
+ vec3i: binaryComponentWise3i3u((a, b) => a << b),
657
+ vec3u: binaryComponentWise3u((a, b) => a << b),
658
+ vec4i: binaryComponentWise4i4u((a, b) => a << b),
659
+ vec4u: binaryComponentWise4u((a, b) => a << b)
660
+ },
661
+ bitShiftRight: {
662
+ vec2i: binaryComponentWise2i2u((a, b) => a >> b),
663
+ vec2u: binaryComponentWise2u((a, b) => a >> b),
664
+ vec3i: binaryComponentWise3i3u((a, b) => a >> b),
665
+ vec3u: binaryComponentWise3u((a, b) => a >> b),
666
+ vec4i: binaryComponentWise4i4u((a, b) => a >> b),
667
+ vec4u: binaryComponentWise4u((a, b) => a >> b)
668
+ },
651
669
  bitcastU32toF32: {
652
670
  vec2u: (n) => vec2f(bitcastU32toF32Impl(n.x), bitcastU32toF32Impl(n.y)),
653
671
  vec3u: (n) => vec3f(bitcastU32toF32Impl(n.x), bitcastU32toF32Impl(n.y), bitcastU32toF32Impl(n.z)),
@@ -659,6 +677,5 @@ const VectorOps = {
659
677
  vec4u: (n) => vec4i(bitcastU32toI32Impl(n.x), bitcastU32toI32Impl(n.y), bitcastU32toI32Impl(n.z), bitcastU32toI32Impl(n.w))
660
678
  }
661
679
  };
662
-
663
680
  //#endregion
664
- export { VectorOps };
681
+ export { VectorOps };
@@ -2,10 +2,10 @@ import { $cast, $gpuCallable, $internal, isMarkedInternal } from "../shared/symb
2
2
  import { schemaCallWrapper, schemaCallWrapperGPU } from "./schemaCallWrapper.js";
3
3
  import { f32, i32, u32 } from "./numeric.js";
4
4
  import { vec2f, vec2i, vec2u, vec3f, vec3i, vec3u, vec4f, vec4i, vec4u } from "./vector.js";
5
-
6
5
  //#region src/data/vertexFormatData.ts
7
6
  var TgpuVertexFormatDataImpl = class {
8
7
  [$internal] = {};
8
+ type;
9
9
  [$gpuCallable];
10
10
  constructor(type) {
11
11
  this.type = type;
@@ -105,6 +105,5 @@ const unorm8x4_bgra = new TgpuVertexFormatDataImpl("unorm8x4-bgra");
105
105
  function isPackedData(value) {
106
106
  return isMarkedInternal(value) && packedFormats.has(value?.type);
107
107
  }
108
-
109
108
  //#endregion
110
- export { float16, float16x2, float16x4, float32, float32x2, float32x3, float32x4, formatToWGSLType, isPackedData, packedFormats, sint16, sint16x2, sint16x4, sint32, sint32x2, sint32x3, sint32x4, sint8, sint8x2, sint8x4, snorm16, snorm16x2, snorm16x4, snorm8, snorm8x2, snorm8x4, uint16, uint16x2, uint16x4, uint32, uint32x2, uint32x3, uint32x4, uint8, uint8x2, uint8x4, unorm10_10_10_2, unorm16, unorm16x2, unorm16x4, unorm8, unorm8x2, unorm8x4, unorm8x4_bgra };
109
+ export { float16, float16x2, float16x4, float32, float32x2, float32x3, float32x4, formatToWGSLType, isPackedData, packedFormats, sint16, sint16x2, sint16x4, sint32, sint32x2, sint32x3, sint32x4, sint8, sint8x2, sint8x4, snorm16, snorm16x2, snorm16x4, snorm8, snorm8x2, snorm8x4, uint16, uint16x2, uint16x4, uint32, uint32x2, uint32x3, uint32x4, uint8, uint8x2, uint8x4, unorm10_10_10_2, unorm16, unorm16x2, unorm16x4, unorm8, unorm8x2, unorm8x4, unorm8x4_bgra };
@@ -1,13 +1,11 @@
1
1
  import { TgpuNamable } from "../shared/meta.js";
2
- import { $gpuRepr, $internal, $invalidSchemaReason, $memIdent, $repr, $reprPartial, $validStorageSchema, $validUniformSchema, $validVertexSchema } from "../shared/symbols.js";
2
+ import { $gpuRepr, $inRepr, $internal, $invalidSchemaReason, $memIdent, $repr, $reprPartial, $reprPatch, $validStorageSchema, $validUniformSchema, $validVertexSchema } from "../shared/symbols.js";
3
3
  import { Prettify, SwapNever } from "../shared/utilityTypes.js";
4
4
  import { WgslComparisonSampler, WgslSampler } from "./sampler.js";
5
5
  import { DualFn } from "../types.js";
6
6
  import { _ref } from "./ref.js";
7
7
  import { WgslExternalTexture, WgslStorageTexture, WgslTexture } from "./texture.js";
8
- import { ExtractInvalidSchemaError, Infer, InferGPU, InferGPURecord, InferPartial, InferPartialRecord, InferRecord, IsValidStorageSchema, IsValidUniformSchema, IsValidVertexSchema, MemIdentity, MemIdentityRecord } from "../shared/repr.js";
9
- import "tsover-runtime";
10
-
8
+ import { ExtractInvalidSchemaError, Infer, InferGPU, InferGPURecord, InferInput, InferInputRecord, InferPartial, InferPartialRecord, InferPatch, InferPatchRecord, InferRecord, IsValidStorageSchema, IsValidUniformSchema, IsValidVertexSchema, MemIdentity, MemIdentityRecord } from "../shared/repr.js";
11
9
  //#region src/data/wgslTypes.d.ts
12
10
  type DecoratedLocation<T extends BaseData> = Decorated<T, Location[]>;
13
11
  interface BaseData {
@@ -21,6 +19,10 @@ interface NumberArrayView {
21
19
  [n: number]: number;
22
20
  [Symbol.iterator]: () => Iterator<number>;
23
21
  }
22
+ /**
23
+ * Maps a scalar, vector, or matrix element schema to the corresponding TypedArray type.
24
+ */
25
+ type TypedArrayFor<T> = T extends F32 | Vec2f | Vec3f | Vec4f | Mat2x2f | Mat3x3f | Mat4x4f ? Float32Array : T extends F16 | Vec2h | Vec3h | Vec4h ? Float16Array : T extends I32 | Vec2i | Vec3i | Vec4i | Atomic<I32> ? Int32Array : T extends U32 | Vec2u | Vec3u | Vec4u | Atomic<U32> ? Uint32Array : T extends U16 ? Uint16Array : T extends Decorated<infer TBase> ? TypedArrayFor<TBase> : never;
24
26
  /**
25
27
  * Vector infix notation.
26
28
  *
@@ -40,6 +42,11 @@ interface vecInfixNotation<T extends vecBase> {
40
42
  [Symbol.operatorSlash](lhs: T | number, rhs: T | number): T;
41
43
  [Symbol.operatorPercent](lhs: T | number, rhs: T | number): T;
42
44
  }
45
+ type vecIToVecU<T extends AnyIntegerVecInstance> = T extends v2i | v2u ? v2u : T extends v3i | v3u ? v3u : v4u;
46
+ interface vecBitShiftNotation<T extends AnyIntegerVecInstance> {
47
+ bitShiftLeft(rhs: vecIToVecU<T> | number): T;
48
+ bitShiftRight(rhs: vecIToVecU<T> | number): T;
49
+ }
43
50
  /**
44
51
  * Matrix infix notation.
45
52
  *
@@ -141,7 +148,7 @@ interface v2h extends Tuple2<number>, Swizzle2<v2h, v3h, v4h>, vecInfixNotation<
141
148
  * Interface representing its WGSL vector type counterpart: vec2i or vec2<i32>.
142
149
  * A vector with 2 elements of type i32
143
150
  */
144
- interface v2i extends Tuple2<number>, Swizzle2<v2i, v3i, v4i>, vecInfixNotation<v2i> {
151
+ interface v2i extends Tuple2<number>, Swizzle2<v2i, v3i, v4i>, vecInfixNotation<v2i>, vecBitShiftNotation<v2i> {
145
152
  readonly [$internal]: true;
146
153
  /** use to distinguish between vectors of the same size on the type level */
147
154
  readonly kind: 'vec2i';
@@ -154,7 +161,7 @@ interface v2i extends Tuple2<number>, Swizzle2<v2i, v3i, v4i>, vecInfixNotation<
154
161
  * Interface representing its WGSL vector type counterpart: vec2u or vec2<u32>.
155
162
  * A vector with 2 elements of type u32
156
163
  */
157
- interface v2u extends Tuple2<number>, Swizzle2<v2u, v3u, v4u>, vecInfixNotation<v2u> {
164
+ interface v2u extends Tuple2<number>, Swizzle2<v2u, v3u, v4u>, vecInfixNotation<v2u>, vecBitShiftNotation<v2u> {
158
165
  readonly [$internal]: true;
159
166
  /** use to distinguish between vectors of the same size on the type level */
160
167
  readonly kind: 'vec2u';
@@ -210,7 +217,7 @@ interface v3h extends Tuple3<number>, Swizzle3<v2h, v3h, v4h>, vecInfixNotation<
210
217
  * Interface representing its WGSL vector type counterpart: vec3i or vec3<i32>.
211
218
  * A vector with 3 elements of type i32
212
219
  */
213
- interface v3i extends Tuple3<number>, Swizzle3<v2i, v3i, v4i>, vecInfixNotation<v3i> {
220
+ interface v3i extends Tuple3<number>, Swizzle3<v2i, v3i, v4i>, vecInfixNotation<v3i>, vecBitShiftNotation<v3i> {
214
221
  readonly [$internal]: true;
215
222
  /** use to distinguish between vectors of the same size on the type level */
216
223
  readonly kind: 'vec3i';
@@ -225,7 +232,7 @@ interface v3i extends Tuple3<number>, Swizzle3<v2i, v3i, v4i>, vecInfixNotation<
225
232
  * Interface representing its WGSL vector type counterpart: vec3u or vec3<u32>.
226
233
  * A vector with 3 elements of type u32
227
234
  */
228
- interface v3u extends Tuple3<number>, Swizzle3<v2u, v3u, v4u>, vecInfixNotation<v3u> {
235
+ interface v3u extends Tuple3<number>, Swizzle3<v2u, v3u, v4u>, vecInfixNotation<v3u>, vecBitShiftNotation<v3u> {
229
236
  readonly [$internal]: true;
230
237
  /** use to distinguish between vectors of the same size on the type level */
231
238
  readonly kind: 'vec3u';
@@ -289,7 +296,7 @@ interface v4h extends Tuple4<number>, Swizzle4<v2h, v3h, v4h>, vecInfixNotation<
289
296
  * Interface representing its WGSL vector type counterpart: vec4i or vec4<i32>.
290
297
  * A vector with 4 elements of type i32
291
298
  */
292
- interface v4i extends Tuple4<number>, Swizzle4<v2i, v3i, v4i>, vecInfixNotation<v4i> {
299
+ interface v4i extends Tuple4<number>, Swizzle4<v2i, v3i, v4i>, vecInfixNotation<v4i>, vecBitShiftNotation<v4i> {
293
300
  readonly [$internal]: true;
294
301
  /** use to distinguish between vectors of the same size on the type level */
295
302
  readonly kind: 'vec4i';
@@ -306,7 +313,7 @@ interface v4i extends Tuple4<number>, Swizzle4<v2i, v3i, v4i>, vecInfixNotation<
306
313
  * Interface representing its WGSL vector type counterpart: vec4u or vec4<u32>.
307
314
  * A vector with 4 elements of type u32
308
315
  */
309
- interface v4u extends Tuple4<number>, Swizzle4<v2u, v3u, v4u>, vecInfixNotation<v4u> {
316
+ interface v4u extends Tuple4<number>, Swizzle4<v2u, v3u, v4u>, vecInfixNotation<v4u>, vecBitShiftNotation<v4u> {
310
317
  readonly [$internal]: true;
311
318
  /** use to distinguish between vectors of the same size on the type level */
312
319
  readonly kind: 'vec4u';
@@ -482,6 +489,7 @@ interface Vec2f extends BaseData, DualFn<((x: number, y: number) => v2f) & ((xy:
482
489
  readonly primitive: F32;
483
490
  readonly componentCount: 2;
484
491
  readonly [$repr]: v2f;
492
+ readonly [$inRepr]: v2f | [number, number] | Float32Array;
485
493
  readonly [$validStorageSchema]: true;
486
494
  readonly [$validUniformSchema]: true;
487
495
  readonly [$validVertexSchema]: true;
@@ -494,6 +502,7 @@ interface Vec2h extends BaseData, DualFn<((x: number, y: number) => v2h) & ((xy:
494
502
  readonly primitive: F16;
495
503
  readonly componentCount: 2;
496
504
  readonly [$repr]: v2h;
505
+ readonly [$inRepr]: v2h | [number, number] | Float16Array;
497
506
  readonly [$validStorageSchema]: true;
498
507
  readonly [$validUniformSchema]: true;
499
508
  readonly [$validVertexSchema]: true;
@@ -506,6 +515,7 @@ interface Vec2i extends BaseData, DualFn<((x: number, y: number) => v2i) & ((xy:
506
515
  readonly primitive: I32;
507
516
  readonly componentCount: 2;
508
517
  readonly [$repr]: v2i;
518
+ readonly [$inRepr]: v2i | [number, number] | Int32Array;
509
519
  readonly [$validStorageSchema]: true;
510
520
  readonly [$validUniformSchema]: true;
511
521
  readonly [$validVertexSchema]: true;
@@ -518,6 +528,7 @@ interface Vec2u extends BaseData, DualFn<((x: number, y: number) => v2u) & ((xy:
518
528
  readonly primitive: U32;
519
529
  readonly componentCount: 2;
520
530
  readonly [$repr]: v2u;
531
+ readonly [$inRepr]: v2u | [number, number] | Uint32Array;
521
532
  readonly [$validStorageSchema]: true;
522
533
  readonly [$validUniformSchema]: true;
523
534
  readonly [$validVertexSchema]: true;
@@ -541,6 +552,7 @@ interface Vec3f extends BaseData, DualFn<((x: number, y: number, z: number) => v
541
552
  readonly primitive: F32;
542
553
  readonly componentCount: 3;
543
554
  readonly [$repr]: v3f;
555
+ readonly [$inRepr]: v3f | [number, number, number] | Float32Array;
544
556
  readonly [$validStorageSchema]: true;
545
557
  readonly [$validUniformSchema]: true;
546
558
  readonly [$validVertexSchema]: true;
@@ -553,6 +565,7 @@ interface Vec3h extends BaseData, DualFn<((x: number, y: number, z: number) => v
553
565
  readonly primitive: F16;
554
566
  readonly componentCount: 3;
555
567
  readonly [$repr]: v3h;
568
+ readonly [$inRepr]: v3h | [number, number, number] | Float16Array;
556
569
  readonly [$validStorageSchema]: true;
557
570
  readonly [$validUniformSchema]: true;
558
571
  readonly [$validVertexSchema]: true;
@@ -565,6 +578,7 @@ interface Vec3i extends BaseData, DualFn<((x: number, y: number, z: number) => v
565
578
  readonly primitive: I32;
566
579
  readonly componentCount: 3;
567
580
  readonly [$repr]: v3i;
581
+ readonly [$inRepr]: v3i | [number, number, number] | Int32Array;
568
582
  readonly [$validStorageSchema]: true;
569
583
  readonly [$validUniformSchema]: true;
570
584
  readonly [$validVertexSchema]: true;
@@ -577,6 +591,7 @@ interface Vec3u extends BaseData, DualFn<((x: number, y: number, z: number) => v
577
591
  readonly primitive: U32;
578
592
  readonly componentCount: 3;
579
593
  readonly [$repr]: v3u;
594
+ readonly [$inRepr]: v3u | [number, number, number] | Uint32Array;
580
595
  readonly [$validStorageSchema]: true;
581
596
  readonly [$validUniformSchema]: true;
582
597
  readonly [$validVertexSchema]: true;
@@ -600,6 +615,7 @@ interface Vec4f extends BaseData, DualFn<((x: number, y: number, z: number, w: n
600
615
  readonly primitive: F32;
601
616
  readonly componentCount: 4;
602
617
  readonly [$repr]: v4f;
618
+ readonly [$inRepr]: v4f | [number, number, number, number] | Float32Array;
603
619
  readonly [$validStorageSchema]: true;
604
620
  readonly [$validUniformSchema]: true;
605
621
  readonly [$validVertexSchema]: true;
@@ -612,6 +628,7 @@ interface Vec4h extends BaseData, DualFn<((x: number, y: number, z: number, w: n
612
628
  readonly primitive: F16;
613
629
  readonly componentCount: 4;
614
630
  readonly [$repr]: v4h;
631
+ readonly [$inRepr]: v4h | [number, number, number, number] | Float16Array;
615
632
  readonly [$validStorageSchema]: true;
616
633
  readonly [$validUniformSchema]: true;
617
634
  readonly [$validVertexSchema]: true;
@@ -624,6 +641,7 @@ interface Vec4i extends BaseData, DualFn<((x: number, y: number, z: number, w: n
624
641
  readonly primitive: I32;
625
642
  readonly componentCount: 4;
626
643
  readonly [$repr]: v4i;
644
+ readonly [$inRepr]: v4i | [number, number, number, number] | Int32Array;
627
645
  readonly [$validStorageSchema]: true;
628
646
  readonly [$validUniformSchema]: true;
629
647
  readonly [$validVertexSchema]: true;
@@ -636,6 +654,7 @@ interface Vec4u extends BaseData, DualFn<((x: number, y: number, z: number, w: n
636
654
  readonly primitive: U32;
637
655
  readonly componentCount: 4;
638
656
  readonly [$repr]: v4u;
657
+ readonly [$inRepr]: v4u | [number, number, number, number] | Uint32Array;
639
658
  readonly [$validStorageSchema]: true;
640
659
  readonly [$validUniformSchema]: true;
641
660
  readonly [$validVertexSchema]: true;
@@ -658,6 +677,7 @@ interface Mat2x2f extends BaseData {
658
677
  readonly type: 'mat2x2f';
659
678
  readonly primitive: F32;
660
679
  readonly [$repr]: m2x2f;
680
+ readonly [$inRepr]: m2x2f | number[] | Float32Array;
661
681
  readonly [$validStorageSchema]: true;
662
682
  readonly [$validUniformSchema]: true;
663
683
  (...elements: [number, number, number, number]): m2x2f;
@@ -672,6 +692,7 @@ interface Mat3x3f extends BaseData {
672
692
  readonly type: 'mat3x3f';
673
693
  readonly primitive: F32;
674
694
  readonly [$repr]: m3x3f;
695
+ readonly [$inRepr]: m3x3f | number[] | Float32Array;
675
696
  readonly [$validStorageSchema]: true;
676
697
  readonly [$validUniformSchema]: true;
677
698
  (...elements: [number, number, number, number, number, number, number, number, number]): m3x3f;
@@ -686,6 +707,7 @@ interface Mat4x4f extends BaseData {
686
707
  readonly type: 'mat4x4f';
687
708
  readonly primitive: F32;
688
709
  readonly [$repr]: m4x4f;
710
+ readonly [$inRepr]: m4x4f | number[] | Float32Array;
689
711
  readonly [$validStorageSchema]: true;
690
712
  readonly [$validUniformSchema]: true;
691
713
  (...elements: [number, number, number, number, number, number, number, number, number, number, number, number, number, number, number, number]): m4x4f;
@@ -712,11 +734,13 @@ interface WgslArray<out TElement extends BaseData = BaseData> extends BaseData {
712
734
  readonly elementCount: number;
713
735
  readonly elementType: TElement;
714
736
  readonly [$repr]: Infer<TElement>[];
737
+ readonly [$inRepr]: InferInput<TElement>[] | TypedArrayFor<TElement>;
715
738
  readonly [$gpuRepr]: InferGPU<TElement>[];
716
739
  readonly [$reprPartial]: {
717
740
  idx: number;
718
741
  value: InferPartial<TElement>;
719
742
  }[] | undefined;
743
+ readonly [$reprPatch]: Record<number, InferPatch<TElement>> | InferInput<TElement>[] | TypedArrayFor<TElement> | undefined;
720
744
  readonly [$memIdent]: WgslArray<MemIdentity<TElement>>;
721
745
  readonly [$validStorageSchema]: IsValidStorageSchema<TElement>;
722
746
  readonly [$validUniformSchema]: IsValidUniformSchema<TElement>;
@@ -739,9 +763,11 @@ interface WgslStruct<out TProps extends Record<string, BaseData> = Record<string
739
763
  (props: Prettify<InferRecord<TProps>>): Prettify<InferRecord<TProps>>;
740
764
  (): Prettify<InferRecord<TProps>>;
741
765
  readonly [$repr]: Prettify<InferRecord<TProps>>;
766
+ readonly [$inRepr]: Prettify<InferInputRecord<TProps>>;
742
767
  readonly [$gpuRepr]: Prettify<InferGPURecord<TProps>>;
743
768
  readonly [$memIdent]: WgslStruct<Prettify<MemIdentityRecord<TProps>>>;
744
769
  readonly [$reprPartial]: Prettify<Partial<InferPartialRecord<TProps>>> | undefined;
770
+ readonly [$reprPatch]: Prettify<Partial<InferPatchRecord<TProps>>> | undefined;
745
771
  readonly [$invalidSchemaReason]: SwapNever<{ [K in keyof TProps]: ExtractInvalidSchemaError<TProps[K], `in struct property '${K & string}' — `> }[keyof TProps], undefined>;
746
772
  readonly [$validStorageSchema]: { [K in keyof TProps]: IsValidStorageSchema<TProps[K]> }[keyof TProps] extends true ? true : false;
747
773
  readonly [$validUniformSchema]: { [K in keyof TProps]: IsValidUniformSchema<TProps[K]> }[keyof TProps] extends true ? true : false;
@@ -819,8 +845,10 @@ interface Decorated<out TInner extends BaseData = BaseData, out TAttribs extends
819
845
  readonly inner: TInner;
820
846
  readonly attribs: TAttribs;
821
847
  readonly [$repr]: Infer<TInner>;
848
+ readonly [$inRepr]: InferInput<TInner>;
822
849
  readonly [$gpuRepr]: InferGPU<TInner>;
823
850
  readonly [$reprPartial]: InferPartial<TInner>;
851
+ readonly [$reprPatch]: InferPatch<TInner>;
824
852
  readonly [$memIdent]: TAttribs extends Location[] ? MemIdentity<TInner> | Decorated<MemIdentity<TInner>, TAttribs> : Decorated<MemIdentity<TInner>, TAttribs>;
825
853
  readonly [$validStorageSchema]: IsValidStorageSchema<TInner>;
826
854
  readonly [$validUniformSchema]: IsValidUniformSchema<TInner>;
@@ -893,4 +921,4 @@ declare function isInterpolateAttrib<T extends InterpolationType>(value: unknown
893
921
  declare function isBuiltinAttrib(value: unknown): value is Builtin<string>;
894
922
  declare function isDecorated(value: unknown): value is Decorated;
895
923
  //#endregion
896
- export { AbstractFloat, AbstractInt, Align, AnyBooleanVecInstance, AnyFloat32VecInstance, AnyFloatVecInstance, AnyIntegerVecInstance, AnyMatInstance, AnyNumericVecInstance, AnySignedVecInstance, AnyVec2Instance, AnyVec3Instance, AnyVecInstance, AnyWgslData, AnyWgslStruct, Atomic, BaseData, Bool, Builtin, Decorated, F16, F32, FlatInterpolatableData, FlatInterpolationType, I32, Interpolate, Invariant, IsWgslData, Location, Mat2x2f, Mat3x3f, Mat4x4f, PerspectiveOrLinearInterpolatableData, PerspectiveOrLinearInterpolationType, Ptr, Size, StorableData, TextureSampleTypes, U16, U32, Vec2b, Vec2f, Vec2h, Vec2i, Vec2u, Vec3b, Vec3f, Vec3h, Vec3i, Vec3u, Vec4b, Vec4f, Vec4h, Vec4i, Vec4u, Void, WgslArray, WgslStruct, atomicI32, atomicU32, isAlignAttrib, isAtomic, isBuiltinAttrib, isDecorated, isInterpolateAttrib, isLocationAttrib, isPtr, isSizeAttrib, isWgslArray, isWgslData, isWgslStruct, m2x2f, m3x3f, m4x4f, mBaseForVec, matBase, v2b, v2f, v2h, v2i, v2u, v3b, v3f, v3h, v3i, v3u, v4b, v4f, v4h, v4i, v4u, vBaseForMat, vecBase };
924
+ export { AbstractFloat, AbstractInt, Align, AnyBooleanVecInstance, AnyFloat32VecInstance, AnyFloatVecInstance, AnyIntegerVecInstance, AnyMatInstance, AnyNumericVecInstance, AnySignedVecInstance, AnyVec2Instance, AnyVec3Instance, AnyVecInstance, AnyWgslData, AnyWgslStruct, Atomic, BaseData, Bool, Builtin, Decorated, F16, F32, FlatInterpolatableData, FlatInterpolationType, I32, Interpolate, Invariant, IsWgslData, Location, Mat2x2f, Mat3x3f, Mat4x4f, PerspectiveOrLinearInterpolatableData, PerspectiveOrLinearInterpolationType, Ptr, Size, StorableData, TextureSampleTypes, TypedArrayFor, U16, U32, Vec2b, Vec2f, Vec2h, Vec2i, Vec2u, Vec3b, Vec3f, Vec3h, Vec3i, Vec3u, Vec4b, Vec4f, Vec4h, Vec4i, Vec4u, Void, WgslArray, WgslStruct, atomicI32, atomicU32, isAlignAttrib, isAtomic, isBuiltinAttrib, isDecorated, isInterpolateAttrib, isLocationAttrib, isPtr, isSizeAttrib, isWgslArray, isWgslData, isWgslStruct, m2x2f, m3x3f, m4x4f, mBaseForVec, matBase, v2b, v2f, v2h, v2i, v2u, v3b, v3f, v3h, v3i, v3u, v4b, v4f, v4h, v4i, v4u, vBaseForMat, vecBase, vecIToVecU };
package/data/wgslTypes.js CHANGED
@@ -1,6 +1,5 @@
1
1
  import { $internal, isMarkedInternal } from "../shared/symbols.js";
2
2
  import "tsover-runtime";
3
-
4
3
  //#region src/data/wgslTypes.ts
5
4
  const Void = {
6
5
  [$internal]: {},
@@ -107,6 +106,12 @@ function isFloat32VecInstance(element) {
107
106
  "vec4f"
108
107
  ].includes(element.kind);
109
108
  }
109
+ function isInteger32VecInstance(value) {
110
+ return isVecInstance(value) && /[iu]$/.test(value.kind);
111
+ }
112
+ function isUint32VecInstance(value) {
113
+ return isVecInstance(value) && /[u]$/.test(value.kind);
114
+ }
110
115
  function isWgslData(value) {
111
116
  return isMarkedInternal(value) && wgslTypeLiterals.includes(value?.type);
112
117
  }
@@ -182,6 +187,9 @@ function isDecorated(value) {
182
187
  function isVoid(value) {
183
188
  return isMarkedInternal(value) && value.type === "void";
184
189
  }
190
+ function isBool(value) {
191
+ return isMarkedInternal(value) && value.type === "bool";
192
+ }
185
193
  function isNumericSchema(schema) {
186
194
  const type = schema?.type;
187
195
  return isMarkedInternal(schema) && (type === "abstractInt" || type === "abstractFloat" || type === "f32" || type === "f16" || type === "i32" || type === "u32");
@@ -210,6 +218,5 @@ function isNaturallyEphemeral(schema) {
210
218
  function WORKAROUND_getSchema(vec) {
211
219
  return vec.schema;
212
220
  }
213
-
214
221
  //#endregion
215
- export { Void, WORKAROUND_getSchema, isAlignAttrib, isAtomic, isBuiltinAttrib, isDecorated, isFloat32VecInstance, isHalfPrecisionSchema, isInterpolateAttrib, isLocationAttrib, isMat, isMat2x2f, isMat3x3f, isMatInstance, isNaturallyEphemeral, isNumericSchema, isPtr, isSizeAttrib, isVec, isVecBool, isVecInstance, isVoid, isWgslArray, isWgslData, isWgslStruct };
222
+ export { Void, WORKAROUND_getSchema, isAlignAttrib, isAtomic, isBool, isBuiltinAttrib, isDecorated, isFloat32VecInstance, isHalfPrecisionSchema, isInteger32VecInstance, isInterpolateAttrib, isLocationAttrib, isMat, isMat2x2f, isMat3x3f, isMatInstance, isNaturallyEphemeral, isNumericSchema, isPtr, isSizeAttrib, isUint32VecInstance, isVec, isVecBool, isVecInstance, isVoid, isWgslArray, isWgslData, isWgslStruct };
package/errors.js CHANGED
@@ -1,6 +1,5 @@
1
1
  import { DEV, TEST } from "./shared/env.js";
2
2
  import { getName, hasTinyestMetadata } from "./shared/meta.js";
3
-
4
3
  //#region src/errors.ts
5
4
  const prefix = "Invariant failed";
6
5
  /**
@@ -21,6 +20,8 @@ function invariant(condition, message) {
21
20
  * @category Errors
22
21
  */
23
22
  var ResolutionError = class ResolutionError extends Error {
23
+ cause;
24
+ trace;
24
25
  constructor(cause, trace) {
25
26
  let entries = trace.map((ancestor) => `- ${hasTinyestMetadata(ancestor) ? `fn*:${getName(ancestor)}` : ancestor}`);
26
27
  if (entries.length > 20) entries = [
@@ -45,6 +46,8 @@ var ResolutionError = class ResolutionError extends Error {
45
46
  * @category Errors
46
47
  */
47
48
  var ExecutionError = class ExecutionError extends Error {
49
+ cause;
50
+ trace;
48
51
  constructor(cause, trace) {
49
52
  let entries = trace.map((ancestor) => `- ${ancestor}`);
50
53
  if (entries.length > 20) entries = [
@@ -66,6 +69,7 @@ var ExecutionError = class ExecutionError extends Error {
66
69
  * @category Errors
67
70
  */
68
71
  var MissingSlotValueError = class MissingSlotValueError extends Error {
72
+ slot;
69
73
  constructor(slot) {
70
74
  super(`Missing value for '${slot}'`);
71
75
  this.slot = slot;
@@ -123,6 +127,5 @@ var SignatureNotSupportedError = class SignatureNotSupportedError extends Error
123
127
  Object.setPrototypeOf(this, SignatureNotSupportedError.prototype);
124
128
  }
125
129
  };
126
-
127
130
  //#endregion
128
- export { ExecutionError, IllegalBufferAccessError, IllegalVarAccessError, MissingBindGroupsError, MissingLinksError, MissingSlotValueError, MissingVertexBuffersError, NotUniformError, ResolutionError, SignatureNotSupportedError, WgslTypeError, invariant };
131
+ export { ExecutionError, IllegalBufferAccessError, IllegalVarAccessError, MissingBindGroupsError, MissingLinksError, MissingSlotValueError, MissingVertexBuffersError, NotUniformError, ResolutionError, SignatureNotSupportedError, WgslTypeError, invariant };
package/execMode.js CHANGED
@@ -1,6 +1,5 @@
1
1
  import { invariant } from "./errors.js";
2
2
  import { NormalState } from "./types.js";
3
-
4
3
  //#region src/execMode.ts
5
4
  /**
6
5
  * Used to track if the code we're currently
@@ -46,6 +45,5 @@ function getExecMode() {
46
45
  function inCodegenMode() {
47
46
  return resolutionCtx?.mode.type === "codegen";
48
47
  }
49
-
50
48
  //#endregion
51
- export { getExecMode, getResolutionCtx, inCodegenMode, isInsideTgpuFn, provideCtx, provideInsideTgpuFn, topLevelState };
49
+ export { getExecMode, getResolutionCtx, inCodegenMode, isInsideTgpuFn, provideCtx, provideInsideTgpuFn, topLevelState };
package/extension.js CHANGED
@@ -1,5 +1,4 @@
1
1
  import { getName } from "./shared/meta.js";
2
-
3
2
  //#region src/extension.ts
4
3
  function isUsableAsStorage(value) {
5
4
  return !!value?.usableAsStorage;
@@ -13,6 +12,5 @@ var NotStorageError = class NotStorageError extends Error {
13
12
  Object.setPrototypeOf(this, NotStorageError.prototype);
14
13
  }
15
14
  };
16
-
17
15
  //#endregion
18
- export { NotStorageError, isUsableAsStorage };
16
+ export { NotStorageError, isUsableAsStorage };