typegpu 0.10.2 → 0.11.0

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 (211) hide show
  1. package/_virtual/_rolldown/runtime.js +6 -11
  2. package/builtin.js +1 -3
  3. package/common/fullScreenTriangle.d.ts +1 -5
  4. package/common/fullScreenTriangle.js +1 -3
  5. package/common/index.d.ts +3 -2
  6. package/common/index.js +6 -4
  7. package/common/writeSoA.d.ts +16 -0
  8. package/common/writeSoA.js +90 -0
  9. package/core/buffer/buffer.d.ts +12 -7
  10. package/core/buffer/buffer.js +102 -53
  11. package/core/buffer/bufferShorthand.d.ts +5 -5
  12. package/core/buffer/bufferShorthand.js +9 -5
  13. package/core/buffer/bufferUsage.d.ts +0 -2
  14. package/core/buffer/bufferUsage.js +6 -4
  15. package/core/constant/tgpuConstant.d.ts +2 -1
  16. package/core/constant/tgpuConstant.js +8 -7
  17. package/core/declare/tgpuDeclare.js +8 -9
  18. package/core/function/autoIO.d.ts +7 -6
  19. package/core/function/autoIO.js +1 -3
  20. package/core/function/comptime.js +1 -3
  21. package/core/function/createCallableSchema.js +4 -6
  22. package/core/function/dualImpl.js +1 -3
  23. package/core/function/entryInputRouter.js +39 -0
  24. package/core/function/extractArgs.js +2 -2
  25. package/core/function/fnCore.js +19 -8
  26. package/core/function/fnTypes.d.ts +14 -8
  27. package/core/function/ioSchema.js +24 -3
  28. package/core/function/shelllessImpl.js +1 -3
  29. package/core/function/templateUtils.js +1 -2
  30. package/core/function/tgpuComputeFn.d.ts +2 -3
  31. package/core/function/tgpuComputeFn.js +9 -16
  32. package/core/function/tgpuFn.d.ts +2 -2
  33. package/core/function/tgpuFn.js +1 -3
  34. package/core/function/tgpuFragmentFn.d.ts +5 -1
  35. package/core/function/tgpuFragmentFn.js +5 -10
  36. package/core/function/tgpuVertexFn.d.ts +4 -0
  37. package/core/function/tgpuVertexFn.js +6 -12
  38. package/core/pipeline/applyPipelineState.js +1 -3
  39. package/core/pipeline/computePipeline.d.ts +2 -6
  40. package/core/pipeline/computePipeline.js +64 -63
  41. package/core/pipeline/connectAttachmentToShader.js +1 -3
  42. package/core/pipeline/connectTargetsToShader.js +1 -3
  43. package/core/pipeline/limitsOverflow.js +1 -2
  44. package/core/pipeline/pipelineUtils.js +29 -0
  45. package/core/pipeline/renderPipeline.d.ts +23 -5
  46. package/core/pipeline/renderPipeline.js +32 -14
  47. package/core/pipeline/timeable.d.ts +0 -3
  48. package/core/pipeline/timeable.js +3 -9
  49. package/core/pipeline/typeGuards.js +1 -3
  50. package/core/querySet/querySet.d.ts +0 -2
  51. package/core/querySet/querySet.js +37 -36
  52. package/core/rawCodeSnippet/tgpuRawCodeSnippet.js +1 -3
  53. package/core/resolve/externals.d.ts +0 -2
  54. package/core/resolve/externals.js +2 -4
  55. package/core/resolve/namespace.js +1 -3
  56. package/core/resolve/resolveData.js +1 -3
  57. package/core/resolve/stitch.js +1 -3
  58. package/core/resolve/tgpuResolve.d.ts +3 -1
  59. package/core/resolve/tgpuResolve.js +3 -5
  60. package/core/root/configurableImpl.js +2 -3
  61. package/core/root/init.d.ts +0 -5
  62. package/core/root/init.js +35 -28
  63. package/core/root/rootTypes.d.ts +25 -5
  64. package/core/sampler/sampler.d.ts +0 -4
  65. package/core/sampler/sampler.js +3 -3
  66. package/core/simulate/tgpuSimulate.js +1 -3
  67. package/core/slot/accessor.d.ts +0 -4
  68. package/core/slot/accessor.js +1 -3
  69. package/core/slot/internalSlots.js +1 -3
  70. package/core/slot/lazy.js +1 -3
  71. package/core/slot/slot.js +2 -3
  72. package/core/slot/slotTypes.js +1 -3
  73. package/core/texture/externalTexture.d.ts +0 -6
  74. package/core/texture/externalTexture.js +2 -3
  75. package/core/texture/texture.d.ts +0 -4
  76. package/core/texture/texture.js +5 -3
  77. package/core/texture/textureFormats.js +1 -3
  78. package/core/texture/textureUtils.js +1 -3
  79. package/core/texture/usageExtension.js +1 -3
  80. package/core/unroll/tgpuUnroll.d.ts +58 -3
  81. package/core/unroll/tgpuUnroll.js +63 -5
  82. package/core/valueProxyUtils.js +1 -3
  83. package/core/variable/tgpuVariable.js +1 -3
  84. package/core/vertexLayout/connectAttributesToShader.js +1 -3
  85. package/core/vertexLayout/vertexLayout.js +9 -9
  86. package/data/alignIO.js +1 -2
  87. package/data/alignmentOf.d.ts +0 -1
  88. package/data/alignmentOf.js +1 -3
  89. package/data/array.d.ts +1 -3
  90. package/data/array.js +2 -4
  91. package/data/atomic.js +2 -3
  92. package/data/attributes.js +3 -3
  93. package/data/autoStruct.d.ts +1 -3
  94. package/data/autoStruct.js +1 -3
  95. package/data/compiledIO.js +83 -86
  96. package/data/dataIO.js +46 -39
  97. package/data/dataTypes.d.ts +7 -7
  98. package/data/dataTypes.js +6 -3
  99. package/data/deepEqual.js +1 -3
  100. package/data/disarray.d.ts +1 -3
  101. package/data/disarray.js +1 -3
  102. package/data/getLongestContiguousPrefix.d.ts +0 -1
  103. package/data/getLongestContiguousPrefix.js +1 -3
  104. package/data/index.d.ts +3 -3
  105. package/data/index.js +10 -3
  106. package/data/isContiguous.d.ts +0 -1
  107. package/data/isContiguous.js +1 -3
  108. package/data/matrix.d.ts +8 -10
  109. package/data/matrix.js +32 -18
  110. package/data/numberOps.js +1 -2
  111. package/data/numeric.js +16 -29
  112. package/data/offsetUtils.d.ts +2 -2
  113. package/data/offsetUtils.js +3 -5
  114. package/data/offsets.js +1 -3
  115. package/data/partialIO.js +84 -39
  116. package/data/ptr.d.ts +0 -1
  117. package/data/ptr.js +1 -3
  118. package/data/ref.d.ts +0 -3
  119. package/data/ref.js +1 -3
  120. package/data/sampler.js +1 -3
  121. package/data/schemaCallWrapper.js +1 -3
  122. package/data/schemaMemoryLayout.js +1 -3
  123. package/data/sizeOf.d.ts +0 -1
  124. package/data/sizeOf.js +1 -3
  125. package/data/snippet.js +12 -3
  126. package/data/struct.js +1 -3
  127. package/data/texture.js +1 -3
  128. package/data/unstruct.js +1 -3
  129. package/data/vector.js +4 -12
  130. package/data/vectorImpl.js +27 -28
  131. package/data/vectorOps.js +20 -3
  132. package/data/vertexFormatData.js +2 -3
  133. package/data/wgslTypes.d.ts +39 -11
  134. package/data/wgslTypes.js +10 -3
  135. package/errors.js +6 -3
  136. package/execMode.js +1 -3
  137. package/extension.js +1 -3
  138. package/getGPUValue.js +1 -3
  139. package/index.d.ts +4 -2
  140. package/index.js +3 -3
  141. package/indexNamedExports.d.ts +3 -1
  142. package/mathUtils.js +1 -2
  143. package/memo.js +8 -8
  144. package/nameRegistry.js +1 -3
  145. package/package.js +2 -3
  146. package/package.json +7 -7
  147. package/resolutionCtx.d.ts +0 -10
  148. package/resolutionCtx.js +84 -18
  149. package/shared/env.js +1 -2
  150. package/shared/generators.js +1 -2
  151. package/shared/meta.js +1 -3
  152. package/shared/repr.d.ts +32 -2
  153. package/shared/stringify.js +1 -3
  154. package/shared/symbols.d.ts +10 -1
  155. package/shared/symbols.js +10 -33
  156. package/shared/utilityTypes.d.ts +6 -2
  157. package/shared/utilityTypes.js +1 -2
  158. package/shared/vertexFormat.js +1 -2
  159. package/std/array.d.ts +1 -1
  160. package/std/array.js +1 -3
  161. package/std/atomic.d.ts +12 -12
  162. package/std/atomic.js +1 -3
  163. package/std/bitcast.d.ts +2 -2
  164. package/std/bitcast.js +1 -3
  165. package/std/boolean.d.ts +30 -16
  166. package/std/boolean.js +37 -12
  167. package/std/derivative.d.ts +9 -9
  168. package/std/derivative.js +1 -3
  169. package/std/discard.d.ts +1 -1
  170. package/std/discard.js +1 -3
  171. package/std/extensions.d.ts +1 -3
  172. package/std/extensions.js +1 -3
  173. package/std/index.d.ts +5 -4
  174. package/std/index.js +8 -5
  175. package/std/matrix.d.ts +5 -5
  176. package/std/matrix.js +1 -3
  177. package/std/numeric.d.ts +78 -132
  178. package/std/numeric.js +1 -3
  179. package/std/operators.d.ts +16 -8
  180. package/std/operators.js +80 -6
  181. package/std/packing.d.ts +4 -4
  182. package/std/packing.js +1 -3
  183. package/std/range.d.ts +24 -0
  184. package/std/range.js +38 -0
  185. package/std/subgroup.d.ts +21 -21
  186. package/std/subgroup.js +1 -3
  187. package/std/texture.d.ts +20 -11
  188. package/std/texture.js +13 -3
  189. package/tgpu.js +1 -3
  190. package/tgpuBindGroupLayout.js +9 -8
  191. package/tgpuUnstable.js +1 -3
  192. package/tgsl/accessIndex.js +2 -4
  193. package/tgsl/accessProp.js +8 -6
  194. package/tgsl/consoleLog/deserializers.js +1 -3
  195. package/tgsl/consoleLog/logGenerator.js +2 -4
  196. package/tgsl/consoleLog/serializers.js +24 -26
  197. package/tgsl/consoleLog/types.d.ts +0 -2
  198. package/tgsl/consoleLog/types.js +1 -2
  199. package/tgsl/conversion.js +1 -3
  200. package/tgsl/forOfUtils.js +35 -9
  201. package/tgsl/generationHelpers.js +3 -3
  202. package/tgsl/math.js +1 -3
  203. package/tgsl/shaderGenerator.d.ts +10 -8
  204. package/tgsl/shaderGenerator_members.d.ts +2 -0
  205. package/tgsl/shaderGenerator_members.js +6 -0
  206. package/tgsl/shellless.js +1 -8
  207. package/tgsl/wgslGenerator.d.ts +36 -0
  208. package/tgsl/wgslGenerator.js +144 -81
  209. package/types.d.ts +14 -4
  210. package/types.js +3 -3
  211. package/wgslExtensions.js +1 -2
package/getGPUValue.js CHANGED
@@ -1,9 +1,7 @@
1
1
  import { $gpuValueOf } from "./shared/symbols.js";
2
-
3
2
  //#region src/getGPUValue.ts
4
3
  function getGPUValue(object) {
5
4
  return object?.[$gpuValueOf];
6
5
  }
7
-
8
6
  //#endregion
9
- export { getGPUValue };
7
+ export { getGPUValue };
package/index.d.ts CHANGED
@@ -7,7 +7,7 @@ import { TgpuComputeFn, TgpuComputeFnShell, computeFn, isTgpuComputeFn } from ".
7
7
  import { TgpuVar, VariableScope, isVariable, privateVar, workgroupVar } from "./core/variable/tgpuVariable.js";
8
8
  import { Eventual, TgpuAccessor, TgpuLazy, TgpuMutableAccessor, TgpuSlot, isAccessor, isLazy, isMutableAccessor, isSlot } from "./core/slot/slotTypes.js";
9
9
  import { TgpuComputePipeline } from "./core/pipeline/computePipeline.js";
10
- import { AutoFragmentIn, AutoFragmentOut, AutoVertexIn, AutoVertexOut } from "./core/function/autoIO.js";
10
+ import { AutoFragmentIn, AutoFragmentOut, AutoVertexOut, _AutoVertexIn } from "./core/function/autoIO.js";
11
11
  import { TgpuFragmentFn, TgpuFragmentFnShell, fragmentFn, isTgpuFragmentFn } from "./core/function/tgpuFragmentFn.js";
12
12
  import { TgpuVertexFn, TgpuVertexFnShell, isTgpuVertexFn, vertexFn } from "./core/function/tgpuVertexFn.js";
13
13
  import { TextureProps } from "./core/texture/textureProps.js";
@@ -16,6 +16,7 @@ import { TgpuVertexLayout, vertexLayout } from "./core/vertexLayout/vertexLayout
16
16
  import { ColorAttachment, TgpuPrimitiveState, TgpuRenderPipeline } from "./core/pipeline/renderPipeline.js";
17
17
  import { TgpuComparisonSampler, TgpuFixedComparisonSampler, TgpuFixedSampler, TgpuSampler, isComparisonSampler, isSampler } from "./core/sampler/sampler.js";
18
18
  import { BindLayoutEntry, ExtractBindGroupInputFromLayout, LayoutEntryToInput, TgpuBindGroup, TgpuBindGroupLayout, TgpuLayoutComparisonSampler, TgpuLayoutEntry, TgpuLayoutExternalTexture, TgpuLayoutSampler, TgpuLayoutStorage, TgpuLayoutTexture, TgpuLayoutUniform, bindGroupLayout } from "./tgpuBindGroupLayout.js";
19
+ import { ShaderGenerator } from "./tgsl/shaderGenerator.js";
19
20
  import { Configurable, TgpuGuardedComputePipeline, TgpuRoot, ValidateBufferSchema, ValidateStorageSchema, ValidateUniformSchema, WithBinding, WithCompute, WithFragment, WithVertex, Withable } from "./core/root/rootTypes.js";
20
21
  import { IndexFlag, TgpuBuffer, Uniform, UniformFlag, ValidUsagesFor, Vertex, VertexFlag, isBuffer, isUsableAsVertex } from "./core/buffer/buffer.js";
21
22
  import { TgpuDeclare } from "./core/declare/tgpuDeclare.js";
@@ -36,6 +37,7 @@ import { index_d_exports as index_d_exports$1 } from "./data/index.js";
36
37
  import { index_d_exports as index_d_exports$2 } from "./std/index.js";
37
38
  import { index_d_exports } from "./common/index.js";
38
39
  import { MissingBindGroupsError, MissingLinksError, MissingSlotValueError, MissingVertexBuffersError, NotUniformError, ResolutionError } from "./errors.js";
40
+ import { WgslGenerator } from "./tgsl/wgslGenerator.js";
39
41
  import { TgpuRenderPipelineDescriptor } from "./indexNamedExports.js";
40
42
 
41
43
  //#region src/index.d.ts
@@ -66,4 +68,4 @@ declare const tgpu: {
66
68
  '~unstable': typeof tgpuUnstable_d_exports;
67
69
  };
68
70
  //#endregion
69
- export { AutoFragmentIn, AutoFragmentOut, AutoVertexIn, AutoVertexOut, BindLayoutEntry, ColorAttachment, Configurable, Eventual, ExtractBindGroupInputFromLayout, INTERNAL_GlobalExt, IndexFlag, InitFromDeviceOptions, InitOptions, LayoutEntryToInput, MissingBindGroupsError, MissingLinksError, MissingSlotValueError, MissingVertexBuffersError, Namespace, NotUniformError, RawCodeSnippetOrigin, RenderFlag, ResolutionError, SampledFlag, Storage, StorageFlag, TextureProps, TgpuAccessor, TgpuBindGroup, TgpuBindGroupLayout, TgpuBuffer, TgpuBufferMutable, TgpuBufferReadonly, TgpuBufferUniform, TgpuComparisonSampler, TgpuComptime, TgpuComputeFn, TgpuComputeFnShell, TgpuComputePipeline, TgpuConst, TgpuDeclare, TgpuFixedComparisonSampler, TgpuFixedSampler, TgpuFn, TgpuFnShell, TgpuFragmentFn, TgpuFragmentFnShell, TgpuGenericFn, TgpuGuardedComputePipeline, TgpuLayoutComparisonSampler, TgpuLayoutEntry, TgpuLayoutExternalTexture, TgpuLayoutSampler, TgpuLayoutStorage, TgpuLayoutTexture, TgpuLayoutUniform, TgpuLazy, TgpuMutable, TgpuMutableAccessor, TgpuPrimitiveState, TgpuQuerySet, TgpuRawCodeSnippet, TgpuReadonly, TgpuRenderPipeline, TgpuRenderPipelineDescriptor, TgpuRoot, TgpuSampler, TgpuSlot, TgpuTexture, TgpuTextureView, TgpuUniform, TgpuVar, TgpuVertexFn, TgpuVertexFnShell, TgpuVertexLayout, Uniform, UniformFlag, ValidUsagesFor, ValidateBufferSchema, ValidateStorageSchema, ValidateUniformSchema, VariableScope, Vertex, VertexFlag, WithBinding, WithCompute, WithFragment, WithVertex, Withable, index_d_exports as common, index_d_exports$1 as d, tgpu as default, tgpu, isAccessor, isBuffer, isBufferShorthand, isComparisonSampler, isLazy, isMutableAccessor, isSampler, isSlot, isTexture, isTgpuComputeFn, isTgpuFn, isTgpuFragmentFn, isTgpuVertexFn, isUsableAsRender, isUsableAsSampled, isUsableAsStorage, isUsableAsUniform, isUsableAsVertex, isVariable, index_d_exports$2 as std };
71
+ export { AutoFragmentIn, AutoFragmentOut, _AutoVertexIn as AutoVertexIn, AutoVertexOut, BindLayoutEntry, ColorAttachment, Configurable, Eventual, ExtractBindGroupInputFromLayout, INTERNAL_GlobalExt, IndexFlag, InitFromDeviceOptions, InitOptions, LayoutEntryToInput, MissingBindGroupsError, MissingLinksError, MissingSlotValueError, MissingVertexBuffersError, Namespace, NotUniformError, RawCodeSnippetOrigin, RenderFlag, ResolutionError, SampledFlag, ShaderGenerator, Storage, StorageFlag, TextureProps, TgpuAccessor, TgpuBindGroup, TgpuBindGroupLayout, TgpuBuffer, TgpuBufferMutable, TgpuBufferReadonly, TgpuBufferUniform, TgpuComparisonSampler, TgpuComptime, TgpuComputeFn, TgpuComputeFnShell, TgpuComputePipeline, TgpuConst, TgpuDeclare, TgpuFixedComparisonSampler, TgpuFixedSampler, TgpuFn, TgpuFnShell, TgpuFragmentFn, TgpuFragmentFnShell, TgpuGenericFn, TgpuGuardedComputePipeline, TgpuLayoutComparisonSampler, TgpuLayoutEntry, TgpuLayoutExternalTexture, TgpuLayoutSampler, TgpuLayoutStorage, TgpuLayoutTexture, TgpuLayoutUniform, TgpuLazy, TgpuMutable, TgpuMutableAccessor, TgpuPrimitiveState, TgpuQuerySet, TgpuRawCodeSnippet, TgpuReadonly, TgpuRenderPipeline, TgpuRenderPipelineDescriptor, TgpuRoot, TgpuSampler, TgpuSlot, TgpuTexture, TgpuTextureView, TgpuUniform, TgpuVar, TgpuVertexFn, TgpuVertexFnShell, TgpuVertexLayout, Uniform, UniformFlag, ValidUsagesFor, ValidateBufferSchema, ValidateStorageSchema, ValidateUniformSchema, VariableScope, Vertex, VertexFlag, WgslGenerator, WithBinding, WithCompute, WithFragment, WithVertex, Withable, index_d_exports as common, index_d_exports$1 as d, tgpu as default, tgpu, isAccessor, isBuffer, isBufferShorthand, isComparisonSampler, isLazy, isMutableAccessor, isSampler, isSlot, isTexture, isTgpuComputeFn, isTgpuFn, isTgpuFragmentFn, isTgpuVertexFn, isUsableAsRender, isUsableAsSampled, isUsableAsStorage, isUsableAsUniform, isUsableAsVertex, isVariable, index_d_exports$2 as std };
package/index.js CHANGED
@@ -1,5 +1,6 @@
1
1
  import { MissingBindGroupsError, MissingLinksError, MissingSlotValueError, MissingVertexBuffersError, NotUniformError, ResolutionError } from "./errors.js";
2
2
  import { isAccessor, isLazy, isMutableAccessor, isSlot } from "./core/slot/slotTypes.js";
3
+ import { shaderGenerator_members_exports } from "./tgsl/shaderGenerator_members.js";
3
4
  import { isTgpuFn } from "./core/function/tgpuFn.js";
4
5
  import { isUsableAsStorage } from "./extension.js";
5
6
  import { isUsableAsUniform } from "./core/buffer/bufferUsage.js";
@@ -8,6 +9,7 @@ import { isComparisonSampler, isSampler } from "./core/sampler/sampler.js";
8
9
  import { isTexture } from "./core/texture/texture.js";
9
10
  import { isUsableAsRender, isUsableAsSampled } from "./core/texture/usageExtension.js";
10
11
  import { isVariable } from "./core/variable/tgpuVariable.js";
12
+ import { WgslGenerator } from "./tgsl/wgslGenerator.js";
11
13
  import { isBufferShorthand } from "./core/buffer/bufferShorthand.js";
12
14
  import { isTgpuComputeFn } from "./core/function/tgpuComputeFn.js";
13
15
  import { isTgpuFragmentFn } from "./core/function/tgpuFragmentFn.js";
@@ -16,12 +18,10 @@ import { tgpu_exports } from "./tgpu.js";
16
18
  import { data_exports } from "./data/index.js";
17
19
  import { std_exports } from "./std/index.js";
18
20
  import { common_exports } from "./common/index.js";
19
-
20
21
  //#region src/index.js
21
22
  /**
22
23
  * @module typegpu
23
24
  */
24
25
  var src_default = tgpu_exports;
25
-
26
26
  //#endregion
27
- export { MissingBindGroupsError, MissingLinksError, MissingSlotValueError, MissingVertexBuffersError, NotUniformError, ResolutionError, common_exports as common, data_exports as d, src_default as default, isAccessor, isBuffer, isBufferShorthand, isComparisonSampler, isLazy, isMutableAccessor, isSampler, isSlot, isTexture, isTgpuComputeFn, isTgpuFn, isTgpuFragmentFn, isTgpuVertexFn, isUsableAsRender, isUsableAsSampled, isUsableAsStorage, isUsableAsUniform, isUsableAsVertex, isVariable, std_exports as std, tgpu_exports as tgpu };
27
+ export { MissingBindGroupsError, MissingLinksError, MissingSlotValueError, MissingVertexBuffersError, NotUniformError, ResolutionError, shaderGenerator_members_exports as ShaderGenerator, WgslGenerator, common_exports as common, data_exports as d, src_default as default, isAccessor, isBuffer, isBufferShorthand, isComparisonSampler, isLazy, isMutableAccessor, isSampler, isSlot, isTexture, isTgpuComputeFn, isTgpuFn, isTgpuFragmentFn, isTgpuVertexFn, isUsableAsRender, isUsableAsSampled, isUsableAsStorage, isUsableAsUniform, isUsableAsVertex, isVariable, std_exports as std, tgpu_exports as tgpu };
@@ -7,7 +7,7 @@ import { TgpuComputeFn, TgpuComputeFnShell, isTgpuComputeFn } from "./core/funct
7
7
  import { TgpuVar, VariableScope, isVariable } from "./core/variable/tgpuVariable.js";
8
8
  import { Eventual, TgpuAccessor, TgpuLazy, TgpuMutableAccessor, TgpuSlot, isAccessor, isLazy, isMutableAccessor, isSlot } from "./core/slot/slotTypes.js";
9
9
  import { TgpuComputePipeline } from "./core/pipeline/computePipeline.js";
10
- import { AutoFragmentIn, AutoFragmentOut, AutoVertexIn, AutoVertexOut } from "./core/function/autoIO.js";
10
+ import { AutoFragmentIn, AutoFragmentOut, AutoVertexOut, _AutoVertexIn } from "./core/function/autoIO.js";
11
11
  import { TgpuFragmentFn, TgpuFragmentFnShell, isTgpuFragmentFn } from "./core/function/tgpuFragmentFn.js";
12
12
  import { TgpuVertexFn, TgpuVertexFnShell, isTgpuVertexFn } from "./core/function/tgpuVertexFn.js";
13
13
  import { TextureProps } from "./core/texture/textureProps.js";
@@ -16,6 +16,7 @@ import { TgpuVertexLayout } from "./core/vertexLayout/vertexLayout.js";
16
16
  import { ColorAttachment, TgpuPrimitiveState, TgpuRenderPipeline } from "./core/pipeline/renderPipeline.js";
17
17
  import { TgpuComparisonSampler, TgpuFixedComparisonSampler, TgpuFixedSampler, TgpuSampler, isComparisonSampler, isSampler } from "./core/sampler/sampler.js";
18
18
  import { BindLayoutEntry, ExtractBindGroupInputFromLayout, LayoutEntryToInput, TgpuBindGroup, TgpuBindGroupLayout, TgpuLayoutComparisonSampler, TgpuLayoutEntry, TgpuLayoutExternalTexture, TgpuLayoutSampler, TgpuLayoutStorage, TgpuLayoutTexture, TgpuLayoutUniform } from "./tgpuBindGroupLayout.js";
19
+ import { ShaderGenerator } from "./tgsl/shaderGenerator.js";
19
20
  import { Configurable, TgpuGuardedComputePipeline, TgpuRoot, ValidateBufferSchema, ValidateStorageSchema, ValidateUniformSchema, WithBinding, WithCompute, WithFragment, WithVertex, Withable } from "./core/root/rootTypes.js";
20
21
  import { IndexFlag, TgpuBuffer, Uniform, UniformFlag, ValidUsagesFor, Vertex, VertexFlag, isBuffer, isUsableAsVertex } from "./core/buffer/buffer.js";
21
22
  import { TgpuDeclare } from "./core/declare/tgpuDeclare.js";
@@ -30,6 +31,7 @@ import { index_d_exports } from "./data/index.js";
30
31
  import { index_d_exports as index_d_exports$1 } from "./std/index.js";
31
32
  import { index_d_exports as index_d_exports$2 } from "./common/index.js";
32
33
  import { MissingBindGroupsError, MissingLinksError, MissingSlotValueError, MissingVertexBuffersError, NotUniformError, ResolutionError } from "./errors.js";
34
+ import { WgslGenerator } from "./tgsl/wgslGenerator.js";
33
35
 
34
36
  //#region src/indexNamedExports.d.ts
35
37
  /** @deprecated Use TgpuRenderPipeline.Descriptor */
package/mathUtils.js CHANGED
@@ -8,6 +8,5 @@ const roundUp = (value, modulo) => {
8
8
  const invBitMask = ~bitMask;
9
9
  return (value & bitMask) === 0 ? value : (value & invBitMask) + modulo;
10
10
  };
11
-
12
11
  //#endregion
13
- export { roundUp };
12
+ export { roundUp };
package/memo.js CHANGED
@@ -6,17 +6,17 @@
6
6
  * If the key can be garbage collected, it will be.
7
7
  */
8
8
  var WeakMemo = class {
9
- _map = /* @__PURE__ */ new WeakMap();
10
- constructor(_make) {
11
- this._make = _make;
9
+ #map = /* @__PURE__ */ new WeakMap();
10
+ #make;
11
+ constructor(make) {
12
+ this.#make = make;
12
13
  }
13
14
  getOrMake(key, ...args) {
14
- if (this._map.has(key)) return this._map.get(key);
15
- const value = this._make(key, ...args);
16
- this._map.set(key, value);
15
+ if (this.#map.has(key)) return this.#map.get(key);
16
+ const value = this.#make(key, ...args);
17
+ this.#map.set(key, value);
17
18
  return value;
18
19
  }
19
20
  };
20
-
21
21
  //#endregion
22
- export { WeakMemo };
22
+ export { WeakMemo };
package/nameRegistry.js CHANGED
@@ -1,5 +1,4 @@
1
1
  import { invariant } from "./errors.js";
2
-
3
2
  //#region src/nameRegistry.ts
4
3
  const bannedTokens = new Set([
5
4
  "alias",
@@ -444,6 +443,5 @@ var StrictNameRegistry = class extends NameRegistryImpl {
444
443
  return name;
445
444
  }
446
445
  };
447
-
448
446
  //#endregion
449
- export { RandomNameRegistry, StrictNameRegistry, isValidProp };
447
+ export { RandomNameRegistry, StrictNameRegistry, isValidProp };
package/package.js CHANGED
@@ -1,5 +1,4 @@
1
1
  //#region package.json
2
- var version = "0.10.2";
3
-
2
+ var version = "0.11.0";
4
3
  //#endregion
5
- export { version };
4
+ export { version };
package/package.json CHANGED
@@ -1,7 +1,6 @@
1
1
  {
2
2
  "name": "typegpu",
3
- "version": "0.10.2",
4
- "private": false,
3
+ "version": "0.11.0",
5
4
  "description": "A thin layer between JS and WebGPU/WGSL that improves development experience and allows for faster iteration.",
6
5
  "keywords": [
7
6
  "compute",
@@ -20,7 +19,8 @@
20
19
  "license": "MIT",
21
20
  "repository": {
22
21
  "type": "git",
23
- "url": "git+https://github.com/software-mansion/TypeGPU.git"
22
+ "url": "git+https://github.com/software-mansion/TypeGPU.git",
23
+ "directory": "packages/typegpu"
24
24
  },
25
25
  "type": "module",
26
26
  "sideEffects": false,
@@ -44,15 +44,15 @@
44
44
  }
45
45
  },
46
46
  "dependencies": {
47
- "tinyest": "~0.3.0",
48
- "tsover-runtime": "^0.0.5",
49
- "typed-binary": "^4.3.1"
47
+ "tinyest": "~0.3.1",
48
+ "tsover-runtime": "^0.0.6",
49
+ "typed-binary": "^4.3.3"
50
50
  },
51
51
  "engines": {
52
52
  "node": ">=12.20.0"
53
53
  },
54
54
  "main": "./index.js",
55
55
  "types": "./index.d.ts",
56
- "peerDependencies": {},
56
+ "private": false,
57
57
  "scripts": {}
58
58
  }
@@ -1,15 +1,5 @@
1
- import "./data/snippet.js";
2
- import "./tgsl/shellless.js";
3
1
  import { LogResources } from "./tgsl/consoleLog/types.js";
4
- import "./core/slot/slotTypes.js";
5
2
  import { TgpuBindGroup, TgpuBindGroupLayout } from "./tgpuBindGroupLayout.js";
6
- import "./tgsl/shaderGenerator.js";
7
- import "./core/root/rootTypes.js";
8
- import "./types.js";
9
- import "./data/wgslTypes.js";
10
- import "./data/dataTypes.js";
11
- import "./core/resolve/namespace.js";
12
-
13
3
  //#region src/resolutionCtx.d.ts
14
4
  /**
15
5
  * The results of a WGSL resolution.
package/resolutionCtx.js CHANGED
@@ -1,7 +1,7 @@
1
1
  import { $internal, $providing, $resolve, isMarkedInternal } from "./shared/symbols.js";
2
2
  import { getName, hasTinyestMetadata, setName } from "./shared/meta.js";
3
3
  import { Void, isPtr, isWgslArray, isWgslStruct } from "./data/wgslTypes.js";
4
- import { UnknownData, isData } from "./data/dataTypes.js";
4
+ import { UnknownData, isData, undecorate } from "./data/dataTypes.js";
5
5
  import { snip } from "./data/snippet.js";
6
6
  import { MissingSlotValueError, ResolutionError, WgslTypeError, invariant } from "./errors.js";
7
7
  import { isLazy, isProviding, isSlot } from "./core/slot/slotTypes.js";
@@ -11,21 +11,20 @@ import { stitch } from "./core/resolve/stitch.js";
11
11
  import { safeStringify } from "./shared/stringify.js";
12
12
  import { getBestConversion } from "./tgsl/conversion.js";
13
13
  import { bool } from "./data/numeric.js";
14
+ import { coerceToSnippet, concretize, numericLiteralToSnippet } from "./tgsl/generationHelpers.js";
14
15
  import { getAttributesString } from "./data/attributes.js";
15
16
  import { createIoSchema } from "./core/function/ioSchema.js";
16
17
  import { AutoStruct } from "./data/autoStruct.js";
17
- import { coerceToSnippet, concretize, numericLiteralToSnippet } from "./tgsl/generationHelpers.js";
18
+ import { EntryInputRouter } from "./core/function/entryInputRouter.js";
18
19
  import { accessProp } from "./tgsl/accessProp.js";
19
20
  import { isTgpuFn } from "./core/function/tgpuFn.js";
20
21
  import { getUniqueName } from "./core/resolve/namespace.js";
21
- import { resolveData } from "./core/resolve/resolveData.js";
22
22
  import { ConfigurableImpl } from "./core/root/configurableImpl.js";
23
23
  import { naturalsExcept } from "./shared/generators.js";
24
24
  import { TgpuBindGroupImpl, bindGroupLayout } from "./tgpuBindGroupLayout.js";
25
25
  import { LogGeneratorImpl, LogGeneratorNullImpl } from "./tgsl/consoleLog/logGenerator.js";
26
26
  import wgslGenerator from "./tgsl/wgslGenerator.js";
27
27
  import { FuncParameterType } from "tinyest";
28
-
29
28
  //#region src/resolutionCtx.ts
30
29
  /**
31
30
  * Inserted into bind group entry definitions that belong
@@ -191,7 +190,6 @@ var IndentController = class {
191
190
  };
192
191
  var ResolutionCtxImpl = class {
193
192
  #namespaceInternal;
194
- #shaderGenerator;
195
193
  _indentController = new IndentController();
196
194
  _itemStateStack = new ItemStateStackImpl();
197
195
  #modeStack = [];
@@ -199,6 +197,7 @@ var ResolutionCtxImpl = class {
199
197
  _varyingLocations;
200
198
  #currentlyResolvedItems = /* @__PURE__ */ new WeakSet();
201
199
  #logGenerator;
200
+ gen;
202
201
  get varyingLocations() {
203
202
  return this._varyingLocations;
204
203
  }
@@ -216,7 +215,7 @@ var ResolutionCtxImpl = class {
216
215
  expectedType;
217
216
  constructor(opts) {
218
217
  this.enableExtensions = opts.enableExtensions;
219
- this.#shaderGenerator = opts.shaderGenerator ?? wgslGenerator;
218
+ this.gen = opts.shaderGenerator ?? wgslGenerator;
220
219
  this.#logGenerator = opts.root ? new LogGeneratorImpl(opts.root) : new LogGeneratorNullImpl();
221
220
  this.#namespaceInternal = opts.namespace[$internal];
222
221
  }
@@ -288,7 +287,62 @@ var ResolutionCtxImpl = class {
288
287
  this.#namespaceInternal.nameRegistry.pushFunctionScope();
289
288
  const args = [];
290
289
  const argAliases = [];
291
- for (const [i, argType] of options.argTypes.entries()) {
290
+ const pendingHeaderEntries = [];
291
+ if (options.entryInput) {
292
+ const { dataSchema, positionalArgs } = options.entryInput;
293
+ const firstParam = options.params[0];
294
+ const structArgName = this.makeNameValid("_arg_0");
295
+ const structArg = dataSchema ? snip(structArgName, dataSchema, "argument") : void 0;
296
+ if (structArg) {
297
+ args.push(structArg);
298
+ pendingHeaderEntries.push({
299
+ argName: structArgName,
300
+ header: `${structArgName}: ${this.resolve(dataSchema).value}`
301
+ });
302
+ }
303
+ if (firstParam?.type === FuncParameterType.destructuredObject) for (const { name, alias } of firstParam.props) {
304
+ const argInfo = positionalArgs.find((a) => a.schemaKey === name);
305
+ if (argInfo) {
306
+ const argName = this.makeNameValid(alias);
307
+ const argSnippet = snip(argName, argInfo.type, "argument");
308
+ args.push(argSnippet);
309
+ argAliases.push([alias, argSnippet]);
310
+ pendingHeaderEntries.push({
311
+ argName,
312
+ header: `${getAttributesString(argInfo.type)}${argName}: ${this.resolve(undecorate(argInfo.type)).value}`
313
+ });
314
+ } else if (structArg) {
315
+ const propSnippet = accessProp(structArg, name);
316
+ if (propSnippet) argAliases.push([alias, propSnippet]);
317
+ }
318
+ }
319
+ else if (firstParam?.type === FuncParameterType.identifier) {
320
+ const proxyEntries = [];
321
+ for (const a of positionalArgs) {
322
+ const argName = this.makeNameValid(`_arg_${a.schemaKey}`);
323
+ const s = snip(argName, a.type, "argument");
324
+ args.push(s);
325
+ proxyEntries.push({
326
+ schemaKey: a.schemaKey,
327
+ argName,
328
+ type: a.type
329
+ });
330
+ pendingHeaderEntries.push({
331
+ argName,
332
+ header: `${getAttributesString(a.type)}${argName}: ${this.resolve(undecorate(a.type)).value}`
333
+ });
334
+ }
335
+ const router = new EntryInputRouter(structArgName, dataSchema, proxyEntries);
336
+ argAliases.push([firstParam.name, snip(firstParam.name, router, "argument")]);
337
+ } else for (const a of positionalArgs) {
338
+ const argName = this.makeNameValid(`_arg_${a.schemaKey}`);
339
+ args.push(snip(argName, a.type, "argument"));
340
+ pendingHeaderEntries.push({
341
+ argName,
342
+ header: `${getAttributesString(a.type)}${argName}: ${this.resolve(undecorate(a.type)).value}`
343
+ });
344
+ }
345
+ } else for (const [i, argType] of options.argTypes.entries()) {
292
346
  const astParam = options.params[i];
293
347
  const origin = isPtr(argType) ? argType.addressSpace === "storage" ? argType.access === "read" ? "readonly" : "mutable" : argType.addressSpace : "argument";
294
348
  switch (astParam?.type) {
@@ -310,8 +364,7 @@ var ResolutionCtxImpl = class {
310
364
  }
311
365
  const scope = this._itemStateStack.pushFunctionScope(options.functionType, args, Object.fromEntries(argAliases), options.returnType, options.externalMap);
312
366
  fnScopePushed = true;
313
- this.#shaderGenerator.initGenerator(this);
314
- const body = this.#shaderGenerator.functionDefinition(options.body);
367
+ const body = this.gen.functionDefinition(options.body);
315
368
  let returnType = options.returnType;
316
369
  if (returnType instanceof AutoStruct) if (isWgslStruct(scope.reportedReturnTypes.values().next().value)) returnType = returnType.completeStruct;
317
370
  else returnType = void 0;
@@ -326,6 +379,11 @@ var ResolutionCtxImpl = class {
326
379
  returnType = concretize(returnType);
327
380
  if (options.functionType === "vertex" || options.functionType === "fragment") returnType = createIoSchema(returnType);
328
381
  }
382
+ if (options.entryInput) return {
383
+ head: `(${pendingHeaderEntries.filter(({ argName }) => isArgUsedInBody(argName, body)).map(({ header }) => header).join(", ")}) ${returnType.type !== "void" ? `-> ${getAttributesString(returnType)}${this.resolve(returnType).value} ` : ""}`,
384
+ body,
385
+ returnType
386
+ };
329
387
  return {
330
388
  head: resolveFunctionHeader(this, args, returnType),
331
389
  body,
@@ -435,7 +493,7 @@ var ResolutionCtxImpl = class {
435
493
  try {
436
494
  for (const instance of instances) if ([...instance.slotToValueMap.entries()].every(([slot, expectedValue]) => slot.areEqual(this._itemStateStack.readSlot(slot), expectedValue))) return instance.result;
437
495
  let result;
438
- if (isData(item)) result = snip(resolveData(this, item), Void, "runtime");
496
+ if (isData(item)) result = snip(this.gen.typeAnnotation(item), Void, "runtime");
439
497
  else if (isLazy(item) || isSlot(item)) result = this.resolve(this.unwrap(item));
440
498
  else if (isSelfResolvable(item)) result = item[$resolve](this);
441
499
  else if (hasTinyestMetadata(item)) {
@@ -465,12 +523,15 @@ var ResolutionCtxImpl = class {
465
523
  }
466
524
  if (isProviding(item)) return this.withRenamed(item[$providing].inner, getName(item), () => this.withSlots(item[$providing].pairs, () => this.resolve(item[$providing].inner, schema)));
467
525
  if (isMarkedInternal(item) || hasTinyestMetadata(item)) {
468
- if (this._itemStateStack.itemDepth === 0) try {
469
- this.pushMode(new CodegenState());
470
- const result = provideCtx(this, () => this._getOrInstantiate(item));
471
- return snip(`${[...this._declarations].join("\n\n")}${result.value}`, Void, "runtime");
472
- } finally {
473
- this.popMode("codegen");
526
+ if (this._itemStateStack.itemDepth === 0) {
527
+ this.gen.initGenerator(this);
528
+ try {
529
+ this.pushMode(new CodegenState());
530
+ const result = provideCtx(this, () => this._getOrInstantiate(item));
531
+ return snip(`${[...this._declarations].join("\n\n")}${result.value}`, Void, "runtime");
532
+ } finally {
533
+ this.popMode("codegen");
534
+ }
474
535
  }
475
536
  return this._getOrInstantiate(item);
476
537
  }
@@ -498,6 +559,9 @@ var ResolutionCtxImpl = class {
498
559
  if (schema && isWgslStruct(schema)) return snip(stitch`${this.resolve(schema)}(${Object.entries(schema.propTypes).map(([key, propType]) => snip(item[key], propType, "runtime"))})`, schema, "runtime");
499
560
  throw new WgslTypeError(`Value ${item} (as json: ${safeStringify(item)}) is not resolvable${schema ? ` to type ${safeStringify(schema)}` : ""}`);
500
561
  }
562
+ resolveSnippet(snippet) {
563
+ return snip(this.resolve(snippet.value, snippet.dataType).value, snippet.dataType, snippet.origin);
564
+ }
501
565
  pushMode(mode) {
502
566
  this.#modeStack.push(mode);
503
567
  }
@@ -537,10 +601,12 @@ function resolve(item, options) {
537
601
  logResources: ctx.logResources
538
602
  };
539
603
  }
604
+ function isArgUsedInBody(argName, body) {
605
+ return new RegExp(`\\b${argName}\\b`).test(body);
606
+ }
540
607
  function resolveFunctionHeader(ctx, args, returnType) {
541
608
  const argList = args.map((arg) => `${arg.value}: ${ctx.resolve(arg.dataType).value}`).join(", ");
542
609
  return returnType.type !== "void" ? `(${argList}) -> ${getAttributesString(returnType)}${ctx.resolve(returnType).value} ` : `(${argList}) `;
543
610
  }
544
-
545
611
  //#endregion
546
- export { ResolutionCtxImpl, resolve };
612
+ export { ResolutionCtxImpl, resolve };
package/shared/env.js CHANGED
@@ -8,6 +8,5 @@
8
8
  */
9
9
  const DEV = process.env.NODE_ENV === "development";
10
10
  const TEST = process.env.NODE_ENV === "test";
11
-
12
11
  //#endregion
13
- export { DEV, TEST };
12
+ export { DEV, TEST };
@@ -9,6 +9,5 @@ function* naturalsExcept(excluded) {
9
9
  next++;
10
10
  }
11
11
  }
12
-
13
12
  //#endregion
14
- export { naturalsExcept };
13
+ export { naturalsExcept };
package/shared/meta.js CHANGED
@@ -1,7 +1,6 @@
1
1
  import { version } from "../package.js";
2
2
  import { DEV, TEST } from "./env.js";
3
3
  import { $getNameForward, isMarkedInternal } from "./symbols.js";
4
-
5
4
  //#region src/shared/meta.ts
6
5
  const globalWithMeta = globalThis;
7
6
  if (globalWithMeta.__TYPEGPU_VERSION__ !== void 0) console.warn(`Found duplicate TypeGPU version. First was ${globalWithMeta.__TYPEGPU_VERSION__}, this one is ${version}. This may cause unexpected behavior.`);
@@ -58,6 +57,5 @@ function setMetaData(definition, metaData) {
58
57
  ...metaData
59
58
  });
60
59
  }
61
-
62
60
  //#endregion
63
- export { PERF, getMetaData, getName, hasTinyestMetadata, isNamable, setName };
61
+ export { PERF, getMetaData, getName, hasTinyestMetadata, isNamable, setName };
package/shared/repr.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { $gpuRepr, $gpuValueOf, $invalidSchemaReason, $memIdent, $repr, $reprPartial, $validStorageSchema, $validUniformSchema, $validVertexSchema } from "./symbols.js";
1
+ import { $gpuRepr, $gpuValueOf, $inRepr, $invalidSchemaReason, $memIdent, $repr, $reprPartial, $reprPatch, $validStorageSchema, $validUniformSchema, $validVertexSchema } from "./symbols.js";
2
2
  import { Default } from "./utilityTypes.js";
3
3
  import { U16, U32, WgslArray } from "../data/wgslTypes.js";
4
4
  import { ViewDimensionToDimension } from "../core/texture/textureFormats.js";
@@ -19,10 +19,25 @@ import { Disarray, Undecorate } from "../data/dataTypes.js";
19
19
  type Infer<T> = T extends {
20
20
  readonly [$repr]: infer TRepr;
21
21
  } ? TRepr : T;
22
+ /**
23
+ * Extracts the inferred input (write-side) representation of a resource.
24
+ *
25
+ * @example
26
+ * type A = InferInput<Vec3f> // => v3f | [number, number, number] | Float32Array
27
+ * type B = InferInput<WgslArray<Vec3f>> // => (v3f | [number, number, number] | Float32Array)[] | Float32Array
28
+ * type C = InferInput<F32> // => number (same as Infer<F32>)
29
+ * const arrayOfStructs = d.arrayOf(d.struct({ pos: d.vec3f, id: d.f32 }), 4);
30
+ * type D = d.InferInput<typeof arrayOfStructs>; // { pos: d.v3f | Float32Array<ArrayBufferLike> | [number, number, number]; id: number; }[]
31
+ */
32
+ type InferInput<T> = Infer<T> | (T extends {
33
+ readonly [$inRepr]: infer TRepr;
34
+ } ? TRepr : never);
22
35
  /**
23
36
  * Extracts a sparse/partial inferred representation of a resource.
24
37
  * Used by the `buffer.writePartial` API.
25
38
  *
39
+ * @deprecated
40
+ *
26
41
  * @example
27
42
  * type A = InferPartial<F32> // => number | undefined
28
43
  * type B = InferPartial<WgslStruct<{ a: F32 }>> // => { a?: number | undefined }
@@ -45,7 +60,22 @@ type InferGPU<T> = T extends {
45
60
  readonly [$gpuRepr]: infer TRepr;
46
61
  } ? TRepr : Infer<T>;
47
62
  type InferRecord<T extends Record<string | number | symbol, unknown>> = { [Key in keyof T]: Infer<T[Key]> };
63
+ type InferInputRecord<T extends Record<string | number | symbol, unknown>> = { [Key in keyof T]: InferInput<T[Key]> };
64
+ /** @deprecated */
48
65
  type InferPartialRecord<T extends Record<string | number | symbol, unknown>> = { [Key in keyof T]?: InferPartial<T[Key]> };
66
+ /**
67
+ * Extracts the patch representation of a resource.
68
+ * Used by the `buffer.patch` API.
69
+ *
70
+ * @example
71
+ * type A = InferPatch<F32> // => number | undefined
72
+ * type B = InferPatch<WgslStruct<{ a: F32 }>> // => { a?: number | undefined }
73
+ * type C = InferPatch<WgslArray<F32>> // => Record<number, number | undefined> | number[] | undefined
74
+ */
75
+ type InferPatch<T> = T extends {
76
+ readonly [$reprPatch]: infer TRepr;
77
+ } ? TRepr : InferInput<T> | undefined;
78
+ type InferPatchRecord<T extends Record<string | number | symbol, unknown>> = { [Key in keyof T]?: InferPatch<T[Key]> };
49
79
  type InferGPURecord<T extends Record<string | number | symbol, unknown>> = { [Key in keyof T]: InferGPU<T[Key]> };
50
80
  type GPUValueOf<T> = T extends {
51
81
  readonly [$gpuValueOf]: infer TValue;
@@ -105,4 +135,4 @@ type ExtractInvalidSchemaError<T, TPrefix extends string = ''> = [T] extends [{
105
135
  readonly [$invalidSchemaReason]: string;
106
136
  }] ? `${TPrefix}${T[typeof $invalidSchemaReason]}` : never;
107
137
  //#endregion
108
- export { ExtractInvalidSchemaError, GPUValueOf, Infer, InferGPU, InferGPURecord, InferPartial, InferPartialRecord, InferRecord, IsValidBufferSchema, IsValidIndexSchema, IsValidStorageSchema, IsValidUniformSchema, IsValidVertexSchema, MemIdentity, MemIdentityRecord, ValidateTextureViewSchema };
138
+ export { ExtractInvalidSchemaError, GPUValueOf, Infer, InferGPU, InferGPURecord, InferInput, InferInputRecord, InferPartial, InferPartialRecord, InferPatch, InferPatchRecord, InferRecord, IsValidBufferSchema, IsValidIndexSchema, IsValidStorageSchema, IsValidUniformSchema, IsValidVertexSchema, MemIdentity, MemIdentityRecord, ValidateTextureViewSchema };
@@ -1,5 +1,4 @@
1
1
  import { isMatInstance, isVecInstance } from "../data/wgslTypes.js";
2
-
3
2
  //#region src/shared/stringify.ts
4
3
  function safeStringify(item) {
5
4
  const asString = String(item);
@@ -17,6 +16,5 @@ function niceStringify(item) {
17
16
  if (item && typeof item === "object") return `{ ${Object.entries(item).map(([key, value]) => `${key}: ${niceStringify(value)}`).join(", ")} }`;
18
17
  return String(item);
19
18
  }
20
-
21
19
  //#endregion
22
- export { niceStringify, safeStringify };
20
+ export { niceStringify, safeStringify };
@@ -37,6 +37,15 @@ declare const $gpuRepr: unique symbol;
37
37
  * If present, it shadows the value of `$repr` for use in partial IO.
38
38
  */
39
39
  declare const $reprPartial: unique symbol;
40
+ /**
41
+ * Type token for the inferred patch representation of a resource.
42
+ * Used by the `buffer.patch` API with `Record<number, T>` sparse arrays.
43
+ */
44
+ declare const $reprPatch: unique symbol;
45
+ /**
46
+ * Type token for the write-side (input) representation of a resource.
47
+ */
48
+ declare const $inRepr: unique symbol;
40
49
  /**
41
50
  * Type token holding schemas that are identical in memory layout.
42
51
  */
@@ -58,4 +67,4 @@ declare const $validVertexSchema: unique symbol;
58
67
  */
59
68
  declare const $invalidSchemaReason: unique symbol;
60
69
  //#endregion
61
- export { $cast, $getNameForward, $gpuCallable, $gpuRepr, $gpuValueOf, $internal, $invalidSchemaReason, $memIdent, $providing, $repr, $reprPartial, $resolve, $validStorageSchema, $validUniformSchema, $validVertexSchema };
70
+ export { $cast, $getNameForward, $gpuCallable, $gpuRepr, $gpuValueOf, $inRepr, $internal, $invalidSchemaReason, $memIdent, $providing, $repr, $reprPartial, $reprPatch, $resolve, $validStorageSchema, $validUniformSchema, $validVertexSchema };
package/shared/symbols.js CHANGED
@@ -1,5 +1,4 @@
1
1
  import { version } from "../package.js";
2
-
3
2
  //#region src/shared/symbols.ts
4
3
  const $internal = Symbol(`typegpu:${version}:$internal`);
5
4
  /**
@@ -33,39 +32,17 @@ const $gpuCallable = Symbol(`typegpu:${version}:$gpuCallable`);
33
32
  * Type token for the inferred (CPU & GPU) representation of a resource
34
33
  */
35
34
  const $repr = Symbol(`typegpu:${version}:$repr`);
36
- /**
37
- * Type token for the inferred (GPU-side) representation of a resource
38
- * If present, it shadows the value of `$repr` for GPU-side inference.
39
- */
40
- const $gpuRepr = Symbol(`typegpu:${version}:$gpuRepr`);
41
- /**
42
- * Type token for the inferred partial representation of a resource.
43
- * If present, it shadows the value of `$repr` for use in partial IO.
44
- */
45
- const $reprPartial = Symbol(`typegpu:${version}:$reprPartial`);
46
- /**
47
- * Type token holding schemas that are identical in memory layout.
48
- */
49
- const $memIdent = Symbol(`typegpu:${version}:$memIdent`);
50
- /**
51
- * Type token, signaling that a schema can be used in a storage buffer.
52
- */
53
- const $validStorageSchema = Symbol(`typegpu:${version}:$invalidStorageSchema`);
54
- /**
55
- * Type token, signaling that a schema can be used in a uniform buffer.
56
- */
57
- const $validUniformSchema = Symbol(`typegpu:${version}:$validUniformSchema`);
58
- /**
59
- * Type token, signaling that a schema can be used in a vertex buffer.
60
- */
61
- const $validVertexSchema = Symbol(`typegpu:${version}:$validVertexSchema`);
62
- /**
63
- * Type token, containing a reason for why the schema is invalid (if it is).
64
- */
65
- const $invalidSchemaReason = Symbol(`typegpu:${version}:$invalidSchemaReason`);
35
+ Symbol(`typegpu:${version}:$gpuRepr`);
36
+ Symbol(`typegpu:${version}:$reprPartial`);
37
+ Symbol(`typegpu:${version}:$reprPatch`);
38
+ Symbol(`typegpu:${version}:$inRepr`);
39
+ Symbol(`typegpu:${version}:$memIdent`);
40
+ Symbol(`typegpu:${version}:$invalidStorageSchema`);
41
+ Symbol(`typegpu:${version}:$validUniformSchema`);
42
+ Symbol(`typegpu:${version}:$validVertexSchema`);
43
+ Symbol(`typegpu:${version}:$invalidSchemaReason`);
66
44
  function isMarkedInternal(value) {
67
45
  return !!value?.[$internal];
68
46
  }
69
-
70
47
  //#endregion
71
- export { $cast, $getNameForward, $gpuCallable, $gpuValueOf, $internal, $ownSnippet, $providing, $repr, $resolve, isMarkedInternal };
48
+ export { $cast, $getNameForward, $gpuCallable, $gpuValueOf, $internal, $ownSnippet, $providing, $repr, $resolve, isMarkedInternal };
@@ -18,12 +18,16 @@ type NullableToOptional<T> = { [K in keyof T as T[K] extends null ? K : never]?:
18
18
  */
19
19
  type Mutable<T> = { -readonly [P in keyof T]: T[P] };
20
20
  /**
21
- * Source: https://code.lol/post/programming/higher-kinded-types/
21
+ * Source: https://code.lol/post/programming/higher-kinded-types
22
22
  */
23
23
  type Assume<T, U> = T extends U ? T : U;
24
24
  /**
25
25
  * Any typed array
26
26
  */
27
27
  type TypedArray = Uint8Array | Uint16Array | Uint32Array | Int32Array | Float32Array | Float64Array;
28
+ /**
29
+ * Source: https://futurestud.io/tutorials/typescript-how-to-remove-index-signature-from-a-type
30
+ */
31
+ type RemoveIndexSignature<T> = { [K in keyof T as string extends K ? never : number extends K ? never : symbol extends K ? never : K]: T[K] };
28
32
  //#endregion
29
- export { Assume, Default, Mutable, NullableToOptional, OmitProps, Prettify, SwapNever, TypedArray, UnionToIntersection, WithDefaults };
33
+ export { Assume, Default, Mutable, NullableToOptional, OmitProps, Prettify, RemoveIndexSignature, SwapNever, TypedArray, UnionToIntersection, WithDefaults };
@@ -2,6 +2,5 @@
2
2
  function assertExhaustive(x, location) {
3
3
  throw new Error(`Failed to handle ${x} at ${location}`);
4
4
  }
5
-
6
5
  //#endregion
7
- export { assertExhaustive };
6
+ export { assertExhaustive };
@@ -59,6 +59,5 @@ const kindToDefaultFormatMap = {
59
59
  vec3i: "sint32x3",
60
60
  vec4i: "sint32x4"
61
61
  };
62
-
63
62
  //#endregion
64
- export { kindToDefaultFormatMap, vertexFormats };
63
+ export { kindToDefaultFormatMap, vertexFormats };