typegpu 0.3.2 → 0.3.3
Sign up to get free protection for your applications and to get access to all the features.
- package/LICENSE.md +1 -1
- package/chunk-2CMWQRQC.cjs +2 -0
- package/chunk-2CMWQRQC.cjs.map +1 -0
- package/chunk-2ZAQFPSX.js +1266 -0
- package/chunk-2ZAQFPSX.js.map +1 -0
- package/chunk-35UVS2JJ.cjs +591 -0
- package/chunk-35UVS2JJ.cjs.map +1 -0
- package/chunk-A2QB4MSZ.js +4 -0
- package/{chunk-47YH5LQ7.cjs.map → chunk-A2QB4MSZ.js.map} +1 -1
- package/chunk-CMYXKKUP.cjs +1266 -0
- package/chunk-CMYXKKUP.cjs.map +1 -0
- package/chunk-DDEF2Y4S.js +591 -0
- package/chunk-DDEF2Y4S.js.map +1 -0
- package/chunk-KYBPSQX5.js +2 -0
- package/chunk-KYBPSQX5.js.map +1 -0
- package/chunk-VRYGOFCW.cjs +4 -0
- package/chunk-VRYGOFCW.cjs.map +1 -0
- package/data/index.cjs +192 -1
- package/data/index.d.cts +2 -2
- package/data/index.d.ts +2 -2
- package/data/index.js +192 -1
- package/{index-CopjPGJg.d.cts → index-CuzbyKXg.d.cts} +5 -3
- package/{index-BM7ZTN7E.d.ts → index-FHKuURMs.d.ts} +5 -3
- package/index.cjs +4269 -14
- package/index.cjs.map +1 -1
- package/index.d.cts +80 -11
- package/index.d.ts +80 -11
- package/index.js +4269 -14
- package/index.js.map +1 -1
- package/package.json +1 -1
- package/std/index.cjs +490 -1
- package/std/index.cjs.map +1 -1
- package/std/index.d.cts +1 -1
- package/std/index.d.ts +1 -1
- package/std/index.js +490 -1
- package/std/index.js.map +1 -1
- package/{vector-BSez01sn.d.cts → vector-CDD2FV2v.d.cts} +19 -3
- package/{vector-BSez01sn.d.ts → vector-CDD2FV2v.d.ts} +19 -3
- package/chunk-47YH5LQ7.cjs +0 -4
- package/chunk-BGPVBIFN.js +0 -4
- package/chunk-BGPVBIFN.js.map +0 -1
- package/chunk-MCUGRE3S.js +0 -2
- package/chunk-MCUGRE3S.js.map +0 -1
- package/chunk-OHFPIYFY.cjs +0 -2
- package/chunk-OHFPIYFY.cjs.map +0 -1
package/index.d.cts
CHANGED
@@ -1,5 +1,5 @@
|
|
1
|
-
import { A as AnyWgslData, I as Infer, D as Decorated, 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, B as BaseWgslData, L as Location,
|
2
|
-
import { T as TgpuNamable, E as Exotic, A as AnyBuiltin, a as AnyAttribute, D as Default, U as UnionToIntersection, b as AnyData, c as Decorate, d as TgpuStruct, I as IsBuiltin, H as HasCustomLocation, O as OmitBuiltins, e as Disarray, K as KindToAcceptedAttribMap, f as Unstruct, V as VertexFormat, g as TgpuVertexAttrib, h as KindToDefaultFormatMap, i as OmitProps, P as Prettify, M as Mutable, j as Infer$1, k as ExoticArray } from './index-
|
1
|
+
import { A as AnyWgslData, I as Infer, D as Decorated, 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, B as BaseWgslData, L as Location, n as AnyWgslStruct, W as WgslArray, o as WgslTypeLiteral, p as AnyVecInstance, q as AnyMatInstance } from './vector-CDD2FV2v.cjs';
|
2
|
+
import { T as TgpuNamable, E as Exotic, A as AnyBuiltin, a as AnyAttribute, D as Default, U as UnionToIntersection, b as AnyData, c as Decorate, d as TgpuStruct, I as IsBuiltin, H as HasCustomLocation, O as OmitBuiltins, e as Disarray, K as KindToAcceptedAttribMap, f as Unstruct, V as VertexFormat, g as TgpuVertexAttrib, h as KindToDefaultFormatMap, i as OmitProps, P as Prettify, M as Mutable, j as Infer$1, k as ExoticArray } from './index-CuzbyKXg.cjs';
|
3
3
|
import * as smol from 'tinyest';
|
4
4
|
import { Block } from 'tinyest';
|
5
5
|
|
@@ -133,6 +133,7 @@ declare class StrictNameRegistry implements NameRegistry {
|
|
133
133
|
|
134
134
|
interface TgpuSlot<T> extends TgpuNamable, Labelled {
|
135
135
|
readonly resourceType: 'slot';
|
136
|
+
'~repr': Infer<T>;
|
136
137
|
readonly defaultValue: T | undefined;
|
137
138
|
/**
|
138
139
|
* Used to determine if code generated using either value `a` or `b` in place
|
@@ -144,6 +145,8 @@ interface TgpuSlot<T> extends TgpuNamable, Labelled {
|
|
144
145
|
interface TgpuDerived<T> {
|
145
146
|
readonly resourceType: 'derived';
|
146
147
|
readonly value: Infer<T>;
|
148
|
+
'~repr': Infer<T>;
|
149
|
+
readonly '~providing'?: Providing | undefined;
|
147
150
|
with<TValue>(slot: TgpuSlot<TValue>, value: Eventual<TValue>): TgpuDerived<T>;
|
148
151
|
/**
|
149
152
|
* @internal
|
@@ -152,6 +155,7 @@ interface TgpuDerived<T> {
|
|
152
155
|
}
|
153
156
|
interface TgpuAccessor<T extends AnyWgslData = AnyWgslData> extends TgpuNamable, Labelled {
|
154
157
|
readonly resourceType: 'accessor';
|
158
|
+
'~repr': Infer<T>;
|
155
159
|
readonly schema: T;
|
156
160
|
readonly defaultValue: TgpuFn<[], T> | TgpuBufferUsage<T> | Infer<T> | undefined;
|
157
161
|
readonly slot: TgpuSlot<TgpuFn<[], T> | TgpuBufferUsage<T> | Infer<T>>;
|
@@ -162,6 +166,10 @@ interface TgpuAccessor<T extends AnyWgslData = AnyWgslData> extends TgpuNamable,
|
|
162
166
|
*/
|
163
167
|
type Eventual<T> = T | TgpuSlot<T> | TgpuDerived<T>;
|
164
168
|
type SlotValuePair<T = unknown> = [TgpuSlot<T>, T];
|
169
|
+
type Providing = {
|
170
|
+
inner: unknown;
|
171
|
+
pairs: SlotValuePair[];
|
172
|
+
};
|
165
173
|
declare function isSlot<T>(value: unknown | TgpuSlot<T>): value is TgpuSlot<T>;
|
166
174
|
declare function isDerived<T extends TgpuDerived<unknown>>(value: T | unknown): value is T;
|
167
175
|
|
@@ -448,7 +456,7 @@ interface Unwrapper {
|
|
448
456
|
type WithLocations<T extends IORecord> = {
|
449
457
|
[Key in keyof T]: IsBuiltin<T[Key]> extends true ? T[Key] : HasCustomLocation<T[Key]> extends true ? T[Key] : Decorate<T[Key], Location<number>>;
|
450
458
|
};
|
451
|
-
type
|
459
|
+
type IOLayoutToSchema<T extends IOLayout> = T extends BaseWgslData ? Decorate<T, Location<0>> : T extends IORecord ? TgpuStruct<WithLocations<T>> : never;
|
452
460
|
|
453
461
|
/**
|
454
462
|
* Describes a fragment entry function signature (its arguments and return type)
|
@@ -470,7 +478,7 @@ interface TgpuFragmentFnShell<FragmentIn extends IOLayout, FragmentOut extends I
|
|
470
478
|
}
|
471
479
|
interface TgpuFragmentFn<Varying extends IOLayout = IOLayout, Output extends IOLayout<Vec4f> = IOLayout<Vec4f>> extends TgpuNamable {
|
472
480
|
readonly shell: TgpuFragmentFnShell<Varying, Output>;
|
473
|
-
readonly outputType:
|
481
|
+
readonly outputType: IOLayoutToSchema<Output>;
|
474
482
|
$uses(dependencyMap: Record<string, unknown>): this;
|
475
483
|
}
|
476
484
|
/**
|
@@ -491,8 +499,9 @@ declare function fragmentFn<FragmentIn extends IORecord, FragmentOut extends IOL
|
|
491
499
|
* Describes a vertex entry function signature (its arguments and return type)
|
492
500
|
*/
|
493
501
|
interface TgpuVertexFnShell<VertexIn extends IOLayout, VertexOut extends IOLayout> {
|
494
|
-
readonly argTypes: [
|
502
|
+
readonly argTypes: [AnyWgslStruct];
|
495
503
|
readonly returnType: VertexOut;
|
504
|
+
readonly attributes: [VertexIn];
|
496
505
|
/**
|
497
506
|
* Creates a type-safe implementation of this signature
|
498
507
|
*/
|
@@ -507,7 +516,8 @@ interface TgpuVertexFnShell<VertexIn extends IOLayout, VertexOut extends IOLayou
|
|
507
516
|
}
|
508
517
|
interface TgpuVertexFn<VertexIn extends IOLayout = IOLayout, VertexOut extends IOLayout = IOLayout> extends TgpuNamable {
|
509
518
|
readonly shell: TgpuVertexFnShell<VertexIn, VertexOut>;
|
510
|
-
readonly outputType:
|
519
|
+
readonly outputType: IOLayoutToSchema<VertexOut>;
|
520
|
+
readonly inputType: IOLayoutToSchema<VertexIn>;
|
511
521
|
$uses(dependencyMap: Record<string, unknown>): this;
|
512
522
|
}
|
513
523
|
/**
|
@@ -521,7 +531,7 @@ interface TgpuVertexFn<VertexIn extends IOLayout = IOLayout, VertexOut extends I
|
|
521
531
|
* A struct type containing the final position of the vertex, and any information
|
522
532
|
* passed onto the fragment shader stage.
|
523
533
|
*/
|
524
|
-
declare function vertexFn<VertexIn extends
|
534
|
+
declare function vertexFn<VertexIn extends IORecord, VertexOut extends IORecord>(inputType: VertexIn, outputType: VertexOut): TgpuVertexFnShell<ExoticIO<VertexIn>, ExoticIO<VertexOut>>;
|
525
535
|
|
526
536
|
/**
|
527
537
|
* The array can hold T, where T is a single/multi-component numeric, or a struct with members of type T.
|
@@ -531,7 +541,7 @@ declare function vertexFn<VertexIn extends IOLayout, VertexOut extends IORecord>
|
|
531
541
|
* - TgpuStruct<{ a: Vec3f, b: unorm8x2 }>
|
532
542
|
* - TgpuStruct<{ nested: TgpuStruct<{ a: Vec3f }> }>
|
533
543
|
*/
|
534
|
-
type DataToContainedAttribs<T> = T extends
|
544
|
+
type DataToContainedAttribs<T> = T extends AnyWgslStruct | Unstruct ? {
|
535
545
|
[Key in keyof T['propTypes']]: DataToContainedAttribs<T['propTypes'][Key]>;
|
536
546
|
} : T extends {
|
537
547
|
type: VertexFormat;
|
@@ -563,6 +573,7 @@ interface TgpuRenderPipeline<Output extends IOLayout = IOLayout> extends TgpuNam
|
|
563
573
|
with<TData extends WgslArray | Disarray>(vertexLayout: TgpuVertexLayout<TData>, buffer: TgpuBuffer$1<TData> & Vertex): TgpuRenderPipeline<IOLayout>;
|
564
574
|
with<Entries extends Record<string, TgpuLayoutEntry | null>>(bindGroupLayout: TgpuBindGroupLayout<Entries>, bindGroup: TgpuBindGroup<Entries>): TgpuRenderPipeline<IOLayout>;
|
565
575
|
withColorAttachment(attachment: FragmentOutToColorAttachment<Output>): TgpuRenderPipeline<IOLayout>;
|
576
|
+
withDepthStencilAttachment(attachment: DepthStencilAttachment): TgpuRenderPipeline<IOLayout>;
|
566
577
|
draw(vertexCount: number, instanceCount?: number, firstVertex?: number, firstInstance?: number): void;
|
567
578
|
}
|
568
579
|
type FragmentOutToTargets<T extends IOLayout> = T extends IOData ? GPUColorTargetState : T extends Record<string, unknown> ? {
|
@@ -609,6 +620,59 @@ interface ColorAttachment {
|
|
609
620
|
*/
|
610
621
|
storeOp: GPUStoreOp;
|
611
622
|
}
|
623
|
+
interface DepthStencilAttachment {
|
624
|
+
/**
|
625
|
+
* A {@link GPUTextureView} | ({@link TgpuTexture} & {@link Render}) describing the texture subresource that will be output to
|
626
|
+
* and read from for this depth/stencil attachment.
|
627
|
+
*/
|
628
|
+
view: (TgpuTexture & Render) | GPUTextureView;
|
629
|
+
/**
|
630
|
+
* Indicates the value to clear {@link GPURenderPassDepthStencilAttachment#view}'s depth component
|
631
|
+
* to prior to executing the render pass. Ignored if {@link GPURenderPassDepthStencilAttachment#depthLoadOp}
|
632
|
+
* is not {@link GPULoadOp#"clear"}. Must be between 0.0 and 1.0, inclusive (unless unrestricted depth is enabled).
|
633
|
+
*/
|
634
|
+
depthClearValue?: number;
|
635
|
+
/**
|
636
|
+
* Indicates the load operation to perform on {@link GPURenderPassDepthStencilAttachment#view}'s
|
637
|
+
* depth component prior to executing the render pass.
|
638
|
+
* Note: It is recommended to prefer clearing; see {@link GPULoadOp#"clear"} for details.
|
639
|
+
*/
|
640
|
+
depthLoadOp?: GPULoadOp;
|
641
|
+
/**
|
642
|
+
* The store operation to perform on {@link GPURenderPassDepthStencilAttachment#view}'s
|
643
|
+
* depth component after executing the render pass.
|
644
|
+
*/
|
645
|
+
depthStoreOp?: GPUStoreOp;
|
646
|
+
/**
|
647
|
+
* Indicates that the depth component of {@link GPURenderPassDepthStencilAttachment#view}
|
648
|
+
* is read only.
|
649
|
+
*/
|
650
|
+
depthReadOnly?: boolean;
|
651
|
+
/**
|
652
|
+
* Indicates the value to clear {@link GPURenderPassDepthStencilAttachment#view}'s stencil component
|
653
|
+
* to prior to executing the render pass. Ignored if {@link GPURenderPassDepthStencilAttachment#stencilLoadOp}
|
654
|
+
* is not {@link GPULoadOp#"clear"}.
|
655
|
+
* The value will be converted to the type of the stencil aspect of `view` by taking the same
|
656
|
+
* number of LSBs as the number of bits in the stencil aspect of one texel block|texel of `view`.
|
657
|
+
*/
|
658
|
+
stencilClearValue?: GPUStencilValue;
|
659
|
+
/**
|
660
|
+
* Indicates the load operation to perform on {@link GPURenderPassDepthStencilAttachment#view}'s
|
661
|
+
* stencil component prior to executing the render pass.
|
662
|
+
* Note: It is recommended to prefer clearing; see {@link GPULoadOp#"clear"} for details.
|
663
|
+
*/
|
664
|
+
stencilLoadOp?: GPULoadOp;
|
665
|
+
/**
|
666
|
+
* The store operation to perform on {@link GPURenderPassDepthStencilAttachment#view}'s
|
667
|
+
* stencil component after executing the render pass.
|
668
|
+
*/
|
669
|
+
stencilStoreOp?: GPUStoreOp;
|
670
|
+
/**
|
671
|
+
* Indicates that the stencil component of {@link GPURenderPassDepthStencilAttachment#view}
|
672
|
+
* is read only.
|
673
|
+
*/
|
674
|
+
stencilReadOnly?: boolean;
|
675
|
+
}
|
612
676
|
|
613
677
|
interface WithCompute {
|
614
678
|
createPipeline(): TgpuComputePipeline;
|
@@ -634,6 +698,7 @@ interface WithVertex<VertexOut extends IORecord = IORecord> {
|
|
634
698
|
}
|
635
699
|
interface WithFragment<Output extends IOLayout<Vec4f> = IOLayout<Vec4f>> {
|
636
700
|
withPrimitive(primitiveState: GPUPrimitiveState | undefined): WithFragment<Output>;
|
701
|
+
withDepthStencil(depthStencilState: GPUDepthStencilState | undefined): WithFragment<Output>;
|
637
702
|
createPipeline(): TgpuRenderPipeline<Output>;
|
638
703
|
}
|
639
704
|
interface WithBinding {
|
@@ -1142,6 +1207,7 @@ interface TgpuFnShell<Args extends AnyWgslData[] = AnyWgslData[], Return extends
|
|
1142
1207
|
interface TgpuFnBase<Args extends AnyWgslData[], Return extends AnyWgslData | undefined = undefined> extends TgpuNamable, Labelled {
|
1143
1208
|
readonly resourceType: 'function';
|
1144
1209
|
readonly shell: TgpuFnShell<Args, Return>;
|
1210
|
+
readonly '~providing'?: Providing | undefined;
|
1145
1211
|
$uses(dependencyMap: Record<string, unknown>): this;
|
1146
1212
|
with<T>(slot: TgpuSlot<T>, value: Eventual<T>): TgpuFn<Args, Return>;
|
1147
1213
|
with<T extends AnyWgslData>(accessor: TgpuAccessor<T>, value: TgpuFn<[], T> | TgpuBufferUsage<T> | Infer$1<T>): TgpuFn<Args, Return>;
|
@@ -1293,8 +1359,11 @@ declare class NotUniformError extends Error {
|
|
1293
1359
|
declare class MissingLinksError extends Error {
|
1294
1360
|
constructor(fnLabel: string | undefined, externalNames: string[]);
|
1295
1361
|
}
|
1296
|
-
declare class
|
1297
|
-
constructor(
|
1362
|
+
declare class MissingBindGroupsError extends Error {
|
1363
|
+
constructor(layouts: Iterable<TgpuBindGroupLayout>);
|
1364
|
+
}
|
1365
|
+
declare class MissingVertexBuffersError extends Error {
|
1366
|
+
constructor(layouts: Iterable<TgpuVertexLayout<WgslArray | Disarray>>);
|
1298
1367
|
}
|
1299
1368
|
|
1300
1369
|
type TgpuBuffer<TData extends AnyData> = TgpuBuffer$1<Exotic<TData>>;
|
@@ -1329,4 +1398,4 @@ declare const tgpu: {
|
|
1329
1398
|
};
|
1330
1399
|
};
|
1331
1400
|
|
1332
|
-
export { type BindLayoutEntry, type Eventual, type InitFromDeviceOptions, type InitOptions, type LayoutEntryToInput,
|
1401
|
+
export { type BindLayoutEntry, type Eventual, type InitFromDeviceOptions, type InitOptions, type LayoutEntryToInput, MissingBindGroupsError, MissingLinksError, MissingSlotValueError, MissingVertexBuffersError, NotUniformError, RandomNameRegistry, type Render, ResolutionError, type Sampled, Storage, StrictNameRegistry, type TextureProps, type TgpuAccessor, type TgpuAnyTextureView, type TgpuBindGroup, type TgpuBindGroupLayout, type TgpuBuffer, type TgpuBufferMutable, type TgpuBufferReadonly, type TgpuBufferUniform, type TgpuComputeFn, type TgpuComputeFnShell, type TgpuComputePipeline, type TgpuConst, type TgpuDeclare, type TgpuDerived, type TgpuFn, type TgpuFnShell, type TgpuFragmentFn, type TgpuFragmentFnShell, type TgpuLayoutComparisonSampler, type TgpuLayoutEntry, type TgpuLayoutExternalTexture, type TgpuLayoutSampler, type TgpuLayoutStorage, type TgpuLayoutStorageTexture, type TgpuLayoutTexture, type TgpuLayoutUniform, type TgpuMutableTexture, type TgpuReadonlyTexture, type TgpuRenderPipeline, type TgpuRoot, type TgpuSampledTexture, type TgpuSampler, type TgpuSlot, type TgpuTexture, type TgpuVar, type TgpuVertexFn, type TgpuVertexFnShell, type TgpuVertexLayout, type TgpuWriteonlyTexture, Uniform, type VariableScope, Vertex, type WithBinding, type WithCompute, type WithFragment, type WithVertex, tgpu as default, isBuffer, isComparisonSampler, isDerived, isSampledTextureView, isSampler, isSlot, isStorageTextureView, isTexture, isTgpuFn, isUsableAsRender, isUsableAsSampled, isUsableAsStorage, isUsableAsUniform, isUsableAsVertex, tgpu, asMutable as unstable_asMutable, asReadonly as unstable_asReadonly, asUniform as unstable_asUniform };
|
package/index.d.ts
CHANGED
@@ -1,5 +1,5 @@
|
|
1
|
-
import { A as AnyWgslData, I as Infer, D as Decorated, 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, B as BaseWgslData, L as Location,
|
2
|
-
import { T as TgpuNamable, E as Exotic, A as AnyBuiltin, a as AnyAttribute, D as Default, U as UnionToIntersection, b as AnyData, c as Decorate, d as TgpuStruct, I as IsBuiltin, H as HasCustomLocation, O as OmitBuiltins, e as Disarray, K as KindToAcceptedAttribMap, f as Unstruct, V as VertexFormat, g as TgpuVertexAttrib, h as KindToDefaultFormatMap, i as OmitProps, P as Prettify, M as Mutable, j as Infer$1, k as ExoticArray } from './index-
|
1
|
+
import { A as AnyWgslData, I as Infer, D as Decorated, 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, B as BaseWgslData, L as Location, n as AnyWgslStruct, W as WgslArray, o as WgslTypeLiteral, p as AnyVecInstance, q as AnyMatInstance } from './vector-CDD2FV2v.js';
|
2
|
+
import { T as TgpuNamable, E as Exotic, A as AnyBuiltin, a as AnyAttribute, D as Default, U as UnionToIntersection, b as AnyData, c as Decorate, d as TgpuStruct, I as IsBuiltin, H as HasCustomLocation, O as OmitBuiltins, e as Disarray, K as KindToAcceptedAttribMap, f as Unstruct, V as VertexFormat, g as TgpuVertexAttrib, h as KindToDefaultFormatMap, i as OmitProps, P as Prettify, M as Mutable, j as Infer$1, k as ExoticArray } from './index-FHKuURMs.js';
|
3
3
|
import * as smol from 'tinyest';
|
4
4
|
import { Block } from 'tinyest';
|
5
5
|
|
@@ -133,6 +133,7 @@ declare class StrictNameRegistry implements NameRegistry {
|
|
133
133
|
|
134
134
|
interface TgpuSlot<T> extends TgpuNamable, Labelled {
|
135
135
|
readonly resourceType: 'slot';
|
136
|
+
'~repr': Infer<T>;
|
136
137
|
readonly defaultValue: T | undefined;
|
137
138
|
/**
|
138
139
|
* Used to determine if code generated using either value `a` or `b` in place
|
@@ -144,6 +145,8 @@ interface TgpuSlot<T> extends TgpuNamable, Labelled {
|
|
144
145
|
interface TgpuDerived<T> {
|
145
146
|
readonly resourceType: 'derived';
|
146
147
|
readonly value: Infer<T>;
|
148
|
+
'~repr': Infer<T>;
|
149
|
+
readonly '~providing'?: Providing | undefined;
|
147
150
|
with<TValue>(slot: TgpuSlot<TValue>, value: Eventual<TValue>): TgpuDerived<T>;
|
148
151
|
/**
|
149
152
|
* @internal
|
@@ -152,6 +155,7 @@ interface TgpuDerived<T> {
|
|
152
155
|
}
|
153
156
|
interface TgpuAccessor<T extends AnyWgslData = AnyWgslData> extends TgpuNamable, Labelled {
|
154
157
|
readonly resourceType: 'accessor';
|
158
|
+
'~repr': Infer<T>;
|
155
159
|
readonly schema: T;
|
156
160
|
readonly defaultValue: TgpuFn<[], T> | TgpuBufferUsage<T> | Infer<T> | undefined;
|
157
161
|
readonly slot: TgpuSlot<TgpuFn<[], T> | TgpuBufferUsage<T> | Infer<T>>;
|
@@ -162,6 +166,10 @@ interface TgpuAccessor<T extends AnyWgslData = AnyWgslData> extends TgpuNamable,
|
|
162
166
|
*/
|
163
167
|
type Eventual<T> = T | TgpuSlot<T> | TgpuDerived<T>;
|
164
168
|
type SlotValuePair<T = unknown> = [TgpuSlot<T>, T];
|
169
|
+
type Providing = {
|
170
|
+
inner: unknown;
|
171
|
+
pairs: SlotValuePair[];
|
172
|
+
};
|
165
173
|
declare function isSlot<T>(value: unknown | TgpuSlot<T>): value is TgpuSlot<T>;
|
166
174
|
declare function isDerived<T extends TgpuDerived<unknown>>(value: T | unknown): value is T;
|
167
175
|
|
@@ -448,7 +456,7 @@ interface Unwrapper {
|
|
448
456
|
type WithLocations<T extends IORecord> = {
|
449
457
|
[Key in keyof T]: IsBuiltin<T[Key]> extends true ? T[Key] : HasCustomLocation<T[Key]> extends true ? T[Key] : Decorate<T[Key], Location<number>>;
|
450
458
|
};
|
451
|
-
type
|
459
|
+
type IOLayoutToSchema<T extends IOLayout> = T extends BaseWgslData ? Decorate<T, Location<0>> : T extends IORecord ? TgpuStruct<WithLocations<T>> : never;
|
452
460
|
|
453
461
|
/**
|
454
462
|
* Describes a fragment entry function signature (its arguments and return type)
|
@@ -470,7 +478,7 @@ interface TgpuFragmentFnShell<FragmentIn extends IOLayout, FragmentOut extends I
|
|
470
478
|
}
|
471
479
|
interface TgpuFragmentFn<Varying extends IOLayout = IOLayout, Output extends IOLayout<Vec4f> = IOLayout<Vec4f>> extends TgpuNamable {
|
472
480
|
readonly shell: TgpuFragmentFnShell<Varying, Output>;
|
473
|
-
readonly outputType:
|
481
|
+
readonly outputType: IOLayoutToSchema<Output>;
|
474
482
|
$uses(dependencyMap: Record<string, unknown>): this;
|
475
483
|
}
|
476
484
|
/**
|
@@ -491,8 +499,9 @@ declare function fragmentFn<FragmentIn extends IORecord, FragmentOut extends IOL
|
|
491
499
|
* Describes a vertex entry function signature (its arguments and return type)
|
492
500
|
*/
|
493
501
|
interface TgpuVertexFnShell<VertexIn extends IOLayout, VertexOut extends IOLayout> {
|
494
|
-
readonly argTypes: [
|
502
|
+
readonly argTypes: [AnyWgslStruct];
|
495
503
|
readonly returnType: VertexOut;
|
504
|
+
readonly attributes: [VertexIn];
|
496
505
|
/**
|
497
506
|
* Creates a type-safe implementation of this signature
|
498
507
|
*/
|
@@ -507,7 +516,8 @@ interface TgpuVertexFnShell<VertexIn extends IOLayout, VertexOut extends IOLayou
|
|
507
516
|
}
|
508
517
|
interface TgpuVertexFn<VertexIn extends IOLayout = IOLayout, VertexOut extends IOLayout = IOLayout> extends TgpuNamable {
|
509
518
|
readonly shell: TgpuVertexFnShell<VertexIn, VertexOut>;
|
510
|
-
readonly outputType:
|
519
|
+
readonly outputType: IOLayoutToSchema<VertexOut>;
|
520
|
+
readonly inputType: IOLayoutToSchema<VertexIn>;
|
511
521
|
$uses(dependencyMap: Record<string, unknown>): this;
|
512
522
|
}
|
513
523
|
/**
|
@@ -521,7 +531,7 @@ interface TgpuVertexFn<VertexIn extends IOLayout = IOLayout, VertexOut extends I
|
|
521
531
|
* A struct type containing the final position of the vertex, and any information
|
522
532
|
* passed onto the fragment shader stage.
|
523
533
|
*/
|
524
|
-
declare function vertexFn<VertexIn extends
|
534
|
+
declare function vertexFn<VertexIn extends IORecord, VertexOut extends IORecord>(inputType: VertexIn, outputType: VertexOut): TgpuVertexFnShell<ExoticIO<VertexIn>, ExoticIO<VertexOut>>;
|
525
535
|
|
526
536
|
/**
|
527
537
|
* The array can hold T, where T is a single/multi-component numeric, or a struct with members of type T.
|
@@ -531,7 +541,7 @@ declare function vertexFn<VertexIn extends IOLayout, VertexOut extends IORecord>
|
|
531
541
|
* - TgpuStruct<{ a: Vec3f, b: unorm8x2 }>
|
532
542
|
* - TgpuStruct<{ nested: TgpuStruct<{ a: Vec3f }> }>
|
533
543
|
*/
|
534
|
-
type DataToContainedAttribs<T> = T extends
|
544
|
+
type DataToContainedAttribs<T> = T extends AnyWgslStruct | Unstruct ? {
|
535
545
|
[Key in keyof T['propTypes']]: DataToContainedAttribs<T['propTypes'][Key]>;
|
536
546
|
} : T extends {
|
537
547
|
type: VertexFormat;
|
@@ -563,6 +573,7 @@ interface TgpuRenderPipeline<Output extends IOLayout = IOLayout> extends TgpuNam
|
|
563
573
|
with<TData extends WgslArray | Disarray>(vertexLayout: TgpuVertexLayout<TData>, buffer: TgpuBuffer$1<TData> & Vertex): TgpuRenderPipeline<IOLayout>;
|
564
574
|
with<Entries extends Record<string, TgpuLayoutEntry | null>>(bindGroupLayout: TgpuBindGroupLayout<Entries>, bindGroup: TgpuBindGroup<Entries>): TgpuRenderPipeline<IOLayout>;
|
565
575
|
withColorAttachment(attachment: FragmentOutToColorAttachment<Output>): TgpuRenderPipeline<IOLayout>;
|
576
|
+
withDepthStencilAttachment(attachment: DepthStencilAttachment): TgpuRenderPipeline<IOLayout>;
|
566
577
|
draw(vertexCount: number, instanceCount?: number, firstVertex?: number, firstInstance?: number): void;
|
567
578
|
}
|
568
579
|
type FragmentOutToTargets<T extends IOLayout> = T extends IOData ? GPUColorTargetState : T extends Record<string, unknown> ? {
|
@@ -609,6 +620,59 @@ interface ColorAttachment {
|
|
609
620
|
*/
|
610
621
|
storeOp: GPUStoreOp;
|
611
622
|
}
|
623
|
+
interface DepthStencilAttachment {
|
624
|
+
/**
|
625
|
+
* A {@link GPUTextureView} | ({@link TgpuTexture} & {@link Render}) describing the texture subresource that will be output to
|
626
|
+
* and read from for this depth/stencil attachment.
|
627
|
+
*/
|
628
|
+
view: (TgpuTexture & Render) | GPUTextureView;
|
629
|
+
/**
|
630
|
+
* Indicates the value to clear {@link GPURenderPassDepthStencilAttachment#view}'s depth component
|
631
|
+
* to prior to executing the render pass. Ignored if {@link GPURenderPassDepthStencilAttachment#depthLoadOp}
|
632
|
+
* is not {@link GPULoadOp#"clear"}. Must be between 0.0 and 1.0, inclusive (unless unrestricted depth is enabled).
|
633
|
+
*/
|
634
|
+
depthClearValue?: number;
|
635
|
+
/**
|
636
|
+
* Indicates the load operation to perform on {@link GPURenderPassDepthStencilAttachment#view}'s
|
637
|
+
* depth component prior to executing the render pass.
|
638
|
+
* Note: It is recommended to prefer clearing; see {@link GPULoadOp#"clear"} for details.
|
639
|
+
*/
|
640
|
+
depthLoadOp?: GPULoadOp;
|
641
|
+
/**
|
642
|
+
* The store operation to perform on {@link GPURenderPassDepthStencilAttachment#view}'s
|
643
|
+
* depth component after executing the render pass.
|
644
|
+
*/
|
645
|
+
depthStoreOp?: GPUStoreOp;
|
646
|
+
/**
|
647
|
+
* Indicates that the depth component of {@link GPURenderPassDepthStencilAttachment#view}
|
648
|
+
* is read only.
|
649
|
+
*/
|
650
|
+
depthReadOnly?: boolean;
|
651
|
+
/**
|
652
|
+
* Indicates the value to clear {@link GPURenderPassDepthStencilAttachment#view}'s stencil component
|
653
|
+
* to prior to executing the render pass. Ignored if {@link GPURenderPassDepthStencilAttachment#stencilLoadOp}
|
654
|
+
* is not {@link GPULoadOp#"clear"}.
|
655
|
+
* The value will be converted to the type of the stencil aspect of `view` by taking the same
|
656
|
+
* number of LSBs as the number of bits in the stencil aspect of one texel block|texel of `view`.
|
657
|
+
*/
|
658
|
+
stencilClearValue?: GPUStencilValue;
|
659
|
+
/**
|
660
|
+
* Indicates the load operation to perform on {@link GPURenderPassDepthStencilAttachment#view}'s
|
661
|
+
* stencil component prior to executing the render pass.
|
662
|
+
* Note: It is recommended to prefer clearing; see {@link GPULoadOp#"clear"} for details.
|
663
|
+
*/
|
664
|
+
stencilLoadOp?: GPULoadOp;
|
665
|
+
/**
|
666
|
+
* The store operation to perform on {@link GPURenderPassDepthStencilAttachment#view}'s
|
667
|
+
* stencil component after executing the render pass.
|
668
|
+
*/
|
669
|
+
stencilStoreOp?: GPUStoreOp;
|
670
|
+
/**
|
671
|
+
* Indicates that the stencil component of {@link GPURenderPassDepthStencilAttachment#view}
|
672
|
+
* is read only.
|
673
|
+
*/
|
674
|
+
stencilReadOnly?: boolean;
|
675
|
+
}
|
612
676
|
|
613
677
|
interface WithCompute {
|
614
678
|
createPipeline(): TgpuComputePipeline;
|
@@ -634,6 +698,7 @@ interface WithVertex<VertexOut extends IORecord = IORecord> {
|
|
634
698
|
}
|
635
699
|
interface WithFragment<Output extends IOLayout<Vec4f> = IOLayout<Vec4f>> {
|
636
700
|
withPrimitive(primitiveState: GPUPrimitiveState | undefined): WithFragment<Output>;
|
701
|
+
withDepthStencil(depthStencilState: GPUDepthStencilState | undefined): WithFragment<Output>;
|
637
702
|
createPipeline(): TgpuRenderPipeline<Output>;
|
638
703
|
}
|
639
704
|
interface WithBinding {
|
@@ -1142,6 +1207,7 @@ interface TgpuFnShell<Args extends AnyWgslData[] = AnyWgslData[], Return extends
|
|
1142
1207
|
interface TgpuFnBase<Args extends AnyWgslData[], Return extends AnyWgslData | undefined = undefined> extends TgpuNamable, Labelled {
|
1143
1208
|
readonly resourceType: 'function';
|
1144
1209
|
readonly shell: TgpuFnShell<Args, Return>;
|
1210
|
+
readonly '~providing'?: Providing | undefined;
|
1145
1211
|
$uses(dependencyMap: Record<string, unknown>): this;
|
1146
1212
|
with<T>(slot: TgpuSlot<T>, value: Eventual<T>): TgpuFn<Args, Return>;
|
1147
1213
|
with<T extends AnyWgslData>(accessor: TgpuAccessor<T>, value: TgpuFn<[], T> | TgpuBufferUsage<T> | Infer$1<T>): TgpuFn<Args, Return>;
|
@@ -1293,8 +1359,11 @@ declare class NotUniformError extends Error {
|
|
1293
1359
|
declare class MissingLinksError extends Error {
|
1294
1360
|
constructor(fnLabel: string | undefined, externalNames: string[]);
|
1295
1361
|
}
|
1296
|
-
declare class
|
1297
|
-
constructor(
|
1362
|
+
declare class MissingBindGroupsError extends Error {
|
1363
|
+
constructor(layouts: Iterable<TgpuBindGroupLayout>);
|
1364
|
+
}
|
1365
|
+
declare class MissingVertexBuffersError extends Error {
|
1366
|
+
constructor(layouts: Iterable<TgpuVertexLayout<WgslArray | Disarray>>);
|
1298
1367
|
}
|
1299
1368
|
|
1300
1369
|
type TgpuBuffer<TData extends AnyData> = TgpuBuffer$1<Exotic<TData>>;
|
@@ -1329,4 +1398,4 @@ declare const tgpu: {
|
|
1329
1398
|
};
|
1330
1399
|
};
|
1331
1400
|
|
1332
|
-
export { type BindLayoutEntry, type Eventual, type InitFromDeviceOptions, type InitOptions, type LayoutEntryToInput,
|
1401
|
+
export { type BindLayoutEntry, type Eventual, type InitFromDeviceOptions, type InitOptions, type LayoutEntryToInput, MissingBindGroupsError, MissingLinksError, MissingSlotValueError, MissingVertexBuffersError, NotUniformError, RandomNameRegistry, type Render, ResolutionError, type Sampled, Storage, StrictNameRegistry, type TextureProps, type TgpuAccessor, type TgpuAnyTextureView, type TgpuBindGroup, type TgpuBindGroupLayout, type TgpuBuffer, type TgpuBufferMutable, type TgpuBufferReadonly, type TgpuBufferUniform, type TgpuComputeFn, type TgpuComputeFnShell, type TgpuComputePipeline, type TgpuConst, type TgpuDeclare, type TgpuDerived, type TgpuFn, type TgpuFnShell, type TgpuFragmentFn, type TgpuFragmentFnShell, type TgpuLayoutComparisonSampler, type TgpuLayoutEntry, type TgpuLayoutExternalTexture, type TgpuLayoutSampler, type TgpuLayoutStorage, type TgpuLayoutStorageTexture, type TgpuLayoutTexture, type TgpuLayoutUniform, type TgpuMutableTexture, type TgpuReadonlyTexture, type TgpuRenderPipeline, type TgpuRoot, type TgpuSampledTexture, type TgpuSampler, type TgpuSlot, type TgpuTexture, type TgpuVar, type TgpuVertexFn, type TgpuVertexFnShell, type TgpuVertexLayout, type TgpuWriteonlyTexture, Uniform, type VariableScope, Vertex, type WithBinding, type WithCompute, type WithFragment, type WithVertex, tgpu as default, isBuffer, isComparisonSampler, isDerived, isSampledTextureView, isSampler, isSlot, isStorageTextureView, isTexture, isTgpuFn, isUsableAsRender, isUsableAsSampled, isUsableAsStorage, isUsableAsUniform, isUsableAsVertex, tgpu, asMutable as unstable_asMutable, asReadonly as unstable_asReadonly, asUniform as unstable_asUniform };
|