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,38 @@
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, AutoVertexIn, AutoVertexOut } 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 { Configurable, TgpuGuardedComputePipeline, TgpuRoot, ValidateBufferSchema, ValidateStorageSchema, ValidateUniformSchema, WithBinding, WithCompute, WithFragment, WithVertex, Withable } from "./core/root/rootTypes.js";
20
+ import { IndexFlag, TgpuBuffer, Uniform, UniformFlag, ValidUsagesFor, Vertex, VertexFlag, isBuffer, isUsableAsVertex } from "./core/buffer/buffer.js";
21
+ import { TgpuDeclare } from "./core/declare/tgpuDeclare.js";
22
+ import { TgpuFn, TgpuFnShell, TgpuGenericFn, isTgpuFn } from "./core/function/tgpuFn.js";
23
+ import { TgpuTexture, TgpuTextureView, isTexture } from "./core/texture/texture.js";
24
+ import { TgpuConst } from "./core/constant/tgpuConstant.js";
25
+ import { TgpuComptime } from "./core/function/comptime.js";
26
+ import { Namespace } from "./core/resolve/namespace.js";
27
+ import { InitFromDeviceOptions, InitOptions } from "./core/root/init.js";
28
+ import { RawCodeSnippetOrigin, TgpuRawCodeSnippet } from "./core/rawCodeSnippet/tgpuRawCodeSnippet.js";
29
+ import { index_d_exports } from "./data/index.js";
30
+ import { index_d_exports as index_d_exports$1 } from "./std/index.js";
31
+ import { index_d_exports as index_d_exports$2 } from "./common/index.js";
32
+ import { MissingBindGroupsError, MissingLinksError, MissingSlotValueError, MissingVertexBuffersError, NotUniformError, ResolutionError } from "./errors.js";
33
+
34
+ //#region src/indexNamedExports.d.ts
35
+ /** @deprecated Use TgpuRenderPipeline.Descriptor */
36
+ type TgpuRenderPipelineDescriptor = TgpuRenderPipeline.Descriptor;
37
+ //#endregion
38
+ export { TgpuRenderPipelineDescriptor };
package/mathUtils.js ADDED
@@ -0,0 +1,13 @@
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
+
12
+ //#endregion
13
+ 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
+ constructor(_make) {
11
+ this._make = _make;
12
+ }
13
+ getOrMake(key, ...args) {
14
+ if (this._map.has(key)) return this._map.get(key);
15
+ const value = this._make(key, ...args);
16
+ this._map.set(key, value);
17
+ return value;
18
+ }
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,449 @@
1
+ import { invariant } from "./errors.js";
2
+
3
+ //#region src/nameRegistry.ts
4
+ const bannedTokens = new Set([
5
+ "alias",
6
+ "break",
7
+ "case",
8
+ "const",
9
+ "const_assert",
10
+ "continue",
11
+ "continuing",
12
+ "default",
13
+ "diagnostic",
14
+ "discard",
15
+ "else",
16
+ "enable",
17
+ "false",
18
+ "fn",
19
+ "for",
20
+ "if",
21
+ "let",
22
+ "loop",
23
+ "override",
24
+ "requires",
25
+ "return",
26
+ "struct",
27
+ "switch",
28
+ "true",
29
+ "var",
30
+ "while",
31
+ "NULL",
32
+ "Self",
33
+ "abstract",
34
+ "active",
35
+ "alignas",
36
+ "alignof",
37
+ "as",
38
+ "asm",
39
+ "asm_fragment",
40
+ "async",
41
+ "attribute",
42
+ "auto",
43
+ "await",
44
+ "become",
45
+ "cast",
46
+ "catch",
47
+ "class",
48
+ "co_await",
49
+ "co_return",
50
+ "co_yield",
51
+ "coherent",
52
+ "column_major",
53
+ "common",
54
+ "compile",
55
+ "compile_fragment",
56
+ "concept",
57
+ "const_cast",
58
+ "consteval",
59
+ "constexpr",
60
+ "constinit",
61
+ "crate",
62
+ "debugger",
63
+ "decltype",
64
+ "delete",
65
+ "demote",
66
+ "demote_to_helper",
67
+ "do",
68
+ "dynamic_cast",
69
+ "enum",
70
+ "explicit",
71
+ "export",
72
+ "extends",
73
+ "extern",
74
+ "external",
75
+ "fallthrough",
76
+ "filter",
77
+ "final",
78
+ "finally",
79
+ "friend",
80
+ "from",
81
+ "fxgroup",
82
+ "get",
83
+ "goto",
84
+ "groupshared",
85
+ "highp",
86
+ "impl",
87
+ "implements",
88
+ "import",
89
+ "inline",
90
+ "instanceof",
91
+ "interface",
92
+ "layout",
93
+ "lowp",
94
+ "macro",
95
+ "macro_rules",
96
+ "match",
97
+ "mediump",
98
+ "meta",
99
+ "mod",
100
+ "module",
101
+ "move",
102
+ "mut",
103
+ "mutable",
104
+ "namespace",
105
+ "new",
106
+ "nil",
107
+ "noexcept",
108
+ "noinline",
109
+ "nointerpolation",
110
+ "non_coherent",
111
+ "noncoherent",
112
+ "noperspective",
113
+ "null",
114
+ "nullptr",
115
+ "of",
116
+ "operator",
117
+ "package",
118
+ "packoffset",
119
+ "partition",
120
+ "pass",
121
+ "patch",
122
+ "pixelfragment",
123
+ "precise",
124
+ "precision",
125
+ "premerge",
126
+ "priv",
127
+ "protected",
128
+ "pub",
129
+ "public",
130
+ "readonly",
131
+ "ref",
132
+ "regardless",
133
+ "register",
134
+ "reinterpret_cast",
135
+ "require",
136
+ "resource",
137
+ "restrict",
138
+ "self",
139
+ "set",
140
+ "shared",
141
+ "sizeof",
142
+ "smooth",
143
+ "snorm",
144
+ "static",
145
+ "static_assert",
146
+ "static_cast",
147
+ "std",
148
+ "subroutine",
149
+ "super",
150
+ "target",
151
+ "template",
152
+ "this",
153
+ "thread_local",
154
+ "throw",
155
+ "trait",
156
+ "try",
157
+ "type",
158
+ "typedef",
159
+ "typeid",
160
+ "typename",
161
+ "typeof",
162
+ "union",
163
+ "unless",
164
+ "unorm",
165
+ "unsafe",
166
+ "unsized",
167
+ "use",
168
+ "using",
169
+ "varying",
170
+ "virtual",
171
+ "volatile",
172
+ "wgsl",
173
+ "where",
174
+ "with",
175
+ "writeonly",
176
+ "yield",
177
+ "sampler",
178
+ "uniform",
179
+ "storage"
180
+ ]);
181
+ const builtins = new Set([
182
+ "array",
183
+ "bool",
184
+ "f16",
185
+ "f32",
186
+ "i32",
187
+ "u32",
188
+ "mat2x2",
189
+ "mat2x3",
190
+ "mat2x4",
191
+ "mat3x2",
192
+ "mat3x3",
193
+ "mat3x4",
194
+ "mat4x2",
195
+ "mat4x3",
196
+ "mat4x4",
197
+ "vec2",
198
+ "vec3",
199
+ "vec4",
200
+ "bitcast",
201
+ "all",
202
+ "any",
203
+ "select",
204
+ "arrayLength",
205
+ "abs",
206
+ "acos",
207
+ "acosh",
208
+ "asin",
209
+ "asinh",
210
+ "atan",
211
+ "atanh",
212
+ "atan2",
213
+ "ceil",
214
+ "clamp",
215
+ "cos",
216
+ "cosh",
217
+ "countLeadingZeros",
218
+ "countOneBits",
219
+ "countTrailingZeros",
220
+ "cross",
221
+ "degrees",
222
+ "determinant",
223
+ "distance",
224
+ "dot",
225
+ "dot4U8Packed",
226
+ "dot4I8Packed",
227
+ "exp",
228
+ "exp2",
229
+ "extractBits",
230
+ "faceForward",
231
+ "firstLeadingBit",
232
+ "firstTrailingBit",
233
+ "floor",
234
+ "fma",
235
+ "fract",
236
+ "frexp",
237
+ "insertBits",
238
+ "inverseSqrt",
239
+ "ldexp",
240
+ "length",
241
+ "log",
242
+ "log2",
243
+ "max",
244
+ "min",
245
+ "mix",
246
+ "modf",
247
+ "normalize",
248
+ "pow",
249
+ "quantizeToF16",
250
+ "radians",
251
+ "reflect",
252
+ "refract",
253
+ "reverseBits",
254
+ "round",
255
+ "saturate",
256
+ "sign",
257
+ "sin",
258
+ "sinh",
259
+ "smoothstep",
260
+ "sqrt",
261
+ "step",
262
+ "tan",
263
+ "tanh",
264
+ "transpose",
265
+ "trunc",
266
+ "dpdx",
267
+ "dpdxCoarse",
268
+ "dpdxFine",
269
+ "dpdy",
270
+ "dpdyCoarse",
271
+ "dpdyFine",
272
+ "fwidth",
273
+ "fwidthCoarse",
274
+ "fwidthFine",
275
+ "textureDimensions",
276
+ "textureGather",
277
+ "textureGatherCompare",
278
+ "textureLoad",
279
+ "textureNumLayers",
280
+ "textureNumLevels",
281
+ "textureNumSamples",
282
+ "textureSample",
283
+ "textureSampleBias",
284
+ "textureSampleCompare",
285
+ "textureSampleCompareLevel",
286
+ "textureSampleGrad",
287
+ "textureSampleLevel",
288
+ "textureSampleBaseClampToEdge",
289
+ "textureStore",
290
+ "atomicLoad",
291
+ "atomicStore",
292
+ "atomicAdd",
293
+ "atomicSub",
294
+ "atomicMax",
295
+ "atomicMin",
296
+ "atomicAnd",
297
+ "atomicOr",
298
+ "atomicXor",
299
+ "atomicExchange",
300
+ "atomicCompareExchangeWeak",
301
+ "pack4x8snorm",
302
+ "pack4x8unorm",
303
+ "pack4xI8",
304
+ "pack4xU8",
305
+ "pack4xI8Clamp",
306
+ "pack4xU8Clamp",
307
+ "pack2x16snorm",
308
+ "pack2x16unorm",
309
+ "pack2x16float",
310
+ "unpack4x8snorm",
311
+ "unpack4x8unorm",
312
+ "unpack4xI8",
313
+ "unpack4xU8",
314
+ "unpack2x16snorm",
315
+ "unpack2x16unorm",
316
+ "unpack2x16float",
317
+ "storageBarrier",
318
+ "textureBarrier",
319
+ "workgroupBarrier",
320
+ "workgroupUniformLoad",
321
+ "subgroupAdd",
322
+ "subgroupExclusiveAdd",
323
+ "subgroupInclusiveAdd",
324
+ "subgroupAll",
325
+ "subgroupAnd",
326
+ "subgroupAny",
327
+ "subgroupBallot",
328
+ "subgroupBroadcast",
329
+ "subgroupBroadcastFirst",
330
+ "subgroupElect",
331
+ "subgroupMax",
332
+ "subgroupMin",
333
+ "subgroupMul",
334
+ "subgroupExclusiveMul",
335
+ "subgroupInclusiveMul",
336
+ "subgroupOr",
337
+ "subgroupShuffle",
338
+ "subgroupShuffleDown",
339
+ "subgroupShuffleUp",
340
+ "subgroupShuffleXor",
341
+ "subgroupXor",
342
+ "quadBroadcast",
343
+ "quadSwapDiagonal",
344
+ "quadSwapX",
345
+ "quadSwapY"
346
+ ]);
347
+ function sanitizePrimer(primer) {
348
+ if (primer) return primer.replaceAll(/\s/g, "_").replaceAll(/[^\w\d]/g, "");
349
+ return "item";
350
+ }
351
+ /**
352
+ * A function for checking whether an identifier needs renaming.
353
+ * Throws if provided with an invalid identifier that cannot be easily renamed.
354
+ * @example
355
+ * isValidIdentifier("ident"); // true
356
+ * isValidIdentifier("struct"); // false
357
+ * isValidIdentifier("struct_1"); // false
358
+ * isValidIdentifier("_"); // ERROR
359
+ * isValidIdentifier("my variable"); // ERROR
360
+ */
361
+ function isValidIdentifier(ident) {
362
+ if (ident === "_" || ident.startsWith("__") || /\s/.test(ident)) throw new Error(`Invalid identifier '${ident}'. Choose an identifier without whitespaces or leading underscores.`);
363
+ const prefix = ident.split("_")[0];
364
+ return !bannedTokens.has(prefix) && !builtins.has(prefix);
365
+ }
366
+ /**
367
+ * Same as `isValidIdentifier`, except does not check for builtin clashes.
368
+ */
369
+ function isValidProp(ident) {
370
+ if (ident === "_" || ident.startsWith("__") || /\s/.test(ident)) throw new Error(`Invalid identifier '${ident}'. Choose an identifier without whitespaces or leading underscores.`);
371
+ const prefix = ident.split("_")[0];
372
+ return !bannedTokens.has(prefix);
373
+ }
374
+ var NameRegistryImpl = class {
375
+ #usedNames;
376
+ #scopeStack;
377
+ constructor() {
378
+ this.#usedNames = new Set([...bannedTokens, ...builtins]);
379
+ this.#scopeStack = [];
380
+ }
381
+ get #usedBlockScopeNames() {
382
+ return this.#scopeStack[this.#scopeStack.length - 1]?.usedBlockScopeNames;
383
+ }
384
+ makeUnique(primer, global) {
385
+ const sanitizedPrimer = sanitizePrimer(primer);
386
+ const name = this.getUniqueVariant(sanitizedPrimer);
387
+ if (global) this.#usedNames.add(name);
388
+ else this.#usedBlockScopeNames?.add(name);
389
+ return name;
390
+ }
391
+ #isUsedInBlocksBefore(name) {
392
+ const functionScopeIndex = this.#scopeStack.findLastIndex((scope) => scope.type === "functionScope");
393
+ return this.#scopeStack.slice(functionScopeIndex + 1).some((scope) => scope.usedBlockScopeNames.has(name));
394
+ }
395
+ makeValid(primer) {
396
+ if (isValidIdentifier(primer) && !this.#usedNames.has(primer) && !this.#isUsedInBlocksBefore(primer)) {
397
+ this.#usedBlockScopeNames?.add(primer);
398
+ return primer;
399
+ }
400
+ return this.makeUnique(primer, false);
401
+ }
402
+ isUsed(name) {
403
+ return this.#usedNames.has(name) || this.#isUsedInBlocksBefore(name);
404
+ }
405
+ pushFunctionScope() {
406
+ this.#scopeStack.push({ type: "functionScope" });
407
+ this.#scopeStack.push({
408
+ type: "blockScope",
409
+ usedBlockScopeNames: /* @__PURE__ */ new Set()
410
+ });
411
+ }
412
+ popFunctionScope() {
413
+ const functionScopeIndex = this.#scopeStack.findLastIndex((scope) => scope.type === "functionScope");
414
+ if (functionScopeIndex === -1) throw new Error("Tried to pop function scope when no scope was present.");
415
+ this.#scopeStack.splice(functionScopeIndex);
416
+ }
417
+ pushBlockScope() {
418
+ this.#scopeStack.push({
419
+ type: "blockScope",
420
+ usedBlockScopeNames: /* @__PURE__ */ new Set()
421
+ });
422
+ }
423
+ popBlockScope() {
424
+ invariant(this.#scopeStack[this.#scopeStack.length - 1]?.type === "blockScope", "Tried to pop block scope, but it is not present");
425
+ this.#scopeStack.pop();
426
+ }
427
+ };
428
+ var RandomNameRegistry = class extends NameRegistryImpl {
429
+ #lastUniqueId = 0;
430
+ getUniqueVariant(base) {
431
+ let name = `${base}_${this.#lastUniqueId++}`;
432
+ while (this.isUsed(name)) name = `${base}_${this.#lastUniqueId++}`;
433
+ return name;
434
+ }
435
+ };
436
+ var StrictNameRegistry = class extends NameRegistryImpl {
437
+ getUniqueVariant(base) {
438
+ let index = 0;
439
+ let name = base;
440
+ while (this.isUsed(name)) {
441
+ index++;
442
+ name = `${base}_${index}`;
443
+ }
444
+ return name;
445
+ }
446
+ };
447
+
448
+ //#endregion
449
+ export { RandomNameRegistry, StrictNameRegistry, isValidProp };
package/package.js ADDED
@@ -0,0 +1,5 @@
1
+ //#region package.json
2
+ var version = "0.10.2";
3
+
4
+ //#endregion
5
+ export { version };
package/package.json CHANGED
@@ -1,10 +1,29 @@
1
1
  {
2
2
  "name": "typegpu",
3
+ "version": "0.10.2",
3
4
  "private": false,
4
- "version": "0.10.0",
5
5
  "description": "A thin layer between JS and WebGPU/WGSL that improves development experience and allows for faster iteration.",
6
+ "keywords": [
7
+ "compute",
8
+ "gpgpu",
9
+ "shader",
10
+ "shaders",
11
+ "typescript",
12
+ "webgpu",
13
+ "wgpu",
14
+ "wgsl"
15
+ ],
16
+ "homepage": "https://typegpu.com",
17
+ "bugs": {
18
+ "url": "https://github.com/software-mansion/TypeGPU/issues"
19
+ },
6
20
  "license": "MIT",
21
+ "repository": {
22
+ "type": "git",
23
+ "url": "git+https://github.com/software-mansion/TypeGPU.git"
24
+ },
7
25
  "type": "module",
26
+ "sideEffects": false,
8
27
  "exports": {
9
28
  "./package.json": "./package.json",
10
29
  ".": {
@@ -24,33 +43,14 @@
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
47
  "tinyest": "~0.3.0",
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
56
  "peerDependencies": {},
@@ -0,0 +1,29 @@
1
+ import "./data/snippet.js";
2
+ import "./tgsl/shellless.js";
3
+ import { LogResources } from "./tgsl/consoleLog/types.js";
4
+ import "./core/slot/slotTypes.js";
5
+ import { TgpuBindGroup, TgpuBindGroupLayout } from "./tgpuBindGroupLayout.js";
6
+ import "./tgsl/shaderGenerator.js";
7
+ import "./core/root/rootTypes.js";
8
+ import "./types.js";
9
+ import "./data/wgslTypes.js";
10
+ import "./data/dataTypes.js";
11
+ import "./core/resolve/namespace.js";
12
+
13
+ //#region src/resolutionCtx.d.ts
14
+ /**
15
+ * The results of a WGSL resolution.
16
+ *
17
+ * @param code - The resolved code.
18
+ * @param usedBindGroupLayouts - List of used `tgpu.bindGroupLayout`s.
19
+ * @param catchall - Automatically constructed bind group for buffer usages and buffer shorthands, preceded by its index.
20
+ * @param logResources - Buffers and information about used console.logs needed to decode the raw data.
21
+ */
22
+ interface ResolutionResult {
23
+ code: string;
24
+ usedBindGroupLayouts: TgpuBindGroupLayout[];
25
+ catchall: [number, TgpuBindGroup] | undefined;
26
+ logResources: LogResources | undefined;
27
+ }
28
+ //#endregion
29
+ export { ResolutionResult };