typegpu 0.10.1 → 0.11.0-rc.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (273) hide show
  1. package/_virtual/_rolldown/runtime.js +13 -0
  2. package/builtin.d.ts +50 -0
  3. package/builtin.js +35 -0
  4. package/common/fullScreenTriangle.d.ts +22 -0
  5. package/common/fullScreenTriangle.js +34 -0
  6. package/common/index.d.ts +4 -4
  7. package/common/index.js +8 -7
  8. package/common/writeSoA.d.ts +16 -0
  9. package/common/writeSoA.js +90 -0
  10. package/core/buffer/buffer.d.ts +79 -0
  11. package/core/buffer/buffer.js +246 -0
  12. package/core/buffer/bufferShorthand.d.ts +48 -0
  13. package/core/buffer/bufferShorthand.js +53 -0
  14. package/core/buffer/bufferUsage.d.ts +43 -0
  15. package/core/buffer/bufferUsage.js +165 -0
  16. package/core/constant/tgpuConstant.d.ts +29 -0
  17. package/core/constant/tgpuConstant.js +68 -0
  18. package/core/declare/tgpuDeclare.d.ts +18 -0
  19. package/core/declare/tgpuDeclare.js +39 -0
  20. package/core/function/autoIO.d.ts +38 -0
  21. package/core/function/autoIO.js +85 -0
  22. package/core/function/comptime.d.ts +39 -0
  23. package/core/function/comptime.js +49 -0
  24. package/core/function/createCallableSchema.js +40 -0
  25. package/core/function/dualImpl.js +52 -0
  26. package/core/function/entryInputRouter.js +39 -0
  27. package/core/function/extractArgs.js +204 -0
  28. package/core/function/fnCore.js +90 -0
  29. package/core/function/fnTypes.d.ts +40 -0
  30. package/core/function/ioSchema.d.ts +10 -0
  31. package/core/function/ioSchema.js +51 -0
  32. package/core/function/shelllessImpl.d.ts +28 -0
  33. package/core/function/shelllessImpl.js +21 -0
  34. package/core/function/templateUtils.js +12 -0
  35. package/core/function/tgpuComputeFn.d.ts +48 -0
  36. package/core/function/tgpuComputeFn.js +55 -0
  37. package/core/function/tgpuFn.d.ts +52 -0
  38. package/core/function/tgpuFn.js +168 -0
  39. package/core/function/tgpuFragmentFn.d.ts +72 -0
  40. package/core/function/tgpuFragmentFn.js +63 -0
  41. package/core/function/tgpuVertexFn.d.ts +59 -0
  42. package/core/function/tgpuVertexFn.js +59 -0
  43. package/core/pipeline/applyPipelineState.js +35 -0
  44. package/core/pipeline/computePipeline.d.ts +54 -0
  45. package/core/pipeline/computePipeline.js +227 -0
  46. package/core/pipeline/connectAttachmentToShader.js +24 -0
  47. package/core/pipeline/connectTargetsToShader.js +27 -0
  48. package/core/pipeline/limitsOverflow.js +12 -0
  49. package/core/pipeline/pipelineUtils.js +29 -0
  50. package/core/pipeline/renderPipeline.d.ts +284 -0
  51. package/core/pipeline/renderPipeline.js +489 -0
  52. package/core/pipeline/timeable.d.ts +20 -0
  53. package/core/pipeline/timeable.js +55 -0
  54. package/core/pipeline/typeGuards.js +27 -0
  55. package/core/querySet/querySet.d.ts +20 -0
  56. package/core/querySet/querySet.js +104 -0
  57. package/core/rawCodeSnippet/tgpuRawCodeSnippet.d.ts +59 -0
  58. package/core/rawCodeSnippet/tgpuRawCodeSnippet.js +94 -0
  59. package/core/resolve/externals.d.ts +8 -0
  60. package/core/resolve/externals.js +56 -0
  61. package/core/resolve/namespace.d.ts +38 -0
  62. package/core/resolve/namespace.js +39 -0
  63. package/core/resolve/resolveData.js +144 -0
  64. package/core/resolve/stitch.js +23 -0
  65. package/core/resolve/tgpuResolve.d.ts +153 -0
  66. package/core/resolve/tgpuResolve.js +66 -0
  67. package/core/root/configurableImpl.js +17 -0
  68. package/core/root/init.d.ts +64 -0
  69. package/core/root/init.js +464 -0
  70. package/core/root/rootTypes.d.ts +642 -0
  71. package/core/sampler/sampler.d.ts +31 -0
  72. package/core/sampler/sampler.js +116 -0
  73. package/core/simulate/tgpuSimulate.d.ts +36 -0
  74. package/core/simulate/tgpuSimulate.js +74 -0
  75. package/core/slot/accessor.d.ts +9 -0
  76. package/core/slot/accessor.js +95 -0
  77. package/core/slot/internalSlots.js +5 -0
  78. package/core/slot/lazy.d.ts +6 -0
  79. package/core/slot/lazy.js +40 -0
  80. package/core/slot/slot.d.ts +6 -0
  81. package/core/slot/slot.js +39 -0
  82. package/core/slot/slotTypes.d.ts +92 -0
  83. package/core/slot/slotTypes.js +19 -0
  84. package/core/texture/externalTexture.d.ts +6 -0
  85. package/core/texture/externalTexture.js +47 -0
  86. package/core/texture/texture.d.ts +114 -0
  87. package/core/texture/texture.js +314 -0
  88. package/core/texture/textureFormats.d.ts +29 -0
  89. package/core/texture/textureFormats.js +97 -0
  90. package/core/texture/textureProps.d.ts +11 -0
  91. package/core/texture/textureUtils.js +222 -0
  92. package/core/texture/usageExtension.d.ts +21 -0
  93. package/core/texture/usageExtension.js +19 -0
  94. package/core/unroll/tgpuUnroll.d.ts +68 -0
  95. package/core/unroll/tgpuUnroll.js +94 -0
  96. package/core/valueProxyUtils.js +42 -0
  97. package/core/variable/tgpuVariable.d.ts +38 -0
  98. package/core/variable/tgpuVariable.js +99 -0
  99. package/core/vertexLayout/connectAttributesToShader.js +57 -0
  100. package/core/vertexLayout/vertexAttribute.d.ts +29 -0
  101. package/core/vertexLayout/vertexLayout.d.ts +19 -0
  102. package/core/vertexLayout/vertexLayout.js +103 -0
  103. package/data/alignIO.js +14 -0
  104. package/data/alignmentOf.d.ts +9 -0
  105. package/data/alignmentOf.js +86 -0
  106. package/data/array.d.ts +26 -0
  107. package/data/array.js +46 -0
  108. package/data/atomic.d.ts +15 -0
  109. package/data/atomic.js +24 -0
  110. package/data/attributes.d.ts +121 -0
  111. package/data/attributes.js +145 -0
  112. package/data/autoStruct.d.ts +1 -0
  113. package/data/autoStruct.js +81 -0
  114. package/data/compiledIO.js +228 -0
  115. package/data/dataIO.js +556 -0
  116. package/data/dataTypes.d.ts +115 -0
  117. package/data/dataTypes.js +100 -0
  118. package/data/deepEqual.d.ts +25 -0
  119. package/data/deepEqual.js +56 -0
  120. package/data/disarray.d.ts +32 -0
  121. package/data/disarray.js +50 -0
  122. package/data/getLongestContiguousPrefix.d.ts +9 -0
  123. package/data/getLongestContiguousPrefix.js +13 -0
  124. package/data/index.d.ts +26 -4
  125. package/data/index.js +36 -9
  126. package/data/instanceToSchema.d.ts +33 -0
  127. package/data/isContiguous.d.ts +9 -0
  128. package/data/isContiguous.js +13 -0
  129. package/data/matrix.d.ts +124 -0
  130. package/data/matrix.js +531 -0
  131. package/data/numberOps.js +23 -0
  132. package/data/numeric.d.ts +81 -0
  133. package/data/numeric.js +221 -0
  134. package/data/offsetUtils.d.ts +33 -0
  135. package/data/offsetUtils.js +165 -0
  136. package/data/offsets.js +34 -0
  137. package/data/partialIO.js +113 -0
  138. package/data/ptr.d.ts +11 -0
  139. package/data/ptr.js +44 -0
  140. package/data/ref.d.ts +34 -0
  141. package/data/ref.js +94 -0
  142. package/data/sampler.d.ts +107 -0
  143. package/data/sampler.js +24 -0
  144. package/data/schemaCallWrapper.js +30 -0
  145. package/data/schemaMemoryLayout.js +198 -0
  146. package/data/sizeOf.d.ts +9 -0
  147. package/data/sizeOf.js +13 -0
  148. package/data/snippet.d.ts +26 -0
  149. package/data/snippet.js +70 -0
  150. package/data/struct.d.ts +17 -0
  151. package/data/struct.js +44 -0
  152. package/data/texture.d.ts +292 -0
  153. package/{texture-BagDrrks.js → data/texture.js} +6 -5
  154. package/data/unstruct.d.ts +24 -0
  155. package/data/unstruct.js +41 -0
  156. package/data/vector.d.ts +191 -0
  157. package/data/vector.js +239 -0
  158. package/data/vectorImpl.js +515 -0
  159. package/data/vectorOps.js +681 -0
  160. package/data/vertexFormatData.d.ts +190 -0
  161. package/data/vertexFormatData.js +109 -0
  162. package/data/wgslTypes.d.ts +924 -0
  163. package/data/wgslTypes.js +222 -0
  164. package/errors.d.ts +44 -0
  165. package/errors.js +131 -0
  166. package/execMode.js +49 -0
  167. package/extension.d.ts +11 -0
  168. package/extension.js +16 -0
  169. package/getGPUValue.js +7 -0
  170. package/index.d.ts +42 -243
  171. package/index.js +21 -6320
  172. package/indexNamedExports.d.ts +40 -0
  173. package/mathUtils.js +12 -0
  174. package/memo.js +22 -0
  175. package/nameRegistry.d.ts +30 -0
  176. package/nameRegistry.js +447 -0
  177. package/package.js +4 -0
  178. package/package.json +26 -26
  179. package/resolutionCtx.d.ts +19 -0
  180. package/resolutionCtx.js +612 -0
  181. package/shared/env.js +12 -0
  182. package/shared/generators.js +13 -0
  183. package/shared/meta.d.ts +39 -0
  184. package/shared/meta.js +61 -0
  185. package/shared/repr.d.ts +138 -0
  186. package/shared/stringify.js +20 -0
  187. package/shared/symbols.d.ts +70 -0
  188. package/shared/symbols.js +48 -0
  189. package/shared/utilityTypes.d.ts +33 -0
  190. package/shared/utilityTypes.js +6 -0
  191. package/shared/vertexFormat.d.ts +70 -0
  192. package/shared/vertexFormat.js +63 -0
  193. package/std/array.d.ts +7 -0
  194. package/std/array.js +25 -0
  195. package/std/atomic.d.ts +19 -0
  196. package/std/atomic.js +111 -0
  197. package/std/bitcast.d.ts +10 -0
  198. package/std/bitcast.js +41 -0
  199. package/std/boolean.d.ts +141 -0
  200. package/std/boolean.js +299 -0
  201. package/std/derivative.d.ts +16 -0
  202. package/std/derivative.js +87 -0
  203. package/std/discard.d.ts +6 -0
  204. package/std/discard.js +14 -0
  205. package/std/extensions.d.ts +6 -0
  206. package/std/extensions.js +12 -0
  207. package/std/index.d.ts +17 -4
  208. package/std/index.js +21 -7
  209. package/std/matrix.d.ts +41 -0
  210. package/std/matrix.js +85 -0
  211. package/std/numeric.d.ts +200 -0
  212. package/std/numeric.js +845 -0
  213. package/std/operators.d.ts +56 -0
  214. package/std/operators.js +227 -0
  215. package/std/packing.d.ts +26 -0
  216. package/std/packing.js +84 -0
  217. package/std/range.d.ts +24 -0
  218. package/std/range.js +38 -0
  219. package/std/subgroup.d.ts +47 -0
  220. package/std/subgroup.js +218 -0
  221. package/std/texture.d.ts +117 -0
  222. package/std/texture.js +207 -0
  223. package/tgpu.js +42 -0
  224. package/tgpuBindGroupLayout.d.ts +161 -0
  225. package/tgpuBindGroupLayout.js +272 -0
  226. package/tgpuUnstable.d.ts +48 -0
  227. package/tgpuUnstable.js +64 -0
  228. package/tgsl/accessIndex.js +43 -0
  229. package/tgsl/accessProp.js +115 -0
  230. package/tgsl/consoleLog/deserializers.js +115 -0
  231. package/tgsl/consoleLog/logGenerator.js +84 -0
  232. package/tgsl/consoleLog/serializers.js +223 -0
  233. package/tgsl/consoleLog/types.d.ts +52 -0
  234. package/tgsl/consoleLog/types.js +11 -0
  235. package/tgsl/conversion.js +198 -0
  236. package/tgsl/forOfUtils.js +71 -0
  237. package/tgsl/generationHelpers.d.ts +37 -0
  238. package/tgsl/generationHelpers.js +67 -0
  239. package/tgsl/math.js +43 -0
  240. package/tgsl/shaderGenerator.d.ts +20 -0
  241. package/tgsl/shaderGenerator_members.d.ts +2 -0
  242. package/tgsl/shaderGenerator_members.js +6 -0
  243. package/tgsl/shellless.d.ts +11 -0
  244. package/tgsl/shellless.js +46 -0
  245. package/tgsl/wgslGenerator.d.ts +36 -0
  246. package/tgsl/wgslGenerator.js +639 -0
  247. package/types.d.ts +265 -0
  248. package/types.js +43 -0
  249. package/unwrapper.d.ts +27 -0
  250. package/wgslExtensions.d.ts +5 -0
  251. package/wgslExtensions.js +17 -0
  252. package/builtin-DdtWpk2t.js +0 -818
  253. package/builtin-DdtWpk2t.js.map +0 -1
  254. package/chunk-BYypO7fO.js +0 -18
  255. package/common/index.d.ts.map +0 -1
  256. package/common/index.js.map +0 -1
  257. package/data/index.d.ts.map +0 -1
  258. package/data/index.js.map +0 -1
  259. package/deepEqual-DQxK4vdp.js +0 -413
  260. package/deepEqual-DQxK4vdp.js.map +0 -1
  261. package/extensions-DIVuAfBM.js +0 -2032
  262. package/extensions-DIVuAfBM.js.map +0 -1
  263. package/fullScreenTriangle-CfFyQd_0.js +0 -543
  264. package/fullScreenTriangle-CfFyQd_0.js.map +0 -1
  265. package/index.d.ts.map +0 -1
  266. package/index.js.map +0 -1
  267. package/indexNamedExports-oL6tyaJ9.d.ts +0 -5697
  268. package/indexNamedExports-oL6tyaJ9.d.ts.map +0 -1
  269. package/operators-d-PMVTo7.js +0 -4158
  270. package/operators-d-PMVTo7.js.map +0 -1
  271. package/std/index.d.ts.map +0 -1
  272. package/std/index.js.map +0 -1
  273. package/texture-BagDrrks.js.map +0 -1
@@ -0,0 +1,40 @@
1
+ import { INTERNAL_GlobalExt } from "./shared/meta.js";
2
+ import { Storage, StorageFlag, isUsableAsStorage } from "./extension.js";
3
+ import { TgpuQuerySet } from "./core/querySet/querySet.js";
4
+ import { TgpuBufferMutable, TgpuBufferReadonly, TgpuBufferUniform, isUsableAsUniform } from "./core/buffer/bufferUsage.js";
5
+ import { TgpuMutable, TgpuReadonly, TgpuUniform, isBufferShorthand } from "./core/buffer/bufferShorthand.js";
6
+ import { TgpuComputeFn, TgpuComputeFnShell, isTgpuComputeFn } from "./core/function/tgpuComputeFn.js";
7
+ import { TgpuVar, VariableScope, isVariable } from "./core/variable/tgpuVariable.js";
8
+ import { Eventual, TgpuAccessor, TgpuLazy, TgpuMutableAccessor, TgpuSlot, isAccessor, isLazy, isMutableAccessor, isSlot } from "./core/slot/slotTypes.js";
9
+ import { TgpuComputePipeline } from "./core/pipeline/computePipeline.js";
10
+ import { AutoFragmentIn, AutoFragmentOut, AutoVertexOut, _AutoVertexIn } from "./core/function/autoIO.js";
11
+ import { TgpuFragmentFn, TgpuFragmentFnShell, isTgpuFragmentFn } from "./core/function/tgpuFragmentFn.js";
12
+ import { TgpuVertexFn, TgpuVertexFnShell, isTgpuVertexFn } from "./core/function/tgpuVertexFn.js";
13
+ import { TextureProps } from "./core/texture/textureProps.js";
14
+ import { RenderFlag, SampledFlag, isUsableAsRender, isUsableAsSampled } from "./core/texture/usageExtension.js";
15
+ import { TgpuVertexLayout } from "./core/vertexLayout/vertexLayout.js";
16
+ import { ColorAttachment, TgpuPrimitiveState, TgpuRenderPipeline } from "./core/pipeline/renderPipeline.js";
17
+ import { TgpuComparisonSampler, TgpuFixedComparisonSampler, TgpuFixedSampler, TgpuSampler, isComparisonSampler, isSampler } from "./core/sampler/sampler.js";
18
+ import { BindLayoutEntry, ExtractBindGroupInputFromLayout, LayoutEntryToInput, TgpuBindGroup, TgpuBindGroupLayout, TgpuLayoutComparisonSampler, TgpuLayoutEntry, TgpuLayoutExternalTexture, TgpuLayoutSampler, TgpuLayoutStorage, TgpuLayoutTexture, TgpuLayoutUniform } from "./tgpuBindGroupLayout.js";
19
+ import { ShaderGenerator } from "./tgsl/shaderGenerator.js";
20
+ import { Configurable, TgpuGuardedComputePipeline, TgpuRoot, ValidateBufferSchema, ValidateStorageSchema, ValidateUniformSchema, WithBinding, WithCompute, WithFragment, WithVertex, Withable } from "./core/root/rootTypes.js";
21
+ import { IndexFlag, TgpuBuffer, Uniform, UniformFlag, ValidUsagesFor, Vertex, VertexFlag, isBuffer, isUsableAsVertex } from "./core/buffer/buffer.js";
22
+ import { TgpuDeclare } from "./core/declare/tgpuDeclare.js";
23
+ import { TgpuFn, TgpuFnShell, TgpuGenericFn, isTgpuFn } from "./core/function/tgpuFn.js";
24
+ import { TgpuTexture, TgpuTextureView, isTexture } from "./core/texture/texture.js";
25
+ import { TgpuConst } from "./core/constant/tgpuConstant.js";
26
+ import { TgpuComptime } from "./core/function/comptime.js";
27
+ import { Namespace } from "./core/resolve/namespace.js";
28
+ import { InitFromDeviceOptions, InitOptions } from "./core/root/init.js";
29
+ import { RawCodeSnippetOrigin, TgpuRawCodeSnippet } from "./core/rawCodeSnippet/tgpuRawCodeSnippet.js";
30
+ import { index_d_exports } from "./data/index.js";
31
+ import { index_d_exports as index_d_exports$1 } from "./std/index.js";
32
+ import { index_d_exports as index_d_exports$2 } from "./common/index.js";
33
+ import { MissingBindGroupsError, MissingLinksError, MissingSlotValueError, MissingVertexBuffersError, NotUniformError, ResolutionError } from "./errors.js";
34
+ import { WgslGenerator } from "./tgsl/wgslGenerator.js";
35
+
36
+ //#region src/indexNamedExports.d.ts
37
+ /** @deprecated Use TgpuRenderPipeline.Descriptor */
38
+ type TgpuRenderPipelineDescriptor = TgpuRenderPipeline.Descriptor;
39
+ //#endregion
40
+ export { TgpuRenderPipelineDescriptor };
package/mathUtils.js ADDED
@@ -0,0 +1,12 @@
1
+ //#region src/mathUtils.ts
2
+ /**
3
+ * @param value
4
+ * @param modulo has to be power of 2
5
+ */
6
+ const roundUp = (value, modulo) => {
7
+ const bitMask = modulo - 1;
8
+ const invBitMask = ~bitMask;
9
+ return (value & bitMask) === 0 ? value : (value & invBitMask) + modulo;
10
+ };
11
+ //#endregion
12
+ export { roundUp };
package/memo.js ADDED
@@ -0,0 +1,22 @@
1
+ //#region src/memo.ts
2
+ /**
3
+ * Caches results of the function passed in as
4
+ * the argument to the constructor.
5
+ *
6
+ * If the key can be garbage collected, it will be.
7
+ */
8
+ var WeakMemo = class {
9
+ #map = /* @__PURE__ */ new WeakMap();
10
+ #make;
11
+ constructor(make) {
12
+ this.#make = make;
13
+ }
14
+ getOrMake(key, ...args) {
15
+ if (this.#map.has(key)) return this.#map.get(key);
16
+ const value = this.#make(key, ...args);
17
+ this.#map.set(key, value);
18
+ return value;
19
+ }
20
+ };
21
+ //#endregion
22
+ export { WeakMemo };
@@ -0,0 +1,30 @@
1
+ //#region src/nameRegistry.d.ts
2
+ interface NameRegistry {
3
+ /**
4
+ * Creates a valid WGSL identifier, each guaranteed to be unique
5
+ * in the lifetime of a single resolution process
6
+ * (excluding non-global identifiers from popped scopes).
7
+ * Should append "_" to primer, followed by some id.
8
+ * @param primer Used in the generation process, makes the identifier more recognizable.
9
+ * @param global Whether the name should be registered in the global scope (true), or in the current function scope (false)
10
+ */
11
+ makeUnique(primer: string | undefined, global: boolean): string;
12
+ /**
13
+ * Creates a valid WGSL identifier.
14
+ * Renames identifiers that are WGSL reserved words.
15
+ * @param primer Used in the generation process.
16
+ *
17
+ * @example
18
+ * makeValid("notAKeyword"); // "notAKeyword"
19
+ * makeValid("struct"); // makeUnique("struct")
20
+ * makeValid("struct_1"); // makeUnique("struct_1") (to avoid potential name collisions)
21
+ * makeValid("_"); // ERROR (too difficult to make valid to care)
22
+ */
23
+ makeValid(primer: string): string;
24
+ pushFunctionScope(): void;
25
+ popFunctionScope(): void;
26
+ pushBlockScope(): void;
27
+ popBlockScope(): void;
28
+ }
29
+ //#endregion
30
+ export { NameRegistry };
@@ -0,0 +1,447 @@
1
+ import { invariant } from "./errors.js";
2
+ //#region src/nameRegistry.ts
3
+ const bannedTokens = new Set([
4
+ "alias",
5
+ "break",
6
+ "case",
7
+ "const",
8
+ "const_assert",
9
+ "continue",
10
+ "continuing",
11
+ "default",
12
+ "diagnostic",
13
+ "discard",
14
+ "else",
15
+ "enable",
16
+ "false",
17
+ "fn",
18
+ "for",
19
+ "if",
20
+ "let",
21
+ "loop",
22
+ "override",
23
+ "requires",
24
+ "return",
25
+ "struct",
26
+ "switch",
27
+ "true",
28
+ "var",
29
+ "while",
30
+ "NULL",
31
+ "Self",
32
+ "abstract",
33
+ "active",
34
+ "alignas",
35
+ "alignof",
36
+ "as",
37
+ "asm",
38
+ "asm_fragment",
39
+ "async",
40
+ "attribute",
41
+ "auto",
42
+ "await",
43
+ "become",
44
+ "cast",
45
+ "catch",
46
+ "class",
47
+ "co_await",
48
+ "co_return",
49
+ "co_yield",
50
+ "coherent",
51
+ "column_major",
52
+ "common",
53
+ "compile",
54
+ "compile_fragment",
55
+ "concept",
56
+ "const_cast",
57
+ "consteval",
58
+ "constexpr",
59
+ "constinit",
60
+ "crate",
61
+ "debugger",
62
+ "decltype",
63
+ "delete",
64
+ "demote",
65
+ "demote_to_helper",
66
+ "do",
67
+ "dynamic_cast",
68
+ "enum",
69
+ "explicit",
70
+ "export",
71
+ "extends",
72
+ "extern",
73
+ "external",
74
+ "fallthrough",
75
+ "filter",
76
+ "final",
77
+ "finally",
78
+ "friend",
79
+ "from",
80
+ "fxgroup",
81
+ "get",
82
+ "goto",
83
+ "groupshared",
84
+ "highp",
85
+ "impl",
86
+ "implements",
87
+ "import",
88
+ "inline",
89
+ "instanceof",
90
+ "interface",
91
+ "layout",
92
+ "lowp",
93
+ "macro",
94
+ "macro_rules",
95
+ "match",
96
+ "mediump",
97
+ "meta",
98
+ "mod",
99
+ "module",
100
+ "move",
101
+ "mut",
102
+ "mutable",
103
+ "namespace",
104
+ "new",
105
+ "nil",
106
+ "noexcept",
107
+ "noinline",
108
+ "nointerpolation",
109
+ "non_coherent",
110
+ "noncoherent",
111
+ "noperspective",
112
+ "null",
113
+ "nullptr",
114
+ "of",
115
+ "operator",
116
+ "package",
117
+ "packoffset",
118
+ "partition",
119
+ "pass",
120
+ "patch",
121
+ "pixelfragment",
122
+ "precise",
123
+ "precision",
124
+ "premerge",
125
+ "priv",
126
+ "protected",
127
+ "pub",
128
+ "public",
129
+ "readonly",
130
+ "ref",
131
+ "regardless",
132
+ "register",
133
+ "reinterpret_cast",
134
+ "require",
135
+ "resource",
136
+ "restrict",
137
+ "self",
138
+ "set",
139
+ "shared",
140
+ "sizeof",
141
+ "smooth",
142
+ "snorm",
143
+ "static",
144
+ "static_assert",
145
+ "static_cast",
146
+ "std",
147
+ "subroutine",
148
+ "super",
149
+ "target",
150
+ "template",
151
+ "this",
152
+ "thread_local",
153
+ "throw",
154
+ "trait",
155
+ "try",
156
+ "type",
157
+ "typedef",
158
+ "typeid",
159
+ "typename",
160
+ "typeof",
161
+ "union",
162
+ "unless",
163
+ "unorm",
164
+ "unsafe",
165
+ "unsized",
166
+ "use",
167
+ "using",
168
+ "varying",
169
+ "virtual",
170
+ "volatile",
171
+ "wgsl",
172
+ "where",
173
+ "with",
174
+ "writeonly",
175
+ "yield",
176
+ "sampler",
177
+ "uniform",
178
+ "storage"
179
+ ]);
180
+ const builtins = new Set([
181
+ "array",
182
+ "bool",
183
+ "f16",
184
+ "f32",
185
+ "i32",
186
+ "u32",
187
+ "mat2x2",
188
+ "mat2x3",
189
+ "mat2x4",
190
+ "mat3x2",
191
+ "mat3x3",
192
+ "mat3x4",
193
+ "mat4x2",
194
+ "mat4x3",
195
+ "mat4x4",
196
+ "vec2",
197
+ "vec3",
198
+ "vec4",
199
+ "bitcast",
200
+ "all",
201
+ "any",
202
+ "select",
203
+ "arrayLength",
204
+ "abs",
205
+ "acos",
206
+ "acosh",
207
+ "asin",
208
+ "asinh",
209
+ "atan",
210
+ "atanh",
211
+ "atan2",
212
+ "ceil",
213
+ "clamp",
214
+ "cos",
215
+ "cosh",
216
+ "countLeadingZeros",
217
+ "countOneBits",
218
+ "countTrailingZeros",
219
+ "cross",
220
+ "degrees",
221
+ "determinant",
222
+ "distance",
223
+ "dot",
224
+ "dot4U8Packed",
225
+ "dot4I8Packed",
226
+ "exp",
227
+ "exp2",
228
+ "extractBits",
229
+ "faceForward",
230
+ "firstLeadingBit",
231
+ "firstTrailingBit",
232
+ "floor",
233
+ "fma",
234
+ "fract",
235
+ "frexp",
236
+ "insertBits",
237
+ "inverseSqrt",
238
+ "ldexp",
239
+ "length",
240
+ "log",
241
+ "log2",
242
+ "max",
243
+ "min",
244
+ "mix",
245
+ "modf",
246
+ "normalize",
247
+ "pow",
248
+ "quantizeToF16",
249
+ "radians",
250
+ "reflect",
251
+ "refract",
252
+ "reverseBits",
253
+ "round",
254
+ "saturate",
255
+ "sign",
256
+ "sin",
257
+ "sinh",
258
+ "smoothstep",
259
+ "sqrt",
260
+ "step",
261
+ "tan",
262
+ "tanh",
263
+ "transpose",
264
+ "trunc",
265
+ "dpdx",
266
+ "dpdxCoarse",
267
+ "dpdxFine",
268
+ "dpdy",
269
+ "dpdyCoarse",
270
+ "dpdyFine",
271
+ "fwidth",
272
+ "fwidthCoarse",
273
+ "fwidthFine",
274
+ "textureDimensions",
275
+ "textureGather",
276
+ "textureGatherCompare",
277
+ "textureLoad",
278
+ "textureNumLayers",
279
+ "textureNumLevels",
280
+ "textureNumSamples",
281
+ "textureSample",
282
+ "textureSampleBias",
283
+ "textureSampleCompare",
284
+ "textureSampleCompareLevel",
285
+ "textureSampleGrad",
286
+ "textureSampleLevel",
287
+ "textureSampleBaseClampToEdge",
288
+ "textureStore",
289
+ "atomicLoad",
290
+ "atomicStore",
291
+ "atomicAdd",
292
+ "atomicSub",
293
+ "atomicMax",
294
+ "atomicMin",
295
+ "atomicAnd",
296
+ "atomicOr",
297
+ "atomicXor",
298
+ "atomicExchange",
299
+ "atomicCompareExchangeWeak",
300
+ "pack4x8snorm",
301
+ "pack4x8unorm",
302
+ "pack4xI8",
303
+ "pack4xU8",
304
+ "pack4xI8Clamp",
305
+ "pack4xU8Clamp",
306
+ "pack2x16snorm",
307
+ "pack2x16unorm",
308
+ "pack2x16float",
309
+ "unpack4x8snorm",
310
+ "unpack4x8unorm",
311
+ "unpack4xI8",
312
+ "unpack4xU8",
313
+ "unpack2x16snorm",
314
+ "unpack2x16unorm",
315
+ "unpack2x16float",
316
+ "storageBarrier",
317
+ "textureBarrier",
318
+ "workgroupBarrier",
319
+ "workgroupUniformLoad",
320
+ "subgroupAdd",
321
+ "subgroupExclusiveAdd",
322
+ "subgroupInclusiveAdd",
323
+ "subgroupAll",
324
+ "subgroupAnd",
325
+ "subgroupAny",
326
+ "subgroupBallot",
327
+ "subgroupBroadcast",
328
+ "subgroupBroadcastFirst",
329
+ "subgroupElect",
330
+ "subgroupMax",
331
+ "subgroupMin",
332
+ "subgroupMul",
333
+ "subgroupExclusiveMul",
334
+ "subgroupInclusiveMul",
335
+ "subgroupOr",
336
+ "subgroupShuffle",
337
+ "subgroupShuffleDown",
338
+ "subgroupShuffleUp",
339
+ "subgroupShuffleXor",
340
+ "subgroupXor",
341
+ "quadBroadcast",
342
+ "quadSwapDiagonal",
343
+ "quadSwapX",
344
+ "quadSwapY"
345
+ ]);
346
+ function sanitizePrimer(primer) {
347
+ if (primer) return primer.replaceAll(/\s/g, "_").replaceAll(/[^\w\d]/g, "");
348
+ return "item";
349
+ }
350
+ /**
351
+ * A function for checking whether an identifier needs renaming.
352
+ * Throws if provided with an invalid identifier that cannot be easily renamed.
353
+ * @example
354
+ * isValidIdentifier("ident"); // true
355
+ * isValidIdentifier("struct"); // false
356
+ * isValidIdentifier("struct_1"); // false
357
+ * isValidIdentifier("_"); // ERROR
358
+ * isValidIdentifier("my variable"); // ERROR
359
+ */
360
+ function isValidIdentifier(ident) {
361
+ if (ident === "_" || ident.startsWith("__") || /\s/.test(ident)) throw new Error(`Invalid identifier '${ident}'. Choose an identifier without whitespaces or leading underscores.`);
362
+ const prefix = ident.split("_")[0];
363
+ return !bannedTokens.has(prefix) && !builtins.has(prefix);
364
+ }
365
+ /**
366
+ * Same as `isValidIdentifier`, except does not check for builtin clashes.
367
+ */
368
+ function isValidProp(ident) {
369
+ if (ident === "_" || ident.startsWith("__") || /\s/.test(ident)) throw new Error(`Invalid identifier '${ident}'. Choose an identifier without whitespaces or leading underscores.`);
370
+ const prefix = ident.split("_")[0];
371
+ return !bannedTokens.has(prefix);
372
+ }
373
+ var NameRegistryImpl = class {
374
+ #usedNames;
375
+ #scopeStack;
376
+ constructor() {
377
+ this.#usedNames = new Set([...bannedTokens, ...builtins]);
378
+ this.#scopeStack = [];
379
+ }
380
+ get #usedBlockScopeNames() {
381
+ return this.#scopeStack[this.#scopeStack.length - 1]?.usedBlockScopeNames;
382
+ }
383
+ makeUnique(primer, global) {
384
+ const sanitizedPrimer = sanitizePrimer(primer);
385
+ const name = this.getUniqueVariant(sanitizedPrimer);
386
+ if (global) this.#usedNames.add(name);
387
+ else this.#usedBlockScopeNames?.add(name);
388
+ return name;
389
+ }
390
+ #isUsedInBlocksBefore(name) {
391
+ const functionScopeIndex = this.#scopeStack.findLastIndex((scope) => scope.type === "functionScope");
392
+ return this.#scopeStack.slice(functionScopeIndex + 1).some((scope) => scope.usedBlockScopeNames.has(name));
393
+ }
394
+ makeValid(primer) {
395
+ if (isValidIdentifier(primer) && !this.#usedNames.has(primer) && !this.#isUsedInBlocksBefore(primer)) {
396
+ this.#usedBlockScopeNames?.add(primer);
397
+ return primer;
398
+ }
399
+ return this.makeUnique(primer, false);
400
+ }
401
+ isUsed(name) {
402
+ return this.#usedNames.has(name) || this.#isUsedInBlocksBefore(name);
403
+ }
404
+ pushFunctionScope() {
405
+ this.#scopeStack.push({ type: "functionScope" });
406
+ this.#scopeStack.push({
407
+ type: "blockScope",
408
+ usedBlockScopeNames: /* @__PURE__ */ new Set()
409
+ });
410
+ }
411
+ popFunctionScope() {
412
+ const functionScopeIndex = this.#scopeStack.findLastIndex((scope) => scope.type === "functionScope");
413
+ if (functionScopeIndex === -1) throw new Error("Tried to pop function scope when no scope was present.");
414
+ this.#scopeStack.splice(functionScopeIndex);
415
+ }
416
+ pushBlockScope() {
417
+ this.#scopeStack.push({
418
+ type: "blockScope",
419
+ usedBlockScopeNames: /* @__PURE__ */ new Set()
420
+ });
421
+ }
422
+ popBlockScope() {
423
+ invariant(this.#scopeStack[this.#scopeStack.length - 1]?.type === "blockScope", "Tried to pop block scope, but it is not present");
424
+ this.#scopeStack.pop();
425
+ }
426
+ };
427
+ var RandomNameRegistry = class extends NameRegistryImpl {
428
+ #lastUniqueId = 0;
429
+ getUniqueVariant(base) {
430
+ let name = `${base}_${this.#lastUniqueId++}`;
431
+ while (this.isUsed(name)) name = `${base}_${this.#lastUniqueId++}`;
432
+ return name;
433
+ }
434
+ };
435
+ var StrictNameRegistry = class extends NameRegistryImpl {
436
+ getUniqueVariant(base) {
437
+ let index = 0;
438
+ let name = base;
439
+ while (this.isUsed(name)) {
440
+ index++;
441
+ name = `${base}_${index}`;
442
+ }
443
+ return name;
444
+ }
445
+ };
446
+ //#endregion
447
+ export { RandomNameRegistry, StrictNameRegistry, isValidProp };
package/package.js ADDED
@@ -0,0 +1,4 @@
1
+ //#region package.json
2
+ var version = "0.11.0-rc.1";
3
+ //#endregion
4
+ export { version };
package/package.json CHANGED
@@ -1,10 +1,29 @@
1
1
  {
2
2
  "name": "typegpu",
3
- "private": false,
4
- "version": "0.10.1",
3
+ "version": "0.11.0-rc.1",
5
4
  "description": "A thin layer between JS and WebGPU/WGSL that improves development experience and allows for faster iteration.",
5
+ "keywords": [
6
+ "compute",
7
+ "gpgpu",
8
+ "shader",
9
+ "shaders",
10
+ "typescript",
11
+ "webgpu",
12
+ "wgpu",
13
+ "wgsl"
14
+ ],
15
+ "homepage": "https://typegpu.com",
16
+ "bugs": {
17
+ "url": "https://github.com/software-mansion/TypeGPU/issues"
18
+ },
6
19
  "license": "MIT",
20
+ "repository": {
21
+ "type": "git",
22
+ "url": "git+https://github.com/software-mansion/TypeGPU.git",
23
+ "directory": "packages/typegpu"
24
+ },
7
25
  "type": "module",
26
+ "sideEffects": false,
8
27
  "exports": {
9
28
  "./package.json": "./package.json",
10
29
  ".": {
@@ -24,35 +43,16 @@
24
43
  "default": "./common/index.js"
25
44
  }
26
45
  },
27
- "sideEffects": false,
28
- "engines": {
29
- "node": ">=12.20.0"
30
- },
31
- "repository": {
32
- "type": "git",
33
- "url": "git+https://github.com/software-mansion/TypeGPU.git"
34
- },
35
- "keywords": [
36
- "webgpu",
37
- "wgpu",
38
- "wgsl",
39
- "typescript",
40
- "compute",
41
- "shader",
42
- "shaders",
43
- "gpgpu"
44
- ],
45
- "bugs": {
46
- "url": "https://github.com/software-mansion/TypeGPU/issues"
47
- },
48
- "homepage": "https://typegpu.com",
49
46
  "dependencies": {
50
- "tinyest": "~0.3.0",
47
+ "tinyest": "~0.3.1",
51
48
  "tsover-runtime": "^0.0.5",
52
49
  "typed-binary": "^4.3.1"
53
50
  },
51
+ "engines": {
52
+ "node": ">=12.20.0"
53
+ },
54
54
  "main": "./index.js",
55
55
  "types": "./index.d.ts",
56
- "peerDependencies": {},
56
+ "private": false,
57
57
  "scripts": {}
58
58
  }
@@ -0,0 +1,19 @@
1
+ import { LogResources } from "./tgsl/consoleLog/types.js";
2
+ import { TgpuBindGroup, TgpuBindGroupLayout } from "./tgpuBindGroupLayout.js";
3
+ //#region src/resolutionCtx.d.ts
4
+ /**
5
+ * The results of a WGSL resolution.
6
+ *
7
+ * @param code - The resolved code.
8
+ * @param usedBindGroupLayouts - List of used `tgpu.bindGroupLayout`s.
9
+ * @param catchall - Automatically constructed bind group for buffer usages and buffer shorthands, preceded by its index.
10
+ * @param logResources - Buffers and information about used console.logs needed to decode the raw data.
11
+ */
12
+ interface ResolutionResult {
13
+ code: string;
14
+ usedBindGroupLayouts: TgpuBindGroupLayout[];
15
+ catchall: [number, TgpuBindGroup] | undefined;
16
+ logResources: LogResources | undefined;
17
+ }
18
+ //#endregion
19
+ export { ResolutionResult };