typegpu 0.11.9 → 0.12.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 (366) hide show
  1. package/bin.mjs +28 -6
  2. package/builtin.d.ts +51 -53
  3. package/builtin.js +30 -34
  4. package/common/fullScreenTriangle.d.ts +2 -10
  5. package/common/fullScreenTriangle.js +20 -28
  6. package/common/index.d.ts +2 -9
  7. package/common/index.js +3 -12
  8. package/common/writeSoA.d.ts +11 -12
  9. package/common/writeSoA.js +88 -76
  10. package/core/buffer/buffer.d.ts +79 -62
  11. package/core/buffer/buffer.js +283 -205
  12. package/core/buffer/bufferBinding.d.ts +71 -0
  13. package/core/buffer/bufferBinding.js +154 -0
  14. package/core/buffer/bufferUsage.d.ts +14 -45
  15. package/core/buffer/bufferUsage.js +1 -171
  16. package/core/buffer/laidOutBuffer.d.ts +25 -0
  17. package/core/buffer/laidOutBuffer.js +55 -0
  18. package/core/commandEncoder/attachments.d.ts +125 -0
  19. package/core/commandEncoder/attachments.js +29 -0
  20. package/core/commandEncoder/commandEncoder.d.ts +53 -0
  21. package/core/commandEncoder/commandEncoder.js +56 -0
  22. package/core/commandEncoder/computePass.d.ts +58 -0
  23. package/core/commandEncoder/computePass.js +63 -0
  24. package/core/commandEncoder/renderPass.d.ts +121 -0
  25. package/core/commandEncoder/renderPass.js +196 -0
  26. package/core/constant/tgpuConstant.d.ts +26 -26
  27. package/core/constant/tgpuConstant.js +76 -65
  28. package/core/declare/tgpuDeclare.d.ts +3 -6
  29. package/core/declare/tgpuDeclare.js +36 -36
  30. package/core/function/autoIO.d.ts +61 -33
  31. package/core/function/autoIO.js +68 -73
  32. package/core/function/comptime.d.ts +11 -13
  33. package/core/function/comptime.js +60 -52
  34. package/core/function/createCallableSchema.d.ts +16 -0
  35. package/core/function/createCallableSchema.js +50 -40
  36. package/core/function/dualImpl.d.ts +44 -0
  37. package/core/function/dualImpl.js +71 -50
  38. package/core/function/entryInputRouter.d.ts +26 -0
  39. package/core/function/entryInputRouter.js +31 -33
  40. package/core/function/extractArgs.d.ts +38 -0
  41. package/core/function/extractArgs.js +202 -200
  42. package/core/function/fnCore.d.ts +44 -5
  43. package/core/function/fnCore.js +148 -93
  44. package/core/function/fnTypes.d.ts +31 -29
  45. package/core/function/fnTypes.js +1 -0
  46. package/core/function/ioSchema.d.ts +12 -10
  47. package/core/function/ioSchema.js +65 -47
  48. package/core/function/shelllessImpl.d.ts +9 -12
  49. package/core/function/shelllessImpl.js +17 -22
  50. package/core/function/templateUtils.d.ts +2 -0
  51. package/core/function/templateUtils.js +9 -8
  52. package/core/function/tgpuComputeFn.d.ts +26 -28
  53. package/core/function/tgpuComputeFn.js +47 -48
  54. package/core/function/tgpuFn.d.ts +34 -37
  55. package/core/function/tgpuFn.js +179 -153
  56. package/core/function/tgpuFragmentFn.d.ts +52 -53
  57. package/core/function/tgpuFragmentFn.js +63 -56
  58. package/core/function/tgpuVertexFn.d.ts +36 -39
  59. package/core/function/tgpuVertexFn.js +56 -53
  60. package/core/pipeline/computePipeline.d.ts +141 -53
  61. package/core/pipeline/computePipeline.js +291 -225
  62. package/core/pipeline/connectAttachmentToShader.d.ts +4 -0
  63. package/core/pipeline/connectAttachmentToShader.js +25 -22
  64. package/core/pipeline/connectTargetsToShader.d.ts +3 -0
  65. package/core/pipeline/connectTargetsToShader.js +29 -27
  66. package/core/pipeline/drawState.d.ts +52 -0
  67. package/core/pipeline/drawState.js +225 -0
  68. package/core/pipeline/performanceTracker.d.ts +14 -0
  69. package/core/pipeline/performanceTracker.js +34 -0
  70. package/core/pipeline/pipelineUtils.d.ts +18 -0
  71. package/core/pipeline/pipelineUtils.js +54 -25
  72. package/core/pipeline/priors.d.ts +1 -0
  73. package/core/pipeline/priors.js +12 -0
  74. package/core/pipeline/renderPipeline.d.ts +246 -261
  75. package/core/pipeline/renderPipeline.js +487 -480
  76. package/core/pipeline/timeable.d.ts +28 -18
  77. package/core/pipeline/timeable.js +90 -52
  78. package/core/pipeline/typeGuards.d.ts +17 -0
  79. package/core/pipeline/typeGuards.js +52 -22
  80. package/core/pipeline/webgpuLimitations.d.ts +10 -0
  81. package/core/pipeline/webgpuLimitations.js +81 -0
  82. package/core/querySet/querySet.d.ts +26 -21
  83. package/core/querySet/querySet.js +127 -103
  84. package/core/rawCodeSnippet/tgpuRawCodeSnippet.d.ts +13 -18
  85. package/core/rawCodeSnippet/tgpuRawCodeSnippet.js +89 -90
  86. package/core/resolve/externals.d.ts +25 -8
  87. package/core/resolve/externals.js +78 -54
  88. package/core/resolve/namespace.d.ts +22 -25
  89. package/core/resolve/namespace.js +16 -21
  90. package/core/resolve/resolvableString.d.ts +7 -0
  91. package/core/resolve/resolvableString.js +13 -0
  92. package/core/resolve/resolveData.d.ts +10 -0
  93. package/core/resolve/resolveData.js +162 -121
  94. package/core/resolve/stitch.d.ts +8 -0
  95. package/core/resolve/stitch.js +23 -21
  96. package/core/resolve/tgpuResolve.d.ts +55 -53
  97. package/core/resolve/tgpuResolve.js +106 -53
  98. package/core/root/configurableImpl.d.ts +10 -0
  99. package/core/root/configurableImpl.js +17 -19
  100. package/core/root/init.d.ts +76 -38
  101. package/core/root/init.js +346 -455
  102. package/core/root/rootTypes.d.ts +461 -636
  103. package/core/root/rootTypes.js +1 -0
  104. package/core/sampler/sampler.d.ts +50 -31
  105. package/core/sampler/sampler.js +120 -113
  106. package/core/simulate/tgpuSimulate.d.ts +9 -12
  107. package/core/simulate/tgpuSimulate.js +68 -71
  108. package/core/slot/accessor.d.ts +36 -13
  109. package/core/slot/accessor.js +138 -91
  110. package/core/slot/internalSlots.d.ts +2 -0
  111. package/core/slot/internalSlots.js +1 -6
  112. package/core/slot/lazy.d.ts +2 -6
  113. package/core/slot/lazy.js +71 -39
  114. package/core/slot/slot.d.ts +2 -6
  115. package/core/slot/slot.js +45 -38
  116. package/core/slot/slotTypes.d.ts +78 -80
  117. package/core/slot/slotTypes.js +11 -16
  118. package/core/texture/externalTexture.d.ts +20 -11
  119. package/core/texture/externalTexture.js +46 -46
  120. package/core/texture/texture.d.ts +152 -97
  121. package/core/texture/texture.js +407 -314
  122. package/core/texture/textureFormats.d.ts +42 -23
  123. package/core/texture/textureFormats.js +104 -75
  124. package/core/texture/textureProps.d.ts +7 -10
  125. package/core/texture/textureProps.js +1 -0
  126. package/core/texture/textureUtils.d.ts +8 -0
  127. package/core/texture/textureUtils.js +185 -179
  128. package/core/texture/usageExtension.d.ts +21 -18
  129. package/core/texture/usageExtension.js +13 -17
  130. package/core/unroll/tgpuUnroll.d.ts +20 -19
  131. package/core/unroll/tgpuUnroll.js +82 -91
  132. package/core/valueProxyUtils.d.ts +3 -0
  133. package/core/valueProxyUtils.js +52 -41
  134. package/core/variable/tgpuVariable.d.ts +26 -27
  135. package/core/variable/tgpuVariable.js +93 -96
  136. package/core/vertexLayout/connectAttributesToShader.d.ts +9 -0
  137. package/core/vertexLayout/connectAttributesToShader.js +61 -56
  138. package/core/vertexLayout/vertexAttribute.d.ts +21 -17
  139. package/core/vertexLayout/vertexAttribute.js +1 -0
  140. package/core/vertexLayout/vertexLayout.d.ts +24 -18
  141. package/core/vertexLayout/vertexLayout.js +130 -99
  142. package/core/whitespaces.d.ts +2 -0
  143. package/core/whitespaces.js +16 -0
  144. package/data/alignIO.d.ts +7 -0
  145. package/data/alignIO.js +13 -13
  146. package/data/alignmentOf.d.ts +5 -8
  147. package/data/alignmentOf.js +90 -75
  148. package/data/array.d.ts +17 -9
  149. package/data/array.js +57 -40
  150. package/data/atomic.d.ts +2 -7
  151. package/data/atomic.js +26 -23
  152. package/data/attributes.d.ts +19 -21
  153. package/data/attributes.js +192 -132
  154. package/data/autoStruct.d.ts +36 -3
  155. package/data/autoStruct.js +84 -81
  156. package/data/compiledIO.d.ts +5 -0
  157. package/data/compiledIO.js +231 -215
  158. package/data/dataIO.d.ts +13 -11
  159. package/data/dataIO.js +643 -589
  160. package/data/dataTypes.d.ts +83 -65
  161. package/data/dataTypes.js +66 -68
  162. package/data/deepEqual.d.ts +2 -7
  163. package/data/deepEqual.js +80 -55
  164. package/data/disarray.d.ts +6 -10
  165. package/data/disarray.js +52 -46
  166. package/data/float16Conversion.d.ts +4 -0
  167. package/data/float16Conversion.js +7 -0
  168. package/data/generalizeFn.d.ts +25 -0
  169. package/data/generalizeFn.js +89 -0
  170. package/data/getLongestContiguousPrefix.d.ts +4 -8
  171. package/data/getLongestContiguousPrefix.js +6 -11
  172. package/data/index.d.ts +30 -31
  173. package/data/index.js +39 -172
  174. package/data/instanceToSchema.d.ts +24 -27
  175. package/data/instanceToSchema.js +1 -0
  176. package/data/isContiguous.d.ts +4 -8
  177. package/data/isContiguous.js +6 -11
  178. package/data/matrix.d.ts +21 -21
  179. package/data/matrix.js +513 -505
  180. package/data/numberOps.d.ts +5 -0
  181. package/data/numberOps.js +21 -21
  182. package/data/numeric.d.ts +21 -12
  183. package/data/numeric.js +287 -197
  184. package/data/offsetUtils.d.ts +9 -13
  185. package/data/offsetUtils.js +204 -144
  186. package/data/offsets.d.ts +8 -0
  187. package/data/offsets.js +33 -33
  188. package/data/partialIO.d.ts +13 -8
  189. package/data/partialIO.js +124 -113
  190. package/data/ptr.d.ts +12 -12
  191. package/data/ptr.js +42 -44
  192. package/data/ref.d.ts +40 -27
  193. package/data/ref.js +125 -95
  194. package/data/sampler.d.ts +99 -101
  195. package/data/sampler.js +17 -21
  196. package/data/schemaCallWrapper.d.ts +19 -0
  197. package/data/schemaCallWrapper.js +31 -26
  198. package/data/schemaMemoryLayout.d.ts +8 -0
  199. package/data/schemaMemoryLayout.js +213 -185
  200. package/data/sizeOf.d.ts +4 -8
  201. package/data/sizeOf.js +6 -11
  202. package/data/snippet.d.ts +96 -20
  203. package/data/snippet.js +75 -86
  204. package/data/struct.d.ts +4 -7
  205. package/data/struct.js +51 -39
  206. package/data/texture.d.ts +253 -250
  207. package/data/texture.js +238 -200
  208. package/data/unstruct.d.ts +2 -7
  209. package/data/unstruct.js +43 -37
  210. package/data/vector.d.ts +33 -21
  211. package/data/vector.js +234 -221
  212. package/data/vectorImpl.d.ts +231 -0
  213. package/data/vectorImpl.js +563 -515
  214. package/data/vectorOps.d.ts +25 -0
  215. package/data/vectorOps.js +118 -669
  216. package/data/vertexFormatData.d.ts +181 -184
  217. package/data/vertexFormatData.js +104 -106
  218. package/data/wgslTypes.d.ts +665 -600
  219. package/data/wgslTypes.js +220 -198
  220. package/errors.d.ts +50 -24
  221. package/errors.js +146 -126
  222. package/execMode.d.ts +16 -0
  223. package/execMode.js +47 -40
  224. package/extension.d.ts +13 -8
  225. package/extension.js +10 -16
  226. package/getGPUValue.d.ts +1 -0
  227. package/getGPUValue.js +2 -7
  228. package/index.d.ts +28 -68
  229. package/index.js +8 -28
  230. package/indexNamedExports.d.ts +69 -42
  231. package/indexNamedExports.js +25 -0
  232. package/internal.d.ts +16 -0
  233. package/internal.js +12 -0
  234. package/mathUtils.d.ts +5 -0
  235. package/mathUtils.js +7 -11
  236. package/memo.d.ts +11 -0
  237. package/memo.js +20 -22
  238. package/minify.d.ts +5 -0
  239. package/minify.js +93 -0
  240. package/nameUtils.d.ts +29 -0
  241. package/nameUtils.js +427 -394
  242. package/package.json +5 -1
  243. package/resolutionCtx.d.ts +162 -22
  244. package/resolutionCtx.js +911 -629
  245. package/serial/registry.d.ts +15 -0
  246. package/serial/registry.js +106 -0
  247. package/serial/restore.d.ts +49 -0
  248. package/serial/restore.js +68 -0
  249. package/serial/schema.d.ts +58 -0
  250. package/serial/schema.js +209 -0
  251. package/serial/types.d.ts +5 -0
  252. package/serial/types.js +1 -0
  253. package/shared/env.d.ts +9 -0
  254. package/shared/env.js +9 -12
  255. package/shared/generators.d.ts +4 -0
  256. package/shared/generators.js +10 -12
  257. package/shared/meta.d.ts +29 -14
  258. package/shared/meta.js +71 -55
  259. package/shared/normalizeMetadata.d.ts +32 -27
  260. package/shared/normalizeMetadata.js +23 -36
  261. package/shared/repr.d.ts +73 -55
  262. package/shared/repr.js +1 -0
  263. package/shared/soul.d.ts +17 -0
  264. package/shared/soul.js +1 -0
  265. package/shared/stringify.d.ts +2 -0
  266. package/shared/stringify.js +29 -20
  267. package/shared/symbols.d.ts +26 -20
  268. package/shared/symbols.js +79 -79
  269. package/shared/tseynit.d.ts +2 -0
  270. package/shared/tseynit.js +160 -75
  271. package/shared/utilityTypes.d.ts +30 -14
  272. package/shared/utilityTypes.js +2 -6
  273. package/shared/vertexFormat.d.ts +41 -43
  274. package/shared/vertexFormat.js +59 -62
  275. package/std/array.d.ts +2 -7
  276. package/std/array.js +18 -23
  277. package/std/atomic.d.ts +14 -18
  278. package/std/atomic.js +96 -95
  279. package/std/bitcast.d.ts +193 -10
  280. package/std/bitcast.js +309 -39
  281. package/std/boolean.d.ts +19 -33
  282. package/std/boolean.js +296 -292
  283. package/std/copy.d.ts +2 -7
  284. package/std/copy.js +27 -24
  285. package/std/derivative.d.ts +11 -15
  286. package/std/derivative.js +56 -79
  287. package/std/discard.d.ts +1 -6
  288. package/std/discard.js +7 -14
  289. package/std/environment.d.ts +19 -14
  290. package/std/environment.js +71 -51
  291. package/std/extensions.d.ts +2 -8
  292. package/std/extensions.js +10 -11
  293. package/std/index.d.ts +20 -24
  294. package/std/index.js +32 -187
  295. package/std/matrix.d.ts +6 -12
  296. package/std/matrix.js +60 -69
  297. package/std/numeric.d.ts +150 -146
  298. package/std/numeric.js +771 -727
  299. package/std/operators.d.ts +19 -27
  300. package/std/operators.js +195 -194
  301. package/std/packing.d.ts +5 -11
  302. package/std/packing.js +67 -75
  303. package/std/range.d.ts +6 -11
  304. package/std/range.js +48 -36
  305. package/std/subgroup.d.ts +33 -37
  306. package/std/subgroup.js +180 -217
  307. package/std/texture.d.ts +70 -38
  308. package/std/texture.js +176 -172
  309. package/taskQueue.d.ts +6 -0
  310. package/taskQueue.js +30 -0
  311. package/tgpu.d.ts +16 -0
  312. package/tgpu.js +17 -44
  313. package/tgpuBindGroupLayout.d.ts +132 -152
  314. package/tgpuBindGroupLayout.js +346 -268
  315. package/tgpuLogger.d.ts +34 -0
  316. package/tgpuLogger.js +64 -0
  317. package/tgpuUnstable.d.ts +16 -22
  318. package/tgpuUnstable.js +13 -35
  319. package/tgsl/accessIndex.d.ts +2 -0
  320. package/tgsl/accessIndex.js +76 -33
  321. package/tgsl/accessProp.d.ts +2 -0
  322. package/tgsl/accessProp.js +142 -101
  323. package/tgsl/accessStructProp.d.ts +5 -0
  324. package/tgsl/accessStructProp.js +13 -15
  325. package/tgsl/consoleLog/deserializers.d.ts +13 -0
  326. package/tgsl/consoleLog/deserializers.js +119 -103
  327. package/tgsl/consoleLog/logGenerator.d.ts +21 -0
  328. package/tgsl/consoleLog/logGenerator.js +85 -80
  329. package/tgsl/consoleLog/serializers.d.ts +21 -0
  330. package/tgsl/consoleLog/serializers.js +119 -100
  331. package/tgsl/consoleLog/types.d.ts +40 -39
  332. package/tgsl/consoleLog/types.js +1 -0
  333. package/tgsl/conversion.d.ts +33 -0
  334. package/tgsl/conversion.js +271 -216
  335. package/tgsl/forOfUtils.d.ts +15 -0
  336. package/tgsl/forOfUtils.js +85 -70
  337. package/tgsl/generationHelpers.d.ts +22 -39
  338. package/tgsl/generationHelpers.js +85 -58
  339. package/tgsl/infixDispatch.d.ts +70 -0
  340. package/tgsl/infixDispatch.js +48 -46
  341. package/tgsl/jsPolyfills.d.ts +16 -19
  342. package/tgsl/jsPolyfills.js +44 -42
  343. package/tgsl/makeDereferenceable.d.ts +48 -0
  344. package/tgsl/makeDereferenceable.js +86 -0
  345. package/tgsl/makeResolvable.d.ts +22 -0
  346. package/tgsl/makeResolvable.js +33 -0
  347. package/tgsl/shaderGenerator.d.ts +77 -17
  348. package/tgsl/shaderGenerator.js +1 -0
  349. package/tgsl/shellless.d.ts +6 -9
  350. package/tgsl/shellless.js +73 -43
  351. package/tgsl/wgslGenerator.d.ts +66 -59
  352. package/tgsl/wgslGenerator.js +1345 -760
  353. package/types.d.ts +287 -222
  354. package/types.js +61 -44
  355. package/unwrapper.d.ts +31 -26
  356. package/unwrapper.js +1 -0
  357. package/wgslExtensions.d.ts +3 -5
  358. package/wgslExtensions.js +12 -16
  359. package/_virtual/rolldown_runtime.js +0 -13
  360. package/core/buffer/bufferShorthand.d.ts +0 -50
  361. package/core/buffer/bufferShorthand.js +0 -55
  362. package/core/pipeline/applyPipelineState.js +0 -37
  363. package/core/pipeline/limitsOverflow.js +0 -13
  364. package/package.js +0 -5
  365. package/tgsl/shaderGenerator_members.d.ts +0 -33
  366. package/tgsl/shaderGenerator_members.js +0 -12
@@ -0,0 +1,34 @@
1
+ declare const warningTypes: readonly ["deprecated", "suspicious", "fallback", "precision-loss", "implicit-conversion", "webgpu-feature-missing", "webgpu-limits-exceeded", "locations-mismatched", "log-limit-exceeded", "external-omitted", "uniform-schema-misaligned"];
2
+ type WarningType = (typeof warningTypes)[number];
3
+ interface Logger {
4
+ warn(type: WarningType, ...args: unknown[]): void;
5
+ warnOnce(type: WarningType, key: object, tag: string, ...args: unknown[]): void;
6
+ }
7
+ /**
8
+ * Use this object to globally disable TypeGPU warnings.
9
+ * All warnings are better addressed than silenced, only use this when absolutely necessary.
10
+ *
11
+ * By default, lesser warnings are already silenced in production environment.
12
+ */
13
+ interface Warn {
14
+ /**
15
+ * Globally disables one kind of warnings.
16
+ * Do not use unless absolutely necessary.
17
+ */
18
+ disable(type: WarningType): void;
19
+ /**
20
+ * Restores the initial state.
21
+ */
22
+ reset(): void;
23
+ }
24
+ export declare class TgpuLogger implements Logger, Warn {
25
+ #private;
26
+ constructor(prod: boolean);
27
+ disable(type: WarningType): void;
28
+ reset(): void;
29
+ warn(type: WarningType, ...args: unknown[]): void;
30
+ warnOnce(type: WarningType, key: object, tag: string, ...args: unknown[]): void;
31
+ }
32
+ export declare const logger: Logger;
33
+ export declare const warn: Warn;
34
+ export {};
package/tgpuLogger.js ADDED
@@ -0,0 +1,64 @@
1
+ import { DEV, TEST } from "./shared/env.js";
2
+ const warningTypes = [
3
+ 'deprecated',
4
+ 'suspicious',
5
+ 'fallback',
6
+ 'precision-loss',
7
+ 'implicit-conversion',
8
+ 'webgpu-feature-missing',
9
+ 'webgpu-limits-exceeded',
10
+ 'locations-mismatched',
11
+ 'log-limit-exceeded',
12
+ 'external-omitted',
13
+ 'uniform-schema-misaligned',
14
+ ];
15
+ export class TgpuLogger {
16
+ #initialEnabledWarnings;
17
+ #enabledWarnings;
18
+ #warned = new WeakMap();
19
+ constructor(prod) {
20
+ if (prod) {
21
+ this.#initialEnabledWarnings = [
22
+ 'webgpu-feature-missing',
23
+ 'webgpu-limits-exceeded',
24
+ 'locations-mismatched',
25
+ 'log-limit-exceeded',
26
+ 'external-omitted',
27
+ ];
28
+ }
29
+ else {
30
+ this.#initialEnabledWarnings = warningTypes;
31
+ }
32
+ this.#enabledWarnings = new Set(this.#initialEnabledWarnings);
33
+ }
34
+ disable(type) {
35
+ this.#enabledWarnings.delete(type);
36
+ }
37
+ reset() {
38
+ this.#enabledWarnings = new Set(this.#initialEnabledWarnings);
39
+ }
40
+ warn(type, ...args) {
41
+ if (this.#enabledWarnings.has(type)) {
42
+ console.warn(`⚠️ [${type}] `, ...args);
43
+ }
44
+ }
45
+ warnOnce(type, key, tag, ...args) {
46
+ if (!this.#enabledWarnings.has(type)) {
47
+ return;
48
+ }
49
+ let warnings = this.#warned.get(key);
50
+ if (!warnings) {
51
+ warnings = new Set();
52
+ this.#warned.set(key, warnings);
53
+ }
54
+ const warningId = `${type}:${tag}`;
55
+ if (warnings.has(warningId)) {
56
+ return;
57
+ }
58
+ warnings.add(warningId);
59
+ this.warn(type, ...args);
60
+ }
61
+ }
62
+ const tgpuLogger = new TgpuLogger(!(DEV || TEST));
63
+ export const logger = tgpuLogger;
64
+ export const warn = tgpuLogger;
package/tgpuUnstable.d.ts CHANGED
@@ -1,23 +1,18 @@
1
- import { computeFn } from "./core/function/tgpuComputeFn.js";
2
- import { privateVar, workgroupVar } from "./core/variable/tgpuVariable.js";
3
- import { fragmentFn } from "./core/function/tgpuFragmentFn.js";
4
- import { vertexFn } from "./core/function/tgpuVertexFn.js";
5
- import { vertexLayout } from "./core/vertexLayout/vertexLayout.js";
6
- import { declare } from "./core/declare/tgpuDeclare.js";
7
- import { fn } from "./core/function/tgpuFn.js";
8
- import { constant } from "./core/constant/tgpuConstant.js";
9
- import { comptime } from "./core/function/comptime.js";
10
- import { namespace } from "./core/resolve/namespace.js";
11
- import { slot } from "./core/slot/slot.js";
12
- import { lazy } from "./core/slot/lazy.js";
13
- import { accessor, mutableAccessor } from "./core/slot/accessor.js";
14
- import { rawCodeSnippet } from "./core/rawCodeSnippet/tgpuRawCodeSnippet.js";
15
- import { simulate } from "./core/simulate/tgpuSimulate.js";
16
-
17
- //#region src/tgpuUnstable.d.ts
18
- declare namespace tgpuUnstable_d_exports {
19
- export { _accessor as accessor, _comptime as comptime, _computeFn as computeFn, _constant as const, declare, _lazy as derived, _fn as fn, _fragmentFn as fragmentFn, _mutableAccessor as mutableAccessor, namespace, _privateVar as privateVar, rawCodeSnippet, simulate, _slot as slot, _vertexFn as vertexFn, _vertexLayout as vertexLayout, _workgroupVar as workgroupVar };
20
- }
1
+ export { declare } from './core/declare/tgpuDeclare.ts';
2
+ export { rawCodeSnippet } from './core/rawCodeSnippet/tgpuRawCodeSnippet.ts';
3
+ export { namespace } from './core/resolve/namespace.ts';
4
+ export { simulate } from './core/simulate/tgpuSimulate.ts';
5
+ import { constant } from './core/constant/tgpuConstant.ts';
6
+ import { comptime } from './core/function/comptime.ts';
7
+ import { computeFn } from './core/function/tgpuComputeFn.ts';
8
+ import { fn } from './core/function/tgpuFn.ts';
9
+ import { fragmentFn } from './core/function/tgpuFragmentFn.ts';
10
+ import { vertexFn } from './core/function/tgpuVertexFn.ts';
11
+ import { accessor, mutableAccessor } from './core/slot/accessor.ts';
12
+ import { lazy } from './core/slot/lazy.ts';
13
+ import { slot } from './core/slot/slot.ts';
14
+ import { privateVar, workgroupVar } from './core/variable/tgpuVariable.ts';
15
+ import { vertexLayout } from './core/vertexLayout/vertexLayout.ts';
21
16
  /** @deprecated This feature is now stable, use tgpu.const. */
22
17
  declare const _constant: typeof constant;
23
18
  /** @deprecated This feature is now stable, use tgpu.comptime. */
@@ -44,5 +39,4 @@ declare const _privateVar: typeof privateVar;
44
39
  declare const _workgroupVar: typeof workgroupVar;
45
40
  /** @deprecated This feature is now stable, use tgpu.vertexLayout. */
46
41
  declare const _vertexLayout: typeof vertexLayout;
47
- //#endregion
48
- export { tgpuUnstable_d_exports };
42
+ export { _accessor as accessor, _comptime as comptime, _computeFn as computeFn, _constant as const, _fn as fn, _fragmentFn as fragmentFn, _lazy as derived, _mutableAccessor as mutableAccessor, _privateVar as privateVar, _slot as slot, _vertexFn as vertexFn, _vertexLayout as vertexLayout, _workgroupVar as workgroupVar, };
package/tgpuUnstable.js CHANGED
@@ -1,40 +1,20 @@
1
- import { __export } from "./_virtual/rolldown_runtime.js";
2
- import { comptime } from "./core/function/comptime.js";
1
+ // NOTE: This is a barrel file, internal files should not import things from this file
2
+ export { declare } from "./core/declare/tgpuDeclare.js";
3
+ export { rawCodeSnippet } from "./core/rawCodeSnippet/tgpuRawCodeSnippet.js";
4
+ export { namespace } from "./core/resolve/namespace.js";
5
+ export { simulate } from "./core/simulate/tgpuSimulate.js";
6
+ // DEPRECATED
3
7
  import { constant } from "./core/constant/tgpuConstant.js";
8
+ import { comptime } from "./core/function/comptime.js";
9
+ import { computeFn } from "./core/function/tgpuComputeFn.js";
4
10
  import { fn } from "./core/function/tgpuFn.js";
11
+ import { fragmentFn } from "./core/function/tgpuFragmentFn.js";
12
+ import { vertexFn } from "./core/function/tgpuVertexFn.js";
13
+ import { accessor, mutableAccessor } from "./core/slot/accessor.js";
14
+ import { lazy } from "./core/slot/lazy.js";
5
15
  import { slot } from "./core/slot/slot.js";
6
16
  import { privateVar, workgroupVar } from "./core/variable/tgpuVariable.js";
7
- import { namespace } from "./core/resolve/namespace.js";
8
- import { computeFn } from "./core/function/tgpuComputeFn.js";
9
17
  import { vertexLayout } from "./core/vertexLayout/vertexLayout.js";
10
- import { lazy } from "./core/slot/lazy.js";
11
- import { accessor, mutableAccessor } from "./core/slot/accessor.js";
12
- import { fragmentFn } from "./core/function/tgpuFragmentFn.js";
13
- import { vertexFn } from "./core/function/tgpuVertexFn.js";
14
- import { declare } from "./core/declare/tgpuDeclare.js";
15
- import { rawCodeSnippet } from "./core/rawCodeSnippet/tgpuRawCodeSnippet.js";
16
- import { simulate } from "./core/simulate/tgpuSimulate.js";
17
-
18
- //#region src/tgpuUnstable.ts
19
- var tgpuUnstable_exports = /* @__PURE__ */ __export({
20
- accessor: () => _accessor,
21
- comptime: () => _comptime,
22
- computeFn: () => _computeFn,
23
- const: () => _constant,
24
- declare: () => declare,
25
- derived: () => _lazy,
26
- fn: () => _fn,
27
- fragmentFn: () => _fragmentFn,
28
- mutableAccessor: () => _mutableAccessor,
29
- namespace: () => namespace,
30
- privateVar: () => _privateVar,
31
- rawCodeSnippet: () => rawCodeSnippet,
32
- simulate: () => simulate,
33
- slot: () => _slot,
34
- vertexFn: () => _vertexFn,
35
- vertexLayout: () => _vertexLayout,
36
- workgroupVar: () => _workgroupVar
37
- });
38
18
  /** @deprecated This feature is now stable, use tgpu.const. */
39
19
  const _constant = constant;
40
20
  /** @deprecated This feature is now stable, use tgpu.comptime. */
@@ -61,6 +41,4 @@ const _privateVar = privateVar;
61
41
  const _workgroupVar = workgroupVar;
62
42
  /** @deprecated This feature is now stable, use tgpu.vertexLayout. */
63
43
  const _vertexLayout = vertexLayout;
64
-
65
- //#endregion
66
- export { tgpuUnstable_exports };
44
+ export { _accessor as accessor, _comptime as comptime, _computeFn as computeFn, _constant as const, _fn as fn, _fragmentFn as fragmentFn, _lazy as derived, _mutableAccessor as mutableAccessor, _privateVar as privateVar, _slot as slot, _vertexFn as vertexFn, _vertexLayout as vertexLayout, _workgroupVar as workgroupVar, };
@@ -0,0 +1,2 @@
1
+ import type { Snippet } from '../data/snippet.ts';
2
+ export declare function accessIndex(target: Snippet, indexArg: Snippet | number): Snippet | undefined;
@@ -1,40 +1,83 @@
1
- import { isPtr, isVec, isWgslArray, isWgslStruct } from "../data/wgslTypes.js";
2
- import { MatrixColumnsAccess, isDisarray } from "../data/dataTypes.js";
3
- import { snip } from "../data/snippet.js";
4
- import { isKnownAtComptime } from "../types.js";
5
1
  import { stitch } from "../core/resolve/stitch.js";
2
+ import { isDisarray, MatrixColumnsAccess } from "../data/dataTypes.js";
6
3
  import { derefSnippet } from "../data/ref.js";
7
- import { ArrayExpression, coerceToSnippet } from "./generationHelpers.js";
4
+ import { snip } from "../data/snippet.js";
8
5
  import { vec2f, vec3f, vec4f } from "../data/vector.js";
6
+ import { isPtr, isVec, isWgslArray, isWgslStruct } from "../data/wgslTypes.js";
7
+ import { isKnownAtComptime } from "../types.js";
9
8
  import { accessProp } from "./accessProp.js";
10
-
11
- //#region src/tgsl/accessIndex.ts
9
+ import { ArrayExpression, coerceToSnippet } from "./generationHelpers.js";
12
10
  const indexableTypeToResult = {
13
- mat2x2f: vec2f,
14
- mat3x3f: vec3f,
15
- mat4x4f: vec4f
11
+ mat2x2f: vec2f,
12
+ mat3x3f: vec3f,
13
+ mat4x4f: vec4f,
16
14
  };
17
- function accessIndex(target, indexArg) {
18
- const index = typeof indexArg === "number" ? coerceToSnippet(indexArg) : indexArg;
19
- if (isWgslArray(target.dataType) || isDisarray(target.dataType)) {
20
- const elementType = target.dataType.elementType;
21
- let origin;
22
- if (target.origin === "constant-immutable-def") origin = index.origin === "constant" || index.origin === "constant-immutable-def" ? "constant-immutable-def" : "runtime-immutable-def";
23
- else if (target.origin === "constant") origin = index.origin === "constant" || index.origin === "constant-immutable-def" ? "constant" : "runtime";
24
- else origin = target.origin;
25
- if (target.value instanceof ArrayExpression && isKnownAtComptime(index)) return target.value.elements[index.value];
26
- return snip(isKnownAtComptime(target) && isKnownAtComptime(index) ? target.value[index.value] : stitch`${target}[${index}]`, elementType, origin, target.possibleSideEffects || index.possibleSideEffects);
27
- }
28
- if (isVec(target.dataType)) return snip(isKnownAtComptime(target) && isKnownAtComptime(index) ? target.value[index.value] : stitch`${target}[${index}]`, target.dataType.primitive, target.origin, target.possibleSideEffects || index.possibleSideEffects);
29
- if (isPtr(target.dataType)) return accessIndex(derefSnippet(target), index);
30
- if (target.value instanceof MatrixColumnsAccess) {
31
- const propType = indexableTypeToResult[target.value.matrix.dataType.type];
32
- return snip(stitch`${target.value.matrix}[${index}]`, propType, target.origin, target.possibleSideEffects || index.possibleSideEffects);
33
- }
34
- if (target.dataType.type in indexableTypeToResult) throw new Error("The only way of accessing matrix elements in TypeGPU functions is through the 'columns' property.");
35
- if (isKnownAtComptime(target) && isKnownAtComptime(index)) return coerceToSnippet(target.value[index.value]);
36
- if (isWgslStruct(target.dataType) && isKnownAtComptime(index) && typeof index.value === "string") return accessProp(target, index.value);
15
+ export function accessIndex(target, indexArg) {
16
+ const index = typeof indexArg === 'number' ? coerceToSnippet(indexArg) : indexArg;
17
+ // array
18
+ if (isWgslArray(target.dataType) || isDisarray(target.dataType)) {
19
+ const elementType = target.dataType.elementType;
20
+ let origin;
21
+ if (target.origin === 'constant-immutable-def') {
22
+ // Constant refs stay const unless the element/index forces runtime materialization
23
+ origin =
24
+ index.origin === 'constant' || index.origin === 'constant-immutable-def'
25
+ ? 'constant-immutable-def'
26
+ : 'runtime-immutable-def';
27
+ }
28
+ else if (target.origin === 'constant') {
29
+ // Ephemeral constants indexed with constants stay constant, otherwise they become runtime-known
30
+ origin =
31
+ index.origin === 'constant' || index.origin === 'constant-immutable-def'
32
+ ? 'constant'
33
+ : 'runtime';
34
+ }
35
+ else {
36
+ // Fallthrough
37
+ origin = target.origin;
38
+ }
39
+ if (target.value instanceof ArrayExpression && isKnownAtComptime(index)) {
40
+ return target.value.elements[index.value];
41
+ }
42
+ return snip(isKnownAtComptime(target) && isKnownAtComptime(index)
43
+ ? // oxlint-disable-next-line typescript/no-explicit-any -- it's fine, it's there
44
+ target.value[index.value]
45
+ : stitch `${target}[${index}]`, elementType,
46
+ /* origin */ origin, target.possibleSideEffects || index.possibleSideEffects);
47
+ }
48
+ // vector
49
+ if (isVec(target.dataType)) {
50
+ return snip(isKnownAtComptime(target) && isKnownAtComptime(index)
51
+ ? // oxlint-disable-next-line typescript/no-explicit-any -- it's fine, it's there
52
+ target.value[index.value]
53
+ : stitch `${target}[${index}]`, target.dataType.primitive,
54
+ /* origin */ target.origin, target.possibleSideEffects || index.possibleSideEffects);
55
+ }
56
+ if (isPtr(target.dataType)) {
57
+ // Sometimes values that are typed as pointers aren't instances of `d.ref`, so we
58
+ // allow indexing as if it wasn't a pointer.
59
+ return accessIndex(derefSnippet(target), index);
60
+ }
61
+ // matrix.columns
62
+ if (target.value instanceof MatrixColumnsAccess) {
63
+ const propType = indexableTypeToResult[target.value.matrix.dataType.type];
64
+ return snip(stitch `${target.value.matrix}[${index}]`, propType,
65
+ /* origin */ target.origin, target.possibleSideEffects || index.possibleSideEffects);
66
+ }
67
+ // matrix
68
+ if (target.dataType.type in indexableTypeToResult) {
69
+ throw new Error("The only way of accessing matrix elements in TypeGPU functions is through the 'columns' property.");
70
+ }
71
+ if (isKnownAtComptime(target) && isKnownAtComptime(index)) {
72
+ // No idea what the type is, so we act on the snippet's value and try to guess
73
+ return coerceToSnippet(
74
+ // oxlint-disable-next-line typescript/no-explicit-any -- we're inspecting the value, and it could be any value
75
+ target.value[index.value]);
76
+ }
77
+ if (isWgslStruct(target.dataType) &&
78
+ isKnownAtComptime(index) &&
79
+ typeof index.value === 'string') {
80
+ return accessProp(target, index.value);
81
+ }
82
+ return undefined;
37
83
  }
38
-
39
- //#endregion
40
- export { accessIndex };
@@ -0,0 +1,2 @@
1
+ import { type Snippet } from '../data/snippet.ts';
2
+ export declare function accessProp(target: Snippet, propName: string): Snippet | undefined;
@@ -1,110 +1,151 @@
1
- import { isMat, isPtr, isVec, isWgslArray, isWgslStruct } from "../data/wgslTypes.js";
2
- import { getName, isNamable, setName } from "../shared/meta.js";
3
- import { MatrixColumnsAccess, UnknownData, isUnstruct } from "../data/dataTypes.js";
4
- import { isSnippet, snip } from "../data/snippet.js";
5
- import { isKnownAtComptime } from "../types.js";
6
1
  import { stitch } from "../core/resolve/stitch.js";
7
- import { derefSnippet } from "../data/ref.js";
8
- import { accessStructProp } from "./accessStructProp.js";
9
- import { bool, f16, f32, i32, u32 } from "../data/numeric.js";
10
- import { coerceToSnippet, numericLiteralToSnippet } from "./generationHelpers.js";
11
- import { vec2b, vec2f, vec2h, vec2i, vec2u, vec3b, vec3f, vec3h, vec3i, vec3u, vec4b, vec4f, vec4h, vec4i, vec4u } from "../data/vector.js";
12
2
  import { AutoStruct } from "../data/autoStruct.js";
13
3
  import { EntryInputRouter } from "../core/function/entryInputRouter.js";
4
+ import { isUnstruct, MatrixColumnsAccess, UnknownData } from "../data/dataTypes.js";
5
+ import { bool, f16, f32, i32, u32 } from "../data/numeric.js";
6
+ import { derefSnippet } from "../data/ref.js";
7
+ import { isSnippet, snip } from "../data/snippet.js";
8
+ import { vec2b, vec2f, vec2h, vec2i, vec2u, vec3b, vec3f, vec3h, vec3i, vec3u, vec4b, vec4f, vec4h, vec4i, vec4u, } from "../data/vector.js";
9
+ import { isMat, isPtr, isVec, isWgslArray, isWgslStruct, } from "../data/wgslTypes.js";
10
+ import { isKnownAtComptime } from "../types.js";
11
+ import { coerceToSnippet, numericLiteralToSnippet } from "./generationHelpers.js";
14
12
  import { InfixDispatch, infixOperators } from "./infixDispatch.js";
15
-
16
- //#region src/tgsl/accessProp.ts
13
+ import { accessStructProp } from "./accessStructProp.js";
14
+ import { getName, isNamable, setName } from "../shared/meta.js";
17
15
  const infixKinds = [
18
- "vec2f",
19
- "vec3f",
20
- "vec4f",
21
- "vec2h",
22
- "vec3h",
23
- "vec4h",
24
- "vec2i",
25
- "vec3i",
26
- "vec4i",
27
- "vec2u",
28
- "vec3u",
29
- "vec4u",
30
- "mat2x2f",
31
- "mat3x3f",
32
- "mat4x4f"
16
+ 'vec2f',
17
+ 'vec3f',
18
+ 'vec4f',
19
+ 'vec2h',
20
+ 'vec3h',
21
+ 'vec4h',
22
+ 'vec2i',
23
+ 'vec3i',
24
+ 'vec4i',
25
+ 'vec2u',
26
+ 'vec3u',
27
+ 'vec4u',
28
+ 'mat2x2f',
29
+ 'mat3x3f',
30
+ 'mat4x4f',
33
31
  ];
34
32
  const swizzleLenToType = {
35
- f: {
36
- 1: f32,
37
- 2: vec2f,
38
- 3: vec3f,
39
- 4: vec4f
40
- },
41
- h: {
42
- 1: f16,
43
- 2: vec2h,
44
- 3: vec3h,
45
- 4: vec4h
46
- },
47
- i: {
48
- 1: i32,
49
- 2: vec2i,
50
- 3: vec3i,
51
- 4: vec4i
52
- },
53
- u: {
54
- 1: u32,
55
- 2: vec2u,
56
- 3: vec3u,
57
- 4: vec4u
58
- },
59
- b: {
60
- 1: bool,
61
- 2: vec2b,
62
- 3: vec3b,
63
- 4: vec4b
64
- }
33
+ f: {
34
+ 1: f32,
35
+ 2: vec2f,
36
+ 3: vec3f,
37
+ 4: vec4f,
38
+ },
39
+ h: {
40
+ 1: f16,
41
+ 2: vec2h,
42
+ 3: vec3h,
43
+ 4: vec4h,
44
+ },
45
+ i: {
46
+ 1: i32,
47
+ 2: vec2i,
48
+ 3: vec3i,
49
+ 4: vec4i,
50
+ },
51
+ u: {
52
+ 1: u32,
53
+ 2: vec2u,
54
+ 3: vec3u,
55
+ 4: vec4u,
56
+ },
57
+ b: {
58
+ 1: bool,
59
+ 2: vec2b,
60
+ 3: vec3b,
61
+ 4: vec4b,
62
+ },
65
63
  };
66
- function accessProp(target, propName) {
67
- if (infixKinds.includes(target.dataType.type) && propName in infixOperators) {
68
- const operator = infixOperators[propName];
69
- return snip(new InfixDispatch(target, operator), UnknownData, target.origin, target.possibleSideEffects);
70
- }
71
- if (isWgslArray(target.dataType) && propName === "length") {
72
- if (target.dataType.elementCount === 0) return snip(stitch`arrayLength(&${target})`, u32, "runtime", target.possibleSideEffects);
73
- return numericLiteralToSnippet(target.dataType.elementCount);
74
- }
75
- if (isMat(target.dataType) && propName === "columns") return snip(new MatrixColumnsAccess(target), UnknownData, target.origin, target.possibleSideEffects);
76
- if (isWgslStruct(target.dataType) || isUnstruct(target.dataType)) return accessStructProp(target, propName);
77
- if (target.dataType instanceof AutoStruct) {
78
- const result = target.dataType.accessProp(propName);
79
- if (!result) return;
80
- return snip(stitch`${target}.${result.prop}`, result.type, "argument", target.possibleSideEffects);
81
- }
82
- if (target.dataType instanceof EntryInputRouter) {
83
- const result = target.dataType.accessProp(propName);
84
- if (isSnippet(result)) return result;
85
- if (result) return accessProp(result.target, result.prop);
86
- return;
87
- }
88
- if (isPtr(target.dataType)) {
89
- const derefed = derefSnippet(target);
90
- if (propName === "$") return derefed;
91
- return accessProp(derefed, propName);
92
- }
93
- if (isVec(target.dataType)) {
94
- if (propName === "kind") return snip(target.dataType.type, UnknownData, "constant", false);
95
- }
96
- const propLength = propName.length;
97
- if (isVec(target.dataType) && propLength >= 1 && propLength <= 4 && /^[xyzw]+$|^[rgba]+$/.test(propName)) {
98
- const swizzleType = swizzleLenToType[target.dataType.type.includes("bool") ? "b" : target.dataType.type[4]][propLength];
99
- if (!swizzleType) return;
100
- return snip(isKnownAtComptime(target) ? target.value[propName] : stitch`${target}.${propName}`, swizzleType, propLength === 1 ? target.origin : target.origin === "constant" || target.origin === "constant-immutable-def" ? "constant" : "runtime", target.possibleSideEffects);
101
- }
102
- if (isKnownAtComptime(target) || target.dataType === UnknownData) {
103
- const prop = target.value[propName];
104
- if (isNamable(prop) && getName(prop) === void 0) setName(prop, propName);
105
- return coerceToSnippet(prop);
106
- }
64
+ export function accessProp(target, propName) {
65
+ if (infixKinds.includes(target.dataType.type) && propName in infixOperators) {
66
+ const operator = infixOperators[propName];
67
+ return snip(new InfixDispatch(target, operator), UnknownData,
68
+ /* origin */ target.origin, target.possibleSideEffects);
69
+ }
70
+ if (isWgslArray(target.dataType) && propName === 'length') {
71
+ if (target.dataType.elementCount === 0) {
72
+ // Dynamically-sized array
73
+ return snip(stitch `arrayLength(&${target})`, u32,
74
+ /* origin */ 'runtime', target.possibleSideEffects);
75
+ }
76
+ return numericLiteralToSnippet(target.dataType.elementCount);
77
+ }
78
+ if (isMat(target.dataType) && propName === 'columns') {
79
+ return snip(new MatrixColumnsAccess(target), UnknownData,
80
+ /* origin */ target.origin, target.possibleSideEffects);
81
+ }
82
+ if (isWgslStruct(target.dataType) || isUnstruct(target.dataType)) {
83
+ return accessStructProp(target, propName);
84
+ }
85
+ if (target.dataType instanceof AutoStruct) {
86
+ const result = target.dataType.accessProp(propName);
87
+ if (!result) {
88
+ return undefined;
89
+ }
90
+ return snip(stitch `${target}.${result.prop}`, result.type, 'argument', target.possibleSideEffects);
91
+ }
92
+ if (target.dataType instanceof EntryInputRouter) {
93
+ const result = target.dataType.accessProp(propName);
94
+ if (isSnippet(result)) {
95
+ return result;
96
+ }
97
+ if (result) {
98
+ return accessProp(result.target, result.prop);
99
+ }
100
+ return undefined;
101
+ }
102
+ if (isPtr(target.dataType)) {
103
+ const derefed = derefSnippet(target);
104
+ if (propName === '$') {
105
+ // Dereference pointer
106
+ return derefed;
107
+ }
108
+ // Sometimes values that are typed as pointers aren't instances of `d.ref`, so we
109
+ // allow access to member props as if it wasn't a pointer.
110
+ return accessProp(derefed, propName);
111
+ }
112
+ if (isVec(target.dataType)) {
113
+ // Example: d.vec3f().kind === 'vec3f'
114
+ if (propName === 'kind') {
115
+ // The snippet has no side-effects
116
+ return snip(target.dataType.type, UnknownData, 'constant', /* possibleSideEffects */ false);
117
+ }
118
+ }
119
+ const propLength = propName.length;
120
+ if (isVec(target.dataType) &&
121
+ propLength >= 1 &&
122
+ propLength <= 4 &&
123
+ /^[xyzw]+$|^[rgba]+$/.test(propName)) {
124
+ const swizzleTypeChar = target.dataType.type.includes('bool')
125
+ ? 'b'
126
+ : target.dataType.type[4];
127
+ const swizzleType = swizzleLenToType[swizzleTypeChar][propLength];
128
+ if (!swizzleType) {
129
+ return undefined;
130
+ }
131
+ return snip(isKnownAtComptime(target)
132
+ ? // oxlint-disable-next-line typescript/no-explicit-any -- it's fine, the prop is there
133
+ target.value[propName]
134
+ : stitch `${target}.${propName}`, swizzleType,
135
+ // Swizzling creates new vectors (unless they're on the lhs of an assignment, but that's not yet supported in WGSL)
136
+ /* origin */ propLength === 1
137
+ ? target.origin
138
+ : target.origin === 'constant' || target.origin === 'constant-immutable-def'
139
+ ? 'constant'
140
+ : 'runtime', target.possibleSideEffects);
141
+ }
142
+ if (isKnownAtComptime(target) || target.dataType === UnknownData) {
143
+ // oxlint-disable-next-line typescript/no-explicit-any -- we either know exactly what it is, or have no idea at all
144
+ const prop = target.value[propName];
145
+ if (isNamable(prop) && getName(prop) === undefined) {
146
+ setName(prop, propName);
147
+ }
148
+ return coerceToSnippet(prop);
149
+ }
150
+ return undefined;
107
151
  }
108
-
109
- //#endregion
110
- export { accessProp };
@@ -0,0 +1,5 @@
1
+ import { type Snippet } from '../data/snippet.ts';
2
+ /**
3
+ * This function is separate from `accessProp` to avoid a circular dependency.
4
+ */
5
+ export declare function accessStructProp(target: Snippet, propName: string): import("../internal.ts").ResolvedSnippet | undefined;
@@ -1,20 +1,18 @@
1
- import { isWgslStruct } from "../data/wgslTypes.js";
1
+ import { stitch } from "../core/resolve/stitch.js";
2
2
  import { isUnstruct, undecorate } from "../data/dataTypes.js";
3
3
  import { snip } from "../data/snippet.js";
4
+ import { isWgslStruct } from "../data/wgslTypes.js";
4
5
  import { invariant } from "../errors.js";
5
- import { stitch } from "../core/resolve/stitch.js";
6
-
7
- //#region src/tgsl/accessStructProp.ts
8
6
  /**
9
- * This function is separate from `accessProp` to avoid a circular dependency.
10
- */
11
- function accessStructProp(target, propName) {
12
- invariant(isWgslStruct(target.dataType) || isUnstruct(target.dataType), "Expected snippet type to be struct/unstruct.");
13
- let propType = target.dataType.propTypes[propName];
14
- if (!propType) return;
15
- propType = undecorate(propType);
16
- return snip(stitch`${target}.${propName}`, propType, target.origin, target.possibleSideEffects);
7
+ * This function is separate from `accessProp` to avoid a circular dependency.
8
+ */
9
+ export function accessStructProp(target, propName) {
10
+ invariant(isWgslStruct(target.dataType) || isUnstruct(target.dataType), 'Expected snippet type to be struct/unstruct.');
11
+ let propType = target.dataType.propTypes[propName];
12
+ if (!propType) {
13
+ return undefined;
14
+ }
15
+ propType = undecorate(propType);
16
+ return snip(stitch `${target}.${propName}`, propType,
17
+ /* origin */ target.origin, target.possibleSideEffects);
17
18
  }
18
-
19
- //#endregion
20
- export { accessStructProp };
@@ -0,0 +1,13 @@
1
+ import { type AnyWgslData } from '../../data/wgslTypes.ts';
2
+ import type { LogResources } from './types.ts';
3
+ export declare function deserializeAndStringify(serializedData: Uint32Array, argTypes: (AnyWgslData | string)[]): string[];
4
+ /**
5
+ * Reads and deserializes log data from GPU buffers, logging results to the console.
6
+ *
7
+ * @remarks
8
+ * - Log entries with IDs equal to 0 are filtered out.
9
+ * - Console messages are prepended with options.messagePrefix styled with purple background and white text.
10
+ * - A warning is displayed if the log count exceeds the limit passed in options.
11
+ * - After processing, the index buffer and the data buffer are cleared.
12
+ */
13
+ export declare function logDataFromGPU(resources: LogResources): void;