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
@@ -1,146 +1,124 @@
1
- import { TgpuNamable } from "../../shared/meta.js";
2
- import { $internal } from "../../shared/symbols.js";
3
- import { Assume, Mutable, OmitProps, Prettify } from "../../shared/utilityTypes.js";
4
- import { WgslComparisonSamplerProps, WgslSamplerProps } from "../../data/sampler.js";
5
- import { AnyComputeBuiltin, AnyFragmentInputBuiltin, OmitBuiltins } from "../../builtin.js";
6
- import { TgpuQuerySet } from "../querySet/querySet.js";
7
- import { InstanceToSchema } from "../../data/instanceToSchema.js";
8
- import { TgpuMutable, TgpuReadonly, TgpuUniform } from "../buffer/bufferShorthand.js";
9
- import { IORecord } from "../function/fnTypes.js";
10
- import { LogGeneratorOptions } from "../../tgsl/consoleLog/types.js";
11
- import { TgpuComputeFn } from "../function/tgpuComputeFn.js";
12
- import { Eventual, TgpuAccessor, TgpuMutableAccessor, TgpuSlot } from "../slot/slotTypes.js";
13
- import { TgpuComputePipeline } from "../pipeline/computePipeline.js";
14
- import { AnyAutoCustoms, AutoFragmentIn, AutoFragmentOut, AutoVertexIn, AutoVertexOut } from "../function/autoIO.js";
15
- import { FragmentInConstrained, FragmentOutConstrained, TgpuFragmentFn, VertexOutToVarying } from "../function/tgpuFragmentFn.js";
16
- import { TgpuVertexFn } from "../function/tgpuVertexFn.js";
17
- import { AttribRecordToDefaultDataTypes, LayoutToAllowedAttribs } from "../vertexLayout/vertexAttribute.js";
18
- import { TgpuVertexLayout } from "../vertexLayout/vertexLayout.js";
19
- import { FragmentOutToTargets, TgpuRenderPipeline } from "../pipeline/renderPipeline.js";
20
- import { Unwrapper } from "../../unwrapper.js";
21
- import { TgpuFixedComparisonSampler, TgpuFixedSampler } from "../sampler/sampler.js";
22
- import { ExtractBindGroupInputFromLayout, TgpuBindGroup, TgpuBindGroupLayout, TgpuLayoutEntry } from "../../tgpuBindGroupLayout.js";
23
- import { ShaderGenerator } from "../../tgsl/shaderGenerator.js";
24
- import { TgpuBuffer, VertexFlag } from "../buffer/buffer.js";
25
- import { AnyWgslData, BaseData, U16, U32, Vec3u, Void, WgslArray, v4f } from "../../data/wgslTypes.js";
26
- import { TgpuTexture } from "../texture/texture.js";
27
- import { ExtractInvalidSchemaError, InferGPURecord, InferInput, IsValidBufferSchema, IsValidStorageSchema, IsValidUniformSchema } from "../../shared/repr.js";
28
- import { AnyData, Disarray, UndecorateRecord } from "../../data/dataTypes.js";
29
-
30
- //#region src/core/root/rootTypes.d.ts
31
- interface TgpuGuardedComputePipeline<TArgs extends number[] = number[]> extends TgpuNamable {
32
- /**
33
- * Returns a pipeline wrapper with the specified bind group bound.
34
- * Analogous to `TgpuComputePipeline.with(bindGroup)`.
35
- */
36
- with(bindGroup: TgpuBindGroup): TgpuGuardedComputePipeline<TArgs>;
37
- /**
38
- * Returns a pipeline wrapper that encodes dispatches into the provided
39
- * command encoder instead of submitting them immediately.
40
- * Analogous to `TgpuComputePipeline.with(encoder)`.
41
- */
42
- with(encoder: GPUCommandEncoder): TgpuGuardedComputePipeline<TArgs>;
43
- /**
44
- * Returns a pipeline wrapper with the given performance callback attached.
45
- * Analogous to `TgpuComputePipeline.withPerformanceCallback(callback)`.
46
- */
47
- withPerformanceCallback(callback: (start: bigint, end: bigint) => void | Promise<void>): TgpuGuardedComputePipeline<TArgs>;
48
- /**
49
- * Returns a pipeline wrapper with the given timestamp writes configuration.
50
- * Analogous to `TgpuComputePipeline.withTimestampWrites(options)`.
51
- */
52
- withTimestampWrites(options: {
53
- querySet: TgpuQuerySet<'timestamp'> | GPUQuerySet;
54
- beginningOfPassWriteIndex?: number;
55
- endOfPassWriteIndex?: number;
56
- }): TgpuGuardedComputePipeline<TArgs>;
57
- /**
58
- * Dispatches the pipeline.
59
- * Unlike `TgpuComputePipeline.dispatchWorkgroups()`, this method takes in the
60
- * number of threads to run in each dimension.
61
- *
62
- * Under the hood, the number of expected threads is sent as a uniform, and
63
- * "guarded" by a bounds check.
64
- */
65
- dispatchThreads(...args: TArgs): void;
66
- /**
67
- * The underlying pipeline used during `dispatchThreads`.
68
- */
69
- pipeline: TgpuComputePipeline;
70
- /**
71
- * The buffer used to automatically pass the thread count to the underlying pipeline during `dispatchThreads`.
72
- * For pipelines with a dimension count lower than 3, the remaining coordinates are expected to be 1.
73
- */
74
- sizeUniform: TgpuUniform<Vec3u>;
1
+ import type { AnyComputeBuiltin, AnyFragmentInputBuiltin, OmitBuiltins } from '../../builtin.ts';
2
+ import type { TgpuQuerySet } from '../querySet/querySet.ts';
3
+ import type { AnyData } from '../../data/dataTypes.ts';
4
+ import type { InstanceToSchema } from '../../data/instanceToSchema.ts';
5
+ import type { WgslComparisonSamplerProps, WgslSamplerProps } from '../../data/sampler.ts';
6
+ import type { AnyWgslData, BaseData, v3u, v4f, Vec3u, Void } from '../../data/wgslTypes.ts';
7
+ import type { TgpuNamable } from '../../shared/meta.ts';
8
+ import type { TgpuSoul } from '../../shared/soul.ts';
9
+ import type { ExtractInvalidSchemaError, InferGPURecord, InferInput, IsValidBufferSchema, IsValidStorageSchema, IsValidUniformSchema } from '../../shared/repr.ts';
10
+ import { $internal, $soul } from '../../shared/symbols.ts';
11
+ import type { Assume, Mutable, OmitProps, Prettify } from '../../shared/utilityTypes.ts';
12
+ import type { ExtractBindGroupInputFromLayout, TgpuBindGroup, TgpuBindGroupLayout, TgpuLayoutEntry } from '../../tgpuBindGroupLayout.ts';
13
+ import type { LogGeneratorOptions } from '../../tgsl/consoleLog/types.ts';
14
+ import type { ShaderGeneratorClass } from '../../tgsl/shaderGenerator.ts';
15
+ import type { Unwrapper } from '../../unwrapper.ts';
16
+ import type { TgpuBuffer } from '../buffer/buffer.ts';
17
+ import type { TgpuMutable, TgpuReadonly, TgpuUniform } from '../buffer/bufferBinding.ts';
18
+ import type { AnyAutoCustoms, AutoFragmentIn, AutoFragmentOut, AutoVertexIn, AutoVertexOut } from '../function/autoIO.ts';
19
+ import type { IORecord } from '../function/fnTypes.ts';
20
+ import type { TgpuFragmentFn, VertexOutToVarying } from '../function/tgpuFragmentFn.ts';
21
+ import type { TgpuVertexFn } from '../function/tgpuVertexFn.ts';
22
+ import type { TgpuCommandEncoder } from '../commandEncoder/commandEncoder.ts';
23
+ import type { TgpuRenderBundleEncoder } from '../commandEncoder/renderPass.ts';
24
+ import type { TgpuComputePipeline } from '../pipeline/computePipeline.ts';
25
+ import type { FragmentOutToTargets, TgpuRenderPipeline } from '../pipeline/renderPipeline.ts';
26
+ import type { TgpuFixedComparisonSampler, TgpuFixedSampler } from '../sampler/sampler.ts';
27
+ import type { Eventual, TgpuAccessor, TgpuMutableAccessor, TgpuSlot } from '../slot/slotTypes.ts';
28
+ import type { TgpuTexture } from '../texture/texture.ts';
29
+ import type { AttribRecordToDefaultDataTypes, LayoutToAllowedAttribs } from '../vertexLayout/vertexAttribute.ts';
30
+ export interface TgpuRootSoul extends TgpuSoul<'root'> {
31
+ readonly device: GPUDevice;
32
+ readonly nameRegistrySetting: 'random' | 'strict';
33
+ readonly logOptions: LogGeneratorOptions;
34
+ readonly minify: boolean;
35
+ readonly nonTransferablePriors?: string[] | undefined;
75
36
  }
76
- interface WithCompute {
77
- createPipeline(): TgpuComputePipeline;
37
+ export interface TgpuGuardedComputePipelineSoul extends TgpuSoul<'guarded-compute-pipeline'> {
38
+ readonly device: GPUDevice;
39
+ readonly pipeline: TgpuComputePipeline;
40
+ readonly sizeUniform: TgpuUniform<Vec3u>;
41
+ readonly workgroupSize: v3u;
78
42
  }
79
- type OptionalArgs<T$1> = T$1 extends Record<string, never> | undefined ? [] | [T$1] : [T$1];
80
- /**
81
- * TODO: Remove in favor of createRenderPipeline's validation
82
- */
83
- type ValidateFragmentIn<VertexOut extends TgpuVertexFn.Out, FragmentIn extends FragmentInConstrained, FragmentOut extends FragmentOutConstrained> = UndecorateRecord<FragmentIn> extends Partial<UndecorateRecord<VertexOut>> ? UndecorateRecord<VertexOut> extends UndecorateRecord<FragmentIn> ? OptionalArgs<FragmentOutToTargets<FragmentOut>> extends infer Args ? Args extends [infer T] ? [entryFn: TgpuFragmentFn<FragmentIn, FragmentOut>, targets: T] : Args extends [] | [infer T] ? [entryFn: TgpuFragmentFn<FragmentIn, FragmentOut>] | [entryFn: TgpuFragmentFn<FragmentIn, FragmentOut>, targets: T] : never : never : [entryFn: 'n/a', targets: 'n/a', MissingFromVertexOutput: { [Key in Exclude<keyof FragmentIn, keyof VertexOut>]: FragmentIn[Key] }] : [entryFn: 'n/a', targets: 'n/a', MismatchedVertexOutput: { [Key in keyof FragmentIn & keyof VertexOut as FragmentIn[Key] extends VertexOut[Key] ? never : Key]: [got: VertexOut[Key], expecting: FragmentIn[Key]] }];
84
- interface WithVertex<VertexOut extends TgpuVertexFn.Out = TgpuVertexFn.Out> {
85
- /**
86
- * @deprecated Use `root.createRenderPipeline` instead.
87
- */
88
- withFragment<FragmentIn extends FragmentInConstrained, FragmentOut extends FragmentOutConstrained>(...args: ValidateFragmentIn<VertexOut, FragmentIn, FragmentOut>): WithFragment<FragmentOut>;
89
- /**
90
- * @deprecated Use `root.createRenderPipeline` instead.
91
- */
92
- withPrimitive(primitiveState: GPUPrimitiveState | (Omit<GPUPrimitiveState, 'stripIndexFormat'> & {
93
- stripIndexFormat?: U32 | U16;
94
- }) | undefined): WithFragment<Void>;
95
- /**
96
- * @deprecated Use `root.createRenderPipeline` instead.
97
- */
98
- withDepthStencil(depthStencilState: GPUDepthStencilState | undefined): WithFragment<Void>;
99
- /**
100
- * @deprecated Use `root.createRenderPipeline` instead.
101
- */
102
- withMultisample(multisampleState: GPUMultisampleState | undefined): WithFragment<Void>;
103
- /**
104
- * @deprecated Use `root.createRenderPipeline` instead.
105
- */
106
- createPipeline(): TgpuRenderPipeline<Void>;
43
+ export interface TgpuGuardedComputePipeline<TArgs extends number[] = number[]> extends TgpuNamable {
44
+ readonly resourceType: 'guarded-compute-pipeline';
45
+ readonly [$soul]: TgpuGuardedComputePipelineSoul;
46
+ /**
47
+ * Returns a pipeline wrapper with the specified bind group bound.
48
+ * Analogous to `TgpuComputePipeline.with(bindGroup)`.
49
+ */
50
+ with(bindGroup: TgpuBindGroup): TgpuGuardedComputePipeline<TArgs>;
51
+ /**
52
+ * Returns a pipeline wrapper with the given performance callback attached.
53
+ * Analogous to `TgpuComputePipeline.withPerformanceCallback(callback)`.
54
+ */
55
+ withPerformanceCallback(callback: (start: bigint, end: bigint) => void | Promise<void>): TgpuGuardedComputePipeline<TArgs>;
56
+ /**
57
+ * Returns a pipeline wrapper with the given timestamp writes configuration.
58
+ * Analogous to `TgpuComputePipeline.withTimestampWrites(options)`.
59
+ */
60
+ withTimestampWrites(options: {
61
+ querySet: TgpuQuerySet<'timestamp'> | GPUQuerySet;
62
+ beginningOfPassWriteIndex?: number;
63
+ endOfPassWriteIndex?: number;
64
+ }): TgpuGuardedComputePipeline<TArgs>;
65
+ /**
66
+ * Dispatches the pipeline.
67
+ * Unlike `TgpuComputePipeline.dispatchWorkgroups()`, this method takes in the
68
+ * number of threads to run in each dimension.
69
+ *
70
+ * Under the hood, the number of expected threads is sent as a uniform, and
71
+ * "guarded" by a bounds check.
72
+ */
73
+ dispatchThreads(...args: TArgs): void;
74
+ /**
75
+ * Immediately resolves the pipeline, then awaits `device.createComputePipelineAsync()`.
76
+ * NOTE: it is not necessary to initialize pipelines manually.
77
+ */
78
+ initAsync(): Promise<void>;
79
+ /**
80
+ * Immediately resolves the pipeline and creates WebGPU resources.
81
+ * NOTE: it is not necessary to initialize pipelines manually.
82
+ */
83
+ initSync(): void;
84
+ /**
85
+ * The underlying pipeline used during `dispatchThreads`.
86
+ */
87
+ pipeline: TgpuComputePipeline;
88
+ /**
89
+ * The buffer used to automatically pass the thread count to the underlying pipeline during `dispatchThreads`.
90
+ * For pipelines with a dimension count lower than 3, the remaining coordinates are expected to be 1.
91
+ */
92
+ sizeUniform: TgpuUniform<Vec3u>;
107
93
  }
108
- interface WithFragment<Targets extends FragmentOutConstrained = FragmentOutConstrained> {
109
- withPrimitive(primitiveState: GPUPrimitiveState | (Omit<GPUPrimitiveState, 'stripIndexFormat'> & {
110
- stripIndexFormat?: U32 | U16;
111
- }) | undefined): WithFragment<Targets>;
112
- withDepthStencil(depthStencilState: GPUDepthStencilState | undefined): WithFragment<Targets>;
113
- withMultisample(multisampleState: GPUMultisampleState | undefined): WithFragment<Targets>;
114
- createPipeline(): TgpuRenderPipeline<Targets>;
94
+ export interface Withable<TSelf> {
95
+ with<T>(slot: TgpuSlot<T>, value: Eventual<T>): TSelf;
96
+ with<T extends BaseData>(accessor: TgpuAccessor<T>, value: TgpuAccessor.In<NoInfer<T>>): TSelf;
97
+ with<T extends BaseData>(accessor: TgpuMutableAccessor<T>, value: TgpuMutableAccessor.In<NoInfer<T>>): TSelf;
115
98
  }
116
- interface Withable<TSelf> {
117
- with<T$1>(slot: TgpuSlot<T$1>, value: Eventual<T$1>): TSelf;
118
- with<T$1 extends BaseData>(accessor: TgpuAccessor<T$1>, value: TgpuAccessor.In<NoInfer<T$1>>): TSelf;
119
- with<T$1 extends BaseData>(accessor: TgpuMutableAccessor<T$1>, value: TgpuMutableAccessor.In<NoInfer<T$1>>): TSelf;
99
+ export interface Withable_Deprecated<TSelf> {
100
+ /**
101
+ * @deprecated This feature is stable, remove the `['~unstable']`
102
+ * @param slot
103
+ * @param value
104
+ */
105
+ with<T>(slot: TgpuSlot<T>, value: Eventual<T>): TSelf;
106
+ /**
107
+ * @deprecated This feature is stable, remove the `['~unstable']`
108
+ * @param slot
109
+ * @param value
110
+ */
111
+ with<T extends BaseData>(accessor: TgpuAccessor<T>, value: TgpuAccessor.In<NoInfer<T>>): TSelf;
112
+ /**
113
+ * @deprecated This feature is stable, remove the `['~unstable']`
114
+ * @param slot
115
+ * @param value
116
+ */
117
+ with<T extends BaseData>(accessor: TgpuMutableAccessor<T>, value: TgpuMutableAccessor.In<NoInfer<T>>): TSelf;
120
118
  }
121
- interface Withable_Deprecated<TSelf> {
122
- /**
123
- * @deprecated This feature is stable, remove the `['~unstable']`
124
- * @param slot
125
- * @param value
126
- */
127
- with<T$1>(slot: TgpuSlot<T$1>, value: Eventual<T$1>): TSelf;
128
- /**
129
- * @deprecated This feature is stable, remove the `['~unstable']`
130
- * @param slot
131
- * @param value
132
- */
133
- with<T$1 extends BaseData>(accessor: TgpuAccessor<T$1>, value: TgpuAccessor.In<NoInfer<T$1>>): TSelf;
134
- /**
135
- * @deprecated This feature is stable, remove the `['~unstable']`
136
- * @param slot
137
- * @param value
138
- */
139
- with<T$1 extends BaseData>(accessor: TgpuMutableAccessor<T$1>, value: TgpuMutableAccessor.In<NoInfer<T$1>>): TSelf;
140
- }
141
- interface Configurable extends Withable<Configurable> {
142
- readonly bindings: [slot: TgpuSlot<unknown>, value: unknown][];
143
- pipe(transform: (cfg: Configurable) => Configurable): Configurable;
119
+ export interface Configurable extends Withable<Configurable> {
120
+ readonly bindings: [slot: TgpuSlot<unknown>, value: unknown][];
121
+ pipe(transform: (cfg: Configurable) => Configurable): Configurable;
144
122
  }
145
123
  /**
146
124
  * Gets rid of builtins, and turns instances into schemas
@@ -148,510 +126,357 @@ interface Configurable extends Withable<Configurable> {
148
126
  * @example d.builtin.position => d.Void
149
127
  * @example { a: d.v4f, $fragDepth: number } => { a: d.Vec4f }
150
128
  */
151
- type NormalizeOutput<T$1> = T$1 extends {
152
- readonly [$internal]: unknown;
153
- } | number | boolean ? [OmitBuiltins<InstanceToSchema<T$1>>] extends [never] ? Void : OmitBuiltins<InstanceToSchema<T$1>> : { [K in keyof OmitBuiltins<T$1>]: InstanceToSchema<OmitBuiltins<T$1>[K]> };
154
- interface WithBinding extends Withable<WithBinding> {
155
- /** @deprecated Use `root.createComputePipeline` instead. */
156
- withCompute<ComputeIn extends IORecord<AnyComputeBuiltin>>(entryFn: TgpuComputeFn<ComputeIn>): WithCompute;
157
- createComputePipeline<ComputeIn extends IORecord<AnyComputeBuiltin>>(descriptor: TgpuComputePipeline.Descriptor<ComputeIn>): TgpuComputePipeline;
158
- createRenderPipeline<TVertexIn extends TgpuVertexFn.In = Record<string, any>, TAttribs extends LayoutToAllowedAttribs<TVertexIn> = LayoutToAllowedAttribs<TVertexIn>, TVertexOut = unknown, TFragmentOut = unknown>(descriptor: TgpuRenderPipeline.DescriptorBase & {
159
- attribs?: TAttribs;
160
- vertex: TgpuVertexFn<TVertexIn, Assume<TVertexOut, TgpuVertexFn.Out>> | ((input: AutoVertexIn<Assume<InferGPURecord<AttribRecordToDefaultDataTypes<TAttribs>>, AnyAutoCustoms>>) => AutoVertexOut<Assume<TVertexOut, AnyAutoCustoms>>);
161
- fragment: TgpuFragmentFn<VertexOutToVarying<TVertexOut> & Record<string, AnyFragmentInputBuiltin>, Assume<TFragmentOut, TgpuFragmentFn.Out>> | ((input: AutoFragmentIn<Assume<InferGPURecord<VertexOutToVarying<TVertexOut>>, AnyAutoCustoms>>) => AutoFragmentOut<Assume<TFragmentOut, AnyAutoCustoms | v4f>>);
162
- targets?: FragmentOutToTargets<NoInfer<TFragmentOut>>;
163
- }): TgpuRenderPipeline<NormalizeOutput<TFragmentOut>>;
164
- createRenderPipeline<TVertexIn extends TgpuVertexFn.In = Record<string, any>, TAttribs extends LayoutToAllowedAttribs<TVertexIn> = LayoutToAllowedAttribs<TVertexIn>, TVertexOut extends TgpuVertexFn.Out = TgpuVertexFn.Out>(descriptor: TgpuRenderPipeline.DescriptorBase & {
165
- attribs?: TAttribs;
166
- vertex: TgpuVertexFn<TVertexIn, Assume<TVertexOut, TgpuVertexFn.Out>> | ((input: AutoVertexIn<Assume<InferGPURecord<AttribRecordToDefaultDataTypes<TAttribs>>, AnyAutoCustoms>>) => AutoVertexOut<Assume<TVertexOut, AnyAutoCustoms>>);
167
- fragment?: undefined | TgpuFragmentFn<VertexOutToVarying<OmitBuiltins<TVertexOut>> & Record<string, AnyFragmentInputBuiltin>, Record<string, never> | Void> | ((input: AutoFragmentIn<Assume<InferGPURecord<OmitBuiltins<NoInfer<TVertexOut>>>, AnyAutoCustoms>>) => AutoFragmentOut<undefined>);
168
- targets?: undefined;
169
- }): TgpuRenderPipeline<Void>;
170
- createRenderPipeline<TVertexIn extends TgpuVertexFn.In = Record<string, any>, TAttribs extends LayoutToAllowedAttribs<TVertexIn> = LayoutToAllowedAttribs<TVertexIn>, TVertexOut extends TgpuVertexFn.Out = TgpuVertexFn.Out, TFragmentOut = unknown>(descriptor: TgpuRenderPipeline.DescriptorBase & ({
171
- attribs?: TAttribs;
172
- vertex: TgpuVertexFn<TVertexIn, Assume<TVertexOut, TgpuVertexFn.Out>> | ((input: AutoVertexIn<Assume<InferGPURecord<AttribRecordToDefaultDataTypes<TAttribs>>, AnyAutoCustoms>>) => AutoVertexOut<Assume<TVertexOut, AnyAutoCustoms>>);
173
- fragment: ((input: AutoFragmentIn<Assume<InferGPURecord<OmitBuiltins<NoInfer<TVertexOut>>>, AnyAutoCustoms>>) => AutoFragmentOut<Assume<TFragmentOut, AnyAutoCustoms | v4f>>) | TgpuFragmentFn<VertexOutToVarying<OmitBuiltins<TVertexOut>> & Record<string, AnyFragmentInputBuiltin>, Assume<TFragmentOut, TgpuFragmentFn.Out>>;
174
- targets?: FragmentOutToTargets<NoInfer<TFragmentOut>>;
175
- } | {
176
- attribs?: TAttribs;
177
- vertex: TgpuVertexFn<TVertexIn, Assume<TVertexOut, TgpuVertexFn.Out>> | ((input: AutoVertexIn<Assume<InferGPURecord<AttribRecordToDefaultDataTypes<TAttribs>>, AnyAutoCustoms>>) => AutoVertexOut<Assume<TVertexOut, AnyAutoCustoms>>);
178
- fragment?: undefined | TgpuFragmentFn<VertexOutToVarying<OmitBuiltins<TVertexOut>> & Record<string, AnyFragmentInputBuiltin>, Record<string, never>> | ((input: AutoFragmentIn<Assume<InferGPURecord<OmitBuiltins<NoInfer<TVertexOut>>>, AnyAutoCustoms>>) => AutoFragmentOut<undefined>);
179
- targets?: undefined;
180
- })): TgpuRenderPipeline<NormalizeOutput<TFragmentOut>> | TgpuRenderPipeline<Void>;
181
- /**
182
- * Creates a compute pipeline that executes the given callback in an exact number of threads.
183
- * This is different from `createComputePipeline()` in that it does a bounds check on the
184
- * thread id, where as regular pipelines do not and work in units of workgroups.
185
- *
186
- * @param callback A function converted to WGSL and executed on the GPU.
187
- * It can accept up to 3 parameters (x, y, z) which correspond to the global invocation ID
188
- * of the executing thread.
189
- *
190
- * @example
191
- * If no parameters are provided, the callback will be executed once, in a single thread.
192
- *
193
- * ```ts
194
- * const fooPipeline = root
195
- * .createGuardedComputePipeline(() => {
196
- * 'use gpu';
197
- * console.log('Hello, GPU!');
198
- * });
199
- *
200
- * fooPipeline.dispatchThreads();
201
- * // [GPU] Hello, GPU!
202
- * ```
203
- *
204
- * @example
205
- * One parameter means n-threads will be executed in parallel.
206
- *
207
- * ```ts
208
- * const fooPipeline = root
209
- * .createGuardedComputePipeline((x) => {
210
- * 'use gpu';
211
- * if (x % 16 === 0) {
212
- * // Logging every 16th thread
213
- * console.log('I am the', x, 'thread');
214
- * }
215
- * });
216
- *
217
- * // executing 512 threads
218
- * fooPipeline.dispatchThreads(512);
219
- * // [GPU] I am the 256 thread
220
- * // [GPU] I am the 272 thread
221
- * // ... (30 hidden logs)
222
- * // [GPU] I am the 16 thread
223
- * // [GPU] I am the 240 thread
224
- * ```
225
- */
226
- createGuardedComputePipeline<TArgs extends number[]>(callback: (...args: TArgs) => void): TgpuGuardedComputePipeline<TArgs>;
227
- /**
228
- * @deprecated Use `root.createRenderPipeline` instead.
229
- */
230
- withVertex<VertexIn extends TgpuVertexFn.In, VertexOut extends TgpuVertexFn.Out>(entryFn: TgpuVertexFn<VertexIn, VertexOut>, ...args: OptionalArgs<LayoutToAllowedAttribs<OmitBuiltins<VertexIn>>>): WithVertex<VertexOut>;
231
- pipe(transform: (cfg: Configurable) => Configurable): WithBinding;
129
+ type NormalizeOutput<T> = T extends {
130
+ readonly [$internal]: unknown;
131
+ } | number | boolean ? [OmitBuiltins<InstanceToSchema<T>>] extends [never] ? Void : OmitBuiltins<InstanceToSchema<T>> : {
132
+ [K in keyof OmitBuiltins<T>]: InstanceToSchema<OmitBuiltins<T>[K]>;
133
+ };
134
+ export interface WithBinding extends Withable<WithBinding> {
135
+ createComputePipeline<ComputeIn extends IORecord<AnyComputeBuiltin>>(descriptor: TgpuComputePipeline.Descriptor<ComputeIn>): TgpuComputePipeline;
136
+ createRenderPipeline<TVertexIn extends TgpuVertexFn.In = Record<string, any>, TAttribs extends LayoutToAllowedAttribs<TVertexIn> = LayoutToAllowedAttribs<TVertexIn>, TVertexOut = unknown, TFragmentOut = unknown>(descriptor: TgpuRenderPipeline.DescriptorBase & {
137
+ attribs?: TAttribs;
138
+ vertex: TgpuVertexFn<TVertexIn, Assume<TVertexOut, TgpuVertexFn.Out>> | ((input: AutoVertexIn<Assume<InferGPURecord<AttribRecordToDefaultDataTypes<TAttribs>>, AnyAutoCustoms>>) => AutoVertexOut<Assume<TVertexOut, AnyAutoCustoms>>);
139
+ fragment: TgpuFragmentFn<VertexOutToVarying<TVertexOut> & Record<string, AnyFragmentInputBuiltin>, Assume<TFragmentOut, TgpuFragmentFn.Out>> | ((input: AutoFragmentIn<Assume<InferGPURecord<VertexOutToVarying<TVertexOut>>, AnyAutoCustoms>>) => AutoFragmentOut<Assume<TFragmentOut, AnyAutoCustoms | v4f>>);
140
+ targets?: FragmentOutToTargets<NoInfer<TFragmentOut>>;
141
+ }): TgpuRenderPipeline<NormalizeOutput<TFragmentOut>>;
142
+ createRenderPipeline<TVertexIn extends TgpuVertexFn.In = Record<string, any>, TAttribs extends LayoutToAllowedAttribs<TVertexIn> = LayoutToAllowedAttribs<TVertexIn>, TVertexOut extends TgpuVertexFn.Out = TgpuVertexFn.Out>(descriptor: TgpuRenderPipeline.DescriptorBase & {
143
+ attribs?: TAttribs;
144
+ vertex: TgpuVertexFn<TVertexIn, Assume<TVertexOut, TgpuVertexFn.Out>> | ((input: AutoVertexIn<Assume<InferGPURecord<AttribRecordToDefaultDataTypes<TAttribs>>, AnyAutoCustoms>>) => AutoVertexOut<Assume<TVertexOut, AnyAutoCustoms>>);
145
+ fragment?: undefined | TgpuFragmentFn<VertexOutToVarying<OmitBuiltins<TVertexOut>> & Record<string, AnyFragmentInputBuiltin>, Record<string, never> | Void> | ((input: AutoFragmentIn<Assume<InferGPURecord<OmitBuiltins<NoInfer<TVertexOut>>>, AnyAutoCustoms>>) => AutoFragmentOut<undefined>);
146
+ targets?: undefined;
147
+ }): TgpuRenderPipeline<Void>;
148
+ createRenderPipeline<TVertexIn extends TgpuVertexFn.In = Record<string, any>, TAttribs extends LayoutToAllowedAttribs<TVertexIn> = LayoutToAllowedAttribs<TVertexIn>, TVertexOut extends TgpuVertexFn.Out = TgpuVertexFn.Out, TFragmentOut = unknown>(descriptor: TgpuRenderPipeline.DescriptorBase & ({
149
+ attribs?: TAttribs;
150
+ vertex: TgpuVertexFn<TVertexIn, Assume<TVertexOut, TgpuVertexFn.Out>> | ((input: AutoVertexIn<Assume<InferGPURecord<AttribRecordToDefaultDataTypes<TAttribs>>, AnyAutoCustoms>>) => AutoVertexOut<Assume<TVertexOut, AnyAutoCustoms>>);
151
+ fragment: ((input: AutoFragmentIn<Assume<InferGPURecord<OmitBuiltins<NoInfer<TVertexOut>>>, AnyAutoCustoms>>) => AutoFragmentOut<Assume<TFragmentOut, AnyAutoCustoms | v4f>>) | TgpuFragmentFn<VertexOutToVarying<OmitBuiltins<TVertexOut>> & Record<string, AnyFragmentInputBuiltin>, Assume<TFragmentOut, TgpuFragmentFn.Out>>;
152
+ targets?: FragmentOutToTargets<NoInfer<TFragmentOut>>;
153
+ } | {
154
+ attribs?: TAttribs;
155
+ vertex: TgpuVertexFn<TVertexIn, Assume<TVertexOut, TgpuVertexFn.Out>> | ((input: AutoVertexIn<Assume<InferGPURecord<AttribRecordToDefaultDataTypes<TAttribs>>, AnyAutoCustoms>>) => AutoVertexOut<Assume<TVertexOut, AnyAutoCustoms>>);
156
+ fragment?: undefined | TgpuFragmentFn<VertexOutToVarying<OmitBuiltins<TVertexOut>> & Record<string, AnyFragmentInputBuiltin>, Record<string, never>> | ((input: AutoFragmentIn<Assume<InferGPURecord<OmitBuiltins<NoInfer<TVertexOut>>>, AnyAutoCustoms>>) => AutoFragmentOut<undefined>);
157
+ targets?: undefined;
158
+ })): TgpuRenderPipeline<NormalizeOutput<TFragmentOut>> | TgpuRenderPipeline<Void>;
159
+ /**
160
+ * Creates a compute pipeline that executes the given callback in an exact number of threads.
161
+ * This is different from `createComputePipeline()` in that it does a bounds check on the
162
+ * thread id, where as regular pipelines do not and work in units of workgroups.
163
+ *
164
+ * @param callback A function converted to WGSL and executed on the GPU.
165
+ * It can accept up to 3 parameters (x, y, z) which correspond to the global invocation ID
166
+ * of the executing thread.
167
+ *
168
+ * @example
169
+ * If no parameters are provided, the callback will be executed once, in a single thread.
170
+ *
171
+ * ```ts
172
+ * const fooPipeline = root
173
+ * .createGuardedComputePipeline(() => {
174
+ * 'use gpu';
175
+ * console.log('Hello, GPU!');
176
+ * });
177
+ *
178
+ * fooPipeline.dispatchThreads();
179
+ * // [GPU] Hello, GPU!
180
+ * ```
181
+ *
182
+ * @example
183
+ * One parameter means n-threads will be executed in parallel.
184
+ *
185
+ * ```ts
186
+ * const fooPipeline = root
187
+ * .createGuardedComputePipeline((x) => {
188
+ * 'use gpu';
189
+ * if (x % 16 === 0) {
190
+ * // Logging every 16th thread
191
+ * console.log('I am the', x, 'thread');
192
+ * }
193
+ * });
194
+ *
195
+ * // executing 512 threads
196
+ * fooPipeline.dispatchThreads(512);
197
+ * // [GPU] I am the 256 thread
198
+ * // [GPU] I am the 272 thread
199
+ * // ... (30 hidden logs)
200
+ * // [GPU] I am the 16 thread
201
+ * // [GPU] I am the 240 thread
202
+ * ```
203
+ */
204
+ createGuardedComputePipeline<TArgs extends number[]>(callback: (...args: TArgs) => void): TgpuGuardedComputePipeline<TArgs>;
205
+ pipe(transform: (cfg: Configurable) => Configurable): WithBinding;
232
206
  }
233
207
  type SrgbVariants = {
234
- rgba8unorm: 'rgba8unorm-srgb';
235
- bgra8unorm: 'bgra8unorm-srgb';
236
- 'bc1-rgba-unorm': 'bc1-rgba-unorm-srgb';
237
- 'bc2-rgba-unorm': 'bc2-rgba-unorm-srgb';
238
- 'bc3-rgba-unorm': 'bc3-rgba-unorm-srgb';
239
- 'bc7-rgba-unorm': 'bc7-rgba-unorm-srgb';
240
- 'etc2-rgb8unorm': 'etc2-rgb8unorm-srgb';
241
- 'etc2-rgb8a1unorm': 'etc2-rgb8a1unorm-srgb';
242
- 'etc2-rgba8unorm': 'etc2-rgba8unorm-srgb';
243
- 'astc-4x4-unorm': 'astc-4x4-unorm-srgb';
244
- 'astc-5x4-unorm': 'astc-5x4-unorm-srgb';
245
- 'astc-5x5-unorm': 'astc-5x5-unorm-srgb';
246
- 'astc-6x5-unorm': 'astc-6x5-unorm-srgb';
247
- 'astc-6x6-unorm': 'astc-6x6-unorm-srgb';
248
- 'astc-8x5-unorm': 'astc-8x5-unorm-srgb';
249
- 'astc-8x6-unorm': 'astc-8x6-unorm-srgb';
250
- 'astc-8x8-unorm': 'astc-8x8-unorm-srgb';
251
- 'astc-10x5-unorm': 'astc-10x5-unorm-srgb';
252
- 'astc-10x6-unorm': 'astc-10x6-unorm-srgb';
253
- 'astc-10x8-unorm': 'astc-10x8-unorm-srgb';
254
- 'astc-10x10-unorm': 'astc-10x10-unorm-srgb';
255
- 'astc-12x10-unorm': 'astc-12x10-unorm-srgb';
256
- 'astc-12x12-unorm': 'astc-12x12-unorm-srgb';
208
+ rgba8unorm: 'rgba8unorm-srgb';
209
+ bgra8unorm: 'bgra8unorm-srgb';
210
+ 'bc1-rgba-unorm': 'bc1-rgba-unorm-srgb';
211
+ 'bc2-rgba-unorm': 'bc2-rgba-unorm-srgb';
212
+ 'bc3-rgba-unorm': 'bc3-rgba-unorm-srgb';
213
+ 'bc7-rgba-unorm': 'bc7-rgba-unorm-srgb';
214
+ 'etc2-rgb8unorm': 'etc2-rgb8unorm-srgb';
215
+ 'etc2-rgb8a1unorm': 'etc2-rgb8a1unorm-srgb';
216
+ 'etc2-rgba8unorm': 'etc2-rgba8unorm-srgb';
217
+ 'astc-4x4-unorm': 'astc-4x4-unorm-srgb';
218
+ 'astc-5x4-unorm': 'astc-5x4-unorm-srgb';
219
+ 'astc-5x5-unorm': 'astc-5x5-unorm-srgb';
220
+ 'astc-6x5-unorm': 'astc-6x5-unorm-srgb';
221
+ 'astc-6x6-unorm': 'astc-6x6-unorm-srgb';
222
+ 'astc-8x5-unorm': 'astc-8x5-unorm-srgb';
223
+ 'astc-8x6-unorm': 'astc-8x6-unorm-srgb';
224
+ 'astc-8x8-unorm': 'astc-8x8-unorm-srgb';
225
+ 'astc-10x5-unorm': 'astc-10x5-unorm-srgb';
226
+ 'astc-10x6-unorm': 'astc-10x6-unorm-srgb';
227
+ 'astc-10x8-unorm': 'astc-10x8-unorm-srgb';
228
+ 'astc-10x10-unorm': 'astc-10x10-unorm-srgb';
229
+ 'astc-12x10-unorm': 'astc-12x10-unorm-srgb';
230
+ 'astc-12x12-unorm': 'astc-12x12-unorm-srgb';
257
231
  };
258
- type SrgbVariantOrSelf<T$1 extends GPUTextureFormat> = T$1 extends keyof SrgbVariants ? (SrgbVariants[T$1] | T$1)[] | undefined : T$1 extends `${infer Base}-srgb` ? Base extends keyof SrgbVariants ? (T$1 | SrgbVariants[Base])[] | undefined : T$1[] | undefined : T$1[] | undefined;
259
- type CreateTextureOptions<TSize, TFormat extends GPUTextureFormat, TMipLevelCount extends number, TSampleCount extends number, TViewFormats extends GPUTextureFormat[], TDimension extends GPUTextureDimension> = {
260
- /**
261
- * The width, height, and depth or layer count of the texture.
262
- */
263
- size: TSize;
264
- /**
265
- * The format of the texture.
266
- */
267
- format: TFormat;
268
- /**
269
- * The number of mip levels the texture will contain.
270
- * @default 1
271
- */
272
- mipLevelCount?: TMipLevelCount | undefined;
273
- /**
274
- * The sample count of the texture. A sampleCount > 1 indicates a multisampled texture.
275
- * @default 1
276
- */
277
- sampleCount?: TSampleCount | undefined;
278
- /**
279
- * Specifies extra formats (in addition to the texture's actual format) that can be used
280
- * when creating views of this texture.
281
- * @default []
282
- */
283
- viewFormats?: TViewFormats extends SrgbVariantOrSelf<NoInfer<TFormat>> ? TViewFormats : SrgbVariantOrSelf<NoInfer<TFormat>>;
284
- /**
285
- * Whether the texture is one-dimensional, an array of two-dimensional layers, or three-dimensional.
286
- * @default '2d'
287
- */
288
- dimension?: TDimension | undefined;
232
+ type SrgbVariantOrSelf<T extends GPUTextureFormat> = T extends keyof SrgbVariants ? (SrgbVariants[T] | T)[] | undefined : T extends `${infer Base}-srgb` ? Base extends keyof SrgbVariants ? (T | SrgbVariants[Base])[] | undefined : T[] | undefined : T[] | undefined;
233
+ export type CreateTextureOptions<TSize, TFormat extends GPUTextureFormat, TMipLevelCount extends number, TSampleCount extends number, TViewFormats extends GPUTextureFormat[], TDimension extends GPUTextureDimension> = {
234
+ /**
235
+ * The width, height, and depth or layer count of the texture.
236
+ */
237
+ size: TSize;
238
+ /**
239
+ * The format of the texture.
240
+ */
241
+ format: TFormat;
242
+ /**
243
+ * The number of mip levels the texture will contain.
244
+ * @default 1
245
+ */
246
+ mipLevelCount?: TMipLevelCount | undefined;
247
+ /**
248
+ * The sample count of the texture. A sampleCount > 1 indicates a multisampled texture.
249
+ * @default 1
250
+ */
251
+ sampleCount?: TSampleCount | undefined;
252
+ /**
253
+ * Specifies extra formats (in addition to the texture's actual format) that can be used
254
+ * when creating views of this texture.
255
+ * @default []
256
+ */
257
+ viewFormats?: TViewFormats extends SrgbVariantOrSelf<NoInfer<TFormat>> ? TViewFormats : SrgbVariantOrSelf<NoInfer<TFormat>>;
258
+ /**
259
+ * Whether the texture is one-dimensional, an array of two-dimensional layers, or three-dimensional.
260
+ * @default '2d'
261
+ */
262
+ dimension?: TDimension | undefined;
289
263
  };
290
- type CreateTextureResult<TSize extends readonly number[], TFormat extends GPUTextureFormat, TMipLevelCount extends number, TSampleCount extends number, TViewFormats extends GPUTextureFormat[], TDimension extends GPUTextureDimension> = Prettify<{
291
- size: Mutable<TSize>;
292
- format: TFormat;
264
+ export type CreateTextureResult<TSize extends readonly number[], TFormat extends GPUTextureFormat, TMipLevelCount extends number, TSampleCount extends number, TViewFormats extends GPUTextureFormat[], TDimension extends GPUTextureDimension> = Prettify<{
265
+ size: Mutable<TSize>;
266
+ format: TFormat;
293
267
  } & OmitProps<{
294
- dimension: GPUTextureDimension extends TDimension ? undefined : TDimension extends '2d' ? undefined : TDimension;
295
- mipLevelCount: number extends TMipLevelCount ? undefined : TMipLevelCount extends 1 ? undefined : TMipLevelCount;
296
- sampleCount: number extends TSampleCount ? undefined : TSampleCount extends 1 ? undefined : TSampleCount;
297
- viewFormats: GPUTextureFormat[] extends TViewFormats ? undefined : TViewFormats extends never[] ? undefined : TViewFormats extends SrgbVariantOrSelf<TFormat> ? TViewFormats : never;
268
+ dimension: GPUTextureDimension extends TDimension ? undefined : TDimension extends '2d' ? undefined : TDimension;
269
+ mipLevelCount: number extends TMipLevelCount ? undefined : TMipLevelCount extends 1 ? undefined : TMipLevelCount;
270
+ sampleCount: number extends TSampleCount ? undefined : TSampleCount extends 1 ? undefined : TSampleCount;
271
+ viewFormats: GPUTextureFormat[] extends TViewFormats ? undefined : TViewFormats extends never[] ? undefined : TViewFormats extends SrgbVariantOrSelf<TFormat> ? TViewFormats : never;
298
272
  }, undefined>>;
299
- interface RenderBundleEncoderPass {
300
- /**
301
- * Sets the current {@link TgpuRenderPipeline} for subsequent draw calls.
302
- * @param pipeline - The render pipeline to use.
303
- */
304
- setPipeline(pipeline: TgpuRenderPipeline): void;
305
- /**
306
- * Sets the current index buffer.
307
- * @param buffer - Buffer containing index data to use for subsequent drawing commands.
308
- * @param indexFormat - Format of the index data contained in `buffer`.
309
- * @param offset - Offset in bytes into `buffer` where the index data begins. Defaults to `0`.
310
- * @param size - Size in bytes of the index data in `buffer`.
311
- * Defaults to the size of the buffer minus the offset.
312
- */
313
- setIndexBuffer<TData extends WgslArray | Disarray>(buffer: TgpuBuffer<TData> | GPUBuffer, indexFormat: GPUIndexFormat, offset?: GPUSize64, size?: GPUSize64): void;
314
- /**
315
- * Binds a vertex buffer to the given vertex layout for subsequent draw calls.
316
- * @param vertexLayout - The vertex layout describing the buffer's structure.
317
- * @param buffer - The vertex buffer to bind.
318
- * @param offset - Offset in bytes into `buffer`. Defaults to `0`.
319
- * @param size - Size in bytes to bind. Defaults to the remainder of the buffer.
320
- */
321
- setVertexBuffer<TData extends WgslArray | Disarray>(vertexLayout: TgpuVertexLayout<TData>, buffer: (TgpuBuffer<TData> & VertexFlag) | GPUBuffer, offset?: GPUSize64, size?: GPUSize64): void;
322
- /**
323
- * Associates a bind group with the given layout for subsequent draw calls.
324
- * @param bindGroupLayout - The layout the bind group conforms to.
325
- * @param bindGroup - The bind group to associate.
326
- */
327
- setBindGroup<Entries extends Record<string, TgpuLayoutEntry | null>>(bindGroupLayout: TgpuBindGroupLayout<Entries>, bindGroup: TgpuBindGroup<Entries> | GPUBindGroup): void;
328
- /**
329
- * Draws primitives.
330
- * @param vertexCount - The number of vertices to draw.
331
- * @param instanceCount - The number of instances to draw.
332
- * @param firstVertex - Offset into the vertex buffers, in vertices, to begin drawing from.
333
- * @param firstInstance - First instance to draw.
334
- */
335
- draw(vertexCount: number, instanceCount?: number, firstVertex?: number, firstInstance?: number): void;
336
- /**
337
- * Draws indexed primitives.
338
- * @param indexCount - The number of indices to draw.
339
- * @param instanceCount - The number of instances to draw.
340
- * @param firstIndex - Offset into the index buffer, in indices, begin drawing from.
341
- * @param baseVertex - Added to each index value before indexing into the vertex buffers.
342
- * @param firstInstance - First instance to draw.
343
- */
344
- drawIndexed(indexCount: number, instanceCount?: number, firstIndex?: number, baseVertex?: number, firstInstance?: number): void;
345
- /**
346
- * Draws primitives using parameters read from a {@link GPUBuffer}.
347
- * @param indirectBuffer - Buffer containing the indirect draw parameters.
348
- * @param indirectOffset - Offset in bytes into `indirectBuffer` where the drawing data begins.
349
- */
350
- drawIndirect(indirectBuffer: GPUBuffer, indirectOffset: GPUSize64): void;
351
- /**
352
- * Draws indexed primitives using parameters read from a {@link GPUBuffer}.
353
- * @param indirectBuffer - Buffer containing the indirect drawIndexed parameters.
354
- * @param indirectOffset - Offset in bytes into `indirectBuffer` where the drawing data begins.
355
- */
356
- drawIndexedIndirect(indirectBuffer: GPUBuffer, indirectOffset: GPUSize64): void;
357
- }
358
- type Replace<T$1, R> = Omit<T$1, keyof R> & R;
359
- /**
360
- * The same as {@link GPURenderPassDescriptor}, but accepting readonly tuples as the clearValue
361
- */
362
- type TgpuRenderPassDescriptor = Replace<GPURenderPassDescriptor, {
363
- colorAttachments: (Replace<GPURenderPassColorAttachment, {
364
- clearValue?: readonly [number, number, number, number] | GPUColor | undefined;
365
- }> | null)[];
366
- }>;
367
- interface RenderPass extends RenderBundleEncoderPass {
368
- /**
369
- * Sets the viewport used during the rasterization stage to linearly map from
370
- * NDC (i.e., normalized device coordinates) to viewport coordinates.
371
- * @param x - Minimum X value of the viewport in pixels.
372
- * @param y - Minimum Y value of the viewport in pixels.
373
- * @param width - Width of the viewport in pixels.
374
- * @param height - Height of the viewport in pixels.
375
- * @param minDepth - Minimum depth value of the viewport.
376
- * @param maxDepth - Maximum depth value of the viewport.
377
- */
378
- setViewport(x: number, y: number, width: number, height: number, minDepth: number, maxDepth: number): void;
379
- /**
380
- * Sets the scissor rectangle used during the rasterization stage.
381
- * After transformation into viewport coordinates any fragments which fall outside the scissor
382
- * rectangle will be discarded.
383
- * @param x - Minimum X value of the scissor rectangle in pixels.
384
- * @param y - Minimum Y value of the scissor rectangle in pixels.
385
- * @param width - Width of the scissor rectangle in pixels.
386
- * @param height - Height of the scissor rectangle in pixels.
387
- */
388
- setScissorRect(x: number, y: number, width: number, height: number): void;
389
- /**
390
- * Sets the constant blend color and alpha values used with {@link GPUBlendFactor#constant}
391
- * and {@link GPUBlendFactor#"one-minus-constant"} {@link GPUBlendFactor}s.
392
- * @param color - The color to use when blending.
393
- */
394
- setBlendConstant(color: GPUColor): void;
395
- /**
396
- * Sets the {@link RenderState#[[stencilReference]]} value used during stencil tests with
397
- * the {@link GPUStencilOperation#"replace"} {@link GPUStencilOperation}.
398
- * @param reference - The new stencil reference value.
399
- */
400
- setStencilReference(reference: GPUStencilValue): void;
401
- /**
402
- * @param queryIndex - The index of the query in the query set.
403
- */
404
- beginOcclusionQuery(queryIndex: GPUSize32): void;
405
- endOcclusionQuery(): void;
406
- /**
407
- * Executes the commands previously recorded into the given {@link GPURenderBundle}s as part of
408
- * this render pass.
409
- * When a {@link GPURenderBundle} is executed, it does not inherit the render pass's pipeline, bind
410
- * groups, or vertex and index buffers. After a {@link GPURenderBundle} has executed, the render
411
- * pass's pipeline, bind group, and vertex/index buffer state is cleared
412
- * (to the initial, empty values).
413
- * Note: The state is cleared, not restored to the previous state.
414
- * This occurs even if zero {@link GPURenderBundle|GPURenderBundles} are executed.
415
- * @param bundles - List of render bundles to execute.
416
- */
417
- executeBundles(bundles: Iterable<GPURenderBundle>): undefined;
418
- setPipeline(pipeline: TgpuRenderPipeline): void;
419
- /**
420
- * Sets the current index buffer.
421
- * @param buffer - Buffer containing index data to use for subsequent drawing commands.
422
- * @param indexFormat - Format of the index data contained in `buffer`.
423
- * @param offset - Offset in bytes into `buffer` where the index data begins. Defaults to `0`.
424
- * @param size - Size in bytes of the index data in `buffer`.
425
- * Defaults to the size of the buffer minus the offset.
426
- */
427
- setIndexBuffer<TData extends WgslArray | Disarray>(buffer: TgpuBuffer<TData> | GPUBuffer, indexFormat: GPUIndexFormat, offset?: GPUSize64, size?: GPUSize64): void;
428
- setVertexBuffer<TData extends WgslArray | Disarray>(vertexLayout: TgpuVertexLayout<TData>, buffer: (TgpuBuffer<TData> & VertexFlag) | GPUBuffer, offset?: GPUSize64, size?: GPUSize64): void;
429
- setBindGroup<Entries extends Record<string, TgpuLayoutEntry | null>>(bindGroupLayout: TgpuBindGroupLayout<Entries>, bindGroup: TgpuBindGroup<Entries> | GPUBindGroup): void;
430
- /**
431
- * Draws primitives.
432
- * @param vertexCount - The number of vertices to draw.
433
- * @param instanceCount - The number of instances to draw.
434
- * @param firstVertex - Offset into the vertex buffers, in vertices, to begin drawing from.
435
- * @param firstInstance - First instance to draw.
436
- */
437
- draw(vertexCount: number, instanceCount?: number, firstVertex?: number, firstInstance?: number): void;
438
- /**
439
- * Draws indexed primitives.
440
- * @param indexCount - The number of indices to draw.
441
- * @param instanceCount - The number of instances to draw.
442
- * @param firstIndex - Offset into the index buffer, in indices, begin drawing from.
443
- * @param baseVertex - Added to each index value before indexing into the vertex buffers.
444
- * @param firstInstance - First instance to draw.
445
- */
446
- drawIndexed(indexCount: number, instanceCount?: number, firstIndex?: number, baseVertex?: number, firstInstance?: number): void;
447
- /**
448
- * Draws primitives using parameters read from a {@link GPUBuffer}.
449
- * Packed block of **four 32-bit unsigned integer values (16 bytes total)**, given in the same
450
- * order as the arguments for {@link GPURenderEncoderBase#draw}. For example:
451
- * @param indirectBuffer - Buffer containing the indirect draw parameters.
452
- * @param indirectOffset - Offset in bytes into `indirectBuffer` where the drawing data begins.
453
- */
454
- drawIndirect(indirectBuffer: GPUBuffer, indirectOffset: GPUSize64): void;
455
- /**
456
- * Draws indexed primitives using parameters read from a {@link GPUBuffer}.
457
- * Tightly packed block of **five 32-bit unsigned integer values (20 bytes total)**, given in
458
- * the same order as the arguments for {@link GPURenderEncoderBase#drawIndexed}. For example:
459
- * @param indirectBuffer - Buffer containing the indirect drawIndexed parameters.
460
- * @param indirectOffset - Offset in bytes into `indirectBuffer` where the drawing data begins.
461
- */
462
- drawIndexedIndirect(indirectBuffer: GPUBuffer, indirectOffset: GPUSize64): void;
463
- }
464
- type ValidateBufferSchema<TData extends BaseData> = IsValidBufferSchema<TData> extends false ? ExtractInvalidSchemaError<TData, '(Error) '> : TData;
465
- type ValidateStorageSchema<TData extends BaseData> = IsValidStorageSchema<TData> extends false ? ExtractInvalidSchemaError<TData, '(Error) '> : TData;
466
- type ValidateUniformSchema<TData extends BaseData> = IsValidUniformSchema<TData> extends false ? ExtractInvalidSchemaError<TData, '(Error) '> : TData;
467
- type ConfigureContextOptions = {
468
- /**
469
- * The canvas for which a context will be created and configured.
470
- */
471
- canvas: HTMLCanvasElement | OffscreenCanvas;
472
- /**
473
- * Passed to `context.configure()`.
474
- * Defaults to `navigator.gpu.getPreferredCanvasFormat()` if not provided.
475
- */
476
- format?: GPUTextureFormat;
273
+ export type ValidateBufferSchema<TData extends BaseData> = IsValidBufferSchema<TData> extends false ? ExtractInvalidSchemaError<TData, '(Error) '> : TData;
274
+ export type ValidateStorageSchema<TData extends BaseData> = IsValidStorageSchema<TData> extends false ? ExtractInvalidSchemaError<TData, '(Error) '> : TData;
275
+ export type ValidateUniformSchema<TData extends BaseData> = IsValidUniformSchema<TData> extends false ? ExtractInvalidSchemaError<TData, '(Error) '> : TData;
276
+ export type ConfigureContextOptions = {
277
+ /**
278
+ * The canvas for which a context will be created and configured.
279
+ */
280
+ canvas: HTMLCanvasElement | OffscreenCanvas;
281
+ /**
282
+ * Passed to `context.configure()`.
283
+ * Defaults to `navigator.gpu.getPreferredCanvasFormat()` if not provided.
284
+ */
285
+ format?: GPUTextureFormat;
477
286
  } & Omit<GPUCanvasConfiguration, 'device' | 'format'>;
478
- interface TgpuRoot extends Unwrapper, WithBinding {
479
- [$internal]: {
480
- logOptions: LogGeneratorOptions;
481
- };
482
- /**
483
- * The GPU device associated with this root.
484
- */
485
- readonly device: GPUDevice;
486
- /**
487
- * Creates and configures context for the provided canvas.
488
- * Automatically sets the format to `navigator.gpu.getPreferredCanvasFormat()` if not provided.
489
- * @throws An error if no context could be obtained
490
- */
491
- configureContext(options: ConfigureContextOptions): GPUCanvasContext;
492
- /**
493
- * Allocates memory on the GPU, allows passing data between host and shader.
494
- *
495
- * @remarks
496
- * Typed wrapper around a GPUBuffer.
497
- *
498
- * @param typeSchema The type of data that this buffer will hold.
499
- * @param initial Either initial value of the buffer, or an initializer to execute on the mapped buffer. (optional)
500
- */
501
- createBuffer<TData extends AnyData>(typeSchema: ValidateBufferSchema<TData>, initial?: ((buffer: TgpuBuffer<NoInfer<TData>>) => void) | InferInput<NoInfer<TData>>): TgpuBuffer<TData>;
502
- /**
503
- * Allocates memory on the GPU, allows passing data between host and shader.
504
- *
505
- * @remarks
506
- * Typed wrapper around a GPUBuffer.
507
- *
508
- * @param typeSchema The type of data that this buffer will hold.
509
- * @param gpuBuffer A vanilla WebGPU buffer.
510
- */
511
- createBuffer<TData extends AnyData>(typeSchema: ValidateBufferSchema<TData>, gpuBuffer: GPUBuffer): TgpuBuffer<TData>;
512
- /**
513
- * Allocates memory on the GPU, allows passing data between host and shader.
514
- * Read-only on the GPU, optimized for small data. For a general-purpose buffer,
515
- * use {@link TgpuRoot.createBuffer}.
516
- *
517
- * @param typeSchema The type of data that this buffer will hold.
518
- * @param initial Either initial value of the buffer, or an initializer to execute on the mapped buffer. (optional)
519
- */
520
- createUniform<TData extends AnyWgslData>(typeSchema: ValidateUniformSchema<TData>, initial?: ((buffer: TgpuBuffer<NoInfer<TData>>) => void) | InferInput<NoInfer<TData>>): TgpuUniform<TData>;
521
- /**
522
- * Allocates memory on the GPU, allows passing data between host and shader.
523
- * Read-only on the GPU, optimized for small data. For a general-purpose buffer,
524
- * use {@link TgpuRoot.createBuffer}.
525
- *
526
- * @param typeSchema The type of data that this buffer will hold.
527
- * @param gpuBuffer A vanilla WebGPU buffer.
528
- */
529
- createUniform<TData extends AnyWgslData>(typeSchema: ValidateUniformSchema<TData>, gpuBuffer: GPUBuffer): TgpuUniform<TData>;
530
- /**
531
- * Allocates memory on the GPU, allows passing data between host and shader.
532
- * Can be mutated in-place on the GPU. For a general-purpose buffer,
533
- * use {@link TgpuRoot.createBuffer}.
534
- *
535
- * @param typeSchema The type of data that this buffer will hold.
536
- * @param initial Either initial value of the buffer, or an initializer to execute on the mapped buffer. (optional)
537
- */
538
- createMutable<TData extends AnyWgslData>(typeSchema: ValidateStorageSchema<TData>, initial?: ((buffer: TgpuBuffer<NoInfer<TData>>) => void) | InferInput<NoInfer<TData>>): TgpuMutable<TData>;
539
- /**
540
- * Allocates memory on the GPU, allows passing data between host and shader.
541
- * Can be mutated in-place on the GPU. For a general-purpose buffer,
542
- * use {@link TgpuRoot.createBuffer}.
543
- *
544
- * @param typeSchema The type of data that this buffer will hold.
545
- * @param gpuBuffer A vanilla WebGPU buffer.
546
- */
547
- createMutable<TData extends AnyWgslData>(typeSchema: ValidateStorageSchema<TData>, gpuBuffer: GPUBuffer): TgpuMutable<TData>;
548
- /**
549
- * Allocates memory on the GPU, allows passing data between host and shader.
550
- * Read-only on the GPU, optimized for large data. For a general-purpose buffer,
551
- * use {@link TgpuRoot.createBuffer}.
552
- *
553
- * @param typeSchema The type of data that this buffer will hold.
554
- * @param initial Either initial value of the buffer, or an initializer to execute on the mapped buffer. (optional)
555
- */
556
- createReadonly<TData extends AnyWgslData>(typeSchema: ValidateStorageSchema<TData>, initial?: ((buffer: TgpuBuffer<NoInfer<TData>>) => void) | InferInput<NoInfer<TData>>): TgpuReadonly<TData>;
557
- /**
558
- * Allocates memory on the GPU, allows passing data between host and shader.
559
- * Read-only on the GPU, optimized for large data. For a general-purpose buffer,
560
- * use {@link TgpuRoot.createBuffer}.
561
- *
562
- * @param typeSchema The type of data that this buffer will hold.
563
- * @param gpuBuffer A vanilla WebGPU buffer.
564
- */
565
- createReadonly<TData extends AnyWgslData>(typeSchema: ValidateStorageSchema<TData>, gpuBuffer: GPUBuffer): TgpuReadonly<TData>;
566
- createTexture<TWidth extends number, THeight extends number, TDepth extends number, TSize extends readonly [TWidth] | readonly [TWidth, THeight] | readonly [TWidth, THeight, TDepth], TFormat extends GPUTextureFormat, TMipLevelCount extends number, TSampleCount extends number, TViewFormats extends GPUTextureFormat[], TDimension extends GPUTextureDimension>(props: CreateTextureOptions<TSize, TFormat, TMipLevelCount, TSampleCount, TViewFormats, TDimension>): TgpuTexture<CreateTextureResult<TSize, TFormat, TMipLevelCount, TSampleCount, TViewFormats, TDimension>>;
567
- createSampler(props: WgslSamplerProps): TgpuFixedSampler;
568
- createComparisonSampler(props: WgslComparisonSamplerProps): TgpuFixedComparisonSampler;
569
- /**
570
- * Creates a query set for collecting timestamps or occlusion queries.
571
- *
572
- * @remarks
573
- * Typed wrapper around a GPUQuerySet.
574
- *
575
- * @param type The type of queries to collect ('occlusion' or 'timestamp').
576
- * @param count The number of queries in the set.
577
- * @param rawQuerySet An optional pre-existing GPUQuerySet to use instead of creating a new one.
578
- */
579
- createQuerySet<T$1 extends GPUQueryType>(type: T$1, count: number, rawQuerySet?: GPUQuerySet): TgpuQuerySet<T$1>;
580
- /**
581
- * Creates a group of resources that can be bound to a shader based on a specified layout.
582
- *
583
- * @remarks
584
- * Typed wrapper around a GPUBindGroup.
585
- *
586
- * @example
587
- * const fooLayout = tgpu.bindGroupLayout({
588
- * foo: { uniform: d.vec3f },
589
- * bar: { texture: 'float' },
590
- * });
591
- *
592
- * const fooBuffer = ...;
593
- * const barTexture = ...;
594
- *
595
- * const fooBindGroup = root.createBindGroup(fooLayout, {
596
- * foo: fooBuffer,
597
- * bar: barTexture,
598
- * });
599
- *
600
- * @param layout Layout describing the bind group to be created.
601
- * @param entries A record with values being the resources populating the bind group
602
- * and keys being their associated names, matching the layout keys.
603
- */
604
- createBindGroup<Entries extends Record<string, TgpuLayoutEntry | null> = Record<string, TgpuLayoutEntry | null>>(layout: TgpuBindGroupLayout<Entries>, entries: ExtractBindGroupInputFromLayout<Entries>): TgpuBindGroup<Entries>;
605
- /**
606
- * Retrieves a read-only list of all enabled features of the GPU device.
607
- * @returns A set of strings representing the enabled features.
608
- */
609
- get enabledFeatures(): ReadonlySet<GPUFeatureName>;
610
- /**
611
- * Destroys all underlying resources (i.e. buffers...) created through this root object.
612
- * If the object is created via `tgpu.init` instead of `tgpu.initFromDevice`,
613
- * then the inner GPU device is destroyed as well.
614
- */
615
- destroy(): void;
616
- '~unstable': Pick<ExperimentalTgpuRoot, 'beginRenderPass' | 'beginRenderBundleEncoder' | 'createComparisonSampler' | 'createGuardedComputePipeline' | 'createSampler' | 'createTexture' | 'flush' | 'nameRegistrySetting' | 'shaderGenerator' | 'pipe' | 'with' | 'withCompute' | 'withVertex'>;
287
+ export interface TgpuRoot extends Unwrapper, WithBinding {
288
+ readonly resourceType: 'root';
289
+ readonly [$soul]: TgpuRootSoul;
290
+ [$internal]: {
291
+ logOptions: LogGeneratorOptions;
292
+ };
293
+ /**
294
+ * The GPU device associated with this root.
295
+ */
296
+ readonly device: GPUDevice;
297
+ /**
298
+ * Creates and configures context for the provided canvas.
299
+ * Automatically sets the format to `navigator.gpu.getPreferredCanvasFormat()` if not provided.
300
+ * @throws An error if no context could be obtained
301
+ */
302
+ configureContext(options: ConfigureContextOptions): GPUCanvasContext;
303
+ /**
304
+ * Allocates memory on the GPU, allows passing data between host and shader.
305
+ *
306
+ * @remarks
307
+ * Typed wrapper around a GPUBuffer.
308
+ *
309
+ * @param typeSchema The type of data that this buffer will hold.
310
+ * @param initial Either initial value of the buffer, or an initializer to execute on the mapped buffer. (optional)
311
+ */
312
+ createBuffer<TData extends AnyData>(typeSchema: ValidateBufferSchema<TData>, initial?: ((buffer: TgpuBuffer<NoInfer<TData>>) => void) | InferInput<NoInfer<TData>>): TgpuBuffer<TData>;
313
+ /**
314
+ * Allocates memory on the GPU, allows passing data between host and shader.
315
+ *
316
+ * @remarks
317
+ * Typed wrapper around a GPUBuffer.
318
+ *
319
+ * @param typeSchema The type of data that this buffer will hold.
320
+ * @param gpuBuffer A vanilla WebGPU buffer.
321
+ */
322
+ createBuffer<TData extends AnyData>(typeSchema: ValidateBufferSchema<TData>, gpuBuffer: GPUBuffer): TgpuBuffer<TData>;
323
+ /**
324
+ * Allocates memory on the GPU, allows passing data between host and shader.
325
+ * Read-only on the GPU, optimized for small data. For a general-purpose buffer,
326
+ * use {@link TgpuRoot.createBuffer}.
327
+ *
328
+ * @param typeSchema The type of data that this buffer will hold.
329
+ * @param initial Either initial value of the buffer, or an initializer to execute on the mapped buffer. (optional)
330
+ */
331
+ createUniform<TData extends AnyWgslData>(typeSchema: ValidateUniformSchema<TData>, initial?: ((buffer: TgpuBuffer<NoInfer<TData>>) => void) | InferInput<NoInfer<TData>>): TgpuUniform<TData>;
332
+ /**
333
+ * Allocates memory on the GPU, allows passing data between host and shader.
334
+ * Read-only on the GPU, optimized for small data. For a general-purpose buffer,
335
+ * use {@link TgpuRoot.createBuffer}.
336
+ *
337
+ * @param typeSchema The type of data that this buffer will hold.
338
+ * @param gpuBuffer A vanilla WebGPU buffer.
339
+ */
340
+ createUniform<TData extends AnyWgslData>(typeSchema: ValidateUniformSchema<TData>, gpuBuffer: GPUBuffer): TgpuUniform<TData>;
341
+ /**
342
+ * Allocates memory on the GPU, allows passing data between host and shader.
343
+ * Can be mutated in-place on the GPU. For a general-purpose buffer,
344
+ * use {@link TgpuRoot.createBuffer}.
345
+ *
346
+ * @param typeSchema The type of data that this buffer will hold.
347
+ * @param initial Either initial value of the buffer, or an initializer to execute on the mapped buffer. (optional)
348
+ */
349
+ createMutable<TData extends AnyWgslData>(typeSchema: ValidateStorageSchema<TData>, initial?: ((buffer: TgpuBuffer<NoInfer<TData>>) => void) | InferInput<NoInfer<TData>>): TgpuMutable<TData>;
350
+ /**
351
+ * Allocates memory on the GPU, allows passing data between host and shader.
352
+ * Can be mutated in-place on the GPU. For a general-purpose buffer,
353
+ * use {@link TgpuRoot.createBuffer}.
354
+ *
355
+ * @param typeSchema The type of data that this buffer will hold.
356
+ * @param gpuBuffer A vanilla WebGPU buffer.
357
+ */
358
+ createMutable<TData extends AnyWgslData>(typeSchema: ValidateStorageSchema<TData>, gpuBuffer: GPUBuffer): TgpuMutable<TData>;
359
+ /**
360
+ * Allocates memory on the GPU, allows passing data between host and shader.
361
+ * Read-only on the GPU, optimized for large data. For a general-purpose buffer,
362
+ * use {@link TgpuRoot.createBuffer}.
363
+ *
364
+ * @param typeSchema The type of data that this buffer will hold.
365
+ * @param initial Either initial value of the buffer, or an initializer to execute on the mapped buffer. (optional)
366
+ */
367
+ createReadonly<TData extends AnyWgslData>(typeSchema: ValidateStorageSchema<TData>, initial?: ((buffer: TgpuBuffer<NoInfer<TData>>) => void) | InferInput<NoInfer<TData>>): TgpuReadonly<TData>;
368
+ /**
369
+ * Allocates memory on the GPU, allows passing data between host and shader.
370
+ * Read-only on the GPU, optimized for large data. For a general-purpose buffer,
371
+ * use {@link TgpuRoot.createBuffer}.
372
+ *
373
+ * @param typeSchema The type of data that this buffer will hold.
374
+ * @param gpuBuffer A vanilla WebGPU buffer.
375
+ */
376
+ createReadonly<TData extends AnyWgslData>(typeSchema: ValidateStorageSchema<TData>, gpuBuffer: GPUBuffer): TgpuReadonly<TData>;
377
+ createTexture<TWidth extends number, THeight extends number, TDepth extends number, TSize extends readonly [TWidth] | readonly [TWidth, THeight] | readonly [TWidth, THeight, TDepth], TFormat extends GPUTextureFormat, TMipLevelCount extends number, TSampleCount extends number, TViewFormats extends GPUTextureFormat[], TDimension extends GPUTextureDimension>(props: CreateTextureOptions<TSize, TFormat, TMipLevelCount, TSampleCount, TViewFormats, TDimension>): TgpuTexture<CreateTextureResult<TSize, TFormat, TMipLevelCount, TSampleCount, TViewFormats, TDimension>>;
378
+ createSampler(props: WgslSamplerProps): TgpuFixedSampler;
379
+ createComparisonSampler(props: WgslComparisonSamplerProps): TgpuFixedComparisonSampler;
380
+ /**
381
+ * Creates a query set for collecting timestamps or occlusion queries.
382
+ *
383
+ * @remarks
384
+ * Typed wrapper around a GPUQuerySet.
385
+ *
386
+ * @param type The type of queries to collect ('occlusion' or 'timestamp').
387
+ * @param count The number of queries in the set.
388
+ * @param rawQuerySet An optional pre-existing GPUQuerySet to use instead of creating a new one.
389
+ */
390
+ createQuerySet<T extends GPUQueryType>(type: T, count: number, rawQuerySet?: GPUQuerySet): TgpuQuerySet<T>;
391
+ /**
392
+ * Creates a group of resources that can be bound to a shader based on a specified layout.
393
+ *
394
+ * @remarks
395
+ * Typed wrapper around a GPUBindGroup.
396
+ *
397
+ * @example
398
+ * const fooLayout = tgpu.bindGroupLayout({
399
+ * foo: { uniform: d.vec3f },
400
+ * bar: { texture: d.texture2d(d.f32) },
401
+ * });
402
+ *
403
+ * const fooBuffer = ...;
404
+ * const barTexture = ...;
405
+ *
406
+ * const fooBindGroup = root.createBindGroup(fooLayout, {
407
+ * foo: fooBuffer,
408
+ * bar: barTexture,
409
+ * });
410
+ *
411
+ * @param layout Layout describing the bind group to be created.
412
+ * @param entries A record with values being the resources populating the bind group
413
+ * and keys being their associated names, matching the layout keys.
414
+ */
415
+ createBindGroup<Entries extends Record<string, TgpuLayoutEntry | null> = Record<string, TgpuLayoutEntry | null>>(layout: TgpuBindGroupLayout<Entries>, entries: ExtractBindGroupInputFromLayout<Entries>): TgpuBindGroup<Entries>;
416
+ /**
417
+ * Retrieves a read-only list of all enabled features of the GPU device.
418
+ * @returns A set of strings representing the enabled features.
419
+ */
420
+ get enabledFeatures(): ReadonlySet<GPUFeatureName>;
421
+ /**
422
+ * Destroys all underlying resources (i.e. buffers...) created through this root object.
423
+ * If the object is created via `tgpu.init` instead of `tgpu.initFromDevice`,
424
+ * then the inner GPU device is destroyed as well.
425
+ */
426
+ destroy(): void;
427
+ '~unstable': Pick<ExperimentalTgpuRoot, 'createCommandEncoder' | 'createComparisonSampler' | 'createGuardedComputePipeline' | 'createRenderBundleEncoder' | 'createSampler' | 'createTexture' | 'nameRegistrySetting' | 'shaderGeneratorClass' | 'pipe' | 'with'>;
617
428
  }
618
- interface ExperimentalTgpuRoot extends Omit<TgpuRoot, 'with'>, Withable_Deprecated<WithBinding> {
619
- readonly nameRegistrySetting: 'strict' | 'random';
620
- readonly shaderGenerator?: ShaderGenerator | undefined;
621
- /** @deprecated Use `root.createTexture` instead. */
622
- createTexture<TWidth extends number, THeight extends number, TDepth extends number, TSize extends readonly [TWidth] | readonly [TWidth, THeight] | readonly [TWidth, THeight, TDepth], TFormat extends GPUTextureFormat, TMipLevelCount extends number, TSampleCount extends number, TViewFormats extends GPUTextureFormat[], TDimension extends GPUTextureDimension>(props: CreateTextureOptions<TSize, TFormat, TMipLevelCount, TSampleCount, TViewFormats, TDimension>): TgpuTexture<CreateTextureResult<TSize, TFormat, TMipLevelCount, TSampleCount, TViewFormats, TDimension>>;
623
- beginRenderPass(descriptor: TgpuRenderPassDescriptor, callback: (pass: RenderPass) => void): void;
624
- /**
625
- * Creates a {@link GPURenderBundle} by recording draw commands into a
626
- * {@link GPURenderBundleEncoder}. The resulting bundle can be replayed in a
627
- * render pass via {@link RenderPass.executeBundles}.
628
- *
629
- * The caller is responsible for ensuring that the `descriptor` (e.g.
630
- * `colorFormats`, `depthStencilFormat`) is compatible with the render pass
631
- * in which the bundle will be executed.
632
- *
633
- * @param descriptor - Describes the formats the bundle must be compatible with.
634
- * @param callback - A function that records draw commands into the bundle.
635
- */
636
- beginRenderBundleEncoder(descriptor: GPURenderBundleEncoderDescriptor, callback: (pass: RenderBundleEncoderPass) => void): GPURenderBundle;
637
- /** @deprecated Use `root.createSampler` instead. */
638
- createSampler(props: WgslSamplerProps): TgpuFixedSampler;
639
- /** @deprecated Use `root.createComparisonSampler` instead. */
640
- createComparisonSampler(props: WgslComparisonSamplerProps): TgpuFixedComparisonSampler;
641
- /**
642
- * @deprecated Used to cause all commands enqueued by pipelines to be
643
- * submitted to the GPU, but now commands are immediately dispatched,
644
- * which makes this method unnecessary.
645
- */
646
- flush(): void;
647
- /** @deprecated Use `root.createComputePipeline` instead. */
648
- withCompute<ComputeIn extends IORecord<AnyComputeBuiltin>>(entryFn: TgpuComputeFn<ComputeIn>): WithCompute;
649
- /** @deprecated This feature is now stable, use `root.createGuardedComputePipeline`. */
650
- createGuardedComputePipeline<TArgs extends number[]>(callback: (...args: TArgs) => void): TgpuGuardedComputePipeline<TArgs>;
651
- /** @deprecated Use `root.createRenderPipeline` instead. */
652
- withVertex<VertexIn extends TgpuVertexFn.In, VertexOut extends TgpuVertexFn.Out>(entryFn: TgpuVertexFn<VertexIn, VertexOut>, ...args: OptionalArgs<LayoutToAllowedAttribs<OmitBuiltins<VertexIn>>>): WithVertex<VertexOut>;
653
- /** @deprecated This feature is now stable, use `root.pipe`. */
654
- pipe(transform: (cfg: Configurable) => Configurable): WithBinding;
429
+ export interface ExperimentalTgpuRoot extends Omit<TgpuRoot, 'with'>, Withable_Deprecated<WithBinding> {
430
+ readonly nameRegistrySetting: 'strict' | 'random';
431
+ readonly minify: boolean;
432
+ readonly shaderGeneratorClass?: ShaderGeneratorClass | undefined;
433
+ /** @deprecated Use `root.createTexture` instead. */
434
+ createTexture<TWidth extends number, THeight extends number, TDepth extends number, TSize extends readonly [TWidth] | readonly [TWidth, THeight] | readonly [TWidth, THeight, TDepth], TFormat extends GPUTextureFormat, TMipLevelCount extends number, TSampleCount extends number, TViewFormats extends GPUTextureFormat[], TDimension extends GPUTextureDimension>(props: CreateTextureOptions<TSize, TFormat, TMipLevelCount, TSampleCount, TViewFormats, TDimension>): TgpuTexture<CreateTextureResult<TSize, TFormat, TMipLevelCount, TSampleCount, TViewFormats, TDimension>>;
435
+ /**
436
+ * Creates a {@link TgpuCommandEncoder} for batching multiple render/compute
437
+ * passes (and draws within them) into a single submission.
438
+ *
439
+ * @example
440
+ * ```ts
441
+ * const encoder = root['~unstable'].createCommandEncoder();
442
+ * const pass = encoder.beginRenderPass({
443
+ * colorAttachments: [{ view: msaaTexture, resolveTarget: context }],
444
+ * });
445
+ * scenePipeline.with(pass).draw(vertexCount);
446
+ * skyPipeline.with(pass).draw(3);
447
+ * pass.end();
448
+ * encoder.submit();
449
+ * ```
450
+ */
451
+ createCommandEncoder(descriptor?: GPUCommandEncoderDescriptor): TgpuCommandEncoder;
452
+ /**
453
+ * Creates a {@link TgpuRenderBundleEncoder} for recording draw commands into
454
+ * a {@link GPURenderBundle}. Call `finish()` on the encoder to obtain the
455
+ * bundle, replayable in a render pass via `pass.executeBundles`.
456
+ *
457
+ * The caller is responsible for ensuring that the `descriptor` (e.g.
458
+ * `colorFormats`, `depthStencilFormat`) is compatible with the render pass
459
+ * in which the bundle will be executed.
460
+ *
461
+ * @param descriptor - Describes the formats the bundle must be compatible with.
462
+ *
463
+ * @example
464
+ * ```ts
465
+ * const bundleEncoder = root['~unstable'].createRenderBundleEncoder({
466
+ * colorFormats: ['rgba8unorm'],
467
+ * });
468
+ * scenePipeline.with(bundleEncoder).draw(vertexCount);
469
+ * const bundle = bundleEncoder.finish();
470
+ * ```
471
+ */
472
+ createRenderBundleEncoder(descriptor: GPURenderBundleEncoderDescriptor): TgpuRenderBundleEncoder;
473
+ /** @deprecated Use `root.createSampler` instead. */
474
+ createSampler(props: WgslSamplerProps): TgpuFixedSampler;
475
+ /** @deprecated Use `root.createComparisonSampler` instead. */
476
+ createComparisonSampler(props: WgslComparisonSamplerProps): TgpuFixedComparisonSampler;
477
+ /** @deprecated This feature is now stable, use `root.createGuardedComputePipeline`. */
478
+ createGuardedComputePipeline<TArgs extends number[]>(callback: (...args: TArgs) => void): TgpuGuardedComputePipeline<TArgs>;
479
+ /** @deprecated This feature is now stable, use `root.pipe`. */
480
+ pipe(transform: (cfg: Configurable) => Configurable): WithBinding;
655
481
  }
656
- //#endregion
657
- export { Configurable, ExperimentalTgpuRoot, TgpuGuardedComputePipeline, TgpuRoot, ValidateBufferSchema, ValidateStorageSchema, ValidateUniformSchema, WithBinding, WithCompute, WithFragment, WithVertex, Withable };
482
+ export {};