typegpu 0.10.0 → 0.10.2

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 (263) hide show
  1. package/{chunk-BYypO7fO.js → _virtual/_rolldown/runtime.js} +1 -1
  2. package/builtin.d.ts +50 -0
  3. package/builtin.js +37 -0
  4. package/common/fullScreenTriangle.d.ts +26 -0
  5. package/common/fullScreenTriangle.js +36 -0
  6. package/common/index.d.ts +2 -3
  7. package/common/index.js +3 -4
  8. package/core/buffer/buffer.d.ts +74 -0
  9. package/core/buffer/buffer.js +197 -0
  10. package/core/buffer/bufferShorthand.d.ts +48 -0
  11. package/core/buffer/bufferShorthand.js +49 -0
  12. package/core/buffer/bufferUsage.d.ts +45 -0
  13. package/core/buffer/bufferUsage.js +163 -0
  14. package/core/constant/tgpuConstant.d.ts +28 -0
  15. package/core/constant/tgpuConstant.js +67 -0
  16. package/core/declare/tgpuDeclare.d.ts +18 -0
  17. package/core/declare/tgpuDeclare.js +40 -0
  18. package/core/function/autoIO.d.ts +37 -0
  19. package/core/function/autoIO.js +87 -0
  20. package/core/function/comptime.d.ts +39 -0
  21. package/core/function/comptime.js +51 -0
  22. package/core/function/createCallableSchema.js +42 -0
  23. package/core/function/dualImpl.js +54 -0
  24. package/core/function/extractArgs.js +204 -0
  25. package/core/function/fnCore.js +79 -0
  26. package/core/function/fnTypes.d.ts +34 -0
  27. package/core/function/ioSchema.d.ts +10 -0
  28. package/core/function/ioSchema.js +30 -0
  29. package/core/function/shelllessImpl.d.ts +28 -0
  30. package/core/function/shelllessImpl.js +23 -0
  31. package/core/function/templateUtils.js +13 -0
  32. package/core/function/tgpuComputeFn.d.ts +49 -0
  33. package/core/function/tgpuComputeFn.js +62 -0
  34. package/core/function/tgpuFn.d.ts +52 -0
  35. package/core/function/tgpuFn.js +170 -0
  36. package/core/function/tgpuFragmentFn.d.ts +68 -0
  37. package/core/function/tgpuFragmentFn.js +68 -0
  38. package/core/function/tgpuVertexFn.d.ts +55 -0
  39. package/core/function/tgpuVertexFn.js +65 -0
  40. package/core/pipeline/applyPipelineState.js +37 -0
  41. package/core/pipeline/computePipeline.d.ts +58 -0
  42. package/core/pipeline/computePipeline.js +226 -0
  43. package/core/pipeline/connectAttachmentToShader.js +26 -0
  44. package/core/pipeline/connectTargetsToShader.js +29 -0
  45. package/core/pipeline/limitsOverflow.js +13 -0
  46. package/core/pipeline/renderPipeline.d.ts +266 -0
  47. package/core/pipeline/renderPipeline.js +471 -0
  48. package/core/pipeline/timeable.d.ts +23 -0
  49. package/core/pipeline/timeable.js +61 -0
  50. package/core/pipeline/typeGuards.js +29 -0
  51. package/core/querySet/querySet.d.ts +22 -0
  52. package/core/querySet/querySet.js +103 -0
  53. package/core/rawCodeSnippet/tgpuRawCodeSnippet.d.ts +59 -0
  54. package/core/rawCodeSnippet/tgpuRawCodeSnippet.js +96 -0
  55. package/core/resolve/externals.d.ts +10 -0
  56. package/core/resolve/externals.js +58 -0
  57. package/core/resolve/namespace.d.ts +38 -0
  58. package/core/resolve/namespace.js +41 -0
  59. package/core/resolve/resolveData.js +146 -0
  60. package/core/resolve/stitch.js +25 -0
  61. package/core/resolve/tgpuResolve.d.ts +151 -0
  62. package/core/resolve/tgpuResolve.js +68 -0
  63. package/core/root/configurableImpl.js +18 -0
  64. package/core/root/init.d.ts +69 -0
  65. package/core/root/init.js +457 -0
  66. package/core/root/rootTypes.d.ts +622 -0
  67. package/core/sampler/sampler.d.ts +35 -0
  68. package/core/sampler/sampler.js +116 -0
  69. package/core/simulate/tgpuSimulate.d.ts +36 -0
  70. package/core/simulate/tgpuSimulate.js +76 -0
  71. package/core/slot/accessor.d.ts +13 -0
  72. package/core/slot/accessor.js +97 -0
  73. package/core/slot/internalSlots.js +7 -0
  74. package/core/slot/lazy.d.ts +6 -0
  75. package/core/slot/lazy.js +42 -0
  76. package/core/slot/slot.d.ts +6 -0
  77. package/core/slot/slot.js +40 -0
  78. package/core/slot/slotTypes.d.ts +92 -0
  79. package/core/slot/slotTypes.js +21 -0
  80. package/core/texture/externalTexture.d.ts +12 -0
  81. package/core/texture/externalTexture.js +48 -0
  82. package/core/texture/texture.d.ts +118 -0
  83. package/core/texture/texture.js +312 -0
  84. package/core/texture/textureFormats.d.ts +29 -0
  85. package/core/texture/textureFormats.js +99 -0
  86. package/core/texture/textureProps.d.ts +11 -0
  87. package/core/texture/textureUtils.js +224 -0
  88. package/core/texture/usageExtension.d.ts +21 -0
  89. package/core/texture/usageExtension.js +21 -0
  90. package/core/unroll/tgpuUnroll.d.ts +13 -0
  91. package/core/unroll/tgpuUnroll.js +36 -0
  92. package/core/valueProxyUtils.js +44 -0
  93. package/core/variable/tgpuVariable.d.ts +38 -0
  94. package/core/variable/tgpuVariable.js +101 -0
  95. package/core/vertexLayout/connectAttributesToShader.js +59 -0
  96. package/core/vertexLayout/vertexAttribute.d.ts +29 -0
  97. package/core/vertexLayout/vertexLayout.d.ts +19 -0
  98. package/core/vertexLayout/vertexLayout.js +103 -0
  99. package/data/alignIO.js +15 -0
  100. package/data/alignmentOf.d.ts +10 -0
  101. package/data/alignmentOf.js +88 -0
  102. package/data/array.d.ts +28 -0
  103. package/data/array.js +48 -0
  104. package/data/atomic.d.ts +15 -0
  105. package/data/atomic.js +25 -0
  106. package/data/attributes.d.ts +121 -0
  107. package/data/attributes.js +145 -0
  108. package/data/autoStruct.d.ts +3 -0
  109. package/data/autoStruct.js +83 -0
  110. package/data/compiledIO.js +231 -0
  111. package/data/dataIO.js +549 -0
  112. package/data/dataTypes.d.ts +115 -0
  113. package/data/dataTypes.js +97 -0
  114. package/data/deepEqual.d.ts +25 -0
  115. package/data/deepEqual.js +58 -0
  116. package/data/disarray.d.ts +34 -0
  117. package/data/disarray.js +52 -0
  118. package/data/getLongestContiguousPrefix.d.ts +10 -0
  119. package/data/getLongestContiguousPrefix.js +15 -0
  120. package/data/index.d.ts +26 -4
  121. package/data/index.js +27 -7
  122. package/data/instanceToSchema.d.ts +33 -0
  123. package/data/isContiguous.d.ts +10 -0
  124. package/data/isContiguous.js +15 -0
  125. package/data/matrix.d.ts +126 -0
  126. package/data/matrix.js +517 -0
  127. package/data/numberOps.js +24 -0
  128. package/data/numeric.d.ts +81 -0
  129. package/data/numeric.js +234 -0
  130. package/data/offsetUtils.d.ts +33 -0
  131. package/data/offsetUtils.js +167 -0
  132. package/data/offsets.js +36 -0
  133. package/data/partialIO.js +68 -0
  134. package/data/ptr.d.ts +12 -0
  135. package/data/ptr.js +46 -0
  136. package/data/ref.d.ts +37 -0
  137. package/data/ref.js +96 -0
  138. package/data/sampler.d.ts +107 -0
  139. package/data/sampler.js +26 -0
  140. package/data/schemaCallWrapper.js +32 -0
  141. package/data/schemaMemoryLayout.js +200 -0
  142. package/data/sizeOf.d.ts +10 -0
  143. package/data/sizeOf.js +15 -0
  144. package/data/snippet.d.ts +26 -0
  145. package/data/snippet.js +61 -0
  146. package/data/struct.d.ts +17 -0
  147. package/data/struct.js +46 -0
  148. package/data/texture.d.ts +292 -0
  149. package/{texture-Dg5ybJro.js → data/texture.js} +6 -3
  150. package/data/unstruct.d.ts +24 -0
  151. package/data/unstruct.js +43 -0
  152. package/data/vector.d.ts +191 -0
  153. package/data/vector.js +247 -0
  154. package/data/vectorImpl.js +516 -0
  155. package/data/vectorOps.js +664 -0
  156. package/data/vertexFormatData.d.ts +190 -0
  157. package/data/vertexFormatData.js +110 -0
  158. package/data/wgslTypes.d.ts +896 -0
  159. package/data/wgslTypes.js +215 -0
  160. package/errors.d.ts +44 -0
  161. package/errors.js +128 -0
  162. package/execMode.js +51 -0
  163. package/extension.d.ts +11 -0
  164. package/extension.js +18 -0
  165. package/getGPUValue.js +9 -0
  166. package/index.d.ts +40 -243
  167. package/index.js +19 -6318
  168. package/indexNamedExports.d.ts +38 -0
  169. package/mathUtils.js +13 -0
  170. package/memo.js +22 -0
  171. package/nameRegistry.d.ts +30 -0
  172. package/nameRegistry.js +449 -0
  173. package/package.js +5 -0
  174. package/package.json +23 -23
  175. package/resolutionCtx.d.ts +29 -0
  176. package/resolutionCtx.js +546 -0
  177. package/shared/env.js +13 -0
  178. package/shared/generators.js +14 -0
  179. package/shared/meta.d.ts +39 -0
  180. package/shared/meta.js +63 -0
  181. package/shared/repr.d.ts +108 -0
  182. package/shared/stringify.js +22 -0
  183. package/shared/symbols.d.ts +61 -0
  184. package/shared/symbols.js +71 -0
  185. package/shared/utilityTypes.d.ts +29 -0
  186. package/shared/utilityTypes.js +7 -0
  187. package/shared/vertexFormat.d.ts +70 -0
  188. package/shared/vertexFormat.js +64 -0
  189. package/std/array.d.ts +7 -0
  190. package/std/array.js +27 -0
  191. package/std/atomic.d.ts +19 -0
  192. package/std/atomic.js +113 -0
  193. package/std/bitcast.d.ts +10 -0
  194. package/std/bitcast.js +43 -0
  195. package/std/boolean.d.ts +127 -0
  196. package/std/boolean.js +274 -0
  197. package/std/derivative.d.ts +16 -0
  198. package/std/derivative.js +89 -0
  199. package/std/discard.d.ts +6 -0
  200. package/std/discard.js +16 -0
  201. package/std/extensions.d.ts +8 -0
  202. package/std/extensions.js +14 -0
  203. package/std/index.d.ts +15 -3
  204. package/std/index.js +16 -5
  205. package/std/matrix.d.ts +41 -0
  206. package/std/matrix.js +87 -0
  207. package/std/numeric.d.ts +254 -0
  208. package/std/numeric.js +847 -0
  209. package/std/operators.d.ts +48 -0
  210. package/std/operators.js +153 -0
  211. package/std/packing.d.ts +26 -0
  212. package/std/packing.js +86 -0
  213. package/std/subgroup.d.ts +47 -0
  214. package/std/subgroup.js +220 -0
  215. package/std/texture.d.ts +108 -0
  216. package/std/texture.js +197 -0
  217. package/tgpu.js +44 -0
  218. package/tgpuBindGroupLayout.d.ts +161 -0
  219. package/tgpuBindGroupLayout.js +271 -0
  220. package/tgpuUnstable.d.ts +48 -0
  221. package/tgpuUnstable.js +66 -0
  222. package/tgsl/accessIndex.js +45 -0
  223. package/tgsl/accessProp.js +113 -0
  224. package/tgsl/consoleLog/deserializers.js +117 -0
  225. package/tgsl/consoleLog/logGenerator.js +86 -0
  226. package/tgsl/consoleLog/serializers.js +225 -0
  227. package/tgsl/consoleLog/types.d.ts +54 -0
  228. package/tgsl/consoleLog/types.js +12 -0
  229. package/tgsl/conversion.js +200 -0
  230. package/tgsl/forOfUtils.js +45 -0
  231. package/tgsl/generationHelpers.d.ts +37 -0
  232. package/tgsl/generationHelpers.js +67 -0
  233. package/tgsl/math.js +45 -0
  234. package/tgsl/shaderGenerator.d.ts +18 -0
  235. package/tgsl/shellless.d.ts +11 -0
  236. package/tgsl/shellless.js +53 -0
  237. package/tgsl/wgslGenerator.js +585 -0
  238. package/types.d.ts +255 -0
  239. package/types.js +43 -0
  240. package/unwrapper.d.ts +27 -0
  241. package/wgslExtensions.d.ts +5 -0
  242. package/wgslExtensions.js +18 -0
  243. package/builtin-ClEnM-Ye.js +0 -818
  244. package/builtin-ClEnM-Ye.js.map +0 -1
  245. package/common/index.d.ts.map +0 -1
  246. package/common/index.js.map +0 -1
  247. package/data/index.d.ts.map +0 -1
  248. package/data/index.js.map +0 -1
  249. package/deepEqual-yZXvaV2C.js +0 -413
  250. package/deepEqual-yZXvaV2C.js.map +0 -1
  251. package/extensions-0SFbU9FH.js +0 -2032
  252. package/extensions-0SFbU9FH.js.map +0 -1
  253. package/fullScreenTriangle-MdLGaAMR.js +0 -543
  254. package/fullScreenTriangle-MdLGaAMR.js.map +0 -1
  255. package/index.d.ts.map +0 -1
  256. package/index.js.map +0 -1
  257. package/indexNamedExports-Cdy7USiY.d.ts +0 -5696
  258. package/indexNamedExports-Cdy7USiY.d.ts.map +0 -1
  259. package/operators-HTxa_0k9.js +0 -4156
  260. package/operators-HTxa_0k9.js.map +0 -1
  261. package/std/index.d.ts.map +0 -1
  262. package/std/index.js.map +0 -1
  263. package/texture-Dg5ybJro.js.map +0 -1
@@ -0,0 +1,151 @@
1
+ import { ShaderGenerator } from "../../tgsl/shaderGenerator.js";
2
+ import { Configurable } from "../root/rootTypes.js";
3
+ import { WgslExtension } from "../../wgslExtensions.js";
4
+ import { ResolvableObject, Wgsl } from "../../types.js";
5
+ import { Namespace } from "./namespace.js";
6
+ import { ResolutionResult } from "../../resolutionCtx.js";
7
+
8
+ //#region src/core/resolve/tgpuResolve.d.ts
9
+ interface TgpuResolveOptions {
10
+ /**
11
+ * The naming strategy used for generating identifiers for resolved externals and their dependencies.
12
+ *
13
+ * ## Namespaces
14
+ * Each call to `tgpu.resolve` uses it's own namespace by default, but a
15
+ * custom namespace can be created with `tgpu.namespace` and passed in.
16
+ *
17
+ * This allows tracking the behavior of the resolution process, as well as
18
+ * sharing state between calls to `tgpu.resolve`.
19
+ *
20
+ * @default 'random'
21
+ */
22
+ names?: 'strict' | 'random' | Namespace | undefined;
23
+ /**
24
+ * A function to configure the resolution context.
25
+ */
26
+ config?: ((cfg: Configurable) => Configurable) | undefined;
27
+ /**
28
+ * List of WGSL shader extensions to enable.
29
+ */
30
+ enableExtensions?: WgslExtension[] | undefined;
31
+ /**
32
+ * A custom shader code generator, used when resolving TypeGPU functions.
33
+ * If not provided, the default WGSL generator will be used.
34
+ */
35
+ shaderGenerator?: ShaderGenerator | undefined;
36
+ }
37
+ interface TgpuExtendedResolveOptions extends TgpuResolveOptions {
38
+ /**
39
+ * Map of external names to their resolvable values.
40
+ */
41
+ externals: Record<string, Wgsl | object>;
42
+ /**
43
+ * The code template to use for the resolution. All external names will be replaced with their resolved values.
44
+ * @default ''
45
+ */
46
+ template?: string | undefined;
47
+ }
48
+ /**
49
+ * Resolves a template with external values. Each external that is used will get resolved to a code string and replaced in the template.
50
+ * Any dependencies of the externals will also be resolved and included in the output.
51
+ * @param options - The options for the resolution.
52
+ *
53
+ * @returns {ResolutionResult}
54
+ *
55
+ * @example
56
+ * ```ts
57
+ * const Gradient = d.struct({ from: d.vec3f, to: d.vec3f });
58
+ *
59
+ * const { code, usedBindGroupLayouts, catchall } = tgpu.resolveWithContext({
60
+ * template: `
61
+ * fn getGradientAngle(gradient: Gradient) -> f32 {
62
+ * return atan(gradient.to.y - gradient.from.y, gradient.to.x - gradient.from.x);
63
+ * }
64
+ * `,
65
+ * externals: {
66
+ * Gradient,
67
+ * },
68
+ * });
69
+ *
70
+ * console.log(code);
71
+ * // struct Gradient_0 {
72
+ * // from: vec3f,
73
+ * // to: vec3f,
74
+ * // }
75
+ * // fn getGradientAngle(gradient: Gradient_0) -> f32 {
76
+ * // return atan(gradient.to.y - gradient.from.y, gradient.to.x - gradient.from.x);
77
+ * // }
78
+ * ```
79
+ */
80
+ declare function resolveWithContext(options: TgpuExtendedResolveOptions): ResolutionResult;
81
+ /**
82
+ * Resolves given TypeGPU resources.
83
+ * Any dependencies of the externals will also be resolved and included in the output.
84
+ * @param items - An array of items to resolve.
85
+ * @param options - The options for the resolution.
86
+ *
87
+ * @returns {ResolutionResult}
88
+ *
89
+ * @example
90
+ * ```ts
91
+ * const Gradient = d.struct({
92
+ * from: d.vec3f,
93
+ * to: d.vec3f,
94
+ * });
95
+ *
96
+ * const { code, usedBindGroupLayouts, catchall } =
97
+ * tgpu.resolveWithContext([Gradient]);
98
+ *
99
+ * console.log(code);
100
+ * // struct Gradient_0 {
101
+ * // from: vec3f,
102
+ * // to: vec3f,
103
+ * // }
104
+ * ```
105
+ */
106
+ declare function resolveWithContext(items: ResolvableObject[], options?: TgpuResolveOptions): ResolutionResult;
107
+ /**
108
+ * A shorthand for calling `tgpu.resolveWithContext(...).code`.
109
+ *
110
+ * @example
111
+ * ```ts
112
+ * const Gradient = d.struct({ from: d.vec3f, to: d.vec3f });
113
+ *
114
+ * const resolved = tgpu.resolve([Gradient]);
115
+ *
116
+ * console.log(resolved);
117
+ * // struct Gradient_0 {
118
+ * // from: vec3f,
119
+ * // to: vec3f,
120
+ * // }
121
+ * ```
122
+ *
123
+ * @example
124
+ * ```ts
125
+ * const Gradient = d.struct({ from: d.vec3f, to: d.vec3f });
126
+ *
127
+ * const code = tgpu.resolve({
128
+ * template: `
129
+ * fn getGradientAngle(gradient: Gradient) -> f32 {
130
+ * return atan(gradient.to.y - gradient.from.y, gradient.to.x - gradient.from.x);
131
+ * }
132
+ * `,
133
+ * externals: {
134
+ * Gradient,
135
+ * },
136
+ * });
137
+ *
138
+ * console.log(code);
139
+ * // struct Gradient_0 {
140
+ * // from: vec3f,
141
+ * // to: vec3f,
142
+ * // }
143
+ * // fn getGradientAngle(gradient: Gradient_0) -> f32 {
144
+ * // return atan(gradient.to.y - gradient.from.y, gradient.to.x - gradient.from.x);
145
+ * // }
146
+ * ```
147
+ */
148
+ declare function resolve(options: TgpuExtendedResolveOptions): string;
149
+ declare function resolve(items: ResolvableObject[], options?: TgpuResolveOptions): string;
150
+ //#endregion
151
+ export { resolve, resolveWithContext };
@@ -0,0 +1,68 @@
1
+ import { $internal, $resolve } from "../../shared/symbols.js";
2
+ import { Void } from "../../data/wgslTypes.js";
3
+ import { snip } from "../../data/snippet.js";
4
+ import { applyExternals, replaceExternalsInWgsl } from "./externals.js";
5
+ import { namespace } from "./namespace.js";
6
+ import { isBindGroupLayout } from "../../tgpuBindGroupLayout.js";
7
+ import { resolve as resolve$1 } from "../../resolutionCtx.js";
8
+ import { isPipeline } from "../pipeline/typeGuards.js";
9
+
10
+ //#region src/core/resolve/tgpuResolve.ts
11
+ function resolveWithContext(arg0, options) {
12
+ if (Array.isArray(arg0)) return resolveFromArray(arg0, options);
13
+ return resolveFromTemplate(arg0);
14
+ }
15
+ function resolve(arg, options) {
16
+ if (Array.isArray(arg)) return resolveWithContext(arg, options).code;
17
+ return resolveWithContext(arg).code;
18
+ }
19
+ function resolveFromTemplate(options) {
20
+ const { template, externals, shaderGenerator, names = "strict", config, enableExtensions } = options;
21
+ if (!template) console.warn("Calling resolve with an empty template is deprecated and will soon return an empty string. Consider using the 'tgpu.resolve(resolvableArray, options)' API instead.");
22
+ const dependencies = {};
23
+ applyExternals(dependencies, externals ?? {});
24
+ return resolve$1({
25
+ [$internal]: true,
26
+ [$resolve](ctx) {
27
+ return snip(replaceExternalsInWgsl(ctx, dependencies, template ?? ""), Void, "runtime");
28
+ },
29
+ toString: () => "<root>"
30
+ }, {
31
+ namespace: typeof names === "string" ? namespace({ names }) : names,
32
+ enableExtensions,
33
+ shaderGenerator,
34
+ config,
35
+ root: tryFindRoot(Object.values(externals))
36
+ });
37
+ }
38
+ function resolveFromArray(items, options) {
39
+ const { shaderGenerator, names = "strict", config, enableExtensions } = options ?? {};
40
+ return resolve$1({
41
+ [$internal]: true,
42
+ [$resolve](ctx) {
43
+ for (const item of items) if (isBindGroupLayout(item)) for (const binding of Object.values(item[$internal].bound)) ctx.resolve(binding);
44
+ else ctx.resolve(item);
45
+ return snip("", Void, "runtime");
46
+ },
47
+ toString: () => "<root>"
48
+ }, {
49
+ namespace: typeof names === "string" ? namespace({ names }) : names,
50
+ enableExtensions,
51
+ shaderGenerator,
52
+ config,
53
+ root: tryFindRoot(items)
54
+ });
55
+ }
56
+ /**
57
+ * Attempts to locate a pipeline in a list of items and returns the root.
58
+ * Does not check recursively.
59
+ * Throws an error if multiple pipelines are found.
60
+ */
61
+ function tryFindRoot(items) {
62
+ const pipelines = items.filter(isPipeline);
63
+ if (pipelines.length > 1) throw new Error(`Found ${pipelines.length} pipelines but can only resolve one at a time.`);
64
+ return pipelines[0]?.[$internal].root;
65
+ }
66
+
67
+ //#endregion
68
+ export { resolve, resolveWithContext };
@@ -0,0 +1,18 @@
1
+ import { isAccessor, isMutableAccessor } from "../slot/slotTypes.js";
2
+
3
+ //#region src/core/root/configurableImpl.ts
4
+ var ConfigurableImpl = class ConfigurableImpl {
5
+ constructor(bindings) {
6
+ this.bindings = bindings;
7
+ }
8
+ with(slot, value) {
9
+ return new ConfigurableImpl([...this.bindings, [isAccessor(slot) || isMutableAccessor(slot) ? slot.slot : slot, value]]);
10
+ }
11
+ pipe(transform) {
12
+ const newCfg = transform(this);
13
+ return new ConfigurableImpl([...this.bindings, ...newCfg.bindings]);
14
+ }
15
+ };
16
+
17
+ //#endregion
18
+ export { ConfigurableImpl };
@@ -0,0 +1,69 @@
1
+ import "../buffer/bufferShorthand.js";
2
+ import { LogGeneratorOptions } from "../../tgsl/consoleLog/types.js";
3
+ import "../pipeline/computePipeline.js";
4
+ import "../../tgpuBindGroupLayout.js";
5
+ import { ShaderGenerator } from "../../tgsl/shaderGenerator.js";
6
+ import { TgpuRoot } from "./rootTypes.js";
7
+ import "../../data/wgslTypes.js";
8
+
9
+ //#region src/core/root/init.d.ts
10
+ /**
11
+ * Options passed into {@link init}.
12
+ */
13
+ type InitOptions = {
14
+ adapter?: GPURequestAdapterOptions | undefined;
15
+ device?: (GPUDeviceDescriptor & {
16
+ optionalFeatures?: Iterable<GPUFeatureName>;
17
+ }) | undefined; /** @default 'random' */
18
+ unstable_names?: 'random' | 'strict' | undefined;
19
+ /**
20
+ * A custom shader code generator, used when resolving TypeGPU functions.
21
+ * If not provided, the default WGSL generator will be used.
22
+ */
23
+ shaderGenerator?: ShaderGenerator | undefined;
24
+ unstable_logOptions?: LogGeneratorOptions;
25
+ };
26
+ /**
27
+ * Options passed into {@link initFromDevice}.
28
+ */
29
+ type InitFromDeviceOptions = {
30
+ device: GPUDevice; /** @default 'random' */
31
+ unstable_names?: 'random' | 'strict' | undefined;
32
+ /**
33
+ * A custom shader code generator, used when resolving TypeGPU functions.
34
+ * If not provided, the default WGSL generator will be used.
35
+ */
36
+ shaderGenerator?: ShaderGenerator | undefined;
37
+ unstable_logOptions?: LogGeneratorOptions;
38
+ };
39
+ /**
40
+ * Requests a new GPU device and creates a root around it.
41
+ * If a specific device should be used instead, use @see initFromDevice.
42
+ *
43
+ * @example
44
+ * When given no options, the function will ask the browser for a suitable GPU device.
45
+ * ```ts
46
+ * const root = await tgpu.init();
47
+ * ```
48
+ *
49
+ * @example
50
+ * If there are specific options that should be used when requesting a device, you can pass those in.
51
+ * ```ts
52
+ * const adapterOptions: GPURequestAdapterOptions = ...;
53
+ * const deviceDescriptor: GPUDeviceDescriptor = ...;
54
+ * const root = await tgpu.init({ adapter: adapterOptions, device: deviceDescriptor });
55
+ * ```
56
+ */
57
+ declare function init(options?: InitOptions): Promise<TgpuRoot>;
58
+ /**
59
+ * Creates a root from the given device, instead of requesting it like @see init.
60
+ *
61
+ * @example
62
+ * ```ts
63
+ * const device: GPUDevice = ...;
64
+ * const root = tgpu.initFromDevice({ device });
65
+ * ```
66
+ */
67
+ declare function initFromDevice(options: InitFromDeviceOptions): TgpuRoot;
68
+ //#endregion
69
+ export { InitFromDeviceOptions, InitOptions, init, initFromDevice };