typegpu 0.4.3 → 0.4.5

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.
package/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- import { A as AnyWgslData, T as TgpuNamable, I as Infer, F as F32, a as F16, b as I32, U as U32, V as Vec2f, c as Vec3f, d as Vec4f, e as Vec2h, f as Vec3h, g as Vec4h, h as Vec2i, i as Vec3i, j as Vec4i, k as Vec2u, l as Vec3u, m as Vec4u, D as Decorated, n as AnyWgslStruct, B as BaseData, L as Location, W as WgslStruct, o as Default, p as UnionToIntersection, q as WgslArray, r as Disarray, s as Unstruct, t as VertexFormat, u as TgpuVertexAttrib, K as KindToDefaultFormatMap, v as KindToAcceptedAttribMap, w as AnyData, O as OmitProps, P as Prettify, M as Mutable, x as WgslTypeLiteral, y as InferPartial, z as MemIdentity, C as AnyVecInstance, E as AnyMatInstance } from './wgslTypes-D0JqCGnw.js';
2
- import { A as AnyAttribute, a as AnyComputeBuiltin, D as Decorate, I as IsBuiltin, H as HasCustomLocation, b as AnyFragmentInputBuiltin, c as AnyFragmentOutputBuiltin, O as OmitBuiltins } from './attributes-Dri8dk1v.js';
1
+ import { A as AnyWgslData, T as TgpuNamable, I as Infer, F as F32, a as F16, b as I32, U as U32, V as Vec2f, c as Vec3f, d as Vec4f, e as Vec2h, f as Vec3h, g as Vec4h, h as Vec2i, i as Vec3i, j as Vec4i, k as Vec2u, l as Vec3u, m as Vec4u, D as Decorated, n as AnyWgslStruct, B as BaseData, L as Location, W as WgslStruct, o as Default, p as UnionToIntersection, q as WgslArray, r as Disarray, s as Unstruct, t as VertexFormat, u as TgpuVertexAttrib, K as KindToDefaultFormatMap, v as KindToAcceptedAttribMap, w as AnyData, O as OmitProps, P as Prettify, M as Mutable, x as WgslTypeLiteral, y as InferPartial, z as MemIdentity, C as InferGPU, E as AbstractInt, G as AbstractFloat, H as AnyVecInstance, J as AnyMatInstance } from './wgslTypes-VtSRoe90.js';
2
+ import { A as AnyAttribute, a as AnyComputeBuiltin, D as Decorate, I as IsBuiltin, H as HasCustomLocation, b as AnyFragmentInputBuiltin, c as AnyFragmentOutputBuiltin, O as OmitBuiltins } from './attributes-B4JpvOTz.js';
3
3
  import * as smol from 'tinyest';
4
4
  import { Block } from 'tinyest';
5
5
 
@@ -523,7 +523,7 @@ type DataToContainedAttribs<T> = T extends AnyWgslStruct | Unstruct ? {
523
523
  type: VertexFormat;
524
524
  } ? TgpuVertexAttrib<T['type']> : T extends {
525
525
  type: keyof KindToDefaultFormatMap;
526
- } ? TgpuVertexAttrib<KindToDefaultFormatMap[T['type']]> : never;
526
+ } ? TgpuVertexAttrib<KindToDefaultFormatMap[T['type']]> : T extends Decorated<infer TInner> ? DataToContainedAttribs<TInner> : never;
527
527
  /**
528
528
  * Interprets an array as a set of vertex attributes.
529
529
  */
@@ -651,6 +651,100 @@ interface DepthStencilAttachment {
651
651
  stencilReadOnly?: boolean;
652
652
  }
653
653
 
654
+ interface SamplerProps {
655
+ addressModeU?: GPUAddressMode;
656
+ addressModeV?: GPUAddressMode;
657
+ /**
658
+ * Specifies the address modes for the texture width, height, and depth
659
+ * coordinates, respectively.
660
+ */
661
+ addressModeW?: GPUAddressMode;
662
+ /**
663
+ * Specifies the sampling behavior when the sample footprint is smaller than or equal to one
664
+ * texel.
665
+ */
666
+ magFilter?: GPUFilterMode;
667
+ /**
668
+ * Specifies the sampling behavior when the sample footprint is larger than one texel.
669
+ */
670
+ minFilter?: GPUFilterMode;
671
+ /**
672
+ * Specifies behavior for sampling between mipmap levels.
673
+ */
674
+ mipmapFilter?: GPUMipmapFilterMode;
675
+ lodMinClamp?: number;
676
+ /**
677
+ * Specifies the minimum and maximum levels of detail, respectively, used internally when
678
+ * sampling a texture.
679
+ */
680
+ lodMaxClamp?: number;
681
+ /**
682
+ * Specifies the maximum anisotropy value clamp used by the sampler. Anisotropic filtering is
683
+ * enabled when {@link GPUSamplerDescriptor.maxAnisotropy} is > 1 and the implementation supports it.
684
+ * Anisotropic filtering improves the image quality of textures sampled at oblique viewing
685
+ * angles. Higher {@link GPUSamplerDescriptor.maxAnisotropy} values indicate the maximum ratio of
686
+ * anisotropy supported when filtering.
687
+ *
688
+ * Most implementations support {@link GPUSamplerDescriptor.maxAnisotropy} values in range
689
+ * between 1 and 16, inclusive. The used value of {@link GPUSamplerDescriptor.maxAnisotropy}
690
+ * will be clamped to the maximum value that the platform supports.
691
+ * The precise filtering behavior is implementation-dependent.
692
+ */
693
+ maxAnisotropy?: number;
694
+ }
695
+ interface ComparisonSamplerProps {
696
+ compare: GPUCompareFunction;
697
+ addressModeU?: GPUAddressMode;
698
+ addressModeV?: GPUAddressMode;
699
+ /**
700
+ * Specifies the address modes for the texture width, height, and depth
701
+ * coordinates, respectively.
702
+ */
703
+ addressModeW?: GPUAddressMode;
704
+ /**
705
+ * Specifies the sampling behavior when the sample footprint is smaller than or equal to one
706
+ * texel.
707
+ */
708
+ magFilter?: GPUFilterMode;
709
+ /**
710
+ * Specifies the sampling behavior when the sample footprint is larger than one texel.
711
+ */
712
+ minFilter?: GPUFilterMode;
713
+ /**
714
+ * Specifies behavior for sampling between mipmap levels.
715
+ */
716
+ mipmapFilter?: GPUMipmapFilterMode;
717
+ lodMinClamp?: number;
718
+ /**
719
+ * Specifies the minimum and maximum levels of detail, respectively, used internally when
720
+ * sampling a texture.
721
+ */
722
+ lodMaxClamp?: number;
723
+ /**
724
+ * Specifies the maximum anisotropy value clamp used by the sampler. Anisotropic filtering is
725
+ * enabled when {@link GPUSamplerDescriptor.maxAnisotropy} is > 1 and the implementation supports it.
726
+ * Anisotropic filtering improves the image quality of textures sampled at oblique viewing
727
+ * angles. Higher {@link GPUSamplerDescriptor.maxAnisotropy} values indicate the maximum ratio of
728
+ * anisotropy supported when filtering.
729
+ *
730
+ * Most implementations support {@link GPUSamplerDescriptor.maxAnisotropy} values in range
731
+ * between 1 and 16, inclusive. The used value of {@link GPUSamplerDescriptor.maxAnisotropy}
732
+ * will be clamped to the maximum value that the platform supports.
733
+ * The precise filtering behavior is implementation-dependent.
734
+ */
735
+ maxAnisotropy?: number;
736
+ }
737
+ interface TgpuSampler {
738
+ readonly resourceType: 'sampler';
739
+ }
740
+ interface TgpuComparisonSampler {
741
+ readonly resourceType: 'sampler-comparison';
742
+ }
743
+ declare function sampler(props: SamplerProps): TgpuSampler;
744
+ declare function comparisonSampler(props: ComparisonSamplerProps): TgpuComparisonSampler;
745
+ declare function isSampler(resource: unknown): resource is TgpuSampler;
746
+ declare function isComparisonSampler(resource: unknown): resource is TgpuComparisonSampler;
747
+
654
748
  interface Unwrapper {
655
749
  readonly device: GPUDevice;
656
750
  unwrap(resource: TgpuComputePipeline): GPUComputePipeline;
@@ -661,6 +755,8 @@ interface Unwrapper {
661
755
  unwrap(resource: TgpuTexture): GPUTexture;
662
756
  unwrap(resource: TgpuReadonlyTexture | TgpuWriteonlyTexture | TgpuMutableTexture | TgpuSampledTexture): GPUTextureView;
663
757
  unwrap(resource: TgpuVertexLayout): GPUVertexBufferLayout;
758
+ unwrap(resource: TgpuSampler): GPUSampler;
759
+ unwrap(resource: TgpuComparisonSampler): GPUSampler;
664
760
  }
665
761
 
666
762
  interface WithCompute {
@@ -688,6 +784,7 @@ interface WithVertex<VertexOut extends IORecord = IORecord> {
688
784
  interface WithFragment<Output extends FragmentOutConstrained = FragmentOutConstrained> {
689
785
  withPrimitive(primitiveState: GPUPrimitiveState | undefined): WithFragment<Output>;
690
786
  withDepthStencil(depthStencilState: GPUDepthStencilState | undefined): WithFragment<Output>;
787
+ withMultisample(multisampleState: GPUMultisampleState | undefined): WithFragment<Output>;
691
788
  createPipeline(): TgpuRenderPipeline<Output>;
692
789
  }
693
790
  interface WithBinding {
@@ -959,100 +1056,6 @@ type RestrictVertexUsages<TData extends BaseData> = TData extends {
959
1056
  readonly type: WgslTypeLiteral;
960
1057
  } ? ('uniform' | 'storage' | 'vertex')[] : 'vertex'[];
961
1058
 
962
- interface SamplerProps {
963
- addressModeU?: GPUAddressMode;
964
- addressModeV?: GPUAddressMode;
965
- /**
966
- * Specifies the address modes for the texture width, height, and depth
967
- * coordinates, respectively.
968
- */
969
- addressModeW?: GPUAddressMode;
970
- /**
971
- * Specifies the sampling behavior when the sample footprint is smaller than or equal to one
972
- * texel.
973
- */
974
- magFilter?: GPUFilterMode;
975
- /**
976
- * Specifies the sampling behavior when the sample footprint is larger than one texel.
977
- */
978
- minFilter?: GPUFilterMode;
979
- /**
980
- * Specifies behavior for sampling between mipmap levels.
981
- */
982
- mipmapFilter?: GPUMipmapFilterMode;
983
- lodMinClamp?: number;
984
- /**
985
- * Specifies the minimum and maximum levels of detail, respectively, used internally when
986
- * sampling a texture.
987
- */
988
- lodMaxClamp?: number;
989
- /**
990
- * Specifies the maximum anisotropy value clamp used by the sampler. Anisotropic filtering is
991
- * enabled when {@link GPUSamplerDescriptor.maxAnisotropy} is > 1 and the implementation supports it.
992
- * Anisotropic filtering improves the image quality of textures sampled at oblique viewing
993
- * angles. Higher {@link GPUSamplerDescriptor.maxAnisotropy} values indicate the maximum ratio of
994
- * anisotropy supported when filtering.
995
- *
996
- * Most implementations support {@link GPUSamplerDescriptor.maxAnisotropy} values in range
997
- * between 1 and 16, inclusive. The used value of {@link GPUSamplerDescriptor.maxAnisotropy}
998
- * will be clamped to the maximum value that the platform supports.
999
- * The precise filtering behavior is implementation-dependent.
1000
- */
1001
- maxAnisotropy?: number;
1002
- }
1003
- interface ComparisonSamplerProps {
1004
- compare: GPUCompareFunction;
1005
- addressModeU?: GPUAddressMode;
1006
- addressModeV?: GPUAddressMode;
1007
- /**
1008
- * Specifies the address modes for the texture width, height, and depth
1009
- * coordinates, respectively.
1010
- */
1011
- addressModeW?: GPUAddressMode;
1012
- /**
1013
- * Specifies the sampling behavior when the sample footprint is smaller than or equal to one
1014
- * texel.
1015
- */
1016
- magFilter?: GPUFilterMode;
1017
- /**
1018
- * Specifies the sampling behavior when the sample footprint is larger than one texel.
1019
- */
1020
- minFilter?: GPUFilterMode;
1021
- /**
1022
- * Specifies behavior for sampling between mipmap levels.
1023
- */
1024
- mipmapFilter?: GPUMipmapFilterMode;
1025
- lodMinClamp?: number;
1026
- /**
1027
- * Specifies the minimum and maximum levels of detail, respectively, used internally when
1028
- * sampling a texture.
1029
- */
1030
- lodMaxClamp?: number;
1031
- /**
1032
- * Specifies the maximum anisotropy value clamp used by the sampler. Anisotropic filtering is
1033
- * enabled when {@link GPUSamplerDescriptor.maxAnisotropy} is > 1 and the implementation supports it.
1034
- * Anisotropic filtering improves the image quality of textures sampled at oblique viewing
1035
- * angles. Higher {@link GPUSamplerDescriptor.maxAnisotropy} values indicate the maximum ratio of
1036
- * anisotropy supported when filtering.
1037
- *
1038
- * Most implementations support {@link GPUSamplerDescriptor.maxAnisotropy} values in range
1039
- * between 1 and 16, inclusive. The used value of {@link GPUSamplerDescriptor.maxAnisotropy}
1040
- * will be clamped to the maximum value that the platform supports.
1041
- * The precise filtering behavior is implementation-dependent.
1042
- */
1043
- maxAnisotropy?: number;
1044
- }
1045
- interface TgpuSampler {
1046
- readonly resourceType: 'sampler';
1047
- }
1048
- interface TgpuComparisonSampler {
1049
- readonly resourceType: 'sampler-comparison';
1050
- }
1051
- declare function sampler(props: SamplerProps): TgpuSampler;
1052
- declare function comparisonSampler(props: ComparisonSamplerProps): TgpuComparisonSampler;
1053
- declare function isSampler(resource: unknown): resource is TgpuSampler;
1054
- declare function isComparisonSampler(resource: unknown): resource is TgpuComparisonSampler;
1055
-
1056
1059
  type TgpuLayoutEntryBase = {
1057
1060
  /**
1058
1061
  * Limits this resource's visibility to specific shader stages.
@@ -1180,13 +1183,13 @@ interface TgpuBufferUsage<TData extends BaseData = BaseData, TUsage extends Bind
1180
1183
  readonly resourceType: 'buffer-usage';
1181
1184
  readonly usage: TUsage;
1182
1185
  readonly '~repr': Infer<TData>;
1183
- value: Infer<TData>;
1186
+ value: InferGPU<TData>;
1184
1187
  }
1185
1188
  interface TgpuBufferUniform<TData extends BaseData> extends TgpuBufferUsage<TData, 'uniform'> {
1186
- readonly value: Infer<TData>;
1189
+ readonly value: InferGPU<TData>;
1187
1190
  }
1188
1191
  interface TgpuBufferReadonly<TData extends BaseData> extends TgpuBufferUsage<TData, 'readonly'> {
1189
- readonly value: Infer<TData>;
1192
+ readonly value: InferGPU<TData>;
1190
1193
  }
1191
1194
  interface TgpuFixedBufferUsage<TData extends BaseData> extends TgpuNamable {
1192
1195
  readonly buffer: TgpuBuffer<TData>;
@@ -1234,11 +1237,13 @@ declare function workgroupVar<TDataType extends AnyWgslData>(dataType: TDataType
1234
1237
 
1235
1238
  type ResolvableObject = SelfResolvable | TgpuBufferUsage | TgpuConst | TgpuDeclare | TgpuFn | TgpuComputeFn | TgpuFragmentFn | TgpuComputePipeline | TgpuRenderPipeline | TgpuVertexFn | TgpuSampler | TgpuAccessor | TgpuExternalTexture | TgpuTexture | TgpuAnyTextureView | TgpuVar | AnyVecInstance | AnyMatInstance | AnyData | TgpuFn<any, any>;
1236
1239
  type Wgsl = Eventual<string | number | boolean | ResolvableObject>;
1237
- declare const UnknownData: unique symbol;
1240
+ declare const UnknownData: {
1241
+ type: string;
1242
+ };
1238
1243
  type UnknownData = typeof UnknownData;
1239
1244
  type Resource = {
1240
1245
  value: unknown;
1241
- dataType: AnyWgslData | UnknownData;
1246
+ dataType: AnyWgslData | UnknownData | AbstractInt | AbstractFloat;
1242
1247
  };
1243
1248
  type TgpuShaderStage = 'compute' | 'vertex' | 'fragment';
1244
1249
  interface FnToWgslOptions {