typegpu 0.11.9 → 0.12.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 (362) hide show
  1. package/builtin.d.ts +51 -53
  2. package/builtin.js +30 -34
  3. package/common/fullScreenTriangle.d.ts +2 -10
  4. package/common/fullScreenTriangle.js +20 -28
  5. package/common/index.d.ts +2 -9
  6. package/common/index.js +3 -12
  7. package/common/writeSoA.d.ts +11 -12
  8. package/common/writeSoA.js +88 -76
  9. package/core/buffer/buffer.d.ts +79 -62
  10. package/core/buffer/buffer.js +279 -205
  11. package/core/buffer/bufferBinding.d.ts +71 -0
  12. package/core/buffer/bufferBinding.js +154 -0
  13. package/core/buffer/bufferUsage.d.ts +14 -45
  14. package/core/buffer/bufferUsage.js +1 -171
  15. package/core/buffer/laidOutBuffer.d.ts +25 -0
  16. package/core/buffer/laidOutBuffer.js +55 -0
  17. package/core/commandEncoder/attachments.d.ts +125 -0
  18. package/core/commandEncoder/attachments.js +29 -0
  19. package/core/commandEncoder/commandEncoder.d.ts +53 -0
  20. package/core/commandEncoder/commandEncoder.js +56 -0
  21. package/core/commandEncoder/computePass.d.ts +58 -0
  22. package/core/commandEncoder/computePass.js +63 -0
  23. package/core/commandEncoder/renderPass.d.ts +121 -0
  24. package/core/commandEncoder/renderPass.js +196 -0
  25. package/core/constant/tgpuConstant.d.ts +26 -26
  26. package/core/constant/tgpuConstant.js +76 -65
  27. package/core/declare/tgpuDeclare.d.ts +3 -6
  28. package/core/declare/tgpuDeclare.js +36 -36
  29. package/core/function/autoIO.d.ts +61 -33
  30. package/core/function/autoIO.js +68 -73
  31. package/core/function/comptime.d.ts +11 -13
  32. package/core/function/comptime.js +60 -52
  33. package/core/function/createCallableSchema.d.ts +16 -0
  34. package/core/function/createCallableSchema.js +50 -40
  35. package/core/function/dualImpl.d.ts +44 -0
  36. package/core/function/dualImpl.js +71 -50
  37. package/core/function/entryInputRouter.d.ts +26 -0
  38. package/core/function/entryInputRouter.js +31 -33
  39. package/core/function/extractArgs.d.ts +38 -0
  40. package/core/function/extractArgs.js +202 -200
  41. package/core/function/fnCore.d.ts +44 -5
  42. package/core/function/fnCore.js +148 -93
  43. package/core/function/fnTypes.d.ts +31 -29
  44. package/core/function/fnTypes.js +1 -0
  45. package/core/function/ioSchema.d.ts +12 -10
  46. package/core/function/ioSchema.js +65 -47
  47. package/core/function/shelllessImpl.d.ts +9 -12
  48. package/core/function/shelllessImpl.js +17 -22
  49. package/core/function/templateUtils.d.ts +2 -0
  50. package/core/function/templateUtils.js +9 -8
  51. package/core/function/tgpuComputeFn.d.ts +26 -28
  52. package/core/function/tgpuComputeFn.js +47 -48
  53. package/core/function/tgpuFn.d.ts +34 -37
  54. package/core/function/tgpuFn.js +179 -153
  55. package/core/function/tgpuFragmentFn.d.ts +52 -53
  56. package/core/function/tgpuFragmentFn.js +63 -56
  57. package/core/function/tgpuVertexFn.d.ts +36 -39
  58. package/core/function/tgpuVertexFn.js +56 -53
  59. package/core/pipeline/computePipeline.d.ts +141 -53
  60. package/core/pipeline/computePipeline.js +291 -225
  61. package/core/pipeline/connectAttachmentToShader.d.ts +4 -0
  62. package/core/pipeline/connectAttachmentToShader.js +25 -22
  63. package/core/pipeline/connectTargetsToShader.d.ts +3 -0
  64. package/core/pipeline/connectTargetsToShader.js +29 -27
  65. package/core/pipeline/drawState.d.ts +52 -0
  66. package/core/pipeline/drawState.js +225 -0
  67. package/core/pipeline/limitsOverflow.d.ts +2 -0
  68. package/core/pipeline/limitsOverflow.js +13 -10
  69. package/core/pipeline/performanceTracker.d.ts +14 -0
  70. package/core/pipeline/performanceTracker.js +34 -0
  71. package/core/pipeline/pipelineUtils.d.ts +18 -0
  72. package/core/pipeline/pipelineUtils.js +54 -25
  73. package/core/pipeline/priors.d.ts +1 -0
  74. package/core/pipeline/priors.js +12 -0
  75. package/core/pipeline/renderPipeline.d.ts +246 -261
  76. package/core/pipeline/renderPipeline.js +487 -480
  77. package/core/pipeline/timeable.d.ts +28 -18
  78. package/core/pipeline/timeable.js +90 -52
  79. package/core/pipeline/typeGuards.d.ts +17 -0
  80. package/core/pipeline/typeGuards.js +52 -22
  81. package/core/querySet/querySet.d.ts +26 -21
  82. package/core/querySet/querySet.js +127 -103
  83. package/core/rawCodeSnippet/tgpuRawCodeSnippet.d.ts +13 -18
  84. package/core/rawCodeSnippet/tgpuRawCodeSnippet.js +89 -90
  85. package/core/resolve/externals.d.ts +25 -8
  86. package/core/resolve/externals.js +78 -54
  87. package/core/resolve/namespace.d.ts +22 -25
  88. package/core/resolve/namespace.js +16 -21
  89. package/core/resolve/resolvableString.d.ts +7 -0
  90. package/core/resolve/resolvableString.js +13 -0
  91. package/core/resolve/resolveData.d.ts +10 -0
  92. package/core/resolve/resolveData.js +162 -121
  93. package/core/resolve/stitch.d.ts +8 -0
  94. package/core/resolve/stitch.js +23 -21
  95. package/core/resolve/tgpuResolve.d.ts +55 -53
  96. package/core/resolve/tgpuResolve.js +106 -53
  97. package/core/root/configurableImpl.d.ts +10 -0
  98. package/core/root/configurableImpl.js +17 -19
  99. package/core/root/init.d.ts +76 -38
  100. package/core/root/init.js +346 -455
  101. package/core/root/rootTypes.d.ts +461 -636
  102. package/core/root/rootTypes.js +1 -0
  103. package/core/sampler/sampler.d.ts +50 -31
  104. package/core/sampler/sampler.js +120 -113
  105. package/core/simulate/tgpuSimulate.d.ts +9 -12
  106. package/core/simulate/tgpuSimulate.js +68 -71
  107. package/core/slot/accessor.d.ts +36 -13
  108. package/core/slot/accessor.js +138 -91
  109. package/core/slot/internalSlots.d.ts +2 -0
  110. package/core/slot/internalSlots.js +1 -6
  111. package/core/slot/lazy.d.ts +2 -6
  112. package/core/slot/lazy.js +71 -39
  113. package/core/slot/slot.d.ts +2 -6
  114. package/core/slot/slot.js +45 -38
  115. package/core/slot/slotTypes.d.ts +78 -80
  116. package/core/slot/slotTypes.js +11 -16
  117. package/core/texture/externalTexture.d.ts +20 -11
  118. package/core/texture/externalTexture.js +46 -46
  119. package/core/texture/texture.d.ts +152 -97
  120. package/core/texture/texture.js +407 -314
  121. package/core/texture/textureFormats.d.ts +42 -23
  122. package/core/texture/textureFormats.js +104 -75
  123. package/core/texture/textureProps.d.ts +7 -10
  124. package/core/texture/textureProps.js +1 -0
  125. package/core/texture/textureUtils.d.ts +8 -0
  126. package/core/texture/textureUtils.js +185 -179
  127. package/core/texture/usageExtension.d.ts +21 -18
  128. package/core/texture/usageExtension.js +13 -17
  129. package/core/unroll/tgpuUnroll.d.ts +20 -19
  130. package/core/unroll/tgpuUnroll.js +82 -91
  131. package/core/valueProxyUtils.d.ts +3 -0
  132. package/core/valueProxyUtils.js +52 -41
  133. package/core/variable/tgpuVariable.d.ts +26 -27
  134. package/core/variable/tgpuVariable.js +93 -96
  135. package/core/vertexLayout/connectAttributesToShader.d.ts +9 -0
  136. package/core/vertexLayout/connectAttributesToShader.js +61 -56
  137. package/core/vertexLayout/vertexAttribute.d.ts +21 -17
  138. package/core/vertexLayout/vertexAttribute.js +1 -0
  139. package/core/vertexLayout/vertexLayout.d.ts +24 -18
  140. package/core/vertexLayout/vertexLayout.js +130 -99
  141. package/core/whitespaces.d.ts +2 -0
  142. package/core/whitespaces.js +16 -0
  143. package/data/alignIO.d.ts +7 -0
  144. package/data/alignIO.js +13 -13
  145. package/data/alignmentOf.d.ts +5 -8
  146. package/data/alignmentOf.js +90 -75
  147. package/data/array.d.ts +6 -9
  148. package/data/array.js +48 -40
  149. package/data/atomic.d.ts +2 -7
  150. package/data/atomic.js +26 -23
  151. package/data/attributes.d.ts +19 -21
  152. package/data/attributes.js +192 -132
  153. package/data/autoStruct.d.ts +36 -3
  154. package/data/autoStruct.js +84 -81
  155. package/data/compiledIO.d.ts +5 -0
  156. package/data/compiledIO.js +231 -215
  157. package/data/dataIO.d.ts +13 -11
  158. package/data/dataIO.js +643 -589
  159. package/data/dataTypes.d.ts +83 -65
  160. package/data/dataTypes.js +66 -68
  161. package/data/deepEqual.d.ts +2 -7
  162. package/data/deepEqual.js +80 -55
  163. package/data/disarray.d.ts +6 -10
  164. package/data/disarray.js +52 -46
  165. package/data/float16Conversion.d.ts +4 -0
  166. package/data/float16Conversion.js +7 -0
  167. package/data/getLongestContiguousPrefix.d.ts +4 -8
  168. package/data/getLongestContiguousPrefix.js +6 -11
  169. package/data/index.d.ts +30 -31
  170. package/data/index.js +39 -172
  171. package/data/instanceToSchema.d.ts +24 -27
  172. package/data/instanceToSchema.js +1 -0
  173. package/data/isContiguous.d.ts +4 -8
  174. package/data/isContiguous.js +6 -11
  175. package/data/matrix.d.ts +21 -21
  176. package/data/matrix.js +513 -505
  177. package/data/numberOps.d.ts +6 -0
  178. package/data/numberOps.js +26 -20
  179. package/data/numeric.d.ts +21 -12
  180. package/data/numeric.js +287 -197
  181. package/data/offsetUtils.d.ts +9 -13
  182. package/data/offsetUtils.js +204 -144
  183. package/data/offsets.d.ts +8 -0
  184. package/data/offsets.js +33 -33
  185. package/data/partialIO.d.ts +13 -8
  186. package/data/partialIO.js +124 -113
  187. package/data/ptr.d.ts +12 -12
  188. package/data/ptr.js +42 -44
  189. package/data/ref.d.ts +40 -27
  190. package/data/ref.js +125 -95
  191. package/data/sampler.d.ts +99 -101
  192. package/data/sampler.js +17 -21
  193. package/data/schemaCallWrapper.d.ts +19 -0
  194. package/data/schemaCallWrapper.js +31 -26
  195. package/data/schemaMemoryLayout.d.ts +8 -0
  196. package/data/schemaMemoryLayout.js +213 -185
  197. package/data/sizeOf.d.ts +4 -8
  198. package/data/sizeOf.js +6 -11
  199. package/data/snippet.d.ts +96 -20
  200. package/data/snippet.js +75 -86
  201. package/data/struct.d.ts +4 -7
  202. package/data/struct.js +51 -39
  203. package/data/texture.d.ts +253 -250
  204. package/data/texture.js +238 -200
  205. package/data/unstruct.d.ts +2 -7
  206. package/data/unstruct.js +43 -37
  207. package/data/vector.d.ts +33 -21
  208. package/data/vector.js +234 -221
  209. package/data/vectorImpl.d.ts +231 -0
  210. package/data/vectorImpl.js +563 -515
  211. package/data/vectorOps.d.ts +63 -0
  212. package/data/vectorOps.js +642 -630
  213. package/data/vertexFormatData.d.ts +181 -184
  214. package/data/vertexFormatData.js +104 -106
  215. package/data/wgslTypes.d.ts +665 -600
  216. package/data/wgslTypes.js +220 -198
  217. package/errors.d.ts +50 -24
  218. package/errors.js +146 -126
  219. package/execMode.d.ts +16 -0
  220. package/execMode.js +47 -40
  221. package/extension.d.ts +13 -8
  222. package/extension.js +10 -16
  223. package/getGPUValue.d.ts +1 -0
  224. package/getGPUValue.js +2 -7
  225. package/index.d.ts +28 -68
  226. package/index.js +8 -28
  227. package/indexNamedExports.d.ts +69 -42
  228. package/indexNamedExports.js +25 -0
  229. package/internal.d.ts +16 -0
  230. package/internal.js +12 -0
  231. package/mathUtils.d.ts +5 -0
  232. package/mathUtils.js +7 -11
  233. package/memo.d.ts +11 -0
  234. package/memo.js +20 -22
  235. package/minify.d.ts +5 -0
  236. package/minify.js +93 -0
  237. package/nameUtils.d.ts +29 -0
  238. package/nameUtils.js +427 -394
  239. package/package.json +5 -1
  240. package/resolutionCtx.d.ts +162 -22
  241. package/resolutionCtx.js +911 -629
  242. package/serial/registry.d.ts +15 -0
  243. package/serial/registry.js +106 -0
  244. package/serial/restore.d.ts +49 -0
  245. package/serial/restore.js +68 -0
  246. package/serial/schema.d.ts +58 -0
  247. package/serial/schema.js +209 -0
  248. package/serial/types.d.ts +5 -0
  249. package/serial/types.js +1 -0
  250. package/shared/env.d.ts +9 -0
  251. package/shared/env.js +9 -12
  252. package/shared/generators.d.ts +4 -0
  253. package/shared/generators.js +10 -12
  254. package/shared/meta.d.ts +29 -14
  255. package/shared/meta.js +71 -55
  256. package/shared/normalizeMetadata.d.ts +32 -27
  257. package/shared/normalizeMetadata.js +23 -36
  258. package/shared/repr.d.ts +73 -55
  259. package/shared/repr.js +1 -0
  260. package/shared/soul.d.ts +17 -0
  261. package/shared/soul.js +1 -0
  262. package/shared/stringify.d.ts +2 -0
  263. package/shared/stringify.js +29 -20
  264. package/shared/symbols.d.ts +26 -20
  265. package/shared/symbols.js +79 -79
  266. package/shared/tseynit.d.ts +2 -0
  267. package/shared/tseynit.js +160 -75
  268. package/shared/utilityTypes.d.ts +30 -14
  269. package/shared/utilityTypes.js +2 -6
  270. package/shared/vertexFormat.d.ts +41 -43
  271. package/shared/vertexFormat.js +59 -62
  272. package/std/array.d.ts +2 -7
  273. package/std/array.js +18 -23
  274. package/std/atomic.d.ts +14 -18
  275. package/std/atomic.js +96 -95
  276. package/std/bitcast.d.ts +193 -10
  277. package/std/bitcast.js +309 -39
  278. package/std/boolean.d.ts +19 -33
  279. package/std/boolean.js +296 -288
  280. package/std/copy.d.ts +2 -7
  281. package/std/copy.js +27 -24
  282. package/std/derivative.d.ts +11 -15
  283. package/std/derivative.js +56 -79
  284. package/std/discard.d.ts +1 -6
  285. package/std/discard.js +7 -14
  286. package/std/environment.d.ts +19 -14
  287. package/std/environment.js +71 -51
  288. package/std/extensions.d.ts +2 -8
  289. package/std/extensions.js +10 -11
  290. package/std/index.d.ts +20 -24
  291. package/std/index.js +32 -187
  292. package/std/matrix.d.ts +6 -12
  293. package/std/matrix.js +60 -69
  294. package/std/numeric.d.ts +143 -146
  295. package/std/numeric.js +858 -749
  296. package/std/operators.d.ts +19 -27
  297. package/std/operators.js +227 -193
  298. package/std/packing.d.ts +5 -11
  299. package/std/packing.js +67 -75
  300. package/std/range.d.ts +6 -11
  301. package/std/range.js +48 -36
  302. package/std/subgroup.d.ts +33 -37
  303. package/std/subgroup.js +180 -217
  304. package/std/texture.d.ts +70 -38
  305. package/std/texture.js +176 -172
  306. package/taskQueue.d.ts +6 -0
  307. package/taskQueue.js +30 -0
  308. package/tgpu.d.ts +16 -0
  309. package/tgpu.js +17 -44
  310. package/tgpuBindGroupLayout.d.ts +132 -152
  311. package/tgpuBindGroupLayout.js +346 -268
  312. package/tgpuLogger.d.ts +34 -0
  313. package/tgpuLogger.js +63 -0
  314. package/tgpuUnstable.d.ts +16 -22
  315. package/tgpuUnstable.js +13 -35
  316. package/tgsl/accessIndex.d.ts +2 -0
  317. package/tgsl/accessIndex.js +76 -33
  318. package/tgsl/accessProp.d.ts +2 -0
  319. package/tgsl/accessProp.js +142 -101
  320. package/tgsl/accessStructProp.d.ts +5 -0
  321. package/tgsl/accessStructProp.js +13 -15
  322. package/tgsl/consoleLog/deserializers.d.ts +13 -0
  323. package/tgsl/consoleLog/deserializers.js +119 -103
  324. package/tgsl/consoleLog/logGenerator.d.ts +21 -0
  325. package/tgsl/consoleLog/logGenerator.js +85 -80
  326. package/tgsl/consoleLog/serializers.d.ts +21 -0
  327. package/tgsl/consoleLog/serializers.js +119 -100
  328. package/tgsl/consoleLog/types.d.ts +40 -39
  329. package/tgsl/consoleLog/types.js +1 -0
  330. package/tgsl/conversion.d.ts +33 -0
  331. package/tgsl/conversion.js +271 -216
  332. package/tgsl/forOfUtils.d.ts +15 -0
  333. package/tgsl/forOfUtils.js +85 -70
  334. package/tgsl/generationHelpers.d.ts +22 -39
  335. package/tgsl/generationHelpers.js +85 -58
  336. package/tgsl/infixDispatch.d.ts +70 -0
  337. package/tgsl/infixDispatch.js +48 -46
  338. package/tgsl/jsPolyfills.d.ts +16 -19
  339. package/tgsl/jsPolyfills.js +44 -42
  340. package/tgsl/makeDereferenceable.d.ts +48 -0
  341. package/tgsl/makeDereferenceable.js +86 -0
  342. package/tgsl/makeResolvable.d.ts +22 -0
  343. package/tgsl/makeResolvable.js +33 -0
  344. package/tgsl/shaderGenerator.d.ts +77 -17
  345. package/tgsl/shaderGenerator.js +1 -0
  346. package/tgsl/shellless.d.ts +6 -9
  347. package/tgsl/shellless.js +73 -43
  348. package/tgsl/wgslGenerator.d.ts +66 -59
  349. package/tgsl/wgslGenerator.js +1344 -760
  350. package/types.d.ts +287 -222
  351. package/types.js +61 -44
  352. package/unwrapper.d.ts +31 -26
  353. package/unwrapper.js +1 -0
  354. package/wgslExtensions.d.ts +3 -5
  355. package/wgslExtensions.js +12 -16
  356. package/_virtual/rolldown_runtime.js +0 -13
  357. package/core/buffer/bufferShorthand.d.ts +0 -50
  358. package/core/buffer/bufferShorthand.js +0 -55
  359. package/core/pipeline/applyPipelineState.js +0 -37
  360. package/package.js +0 -5
  361. package/tgsl/shaderGenerator_members.d.ts +0 -33
  362. 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"];
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,63 @@
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
+ ];
14
+ export class TgpuLogger {
15
+ #initialEnabledWarnings;
16
+ #enabledWarnings;
17
+ #warned = new WeakMap();
18
+ constructor(prod) {
19
+ if (prod) {
20
+ this.#initialEnabledWarnings = [
21
+ 'webgpu-feature-missing',
22
+ 'webgpu-limits-exceeded',
23
+ 'locations-mismatched',
24
+ 'log-limit-exceeded',
25
+ 'external-omitted',
26
+ ];
27
+ }
28
+ else {
29
+ this.#initialEnabledWarnings = warningTypes;
30
+ }
31
+ this.#enabledWarnings = new Set(this.#initialEnabledWarnings);
32
+ }
33
+ disable(type) {
34
+ this.#enabledWarnings.delete(type);
35
+ }
36
+ reset() {
37
+ this.#enabledWarnings = new Set(this.#initialEnabledWarnings);
38
+ }
39
+ warn(type, ...args) {
40
+ if (this.#enabledWarnings.has(type)) {
41
+ console.warn(`⚠️ [${type}] `, ...args);
42
+ }
43
+ }
44
+ warnOnce(type, key, tag, ...args) {
45
+ if (!this.#enabledWarnings.has(type)) {
46
+ return;
47
+ }
48
+ let warnings = this.#warned.get(key);
49
+ if (!warnings) {
50
+ warnings = new Set();
51
+ this.#warned.set(key, warnings);
52
+ }
53
+ const warningId = `${type}:${tag}`;
54
+ if (warnings.has(warningId)) {
55
+ return;
56
+ }
57
+ warnings.add(warningId);
58
+ this.warn(type, ...args);
59
+ }
60
+ }
61
+ const tgpuLogger = new TgpuLogger(!(DEV || TEST));
62
+ export const logger = tgpuLogger;
63
+ 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;