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,292 @@
1
+ import { $internal, $repr } from "../shared/symbols.js";
2
+ import { WithDefaults } from "../shared/utilityTypes.js";
3
+ import { BaseData, F32, TextureSampleTypes } from "./wgslTypes.js";
4
+ import { StorageTextureFormats } from "../core/texture/textureFormats.js";
5
+
6
+ //#region src/data/texture.d.ts
7
+ type StorageTextureDimension = '1d' | '2d' | '2d-array' | '3d';
8
+ type WgslTextureProps = {
9
+ dimension: GPUTextureViewDimension;
10
+ sampleType: TextureSampleTypes;
11
+ multisampled: boolean;
12
+ };
13
+ type WgslStorageTextureProps = {
14
+ dimension: StorageTextureDimension;
15
+ format: StorageTextureFormats;
16
+ access: GPUStorageTextureAccess;
17
+ };
18
+ type ResolvedTextureProps<TProps extends Partial<WgslTextureProps>> = WithDefaults<TProps, WgslTextureProps>;
19
+ type ResolvedStorageTextureProps<TProps extends Partial<WgslStorageTextureProps>> = WithDefaults<TProps, WgslStorageTextureProps>;
20
+ type SampledTextureLiteral = `texture_${'1d' | '2d' | '2d_array' | '3d' | 'cube' | 'cube_array' | 'multisampled_2d' | 'depth_multisampled_2d' | 'depth_2d' | 'depth_2d_array' | 'depth_cube' | 'depth_cube_array'}`;
21
+ type StorageTextureLiteral = `texture_storage_${'1d' | '2d' | '2d_array' | '3d'}`;
22
+ interface WgslTexture<TProps extends Partial<WgslTextureProps> = WgslTextureProps> extends BaseData {
23
+ readonly [$repr]: unknown;
24
+ readonly type: SampledTextureLiteral;
25
+ readonly sampleType: ResolvedTextureProps<TProps>['sampleType'];
26
+ readonly dimension: ResolvedTextureProps<TProps>['dimension'];
27
+ readonly multisampled: ResolvedTextureProps<TProps>['multisampled'];
28
+ readonly bindingSampleType: [GPUTextureSampleType, ...GPUTextureSampleType[]];
29
+ }
30
+ interface WgslStorageTexture<TProps extends Partial<WgslStorageTextureProps> = WgslStorageTextureProps> extends BaseData {
31
+ readonly [$repr]: unknown;
32
+ readonly type: StorageTextureLiteral;
33
+ readonly format: ResolvedStorageTextureProps<TProps>['format'];
34
+ readonly dimension: ResolvedStorageTextureProps<TProps>['dimension'];
35
+ readonly access: ResolvedStorageTextureProps<TProps>['access'];
36
+ }
37
+ interface WgslExternalTexture extends BaseData {
38
+ readonly [$repr]: textureExternal;
39
+ readonly type: 'texture_external';
40
+ readonly dimension: '2d';
41
+ }
42
+ interface WgslTexture1d<TSample extends TextureSampleTypes = TextureSampleTypes> extends WgslTexture<{
43
+ dimension: '1d';
44
+ sampleType: TSample;
45
+ multisampled: false;
46
+ }> {
47
+ readonly type: 'texture_1d';
48
+ readonly [$repr]: texture1d<TSample>;
49
+ }
50
+ interface WgslTexture2d<TSample extends TextureSampleTypes = TextureSampleTypes> extends WgslTexture<{
51
+ dimension: '2d';
52
+ sampleType: TSample;
53
+ multisampled: false;
54
+ }> {
55
+ readonly type: 'texture_2d';
56
+ readonly [$repr]: texture2d<TSample>;
57
+ }
58
+ interface WgslTextureMultisampled2d<TSample extends TextureSampleTypes = TextureSampleTypes> extends WgslTexture<{
59
+ dimension: '2d';
60
+ sampleType: TSample;
61
+ multisampled: true;
62
+ }> {
63
+ readonly type: 'texture_multisampled_2d';
64
+ readonly [$repr]: textureMultisampled2d<TSample>;
65
+ }
66
+ interface WgslTexture2dArray<TSample extends TextureSampleTypes = TextureSampleTypes> extends WgslTexture<{
67
+ dimension: '2d-array';
68
+ sampleType: TSample;
69
+ multisampled: false;
70
+ }> {
71
+ readonly type: 'texture_2d_array';
72
+ readonly [$repr]: texture2dArray<TSample>;
73
+ }
74
+ interface WgslTextureCube<TSample extends TextureSampleTypes = TextureSampleTypes> extends WgslTexture<{
75
+ dimension: 'cube';
76
+ sampleType: TSample;
77
+ multisampled: false;
78
+ }> {
79
+ readonly type: 'texture_cube';
80
+ readonly [$repr]: textureCube<TSample>;
81
+ }
82
+ interface WgslTextureCubeArray<TSample extends TextureSampleTypes = TextureSampleTypes> extends WgslTexture<{
83
+ dimension: 'cube-array';
84
+ sampleType: TSample;
85
+ multisampled: false;
86
+ }> {
87
+ readonly type: 'texture_cube_array';
88
+ readonly [$repr]: textureCubeArray<TSample>;
89
+ }
90
+ interface WgslTexture3d<TSample extends TextureSampleTypes = TextureSampleTypes> extends WgslTexture<{
91
+ dimension: '3d';
92
+ sampleType: TSample;
93
+ multisampled: false;
94
+ }> {
95
+ readonly type: 'texture_3d';
96
+ readonly [$repr]: texture3d<TSample>;
97
+ }
98
+ interface WgslTextureDepth2d extends WgslTexture<{
99
+ dimension: '2d';
100
+ sampleType: F32;
101
+ multisampled: false;
102
+ }> {
103
+ readonly type: 'texture_depth_2d';
104
+ readonly [$repr]: textureDepth2d;
105
+ }
106
+ interface WgslTextureDepthMultisampled2d extends WgslTexture<{
107
+ dimension: '2d';
108
+ sampleType: F32;
109
+ multisampled: true;
110
+ }> {
111
+ readonly type: 'texture_depth_multisampled_2d';
112
+ readonly [$repr]: textureDepthMultisampled2d;
113
+ }
114
+ interface WgslTextureDepth2dArray extends WgslTexture<{
115
+ dimension: '2d-array';
116
+ sampleType: F32;
117
+ multisampled: false;
118
+ }> {
119
+ readonly type: 'texture_depth_2d_array';
120
+ readonly [$repr]: textureDepth2dArray;
121
+ }
122
+ interface WgslTextureDepthCube extends WgslTexture<{
123
+ dimension: 'cube';
124
+ sampleType: F32;
125
+ multisampled: false;
126
+ }> {
127
+ readonly type: 'texture_depth_cube';
128
+ readonly [$repr]: textureDepthCube;
129
+ }
130
+ interface WgslTextureDepthCubeArray extends WgslTexture<{
131
+ dimension: 'cube-array';
132
+ sampleType: F32;
133
+ multisampled: false;
134
+ }> {
135
+ readonly type: 'texture_depth_cube_array';
136
+ readonly [$repr]: textureDepthCubeArray;
137
+ }
138
+ interface WgslStorageTexture1d<TFormat extends StorageTextureFormats = StorageTextureFormats, TAccess extends GPUStorageTextureAccess = GPUStorageTextureAccess> extends WgslStorageTexture<{
139
+ dimension: '1d';
140
+ format: TFormat;
141
+ access: TAccess;
142
+ }> {
143
+ readonly type: 'texture_storage_1d';
144
+ readonly [$repr]: textureStorage1d<TFormat, TAccess>;
145
+ }
146
+ interface WgslStorageTexture2d<TFormat extends StorageTextureFormats = StorageTextureFormats, TAccess extends GPUStorageTextureAccess = GPUStorageTextureAccess> extends WgslStorageTexture<{
147
+ dimension: '2d';
148
+ format: TFormat;
149
+ access: TAccess;
150
+ }> {
151
+ readonly type: 'texture_storage_2d';
152
+ readonly [$repr]: textureStorage2d<TFormat, TAccess>;
153
+ }
154
+ interface WgslStorageTexture2dArray<TFormat extends StorageTextureFormats = StorageTextureFormats, TAccess extends GPUStorageTextureAccess = GPUStorageTextureAccess> extends WgslStorageTexture<{
155
+ dimension: '2d-array';
156
+ format: TFormat;
157
+ access: TAccess;
158
+ }> {
159
+ readonly type: 'texture_storage_2d_array';
160
+ readonly [$repr]: textureStorage2dArray<TFormat, TAccess>;
161
+ }
162
+ interface WgslStorageTexture3d<TFormat extends StorageTextureFormats = StorageTextureFormats, TAccess extends GPUStorageTextureAccess = GPUStorageTextureAccess> extends WgslStorageTexture<{
163
+ dimension: '3d';
164
+ format: TFormat;
165
+ access: TAccess;
166
+ }> {
167
+ readonly type: 'texture_storage_3d';
168
+ readonly [$repr]: textureStorage3d<TFormat, TAccess>;
169
+ }
170
+ type SampledTextureSchemaMap<T extends WgslTextureProps> = {
171
+ multisampled: {
172
+ '1d': never;
173
+ '2d': WgslTextureMultisampled2d<T['sampleType']>;
174
+ '2d-array': never;
175
+ '3d': never;
176
+ cube: never;
177
+ 'cube-array': never;
178
+ };
179
+ sampled: {
180
+ '1d': WgslTexture1d<T['sampleType']>;
181
+ '2d': WgslTexture2d<T['sampleType']>;
182
+ '2d-array': WgslTexture2dArray<T['sampleType']>;
183
+ '3d': WgslTexture3d<T['sampleType']>;
184
+ cube: WgslTextureCube<T['sampleType']>;
185
+ 'cube-array': WgslTextureCubeArray<T['sampleType']>;
186
+ };
187
+ };
188
+ type StorageTextureSchemaMap<T extends WgslStorageTextureProps> = {
189
+ '1d': WgslStorageTexture1d<T['format'], T['access']>;
190
+ '2d': WgslStorageTexture2d<T['format'], T['access']>;
191
+ '2d-array': WgslStorageTexture2dArray<T['format'], T['access']>;
192
+ '3d': WgslStorageTexture3d<T['format'], T['access']>;
193
+ };
194
+ type TextureSchemaForDescriptor<T extends WgslTextureProps | WgslStorageTextureProps> = T extends WgslTextureProps ? T['multisampled'] extends true ? SampledTextureSchemaMap<T>['multisampled'][T['dimension']] : SampledTextureSchemaMap<T>['sampled'][T['dimension']] : T extends WgslStorageTextureProps ? StorageTextureSchemaMap<T>[T['dimension']] : never;
195
+ interface texture1d<T extends TextureSampleTypes = TextureSampleTypes> {
196
+ readonly kind: `texture_1d<${T['type']}>`;
197
+ [$internal]: T;
198
+ }
199
+ declare function texture1d<T extends TextureSampleTypes>(sampleType: T): WgslTexture1d<T>;
200
+ declare function texture1d(): WgslTexture1d<F32>;
201
+ interface texture2d<T extends TextureSampleTypes = TextureSampleTypes> {
202
+ readonly kind: `texture_2d<${T['type']}>`;
203
+ [$internal]: T;
204
+ }
205
+ declare function texture2d<T extends TextureSampleTypes>(sampleType: T): WgslTexture2d<T>;
206
+ declare function texture2d(): WgslTexture2d<F32>;
207
+ interface textureMultisampled2d<T extends TextureSampleTypes = TextureSampleTypes> {
208
+ readonly kind: `texture_multisampled_2d<${T['type']}>`;
209
+ [$internal]: T;
210
+ }
211
+ declare function textureMultisampled2d<T extends TextureSampleTypes>(sampleType: T): WgslTextureMultisampled2d<T>;
212
+ declare function textureMultisampled2d(): WgslTextureMultisampled2d<F32>;
213
+ interface texture2dArray<T extends TextureSampleTypes = TextureSampleTypes> {
214
+ readonly kind: `texture_2d_array<${T['type']}>`;
215
+ [$internal]: T;
216
+ }
217
+ declare function texture2dArray<T extends TextureSampleTypes>(sampleType: T): WgslTexture2dArray<T>;
218
+ declare function texture2dArray(): WgslTexture2dArray<F32>;
219
+ interface textureCube<T extends TextureSampleTypes = TextureSampleTypes> {
220
+ readonly kind: `texture_cube<${T['type']}>`;
221
+ [$internal]: T;
222
+ }
223
+ declare function textureCube<T extends TextureSampleTypes>(sampleType: T): WgslTextureCube<T>;
224
+ declare function textureCube(): WgslTextureCube<F32>;
225
+ interface textureCubeArray<T extends TextureSampleTypes = TextureSampleTypes> {
226
+ readonly kind: `texture_cube_array<${T['type']}>`;
227
+ [$internal]: T;
228
+ }
229
+ declare function textureCubeArray<T extends TextureSampleTypes>(sampleType: T): WgslTextureCubeArray<T>;
230
+ declare function textureCubeArray(): WgslTextureCubeArray<F32>;
231
+ interface texture3d<T extends TextureSampleTypes = TextureSampleTypes> {
232
+ readonly kind: `texture_3d<${T['type']}>`;
233
+ [$internal]: T;
234
+ }
235
+ declare function texture3d<T extends TextureSampleTypes>(sampleType: T): WgslTexture3d<T>;
236
+ declare function texture3d(): WgslTexture3d<F32>;
237
+ interface textureStorage1d<TFormat extends StorageTextureFormats = StorageTextureFormats, TAccess extends GPUStorageTextureAccess = GPUStorageTextureAccess> {
238
+ readonly kind: `texture_storage_1d<${TFormat}, ${TAccess}>`;
239
+ [$internal]: [TFormat, TAccess];
240
+ }
241
+ declare function textureStorage1d<TFormat extends StorageTextureFormats, TAccess extends GPUStorageTextureAccess>(format: TFormat, access: TAccess): WgslStorageTexture1d<TFormat, TAccess>;
242
+ declare function textureStorage1d<TFormat extends StorageTextureFormats>(format: TFormat): WgslStorageTexture1d<TFormat, 'write-only'>;
243
+ interface textureStorage2d<TFormat extends StorageTextureFormats = StorageTextureFormats, TAccess extends GPUStorageTextureAccess = GPUStorageTextureAccess> {
244
+ readonly kind: `texture_storage_2d<${TFormat}, ${TAccess}>`;
245
+ [$internal]: [TFormat, TAccess];
246
+ }
247
+ declare function textureStorage2d<TFormat extends StorageTextureFormats, TAccess extends GPUStorageTextureAccess>(format: TFormat, access: TAccess): WgslStorageTexture2d<TFormat, TAccess>;
248
+ declare function textureStorage2d<TFormat extends StorageTextureFormats>(format: TFormat): WgslStorageTexture2d<TFormat, 'write-only'>;
249
+ interface textureStorage2dArray<TFormat extends StorageTextureFormats = StorageTextureFormats, TAccess extends GPUStorageTextureAccess = GPUStorageTextureAccess> {
250
+ readonly kind: `texture_storage_2d_array<${TFormat}, ${TAccess}>`;
251
+ [$internal]: [TFormat, TAccess];
252
+ }
253
+ declare function textureStorage2dArray<TFormat extends StorageTextureFormats, TAccess extends GPUStorageTextureAccess>(format: TFormat, access: TAccess): WgslStorageTexture2dArray<TFormat, TAccess>;
254
+ declare function textureStorage2dArray<TFormat extends StorageTextureFormats>(format: TFormat): WgslStorageTexture2dArray<TFormat, 'write-only'>;
255
+ interface textureStorage3d<TFormat extends StorageTextureFormats = StorageTextureFormats, TAccess extends GPUStorageTextureAccess = GPUStorageTextureAccess> {
256
+ readonly kind: `texture_storage_3d<${TFormat}, ${TAccess}>`;
257
+ [$internal]: [TFormat, TAccess];
258
+ }
259
+ declare function textureStorage3d<TFormat extends StorageTextureFormats, TAccess extends GPUStorageTextureAccess>(format: TFormat, access: TAccess): WgslStorageTexture3d<TFormat, TAccess>;
260
+ declare function textureStorage3d<TFormat extends StorageTextureFormats>(format: TFormat): WgslStorageTexture3d<TFormat, 'write-only'>;
261
+ interface textureDepth2d {
262
+ readonly kind: 'texture_depth_2d';
263
+ [$internal]: F32;
264
+ }
265
+ declare function textureDepth2d(): WgslTextureDepth2d;
266
+ interface textureDepthMultisampled2d {
267
+ readonly kind: 'texture_depth_multisampled_2d';
268
+ [$internal]: F32;
269
+ }
270
+ declare function textureDepthMultisampled2d(): WgslTextureDepthMultisampled2d;
271
+ interface textureDepth2dArray {
272
+ readonly kind: 'texture_depth_2d_array';
273
+ [$internal]: F32;
274
+ }
275
+ declare function textureDepth2dArray(): WgslTextureDepth2dArray;
276
+ interface textureDepthCube {
277
+ readonly kind: 'texture_depth_cube';
278
+ [$internal]: F32;
279
+ }
280
+ declare function textureDepthCube(): WgslTextureDepthCube;
281
+ interface textureDepthCubeArray {
282
+ readonly kind: 'texture_depth_cube_array';
283
+ [$internal]: F32;
284
+ }
285
+ declare function textureDepthCubeArray(): WgslTextureDepthCubeArray;
286
+ interface textureExternal {
287
+ readonly kind: 'texture_external';
288
+ [$internal]: true;
289
+ }
290
+ declare function textureExternal(): WgslExternalTexture;
291
+ //#endregion
292
+ export { StorageTextureDimension, TextureSchemaForDescriptor, WgslExternalTexture, WgslStorageTexture, WgslStorageTexture1d, WgslStorageTexture2d, WgslStorageTexture2dArray, WgslStorageTexture3d, WgslStorageTextureProps, WgslTexture, WgslTexture1d, WgslTexture2d, WgslTexture2dArray, WgslTexture3d, WgslTextureCube, WgslTextureCubeArray, WgslTextureDepth2d, WgslTextureDepth2dArray, WgslTextureDepthCube, WgslTextureDepthCubeArray, WgslTextureDepthMultisampled2d, WgslTextureMultisampled2d, texture1d, texture2d, texture2dArray, texture3d, textureCube, textureCubeArray, textureDepth2d, textureDepth2dArray, textureDepthCube, textureDepthCubeArray, textureDepthMultisampled2d, textureExternal, textureMultisampled2d, textureStorage1d, textureStorage2d, textureStorage2dArray, textureStorage3d };
@@ -1,4 +1,5 @@
1
- import { cr as $internal, dr as $repr, it as f32 } from "./operators-HTxa_0k9.js";
1
+ import { $internal, $repr } from "../shared/symbols.js";
2
+ import { f32 } from "./numeric.js";
2
3
 
3
4
  //#region src/data/texture.ts
4
5
  function textureDescriptorToSchema(desc) {
@@ -199,7 +200,9 @@ function isWgslTexture(value) {
199
200
  function isWgslStorageTexture(value) {
200
201
  return !!value[$internal] && typeof value.format === "string" && typeof value.access === "string";
201
202
  }
203
+ function isWgslExternalTexture(value) {
204
+ return !!value[$internal] && value.type === "texture_external";
205
+ }
202
206
 
203
207
  //#endregion
204
- export { textureMultisampled2d as _, texture2d as a, textureStorage2dArray as b, textureCube as c, textureDepth2dArray as d, textureDepthCube as f, textureExternal as g, textureDescriptorToSchema as h, texture1d as i, textureCubeArray as l, textureDepthMultisampled2d as m, isWgslStorageTexture as n, texture2dArray as o, textureDepthCubeArray as p, isWgslTexture as r, texture3d as s, accessModeMap as t, textureDepth2d as u, textureStorage1d as v, textureStorage3d as x, textureStorage2d as y };
205
- //# sourceMappingURL=texture-Dg5ybJro.js.map
208
+ export { accessModeMap, isWgslExternalTexture, isWgslStorageTexture, isWgslTexture, texture1d, texture2d, texture2dArray, texture3d, textureCube, textureCubeArray, textureDepth2d, textureDepth2dArray, textureDepthCube, textureDepthCubeArray, textureDepthMultisampled2d, textureDescriptorToSchema, textureExternal, textureMultisampled2d, textureStorage1d, textureStorage2d, textureStorage2dArray, textureStorage3d };
@@ -0,0 +1,24 @@
1
+ import { AnyData, Unstruct } from "./dataTypes.js";
2
+
3
+ //#region src/data/unstruct.d.ts
4
+ /**
5
+ * Creates a loose struct schema that can be used to construct vertex buffers.
6
+ * Describes structs with members of both loose and non-loose types.
7
+ *
8
+ * The order of members matches the passed in properties object.
9
+ * Members are not aligned in respect to their `byteAlignment`,
10
+ * unless they are explicitly decorated with the custom align attribute
11
+ * via `d.align` function.
12
+ *
13
+ * @example
14
+ * const CircleStruct = d.unstruct({ radius: d.f32, pos: d.vec3f }); // packed struct with no padding
15
+ *
16
+ * @example
17
+ * const CircleStruct = d.unstruct({ radius: d.f32, pos: d.align(16, d.vec3f) });
18
+ *
19
+ * @param properties Record with `string` keys and `TgpuData` or `TgpuLooseData` values,
20
+ * each entry describing one struct member.
21
+ */
22
+ declare function unstruct<TProps extends Record<string, AnyData>>(properties: TProps): Unstruct<TProps>;
23
+ //#endregion
24
+ export { unstruct };
@@ -0,0 +1,43 @@
1
+ import { $internal } from "../shared/symbols.js";
2
+ import { getName, setName } from "../shared/meta.js";
3
+ import { schemaCallWrapper } from "./schemaCallWrapper.js";
4
+
5
+ //#region src/data/unstruct.ts
6
+ /**
7
+ * Creates a loose struct schema that can be used to construct vertex buffers.
8
+ * Describes structs with members of both loose and non-loose types.
9
+ *
10
+ * The order of members matches the passed in properties object.
11
+ * Members are not aligned in respect to their `byteAlignment`,
12
+ * unless they are explicitly decorated with the custom align attribute
13
+ * via `d.align` function.
14
+ *
15
+ * @example
16
+ * const CircleStruct = d.unstruct({ radius: d.f32, pos: d.vec3f }); // packed struct with no padding
17
+ *
18
+ * @example
19
+ * const CircleStruct = d.unstruct({ radius: d.f32, pos: d.align(16, d.vec3f) });
20
+ *
21
+ * @param properties Record with `string` keys and `TgpuData` or `TgpuLooseData` values,
22
+ * each entry describing one struct member.
23
+ */
24
+ function unstruct(properties) {
25
+ const unstructSchema = (instanceProps) => Object.fromEntries(Object.entries(properties).map(([key, schema]) => [key, schemaCallWrapper(schema, instanceProps?.[key])]));
26
+ Object.setPrototypeOf(unstructSchema, UnstructImpl);
27
+ unstructSchema.propTypes = properties;
28
+ return unstructSchema;
29
+ }
30
+ const UnstructImpl = {
31
+ [$internal]: true,
32
+ type: "unstruct",
33
+ $name(label) {
34
+ setName(this, label);
35
+ return this;
36
+ },
37
+ toString() {
38
+ return `unstruct:${getName(this) ?? "<unnamed>"}`;
39
+ }
40
+ };
41
+
42
+ //#endregion
43
+ export { unstruct };
@@ -0,0 +1,191 @@
1
+ import { Vec2b, Vec2f, Vec2h, Vec2i, Vec2u, Vec3b, Vec3f, Vec3h, Vec3i, Vec3u, Vec4b, Vec4f, Vec4h, Vec4i, Vec4u } from "./wgslTypes.js";
2
+
3
+ //#region src/data/vector.d.ts
4
+ /**
5
+ * Schema representing vec2f - a vector with 2 elements of type f32.
6
+ * Also a constructor function for this vector value.
7
+ *
8
+ * @example
9
+ * const vector = d.vec2f(); // (0.0, 0.0)
10
+ * const vector = d.vec2f(1); // (1.0, 1.0)
11
+ * const vector = d.vec2f(0.5, 0.1); // (0.5, 0.1)
12
+ *
13
+ * @example
14
+ * const buffer = root.createBuffer(d.vec2f, d.vec2f(0, 1)); // buffer holding a d.vec2f value, with an initial value of vec2f(0, 1);
15
+ */
16
+ declare const vec2f: Vec2f;
17
+ /**
18
+ * Schema representing vec2h - a vector with 2 elements of type f16.
19
+ * Also a constructor function for this vector value.
20
+ *
21
+ * @example
22
+ * const vector = d.vec2h(); // (0.0, 0.0)
23
+ * const vector = d.vec2h(1); // (1.0, 1.0)
24
+ * const vector = d.vec2h(0.5, 0.1); // (0.5, 0.1)
25
+ *
26
+ * @example
27
+ * const buffer = root.createBuffer(d.vec2h, d.vec2h(0, 1)); // buffer holding a d.vec2h value, with an initial value of vec2h(0, 1);
28
+ */
29
+ declare const vec2h: Vec2h;
30
+ /**
31
+ * Schema representing vec2i - a vector with 2 elements of type i32.
32
+ * Also a constructor function for this vector value.
33
+ *
34
+ * @example
35
+ * const vector = d.vec2i(); // (0, 0)
36
+ * const vector = d.vec2i(1); // (1, 1)
37
+ * const vector = d.vec2i(-1, 1); // (-1, 1)
38
+ *
39
+ * @example
40
+ * const buffer = root.createBuffer(d.vec2i, d.vec2i(0, 1)); // buffer holding a d.vec2i value, with an initial value of vec2i(0, 1);
41
+ */
42
+ declare const vec2i: Vec2i;
43
+ /**
44
+ * Schema representing vec2u - a vector with 2 elements of type u32.
45
+ * Also a constructor function for this vector value.
46
+ *
47
+ * @example
48
+ * const vector = d.vec2u(); // (0, 0)
49
+ * const vector = d.vec2u(1); // (1, 1)
50
+ * const vector = d.vec2u(1, 2); // (1, 2)
51
+ *
52
+ * @example
53
+ * const buffer = root.createBuffer(d.vec2u, d.vec2u(0, 1)); // buffer holding a d.vec2u value, with an initial value of vec2u(0, 1);
54
+ */
55
+ declare const vec2u: Vec2u;
56
+ /**
57
+ * Schema representing `vec2<bool>` - a vector with 2 elements of type `bool`.
58
+ * Also a constructor function for this vector value.
59
+ *
60
+ * @example
61
+ * const vector = d.vec2b(); // (false, false)
62
+ * const vector = d.vec2b(true); // (true, true)
63
+ * const vector = d.vec2b(false, true); // (false, true)
64
+ */
65
+ declare const vec2b: Vec2b;
66
+ /**
67
+ * Schema representing vec3f - a vector with 3 elements of type f32.
68
+ * Also a constructor function for this vector value.
69
+ *
70
+ * @example
71
+ * const vector = d.vec3f(); // (0.0, 0.0, 0.0)
72
+ * const vector = d.vec3f(1); // (1.0, 1.0, 1.0)
73
+ * const vector = d.vec3f(1, 2, 3.5); // (1.0, 2.0, 3.5)
74
+ *
75
+ * @example
76
+ * const buffer = root.createBuffer(d.vec3f, d.vec3f(0, 1, 2)); // buffer holding a d.vec3f value, with an initial value of vec3f(0, 1, 2);
77
+ */
78
+ declare const vec3f: Vec3f;
79
+ /**
80
+ * Schema representing vec3h - a vector with 3 elements of type f16.
81
+ * Also a constructor function for this vector value.
82
+ *
83
+ * @example
84
+ * const vector = d.vec3h(); // (0.0, 0.0, 0.0)
85
+ * const vector = d.vec3h(1); // (1.0, 1.0, 1.0)
86
+ * const vector = d.vec3h(1, 2, 3.5); // (1.0, 2.0, 3.5)
87
+ *
88
+ * @example
89
+ * const buffer = root.createBuffer(d.vec3h, d.vec3h(0, 1, 2)); // buffer holding a d.vec3h value, with an initial value of vec3h(0, 1, 2);
90
+ */
91
+ declare const vec3h: Vec3h;
92
+ /**
93
+ * Schema representing vec3i - a vector with 3 elements of type i32.
94
+ * Also a constructor function for this vector value.
95
+ *
96
+ * @example
97
+ * const vector = d.vec3i(); // (0, 0, 0)
98
+ * const vector = d.vec3i(1); // (1, 1, 1)
99
+ * const vector = d.vec3i(1, 2, -3); // (1, 2, -3)
100
+ *
101
+ * @example
102
+ * const buffer = root.createBuffer(d.vec3i, d.vec3i(0, 1, 2)); // buffer holding a d.vec3i value, with an initial value of vec3i(0, 1, 2);
103
+ */
104
+ declare const vec3i: Vec3i;
105
+ /**
106
+ * Schema representing vec3u - a vector with 3 elements of type u32.
107
+ * Also a constructor function for this vector value.
108
+ *
109
+ * @example
110
+ * const vector = d.vec3u(); // (0, 0, 0)
111
+ * const vector = d.vec3u(1); // (1, 1, 1)
112
+ * const vector = d.vec3u(1, 2, 3); // (1, 2, 3)
113
+ *
114
+ * @example
115
+ * const buffer = root.createBuffer(d.vec3u, d.vec3u(0, 1, 2)); // buffer holding a d.vec3u value, with an initial value of vec3u(0, 1, 2);
116
+ */
117
+ declare const vec3u: Vec3u;
118
+ /**
119
+ * Schema representing `vec3<bool>` - a vector with 3 elements of type `bool`.
120
+ * Also a constructor function for this vector value.
121
+ *
122
+ * @example
123
+ * const vector = d.vec3b(); // (false, false, false)
124
+ * const vector = d.vec3b(true); // (true, true, true)
125
+ * const vector = d.vec3b(false, true, false); // (false, true, false)
126
+ */
127
+ declare const vec3b: Vec3b;
128
+ /**
129
+ * Schema representing vec4f - a vector with 4 elements of type f32.
130
+ * Also a constructor function for this vector value.
131
+ *
132
+ * @example
133
+ * const vector = d.vec4f(); // (0.0, 0.0, 0.0, 0.0)
134
+ * const vector = d.vec4f(1); // (1.0, 1.0, 1.0, 1.0)
135
+ * const vector = d.vec4f(1, 2, 3, 4.5); // (1.0, 2.0, 3.0, 4.5)
136
+ *
137
+ * @example
138
+ * const buffer = root.createBuffer(d.vec4f, d.vec4f(0, 1, 2, 3)); // buffer holding a d.vec4f value, with an initial value of vec4f(0, 1, 2, 3);
139
+ */
140
+ declare const vec4f: Vec4f;
141
+ /**
142
+ * Schema representing vec4h - a vector with 4 elements of type f16.
143
+ * Also a constructor function for this vector value.
144
+ *
145
+ * @example
146
+ * const vector = d.vec4h(); // (0.0, 0.0, 0.0, 0.0)
147
+ * const vector = d.vec4h(1); // (1.0, 1.0, 1.0, 1.0)
148
+ * const vector = d.vec4h(1, 2, 3, 4.5); // (1.0, 2.0, 3.0, 4.5)
149
+ *
150
+ * @example
151
+ * const buffer = root.createBuffer(d.vec4h, d.vec4h(0, 1, 2, 3)); // buffer holding a d.vec4h value, with an initial value of vec4h(0, 1, 2, 3);
152
+ */
153
+ declare const vec4h: Vec4h;
154
+ /**
155
+ * Schema representing vec4i - a vector with 4 elements of type i32.
156
+ * Also a constructor function for this vector value.
157
+ *
158
+ * @example
159
+ * const vector = d.vec4i(); // (0, 0, 0, 0)
160
+ * const vector = d.vec4i(1); // (1, 1, 1, 1)
161
+ * const vector = d.vec4i(1, 2, 3, -4); // (1, 2, 3, -4)
162
+ *
163
+ * @example
164
+ * const buffer = root.createBuffer(d.vec4i, d.vec4i(0, 1, 2, 3)); // buffer holding a d.vec4i value, with an initial value of vec4i(0, 1, 2, 3);
165
+ */
166
+ declare const vec4i: Vec4i;
167
+ /**
168
+ * Schema representing vec4u - a vector with 4 elements of type u32.
169
+ * Also a constructor function for this vector value.
170
+ *
171
+ * @example
172
+ * const vector = d.vec4u(); // (0, 0, 0, 0)
173
+ * const vector = d.vec4u(1); // (1, 1, 1, 1)
174
+ * const vector = d.vec4u(1, 2, 3, 4); // (1, 2, 3, 4)
175
+ *
176
+ * @example
177
+ * const buffer = root.createBuffer(d.vec4u, d.vec4u(0, 1, 2, 3)); // buffer holding a d.vec4u value, with an initial value of vec4u(0, 1, 2, 3);
178
+ */
179
+ declare const vec4u: Vec4u;
180
+ /**
181
+ * Schema representing `vec4<bool>` - a vector with 4 elements of type `bool`.
182
+ * Also a constructor function for this vector value.
183
+ *
184
+ * @example
185
+ * const vector = d.vec4b(); // (false, false, false, false)
186
+ * const vector = d.vec4b(true); // (true, true, true, true)
187
+ * const vector = d.vec4b(false, true, false, true); // (false, true, false, true)
188
+ */
189
+ declare const vec4b: Vec4b;
190
+ //#endregion
191
+ export { vec2b, vec2f, vec2h, vec2i, vec2u, vec3b, vec3f, vec3h, vec3i, vec3u, vec4b, vec4f, vec4h, vec4i, vec4u };