typegpu 0.3.3 → 0.3.4
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/chunk-RFXJKOYG.cjs +2 -0
- package/chunk-RFXJKOYG.cjs.map +1 -0
- package/chunk-RW6OZYQI.js +2 -0
- package/chunk-RW6OZYQI.js.map +1 -0
- package/data/index.cjs +1 -192
- package/data/index.d.cts +2 -2
- package/data/index.d.ts +2 -2
- package/data/index.js +1 -192
- package/index-DtGAMBfJ.d.cts +407 -0
- package/index-FeXoGB17.d.ts +407 -0
- package/index.cjs +14 -4269
- package/index.cjs.map +1 -1
- package/index.d.cts +44 -44
- package/index.d.ts +44 -44
- package/index.js +14 -4269
- package/index.js.map +1 -1
- package/package.json +1 -1
- package/std/index.cjs +1 -490
- package/std/index.cjs.map +1 -1
- package/std/index.d.cts +3 -2
- package/std/index.d.ts +3 -2
- package/std/index.js +1 -490
- package/std/index.js.map +1 -1
- package/{vector-CDD2FV2v.d.ts → wgslTypes-DHAmU620.d.cts} +603 -246
- package/{vector-CDD2FV2v.d.cts → wgslTypes-DHAmU620.d.ts} +603 -246
- package/chunk-2CMWQRQC.cjs +0 -2
- package/chunk-2CMWQRQC.cjs.map +0 -1
- package/chunk-2ZAQFPSX.js +0 -1266
- package/chunk-2ZAQFPSX.js.map +0 -1
- package/chunk-35UVS2JJ.cjs +0 -591
- package/chunk-35UVS2JJ.cjs.map +0 -1
- package/chunk-CMYXKKUP.cjs +0 -1266
- package/chunk-CMYXKKUP.cjs.map +0 -1
- package/chunk-DDEF2Y4S.js +0 -591
- package/chunk-DDEF2Y4S.js.map +0 -1
- package/chunk-KYBPSQX5.js +0 -2
- package/chunk-KYBPSQX5.js.map +0 -1
- package/index-CuzbyKXg.d.cts +0 -751
- package/index-FHKuURMs.d.ts +0 -751
package/data/index.js
CHANGED
@@ -1,193 +1,2 @@
|
|
1
|
-
import {
|
2
|
-
PUBLIC_alignmentOf,
|
3
|
-
PUBLIC_sizeOf,
|
4
|
-
align,
|
5
|
-
arrayOf,
|
6
|
-
atomic,
|
7
|
-
bool,
|
8
|
-
builtin,
|
9
|
-
disarrayOf,
|
10
|
-
f16,
|
11
|
-
f32,
|
12
|
-
float16,
|
13
|
-
float16x2,
|
14
|
-
float16x4,
|
15
|
-
float32,
|
16
|
-
float32x2,
|
17
|
-
float32x3,
|
18
|
-
float32x4,
|
19
|
-
i32,
|
20
|
-
interpolate,
|
21
|
-
isAlignAttrib,
|
22
|
-
isAtomic,
|
23
|
-
isBuiltin,
|
24
|
-
isBuiltinAttrib,
|
25
|
-
isData,
|
26
|
-
isDecorated,
|
27
|
-
isDisarray,
|
28
|
-
isInterpolateAttrib,
|
29
|
-
isLocationAttrib,
|
30
|
-
isLooseData,
|
31
|
-
isLooseDecorated,
|
32
|
-
isPtrFn,
|
33
|
-
isSizeAttrib,
|
34
|
-
isUnstruct,
|
35
|
-
isWgslArray,
|
36
|
-
isWgslData,
|
37
|
-
isWgslStruct,
|
38
|
-
location,
|
39
|
-
mat2x2f,
|
40
|
-
mat3x3f,
|
41
|
-
mat4x4f,
|
42
|
-
matToArray,
|
43
|
-
packedFormats,
|
44
|
-
ptrFn,
|
45
|
-
sint16,
|
46
|
-
sint16x2,
|
47
|
-
sint16x4,
|
48
|
-
sint32,
|
49
|
-
sint32x2,
|
50
|
-
sint32x3,
|
51
|
-
sint32x4,
|
52
|
-
sint8,
|
53
|
-
sint8x2,
|
54
|
-
sint8x4,
|
55
|
-
size,
|
56
|
-
snorm16,
|
57
|
-
snorm16x2,
|
58
|
-
snorm16x4,
|
59
|
-
snorm8,
|
60
|
-
snorm8x2,
|
61
|
-
snorm8x4,
|
62
|
-
struct,
|
63
|
-
u32,
|
64
|
-
uint16,
|
65
|
-
uint16x2,
|
66
|
-
uint16x4,
|
67
|
-
uint32,
|
68
|
-
uint32x2,
|
69
|
-
uint32x3,
|
70
|
-
uint32x4,
|
71
|
-
uint8,
|
72
|
-
uint8x2,
|
73
|
-
uint8x4,
|
74
|
-
unorm10_10_10_2,
|
75
|
-
unorm16,
|
76
|
-
unorm16x2,
|
77
|
-
unorm16x4,
|
78
|
-
unorm8,
|
79
|
-
unorm8x2,
|
80
|
-
unorm8x4,
|
81
|
-
unorm8x4_bgra,
|
82
|
-
unstruct
|
83
|
-
} from "../chunk-2ZAQFPSX.js";
|
84
|
-
import {
|
85
|
-
vec2f,
|
86
|
-
vec2h,
|
87
|
-
vec2i,
|
88
|
-
vec2u,
|
89
|
-
vec3f,
|
90
|
-
vec3h,
|
91
|
-
vec3i,
|
92
|
-
vec3u,
|
93
|
-
vec4f,
|
94
|
-
vec4h,
|
95
|
-
vec4i,
|
96
|
-
vec4u
|
97
|
-
} from "../chunk-DDEF2Y4S.js";
|
98
|
-
export {
|
99
|
-
align,
|
100
|
-
PUBLIC_alignmentOf as alignmentOf,
|
101
|
-
arrayOf,
|
102
|
-
atomic,
|
103
|
-
bool,
|
104
|
-
builtin,
|
105
|
-
disarrayOf,
|
106
|
-
f16,
|
107
|
-
f32,
|
108
|
-
float16,
|
109
|
-
float16x2,
|
110
|
-
float16x4,
|
111
|
-
float32,
|
112
|
-
float32x2,
|
113
|
-
float32x3,
|
114
|
-
float32x4,
|
115
|
-
i32,
|
116
|
-
interpolate,
|
117
|
-
isAlignAttrib,
|
118
|
-
isAtomic,
|
119
|
-
isBuiltin,
|
120
|
-
isBuiltinAttrib,
|
121
|
-
isData,
|
122
|
-
isDecorated,
|
123
|
-
isDisarray,
|
124
|
-
isInterpolateAttrib,
|
125
|
-
isLocationAttrib,
|
126
|
-
isLooseData,
|
127
|
-
isLooseDecorated,
|
128
|
-
isPtrFn,
|
129
|
-
isSizeAttrib,
|
130
|
-
isUnstruct,
|
131
|
-
isWgslArray,
|
132
|
-
isWgslData,
|
133
|
-
isWgslStruct,
|
134
|
-
location,
|
135
|
-
mat2x2f,
|
136
|
-
mat3x3f,
|
137
|
-
mat4x4f,
|
138
|
-
matToArray,
|
139
|
-
packedFormats,
|
140
|
-
ptrFn,
|
141
|
-
sint16,
|
142
|
-
sint16x2,
|
143
|
-
sint16x4,
|
144
|
-
sint32,
|
145
|
-
sint32x2,
|
146
|
-
sint32x3,
|
147
|
-
sint32x4,
|
148
|
-
sint8,
|
149
|
-
sint8x2,
|
150
|
-
sint8x4,
|
151
|
-
size,
|
152
|
-
PUBLIC_sizeOf as sizeOf,
|
153
|
-
snorm16,
|
154
|
-
snorm16x2,
|
155
|
-
snorm16x4,
|
156
|
-
snorm8,
|
157
|
-
snorm8x2,
|
158
|
-
snorm8x4,
|
159
|
-
struct,
|
160
|
-
u32,
|
161
|
-
uint16,
|
162
|
-
uint16x2,
|
163
|
-
uint16x4,
|
164
|
-
uint32,
|
165
|
-
uint32x2,
|
166
|
-
uint32x3,
|
167
|
-
uint32x4,
|
168
|
-
uint8,
|
169
|
-
uint8x2,
|
170
|
-
uint8x4,
|
171
|
-
unorm10_10_10_2,
|
172
|
-
unorm16,
|
173
|
-
unorm16x2,
|
174
|
-
unorm16x4,
|
175
|
-
unorm8,
|
176
|
-
unorm8x2,
|
177
|
-
unorm8x4,
|
178
|
-
unorm8x4_bgra,
|
179
|
-
unstruct,
|
180
|
-
vec2f,
|
181
|
-
vec2h,
|
182
|
-
vec2i,
|
183
|
-
vec2u,
|
184
|
-
vec3f,
|
185
|
-
vec3h,
|
186
|
-
vec3i,
|
187
|
-
vec3u,
|
188
|
-
vec4f,
|
189
|
-
vec4h,
|
190
|
-
vec4i,
|
191
|
-
vec4u
|
192
|
-
};
|
1
|
+
import{$ as ha,A as I,Aa as Fa,B as J,Ba as Ga,C as K,D as L,Da as Ha,E as M,Ea as Ia,F as N,Fa as Ja,G as O,Ga as Ka,H as P,Ha as La,I as Q,J as R,Ja as Ma,K as S,L as T,M as U,N as V,O as W,P as X,Q as Y,R as Z,S as _,T as $,U as aa,V as ba,W as ca,X as da,Y as ea,Z as fa,_ as ga,a,aa as ia,b,ba as ja,c,ca as ka,d,da as la,e,ea as ma,f,fa as na,g,ga as oa,h,ha as pa,i,ia as qa,j,ja as ra,k,ka as sa,l,la as ta,m,ma as ua,n,na as va,o,p,q,qa as wa,sa as xa,ta as ya,u as r,ua as za,v as s,va as Aa,w as t,wa as Ba,x as u,xa as Ca,ya as Da,z as v,za as Ea}from"../chunk-RW6OZYQI.js";import{n as w,o as x,p as y,q as z,r as A,s as B,t as C,u as D,v as E,w as F,x as G,y as H}from"../chunk-A2QB4MSZ.js";export{Ha as align,wa as alignmentOf,ya as arrayOf,Ga as atomic,l as bool,Ma as builtin,Aa as disarrayOf,p as f16,o as f32,fa as float16,ga as float16x2,ha as float16x4,ia as float32,ja as float32x2,ka as float32x3,la as float32x4,n as i32,Ka as interpolate,f as isAlignAttrib,e as isAtomic,La as isBuiltin,j as isBuiltinAttrib,v as isData,k as isDecorated,s as isDisarray,i as isInterpolateAttrib,h as isLocationAttrib,r as isLooseData,u as isLooseDecorated,d as isPtrFn,g as isSizeAttrib,t as isUnstruct,b as isWgslArray,a as isWgslData,c as isWgslStruct,Ja as location,Ca as mat2x2f,Da as mat3x3f,Ea as mat4x4f,Fa as matToArray,I as packedFormats,za as ptrFn,Y as sint16,Z as sint16x2,_ as sint16x4,qa as sint32,ra as sint32x2,sa as sint32x3,ta as sint32x4,M as sint8,N as sint8x2,O as sint8x4,Ia as size,xa as sizeOf,ca as snorm16,da as snorm16x2,ea as snorm16x4,S as snorm8,T as snorm8x2,U as snorm8x4,q as struct,m as u32,V as uint16,W as uint16x2,X as uint16x4,ma as uint32,na as uint32x2,oa as uint32x3,pa as uint32x4,J as uint8,K as uint8x2,L as uint8x4,ua as unorm10_10_10_2,$ as unorm16,aa as unorm16x2,ba as unorm16x4,P as unorm8,Q as unorm8x2,R as unorm8x4,va as unorm8x4_bgra,Ba as unstruct,w as vec2f,x as vec2h,y as vec2i,z as vec2u,A as vec3f,B as vec3h,C as vec3i,D as vec3u,E as vec4f,F as vec4h,G as vec4i,H as vec4u};
|
193
2
|
//# sourceMappingURL=index.js.map
|
@@ -0,0 +1,407 @@
|
|
1
|
+
import { D as Decorated, U as U32, w as Builtin, d as Vec4f, W as WgslArray, F as F32, l as Vec3u, B as BaseWgslData, x as Align, S as Size, L as Location, y as Interpolate, z as InterpolationType, o as AnyData, P as PerspectiveOrLinearInterpolationType, C as PerspectiveOrLinearInterpolatableData, E as FlatInterpolationType, G as FlatInterpolatableData, A as AnyWgslData, H as LooseDecorated, J as AnyLooseData, t as WgslTypeLiteral, N as LooseTypeLiteral, O as WgslStruct, Q as PtrFn, p as Disarray, q as Unstruct, R as m2x2f, X as m3x3f, Y as m4x4f, Z as Mat2x2f, _ as v2f, $ as Mat3x3f, a0 as v3f, a1 as Mat4x4f, a2 as v4f, b as I32, a3 as Atomic, I as Infer$1 } from './wgslTypes-DHAmU620.cjs';
|
2
|
+
|
3
|
+
/**
|
4
|
+
* Can be assigned a name. Not to be confused with
|
5
|
+
* being able to HAVE a name.
|
6
|
+
*/
|
7
|
+
interface TgpuNamable {
|
8
|
+
$name(label?: string | undefined): this;
|
9
|
+
}
|
10
|
+
|
11
|
+
/**
|
12
|
+
* Strips schema types down to their most basic forms. (native -> exotic)
|
13
|
+
* This is used by schema constructors to be able to ingest native schemas (created by TypeGPU), and
|
14
|
+
* spit out a type that matches non-native schemas as well.
|
15
|
+
*/
|
16
|
+
type Exotic<T> = T extends {
|
17
|
+
readonly '~exotic': infer TExotic;
|
18
|
+
} ? TExotic : T;
|
19
|
+
type ExoticArray<T> = T extends unknown[] | [] ? {
|
20
|
+
[Key in keyof T]: Exotic<T[Key]>;
|
21
|
+
} : T;
|
22
|
+
type ExoticRecord<T> = T extends Record<string | number | symbol, unknown> ? {
|
23
|
+
[Key in keyof T]: Exotic<T[Key]>;
|
24
|
+
} : T;
|
25
|
+
|
26
|
+
type BuiltinVertexIndex = Decorated<U32, [Builtin<'vertex_index'>]>;
|
27
|
+
type BuiltinInstanceIndex = Decorated<U32, [Builtin<'instance_index'>]>;
|
28
|
+
type BuiltinPosition = Decorated<Vec4f, [Builtin<'position'>]>;
|
29
|
+
type BuiltinClipDistances = Decorated<WgslArray<U32>, [
|
30
|
+
Builtin<'clip_distances'>
|
31
|
+
]>;
|
32
|
+
type BuiltinFrontFacing = Decorated<F32, [Builtin<'front_facing'>]>;
|
33
|
+
type BuiltinFragDepth = Decorated<F32, [Builtin<'frag_depth'>]>;
|
34
|
+
type BuiltinSampleIndex = Decorated<U32, [Builtin<'sample_index'>]>;
|
35
|
+
type BuiltinSampleMask = Decorated<U32, [Builtin<'sample_mask'>]>;
|
36
|
+
type BuiltinLocalInvocationId = Decorated<Vec3u, [
|
37
|
+
Builtin<'local_invocation_id'>
|
38
|
+
]>;
|
39
|
+
type BuiltinLocalInvocationIndex = Decorated<U32, [
|
40
|
+
Builtin<'local_invocation_index'>
|
41
|
+
]>;
|
42
|
+
type BuiltinGlobalInvocationId = Decorated<Vec3u, [
|
43
|
+
Builtin<'global_invocation_id'>
|
44
|
+
]>;
|
45
|
+
type BuiltinWorkgroupId = Decorated<Vec3u, [Builtin<'workgroup_id'>]>;
|
46
|
+
type BuiltinNumWorkgroups = Decorated<Vec3u, [
|
47
|
+
Builtin<'num_workgroups'>
|
48
|
+
]>;
|
49
|
+
declare const builtin: {
|
50
|
+
readonly vertexIndex: BuiltinVertexIndex;
|
51
|
+
readonly instanceIndex: BuiltinInstanceIndex;
|
52
|
+
readonly position: BuiltinPosition;
|
53
|
+
readonly clipDistances: BuiltinClipDistances;
|
54
|
+
readonly frontFacing: BuiltinFrontFacing;
|
55
|
+
readonly fragDepth: BuiltinFragDepth;
|
56
|
+
readonly sampleIndex: BuiltinSampleIndex;
|
57
|
+
readonly sampleMask: BuiltinSampleMask;
|
58
|
+
readonly localInvocationId: BuiltinLocalInvocationId;
|
59
|
+
readonly localInvocationIndex: BuiltinLocalInvocationIndex;
|
60
|
+
readonly globalInvocationId: BuiltinGlobalInvocationId;
|
61
|
+
readonly workgroupId: BuiltinWorkgroupId;
|
62
|
+
readonly numWorkgroups: BuiltinNumWorkgroups;
|
63
|
+
};
|
64
|
+
type AnyBuiltin = (typeof builtin)[keyof typeof builtin];
|
65
|
+
type AnyComputeBuiltin = BuiltinLocalInvocationId | BuiltinLocalInvocationIndex | BuiltinGlobalInvocationId | BuiltinWorkgroupId | BuiltinNumWorkgroups;
|
66
|
+
type OmitBuiltins<S> = S extends AnyBuiltin ? never : S extends BaseWgslData ? S : {
|
67
|
+
[Key in keyof S as S[Key] extends AnyBuiltin ? never : Key]: S[Key];
|
68
|
+
};
|
69
|
+
|
70
|
+
declare const builtinNames: readonly ["vertex_index", "instance_index", "position", "clip_distances", "front_facing", "frag_depth", "sample_index", "sample_mask", "fragment", "local_invocation_id", "local_invocation_index", "global_invocation_id", "workgroup_id", "num_workgroups"];
|
71
|
+
type BuiltinName = (typeof builtinNames)[number];
|
72
|
+
type AnyAttribute = Align<number> | Size<number> | Location<number> | Builtin<BuiltinName> | Interpolate<InterpolationType>;
|
73
|
+
type ExtractAttributes<T> = T extends {
|
74
|
+
readonly attribs: unknown[];
|
75
|
+
} ? T['attribs'] : [];
|
76
|
+
type Undecorate<T> = T extends {
|
77
|
+
readonly inner: infer TInner;
|
78
|
+
} ? TInner : T;
|
79
|
+
/**
|
80
|
+
* Decorates a data-type `TData` with an attribute `TAttrib`.
|
81
|
+
*
|
82
|
+
* - if `TData` is loose
|
83
|
+
* - if `TData` is already `LooseDecorated`
|
84
|
+
* - Prepend `TAttrib` to the existing attribute tuple.
|
85
|
+
* - else
|
86
|
+
* - Wrap `TData` with `LooseDecorated` and a single attribute `[TAttrib]`
|
87
|
+
* - else
|
88
|
+
* - if `TData` is already `Decorated`
|
89
|
+
* - Prepend `TAttrib` to the existing attribute tuple.
|
90
|
+
* - else
|
91
|
+
* - Wrap `TData` with `Decorated` and a single attribute `[TAttrib]`
|
92
|
+
*/
|
93
|
+
type Decorate<TData extends BaseWgslData, TAttrib extends AnyAttribute> = TData['type'] extends WgslTypeLiteral ? Decorated<Undecorate<TData>, [TAttrib, ...ExtractAttributes<TData>]> : TData['type'] extends LooseTypeLiteral ? LooseDecorated<Undecorate<TData>, [TAttrib, ...ExtractAttributes<TData>]> : never;
|
94
|
+
type IsBuiltin<T> = ExtractAttributes<T>[number] extends [] ? false : ExtractAttributes<T>[number] extends Builtin<BuiltinName> ? true : false;
|
95
|
+
type HasCustomLocation<T> = ExtractAttributes<T>[number] extends [] ? false : ExtractAttributes<T>[number] extends Location<number> ? true : false;
|
96
|
+
/**
|
97
|
+
* Gives the wrapped data-type a custom byte alignment. Useful in order to
|
98
|
+
* fulfill uniform alignment requirements.
|
99
|
+
*
|
100
|
+
* @example
|
101
|
+
* const Data = d.struct({
|
102
|
+
* a: u32, // takes up 4 bytes
|
103
|
+
* // 12 bytes of padding, because `b` is custom aligned to multiples of 16 bytes
|
104
|
+
* b: d.align(16, u32),
|
105
|
+
* });
|
106
|
+
*
|
107
|
+
* @param alignment The multiple of bytes this data should align itself to.
|
108
|
+
* @param data The data-type to align.
|
109
|
+
*/
|
110
|
+
declare function align<TAlign extends number, TData extends AnyData>(alignment: TAlign, data: TData): Decorate<Exotic<TData>, Align<TAlign>>;
|
111
|
+
/**
|
112
|
+
* Adds padding bytes after the wrapped data-type, until the whole value takes up `size` bytes.
|
113
|
+
*
|
114
|
+
* @example
|
115
|
+
* const Data = d.struct({
|
116
|
+
* a: d.size(16, u32), // takes up 16 bytes, instead of 4
|
117
|
+
* b: u32, // starts at byte 16, because `a` has a custom size
|
118
|
+
* });
|
119
|
+
*
|
120
|
+
* @param size The amount of bytes that should be reserved for this data-type.
|
121
|
+
* @param data The data-type to wrap.
|
122
|
+
*/
|
123
|
+
declare function size<TSize extends number, TData extends AnyData>(size: TSize, data: TData): Decorate<Exotic<TData>, Size<TSize>>;
|
124
|
+
/**
|
125
|
+
* Assigns an explicit numeric location to a struct member or a parameter that has this type.
|
126
|
+
*
|
127
|
+
* @example
|
128
|
+
* const VertexOutput = {
|
129
|
+
* a: d.u32, // has implicit location 0
|
130
|
+
* b: d.location(5, d.u32),
|
131
|
+
* c: d.u32, // has implicit location 6
|
132
|
+
* };
|
133
|
+
*
|
134
|
+
* @param location The explicit numeric location.
|
135
|
+
* @param data The data-type to wrap.
|
136
|
+
*/
|
137
|
+
declare function location<TLocation extends number, TData extends AnyData>(location: TLocation, data: TData): Decorate<Exotic<TData>, Location<TLocation>>;
|
138
|
+
/**
|
139
|
+
* Specifies how user-defined vertex shader output (fragment shader input)
|
140
|
+
* must be interpolated.
|
141
|
+
*
|
142
|
+
* Tip: Integer outputs cannot be interpolated.
|
143
|
+
*
|
144
|
+
* @example
|
145
|
+
* const VertexOutput = {
|
146
|
+
* a: d.f32, // has implicit 'perspective, center' interpolation
|
147
|
+
* b: d.interpolate('linear, sample', d.f32),
|
148
|
+
* };
|
149
|
+
*
|
150
|
+
* @param interpolationType How data should be interpolated.
|
151
|
+
* @param data The data-type to wrap.
|
152
|
+
*/
|
153
|
+
declare function interpolate<TInterpolation extends PerspectiveOrLinearInterpolationType, TData extends PerspectiveOrLinearInterpolatableData>(interpolationType: TInterpolation, data: TData): Decorate<Exotic<TData>, Interpolate<TInterpolation>>;
|
154
|
+
/**
|
155
|
+
* Specifies how user-defined vertex shader output (fragment shader input)
|
156
|
+
* must be interpolated.
|
157
|
+
*
|
158
|
+
* Tip: Default sampling method of `flat` is `first`. Unless you specifically
|
159
|
+
* need deterministic behavior provided by `'flat, first'`, prefer explicit
|
160
|
+
* `'flat, either'` as it could be slightly faster in hardware.
|
161
|
+
*
|
162
|
+
* @example
|
163
|
+
* const VertexOutput = {
|
164
|
+
* a: d.f32, // has implicit 'perspective, center' interpolation
|
165
|
+
* b: d.interpolate('flat, either', d.u32), // integer outputs cannot interpolate
|
166
|
+
* };
|
167
|
+
*
|
168
|
+
* @param interpolationType How data should be interpolated.
|
169
|
+
* @param data The data-type to wrap.
|
170
|
+
*/
|
171
|
+
declare function interpolate<TInterpolation extends FlatInterpolationType, TData extends FlatInterpolatableData>(interpolationType: TInterpolation, data: TData): Decorate<Exotic<TData>, Interpolate<TInterpolation>>;
|
172
|
+
declare function isBuiltin<T extends Decorated<AnyWgslData, AnyAttribute[]> | LooseDecorated<AnyLooseData, AnyAttribute[]>>(value: T | unknown): value is T;
|
173
|
+
|
174
|
+
type Default<T, TDefault> = unknown extends T ? TDefault : T extends undefined ? TDefault : T;
|
175
|
+
type UnionToIntersection<U> = (U extends any ? (x: U) => void : never) extends (x: infer I) => void ? I : never;
|
176
|
+
type Prettify<T> = {
|
177
|
+
[K in keyof T]: T[K];
|
178
|
+
} & {};
|
179
|
+
/**
|
180
|
+
* Removes properties from record type that extend `Prop`
|
181
|
+
*/
|
182
|
+
type OmitProps<T extends Record<string, unknown>, Prop> = Pick<T, {
|
183
|
+
[Key in keyof T]: T[Key] extends Prop ? never : Key;
|
184
|
+
}[keyof T]>;
|
185
|
+
/**
|
186
|
+
* The opposite of Readonly<T>
|
187
|
+
*/
|
188
|
+
type Mutable<T> = {
|
189
|
+
-readonly [P in keyof T]: T[P];
|
190
|
+
};
|
191
|
+
|
192
|
+
/**
|
193
|
+
* Struct schema constructed via `d.struct` function.
|
194
|
+
*
|
195
|
+
* Responsible for handling reading and writing struct values
|
196
|
+
* between binary and JS representation. Takes into account
|
197
|
+
* the `byteAlignment` requirement of its members.
|
198
|
+
*/
|
199
|
+
interface TgpuStruct<TProps extends Record<string, BaseWgslData>> extends WgslStruct<TProps>, TgpuNamable {
|
200
|
+
readonly '~exotic': WgslStruct<TProps>;
|
201
|
+
}
|
202
|
+
/**
|
203
|
+
* Creates a struct schema that can be used to construct GPU buffers.
|
204
|
+
* Ensures proper alignment and padding of properties (as opposed to a `d.unstruct` schema).
|
205
|
+
* The order of members matches the passed in properties object.
|
206
|
+
*
|
207
|
+
* @example
|
208
|
+
* const CircleStruct = d.struct({ radius: d.f32, pos: d.vec3f });
|
209
|
+
*
|
210
|
+
* @param props Record with `string` keys and `TgpuData` values,
|
211
|
+
* each entry describing one struct member.
|
212
|
+
*/
|
213
|
+
declare const struct: <TProps extends Record<string, AnyWgslData>>(props: TProps) => TgpuStruct<Prettify<ExoticRecord<TProps>>>;
|
214
|
+
|
215
|
+
/**
|
216
|
+
* Array schema constructed via `d.arrayOf` function.
|
217
|
+
*
|
218
|
+
* Responsible for handling reading and writing array values
|
219
|
+
* between binary and JS representation. Takes into account
|
220
|
+
* the `byteAlignment` requirement of its elementType.
|
221
|
+
*/
|
222
|
+
interface TgpuArray<TElement extends AnyWgslData> extends WgslArray<TElement> {
|
223
|
+
readonly '~exotic': WgslArray<Exotic<TElement>>;
|
224
|
+
}
|
225
|
+
/**
|
226
|
+
* Creates an array schema that can be used to construct gpu buffers.
|
227
|
+
* Describes arrays with fixed-size length, storing elements of the same type.
|
228
|
+
*
|
229
|
+
* @example
|
230
|
+
* const LENGTH = 3;
|
231
|
+
* const array = d.arrayOf(d.u32, LENGTH);
|
232
|
+
*
|
233
|
+
* @param elementType The type of elements in the array.
|
234
|
+
* @param elementCount The number of elements in the array.
|
235
|
+
*/
|
236
|
+
declare const arrayOf: <TElement extends AnyWgslData>(elementType: TElement, elementCount: number) => TgpuArray<Exotic<TElement>>;
|
237
|
+
|
238
|
+
declare function ptrFn<T extends AnyData>(inner: T): PtrFn<Exotic<T>>;
|
239
|
+
|
240
|
+
/**
|
241
|
+
* Creates an array schema that can be used to construct vertex buffers.
|
242
|
+
* Describes arrays with fixed-size length, storing elements of the same type.
|
243
|
+
*
|
244
|
+
* Elements in the schema are not aligned in respect to their `byteAlignment`,
|
245
|
+
* unless they are explicitly decorated with the custom align attribute
|
246
|
+
* via `d.align` function.
|
247
|
+
*
|
248
|
+
* @example
|
249
|
+
* const disarray = d.disarrayOf(d.vec3f, 3); // packed array of vec3f
|
250
|
+
*
|
251
|
+
* @example
|
252
|
+
* const disarray = d.disarrayOf(d.align(16, d.vec3f), 3);
|
253
|
+
*
|
254
|
+
* @param elementType The type of elements in the array.
|
255
|
+
* @param count The number of elements in the array.
|
256
|
+
*/
|
257
|
+
declare const disarrayOf: <TElement extends AnyData>(elementType: TElement, count: number) => Disarray<Exotic<TElement>>;
|
258
|
+
|
259
|
+
/**
|
260
|
+
* Creates a loose struct schema that can be used to construct vertex buffers.
|
261
|
+
* Describes structs with members of both loose and non-loose types.
|
262
|
+
*
|
263
|
+
* The order of members matches the passed in properties object.
|
264
|
+
* Members are not aligned in respect to their `byteAlignment`,
|
265
|
+
* unless they are explicitly decorated with the custom align attribute
|
266
|
+
* via `d.align` function.
|
267
|
+
*
|
268
|
+
* @example
|
269
|
+
* const CircleStruct = d.unstruct({ radius: d.f32, pos: d.vec3f }); // packed struct with no padding
|
270
|
+
*
|
271
|
+
* @example
|
272
|
+
* const CircleStruct = d.unstruct({ radius: d.f32, pos: d.align(16, d.vec3f) });
|
273
|
+
*
|
274
|
+
* @param properties Record with `string` keys and `TgpuData` or `TgpuLooseData` values,
|
275
|
+
* each entry describing one struct member.
|
276
|
+
*/
|
277
|
+
declare const unstruct: <TProps extends Record<string, BaseWgslData>>(properties: TProps) => Unstruct<ExoticRecord<TProps>>;
|
278
|
+
|
279
|
+
/**
|
280
|
+
* Type of the `d.mat2x2f` object/function: matrix data type schema/constructor
|
281
|
+
*/
|
282
|
+
type NativeMat2x2f = Mat2x2f & {
|
283
|
+
'~exotic': Mat2x2f;
|
284
|
+
} & ((...elements: number[]) => m2x2f) & ((...columns: v2f[]) => m2x2f) & (() => m2x2f);
|
285
|
+
/**
|
286
|
+
*
|
287
|
+
* Schema representing mat2x2f - a matrix with 2 rows and 2 columns, with elements of type f32.
|
288
|
+
* Also a constructor function for this matrix type.
|
289
|
+
*
|
290
|
+
* @example
|
291
|
+
* const zero2x2 = mat2x2f(); // filled with zeros
|
292
|
+
*
|
293
|
+
* @example
|
294
|
+
* const mat = mat2x2f(0, 1, 2, 3);
|
295
|
+
* mat[0] // vec2f(0, 1)
|
296
|
+
* mat[1] // vec2f(2, 3)
|
297
|
+
*
|
298
|
+
* @example
|
299
|
+
* const mat = mat2x2f(
|
300
|
+
* vec2f(0, 1), // column 0
|
301
|
+
* vec2f(1, 2), // column 1
|
302
|
+
* );
|
303
|
+
*
|
304
|
+
* @example
|
305
|
+
* const buffer = root.createBuffer(d.mat2x2f, d.mat2x2f(0, 1, 2, 3)); // buffer holding a d.mat2x2f value, with an initial value of ((0, 1), (2, 3))
|
306
|
+
*/
|
307
|
+
declare const mat2x2f: NativeMat2x2f;
|
308
|
+
/**
|
309
|
+
* Type of the `d.mat3x3f` object/function: matrix data type schema/constructor
|
310
|
+
*/
|
311
|
+
type NativeMat3x3f = Mat3x3f & {
|
312
|
+
'~exotic': Mat3x3f;
|
313
|
+
} & ((...elements: number[]) => m3x3f) & ((...columns: v3f[]) => m3x3f) & (() => m3x3f);
|
314
|
+
/**
|
315
|
+
*
|
316
|
+
* Schema representing mat3x3f - a matrix with 3 rows and 3 columns, with elements of type f32.
|
317
|
+
* Also a constructor function for this matrix type.
|
318
|
+
*
|
319
|
+
* @example
|
320
|
+
* const zero3x3 = mat3x3f(); // filled with zeros
|
321
|
+
*
|
322
|
+
* @example
|
323
|
+
* const mat = mat3x3f(0, 1, 2, 3, 4, 5, 6, 7, 8);
|
324
|
+
* mat[0] // vec3f(0, 1, 2)
|
325
|
+
* mat[1] // vec3f(3, 4, 5)
|
326
|
+
* mat[2] // vec3f(6, 7, 8)
|
327
|
+
*
|
328
|
+
* @example
|
329
|
+
* const mat = mat3x3f(
|
330
|
+
* vec3f(0, 1, 2), // column 0
|
331
|
+
* vec3f(2, 3, 4), // column 1
|
332
|
+
* vec3f(5, 6, 7), // column 2
|
333
|
+
* );
|
334
|
+
*
|
335
|
+
* @example
|
336
|
+
* const buffer = root.createBuffer(d.mat3x3f, d.mat3x3f()); // buffer holding a d.mat3x3f value, with an initial value of mat3x3f filled with zeros
|
337
|
+
*/
|
338
|
+
declare const mat3x3f: NativeMat3x3f;
|
339
|
+
/**
|
340
|
+
* Type of the `d.mat4x4f` object/function: matrix data type schema/constructor
|
341
|
+
*/
|
342
|
+
type NativeMat4x4f = Mat4x4f & {
|
343
|
+
'~exotic': Mat4x4f;
|
344
|
+
} & ((...elements: number[]) => m4x4f) & ((...columns: v4f[]) => m4x4f) & (() => m4x4f);
|
345
|
+
/**
|
346
|
+
*
|
347
|
+
* Schema representing mat4x4f - a matrix with 4 rows and 4 columns, with elements of type f32.
|
348
|
+
* Also a constructor function for this matrix type.
|
349
|
+
*
|
350
|
+
* @example
|
351
|
+
* const zero4x4 = mat4x4f(); // filled with zeros
|
352
|
+
*
|
353
|
+
* @example
|
354
|
+
* const mat = mat3x3f(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15);
|
355
|
+
* mat[0] // vec4f(0, 1, 2, 3)
|
356
|
+
* mat[1] // vec4f(4, 5, 6, 7)
|
357
|
+
* mat[2] // vec4f(8, 9, 10, 11)
|
358
|
+
* mat[3] // vec4f(12, 13, 14, 15)
|
359
|
+
*
|
360
|
+
* @example
|
361
|
+
* const mat = mat3x3f(
|
362
|
+
* vec4f(0, 1, 2, 3), // column 0
|
363
|
+
* vec4f(4, 5, 6, 7), // column 1
|
364
|
+
* vec4f(8, 9, 10, 11), // column 2
|
365
|
+
* vec4f(12, 13, 14, 15), // column 3
|
366
|
+
* );
|
367
|
+
*
|
368
|
+
* @example
|
369
|
+
* const buffer = root.createBuffer(d.mat4x4f, d.mat4x4f()); // buffer holding a d.mat4x4f value, with an initial value of mat4x4f filled with zeros
|
370
|
+
*/
|
371
|
+
declare const mat4x4f: NativeMat4x4f;
|
372
|
+
declare function matToArray(mat: m2x2f | m3x3f | m4x4f): number[];
|
373
|
+
|
374
|
+
/**
|
375
|
+
* Marks a concrete integer scalar type schema (u32 or i32) as a WGSL atomic.
|
376
|
+
*
|
377
|
+
* @example
|
378
|
+
* const atomicU32 = d.atomic(d.u32);
|
379
|
+
* const atomicI32 = d.atomic(d.i32);
|
380
|
+
*
|
381
|
+
* @param data Underlying type schema.
|
382
|
+
*/
|
383
|
+
declare function atomic<TSchema extends U32 | I32>(data: TSchema): Atomic<Exotic<TSchema>>;
|
384
|
+
|
385
|
+
/**
|
386
|
+
* Returns the size (in bytes) of data represented by the `schema`.
|
387
|
+
*/
|
388
|
+
declare function PUBLIC_sizeOf(schema: AnyData): number;
|
389
|
+
|
390
|
+
/**
|
391
|
+
* Returns the alignment (in bytes) of data represented by the `schema`.
|
392
|
+
*/
|
393
|
+
declare function PUBLIC_alignmentOf(schema: AnyData): number;
|
394
|
+
|
395
|
+
/**
|
396
|
+
* @module typegpu/data
|
397
|
+
*/
|
398
|
+
|
399
|
+
/**
|
400
|
+
* Extracts the inferred representation of a resource.
|
401
|
+
* @example
|
402
|
+
* type A = Infer<F32> // => number
|
403
|
+
* type B = Infer<TgpuArray<F32>> // => number[]
|
404
|
+
*/
|
405
|
+
type Infer<T> = Infer$1<Exotic<T>>;
|
406
|
+
|
407
|
+
export { type AnyAttribute as A, type BuiltinVertexIndex as B, type BuiltinPosition as C, type Default as D, type Exotic as E, type BuiltinClipDistances as F, type BuiltinFrontFacing as G, type HasCustomLocation as H, type IsBuiltin as I, type BuiltinFragDepth as J, type BuiltinSampleIndex as K, type BuiltinSampleMask as L, type Mutable as M, type BuiltinLocalInvocationId as N, type OmitBuiltins as O, type Prettify as P, type BuiltinLocalInvocationIndex as Q, type BuiltinGlobalInvocationId as R, type BuiltinWorkgroupId as S, type TgpuNamable as T, type UnionToIntersection as U, type BuiltinNumWorkgroups as V, type AnyBuiltin as W, type AnyComputeBuiltin as a, type Decorate as b, type TgpuStruct as c, type OmitProps as d, type Infer as e, type ExoticArray as f, type TgpuArray as g, arrayOf as h, disarrayOf as i, mat3x3f as j, mat4x4f as k, matToArray as l, mat2x2f as m, atomic as n, align as o, ptrFn as p, size as q, location as r, struct as s, interpolate as t, unstruct as u, isBuiltin as v, PUBLIC_sizeOf as w, PUBLIC_alignmentOf as x, builtin as y, type BuiltinInstanceIndex as z };
|