typegpu 0.10.1 → 0.11.0-rc.1

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 (273) hide show
  1. package/_virtual/_rolldown/runtime.js +13 -0
  2. package/builtin.d.ts +50 -0
  3. package/builtin.js +35 -0
  4. package/common/fullScreenTriangle.d.ts +22 -0
  5. package/common/fullScreenTriangle.js +34 -0
  6. package/common/index.d.ts +4 -4
  7. package/common/index.js +8 -7
  8. package/common/writeSoA.d.ts +16 -0
  9. package/common/writeSoA.js +90 -0
  10. package/core/buffer/buffer.d.ts +79 -0
  11. package/core/buffer/buffer.js +246 -0
  12. package/core/buffer/bufferShorthand.d.ts +48 -0
  13. package/core/buffer/bufferShorthand.js +53 -0
  14. package/core/buffer/bufferUsage.d.ts +43 -0
  15. package/core/buffer/bufferUsage.js +165 -0
  16. package/core/constant/tgpuConstant.d.ts +29 -0
  17. package/core/constant/tgpuConstant.js +68 -0
  18. package/core/declare/tgpuDeclare.d.ts +18 -0
  19. package/core/declare/tgpuDeclare.js +39 -0
  20. package/core/function/autoIO.d.ts +38 -0
  21. package/core/function/autoIO.js +85 -0
  22. package/core/function/comptime.d.ts +39 -0
  23. package/core/function/comptime.js +49 -0
  24. package/core/function/createCallableSchema.js +40 -0
  25. package/core/function/dualImpl.js +52 -0
  26. package/core/function/entryInputRouter.js +39 -0
  27. package/core/function/extractArgs.js +204 -0
  28. package/core/function/fnCore.js +90 -0
  29. package/core/function/fnTypes.d.ts +40 -0
  30. package/core/function/ioSchema.d.ts +10 -0
  31. package/core/function/ioSchema.js +51 -0
  32. package/core/function/shelllessImpl.d.ts +28 -0
  33. package/core/function/shelllessImpl.js +21 -0
  34. package/core/function/templateUtils.js +12 -0
  35. package/core/function/tgpuComputeFn.d.ts +48 -0
  36. package/core/function/tgpuComputeFn.js +55 -0
  37. package/core/function/tgpuFn.d.ts +52 -0
  38. package/core/function/tgpuFn.js +168 -0
  39. package/core/function/tgpuFragmentFn.d.ts +72 -0
  40. package/core/function/tgpuFragmentFn.js +63 -0
  41. package/core/function/tgpuVertexFn.d.ts +59 -0
  42. package/core/function/tgpuVertexFn.js +59 -0
  43. package/core/pipeline/applyPipelineState.js +35 -0
  44. package/core/pipeline/computePipeline.d.ts +54 -0
  45. package/core/pipeline/computePipeline.js +227 -0
  46. package/core/pipeline/connectAttachmentToShader.js +24 -0
  47. package/core/pipeline/connectTargetsToShader.js +27 -0
  48. package/core/pipeline/limitsOverflow.js +12 -0
  49. package/core/pipeline/pipelineUtils.js +29 -0
  50. package/core/pipeline/renderPipeline.d.ts +284 -0
  51. package/core/pipeline/renderPipeline.js +489 -0
  52. package/core/pipeline/timeable.d.ts +20 -0
  53. package/core/pipeline/timeable.js +55 -0
  54. package/core/pipeline/typeGuards.js +27 -0
  55. package/core/querySet/querySet.d.ts +20 -0
  56. package/core/querySet/querySet.js +104 -0
  57. package/core/rawCodeSnippet/tgpuRawCodeSnippet.d.ts +59 -0
  58. package/core/rawCodeSnippet/tgpuRawCodeSnippet.js +94 -0
  59. package/core/resolve/externals.d.ts +8 -0
  60. package/core/resolve/externals.js +56 -0
  61. package/core/resolve/namespace.d.ts +38 -0
  62. package/core/resolve/namespace.js +39 -0
  63. package/core/resolve/resolveData.js +144 -0
  64. package/core/resolve/stitch.js +23 -0
  65. package/core/resolve/tgpuResolve.d.ts +153 -0
  66. package/core/resolve/tgpuResolve.js +66 -0
  67. package/core/root/configurableImpl.js +17 -0
  68. package/core/root/init.d.ts +64 -0
  69. package/core/root/init.js +464 -0
  70. package/core/root/rootTypes.d.ts +642 -0
  71. package/core/sampler/sampler.d.ts +31 -0
  72. package/core/sampler/sampler.js +116 -0
  73. package/core/simulate/tgpuSimulate.d.ts +36 -0
  74. package/core/simulate/tgpuSimulate.js +74 -0
  75. package/core/slot/accessor.d.ts +9 -0
  76. package/core/slot/accessor.js +95 -0
  77. package/core/slot/internalSlots.js +5 -0
  78. package/core/slot/lazy.d.ts +6 -0
  79. package/core/slot/lazy.js +40 -0
  80. package/core/slot/slot.d.ts +6 -0
  81. package/core/slot/slot.js +39 -0
  82. package/core/slot/slotTypes.d.ts +92 -0
  83. package/core/slot/slotTypes.js +19 -0
  84. package/core/texture/externalTexture.d.ts +6 -0
  85. package/core/texture/externalTexture.js +47 -0
  86. package/core/texture/texture.d.ts +114 -0
  87. package/core/texture/texture.js +314 -0
  88. package/core/texture/textureFormats.d.ts +29 -0
  89. package/core/texture/textureFormats.js +97 -0
  90. package/core/texture/textureProps.d.ts +11 -0
  91. package/core/texture/textureUtils.js +222 -0
  92. package/core/texture/usageExtension.d.ts +21 -0
  93. package/core/texture/usageExtension.js +19 -0
  94. package/core/unroll/tgpuUnroll.d.ts +68 -0
  95. package/core/unroll/tgpuUnroll.js +94 -0
  96. package/core/valueProxyUtils.js +42 -0
  97. package/core/variable/tgpuVariable.d.ts +38 -0
  98. package/core/variable/tgpuVariable.js +99 -0
  99. package/core/vertexLayout/connectAttributesToShader.js +57 -0
  100. package/core/vertexLayout/vertexAttribute.d.ts +29 -0
  101. package/core/vertexLayout/vertexLayout.d.ts +19 -0
  102. package/core/vertexLayout/vertexLayout.js +103 -0
  103. package/data/alignIO.js +14 -0
  104. package/data/alignmentOf.d.ts +9 -0
  105. package/data/alignmentOf.js +86 -0
  106. package/data/array.d.ts +26 -0
  107. package/data/array.js +46 -0
  108. package/data/atomic.d.ts +15 -0
  109. package/data/atomic.js +24 -0
  110. package/data/attributes.d.ts +121 -0
  111. package/data/attributes.js +145 -0
  112. package/data/autoStruct.d.ts +1 -0
  113. package/data/autoStruct.js +81 -0
  114. package/data/compiledIO.js +228 -0
  115. package/data/dataIO.js +556 -0
  116. package/data/dataTypes.d.ts +115 -0
  117. package/data/dataTypes.js +100 -0
  118. package/data/deepEqual.d.ts +25 -0
  119. package/data/deepEqual.js +56 -0
  120. package/data/disarray.d.ts +32 -0
  121. package/data/disarray.js +50 -0
  122. package/data/getLongestContiguousPrefix.d.ts +9 -0
  123. package/data/getLongestContiguousPrefix.js +13 -0
  124. package/data/index.d.ts +26 -4
  125. package/data/index.js +36 -9
  126. package/data/instanceToSchema.d.ts +33 -0
  127. package/data/isContiguous.d.ts +9 -0
  128. package/data/isContiguous.js +13 -0
  129. package/data/matrix.d.ts +124 -0
  130. package/data/matrix.js +531 -0
  131. package/data/numberOps.js +23 -0
  132. package/data/numeric.d.ts +81 -0
  133. package/data/numeric.js +221 -0
  134. package/data/offsetUtils.d.ts +33 -0
  135. package/data/offsetUtils.js +165 -0
  136. package/data/offsets.js +34 -0
  137. package/data/partialIO.js +113 -0
  138. package/data/ptr.d.ts +11 -0
  139. package/data/ptr.js +44 -0
  140. package/data/ref.d.ts +34 -0
  141. package/data/ref.js +94 -0
  142. package/data/sampler.d.ts +107 -0
  143. package/data/sampler.js +24 -0
  144. package/data/schemaCallWrapper.js +30 -0
  145. package/data/schemaMemoryLayout.js +198 -0
  146. package/data/sizeOf.d.ts +9 -0
  147. package/data/sizeOf.js +13 -0
  148. package/data/snippet.d.ts +26 -0
  149. package/data/snippet.js +70 -0
  150. package/data/struct.d.ts +17 -0
  151. package/data/struct.js +44 -0
  152. package/data/texture.d.ts +292 -0
  153. package/{texture-BagDrrks.js → data/texture.js} +6 -5
  154. package/data/unstruct.d.ts +24 -0
  155. package/data/unstruct.js +41 -0
  156. package/data/vector.d.ts +191 -0
  157. package/data/vector.js +239 -0
  158. package/data/vectorImpl.js +515 -0
  159. package/data/vectorOps.js +681 -0
  160. package/data/vertexFormatData.d.ts +190 -0
  161. package/data/vertexFormatData.js +109 -0
  162. package/data/wgslTypes.d.ts +924 -0
  163. package/data/wgslTypes.js +222 -0
  164. package/errors.d.ts +44 -0
  165. package/errors.js +131 -0
  166. package/execMode.js +49 -0
  167. package/extension.d.ts +11 -0
  168. package/extension.js +16 -0
  169. package/getGPUValue.js +7 -0
  170. package/index.d.ts +42 -243
  171. package/index.js +21 -6320
  172. package/indexNamedExports.d.ts +40 -0
  173. package/mathUtils.js +12 -0
  174. package/memo.js +22 -0
  175. package/nameRegistry.d.ts +30 -0
  176. package/nameRegistry.js +447 -0
  177. package/package.js +4 -0
  178. package/package.json +26 -26
  179. package/resolutionCtx.d.ts +19 -0
  180. package/resolutionCtx.js +612 -0
  181. package/shared/env.js +12 -0
  182. package/shared/generators.js +13 -0
  183. package/shared/meta.d.ts +39 -0
  184. package/shared/meta.js +61 -0
  185. package/shared/repr.d.ts +138 -0
  186. package/shared/stringify.js +20 -0
  187. package/shared/symbols.d.ts +70 -0
  188. package/shared/symbols.js +48 -0
  189. package/shared/utilityTypes.d.ts +33 -0
  190. package/shared/utilityTypes.js +6 -0
  191. package/shared/vertexFormat.d.ts +70 -0
  192. package/shared/vertexFormat.js +63 -0
  193. package/std/array.d.ts +7 -0
  194. package/std/array.js +25 -0
  195. package/std/atomic.d.ts +19 -0
  196. package/std/atomic.js +111 -0
  197. package/std/bitcast.d.ts +10 -0
  198. package/std/bitcast.js +41 -0
  199. package/std/boolean.d.ts +141 -0
  200. package/std/boolean.js +299 -0
  201. package/std/derivative.d.ts +16 -0
  202. package/std/derivative.js +87 -0
  203. package/std/discard.d.ts +6 -0
  204. package/std/discard.js +14 -0
  205. package/std/extensions.d.ts +6 -0
  206. package/std/extensions.js +12 -0
  207. package/std/index.d.ts +17 -4
  208. package/std/index.js +21 -7
  209. package/std/matrix.d.ts +41 -0
  210. package/std/matrix.js +85 -0
  211. package/std/numeric.d.ts +200 -0
  212. package/std/numeric.js +845 -0
  213. package/std/operators.d.ts +56 -0
  214. package/std/operators.js +227 -0
  215. package/std/packing.d.ts +26 -0
  216. package/std/packing.js +84 -0
  217. package/std/range.d.ts +24 -0
  218. package/std/range.js +38 -0
  219. package/std/subgroup.d.ts +47 -0
  220. package/std/subgroup.js +218 -0
  221. package/std/texture.d.ts +117 -0
  222. package/std/texture.js +207 -0
  223. package/tgpu.js +42 -0
  224. package/tgpuBindGroupLayout.d.ts +161 -0
  225. package/tgpuBindGroupLayout.js +272 -0
  226. package/tgpuUnstable.d.ts +48 -0
  227. package/tgpuUnstable.js +64 -0
  228. package/tgsl/accessIndex.js +43 -0
  229. package/tgsl/accessProp.js +115 -0
  230. package/tgsl/consoleLog/deserializers.js +115 -0
  231. package/tgsl/consoleLog/logGenerator.js +84 -0
  232. package/tgsl/consoleLog/serializers.js +223 -0
  233. package/tgsl/consoleLog/types.d.ts +52 -0
  234. package/tgsl/consoleLog/types.js +11 -0
  235. package/tgsl/conversion.js +198 -0
  236. package/tgsl/forOfUtils.js +71 -0
  237. package/tgsl/generationHelpers.d.ts +37 -0
  238. package/tgsl/generationHelpers.js +67 -0
  239. package/tgsl/math.js +43 -0
  240. package/tgsl/shaderGenerator.d.ts +20 -0
  241. package/tgsl/shaderGenerator_members.d.ts +2 -0
  242. package/tgsl/shaderGenerator_members.js +6 -0
  243. package/tgsl/shellless.d.ts +11 -0
  244. package/tgsl/shellless.js +46 -0
  245. package/tgsl/wgslGenerator.d.ts +36 -0
  246. package/tgsl/wgslGenerator.js +639 -0
  247. package/types.d.ts +265 -0
  248. package/types.js +43 -0
  249. package/unwrapper.d.ts +27 -0
  250. package/wgslExtensions.d.ts +5 -0
  251. package/wgslExtensions.js +17 -0
  252. package/builtin-DdtWpk2t.js +0 -818
  253. package/builtin-DdtWpk2t.js.map +0 -1
  254. package/chunk-BYypO7fO.js +0 -18
  255. package/common/index.d.ts.map +0 -1
  256. package/common/index.js.map +0 -1
  257. package/data/index.d.ts.map +0 -1
  258. package/data/index.js.map +0 -1
  259. package/deepEqual-DQxK4vdp.js +0 -413
  260. package/deepEqual-DQxK4vdp.js.map +0 -1
  261. package/extensions-DIVuAfBM.js +0 -2032
  262. package/extensions-DIVuAfBM.js.map +0 -1
  263. package/fullScreenTriangle-CfFyQd_0.js +0 -543
  264. package/fullScreenTriangle-CfFyQd_0.js.map +0 -1
  265. package/index.d.ts.map +0 -1
  266. package/index.js.map +0 -1
  267. package/indexNamedExports-oL6tyaJ9.d.ts +0 -5697
  268. package/indexNamedExports-oL6tyaJ9.d.ts.map +0 -1
  269. package/operators-d-PMVTo7.js +0 -4158
  270. package/operators-d-PMVTo7.js.map +0 -1
  271. package/std/index.d.ts.map +0 -1
  272. package/std/index.js.map +0 -1
  273. package/texture-BagDrrks.js.map +0 -1
package/data/vector.js ADDED
@@ -0,0 +1,239 @@
1
+ import { $internal, $repr } from "../shared/symbols.js";
2
+ import { isVec } from "./wgslTypes.js";
3
+ import { callableSchema } from "../core/function/createCallableSchema.js";
4
+ import { bool, f16, f32, i32, u32 } from "./numeric.js";
5
+ import { Vec2bImpl, Vec2fImpl, Vec2hImpl, Vec2iImpl, Vec2uImpl, Vec3bImpl, Vec3fImpl, Vec3hImpl, Vec3iImpl, Vec3uImpl, Vec4bImpl, Vec4fImpl, Vec4hImpl, Vec4iImpl, Vec4uImpl } from "./vectorImpl.js";
6
+ //#region src/data/vector.ts
7
+ /**
8
+ * Schema representing vec2f - a vector with 2 elements of type f32.
9
+ * Also a constructor function for this vector value.
10
+ *
11
+ * @example
12
+ * const vector = d.vec2f(); // (0.0, 0.0)
13
+ * const vector = d.vec2f(1); // (1.0, 1.0)
14
+ * const vector = d.vec2f(0.5, 0.1); // (0.5, 0.1)
15
+ *
16
+ * @example
17
+ * const buffer = root.createBuffer(d.vec2f, d.vec2f(0, 1)); // buffer holding a d.vec2f value, with an initial value of vec2f(0, 1);
18
+ */
19
+ const vec2f = makeVecSchema(Vec2fImpl, f32);
20
+ /**
21
+ * Schema representing vec2h - a vector with 2 elements of type f16.
22
+ * Also a constructor function for this vector value.
23
+ *
24
+ * @example
25
+ * const vector = d.vec2h(); // (0.0, 0.0)
26
+ * const vector = d.vec2h(1); // (1.0, 1.0)
27
+ * const vector = d.vec2h(0.5, 0.1); // (0.5, 0.1)
28
+ *
29
+ * @example
30
+ * const buffer = root.createBuffer(d.vec2h, d.vec2h(0, 1)); // buffer holding a d.vec2h value, with an initial value of vec2h(0, 1);
31
+ */
32
+ const vec2h = makeVecSchema(Vec2hImpl, f16);
33
+ /**
34
+ * Schema representing vec2i - a vector with 2 elements of type i32.
35
+ * Also a constructor function for this vector value.
36
+ *
37
+ * @example
38
+ * const vector = d.vec2i(); // (0, 0)
39
+ * const vector = d.vec2i(1); // (1, 1)
40
+ * const vector = d.vec2i(-1, 1); // (-1, 1)
41
+ *
42
+ * @example
43
+ * const buffer = root.createBuffer(d.vec2i, d.vec2i(0, 1)); // buffer holding a d.vec2i value, with an initial value of vec2i(0, 1);
44
+ */
45
+ const vec2i = makeVecSchema(Vec2iImpl, i32);
46
+ /**
47
+ * Schema representing vec2u - a vector with 2 elements of type u32.
48
+ * Also a constructor function for this vector value.
49
+ *
50
+ * @example
51
+ * const vector = d.vec2u(); // (0, 0)
52
+ * const vector = d.vec2u(1); // (1, 1)
53
+ * const vector = d.vec2u(1, 2); // (1, 2)
54
+ *
55
+ * @example
56
+ * const buffer = root.createBuffer(d.vec2u, d.vec2u(0, 1)); // buffer holding a d.vec2u value, with an initial value of vec2u(0, 1);
57
+ */
58
+ const vec2u = makeVecSchema(Vec2uImpl, u32);
59
+ /**
60
+ * Schema representing `vec2<bool>` - a vector with 2 elements of type `bool`.
61
+ * Also a constructor function for this vector value.
62
+ *
63
+ * @example
64
+ * const vector = d.vec2b(); // (false, false)
65
+ * const vector = d.vec2b(true); // (true, true)
66
+ * const vector = d.vec2b(false, true); // (false, true)
67
+ */
68
+ const vec2b = makeVecSchema(Vec2bImpl, bool);
69
+ /**
70
+ * Schema representing vec3f - a vector with 3 elements of type f32.
71
+ * Also a constructor function for this vector value.
72
+ *
73
+ * @example
74
+ * const vector = d.vec3f(); // (0.0, 0.0, 0.0)
75
+ * const vector = d.vec3f(1); // (1.0, 1.0, 1.0)
76
+ * const vector = d.vec3f(1, 2, 3.5); // (1.0, 2.0, 3.5)
77
+ *
78
+ * @example
79
+ * const buffer = root.createBuffer(d.vec3f, d.vec3f(0, 1, 2)); // buffer holding a d.vec3f value, with an initial value of vec3f(0, 1, 2);
80
+ */
81
+ const vec3f = makeVecSchema(Vec3fImpl, f32);
82
+ /**
83
+ * Schema representing vec3h - a vector with 3 elements of type f16.
84
+ * Also a constructor function for this vector value.
85
+ *
86
+ * @example
87
+ * const vector = d.vec3h(); // (0.0, 0.0, 0.0)
88
+ * const vector = d.vec3h(1); // (1.0, 1.0, 1.0)
89
+ * const vector = d.vec3h(1, 2, 3.5); // (1.0, 2.0, 3.5)
90
+ *
91
+ * @example
92
+ * const buffer = root.createBuffer(d.vec3h, d.vec3h(0, 1, 2)); // buffer holding a d.vec3h value, with an initial value of vec3h(0, 1, 2);
93
+ */
94
+ const vec3h = makeVecSchema(Vec3hImpl, f16);
95
+ /**
96
+ * Schema representing vec3i - a vector with 3 elements of type i32.
97
+ * Also a constructor function for this vector value.
98
+ *
99
+ * @example
100
+ * const vector = d.vec3i(); // (0, 0, 0)
101
+ * const vector = d.vec3i(1); // (1, 1, 1)
102
+ * const vector = d.vec3i(1, 2, -3); // (1, 2, -3)
103
+ *
104
+ * @example
105
+ * const buffer = root.createBuffer(d.vec3i, d.vec3i(0, 1, 2)); // buffer holding a d.vec3i value, with an initial value of vec3i(0, 1, 2);
106
+ */
107
+ const vec3i = makeVecSchema(Vec3iImpl, i32);
108
+ /**
109
+ * Schema representing vec3u - a vector with 3 elements of type u32.
110
+ * Also a constructor function for this vector value.
111
+ *
112
+ * @example
113
+ * const vector = d.vec3u(); // (0, 0, 0)
114
+ * const vector = d.vec3u(1); // (1, 1, 1)
115
+ * const vector = d.vec3u(1, 2, 3); // (1, 2, 3)
116
+ *
117
+ * @example
118
+ * const buffer = root.createBuffer(d.vec3u, d.vec3u(0, 1, 2)); // buffer holding a d.vec3u value, with an initial value of vec3u(0, 1, 2);
119
+ */
120
+ const vec3u = makeVecSchema(Vec3uImpl, u32);
121
+ /**
122
+ * Schema representing `vec3<bool>` - a vector with 3 elements of type `bool`.
123
+ * Also a constructor function for this vector value.
124
+ *
125
+ * @example
126
+ * const vector = d.vec3b(); // (false, false, false)
127
+ * const vector = d.vec3b(true); // (true, true, true)
128
+ * const vector = d.vec3b(false, true, false); // (false, true, false)
129
+ */
130
+ const vec3b = makeVecSchema(Vec3bImpl, bool);
131
+ /**
132
+ * Schema representing vec4f - a vector with 4 elements of type f32.
133
+ * Also a constructor function for this vector value.
134
+ *
135
+ * @example
136
+ * const vector = d.vec4f(); // (0.0, 0.0, 0.0, 0.0)
137
+ * const vector = d.vec4f(1); // (1.0, 1.0, 1.0, 1.0)
138
+ * const vector = d.vec4f(1, 2, 3, 4.5); // (1.0, 2.0, 3.0, 4.5)
139
+ *
140
+ * @example
141
+ * const buffer = root.createBuffer(d.vec4f, d.vec4f(0, 1, 2, 3)); // buffer holding a d.vec4f value, with an initial value of vec4f(0, 1, 2, 3);
142
+ */
143
+ const vec4f = makeVecSchema(Vec4fImpl, f32);
144
+ /**
145
+ * Schema representing vec4h - a vector with 4 elements of type f16.
146
+ * Also a constructor function for this vector value.
147
+ *
148
+ * @example
149
+ * const vector = d.vec4h(); // (0.0, 0.0, 0.0, 0.0)
150
+ * const vector = d.vec4h(1); // (1.0, 1.0, 1.0, 1.0)
151
+ * const vector = d.vec4h(1, 2, 3, 4.5); // (1.0, 2.0, 3.0, 4.5)
152
+ *
153
+ * @example
154
+ * const buffer = root.createBuffer(d.vec4h, d.vec4h(0, 1, 2, 3)); // buffer holding a d.vec4h value, with an initial value of vec4h(0, 1, 2, 3);
155
+ */
156
+ const vec4h = makeVecSchema(Vec4hImpl, f16);
157
+ /**
158
+ * Schema representing vec4i - a vector with 4 elements of type i32.
159
+ * Also a constructor function for this vector value.
160
+ *
161
+ * @example
162
+ * const vector = d.vec4i(); // (0, 0, 0, 0)
163
+ * const vector = d.vec4i(1); // (1, 1, 1, 1)
164
+ * const vector = d.vec4i(1, 2, 3, -4); // (1, 2, 3, -4)
165
+ *
166
+ * @example
167
+ * const buffer = root.createBuffer(d.vec4i, d.vec4i(0, 1, 2, 3)); // buffer holding a d.vec4i value, with an initial value of vec4i(0, 1, 2, 3);
168
+ */
169
+ const vec4i = makeVecSchema(Vec4iImpl, i32);
170
+ /**
171
+ * Schema representing vec4u - a vector with 4 elements of type u32.
172
+ * Also a constructor function for this vector value.
173
+ *
174
+ * @example
175
+ * const vector = d.vec4u(); // (0, 0, 0, 0)
176
+ * const vector = d.vec4u(1); // (1, 1, 1, 1)
177
+ * const vector = d.vec4u(1, 2, 3, 4); // (1, 2, 3, 4)
178
+ *
179
+ * @example
180
+ * const buffer = root.createBuffer(d.vec4u, d.vec4u(0, 1, 2, 3)); // buffer holding a d.vec4u value, with an initial value of vec4u(0, 1, 2, 3);
181
+ */
182
+ const vec4u = makeVecSchema(Vec4uImpl, u32);
183
+ /**
184
+ * Schema representing `vec4<bool>` - a vector with 4 elements of type `bool`.
185
+ * Also a constructor function for this vector value.
186
+ *
187
+ * @example
188
+ * const vector = d.vec4b(); // (false, false, false, false)
189
+ * const vector = d.vec4b(true); // (true, true, true, true)
190
+ * const vector = d.vec4b(false, true, false, true); // (false, true, false, true)
191
+ */
192
+ const vec4b = makeVecSchema(Vec4bImpl, bool);
193
+ const vecTypeToConstructor = {
194
+ vec2f,
195
+ vec2h,
196
+ vec2i,
197
+ vec2u,
198
+ "vec2<bool>": vec2b,
199
+ vec3f,
200
+ vec3h,
201
+ vec3i,
202
+ vec3u,
203
+ "vec3<bool>": vec3b,
204
+ vec4f,
205
+ vec4h,
206
+ vec4i,
207
+ vec4u,
208
+ "vec4<bool>": vec4b
209
+ };
210
+ function makeVecSchema(VecImpl, primitive) {
211
+ const { kind: type, length } = new VecImpl();
212
+ const componentCount = length;
213
+ const cpuConstruct = (...args) => {
214
+ const values = Array.from({ length: args.length });
215
+ let j = 0;
216
+ for (const arg of args) if (typeof arg === "number" || typeof arg === "boolean") values[j++] = arg;
217
+ else for (let c = 0; c < arg.length; ++c) values[j++] = arg[c];
218
+ if (values.length <= 1 || values.length === componentCount) return new VecImpl(...values);
219
+ throw new Error(`'${type}' constructor called with invalid number of arguments.`);
220
+ };
221
+ const construct = callableSchema({
222
+ name: type,
223
+ schema: () => schema,
224
+ argTypes: (...args) => args.map((arg) => isVec(arg) ? arg : primitive),
225
+ normalImpl: cpuConstruct,
226
+ codegenImpl: (ctx, args) => ctx.gen.typeInstantiation(schema, args)
227
+ });
228
+ const schema = Object.assign(construct, {
229
+ [$internal]: {},
230
+ type,
231
+ primitive,
232
+ componentCount,
233
+ [$repr]: void 0
234
+ });
235
+ VecImpl.prototype.schema = schema;
236
+ return schema;
237
+ }
238
+ //#endregion
239
+ export { vec2b, vec2f, vec2h, vec2i, vec2u, vec3b, vec3f, vec3h, vec3i, vec3u, vec4b, vec4f, vec4h, vec4i, vec4u, vecTypeToConstructor };