typegpu 0.11.1 → 0.11.3

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 (216) hide show
  1. package/_virtual/{_rolldown/runtime.js → rolldown_runtime.js} +4 -4
  2. package/builtin.js +3 -1
  3. package/common/fullScreenTriangle.d.ts +6 -1
  4. package/common/fullScreenTriangle.js +3 -1
  5. package/common/index.js +5 -3
  6. package/common/writeSoA.js +3 -1
  7. package/core/buffer/buffer.d.ts +3 -0
  8. package/core/buffer/buffer.js +5 -3
  9. package/core/buffer/bufferShorthand.d.ts +2 -0
  10. package/core/buffer/bufferShorthand.js +3 -1
  11. package/core/buffer/bufferUsage.d.ts +2 -0
  12. package/core/buffer/bufferUsage.js +3 -1
  13. package/core/constant/tgpuConstant.d.ts +2 -1
  14. package/core/constant/tgpuConstant.js +3 -1
  15. package/core/declare/tgpuDeclare.js +3 -1
  16. package/core/function/autoIO.d.ts +3 -0
  17. package/core/function/autoIO.js +5 -3
  18. package/core/function/comptime.js +3 -1
  19. package/core/function/createCallableSchema.js +3 -1
  20. package/core/function/dualImpl.js +3 -1
  21. package/core/function/entryInputRouter.js +13 -17
  22. package/core/function/extractArgs.js +2 -1
  23. package/core/function/fnCore.js +17 -11
  24. package/core/function/fnTypes.d.ts +2 -0
  25. package/core/function/ioSchema.d.ts +1 -0
  26. package/core/function/ioSchema.js +3 -1
  27. package/core/function/shelllessImpl.d.ts +1 -0
  28. package/core/function/shelllessImpl.js +4 -2
  29. package/core/function/templateUtils.js +2 -1
  30. package/core/function/tgpuComputeFn.d.ts +1 -0
  31. package/core/function/tgpuComputeFn.js +4 -2
  32. package/core/function/tgpuFn.d.ts +1 -0
  33. package/core/function/tgpuFn.js +17 -15
  34. package/core/function/tgpuFragmentFn.js +4 -2
  35. package/core/function/tgpuVertexFn.js +4 -2
  36. package/core/pipeline/applyPipelineState.js +3 -1
  37. package/core/pipeline/computePipeline.d.ts +4 -0
  38. package/core/pipeline/computePipeline.js +8 -6
  39. package/core/pipeline/connectAttachmentToShader.js +3 -1
  40. package/core/pipeline/connectTargetsToShader.js +3 -1
  41. package/core/pipeline/limitsOverflow.js +2 -1
  42. package/core/pipeline/pipelineUtils.js +6 -4
  43. package/core/pipeline/renderPipeline.js +21 -19
  44. package/core/pipeline/timeable.d.ts +2 -0
  45. package/core/pipeline/timeable.js +3 -1
  46. package/core/pipeline/typeGuards.js +3 -1
  47. package/core/querySet/querySet.d.ts +2 -0
  48. package/core/querySet/querySet.js +3 -1
  49. package/core/rawCodeSnippet/tgpuRawCodeSnippet.d.ts +1 -0
  50. package/core/rawCodeSnippet/tgpuRawCodeSnippet.js +3 -1
  51. package/core/resolve/externals.d.ts +3 -0
  52. package/core/resolve/externals.js +7 -5
  53. package/core/resolve/namespace.js +6 -4
  54. package/core/resolve/resolveData.js +3 -1
  55. package/core/resolve/stitch.js +3 -1
  56. package/core/resolve/tgpuResolve.js +7 -5
  57. package/core/root/configurableImpl.js +3 -1
  58. package/core/root/init.d.ts +10 -2
  59. package/core/root/init.js +4 -2
  60. package/core/root/rootTypes.d.ts +11 -11
  61. package/core/sampler/sampler.d.ts +4 -0
  62. package/core/sampler/sampler.js +3 -1
  63. package/core/simulate/tgpuSimulate.js +6 -4
  64. package/core/slot/accessor.d.ts +4 -0
  65. package/core/slot/accessor.js +3 -1
  66. package/core/slot/internalSlots.js +3 -1
  67. package/core/slot/lazy.js +3 -1
  68. package/core/slot/slot.js +3 -1
  69. package/core/slot/slotTypes.js +3 -1
  70. package/core/texture/externalTexture.d.ts +6 -0
  71. package/core/texture/externalTexture.js +3 -1
  72. package/core/texture/texture.d.ts +4 -0
  73. package/core/texture/texture.js +6 -4
  74. package/core/texture/textureFormats.js +3 -1
  75. package/core/texture/textureUtils.js +3 -1
  76. package/core/texture/usageExtension.js +3 -1
  77. package/core/unroll/tgpuUnroll.d.ts +3 -1
  78. package/core/unroll/tgpuUnroll.js +3 -1
  79. package/core/valueProxyUtils.js +7 -5
  80. package/core/variable/tgpuVariable.d.ts +3 -1
  81. package/core/variable/tgpuVariable.js +3 -1
  82. package/core/vertexLayout/connectAttributesToShader.js +3 -1
  83. package/core/vertexLayout/vertexAttribute.d.ts +1 -0
  84. package/core/vertexLayout/vertexLayout.js +7 -5
  85. package/data/alignIO.js +3 -1
  86. package/data/alignmentOf.d.ts +2 -0
  87. package/data/alignmentOf.js +3 -1
  88. package/data/array.js +3 -1
  89. package/data/atomic.d.ts +1 -0
  90. package/data/atomic.js +3 -1
  91. package/data/attributes.js +7 -5
  92. package/data/autoStruct.d.ts +3 -1
  93. package/data/autoStruct.js +3 -1
  94. package/data/compiledIO.js +39 -37
  95. package/data/dataIO.js +22 -20
  96. package/data/dataTypes.d.ts +9 -4
  97. package/data/dataTypes.js +3 -1
  98. package/data/deepEqual.d.ts +1 -0
  99. package/data/deepEqual.js +3 -1
  100. package/data/disarray.d.ts +3 -1
  101. package/data/disarray.js +3 -1
  102. package/data/getLongestContiguousPrefix.d.ts +2 -0
  103. package/data/getLongestContiguousPrefix.js +3 -1
  104. package/data/index.d.ts +3 -3
  105. package/data/index.js +5 -6
  106. package/data/isContiguous.d.ts +2 -0
  107. package/data/isContiguous.js +3 -1
  108. package/data/matrix.d.ts +11 -8
  109. package/data/matrix.js +3 -1
  110. package/data/numberOps.js +2 -1
  111. package/data/numeric.d.ts +1 -0
  112. package/data/numeric.js +19 -15
  113. package/data/offsetUtils.d.ts +1 -0
  114. package/data/offsetUtils.js +3 -1
  115. package/data/offsets.js +5 -3
  116. package/data/partialIO.js +3 -1
  117. package/data/ptr.d.ts +1 -0
  118. package/data/ptr.js +3 -1
  119. package/data/ref.d.ts +3 -0
  120. package/data/ref.js +5 -3
  121. package/data/sampler.js +3 -1
  122. package/data/schemaCallWrapper.js +3 -1
  123. package/data/schemaMemoryLayout.js +3 -1
  124. package/data/sizeOf.d.ts +2 -0
  125. package/data/sizeOf.js +3 -1
  126. package/data/snippet.d.ts +1 -6
  127. package/data/snippet.js +3 -1
  128. package/data/struct.d.ts +1 -0
  129. package/data/struct.js +3 -1
  130. package/data/texture.js +3 -1
  131. package/data/unstruct.d.ts +1 -0
  132. package/data/unstruct.js +3 -1
  133. package/data/vector.d.ts +1 -0
  134. package/data/vector.js +3 -1
  135. package/data/vectorImpl.js +3 -1
  136. package/data/vectorOps.js +3 -1
  137. package/data/vertexFormatData.js +3 -1
  138. package/data/wgslTypes.d.ts +4 -0
  139. package/data/wgslTypes.js +3 -1
  140. package/errors.d.ts +1 -0
  141. package/errors.js +3 -1
  142. package/execMode.js +3 -1
  143. package/extension.d.ts +1 -0
  144. package/extension.js +3 -1
  145. package/getGPUValue.js +3 -1
  146. package/index.js +3 -4
  147. package/indexNamedExports.d.ts +1 -0
  148. package/mathUtils.js +2 -1
  149. package/memo.js +2 -1
  150. package/nameRegistry.js +3 -1
  151. package/package.js +3 -2
  152. package/package.json +1 -1
  153. package/resolutionCtx.d.ts +11 -0
  154. package/resolutionCtx.js +86 -87
  155. package/shared/env.js +2 -1
  156. package/shared/generators.js +2 -1
  157. package/shared/meta.js +3 -1
  158. package/shared/repr.d.ts +1 -0
  159. package/shared/stringify.js +3 -1
  160. package/shared/symbols.js +42 -10
  161. package/shared/utilityTypes.js +2 -1
  162. package/shared/vertexFormat.js +2 -1
  163. package/std/array.d.ts +1 -1
  164. package/std/array.js +3 -1
  165. package/std/atomic.d.ts +12 -12
  166. package/std/atomic.js +3 -1
  167. package/std/bitcast.d.ts +2 -2
  168. package/std/bitcast.js +3 -1
  169. package/std/boolean.d.ts +15 -14
  170. package/std/boolean.js +3 -1
  171. package/std/derivative.d.ts +9 -9
  172. package/std/derivative.js +3 -1
  173. package/std/discard.d.ts +1 -1
  174. package/std/discard.js +3 -1
  175. package/std/extensions.d.ts +3 -1
  176. package/std/extensions.js +3 -1
  177. package/std/index.js +5 -3
  178. package/std/matrix.d.ts +6 -5
  179. package/std/matrix.js +3 -1
  180. package/std/numeric.d.ts +132 -78
  181. package/std/numeric.js +7 -5
  182. package/std/operators.d.ts +8 -8
  183. package/std/operators.js +7 -5
  184. package/std/packing.d.ts +5 -4
  185. package/std/packing.js +3 -1
  186. package/std/range.d.ts +3 -1
  187. package/std/range.js +3 -1
  188. package/std/subgroup.d.ts +21 -21
  189. package/std/subgroup.js +3 -1
  190. package/std/texture.d.ts +11 -11
  191. package/std/texture.js +9 -7
  192. package/tgpu.js +5 -3
  193. package/tgpuBindGroupLayout.d.ts +11 -7
  194. package/tgpuBindGroupLayout.js +3 -1
  195. package/tgpuUnstable.js +5 -3
  196. package/tgsl/accessIndex.js +5 -3
  197. package/tgsl/accessProp.js +10 -3
  198. package/tgsl/consoleLog/deserializers.js +3 -1
  199. package/tgsl/consoleLog/logGenerator.js +18 -9
  200. package/tgsl/consoleLog/serializers.js +3 -1
  201. package/tgsl/consoleLog/types.d.ts +3 -0
  202. package/tgsl/consoleLog/types.js +2 -1
  203. package/tgsl/conversion.js +18 -6
  204. package/tgsl/forOfUtils.js +17 -7
  205. package/tgsl/generationHelpers.d.ts +1 -0
  206. package/tgsl/generationHelpers.js +3 -4
  207. package/tgsl/math.js +3 -1
  208. package/tgsl/shaderGenerator.d.ts +3 -2
  209. package/tgsl/shaderGenerator_members.d.ts +15 -2
  210. package/tgsl/shaderGenerator_members.js +5 -3
  211. package/tgsl/shellless.js +3 -1
  212. package/tgsl/wgslGenerator.d.ts +3 -1
  213. package/tgsl/wgslGenerator.js +54 -44
  214. package/types.d.ts +11 -7
  215. package/types.js +3 -1
  216. package/wgslExtensions.js +2 -1
package/std/texture.d.ts CHANGED
@@ -15,13 +15,13 @@ declare function sampleCpu<T extends textureCubeArray>(texture: T, sampler: samp
15
15
  declare function sampleCpu<T extends textureDepth2d>(texture: T, sampler: sampler, coords: v2f, offset?: v2i): number;
16
16
  declare function sampleCpu<T extends textureDepth2dArray>(texture: T, sampler: sampler, coords: v2f, arrayIndex: number, offset?: v2i): number;
17
17
  declare function sampleCpu<T extends textureDepthCube>(texture: T, sampler: sampler, coords: v3f, arrayIndex?: number): number;
18
- declare const textureSample: DualFn;
18
+ declare const textureSample: DualFn<typeof sampleCpu>;
19
19
  declare function sampleBiasCpu<T extends texture1d>(texture: T, sampler: sampler, coords: number, bias: number): v4f;
20
20
  declare function sampleBiasCpu<T extends texture2d>(texture: T, sampler: sampler, coords: v2f, bias: number, offset?: v2i): v4f;
21
21
  declare function sampleBiasCpu<T extends texture2dArray>(texture: T, sampler: sampler, coords: v2f, arrayIndex: number, bias: number, offset?: v2i): v4f;
22
22
  declare function sampleBiasCpu<T extends texture3d | textureCube>(texture: T, sampler: sampler, coords: v3f, bias: number, offset?: v3i): v4f;
23
23
  declare function sampleBiasCpu<T extends textureCubeArray>(texture: T, sampler: sampler, coords: v3f, arrayIndex: number, bias: number): v4f;
24
- declare const textureSampleBias: DualFn;
24
+ declare const textureSampleBias: DualFn<typeof sampleBiasCpu>;
25
25
  declare function sampleLevelCpu<T extends texture1d>(texture: T, sampler: sampler, coords: number, level: number): v4f;
26
26
  declare function sampleLevelCpu<T extends texture2d>(texture: T, sampler: sampler, coords: v2f, level: number): v4f;
27
27
  declare function sampleLevelCpu<T extends texture2d>(texture: T, sampler: sampler, coords: v2f, level: number, offset: v2i): v4f;
@@ -36,7 +36,7 @@ declare function sampleLevelCpu<T extends textureDepth2dArray>(texture: T, sampl
36
36
  declare function sampleLevelCpu<T extends textureDepth2dArray>(texture: T, sampler: sampler, coords: v2f, arrayIndex: number, level: number, offset: v2i): number;
37
37
  declare function sampleLevelCpu<T extends textureDepthCube>(texture: T, sampler: sampler, coords: v3f, level: number): number;
38
38
  declare function sampleLevelCpu<T extends textureCubeArray>(texture: T, sampler: sampler, coords: v3f, arrayIndex: number, level: number): number;
39
- declare const textureSampleLevel: DualFn;
39
+ declare const textureSampleLevel: DualFn<typeof sampleLevelCpu>;
40
40
  type PrimitiveToLoadedType = {
41
41
  f32: v4f;
42
42
  i32: v4i;
@@ -56,19 +56,19 @@ declare function textureLoadCpu<T extends textureStorage1d>(texture: T, coords:
56
56
  declare function textureLoadCpu<T extends textureStorage2d>(texture: T, coords: v2i | v2u): TexelFormatToInstanceType<T[typeof $internal][0]>;
57
57
  declare function textureLoadCpu<T extends textureStorage2dArray>(texture: T, coords: v2i | v2u, arrayIndex: number): TexelFormatToInstanceType<T[typeof $internal][0]>;
58
58
  declare function textureLoadCpu<T extends textureStorage3d>(texture: T, coords: v3i | v3u): TexelFormatToInstanceType<T[typeof $internal][0]>;
59
- declare const textureLoad: DualFn;
59
+ declare const textureLoad: DualFn<typeof textureLoadCpu>;
60
60
  declare function textureStoreCpu<T extends textureStorage1d>(texture: T, coords: number, value: TexelFormatToInstanceType<T[typeof $internal][0]>): void;
61
61
  declare function textureStoreCpu<T extends textureStorage2d>(texture: T, coords: v2i | v2u, value: TexelFormatToInstanceType<T[typeof $internal][0]>): void;
62
62
  declare function textureStoreCpu<T extends textureStorage2dArray>(texture: T, coords: v2i | v2u, arrayIndex: number, value: TexelFormatToInstanceType<T[typeof $internal][0]>): void;
63
63
  declare function textureStoreCpu<T extends textureStorage3d>(texture: T, coords: v3i | v3u, value: TexelFormatToInstanceType<T[typeof $internal][0]>): void;
64
- declare const textureStore: DualFn;
64
+ declare const textureStore: DualFn<typeof textureStoreCpu>;
65
65
  declare function textureDimensionsCpu<T extends texture1d | textureStorage1d>(texture: T): number;
66
66
  declare function textureDimensionsCpu<T extends texture1d>(texture: T, level: number): number;
67
67
  declare function textureDimensionsCpu<T extends texture2d | texture2dArray | textureCube | textureCubeArray | textureStorage2d | textureStorage2dArray | textureExternal>(texture: T): v2u;
68
68
  declare function textureDimensionsCpu<T extends texture2d | texture2dArray | textureCube | textureCubeArray>(texture: T, level: number): v2u;
69
69
  declare function textureDimensionsCpu<T extends texture3d | textureStorage3d>(texture: T): v3u;
70
70
  declare function textureDimensionsCpu<T extends texture3d>(texture: T, level: number): v3u;
71
- declare const textureDimensions: DualFn;
71
+ declare const textureDimensions: DualFn<typeof textureDimensionsCpu>;
72
72
  type Gather2dArgs<T extends texture2d = texture2d> = [component: number, texture: T, sampler: sampler, coords: v2f, offset?: v2i];
73
73
  type Gather2dArrayArgs<T extends texture2dArray = texture2dArray> = [component: number, texture: T, sampler: sampler, coords: v2f, arrayIndex: number, offset?: v2i];
74
74
  type GatherCubeArgs<T extends textureCube = textureCube> = [component: number, texture: T, sampler: sampler, coords: v3f];
@@ -87,21 +87,21 @@ type TextureGatherCpuFn = {
87
87
  (...args: GatherDepthCubeArgs): v4f;
88
88
  (...args: GatherDepthCubeArrayArgs): v4f;
89
89
  };
90
- declare const textureGather: DualFn;
90
+ declare const textureGather: DualFn<TextureGatherCpuFn>;
91
91
  declare function textureSampleCompareCpu<T extends textureDepth2d>(texture: T, sampler: comparisonSampler, coords: v2f, depthRef: number): number;
92
92
  declare function textureSampleCompareCpu<T extends textureDepth2d>(texture: T, sampler: comparisonSampler, coords: v2f, depthRef: number, offset: v2i): number;
93
93
  declare function textureSampleCompareCpu<T extends textureDepth2dArray>(texture: T, sampler: comparisonSampler, coords: v2f, arrayIndex: number, depthRef: number): number;
94
94
  declare function textureSampleCompareCpu<T extends textureDepth2dArray>(texture: T, sampler: comparisonSampler, coords: v2f, arrayIndex: number, depthRef: number, offset: v2i): number;
95
95
  declare function textureSampleCompareCpu<T extends textureDepthCube>(texture: T, sampler: comparisonSampler, coords: v3f, depthRef: number): number;
96
96
  declare function textureSampleCompareCpu<T extends textureDepthCubeArray>(texture: T, sampler: comparisonSampler, coords: v3f, arrayIndex: number, depthRef: number): number;
97
- declare const textureSampleCompare: DualFn;
97
+ declare const textureSampleCompare: DualFn<typeof textureSampleCompareCpu>;
98
98
  declare function textureSampleCompareLevelCpu<T extends textureDepth2d>(texture: T, sampler: comparisonSampler, coords: v2f, depthRef: number): number;
99
99
  declare function textureSampleCompareLevelCpu<T extends textureDepth2d>(texture: T, sampler: comparisonSampler, coords: v2f, depthRef: number, offset: v2i): number;
100
100
  declare function textureSampleCompareLevelCpu<T extends textureDepth2dArray>(texture: T, sampler: comparisonSampler, coords: v2f, arrayIndex: number, depthRef: number): number;
101
101
  declare function textureSampleCompareLevelCpu<T extends textureDepth2dArray>(texture: T, sampler: comparisonSampler, coords: v2f, arrayIndex: number, depthRef: number, offset: v2i): number;
102
102
  declare function textureSampleCompareLevelCpu<T extends textureDepthCube>(texture: T, sampler: comparisonSampler, coords: v3f, depthRef: number): number;
103
103
  declare function textureSampleCompareLevelCpu<T extends textureDepthCubeArray>(texture: T, sampler: comparisonSampler, coords: v3f, arrayIndex: number, depthRef: number): number;
104
- declare const textureSampleCompareLevel: DualFn;
104
+ declare const textureSampleCompareLevel: DualFn<typeof textureSampleCompareLevelCpu>;
105
105
  declare function textureSampleBaseClampToEdgeCpu<T extends texture2d | textureExternal>(_texture: T, _sampler: sampler, _coords: v2f): v4f;
106
106
  declare function sampleGradCpu<T extends texture2d>(texture: T, sampler: sampler, coords: v2f, ddx: v2f, ddy: v2f): v4f;
107
107
  declare function sampleGradCpu<T extends texture2d>(texture: T, sampler: sampler, coords: v2f, ddx: v2f, ddy: v2f, offset: v2i): v4f;
@@ -111,7 +111,7 @@ declare function sampleGradCpu<T extends texture3d>(texture: T, sampler: sampler
111
111
  declare function sampleGradCpu<T extends texture3d>(texture: T, sampler: sampler, coords: v3f, ddx: v3f, ddy: v3f, offset: v3i): v4f;
112
112
  declare function sampleGradCpu<T extends textureCube>(texture: T, sampler: sampler, coords: v3f, ddx: v3f, ddy: v3f): v4f;
113
113
  declare function sampleGradCpu<T extends textureCubeArray>(texture: T, sampler: sampler, coords: v3f, arrayIndex: number, ddx: v3f, ddy: v3f): v4f;
114
- declare const textureSampleGrad: DualFn;
115
- declare const textureSampleBaseClampToEdge: DualFn;
114
+ declare const textureSampleGrad: DualFn<typeof sampleGradCpu>;
115
+ declare const textureSampleBaseClampToEdge: DualFn<typeof textureSampleBaseClampToEdgeCpu>;
116
116
  //#endregion
117
117
  export { textureDimensions, textureGather, textureLoad, textureSample, textureSampleBaseClampToEdge, textureSampleBias, textureSampleCompare, textureSampleCompareLevel, textureSampleGrad, textureSampleLevel, textureStore };
package/std/texture.js CHANGED
@@ -5,6 +5,7 @@ import { vec2u, vec3u, vec4f, vec4i, vec4u } from "../data/vector.js";
5
5
  import { MissingCpuImplError, dualImpl } from "../core/function/dualImpl.js";
6
6
  import { isWgslExternalTexture, isWgslTexture } from "../data/texture.js";
7
7
  import { getTextureFormatInfo } from "../core/texture/textureFormats.js";
8
+
8
9
  //#region src/std/texture.ts
9
10
  function sampleCpu(_texture, _sampler, _coords, _offsetOrArrayIndex, _maybeOffset) {
10
11
  throw new MissingCpuImplError("Texture sampling relies on GPU resources and cannot be executed outside of a draw call");
@@ -123,14 +124,14 @@ const textureGather = dualImpl({
123
124
  codegenImpl: (_ctx, args) => stitch`textureGather(${args})`,
124
125
  signature: (...args) => {
125
126
  if (args[0].type.startsWith("texture")) {
126
- const [texture, sampler, coords, _, ...rest] = args;
127
+ const [texture$1, sampler$1, coords$1, _$1, ...rest$1] = args;
127
128
  return {
128
- argTypes: texture.type === "texture_depth_2d_array" || texture.type === "texture_depth_cube_array" ? [
129
- texture,
130
- sampler,
131
- coords,
129
+ argTypes: texture$1.type === "texture_depth_2d_array" || texture$1.type === "texture_depth_cube_array" ? [
130
+ texture$1,
131
+ sampler$1,
132
+ coords$1,
132
133
  [u32, i32],
133
- ...rest
134
+ ...rest$1
134
135
  ] : args,
135
136
  returnType: vec4f
136
137
  };
@@ -203,5 +204,6 @@ const textureSampleBaseClampToEdge = dualImpl({
203
204
  returnType: vec4f
204
205
  })
205
206
  });
207
+
206
208
  //#endregion
207
- export { textureDimensions, textureGather, textureLoad, textureSample, textureSampleBaseClampToEdge, textureSampleBias, textureSampleCompare, textureSampleCompareLevel, textureSampleGrad, textureSampleLevel, textureStore };
209
+ export { textureDimensions, textureGather, textureLoad, textureSample, textureSampleBaseClampToEdge, textureSampleBias, textureSampleCompare, textureSampleCompareLevel, textureSampleGrad, textureSampleLevel, textureStore };
package/tgpu.js CHANGED
@@ -1,4 +1,4 @@
1
- import { __exportAll } from "./_virtual/_rolldown/runtime.js";
1
+ import { __export } from "./_virtual/rolldown_runtime.js";
2
2
  import { comptime } from "./core/function/comptime.js";
3
3
  import { constant } from "./core/constant/tgpuConstant.js";
4
4
  import { fn } from "./core/function/tgpuFn.js";
@@ -15,8 +15,9 @@ import { accessor, mutableAccessor } from "./core/slot/accessor.js";
15
15
  import { fragmentFn } from "./core/function/tgpuFragmentFn.js";
16
16
  import { vertexFn } from "./core/function/tgpuVertexFn.js";
17
17
  import { tgpuUnstable_exports } from "./tgpuUnstable.js";
18
+
18
19
  //#region src/tgpu.ts
19
- var tgpu_exports = /* @__PURE__ */ __exportAll({
20
+ var tgpu_exports = /* @__PURE__ */ __export({
20
21
  accessor: () => accessor,
21
22
  bindGroupLayout: () => bindGroupLayout,
22
23
  comptime: () => comptime,
@@ -38,5 +39,6 @@ var tgpu_exports = /* @__PURE__ */ __exportAll({
38
39
  workgroupVar: () => workgroupVar,
39
40
  "~unstable": () => tgpuUnstable_exports
40
41
  });
42
+
41
43
  //#endregion
42
- export { tgpu_exports };
44
+ export { tgpu_exports };
@@ -17,6 +17,7 @@ import { PropsForSchema, TgpuTexture, TgpuTextureView } from "./core/texture/tex
17
17
  import { InferGPU, MemIdentity } from "./shared/repr.js";
18
18
 
19
19
  //#region src/tgpuBindGroupLayout.d.ts
20
+
20
21
  type TgpuLayoutEntryBase = {
21
22
  /**
22
23
  * Limits this resource's visibility to specific shader stages.
@@ -33,7 +34,8 @@ type TgpuLayoutUniform = TgpuLayoutEntryBase & {
33
34
  uniform: BaseData;
34
35
  };
35
36
  type TgpuLayoutStorage = TgpuLayoutEntryBase & {
36
- storage: BaseData | ((arrayLength: number) => BaseData); /** @default 'readonly' */
37
+ storage: BaseData | ((arrayLength: number) => BaseData);
38
+ /** @default 'readonly' */
37
39
  access?: 'mutable' | 'readonly';
38
40
  };
39
41
  type TgpuLayoutSampler = TgpuLayoutEntryBase & {
@@ -42,12 +44,12 @@ type TgpuLayoutSampler = TgpuLayoutEntryBase & {
42
44
  type TgpuLayoutComparisonSampler = TgpuLayoutEntryBase & {
43
45
  sampler: 'comparison';
44
46
  };
45
- type TgpuLayoutTexture<TSchema extends WgslTexture = WgslTexture> = TgpuLayoutEntryBase & {
46
- texture: TSchema;
47
+ type TgpuLayoutTexture<TSchema$1 extends WgslTexture = WgslTexture> = TgpuLayoutEntryBase & {
48
+ texture: TSchema$1;
47
49
  sampleType?: GPUTextureSampleType;
48
50
  };
49
- type TgpuLayoutStorageTexture<TSchema extends WgslStorageTexture = WgslStorageTexture> = TgpuLayoutEntryBase & {
50
- storageTexture: TSchema;
51
+ type TgpuLayoutStorageTexture<TSchema$1 extends WgslStorageTexture = WgslStorageTexture> = TgpuLayoutEntryBase & {
52
+ storageTexture: TSchema$1;
51
53
  };
52
54
  type TgpuLayoutExternalTexture = TgpuLayoutEntryBase & {
53
55
  externalTexture: WgslExternalTexture;
@@ -71,8 +73,10 @@ type TgpuLegacyLayoutTexture<TSampleType extends GPUTextureSampleType = GPUTextu
71
73
  multisampled?: boolean;
72
74
  };
73
75
  type TgpuLegacyLayoutStorageTexture<TFormat extends StorageTextureFormats = StorageTextureFormats> = TgpuLayoutEntryBase & {
74
- storageTexture: TFormat; /** @default 'writeonly' */
75
- access?: 'readonly' | 'writeonly' | 'mutable'; /** @default '2d' */
76
+ storageTexture: TFormat;
77
+ /** @default 'writeonly' */
78
+ access?: 'readonly' | 'writeonly' | 'mutable';
79
+ /** @default '2d' */
76
80
  viewDimension?: StorageTextureDimension;
77
81
  };
78
82
  type TgpuLegacyLayoutExternalTexture = TgpuLayoutEntryBase & {
@@ -12,6 +12,7 @@ import { textureDescriptorToSchema } from "./data/texture.js";
12
12
  import { TgpuExternalTextureImpl } from "./core/texture/externalTexture.js";
13
13
  import { TgpuLaidOutTextureViewImpl, isTexture, isTextureView } from "./core/texture/texture.js";
14
14
  import { NotSampledError, isUsableAsSampled } from "./core/texture/usageExtension.js";
15
+
15
16
  //#region src/tgpuBindGroupLayout.ts
16
17
  /**
17
18
  * Converts legacy entries to new API format
@@ -268,5 +269,6 @@ var TgpuBindGroupImpl = class {
268
269
  });
269
270
  }
270
271
  };
272
+
271
273
  //#endregion
272
- export { TgpuBindGroupImpl, bindGroupLayout, isBindGroup, isBindGroupLayout };
274
+ export { TgpuBindGroupImpl, bindGroupLayout, isBindGroup, isBindGroupLayout };
package/tgpuUnstable.js CHANGED
@@ -1,4 +1,4 @@
1
- import { __exportAll } from "./_virtual/_rolldown/runtime.js";
1
+ import { __export } from "./_virtual/rolldown_runtime.js";
2
2
  import { comptime } from "./core/function/comptime.js";
3
3
  import { constant } from "./core/constant/tgpuConstant.js";
4
4
  import { fn } from "./core/function/tgpuFn.js";
@@ -14,8 +14,9 @@ import { vertexFn } from "./core/function/tgpuVertexFn.js";
14
14
  import { declare } from "./core/declare/tgpuDeclare.js";
15
15
  import { rawCodeSnippet } from "./core/rawCodeSnippet/tgpuRawCodeSnippet.js";
16
16
  import { simulate } from "./core/simulate/tgpuSimulate.js";
17
+
17
18
  //#region src/tgpuUnstable.ts
18
- var tgpuUnstable_exports = /* @__PURE__ */ __exportAll({
19
+ var tgpuUnstable_exports = /* @__PURE__ */ __export({
19
20
  accessor: () => _accessor,
20
21
  comptime: () => _comptime,
21
22
  computeFn: () => _computeFn,
@@ -60,5 +61,6 @@ const _privateVar = privateVar;
60
61
  const _workgroupVar = workgroupVar;
61
62
  /** @deprecated This feature is now stable, use tgpu.vertexLayout. */
62
63
  const _vertexLayout = vertexLayout;
64
+
63
65
  //#endregion
64
- export { tgpuUnstable_exports };
66
+ export { tgpuUnstable_exports };
@@ -1,5 +1,5 @@
1
1
  import { isNaturallyEphemeral, isPtr, isVec, isWgslArray, isWgslStruct } from "../data/wgslTypes.js";
2
- import { MatrixColumnsAccess, UnknownData, isDisarray } from "../data/dataTypes.js";
2
+ import { MatrixColumnsAccess, isDisarray } from "../data/dataTypes.js";
3
3
  import { isEphemeralSnippet, snip } from "../data/snippet.js";
4
4
  import { isKnownAtComptime } from "../types.js";
5
5
  import { stitch } from "../core/resolve/stitch.js";
@@ -7,6 +7,7 @@ import { derefSnippet } from "../data/ref.js";
7
7
  import { coerceToSnippet } from "./generationHelpers.js";
8
8
  import { vec2f, vec3f, vec4f } from "../data/vector.js";
9
9
  import { accessProp } from "./accessProp.js";
10
+
10
11
  //#region src/tgsl/accessIndex.ts
11
12
  const indexableTypeToResult = {
12
13
  mat2x2f: vec2f,
@@ -36,8 +37,9 @@ function accessIndex(target, indexArg) {
36
37
  return snip(stitch`${target.value.matrix}[${index}]`, propType, target.origin);
37
38
  }
38
39
  if (target.dataType.type in indexableTypeToResult) throw new Error("The only way of accessing matrix elements in TypeGPU functions is through the 'columns' property.");
39
- if (isKnownAtComptime(target) && isKnownAtComptime(index) || target.dataType === UnknownData) return coerceToSnippet(target.value[index.value]);
40
+ if (isKnownAtComptime(target) && isKnownAtComptime(index)) return coerceToSnippet(target.value[index.value]);
40
41
  if (isWgslStruct(target.dataType) && isKnownAtComptime(index) && typeof index.value === "string") return accessProp(target, index.value);
41
42
  }
43
+
42
44
  //#endregion
43
- export { accessIndex };
45
+ export { accessIndex };
@@ -1,7 +1,7 @@
1
1
  import { $gpuCallable } from "../shared/symbols.js";
2
2
  import { isMat, isNaturallyEphemeral, isPtr, isVec, isWgslArray, isWgslStruct } from "../data/wgslTypes.js";
3
3
  import { InfixDispatch, MatrixColumnsAccess, UnknownData, isUnstruct, undecorate } from "../data/dataTypes.js";
4
- import { isEphemeralSnippet, snip } from "../data/snippet.js";
4
+ import { isEphemeralSnippet, isSnippet, snip } from "../data/snippet.js";
5
5
  import { isKnownAtComptime } from "../types.js";
6
6
  import { stitch } from "../core/resolve/stitch.js";
7
7
  import { derefSnippet } from "../data/ref.js";
@@ -11,6 +11,7 @@ import { vec2b, vec2f, vec2h, vec2i, vec2u, vec3b, vec3f, vec3h, vec3i, vec3u, v
11
11
  import { AutoStruct } from "../data/autoStruct.js";
12
12
  import { EntryInputRouter } from "../core/function/entryInputRouter.js";
13
13
  import { add, bitShiftLeft, bitShiftRight, div, mod, mul, sub } from "../std/operators.js";
14
+
14
15
  //#region src/tgsl/accessProp.ts
15
16
  const infixKinds = [
16
17
  "vec2f",
@@ -91,7 +92,12 @@ function accessProp(target, propName) {
91
92
  if (!result) return;
92
93
  return snip(stitch`${target}.${result.prop}`, result.type, "argument");
93
94
  }
94
- if (target.dataType instanceof EntryInputRouter) return target.dataType.accessProp(propName);
95
+ if (target.dataType instanceof EntryInputRouter) {
96
+ const result = target.dataType.accessProp(propName);
97
+ if (isSnippet(result)) return result;
98
+ if (result) return accessProp(result.target, result.prop);
99
+ return;
100
+ }
95
101
  if (isPtr(target.dataType)) {
96
102
  const derefed = derefSnippet(target);
97
103
  if (propName === "$") return derefed;
@@ -111,5 +117,6 @@ function accessProp(target, propName) {
111
117
  }
112
118
  if (isKnownAtComptime(target) || target.dataType === UnknownData) return coerceToSnippet(target.value[propName]);
113
119
  }
120
+
114
121
  //#endregion
115
- export { accessProp, infixOperators };
122
+ export { accessProp, infixOperators };
@@ -5,6 +5,7 @@ import { sizeOf } from "../../data/sizeOf.js";
5
5
  import { mat2x2f, mat3x3f, mat4x4f } from "../../data/matrix.js";
6
6
  import { bitcastU32toF32, bitcastU32toI32 } from "../../std/bitcast.js";
7
7
  import { unpack2x16float } from "../../std/packing.js";
8
+
8
9
  //#region src/tgsl/consoleLog/deserializers.ts
9
10
  const toF = (n) => bitcastU32toF32(n ?? 0);
10
11
  const toI = (n) => bitcastU32toI32(n ?? 0);
@@ -111,5 +112,6 @@ function logDataFromGPU(resources) {
111
112
  dataBuffer.buffer.clear();
112
113
  indexBuffer.buffer.clear();
113
114
  }
115
+
114
116
  //#endregion
115
- export { logDataFromGPU };
117
+ export { logDataFromGPU };
@@ -1,16 +1,19 @@
1
1
  import { $internal } from "../../shared/symbols.js";
2
2
  import { Void } from "../../data/wgslTypes.js";
3
- import { UnknownData } from "../../data/dataTypes.js";
3
+ import { UnknownData, unptr } from "../../data/dataTypes.js";
4
4
  import { snip } from "../../data/snippet.js";
5
+ import { invariant } from "../../errors.js";
5
6
  import { stitch } from "../../core/resolve/stitch.js";
7
+ import { convertToCommonType } from "../conversion.js";
6
8
  import { u32 } from "../../data/numeric.js";
7
- import { concretizeSnippets } from "../generationHelpers.js";
9
+ import { concretizeSnippet } from "../generationHelpers.js";
8
10
  import { struct } from "../../data/struct.js";
9
11
  import { shaderStageSlot } from "../../core/slot/internalSlots.js";
10
12
  import { arrayOf } from "../../data/array.js";
11
13
  import { atomic } from "../../data/atomic.js";
12
14
  import { createLoggingFunction } from "./serializers.js";
13
15
  import { supportedLogOps } from "./types.js";
16
+
14
17
  //#region src/tgsl/consoleLog/logGenerator.ts
15
18
  const defaultOptions = {
16
19
  logCountLimit: 64,
@@ -60,16 +63,21 @@ var LogGeneratorImpl = class {
60
63
  console.warn(`Unsupported log method '${op}'.`);
61
64
  return fallbackSnippet;
62
65
  }
63
- const concreteArgs = concretizeSnippets(args);
64
66
  const id = this.#firstUnusedId++;
65
- const nonStringArgs = concreteArgs.filter((e) => e.dataType !== UnknownData);
66
- const logFn = createLoggingFunction(id, nonStringArgs.map((e) => e.dataType), this.#dataBuffer, this.#indexBuffer, this.#options);
67
- const argTypes = concreteArgs.map((e) => e.dataType === UnknownData ? e.value : e.dataType);
67
+ const concreteArgsWithStrings = args.map((arg) => {
68
+ if (arg.dataType === UnknownData) return arg;
69
+ const converted = convertToCommonType(ctx, [arg], [unptr(arg.dataType)])?.[0];
70
+ invariant(converted, `Internal error. Expected type ${arg.dataType} to be convertible to ${unptr(arg.dataType)}`);
71
+ return converted;
72
+ }).map(concretizeSnippet);
73
+ const concreteArgs = concreteArgsWithStrings.filter((arg) => arg.dataType !== UnknownData);
74
+ const logFn = createLoggingFunction(id, concreteArgs.map((e) => e.dataType), this.#dataBuffer, this.#indexBuffer, this.#options);
75
+ const functionSnippet = snip(stitch`${ctx.resolve(logFn).value}(${concreteArgs})`, Void, "runtime");
68
76
  this.#logIdToMeta.set(id, {
69
77
  op,
70
- argTypes
78
+ argTypes: concreteArgsWithStrings.map((e) => e?.dataType === UnknownData ? e?.value : e?.dataType)
71
79
  });
72
- return snip(stitch`${ctx.resolve(logFn).value}(${nonStringArgs})`, Void, "runtime");
80
+ return functionSnippet;
73
81
  }
74
82
  get logResources() {
75
83
  return this.#firstUnusedId === 1 ? void 0 : {
@@ -80,5 +88,6 @@ var LogGeneratorImpl = class {
80
88
  };
81
89
  }
82
90
  };
91
+
83
92
  //#endregion
84
- export { LogGeneratorImpl, LogGeneratorNullImpl };
93
+ export { LogGeneratorImpl, LogGeneratorNullImpl };
@@ -7,6 +7,7 @@ import { mat2x2f, mat3x3f, mat4x4f } from "../../data/matrix.js";
7
7
  import { fn } from "../../core/function/tgpuFn.js";
8
8
  import { slot } from "../../core/slot/slot.js";
9
9
  import { privateVar } from "../../core/variable/tgpuVariable.js";
10
+
10
11
  //#region src/tgsl/consoleLog/serializers.ts
11
12
  const dataBlockIndex = privateVar(u32, 0).$name("dataBlockIndex");
12
13
  const dataByteIndex = privateVar(u32, 0).$name("dataByteIndex");
@@ -219,5 +220,6 @@ function createLoggingFunction(id, dataTypes, dataBuffer, indexBuffer, logOption
219
220
  compoundSerializer
220
221
  }).$name(`log${id}`);
221
222
  }
223
+
222
224
  //#endregion
223
- export { createLoggingFunction };
225
+ export { createLoggingFunction };
@@ -1,7 +1,10 @@
1
+ import "../../data/snippet.js";
1
2
  import { TgpuMutable } from "../../core/buffer/bufferShorthand.js";
3
+ import "../generationHelpers.js";
2
4
  import { AnyWgslData, Atomic, U32, WgslArray, WgslStruct } from "../../data/wgslTypes.js";
3
5
 
4
6
  //#region src/tgsl/consoleLog/types.d.ts
7
+
5
8
  /**
6
9
  * Options for configuring GPU log generation.
7
10
  */
@@ -7,5 +7,6 @@ const supportedLogOps = [
7
7
  "error",
8
8
  "clear"
9
9
  ];
10
+
10
11
  //#endregion
11
- export { supportedLogOps };
12
+ export { supportedLogOps };
@@ -8,6 +8,7 @@ import { RefOperator, derefSnippet } from "../data/ref.js";
8
8
  import { schemaCallWrapperGPU } from "../data/schemaCallWrapper.js";
9
9
  import { safeStringify } from "../shared/stringify.js";
10
10
  import { assertExhaustive } from "../shared/utilityTypes.js";
11
+
11
12
  //#region src/tgsl/conversion.ts
12
13
  const INFINITE_RANK = {
13
14
  rank: Number.POSITIVE_INFINITY,
@@ -89,14 +90,19 @@ function getImplicitConversionRank(src, dest) {
89
90
  };
90
91
  }
91
92
  }
93
+ if ((trueSrc.type === "u32" || trueSrc.type === "i32") && trueDst.type === "abstractFloat") return {
94
+ rank: 1,
95
+ action: "cast",
96
+ targetType: trueDst.concretized
97
+ };
92
98
  if (trueSrc.type === "abstractFloat") {
93
- if (trueDst.type === "u32") return {
99
+ if (trueDst.type === "i32") return {
94
100
  rank: 2,
95
101
  action: "cast",
96
102
  targetType: trueDst
97
103
  };
98
- if (trueDst.type === "i32") return {
99
- rank: 1,
104
+ if (trueDst.type === "u32") return {
105
+ rank: 3,
100
106
  action: "cast",
101
107
  targetType: trueDst
102
108
  };
@@ -112,6 +118,10 @@ function getConversionRank(src, dest, allowImplicit) {
112
118
  function findBestType(types, uniqueTypes, allowImplicit) {
113
119
  let bestResult;
114
120
  for (const targetType of uniqueTypes) {
121
+ /**
122
+ * The type we end up converting to. Will be different than `targetType` if `targetType === abstractFloat`
123
+ */
124
+ let destType = targetType;
115
125
  const details = [];
116
126
  let sum = 0;
117
127
  for (const sourceType of types) {
@@ -119,9 +129,10 @@ function findBestType(types, uniqueTypes, allowImplicit) {
119
129
  sum += conversion.rank;
120
130
  if (conversion.rank === Number.POSITIVE_INFINITY) break;
121
131
  details.push(conversion);
132
+ if (conversion.action === "cast") destType = conversion.targetType;
122
133
  }
123
134
  if (sum < (bestResult?.sum ?? Number.POSITIVE_INFINITY)) bestResult = {
124
- type: targetType,
135
+ type: destType,
125
136
  details,
126
137
  sum
127
138
  };
@@ -167,7 +178,7 @@ function convertToCommonType(ctx, values, restrictTo, verbose = true) {
167
178
  if (DEV && Array.isArray(restrictTo) && restrictTo.length === 0) console.warn("convertToCommonType was called with an empty restrictTo array, which prevents any conversions from being made. If you intend to allow all conversions, pass undefined instead. If this was intended call the function conditionally since the result will always be undefined.");
168
179
  const conversion = getBestConversion(types, restrictTo);
169
180
  if (!conversion) return;
170
- if ((TEST || DEV) && verbose && conversion.hasImplicitConversions) console.warn(`Implicit conversions from [\n${values.map((v) => ` ${v.value}: ${safeStringify(v.dataType)}`).join(",\n")}\n] to ${conversion.targetType.type} are supported, but not recommended.
181
+ if ((TEST || DEV) && verbose && conversion.hasImplicitConversions) console.warn(`Implicit conversions from [\n${values.map((v) => ` ${ctx.resolveSnippet(v).value}: ${safeStringify(v.dataType)}`).join(",\n")}\n] to ${conversion.targetType.type} are supported, but not recommended.
171
182
  Consider using explicit conversions instead.`);
172
183
  return values.map((value, index) => {
173
184
  const action = conversion.actions[index];
@@ -194,5 +205,6 @@ function convertStructValues(ctx, structType, values) {
194
205
  return convertToCommonType(ctx, [val], [targetType])?.[0] ?? val;
195
206
  });
196
207
  }
208
+
197
209
  //#endregion
198
- export { convertStructValues, convertToCommonType, getBestConversion, tryConvertSnippet, unify };
210
+ export { convertStructValues, convertToCommonType, getBestConversion, tryConvertSnippet, unify };
@@ -10,6 +10,7 @@ import { ArrayExpression, concretize } from "./generationHelpers.js";
10
10
  import { accessIndex } from "./accessIndex.js";
11
11
  import { arrayLength } from "../std/array.js";
12
12
  import { isTgpuRange } from "../std/range.js";
13
+
13
14
  //#region src/tgsl/forOfUtils.ts
14
15
  function getLoopVarKind(elementSnippet) {
15
16
  return elementSnippet.origin === "constant-tgpu-const-ref" ? "const" : "let";
@@ -32,12 +33,20 @@ function getElementType(elementSnippet, iterableSnippet) {
32
33
  }
33
34
  function getRangeSnippets(ctx, iterableSnippet, unroll = false) {
34
35
  const { value, dataType } = iterableSnippet;
35
- if (isTgpuRange(value)) return {
36
- start: snip(value.start, i32, "constant"),
37
- end: snip(value.end, i32, "constant"),
38
- step: snip(value.step, i32, "constant"),
39
- comparison: value.step < 0 ? ">" : "<"
40
- };
36
+ if (isTgpuRange(value)) {
37
+ const { start, end, step } = value;
38
+ const dataType$1 = [
39
+ start,
40
+ end,
41
+ step
42
+ ].every((v) => v >= 0) ? u32 : i32;
43
+ return {
44
+ start: snip(start, dataType$1, "constant"),
45
+ end: snip(end, dataType$1, "constant"),
46
+ step: snip(step, dataType$1, "constant"),
47
+ comparison: step < 0 ? ">" : "<"
48
+ };
49
+ }
41
50
  if (!unroll && isEphemeralSnippet(iterableSnippet)) throw new Error(`\`for ... of ...\` loops only support std.range or iterables stored in variables.
42
51
  -----
43
52
  You can wrap iterable with \`tgpu.unroll(...)\`. If iterable is known at comptime, the loop will be unrolled.
@@ -67,5 +76,6 @@ You can wrap iterable with \`tgpu.unroll(...)\`. If iterable is known at comptim
67
76
  }
68
77
  throw new WgslTypeError("`for ... of ...` loops only support array or vector iterables");
69
78
  }
79
+
70
80
  //#endregion
71
- export { getElementSnippet, getElementType, getLoopVarKind, getRangeSnippets };
81
+ export { getElementSnippet, getElementType, getLoopVarKind, getRangeSnippets };
@@ -4,6 +4,7 @@ import { FunctionScopeLayer, ResolutionCtx } from "../types.js";
4
4
  import { BaseData } from "../data/wgslTypes.js";
5
5
 
6
6
  //#region src/tgsl/generationHelpers.d.ts
7
+
7
8
  type GenerationCtx = ResolutionCtx & {
8
9
  readonly pre: string;
9
10
  /**
@@ -7,6 +7,7 @@ import { getOwnSnippet } from "../types.js";
7
7
  import { stitch } from "../core/resolve/stitch.js";
8
8
  import { isRef } from "../data/ref.js";
9
9
  import { abstractFloat, abstractInt, bool, f32, i32 } from "../data/numeric.js";
10
+
10
11
  //#region src/tgsl/generationHelpers.ts
11
12
  function numericLiteralToSnippet(value) {
12
13
  if (value >= 2 ** 63 || value < -(2 ** 63)) return snip(value, abstractFloat, "constant");
@@ -24,9 +25,6 @@ function concretize(type) {
24
25
  function concretizeSnippet(snippet) {
25
26
  return snip(snippet.value, concretize(snippet.dataType), snippet.origin);
26
27
  }
27
- function concretizeSnippets(args) {
28
- return args.map(concretizeSnippet);
29
- }
30
28
  function coerceToSnippet(value) {
31
29
  if (isSnippet(value)) return value;
32
30
  if (isRef(value)) throw new Error("Cannot use refs (d.ref(...)) from the outer scope.");
@@ -63,5 +61,6 @@ var ArrayExpression = class {
63
61
  return snip(stitch`${`array<${ctx.resolve(this.type.elementType).value}, ${this.elements.length}>`}(${this.elements})`, this.type, "runtime");
64
62
  }
65
63
  };
64
+
66
65
  //#endregion
67
- export { ArrayExpression, coerceToSnippet, concretize, concretizeSnippets, numericLiteralToSnippet };
66
+ export { ArrayExpression, coerceToSnippet, concretize, concretizeSnippet, numericLiteralToSnippet };
package/tgsl/math.js CHANGED
@@ -1,5 +1,6 @@
1
1
  import { f32 } from "../data/numeric.js";
2
2
  import { abs, acos, acosh, asin, asinh, atan, atan2, atanh, ceil, cos, cosh, countLeadingZeros, exp, floor, log, log2, max, min, pow, sign, sin, sinh, sqrt, tan, tanh, trunc } from "../std/numeric.js";
3
+
3
4
  //#region src/tgsl/math.ts
4
5
  const mathToStd = {
5
6
  abs,
@@ -39,5 +40,6 @@ const mathToStd = {
39
40
  imul: void 0,
40
41
  round: void 0
41
42
  };
43
+
42
44
  //#endregion
43
- export { mathToStd };
45
+ export { mathToStd };
@@ -1,9 +1,10 @@
1
1
  import { ResolvedSnippet, Snippet } from "../data/snippet.js";
2
2
  import { GenerationCtx } from "./generationHelpers.js";
3
+ import { FunctionDefinitionOptions } from "./shaderGenerator_members.js";
3
4
  import { BaseData } from "../data/wgslTypes.js";
4
- import { Block } from "tinyest";
5
5
 
6
6
  //#region src/tgsl/shaderGenerator.d.ts
7
+
7
8
  /**
8
9
  * **NOTE: This is an unstable API and may change in the future.**
9
10
  *
@@ -12,7 +13,7 @@ import { Block } from "tinyest";
12
13
  */
13
14
  interface ShaderGenerator {
14
15
  initGenerator(ctx: GenerationCtx): void;
15
- functionDefinition(body: Block): string;
16
+ functionDefinition(options: FunctionDefinitionOptions): string;
16
17
  typeInstantiation(schema: BaseData, args: readonly Snippet[]): ResolvedSnippet;
17
18
  typeAnnotation(schema: BaseData): string;
18
19
  }
@@ -1,2 +1,15 @@
1
- import { ResolutionCtx } from "../types.js";
2
- import { UnknownData } from "../data/dataTypes.js";
1
+ import { Origin, Snippet } from "../data/snippet.js";
2
+ import { FunctionArgument, ResolutionCtx, TgpuShaderStage } from "../types.js";
3
+ import { BaseData } from "../data/wgslTypes.js";
4
+ import { UnknownData } from "../data/dataTypes.js";
5
+ import { Block } from "tinyest";
6
+
7
+ //#region src/tgsl/shaderGenerator_members.d.ts
8
+ interface FunctionDefinitionOptions {
9
+ readonly functionType: 'normal' | TgpuShaderStage;
10
+ readonly args: readonly FunctionArgument[];
11
+ readonly body: Block;
12
+ determineReturnType(): BaseData;
13
+ }
14
+ //#endregion
15
+ export { FunctionDefinitionOptions };
@@ -1,6 +1,8 @@
1
- import { __exportAll } from "../_virtual/_rolldown/runtime.js";
1
+ import { __export } from "../_virtual/rolldown_runtime.js";
2
2
  import { UnknownData } from "../data/dataTypes.js";
3
+
3
4
  //#region src/tgsl/shaderGenerator_members.ts
4
- var shaderGenerator_members_exports = /* @__PURE__ */ __exportAll({ UnknownData: () => UnknownData });
5
+ var shaderGenerator_members_exports = /* @__PURE__ */ __export({ UnknownData: () => UnknownData });
6
+
5
7
  //#endregion
6
- export { shaderGenerator_members_exports };
8
+ export { shaderGenerator_members_exports };