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,108 @@
1
+ import { $internal, $repr } from "../shared/symbols.js";
2
+ import { comparisonSampler, sampler } from "../data/sampler.js";
3
+ import { DualFn } from "../types.js";
4
+ import { v2f, v2i, v2u, v3f, v3i, v3u, v4f, v4i, v4u } from "../data/wgslTypes.js";
5
+ import { StorageTextureFormats, TextureFormats } from "../core/texture/textureFormats.js";
6
+ import { texture1d, texture2d, texture2dArray, texture3d, textureCube, textureCubeArray, textureDepth2d, textureDepth2dArray, textureDepthCube, textureDepthCubeArray, textureDepthMultisampled2d, textureExternal, textureMultisampled2d, textureStorage1d, textureStorage2d, textureStorage2dArray, textureStorage3d } from "../data/texture.js";
7
+
8
+ //#region src/std/texture.d.ts
9
+ declare function sampleCpu<T extends texture1d>(texture: T, sampler: sampler, coords: number): v4f;
10
+ declare function sampleCpu<T extends texture2d>(texture: T, sampler: sampler, coords: v2f, offset?: v2i): v4f;
11
+ declare function sampleCpu<T extends texture2dArray>(texture: T, sampler: sampler, coords: v2f, arrayIndex: number, offset?: v2i): v4f;
12
+ declare function sampleCpu<T extends texture3d | textureCube>(texture: T, sampler: sampler, coords: v3f): v4f;
13
+ declare function sampleCpu<T extends texture3d>(texture: T, sampler: sampler, coords: v3f, offset: v3i): v4f;
14
+ declare function sampleCpu<T extends textureCubeArray>(texture: T, sampler: sampler, coords: v3f, arrayIndex: number): v4f;
15
+ declare function sampleCpu<T extends textureDepth2d>(texture: T, sampler: sampler, coords: v2f, offset?: v2i): number;
16
+ declare function sampleCpu<T extends textureDepth2dArray>(texture: T, sampler: sampler, coords: v2f, arrayIndex: number, offset?: v2i): number;
17
+ declare function sampleCpu<T extends textureDepthCube>(texture: T, sampler: sampler, coords: v3f, arrayIndex?: number): number;
18
+ declare const textureSample: DualFn<typeof sampleCpu>;
19
+ declare function sampleBiasCpu<T extends texture1d>(texture: T, sampler: sampler, coords: number, bias: number): v4f;
20
+ declare function sampleBiasCpu<T extends texture2d>(texture: T, sampler: sampler, coords: v2f, bias: number, offset?: v2i): v4f;
21
+ declare function sampleBiasCpu<T extends texture2dArray>(texture: T, sampler: sampler, coords: v2f, arrayIndex: number, bias: number, offset?: v2i): v4f;
22
+ declare function sampleBiasCpu<T extends texture3d | textureCube>(texture: T, sampler: sampler, coords: v3f, bias: number, offset?: v3i): v4f;
23
+ declare function sampleBiasCpu<T extends textureCubeArray>(texture: T, sampler: sampler, coords: v3f, arrayIndex: number, bias: number): v4f;
24
+ declare const textureSampleBias: DualFn<typeof sampleBiasCpu>;
25
+ declare function sampleLevelCpu<T extends texture1d>(texture: T, sampler: sampler, coords: number, level: number): v4f;
26
+ declare function sampleLevelCpu<T extends texture2d>(texture: T, sampler: sampler, coords: v2f, level: number): v4f;
27
+ declare function sampleLevelCpu<T extends texture2d>(texture: T, sampler: sampler, coords: v2f, level: number, offset: v2i): v4f;
28
+ declare function sampleLevelCpu<T extends texture2dArray>(texture: T, sampler: sampler, coords: v2f, arrayIndex: number, level: number): v4f;
29
+ declare function sampleLevelCpu<T extends texture2dArray>(texture: T, sampler: sampler, coords: v2f, arrayIndex: number, level: number, offset: v2i): v4f;
30
+ declare function sampleLevelCpu<T extends texture3d | textureCube>(texture: T, sampler: sampler, coords: v3f, level: number): v4f;
31
+ declare function sampleLevelCpu<T extends texture3d>(texture: T, sampler: sampler, coords: v3f, level: number, offset: v3i): v4f;
32
+ declare function sampleLevelCpu<T extends textureCubeArray>(texture: T, sampler: sampler, coords: v3f, arrayIndex: number, level: number): v4f;
33
+ declare function sampleLevelCpu<T extends textureDepth2d>(texture: T, sampler: sampler, coords: v2f, level: number): number;
34
+ declare function sampleLevelCpu<T extends textureDepth2d>(texture: T, sampler: sampler, coords: v2f, level: number, offset: v2i): number;
35
+ declare function sampleLevelCpu<T extends textureDepth2dArray>(texture: T, sampler: sampler, coords: v2f, arrayIndex: number, level: number): number;
36
+ declare function sampleLevelCpu<T extends textureDepth2dArray>(texture: T, sampler: sampler, coords: v2f, arrayIndex: number, level: number, offset: v2i): number;
37
+ declare function sampleLevelCpu<T extends textureDepthCube>(texture: T, sampler: sampler, coords: v3f, level: number): number;
38
+ declare function sampleLevelCpu<T extends textureCubeArray>(texture: T, sampler: sampler, coords: v3f, arrayIndex: number, level: number): number;
39
+ declare const textureSampleLevel: DualFn<typeof sampleLevelCpu>;
40
+ type PrimitiveToLoadedType = {
41
+ f32: v4f;
42
+ i32: v4i;
43
+ u32: v4u;
44
+ };
45
+ type TexelFormatToInstanceType<T extends StorageTextureFormats> = TextureFormats[T]['vectorType'][typeof $repr];
46
+ declare function textureLoadCpu<T extends texture1d>(texture: T, coords: number, level: number): PrimitiveToLoadedType[T[typeof $internal]['type']];
47
+ declare function textureLoadCpu<T extends texture2d>(texture: T, coords: v2i | v2u, level: number): PrimitiveToLoadedType[T[typeof $internal]['type']];
48
+ declare function textureLoadCpu<T extends texture2dArray>(texture: T, coords: v2i | v2u, arrayIndex: number, level: number): PrimitiveToLoadedType[T[typeof $internal]['type']];
49
+ declare function textureLoadCpu<T extends texture3d>(texture: T, coords: v3i | v3u, level: number): PrimitiveToLoadedType[T[typeof $internal]['type']];
50
+ declare function textureLoadCpu<T extends textureMultisampled2d>(texture: T, coords: v2i | v2u, sampleIndex: number): PrimitiveToLoadedType[T[typeof $internal]['type']];
51
+ declare function textureLoadCpu<T extends textureDepth2d>(texture: T, coords: v2i | v2u, level: number): number;
52
+ declare function textureLoadCpu<T extends textureDepth2dArray>(texture: T, coords: v2i | v2u, arrayIndex: number, level: number): number;
53
+ declare function textureLoadCpu<T extends textureDepthMultisampled2d>(texture: T, coords: v2i | v2u, sampleIndex: number): number;
54
+ declare function textureLoadCpu<T extends textureExternal>(texture: T, coords: v2i | v2u): v4f;
55
+ declare function textureLoadCpu<T extends textureStorage1d>(texture: T, coords: number): TexelFormatToInstanceType<T[typeof $internal][0]>;
56
+ declare function textureLoadCpu<T extends textureStorage2d>(texture: T, coords: v2i | v2u): TexelFormatToInstanceType<T[typeof $internal][0]>;
57
+ declare function textureLoadCpu<T extends textureStorage2dArray>(texture: T, coords: v2i | v2u, arrayIndex: number): TexelFormatToInstanceType<T[typeof $internal][0]>;
58
+ declare function textureLoadCpu<T extends textureStorage3d>(texture: T, coords: v3i | v3u): TexelFormatToInstanceType<T[typeof $internal][0]>;
59
+ declare const textureLoad: DualFn<typeof textureLoadCpu>;
60
+ declare function textureStoreCpu<T extends textureStorage1d>(texture: T, coords: number, value: TexelFormatToInstanceType<T[typeof $internal][0]>): void;
61
+ declare function textureStoreCpu<T extends textureStorage2d>(texture: T, coords: v2i | v2u, value: TexelFormatToInstanceType<T[typeof $internal][0]>): void;
62
+ declare function textureStoreCpu<T extends textureStorage2dArray>(texture: T, coords: v2i | v2u, arrayIndex: number, value: TexelFormatToInstanceType<T[typeof $internal][0]>): void;
63
+ declare function textureStoreCpu<T extends textureStorage3d>(texture: T, coords: v3i | v3u, value: TexelFormatToInstanceType<T[typeof $internal][0]>): void;
64
+ declare const textureStore: DualFn<typeof textureStoreCpu>;
65
+ declare function textureDimensionsCpu<T extends texture1d | textureStorage1d>(texture: T): number;
66
+ declare function textureDimensionsCpu<T extends texture1d>(texture: T, level: number): number;
67
+ declare function textureDimensionsCpu<T extends texture2d | texture2dArray | textureCube | textureCubeArray | textureStorage2d | textureStorage2dArray | textureExternal>(texture: T): v2u;
68
+ declare function textureDimensionsCpu<T extends texture2d | texture2dArray | textureCube | textureCubeArray>(texture: T, level: number): v2u;
69
+ declare function textureDimensionsCpu<T extends texture3d | textureStorage3d>(texture: T): v3u;
70
+ declare function textureDimensionsCpu<T extends texture3d>(texture: T, level: number): v3u;
71
+ declare const textureDimensions: DualFn<typeof textureDimensionsCpu>;
72
+ type Gather2dArgs<T extends texture2d = texture2d> = [component: number, texture: T, sampler: sampler, coords: v2f, offset?: v2i];
73
+ type Gather2dArrayArgs<T extends texture2dArray = texture2dArray> = [component: number, texture: T, sampler: sampler, coords: v2f, arrayIndex: number, offset?: v2i];
74
+ type GatherCubeArgs<T extends textureCube = textureCube> = [component: number, texture: T, sampler: sampler, coords: v3f];
75
+ type GatherCubeArrayArgs<T extends textureCubeArray = textureCubeArray> = [component: number, texture: T, sampler: sampler, coords: v3f, arrayIndex: number];
76
+ type GatherDepth2dArgs = [texture: textureDepth2d, sampler: sampler, coords: v2f, offset?: v2i];
77
+ type GatherDepth2dArrayArgs = [texture: textureDepth2dArray, sampler: sampler, coords: v2f, arrayIndex: number, offset?: v2i];
78
+ type GatherDepthCubeArgs = [texture: textureDepthCube, sampler: sampler, coords: v3f];
79
+ type GatherDepthCubeArrayArgs = [texture: textureDepthCubeArray, sampler: sampler, coords: v3f, arrayIndex: number];
80
+ type TextureGatherCpuFn = {
81
+ <T extends texture2d>(...args: Gather2dArgs<T>): PrimitiveToLoadedType[T[typeof $internal]['type']];
82
+ <T extends texture2dArray>(...args: Gather2dArrayArgs<T>): PrimitiveToLoadedType[T[typeof $internal]['type']];
83
+ <T extends textureCube>(...args: GatherCubeArgs<T>): PrimitiveToLoadedType[T[typeof $internal]['type']];
84
+ <T extends textureCubeArray>(...args: GatherCubeArrayArgs<T>): PrimitiveToLoadedType[T[typeof $internal]['type']];
85
+ (...args: GatherDepth2dArgs): v4f;
86
+ (...args: GatherDepth2dArrayArgs): v4f;
87
+ (...args: GatherDepthCubeArgs): v4f;
88
+ (...args: GatherDepthCubeArrayArgs): v4f;
89
+ };
90
+ declare const textureGather: DualFn<TextureGatherCpuFn>;
91
+ declare function textureSampleCompareCpu<T extends textureDepth2d>(texture: T, sampler: comparisonSampler, coords: v2f, depthRef: number): number;
92
+ declare function textureSampleCompareCpu<T extends textureDepth2d>(texture: T, sampler: comparisonSampler, coords: v2f, depthRef: number, offset: v2i): number;
93
+ declare function textureSampleCompareCpu<T extends textureDepth2dArray>(texture: T, sampler: comparisonSampler, coords: v2f, arrayIndex: number, depthRef: number): number;
94
+ declare function textureSampleCompareCpu<T extends textureDepth2dArray>(texture: T, sampler: comparisonSampler, coords: v2f, arrayIndex: number, depthRef: number, offset: v2i): number;
95
+ declare function textureSampleCompareCpu<T extends textureDepthCube>(texture: T, sampler: comparisonSampler, coords: v3f, depthRef: number): number;
96
+ declare function textureSampleCompareCpu<T extends textureDepthCubeArray>(texture: T, sampler: comparisonSampler, coords: v3f, arrayIndex: number, depthRef: number): number;
97
+ declare const textureSampleCompare: DualFn<typeof textureSampleCompareCpu>;
98
+ declare function textureSampleCompareLevelCpu<T extends textureDepth2d>(texture: T, sampler: comparisonSampler, coords: v2f, depthRef: number): number;
99
+ declare function textureSampleCompareLevelCpu<T extends textureDepth2d>(texture: T, sampler: comparisonSampler, coords: v2f, depthRef: number, offset: v2i): number;
100
+ declare function textureSampleCompareLevelCpu<T extends textureDepth2dArray>(texture: T, sampler: comparisonSampler, coords: v2f, arrayIndex: number, depthRef: number): number;
101
+ declare function textureSampleCompareLevelCpu<T extends textureDepth2dArray>(texture: T, sampler: comparisonSampler, coords: v2f, arrayIndex: number, depthRef: number, offset: v2i): number;
102
+ declare function textureSampleCompareLevelCpu<T extends textureDepthCube>(texture: T, sampler: comparisonSampler, coords: v3f, depthRef: number): number;
103
+ declare function textureSampleCompareLevelCpu<T extends textureDepthCubeArray>(texture: T, sampler: comparisonSampler, coords: v3f, arrayIndex: number, depthRef: number): number;
104
+ declare const textureSampleCompareLevel: DualFn<typeof textureSampleCompareLevelCpu>;
105
+ declare function textureSampleBaseClampToEdgeCpu<T extends texture2d | textureExternal>(_texture: T, _sampler: sampler, _coords: v2f): v4f;
106
+ declare const textureSampleBaseClampToEdge: DualFn<typeof textureSampleBaseClampToEdgeCpu>;
107
+ //#endregion
108
+ export { textureDimensions, textureGather, textureLoad, textureSample, textureSampleBaseClampToEdge, textureSampleBias, textureSampleCompare, textureSampleCompareLevel, textureSampleLevel, textureStore };
package/std/texture.js ADDED
@@ -0,0 +1,197 @@
1
+ import { Void } from "../data/wgslTypes.js";
2
+ import { stitch } from "../core/resolve/stitch.js";
3
+ import { f32, i32, u32 } from "../data/numeric.js";
4
+ import { vec2u, vec3u, vec4f, vec4i, vec4u } from "../data/vector.js";
5
+ import { MissingCpuImplError, dualImpl } from "../core/function/dualImpl.js";
6
+ import { isWgslExternalTexture, isWgslTexture } from "../data/texture.js";
7
+ import { getTextureFormatInfo } from "../core/texture/textureFormats.js";
8
+
9
+ //#region src/std/texture.ts
10
+ function sampleCpu(_texture, _sampler, _coords, _offsetOrArrayIndex, _maybeOffset) {
11
+ throw new MissingCpuImplError("Texture sampling relies on GPU resources and cannot be executed outside of a draw call");
12
+ }
13
+ const textureSample = dualImpl({
14
+ name: "textureSample",
15
+ normalImpl: sampleCpu,
16
+ codegenImpl: (_ctx, args) => stitch`textureSample(${args})`,
17
+ signature: (...args) => {
18
+ return {
19
+ argTypes: args,
20
+ returnType: args[0].type.startsWith("texture_depth") ? f32 : vec4f
21
+ };
22
+ }
23
+ });
24
+ function sampleBiasCpu(_texture, _sampler, _coords, _biasOrArrayIndex, _biasOrOffset, _maybeOffset) {
25
+ throw new MissingCpuImplError("Texture sampling with bias relies on GPU resources and cannot be executed outside of a draw call");
26
+ }
27
+ const textureSampleBias = dualImpl({
28
+ name: "textureSampleBias",
29
+ normalImpl: sampleBiasCpu,
30
+ codegenImpl: (_ctx, args) => stitch`textureSampleBias(${args})`,
31
+ signature: (...args) => ({
32
+ argTypes: args,
33
+ returnType: vec4f
34
+ })
35
+ });
36
+ function sampleLevelCpu(_texture, _sampler, _coords, _level, _offsetOrArrayIndex, _maybeOffset) {
37
+ throw new MissingCpuImplError("Texture sampling relies on GPU resources and cannot be executed outside of a draw call");
38
+ }
39
+ const textureSampleLevel = dualImpl({
40
+ name: "textureSampleLevel",
41
+ normalImpl: sampleLevelCpu,
42
+ codegenImpl: (_ctx, args) => stitch`textureSampleLevel(${args})`,
43
+ signature: (...args) => {
44
+ return {
45
+ argTypes: args,
46
+ returnType: args[0].type.startsWith("texture_depth") ? f32 : vec4f
47
+ };
48
+ }
49
+ });
50
+ function textureLoadCpu(_texture, _coords, _levelOrArrayIndex) {
51
+ throw new MissingCpuImplError("`textureLoad` relies on GPU resources and cannot be executed outside of a draw call");
52
+ }
53
+ const textureLoad = dualImpl({
54
+ name: "textureLoad",
55
+ normalImpl: textureLoadCpu,
56
+ codegenImpl: (_ctx, args) => stitch`textureLoad(${args})`,
57
+ signature: (...args) => {
58
+ const texture = args[0];
59
+ if (isWgslTexture(texture)) {
60
+ const isDepth = texture.type.startsWith("texture_depth");
61
+ const sampleType = texture.sampleType;
62
+ return {
63
+ argTypes: args,
64
+ returnType: isDepth ? f32 : sampleType.type === "f32" ? vec4f : sampleType.type === "u32" ? vec4u : vec4i
65
+ };
66
+ }
67
+ if (isWgslExternalTexture(texture)) return {
68
+ argTypes: args,
69
+ returnType: vec4f
70
+ };
71
+ const format = texture.format;
72
+ return {
73
+ argTypes: args,
74
+ returnType: getTextureFormatInfo(format).vectorType
75
+ };
76
+ }
77
+ });
78
+ function textureStoreCpu(_texture, _coords, _arrayIndexOrValue, _maybeValue) {
79
+ throw new MissingCpuImplError("`textureStore` relies on GPU resources and cannot be executed outside of a draw call");
80
+ }
81
+ const textureStore = dualImpl({
82
+ name: "textureStore",
83
+ normalImpl: textureStoreCpu,
84
+ codegenImpl: (_ctx, args) => stitch`textureStore(${args})`,
85
+ signature: (...args) => ({
86
+ argTypes: args,
87
+ returnType: Void
88
+ })
89
+ });
90
+ function textureDimensionsCpu(_texture, _level) {
91
+ throw new MissingCpuImplError("`textureDimensions` relies on GPU resources and cannot be executed outside of a draw call");
92
+ }
93
+ const textureDimensions = dualImpl({
94
+ name: "textureDimensions",
95
+ normalImpl: textureDimensionsCpu,
96
+ codegenImpl: (_ctx, args) => stitch`textureDimensions(${args})`,
97
+ signature: (...args) => {
98
+ const dim = args[0].dimension;
99
+ if (dim === "1d") return {
100
+ argTypes: args,
101
+ returnType: u32
102
+ };
103
+ if (dim === "3d") return {
104
+ argTypes: args,
105
+ returnType: vec3u
106
+ };
107
+ return {
108
+ argTypes: args,
109
+ returnType: vec2u
110
+ };
111
+ }
112
+ });
113
+ const textureGatherCpu = (..._args) => {
114
+ throw new Error("Texture gather relies on GPU resources and cannot be executed outside of a draw call");
115
+ };
116
+ const sampleTypeToVecType = {
117
+ f32: vec4f,
118
+ i32: vec4i,
119
+ u32: vec4u
120
+ };
121
+ const textureGather = dualImpl({
122
+ name: "textureGather",
123
+ normalImpl: textureGatherCpu,
124
+ codegenImpl: (_ctx, args) => stitch`textureGather(${args})`,
125
+ signature: (...args) => {
126
+ if (args[0].type.startsWith("texture")) {
127
+ const [texture, sampler, coords, _, ...rest] = args;
128
+ return {
129
+ argTypes: texture.type === "texture_depth_2d_array" || texture.type === "texture_depth_cube_array" ? [
130
+ texture,
131
+ sampler,
132
+ coords,
133
+ [u32, i32],
134
+ ...rest
135
+ ] : args,
136
+ returnType: vec4f
137
+ };
138
+ }
139
+ const [_, texture, sampler, coords, ...rest] = args;
140
+ return {
141
+ argTypes: texture.type === "texture_2d_array" || texture.type === "texture_cube_array" ? [
142
+ [u32, i32],
143
+ texture,
144
+ sampler,
145
+ coords,
146
+ [u32, i32],
147
+ ...rest
148
+ ] : [
149
+ [u32, i32],
150
+ texture,
151
+ sampler,
152
+ coords,
153
+ ...rest
154
+ ],
155
+ returnType: sampleTypeToVecType[texture.sampleType.type]
156
+ };
157
+ }
158
+ });
159
+ function textureSampleCompareCpu(_texture, _sampler, _coords, _depthRefOrArrayIndex, _depthRefOrOffset, _maybeOffset) {
160
+ throw new MissingCpuImplError("Texture comparison sampling relies on GPU resources and cannot be executed outside of a draw call");
161
+ }
162
+ const textureSampleCompare = dualImpl({
163
+ name: "textureSampleCompare",
164
+ normalImpl: textureSampleCompareCpu,
165
+ codegenImpl: (_ctx, args) => stitch`textureSampleCompare(${args})`,
166
+ signature: (...args) => ({
167
+ argTypes: args,
168
+ returnType: f32
169
+ })
170
+ });
171
+ function textureSampleCompareLevelCpu(_texture, _sampler, _coords, _depthRefOrArrayIndex, _depthRefOrOffset, _maybeOffset) {
172
+ throw new MissingCpuImplError("Texture comparison sampling with level relies on GPU resources and cannot be executed outside of a draw call");
173
+ }
174
+ const textureSampleCompareLevel = dualImpl({
175
+ name: "textureSampleCompareLevel",
176
+ normalImpl: textureSampleCompareLevelCpu,
177
+ codegenImpl: (ctx, args) => stitch`textureSampleCompareLevel(${args})`,
178
+ signature: (...args) => ({
179
+ argTypes: args,
180
+ returnType: f32
181
+ })
182
+ });
183
+ function textureSampleBaseClampToEdgeCpu(_texture, _sampler, _coords) {
184
+ throw new MissingCpuImplError("Texture sampling with base clamp to edge is not supported outside of GPU mode.");
185
+ }
186
+ const textureSampleBaseClampToEdge = dualImpl({
187
+ name: "textureSampleBaseClampToEdge",
188
+ normalImpl: textureSampleBaseClampToEdgeCpu,
189
+ codegenImpl: (_ctx, args) => stitch`textureSampleBaseClampToEdge(${args})`,
190
+ signature: (...args) => ({
191
+ argTypes: args,
192
+ returnType: vec4f
193
+ })
194
+ });
195
+
196
+ //#endregion
197
+ export { textureDimensions, textureGather, textureLoad, textureSample, textureSampleBaseClampToEdge, textureSampleBias, textureSampleCompare, textureSampleCompareLevel, textureSampleLevel, textureStore };
package/tgpu.js ADDED
@@ -0,0 +1,44 @@
1
+ import { __exportAll } from "./_virtual/_rolldown/runtime.js";
2
+ import { comptime } from "./core/function/comptime.js";
3
+ import { constant } from "./core/constant/tgpuConstant.js";
4
+ import { fn } from "./core/function/tgpuFn.js";
5
+ import { bindGroupLayout } from "./tgpuBindGroupLayout.js";
6
+ import { slot } from "./core/slot/slot.js";
7
+ import { privateVar, workgroupVar } from "./core/variable/tgpuVariable.js";
8
+ import { unroll } from "./core/unroll/tgpuUnroll.js";
9
+ import { resolve, resolveWithContext } from "./core/resolve/tgpuResolve.js";
10
+ import { computeFn } from "./core/function/tgpuComputeFn.js";
11
+ import { vertexLayout } from "./core/vertexLayout/vertexLayout.js";
12
+ import { init, initFromDevice } from "./core/root/init.js";
13
+ import { lazy } from "./core/slot/lazy.js";
14
+ import { accessor, mutableAccessor } from "./core/slot/accessor.js";
15
+ import { fragmentFn } from "./core/function/tgpuFragmentFn.js";
16
+ import { vertexFn } from "./core/function/tgpuVertexFn.js";
17
+ import { tgpuUnstable_exports } from "./tgpuUnstable.js";
18
+
19
+ //#region src/tgpu.ts
20
+ var tgpu_exports = /* @__PURE__ */ __exportAll({
21
+ accessor: () => accessor,
22
+ bindGroupLayout: () => bindGroupLayout,
23
+ comptime: () => comptime,
24
+ computeFn: () => computeFn,
25
+ const: () => constant,
26
+ fn: () => fn,
27
+ fragmentFn: () => fragmentFn,
28
+ init: () => init,
29
+ initFromDevice: () => initFromDevice,
30
+ lazy: () => lazy,
31
+ mutableAccessor: () => mutableAccessor,
32
+ privateVar: () => privateVar,
33
+ resolve: () => resolve,
34
+ resolveWithContext: () => resolveWithContext,
35
+ slot: () => slot,
36
+ unroll: () => unroll,
37
+ vertexFn: () => vertexFn,
38
+ vertexLayout: () => vertexLayout,
39
+ workgroupVar: () => workgroupVar,
40
+ "~unstable": () => tgpuUnstable_exports
41
+ });
42
+
43
+ //#endregion
44
+ export { tgpu_exports };
@@ -0,0 +1,161 @@
1
+ import { TgpuNamable } from "./shared/meta.js";
2
+ import { $gpuValueOf, $internal } from "./shared/symbols.js";
3
+ import { Default, NullableToOptional, Prettify } from "./shared/utilityTypes.js";
4
+ import { WgslComparisonSampler, WgslSampler } from "./data/sampler.js";
5
+ import { StorageFlag } from "./extension.js";
6
+ import { TgpuBufferMutable, TgpuBufferReadonly, TgpuBufferUniform } from "./core/buffer/bufferUsage.js";
7
+ import { SampledFlag } from "./core/texture/usageExtension.js";
8
+ import { Unwrapper } from "./unwrapper.js";
9
+ import { TgpuComparisonSampler, TgpuSampler } from "./core/sampler/sampler.js";
10
+ import { TgpuExternalTexture } from "./core/texture/externalTexture.js";
11
+ import { TgpuBuffer, UniformFlag } from "./core/buffer/buffer.js";
12
+ import { TgpuShaderStage } from "./types.js";
13
+ import { AnyWgslData, BaseData, F32, I32, U32 } from "./data/wgslTypes.js";
14
+ import { StorageTextureFormats } from "./core/texture/textureFormats.js";
15
+ import { StorageTextureDimension, TextureSchemaForDescriptor, WgslExternalTexture, WgslStorageTexture, WgslTexture } from "./data/texture.js";
16
+ import { PropsForSchema, TgpuTexture, TgpuTextureView } from "./core/texture/texture.js";
17
+ import { InferGPU, MemIdentity } from "./shared/repr.js";
18
+
19
+ //#region src/tgpuBindGroupLayout.d.ts
20
+ type TgpuLayoutEntryBase = {
21
+ /**
22
+ * Limits this resource's visibility to specific shader stages.
23
+ *
24
+ * By default, each resource is visible to all shader stage types, but
25
+ * depending on the underlying implementation, this may have performance implications.
26
+ *
27
+ * @default ['compute','fragment'] for mutable resources
28
+ * @default ['compute','vertex','fragment'] for everything else
29
+ */
30
+ visibility?: TgpuShaderStage[];
31
+ };
32
+ type TgpuLayoutUniform = TgpuLayoutEntryBase & {
33
+ uniform: BaseData;
34
+ };
35
+ type TgpuLayoutStorage = TgpuLayoutEntryBase & {
36
+ storage: BaseData | ((arrayLength: number) => BaseData); /** @default 'readonly' */
37
+ access?: 'mutable' | 'readonly';
38
+ };
39
+ type TgpuLayoutSampler = TgpuLayoutEntryBase & {
40
+ sampler: 'filtering' | 'non-filtering';
41
+ };
42
+ type TgpuLayoutComparisonSampler = TgpuLayoutEntryBase & {
43
+ sampler: 'comparison';
44
+ };
45
+ type TgpuLayoutTexture<TSchema extends WgslTexture = WgslTexture> = TgpuLayoutEntryBase & {
46
+ texture: TSchema;
47
+ sampleType?: GPUTextureSampleType;
48
+ };
49
+ type TgpuLayoutStorageTexture<TSchema extends WgslStorageTexture = WgslStorageTexture> = TgpuLayoutEntryBase & {
50
+ storageTexture: TSchema;
51
+ };
52
+ type TgpuLayoutExternalTexture = TgpuLayoutEntryBase & {
53
+ externalTexture: WgslExternalTexture;
54
+ };
55
+ type TgpuLegacyLayoutTexture<TSampleType extends GPUTextureSampleType = GPUTextureSampleType> = TgpuLayoutEntryBase & {
56
+ /**
57
+ * - 'float' - f32
58
+ * - 'unfilterable-float' - f32, cannot be used with filtering samplers
59
+ * - 'depth' - f32
60
+ * - 'sint' - i32
61
+ * - 'uint' - u32
62
+ */
63
+ texture: TSampleType;
64
+ /**
65
+ * @default '2d'
66
+ */
67
+ viewDimension?: GPUTextureViewDimension;
68
+ /**
69
+ * @default false
70
+ */
71
+ multisampled?: boolean;
72
+ };
73
+ type TgpuLegacyLayoutStorageTexture<TFormat extends StorageTextureFormats = StorageTextureFormats> = TgpuLayoutEntryBase & {
74
+ storageTexture: TFormat; /** @default 'writeonly' */
75
+ access?: 'readonly' | 'writeonly' | 'mutable'; /** @default '2d' */
76
+ viewDimension?: StorageTextureDimension;
77
+ };
78
+ type TgpuLegacyLayoutExternalTexture = TgpuLayoutEntryBase & {
79
+ externalTexture: Record<string, never>;
80
+ };
81
+ type TgpuLegacyLayoutEntry = TgpuLayoutUniform | TgpuLayoutStorage | TgpuLayoutSampler | TgpuLayoutComparisonSampler | TgpuLegacyLayoutTexture | TgpuLegacyLayoutStorageTexture | TgpuLegacyLayoutExternalTexture;
82
+ type TgpuLayoutEntry = TgpuLayoutUniform | TgpuLayoutStorage | TgpuLayoutSampler | TgpuLayoutComparisonSampler | TgpuLayoutTexture | TgpuLayoutStorageTexture | TgpuLayoutExternalTexture;
83
+ type SampleTypeToPrimitive = {
84
+ float: F32;
85
+ 'unfilterable-float': F32;
86
+ depth: F32;
87
+ sint: I32;
88
+ uint: U32;
89
+ };
90
+ type LeagcyAccessToAccess = {
91
+ writeonly: 'write-only';
92
+ readonly: 'read-only';
93
+ mutable: 'read-write';
94
+ };
95
+ type MapLegacyTextureToUpToDate<T extends Record<string, TgpuLegacyLayoutEntry | TgpuLayoutEntry | null>> = { [K in keyof T]: T[K] extends TgpuLayoutEntry | null ? T[K] : T[K] extends TgpuLegacyLayoutTexture<infer SampleType> ? TgpuLayoutTexture<TextureSchemaForDescriptor<{
96
+ dimension: Default<T[K]['viewDimension'], '2d'>;
97
+ sampleType: SampleTypeToPrimitive[SampleType];
98
+ multisampled: Default<T[K]['multisampled'], false>;
99
+ }>> : T[K] extends TgpuLegacyLayoutStorageTexture<infer Format> ? TgpuLayoutStorageTexture<TextureSchemaForDescriptor<{
100
+ access: LeagcyAccessToAccess[Default<T[K]['access'], 'writeonly'>];
101
+ format: Format;
102
+ dimension: Default<T[K]['viewDimension'], '2d'>;
103
+ }>> : T[K] extends TgpuLegacyLayoutExternalTexture ? TgpuLayoutExternalTexture : never };
104
+ type UnwrapRuntimeConstructorInner<T extends BaseData | ((_: number) => BaseData)> = T extends ((_: number) => BaseData) ? ReturnType<T> : T;
105
+ type UnwrapRuntimeConstructor<T extends BaseData | ((_: number) => BaseData)> = T extends unknown ? UnwrapRuntimeConstructorInner<T> : never;
106
+ interface BindGroupLayoutInternals<Entries extends Record<string, TgpuLayoutEntry | null>> {
107
+ bound: { [K in keyof Entries]: BindLayoutEntry<Entries[K]> };
108
+ }
109
+ interface TgpuBindGroupLayout<Entries extends Record<string, TgpuLayoutEntry | null> = Record<string, TgpuLayoutEntry | null>> extends TgpuNamable {
110
+ readonly [$internal]: BindGroupLayoutInternals<Entries>;
111
+ readonly resourceType: 'bind-group-layout';
112
+ readonly entries: Entries;
113
+ /**
114
+ * @deprecated Use `layout.$.foo` instead of `layout.bound.foo.$`
115
+ */
116
+ readonly bound: { [K in keyof Entries]: BindLayoutEntry<Entries[K]> };
117
+ readonly [$gpuValueOf]: { [K in keyof Entries]: InferLayoutEntry<Entries[K]> };
118
+ /**
119
+ * @deprecated Use `.$` instead, works the same way.
120
+ */
121
+ readonly value: { [K in keyof Entries]: InferLayoutEntry<Entries[K]> };
122
+ readonly $: { [K in keyof Entries]: InferLayoutEntry<Entries[K]> };
123
+ /**
124
+ * An explicit numeric index assigned to this bind group layout. If undefined, a unique
125
+ * index is assigned automatically during resolution. This can be changed with the
126
+ * `.$idx()` method.
127
+ */
128
+ readonly index: number | undefined;
129
+ /**
130
+ * Associates this bind group layout with an explicit numeric index. When a call to this
131
+ * method is omitted, a unique numeric index is assigned to it automatically.
132
+ *
133
+ * Used when generating WGSL code: `@group(${index}) @binding(...) ...;`
134
+ */
135
+ $idx(index?: number): this;
136
+ /**
137
+ * Creates a raw WebGPU resource based on the typed descriptor.
138
+ * NOTE: This creates a new resource every time, better to use `root.unwrap(...)` instead.
139
+ * @param unwrapper Used to unwrap any resources that this resource depends on.
140
+ */
141
+ unwrap(unwrapper: Unwrapper): GPUBindGroupLayout;
142
+ }
143
+ type StorageUsageForEntry<T extends TgpuLayoutStorage> = T extends {
144
+ access?: infer Access;
145
+ } ? 'mutable' | 'readonly' extends Access ? TgpuBufferReadonly<UnwrapRuntimeConstructor<T['storage']>> | TgpuBufferMutable<UnwrapRuntimeConstructor<T['storage']>> : 'readonly' extends Access ? TgpuBufferReadonly<UnwrapRuntimeConstructor<T['storage']>> : 'mutable' extends Access ? TgpuBufferMutable<UnwrapRuntimeConstructor<T['storage']>> : TgpuBufferReadonly<UnwrapRuntimeConstructor<T['storage']>> | TgpuBufferMutable<UnwrapRuntimeConstructor<T['storage']>> : TgpuBufferReadonly<UnwrapRuntimeConstructor<T['storage']>>;
146
+ type LayoutEntryToInput<T extends TgpuLayoutEntry | null> = TgpuLayoutEntry | null extends T ? TgpuBuffer<AnyWgslData> | GPUBuffer | TgpuSampler | GPUSampler | TgpuComparisonSampler | TgpuTexture | GPUTextureView | GPUExternalTexture : T extends TgpuLayoutUniform ? (TgpuBuffer<MemIdentity<UnwrapRuntimeConstructor<T['uniform']>>> & UniformFlag) | GPUBuffer : T extends TgpuLayoutStorage ? (TgpuBuffer<MemIdentity<UnwrapRuntimeConstructor<T['storage']>>> & StorageFlag) | GPUBuffer : T extends TgpuLayoutSampler ? TgpuSampler | GPUSampler : T extends TgpuLayoutComparisonSampler ? TgpuComparisonSampler | GPUSampler : T extends TgpuLayoutTexture ? GPUTextureView | GPUTexture | (SampledFlag & TgpuTexture<Prettify<PropsForSchema<T['texture']>>>) | TgpuTextureView<WgslTexture> : T extends TgpuLayoutStorageTexture ? GPUTextureView | GPUTexture | (StorageFlag & TgpuTexture<Prettify<PropsForSchema<T['storageTexture']>>>) | TgpuTextureView<WgslStorageTexture> : T extends TgpuLayoutExternalTexture ? GPUExternalTexture : never;
147
+ type BindLayoutEntry<T extends TgpuLayoutEntry | null> = T extends TgpuLayoutUniform ? TgpuBufferUniform<T['uniform']> : T extends TgpuLayoutStorage ? StorageUsageForEntry<T> : T extends TgpuLayoutSampler ? TgpuSampler : T extends TgpuLayoutComparisonSampler ? TgpuComparisonSampler : T extends TgpuLayoutTexture<infer TSchema> ? TgpuTextureView<TSchema> : T extends TgpuLayoutStorageTexture<infer TSchema> ? TgpuTextureView<TSchema> : T extends TgpuLayoutExternalTexture ? TgpuExternalTexture : never;
148
+ type InferLayoutEntry<T extends TgpuLayoutEntry | null> = T extends TgpuLayoutUniform ? InferGPU<T['uniform']> : T extends TgpuLayoutStorage ? InferGPU<UnwrapRuntimeConstructor<T['storage']>> : T extends TgpuLayoutSampler ? InferGPU<WgslSampler> : T extends TgpuLayoutComparisonSampler ? InferGPU<WgslComparisonSampler> : T extends TgpuLayoutTexture<infer TSchema> ? InferGPU<TSchema> : T extends TgpuLayoutStorageTexture<infer TSchema> ? InferGPU<TSchema> : T extends TgpuLayoutExternalTexture ? InferGPU<T['externalTexture']> : never;
149
+ type ExtractBindGroupInputFromLayout<T extends Record<string, TgpuLayoutEntry | null>> = NullableToOptional<{ [K in keyof T]: LayoutEntryToInput<T[K]> }>;
150
+ type TgpuBindGroup<Entries extends Record<string, TgpuLayoutEntry | null> = Record<string, TgpuLayoutEntry | null>> = {
151
+ readonly resourceType: 'bind-group';
152
+ readonly layout: TgpuBindGroupLayout<Entries>;
153
+ unwrap(unwrapper: Unwrapper): GPUBindGroup;
154
+ };
155
+ declare function bindGroupLayout<Entries extends Record<string, TgpuLayoutEntry | null>>(entries: Entries): TgpuBindGroupLayout<Prettify<Entries>>;
156
+ /**
157
+ * @deprecated Layouts containing the legacy texture api entries are deprecated and will be removed in future versions. Please use the up-to-date texture api entries instead.
158
+ */
159
+ declare function bindGroupLayout<Entries extends Record<string, TgpuLegacyLayoutEntry | null>>(entries: Entries): TgpuBindGroupLayout<Prettify<MapLegacyTextureToUpToDate<Entries>>>;
160
+ //#endregion
161
+ export { BindLayoutEntry, ExtractBindGroupInputFromLayout, LayoutEntryToInput, TgpuBindGroup, TgpuBindGroupLayout, TgpuLayoutComparisonSampler, TgpuLayoutEntry, TgpuLayoutExternalTexture, TgpuLayoutSampler, TgpuLayoutStorage, TgpuLayoutTexture, TgpuLayoutUniform, UnwrapRuntimeConstructor, bindGroupLayout };