typegpu 0.2.0 → 0.3.0-alpha.2
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/README.md +2 -2
- package/chunk-CKSBATTP.cjs +2 -0
- package/chunk-CKSBATTP.cjs.map +1 -0
- package/chunk-IQYHODCR.js +2 -0
- package/chunk-IQYHODCR.js.map +1 -0
- package/data/index.cjs +1 -1
- package/data/index.d.cts +122 -379
- package/data/index.d.ts +122 -379
- package/data/index.js +1 -1
- package/index.cjs +14 -47
- package/index.cjs.map +1 -1
- package/index.d.cts +505 -168
- package/index.d.ts +505 -168
- package/index.js +14 -47
- package/index.js.map +1 -1
- package/package.json +3 -14
- package/utilityTypes-0b50gROn.d.cts +1122 -0
- package/utilityTypes-0b50gROn.d.ts +1122 -0
- package/chunk-5EPBCOO4.js +0 -8
- package/chunk-5EPBCOO4.js.map +0 -1
- package/chunk-SBJR5ZQJ.cjs +0 -8
- package/chunk-SBJR5ZQJ.cjs.map +0 -1
- package/types-CGmVkuAt.d.cts +0 -880
- package/types-CGmVkuAt.d.ts +0 -880
package/data/index.d.ts
CHANGED
@@ -1,115 +1,75 @@
|
|
1
|
-
import {
|
2
|
-
export {
|
3
|
-
import { A as AnyTgpuData, x as AnyTgpuLooseData, r as TgpuData, y as TgpuLooseData, R as ResolutionCtx, a as TgpuNamable, z as vec2f, o as vec3f, C as vec4f, N as NumberArrayView, D as Vec2u, V as Vec4u, G as Vec2i, i as Vec4i, H as Vec2f, j as Vec4f, F as F32, J as Vec3f, h as U32, K as Vec3u, I as I32, L as Vec3i, M as TgpuPointer } from '../types-CGmVkuAt.js';
|
4
|
-
export { P as Bool, Z as VecKind, Q as bool, Y as f32, X as i32, W as u32, _ as vec2i, $ as vec2u, p as vec3i, q as vec3u, a0 as vec4i, a1 as vec4u, v as vecBase } from '../types-CGmVkuAt.js';
|
1
|
+
import { f as Align, S as Size, L as Location, g as Builtin, A as AnyData, E as Exotic, h as Decorated, e as AnyWgslData, i as LooseDecorated, j as AnyLooseData, B as BaseWgslData, W as WgslTypeLiteral, k as LooseTypeLiteral, l as WgslStruct, T as TgpuNamable, m as ExoticRecord, P as Prettify, n as WgslArray, o as LooseArray, p as LooseStruct, q as m2x2f, r as m3x3f, s as m4x4f, t as Mat2x2f, v as v2f, u as Mat3x3f, w as v3f, x as Mat4x4f, y as v4f, U as U32, I as I32, z as Atomic, d as Infer$1 } from '../utilityTypes-0b50gROn.js';
|
2
|
+
export { a1 as Bool, a2 as F16, F as F32, at as FormatToWGSLType, a$ as PackedData, au as TgpuVertexFormatData, a3 as Vec2f, a4 as Vec2i, a5 as Vec2u, a6 as Vec3f, a7 as Vec3i, a8 as Vec3u, V as Vec4f, b as Vec4i, a as Vec4u, C as bool, H as f16, G as f32, aM as float16x2, aN as float16x4, aO as float32, aP as float32x2, aQ as float32x3, aR as float32x4, J as i32, Z as isAlignAttrib, X as isAtomic, _ as isBuiltinAttrib, ar as isData, Y as isDecorated, $ as isLocationAttrib, ao as isLooseArray, as as isLooseData, aq as isLooseDecorated, ap as isLooseStruct, a0 as isSizeAttrib, Q as isWgslArray, N as isWgslData, R as isWgslStruct, av as packedFormats, aG as sint16x2, aH as sint16x4, aW as sint32, aX as sint32x2, aY as sint32x3, aZ as sint32x4, ay as sint8x2, az as sint8x4, aK as snorm16x2, aL as snorm16x4, aC as snorm8x2, aD as snorm8x4, K as u32, aE as uint16x2, aF as uint16x4, aS as uint32, aT as uint32x2, aU as uint32x3, aV as uint32x4, aw as uint8x2, ax as uint8x4, a_ as unorm10_10_10_2, aI as unorm16x2, aJ as unorm16x4, aA as unorm8x2, aB as unorm8x4, a9 as v2i, aa as v2u, ab as v3i, ac as v3u, ad as v4i, ae as v4u, af as vec2f, ag as vec2i, ah as vec2u, ai as vec3f, aj as vec3i, ak as vec3u, al as vec4f, am as vec4i, an as vec4u } from '../utilityTypes-0b50gROn.js';
|
5
3
|
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
4
|
+
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"];
|
5
|
+
type BuiltinName = (typeof builtinNames)[number];
|
6
|
+
type AnyAttribute = Align<number> | Size<number> | Location<number> | Builtin<BuiltinName>;
|
7
|
+
type ExtractAttributes<T> = T extends {
|
8
|
+
readonly attribs: unknown[];
|
9
|
+
} ? T['attribs'] : [];
|
10
|
+
type Undecorate<T> = T extends {
|
11
|
+
readonly inner: infer TInner;
|
12
|
+
} ? TInner : T;
|
11
13
|
/**
|
12
|
-
*
|
14
|
+
* Decorates a data-type `TData` with an attribute `TAttrib`.
|
13
15
|
*
|
14
|
-
*
|
15
|
-
*
|
16
|
-
*
|
16
|
+
* - if `TData` is loose
|
17
|
+
* - if `TData` is already `LooseDecorated`
|
18
|
+
* - Prepend `TAttrib` to the existing attribute tuple.
|
19
|
+
* - else
|
20
|
+
* - Wrap `TData` with `LooseDecorated` and a single attribute `[TAttrib]`
|
21
|
+
* - else
|
22
|
+
* - if `TData` is already `Decorated`
|
23
|
+
* - Prepend `TAttrib` to the existing attribute tuple.
|
24
|
+
* - else
|
25
|
+
* - Wrap `TData` with `Decorated` and a single attribute `[TAttrib]`
|
17
26
|
*/
|
18
|
-
|
19
|
-
|
27
|
+
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;
|
28
|
+
type IsBuiltin<T> = ExtractAttributes<T>[number] extends [] ? false : ExtractAttributes<T>[number] extends Builtin<BuiltinName> ? true : false;
|
20
29
|
/**
|
21
|
-
*
|
22
|
-
*
|
30
|
+
* Gives the wrapped data-type a custom byte alignment. Useful in order to
|
31
|
+
* fulfill uniform alignment requirements.
|
23
32
|
*
|
24
33
|
* @example
|
25
|
-
* const
|
26
|
-
*
|
27
|
-
*
|
28
|
-
*
|
29
|
-
*
|
30
|
-
*/
|
31
|
-
declare const arrayOf: <TElement extends AnyTgpuData>(elementType: TElement, count: number) => TgpuArray<TElement>;
|
32
|
-
/**
|
33
|
-
* Array schema constructed via `d.looseArrayOf` function.
|
34
|
+
* const Data = d.struct({
|
35
|
+
* a: u32, // takes up 4 bytes
|
36
|
+
* // 12 bytes of padding, because `b` is custom aligned to multiples of 16 bytes
|
37
|
+
* b: d.align(16, u32),
|
38
|
+
* });
|
34
39
|
*
|
35
|
-
*
|
36
|
-
*
|
37
|
-
* unless they are explicitly decorated with the custom align attribute
|
38
|
-
* via `d.align` function.
|
40
|
+
* @param alignment The multiple of bytes this data should align itself to.
|
41
|
+
* @param data The data-type to align.
|
39
42
|
*/
|
40
|
-
|
41
|
-
}
|
43
|
+
declare function align<TAlign extends number, TData extends AnyData>(alignment: TAlign, data: TData): Decorate<Exotic<TData>, Align<TAlign>>;
|
42
44
|
/**
|
43
|
-
*
|
44
|
-
* Describes arrays with fixed-size length, storing elements of the same type.
|
45
|
-
*
|
46
|
-
* Elements in the schema are not aligned in respect to their `byteAlignment`,
|
47
|
-
* unless they are explicitly decorated with the custom align attribute
|
48
|
-
* via `d.align` function.
|
49
|
-
*
|
50
|
-
* @example
|
51
|
-
* const looseArray = d.looseArrayOf(d.vec3f, 3); // packed array of vec3f
|
45
|
+
* Adds padding bytes after the wrapped data-type, until the whole value takes up `size` bytes.
|
52
46
|
*
|
53
47
|
* @example
|
54
|
-
* const
|
48
|
+
* const Data = d.struct({
|
49
|
+
* a: d.size(16, u32), // takes up 16 bytes, instead of 4
|
50
|
+
* b: u32, // starts at byte 16, because `a` has a custom size
|
51
|
+
* });
|
55
52
|
*
|
56
|
-
* @param
|
57
|
-
* @param
|
53
|
+
* @param size The amount of bytes that should be reserved for this data-type.
|
54
|
+
* @param data The data-type to wrap.
|
58
55
|
*/
|
59
|
-
declare
|
56
|
+
declare function size<TSize extends number, TData extends AnyData>(size: TSize, data: TData): Decorate<Exotic<TData>, Size<TSize>>;
|
60
57
|
/**
|
61
|
-
*
|
62
|
-
* as opposed to, e.g., a looseArray schema.
|
63
|
-
*
|
64
|
-
* Array schemas can be used to describe uniform and storage buffers,
|
65
|
-
* whereas looseArray schemas cannot.
|
58
|
+
* Assigns an explicit numeric location to a struct member or a parameter that has this type.
|
66
59
|
*
|
67
60
|
* @example
|
68
|
-
*
|
69
|
-
*
|
70
|
-
*
|
71
|
-
|
72
|
-
|
73
|
-
/**
|
74
|
-
* Checks whether the passed in value is a looseArray schema,
|
75
|
-
* as opposed to, e.g., a regular array schema.
|
76
|
-
*
|
77
|
-
* Array schemas can be used to describe uniform and storage buffers,
|
78
|
-
* whereas looseArray schemas cannot. Loose arrays are useful for
|
79
|
-
* defining vertex buffers instead.
|
61
|
+
* const Data = d.ioStruct({
|
62
|
+
* a: d.u32, // has implicit location 0
|
63
|
+
* b: d.location(5, d.u32),
|
64
|
+
* c: d.u32, // has implicit location 6
|
65
|
+
* });
|
80
66
|
*
|
81
|
-
* @
|
82
|
-
*
|
83
|
-
* isLooseArraySchema(d.looseArrayOf(d.u32, 4)) // true
|
84
|
-
* isLooseArraySchema(d.vec3f) // false
|
67
|
+
* @param location The explicit numeric location.
|
68
|
+
* @param data The data-type to wrap.
|
85
69
|
*/
|
86
|
-
declare function
|
87
|
-
|
88
|
-
declare class SimpleTgpuData<TSchema extends AnySchema> extends Schema<Unwrap<TSchema>> implements TgpuData<Unwrap<TSchema>> {
|
89
|
-
readonly size: number;
|
90
|
-
readonly byteAlignment: number;
|
91
|
-
readonly expressionCode: string;
|
92
|
-
private readonly _innerSchema;
|
93
|
-
readonly isLoose: false;
|
94
|
-
readonly label?: string | undefined;
|
95
|
-
/**
|
96
|
-
* byteAlignment has to be a power of 2
|
97
|
-
*/
|
98
|
-
constructor({ schema, byteAlignment, code, }: {
|
99
|
-
schema: TSchema;
|
100
|
-
byteAlignment: number;
|
101
|
-
code: string;
|
102
|
-
});
|
103
|
-
resolveReferences(): void;
|
104
|
-
write(output: ISerialOutput, value: ParseUnwrapped<TSchema>): void;
|
105
|
-
read(input: ISerialInput): ParseUnwrapped<TSchema>;
|
106
|
-
measure(value: ParseUnwrapped<TSchema> | MaxValue, measurer?: IMeasurer): IMeasurer;
|
107
|
-
resolve(ctx: ResolutionCtx): string;
|
108
|
-
}
|
70
|
+
declare function location<TLocation extends number, TData extends AnyData>(location: TLocation, data: TData): Decorate<Exotic<TData>, Location<TLocation>>;
|
71
|
+
declare function isBuiltin<T extends Decorated<AnyWgslData, AnyAttribute[]> | LooseDecorated<AnyLooseData, AnyAttribute[]>>(value: T | unknown): value is T;
|
109
72
|
|
110
|
-
interface TgpuBaseStruct<TProps extends Record<string, unknown>> extends ISchema<UnwrapRecord<TProps>> {
|
111
|
-
readonly properties: TProps;
|
112
|
-
}
|
113
73
|
/**
|
114
74
|
* Struct schema constructed via `d.struct` function.
|
115
75
|
*
|
@@ -117,7 +77,8 @@ interface TgpuBaseStruct<TProps extends Record<string, unknown>> extends ISchema
|
|
117
77
|
* between binary and JS representation. Takes into account
|
118
78
|
* the `byteAlignment` requirement of its members.
|
119
79
|
*/
|
120
|
-
interface TgpuStruct<TProps extends Record<string,
|
80
|
+
interface TgpuStruct<TProps extends Record<string, BaseWgslData>> extends WgslStruct<TProps>, TgpuNamable {
|
81
|
+
readonly '~exotic': WgslStruct<ExoticRecord<TProps>>;
|
121
82
|
}
|
122
83
|
/**
|
123
84
|
* Creates a struct schema that can be used to construct GPU buffers.
|
@@ -127,20 +88,53 @@ interface TgpuStruct<TProps extends Record<string, AnyTgpuData>> extends TgpuBas
|
|
127
88
|
* @example
|
128
89
|
* const CircleStruct = d.struct({ radius: d.f32, pos: d.vec3f });
|
129
90
|
*
|
130
|
-
* @param
|
91
|
+
* @param props Record with `string` keys and `TgpuData` values,
|
131
92
|
* each entry describing one struct member.
|
132
93
|
*/
|
133
|
-
declare const struct: <TProps extends Record<string,
|
94
|
+
declare const struct: <TProps extends Record<string, AnyWgslData>>(props: TProps) => TgpuStruct<Prettify<ExoticRecord<TProps>>>;
|
95
|
+
|
96
|
+
/**
|
97
|
+
* Array schema constructed via `d.arrayOf` function.
|
98
|
+
*
|
99
|
+
* Responsible for handling reading and writing array values
|
100
|
+
* between binary and JS representation. Takes into account
|
101
|
+
* the `byteAlignment` requirement of its elementType.
|
102
|
+
*/
|
103
|
+
interface TgpuArray<TElement extends AnyWgslData> extends WgslArray<TElement> {
|
104
|
+
readonly '~exotic': WgslArray<Exotic<TElement>>;
|
105
|
+
}
|
134
106
|
/**
|
135
|
-
*
|
107
|
+
* Creates an array schema that can be used to construct gpu buffers.
|
108
|
+
* Describes arrays with fixed-size length, storing elements of the same type.
|
136
109
|
*
|
137
|
-
*
|
138
|
-
*
|
110
|
+
* @example
|
111
|
+
* const LENGTH = 3;
|
112
|
+
* const array = d.arrayOf(d.u32, LENGTH);
|
113
|
+
*
|
114
|
+
* @param elementType The type of elements in the array.
|
115
|
+
* @param elementCount The number of elements in the array.
|
116
|
+
*/
|
117
|
+
declare const arrayOf: <TElement extends AnyWgslData>(elementType: TElement, elementCount: number) => TgpuArray<Exotic<TElement>>;
|
118
|
+
|
119
|
+
/**
|
120
|
+
* Creates an array schema that can be used to construct vertex buffers.
|
121
|
+
* Describes arrays with fixed-size length, storing elements of the same type.
|
122
|
+
*
|
123
|
+
* Elements in the schema are not aligned in respect to their `byteAlignment`,
|
139
124
|
* unless they are explicitly decorated with the custom align attribute
|
140
125
|
* via `d.align` function.
|
126
|
+
*
|
127
|
+
* @example
|
128
|
+
* const looseArray = d.looseArrayOf(d.vec3f, 3); // packed array of vec3f
|
129
|
+
*
|
130
|
+
* @example
|
131
|
+
* const looseArray = d.looseArrayOf(d.align(16, d.vec3f), 3);
|
132
|
+
*
|
133
|
+
* @param elementType The type of elements in the array.
|
134
|
+
* @param count The number of elements in the array.
|
141
135
|
*/
|
142
|
-
|
143
|
-
|
136
|
+
declare const looseArrayOf: <TElement extends AnyData>(elementType: TElement, count: number) => LooseArray<Exotic<TElement>>;
|
137
|
+
|
144
138
|
/**
|
145
139
|
* Creates a loose struct schema that can be used to construct vertex buffers.
|
146
140
|
* Describes structs with members of both loose and non-loose types.
|
@@ -159,57 +153,14 @@ interface TgpuLooseStruct<TProps extends Record<string, AnyTgpuData | AnyTgpuLoo
|
|
159
153
|
* @param properties Record with `string` keys and `TgpuData` or `TgpuLooseData` values,
|
160
154
|
* each entry describing one struct member.
|
161
155
|
*/
|
162
|
-
declare const looseStruct: <TProps extends Record<string,
|
163
|
-
/**
|
164
|
-
* Checks whether passed in value is a struct schema,
|
165
|
-
* as opposed to, e.g., a looseStruct schema.
|
166
|
-
*
|
167
|
-
* Struct schemas can be used to describe uniform and storage buffers,
|
168
|
-
* whereas looseStruct schemas cannot.
|
169
|
-
*
|
170
|
-
* @example
|
171
|
-
* isStructSchema(d.struct({ a: d.u32 })) // true
|
172
|
-
* isStructSchema(d.looseStruct({ a: d.u32 })) // false
|
173
|
-
* isStructSchema(d.vec3f) // false
|
174
|
-
*/
|
175
|
-
declare function isStructSchema<T extends TgpuStruct<Record<string, AnyTgpuData>>>(schema: T | unknown): schema is T;
|
176
|
-
/**
|
177
|
-
* Checks whether passed in value is a looseStruct schema,
|
178
|
-
* as opposed to, e.g., a struct schema.
|
179
|
-
*
|
180
|
-
* Struct schemas can be used to describe uniform and storage buffers,
|
181
|
-
* whereas looseStruct schemas cannot. Loose structs are useful for
|
182
|
-
* defining vertex buffers instead.
|
183
|
-
*
|
184
|
-
* @example
|
185
|
-
* isLooseStructSchema(d.struct({ a: d.u32 })) // false
|
186
|
-
* isLooseStructSchema(d.looseStruct({ a: d.u32 })) // true
|
187
|
-
* isLooseStructSchema(d.vec3f) // false
|
188
|
-
*/
|
189
|
-
declare function isLooseStructSchema<T extends TgpuLooseStruct<Record<string, AnyTgpuData | AnyTgpuLooseData>>>(schema: T | unknown): schema is T;
|
156
|
+
declare const looseStruct: <TProps extends Record<string, BaseWgslData>>(properties: TProps) => LooseStruct<ExoticRecord<TProps>>;
|
190
157
|
|
191
|
-
interface matBase<TColumn> extends NumberArrayView {
|
192
|
-
readonly columns: readonly TColumn[];
|
193
|
-
elements(): Iterable<number>;
|
194
|
-
}
|
195
|
-
/**
|
196
|
-
* Interface representing its WGSL matrix type counterpart: mat2x2
|
197
|
-
* A matrix with 2 rows and 2 columns, with elements of type `TColumn`
|
198
|
-
*/
|
199
|
-
interface mat2x2<TColumn> extends matBase<TColumn> {
|
200
|
-
readonly length: 4;
|
201
|
-
[n: number]: number;
|
202
|
-
}
|
203
158
|
/**
|
204
159
|
* Type of the `d.mat2x2f` object/function: matrix data type schema/constructor
|
205
160
|
*/
|
206
|
-
type
|
207
|
-
|
208
|
-
|
209
|
-
* A matrix with 2 rows and 2 columns, with elements of type d.f32
|
210
|
-
*/
|
211
|
-
interface mat2x2f extends mat2x2<vec2f> {
|
212
|
-
}
|
161
|
+
type NativeMat2x2f = Mat2x2f & {
|
162
|
+
'~exotic': Mat2x2f;
|
163
|
+
} & ((...elements: number[]) => m2x2f) & ((...columns: v2f[]) => m2x2f) & (() => m2x2f);
|
213
164
|
/**
|
214
165
|
*
|
215
166
|
* Schema representing mat2x2f - a matrix with 2 rows and 2 columns, with elements of type f32.
|
@@ -232,25 +183,13 @@ interface mat2x2f extends mat2x2<vec2f> {
|
|
232
183
|
* @example
|
233
184
|
* 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))
|
234
185
|
*/
|
235
|
-
declare const mat2x2f:
|
236
|
-
/**
|
237
|
-
* Interface representing its WGSL matrix type counterpart: mat3x3
|
238
|
-
* A matrix with 3 rows and 3 columns, with elements of type `TColumn`
|
239
|
-
*/
|
240
|
-
interface mat3x3<TColumn> extends matBase<TColumn> {
|
241
|
-
readonly length: 12;
|
242
|
-
[n: number]: number;
|
243
|
-
}
|
186
|
+
declare const mat2x2f: NativeMat2x2f;
|
244
187
|
/**
|
245
188
|
* Type of the `d.mat3x3f` object/function: matrix data type schema/constructor
|
246
189
|
*/
|
247
|
-
type
|
248
|
-
|
249
|
-
|
250
|
-
* A matrix with 3 rows and 3 columns, with elements of type d.f32
|
251
|
-
*/
|
252
|
-
interface mat3x3f extends mat3x3<vec3f> {
|
253
|
-
}
|
190
|
+
type NativeMat3x3f = Mat3x3f & {
|
191
|
+
'~exotic': Mat3x3f;
|
192
|
+
} & ((...elements: number[]) => m3x3f) & ((...columns: v3f[]) => m3x3f) & (() => m3x3f);
|
254
193
|
/**
|
255
194
|
*
|
256
195
|
* Schema representing mat3x3f - a matrix with 3 rows and 3 columns, with elements of type f32.
|
@@ -275,25 +214,13 @@ interface mat3x3f extends mat3x3<vec3f> {
|
|
275
214
|
* @example
|
276
215
|
* const buffer = root.createBuffer(d.mat3x3f, d.mat3x3f()); // buffer holding a d.mat3x3f value, with an initial value of mat3x3f filled with zeros
|
277
216
|
*/
|
278
|
-
declare const mat3x3f:
|
279
|
-
/**
|
280
|
-
* Interface representing its WGSL matrix type counterpart: mat4x4
|
281
|
-
* A matrix with 4 rows and 4 columns, with elements of type `TColumn`
|
282
|
-
*/
|
283
|
-
interface mat4x4<TColumn> extends matBase<TColumn> {
|
284
|
-
readonly length: 16;
|
285
|
-
[n: number]: number;
|
286
|
-
}
|
217
|
+
declare const mat3x3f: NativeMat3x3f;
|
287
218
|
/**
|
288
219
|
* Type of the `d.mat4x4f` object/function: matrix data type schema/constructor
|
289
220
|
*/
|
290
|
-
type
|
291
|
-
|
292
|
-
|
293
|
-
* A matrix with 4 rows and 4 columns, with elements of type d.f32
|
294
|
-
*/
|
295
|
-
interface mat4x4f extends mat4x4<vec4f> {
|
296
|
-
}
|
221
|
+
type NativeMat4x4f = Mat4x4f & {
|
222
|
+
'~exotic': Mat4x4f;
|
223
|
+
} & ((...elements: number[]) => m4x4f) & ((...columns: v4f[]) => m4x4f) & (() => m4x4f);
|
297
224
|
/**
|
298
225
|
*
|
299
226
|
* Schema representing mat4x4f - a matrix with 4 rows and 4 columns, with elements of type f32.
|
@@ -320,112 +247,8 @@ interface mat4x4f extends mat4x4<vec4f> {
|
|
320
247
|
* @example
|
321
248
|
* const buffer = root.createBuffer(d.mat4x4f, d.mat4x4f()); // buffer holding a d.mat4x4f value, with an initial value of mat4x4f filled with zeros
|
322
249
|
*/
|
323
|
-
declare const mat4x4f:
|
324
|
-
|
325
|
-
declare const vertexFormats: readonly ["uint8x2", "uint8x4", "sint8x2", "sint8x4", "unorm8x2", "unorm8x4", "snorm8x2", "snorm8x4", "uint16x2", "uint16x4", "sint16x2", "sint16x4", "unorm16x2", "unorm16x4", "snorm16x2", "snorm16x4", "float16x2", "float16x4", "float32", "float32x2", "float32x3", "float32x4", "uint32", "uint32x2", "uint32x3", "uint32x4", "sint32", "sint32x2", "sint32x3", "sint32x4", "unorm10_10_10_2"];
|
326
|
-
type VertexFormat = (typeof vertexFormats)[number];
|
327
|
-
|
328
|
-
type FormatToWGSLType<T extends VertexFormat> = (typeof formatToWGSLType)[T];
|
329
|
-
interface TgpuVertexFormatData<T extends VertexFormat> extends TgpuLooseData<FormatToWGSLType<T>> {
|
330
|
-
readonly kind: T;
|
331
|
-
}
|
332
|
-
declare const formatToWGSLType: {
|
333
|
-
readonly uint8x2: Vec2u;
|
334
|
-
readonly uint8x4: Vec4u;
|
335
|
-
readonly sint8x2: Vec2i;
|
336
|
-
readonly sint8x4: Vec4i;
|
337
|
-
readonly unorm8x2: Vec2f;
|
338
|
-
readonly unorm8x4: Vec4f;
|
339
|
-
readonly snorm8x2: Vec2f;
|
340
|
-
readonly snorm8x4: Vec4f;
|
341
|
-
readonly uint16x2: Vec2u;
|
342
|
-
readonly uint16x4: Vec4u;
|
343
|
-
readonly sint16x2: Vec2i;
|
344
|
-
readonly sint16x4: Vec4i;
|
345
|
-
readonly unorm16x2: Vec2f;
|
346
|
-
readonly unorm16x4: Vec4f;
|
347
|
-
readonly snorm16x2: Vec2f;
|
348
|
-
readonly snorm16x4: Vec4f;
|
349
|
-
readonly float16x2: Vec2f;
|
350
|
-
readonly float16x4: Vec4f;
|
351
|
-
readonly float32: F32;
|
352
|
-
readonly float32x2: Vec2f;
|
353
|
-
readonly float32x3: Vec3f;
|
354
|
-
readonly float32x4: Vec4f;
|
355
|
-
readonly uint32: U32;
|
356
|
-
readonly uint32x2: Vec2u;
|
357
|
-
readonly uint32x3: Vec3u;
|
358
|
-
readonly uint32x4: Vec4u;
|
359
|
-
readonly sint32: I32;
|
360
|
-
readonly sint32x2: Vec2i;
|
361
|
-
readonly sint32x3: Vec3i;
|
362
|
-
readonly sint32x4: Vec4i;
|
363
|
-
readonly unorm10_10_10_2: Vec4f;
|
364
|
-
};
|
365
|
-
type uint8x2 = TgpuVertexFormatData<'uint8x2'>;
|
366
|
-
declare const uint8x2: uint8x2;
|
367
|
-
type uint8x4 = TgpuVertexFormatData<'uint8x4'>;
|
368
|
-
declare const uint8x4: uint8x4;
|
369
|
-
type sint8x2 = TgpuVertexFormatData<'sint8x2'>;
|
370
|
-
declare const sint8x2: sint8x2;
|
371
|
-
type sint8x4 = TgpuVertexFormatData<'sint8x4'>;
|
372
|
-
declare const sint8x4: sint8x4;
|
373
|
-
type unorm8x2 = TgpuVertexFormatData<'unorm8x2'>;
|
374
|
-
declare const unorm8x2: unorm8x2;
|
375
|
-
type unorm8x4 = TgpuVertexFormatData<'unorm8x4'>;
|
376
|
-
declare const unorm8x4: unorm8x4;
|
377
|
-
type snorm8x2 = TgpuVertexFormatData<'snorm8x2'>;
|
378
|
-
declare const snorm8x2: snorm8x2;
|
379
|
-
type snorm8x4 = TgpuVertexFormatData<'snorm8x4'>;
|
380
|
-
declare const snorm8x4: snorm8x4;
|
381
|
-
type uint16x2 = TgpuVertexFormatData<'uint16x2'>;
|
382
|
-
declare const uint16x2: uint16x2;
|
383
|
-
type uint16x4 = TgpuVertexFormatData<'uint16x4'>;
|
384
|
-
declare const uint16x4: uint16x4;
|
385
|
-
type sint16x2 = TgpuVertexFormatData<'sint16x2'>;
|
386
|
-
declare const sint16x2: sint16x2;
|
387
|
-
type sint16x4 = TgpuVertexFormatData<'sint16x4'>;
|
388
|
-
declare const sint16x4: sint16x4;
|
389
|
-
type unorm16x2 = TgpuVertexFormatData<'unorm16x2'>;
|
390
|
-
declare const unorm16x2: unorm16x2;
|
391
|
-
type unorm16x4 = TgpuVertexFormatData<'unorm16x4'>;
|
392
|
-
declare const unorm16x4: unorm16x4;
|
393
|
-
type snorm16x2 = TgpuVertexFormatData<'snorm16x2'>;
|
394
|
-
declare const snorm16x2: snorm16x2;
|
395
|
-
type snorm16x4 = TgpuVertexFormatData<'snorm16x4'>;
|
396
|
-
declare const snorm16x4: snorm16x4;
|
397
|
-
type float16x2 = TgpuVertexFormatData<'float16x2'>;
|
398
|
-
declare const float16x2: float16x2;
|
399
|
-
type float16x4 = TgpuVertexFormatData<'float16x4'>;
|
400
|
-
declare const float16x4: float16x4;
|
401
|
-
type float32 = TgpuVertexFormatData<'float32'>;
|
402
|
-
declare const float32: float32;
|
403
|
-
type float32x2 = TgpuVertexFormatData<'float32x2'>;
|
404
|
-
declare const float32x2: float32x2;
|
405
|
-
type float32x3 = TgpuVertexFormatData<'float32x3'>;
|
406
|
-
declare const float32x3: float32x3;
|
407
|
-
type float32x4 = TgpuVertexFormatData<'float32x4'>;
|
408
|
-
declare const float32x4: float32x4;
|
409
|
-
type uint32 = TgpuVertexFormatData<'uint32'>;
|
410
|
-
declare const uint32: uint32;
|
411
|
-
type uint32x2 = TgpuVertexFormatData<'uint32x2'>;
|
412
|
-
declare const uint32x2: uint32x2;
|
413
|
-
type uint32x3 = TgpuVertexFormatData<'uint32x3'>;
|
414
|
-
declare const uint32x3: uint32x3;
|
415
|
-
type uint32x4 = TgpuVertexFormatData<'uint32x4'>;
|
416
|
-
declare const uint32x4: uint32x4;
|
417
|
-
type sint32 = TgpuVertexFormatData<'sint32'>;
|
418
|
-
declare const sint32: sint32;
|
419
|
-
type sint32x2 = TgpuVertexFormatData<'sint32x2'>;
|
420
|
-
declare const sint32x2: sint32x2;
|
421
|
-
type sint32x3 = TgpuVertexFormatData<'sint32x3'>;
|
422
|
-
declare const sint32x3: sint32x3;
|
423
|
-
type sint32x4 = TgpuVertexFormatData<'sint32x4'>;
|
424
|
-
declare const sint32x4: sint32x4;
|
425
|
-
type unorm10_10_10_2 = TgpuVertexFormatData<'unorm10_10_10_2'>;
|
426
|
-
declare const unorm10_10_10_2: unorm10_10_10_2;
|
427
|
-
|
428
|
-
declare function ptr<TDataType extends AnyTgpuData>(pointsTo: TDataType): TgpuPointer<'function', TDataType>;
|
250
|
+
declare const mat4x4f: NativeMat4x4f;
|
251
|
+
declare function matToArray(mat: m2x2f | m3x3f | m4x4f): number[];
|
429
252
|
|
430
253
|
/**
|
431
254
|
* Marks a concrete integer scalar type schema (u32 or i32) as a WGSL atomic.
|
@@ -436,108 +259,28 @@ declare function ptr<TDataType extends AnyTgpuData>(pointsTo: TDataType): TgpuPo
|
|
436
259
|
*
|
437
260
|
* @param data Underlying type schema.
|
438
261
|
*/
|
439
|
-
declare function atomic<TSchema extends U32 | I32>(data: TSchema): Atomic<TSchema
|
440
|
-
/**
|
441
|
-
* Atomic schema constructed via `d.atomic` function.
|
442
|
-
*/
|
443
|
-
interface Atomic<TSchema extends U32 | I32> extends TgpuData<Unwrap<TSchema>> {
|
444
|
-
}
|
445
|
-
/**
|
446
|
-
* Checks whether the passed in value is a d.atomic schema.
|
447
|
-
*
|
448
|
-
* @example
|
449
|
-
* isAtomicSchema(d.atomic(d.u32)) // true
|
450
|
-
* isAtomicSchema(d.u32) // false
|
451
|
-
*/
|
452
|
-
declare function isAtomicSchema<T extends Atomic<U32 | I32>>(schema: T | unknown): schema is T;
|
262
|
+
declare function atomic<TSchema extends U32 | I32>(data: TSchema): Atomic<Exotic<TSchema>>;
|
453
263
|
|
454
|
-
interface Align<T extends number> {
|
455
|
-
type: 'align';
|
456
|
-
alignment: T;
|
457
|
-
}
|
458
|
-
interface Size<T extends number> {
|
459
|
-
type: 'size';
|
460
|
-
size: T;
|
461
|
-
}
|
462
|
-
interface Location<T extends number> {
|
463
|
-
type: 'location';
|
464
|
-
location: T;
|
465
|
-
}
|
466
|
-
type AnyAttribute = Align<number> | Size<number> | Location<number>;
|
467
|
-
interface BaseDecorated<TInner extends AnyTgpuData | AnyTgpuLooseData = AnyTgpuData | AnyTgpuLooseData, TAttribs extends AnyAttribute[] = AnyAttribute[]> {
|
468
|
-
readonly inner: TInner;
|
469
|
-
readonly attributes: TAttribs;
|
470
|
-
readonly alignAttrib: number | undefined;
|
471
|
-
readonly sizeAttrib: number | undefined;
|
472
|
-
readonly locationAttrib: number | undefined;
|
473
|
-
}
|
474
|
-
interface Decorated<TInner extends AnyTgpuData, TAttribs extends AnyAttribute[]> extends BaseDecorated<TInner, TAttribs>, TgpuData<Unwrap<TInner>> {
|
475
|
-
}
|
476
|
-
interface LooseDecorated<TInner extends AnyTgpuLooseData, TAttribs extends AnyAttribute[]> extends BaseDecorated<TInner, TAttribs>, TgpuLooseData<Unwrap<TInner>> {
|
477
|
-
}
|
478
|
-
type ExtractAttributes<T> = T extends BaseDecorated<AnyTgpuData, infer Attribs> ? Attribs : [];
|
479
|
-
type UnwrapDecorated<T> = T extends BaseDecorated<infer Inner> ? Inner : T;
|
480
264
|
/**
|
481
|
-
*
|
482
|
-
*
|
483
|
-
* - if `TData` is loose
|
484
|
-
* - if `TData` is already `LooseDecorated`
|
485
|
-
* - Prepend `TAttrib` to the existing attribute tuple.
|
486
|
-
* - else
|
487
|
-
* - Wrap `TData` with `LooseDecorated` and a single attribute `[TAttrib]`
|
488
|
-
* - else
|
489
|
-
* - if `TData` is already `Decorated`
|
490
|
-
* - Prepend `TAttrib` to the existing attribute tuple.
|
491
|
-
* - else
|
492
|
-
* - Wrap `TData` with `Decorated` and a single attribute `[TAttrib]`
|
265
|
+
* Returns the size (in bytes) of data represented by the `schema`.
|
493
266
|
*/
|
494
|
-
|
495
|
-
|
496
|
-
...ExtractAttributes<TData>
|
497
|
-
]> : never;
|
267
|
+
declare function PUBLIC_sizeOf(schema: AnyData): number;
|
268
|
+
|
498
269
|
/**
|
499
|
-
*
|
500
|
-
* fulfill uniform alignment requirements.
|
501
|
-
*
|
502
|
-
* @example
|
503
|
-
* const Data = d.struct({
|
504
|
-
* a: u32, // takes up 4 bytes
|
505
|
-
* // 12 bytes of padding, because `b` is custom aligned to multiples of 16 bytes
|
506
|
-
* b: d.align(16, u32),
|
507
|
-
* });
|
508
|
-
*
|
509
|
-
* @param alignment The multiple of bytes this data should align itself to.
|
510
|
-
* @param data The data-type to align.
|
270
|
+
* Returns the alignment (in bytes) of data represented by the `schema`.
|
511
271
|
*/
|
512
|
-
declare function
|
272
|
+
declare function PUBLIC_alignmentOf(schema: AnyData): number;
|
273
|
+
|
513
274
|
/**
|
514
|
-
*
|
515
|
-
*
|
516
|
-
* @example
|
517
|
-
* const Data = d.struct({
|
518
|
-
* a: d.size(16, u32), // takes up 16 bytes, instead of 4
|
519
|
-
* b: u32, // starts at byte 16, because `a` has a custom size
|
520
|
-
* });
|
521
|
-
*
|
522
|
-
* @param size The amount of bytes that should be reserved for this data-type.
|
523
|
-
* @param data The data-type to wrap.
|
275
|
+
* @module typegpu/data
|
524
276
|
*/
|
525
|
-
|
277
|
+
|
526
278
|
/**
|
527
|
-
*
|
528
|
-
*
|
279
|
+
* Extracts the inferred representation of a resource.
|
529
280
|
* @example
|
530
|
-
*
|
531
|
-
*
|
532
|
-
* b: d.location(5, d.u32),
|
533
|
-
* c: d.u32, // has implicit location 6
|
534
|
-
* });
|
535
|
-
*
|
536
|
-
* @param location The explicit numeric location.
|
537
|
-
* @param data The data-type to wrap.
|
281
|
+
* type A = Infer<F32> // => number
|
282
|
+
* type B = Infer<TgpuArray<F32>> // => number[]
|
538
283
|
*/
|
539
|
-
|
540
|
-
declare function isDecorated<T extends Decorated<AnyTgpuData, AnyAttribute[]>>(value: T | unknown): value is T;
|
541
|
-
declare function isLooseDecorated<T extends LooseDecorated<AnyTgpuLooseData, AnyAttribute[]>>(value: T | unknown): value is T;
|
284
|
+
type Infer<T> = Infer$1<Exotic<T>>;
|
542
285
|
|
543
|
-
export {
|
286
|
+
export { Align, type AnyAttribute, AnyData, AnyLooseData, AnyWgslData, Atomic, Builtin, Decorated, I32, type Infer, type IsBuiltin, Location, LooseArray, LooseDecorated, LooseStruct, Mat2x2f, Mat3x3f, Mat4x4f, Size, type TgpuArray, type TgpuStruct, U32, WgslArray, WgslStruct, align, PUBLIC_alignmentOf as alignmentOf, arrayOf, atomic, isBuiltin, location, looseArrayOf, looseStruct, m2x2f, m3x3f, m4x4f, mat2x2f, mat3x3f, mat4x4f, matToArray, size, PUBLIC_sizeOf as sizeOf, struct, v2f, v3f, v4f };
|
package/data/index.js
CHANGED
@@ -1,2 +1,2 @@
|
|
1
|
-
import{$ as
|
1
|
+
import{$ as V,A as u,Aa as qa,B as v,Ba as ra,C as w,Ca as sa,D as x,Da as ta,E as y,Ea as ua,F as z,G as A,H as B,I as C,J as D,K as E,L as F,M as G,N as H,O as I,P as J,Q as K,R as L,S as M,T as N,U as O,V as P,W as Q,X as R,Y as S,Z as T,_ as U,aa as W,ba as X,ca as Y,d as a,da as Z,e as b,ea as _,f as c,fa as $,g as d,ga as aa,h as e,ha as ba,i as f,ia as ca,j as g,ja as da,k as h,ka as ea,l as i,la as fa,m as j,n as k,o as l,oa as ga,p as m,qa as ha,r as n,ra as ia,sa as ja,ta as ka,u as o,ua as la,v as p,w as q,wa as ma,x as r,xa as na,y as s,ya as oa,z as t,za as pa}from"../chunk-IQYHODCR.js";export{ia as align,ga as alignmentOf,na as arrayOf,ua as atomic,o as bool,s as f16,r as f32,T as float16x2,U as float16x4,V as float32,W as float32x2,X as float32x3,Y as float32x4,q as i32,e as isAlignAttrib,d as isAtomic,la as isBuiltin,h as isBuiltinAttrib,n as isData,i as isDecorated,g as isLocationAttrib,k as isLooseArray,j as isLooseData,m as isLooseDecorated,l as isLooseStruct,f as isSizeAttrib,b as isWgslArray,a as isWgslData,c as isWgslStruct,ka as location,oa as looseArrayOf,pa as looseStruct,qa as mat2x2f,ra as mat3x3f,sa as mat4x4f,ta as matToArray,C as packedFormats,N as sint16x2,O as sint16x4,ba as sint32,ca as sint32x2,da as sint32x3,ea as sint32x4,F as sint8x2,G as sint8x4,ja as size,ha as sizeOf,R as snorm16x2,S as snorm16x4,J as snorm8x2,K as snorm8x4,ma as struct,p as u32,L as uint16x2,M as uint16x4,Z as uint32,_ as uint32x2,$ as uint32x3,aa as uint32x4,D as uint8x2,E as uint8x4,fa as unorm10_10_10_2,P as unorm16x2,Q as unorm16x4,H as unorm8x2,I as unorm8x4,t as vec2f,u as vec2i,v as vec2u,w as vec3f,x as vec3i,y as vec3u,z as vec4f,A as vec4i,B as vec4u};
|
2
2
|
//# sourceMappingURL=index.js.map
|