typegpu 0.2.0-alpha.0 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
package/data/index.d.cts CHANGED
@@ -1,7 +1,89 @@
1
- import { AnySchema, Schema, Unwrap, ISerialOutput, ParseUnwrapped, ISerialInput, MaxValue, IMeasurer, ISchema, UnwrapRecord } from 'typed-binary';
1
+ import { Unwrap, AnySchema, Schema, ISerialOutput, ParseUnwrapped, ISerialInput, MaxValue, IMeasurer, ISchema, UnwrapRecord } from 'typed-binary';
2
2
  export { Parsed, Unwrap } from 'typed-binary';
3
- import { r as TgpuData, R as ResolutionCtx, A as AnyTgpuData, a as TgpuNamable, x as AnyTgpuLooseData, y as TgpuLooseData, 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-qmW7FFqN.cjs';
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-qmW7FFqN.cjs';
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.cjs';
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.cjs';
5
+
6
+ interface TgpuBaseArray<TElement extends AnyTgpuData | AnyTgpuLooseData = AnyTgpuData | AnyTgpuLooseData> {
7
+ readonly elementType: TElement;
8
+ readonly elementCount: number;
9
+ readonly stride: number;
10
+ }
11
+ /**
12
+ * Array schema constructed via `d.arrayOf` function.
13
+ *
14
+ * Responsible for handling reading and writing array values
15
+ * between binary and JS representation. Takes into account
16
+ * the `byteAlignment` requirement of its elementType.
17
+ */
18
+ interface TgpuArray<TElement extends AnyTgpuData> extends TgpuBaseArray<TElement>, TgpuData<Unwrap<TElement>[]> {
19
+ }
20
+ /**
21
+ * Creates an array schema that can be used to construct gpu buffers.
22
+ * Describes arrays with fixed-size length, storing elements of the same type.
23
+ *
24
+ * @example
25
+ * const LENGTH = 3;
26
+ * const array = d.arrayOf(d.u32, LENGTH);
27
+ *
28
+ * @param elementType The type of elements in the array.
29
+ * @param count The number of elements in the array.
30
+ */
31
+ declare const arrayOf: <TElement extends AnyTgpuData>(elementType: TElement, count: number) => TgpuArray<TElement>;
32
+ /**
33
+ * Array schema constructed via `d.looseArrayOf` function.
34
+ *
35
+ * Useful for defining vertex buffers.
36
+ * Elements in the schema are not aligned in respect to their `byteAlignment`,
37
+ * unless they are explicitly decorated with the custom align attribute
38
+ * via `d.align` function.
39
+ */
40
+ interface TgpuLooseArray<TElement extends AnyTgpuData | AnyTgpuLooseData> extends TgpuBaseArray<TElement>, TgpuLooseData<Unwrap<TElement>[]> {
41
+ }
42
+ /**
43
+ * Creates an array schema that can be used to construct vertex buffers.
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
52
+ *
53
+ * @example
54
+ * const looseArray = d.looseArrayOf(d.align(16, d.vec3f), 3);
55
+ *
56
+ * @param elementType The type of elements in the array.
57
+ * @param count The number of elements in the array.
58
+ */
59
+ declare const looseArrayOf: <TElement extends AnyTgpuData | AnyTgpuLooseData>(elementType: TElement, count: number) => TgpuLooseArray<TElement>;
60
+ /**
61
+ * Checks whether passed in value is an array schema,
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.
66
+ *
67
+ * @example
68
+ * isArraySchema(d.arrayOf(d.u32, 4)) // true
69
+ * isArraySchema(d.looseArrayOf(d.u32, 4)) // false
70
+ * isArraySchema(d.vec3f) // false
71
+ */
72
+ declare function isArraySchema<T extends TgpuArray<AnyTgpuData>>(schema: T | unknown): schema is T;
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.
80
+ *
81
+ * @example
82
+ * isLooseArraySchema(d.arrayOf(d.u32, 4)) // false
83
+ * isLooseArraySchema(d.looseArrayOf(d.u32, 4)) // true
84
+ * isLooseArraySchema(d.vec3f) // false
85
+ */
86
+ declare function isLooseArraySchema<T extends TgpuLooseArray<AnyTgpuData>>(schema: T | unknown): schema is T;
5
87
 
6
88
  declare class SimpleTgpuData<TSchema extends AnySchema> extends Schema<Unwrap<TSchema>> implements TgpuData<Unwrap<TSchema>> {
7
89
  readonly size: number;
@@ -106,88 +188,6 @@ declare function isStructSchema<T extends TgpuStruct<Record<string, AnyTgpuData>
106
188
  */
107
189
  declare function isLooseStructSchema<T extends TgpuLooseStruct<Record<string, AnyTgpuData | AnyTgpuLooseData>>>(schema: T | unknown): schema is T;
108
190
 
109
- interface TgpuBaseArray<TElement extends AnyTgpuData | AnyTgpuLooseData = AnyTgpuData | AnyTgpuLooseData> {
110
- readonly elementType: TElement;
111
- readonly elementCount: number;
112
- readonly stride: number;
113
- }
114
- /**
115
- * Array schema constructed via `d.arrayOf` function.
116
- *
117
- * Responsible for handling reading and writing array values
118
- * between binary and JS representation. Takes into account
119
- * the `byteAlignment` requirement of its elementType.
120
- */
121
- interface TgpuArray<TElement extends AnyTgpuData> extends TgpuBaseArray<TElement>, TgpuData<Unwrap<TElement>[]> {
122
- }
123
- /**
124
- * Creates an array schema that can be used to construct gpu buffers.
125
- * Describes arrays with fixed-size length, storing elements of the same type.
126
- *
127
- * @example
128
- * const LENGTH = 3;
129
- * const array = d.arrayOf(d.u32, LENGTH);
130
- *
131
- * @param elementType The type of elements in the array.
132
- * @param count The number of elements in the array.
133
- */
134
- declare const arrayOf: <TElement extends AnyTgpuData>(elementType: TElement, count: number) => TgpuArray<TElement>;
135
- /**
136
- * Array schema constructed via `d.looseArrayOf` function.
137
- *
138
- * Useful for defining vertex buffers.
139
- * Elements in the schema are not aligned in respect to their `byteAlignment`,
140
- * unless they are explicitly decorated with the custom align attribute
141
- * via `d.align` function.
142
- */
143
- interface TgpuLooseArray<TElement extends AnyTgpuData | AnyTgpuLooseData> extends TgpuBaseArray<TElement>, TgpuLooseData<Unwrap<TElement>[]> {
144
- }
145
- /**
146
- * Creates an array schema that can be used to construct vertex buffers.
147
- * Describes arrays with fixed-size length, storing elements of the same type.
148
- *
149
- * Elements in the schema are not aligned in respect to their `byteAlignment`,
150
- * unless they are explicitly decorated with the custom align attribute
151
- * via `d.align` function.
152
- *
153
- * @example
154
- * const looseArray = d.looseArrayOf(d.vec3f, 3); // packed array of vec3f
155
- *
156
- * @example
157
- * const looseArray = d.looseArrayOf(d.align(16, d.vec3f), 3);
158
- *
159
- * @param elementType The type of elements in the array.
160
- * @param count The number of elements in the array.
161
- */
162
- declare const looseArrayOf: <TElement extends AnyTgpuData | AnyTgpuLooseData>(elementType: TElement, count: number) => TgpuLooseArray<TElement>;
163
- /**
164
- * Checks whether passed in value is an array schema,
165
- * as opposed to, e.g., a looseArray schema.
166
- *
167
- * Array schemas can be used to describe uniform and storage buffers,
168
- * whereas looseArray schemas cannot.
169
- *
170
- * @example
171
- * isArraySchema(d.arrayOf(d.u32, 4)) // true
172
- * isArraySchema(d.looseArrayOf(d.u32, 4)) // false
173
- * isArraySchema(d.vec3f) // false
174
- */
175
- declare function isArraySchema<T extends TgpuArray<AnyTgpuData>>(schema: T | unknown): schema is T;
176
- /**
177
- * Checks whether the passed in value is a looseArray schema,
178
- * as opposed to, e.g., a regular array schema.
179
- *
180
- * Array schemas can be used to describe uniform and storage buffers,
181
- * whereas looseArray schemas cannot. Loose arrays are useful for
182
- * defining vertex buffers instead.
183
- *
184
- * @example
185
- * isLooseArraySchema(d.arrayOf(d.u32, 4)) // false
186
- * isLooseArraySchema(d.looseArrayOf(d.u32, 4)) // true
187
- * isLooseArraySchema(d.vec3f) // false
188
- */
189
- declare function isLooseArraySchema<T extends TgpuLooseArray<AnyTgpuData>>(schema: T | unknown): schema is T;
190
-
191
191
  interface matBase<TColumn> extends NumberArrayView {
192
192
  readonly columns: readonly TColumn[];
193
193
  elements(): Iterable<number>;
package/data/index.d.ts CHANGED
@@ -1,7 +1,89 @@
1
- import { AnySchema, Schema, Unwrap, ISerialOutput, ParseUnwrapped, ISerialInput, MaxValue, IMeasurer, ISchema, UnwrapRecord } from 'typed-binary';
1
+ import { Unwrap, AnySchema, Schema, ISerialOutput, ParseUnwrapped, ISerialInput, MaxValue, IMeasurer, ISchema, UnwrapRecord } from 'typed-binary';
2
2
  export { Parsed, Unwrap } from 'typed-binary';
3
- import { r as TgpuData, R as ResolutionCtx, A as AnyTgpuData, a as TgpuNamable, x as AnyTgpuLooseData, y as TgpuLooseData, 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-qmW7FFqN.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-qmW7FFqN.js';
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';
5
+
6
+ interface TgpuBaseArray<TElement extends AnyTgpuData | AnyTgpuLooseData = AnyTgpuData | AnyTgpuLooseData> {
7
+ readonly elementType: TElement;
8
+ readonly elementCount: number;
9
+ readonly stride: number;
10
+ }
11
+ /**
12
+ * Array schema constructed via `d.arrayOf` function.
13
+ *
14
+ * Responsible for handling reading and writing array values
15
+ * between binary and JS representation. Takes into account
16
+ * the `byteAlignment` requirement of its elementType.
17
+ */
18
+ interface TgpuArray<TElement extends AnyTgpuData> extends TgpuBaseArray<TElement>, TgpuData<Unwrap<TElement>[]> {
19
+ }
20
+ /**
21
+ * Creates an array schema that can be used to construct gpu buffers.
22
+ * Describes arrays with fixed-size length, storing elements of the same type.
23
+ *
24
+ * @example
25
+ * const LENGTH = 3;
26
+ * const array = d.arrayOf(d.u32, LENGTH);
27
+ *
28
+ * @param elementType The type of elements in the array.
29
+ * @param count The number of elements in the array.
30
+ */
31
+ declare const arrayOf: <TElement extends AnyTgpuData>(elementType: TElement, count: number) => TgpuArray<TElement>;
32
+ /**
33
+ * Array schema constructed via `d.looseArrayOf` function.
34
+ *
35
+ * Useful for defining vertex buffers.
36
+ * Elements in the schema are not aligned in respect to their `byteAlignment`,
37
+ * unless they are explicitly decorated with the custom align attribute
38
+ * via `d.align` function.
39
+ */
40
+ interface TgpuLooseArray<TElement extends AnyTgpuData | AnyTgpuLooseData> extends TgpuBaseArray<TElement>, TgpuLooseData<Unwrap<TElement>[]> {
41
+ }
42
+ /**
43
+ * Creates an array schema that can be used to construct vertex buffers.
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
52
+ *
53
+ * @example
54
+ * const looseArray = d.looseArrayOf(d.align(16, d.vec3f), 3);
55
+ *
56
+ * @param elementType The type of elements in the array.
57
+ * @param count The number of elements in the array.
58
+ */
59
+ declare const looseArrayOf: <TElement extends AnyTgpuData | AnyTgpuLooseData>(elementType: TElement, count: number) => TgpuLooseArray<TElement>;
60
+ /**
61
+ * Checks whether passed in value is an array schema,
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.
66
+ *
67
+ * @example
68
+ * isArraySchema(d.arrayOf(d.u32, 4)) // true
69
+ * isArraySchema(d.looseArrayOf(d.u32, 4)) // false
70
+ * isArraySchema(d.vec3f) // false
71
+ */
72
+ declare function isArraySchema<T extends TgpuArray<AnyTgpuData>>(schema: T | unknown): schema is T;
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.
80
+ *
81
+ * @example
82
+ * isLooseArraySchema(d.arrayOf(d.u32, 4)) // false
83
+ * isLooseArraySchema(d.looseArrayOf(d.u32, 4)) // true
84
+ * isLooseArraySchema(d.vec3f) // false
85
+ */
86
+ declare function isLooseArraySchema<T extends TgpuLooseArray<AnyTgpuData>>(schema: T | unknown): schema is T;
5
87
 
6
88
  declare class SimpleTgpuData<TSchema extends AnySchema> extends Schema<Unwrap<TSchema>> implements TgpuData<Unwrap<TSchema>> {
7
89
  readonly size: number;
@@ -106,88 +188,6 @@ declare function isStructSchema<T extends TgpuStruct<Record<string, AnyTgpuData>
106
188
  */
107
189
  declare function isLooseStructSchema<T extends TgpuLooseStruct<Record<string, AnyTgpuData | AnyTgpuLooseData>>>(schema: T | unknown): schema is T;
108
190
 
109
- interface TgpuBaseArray<TElement extends AnyTgpuData | AnyTgpuLooseData = AnyTgpuData | AnyTgpuLooseData> {
110
- readonly elementType: TElement;
111
- readonly elementCount: number;
112
- readonly stride: number;
113
- }
114
- /**
115
- * Array schema constructed via `d.arrayOf` function.
116
- *
117
- * Responsible for handling reading and writing array values
118
- * between binary and JS representation. Takes into account
119
- * the `byteAlignment` requirement of its elementType.
120
- */
121
- interface TgpuArray<TElement extends AnyTgpuData> extends TgpuBaseArray<TElement>, TgpuData<Unwrap<TElement>[]> {
122
- }
123
- /**
124
- * Creates an array schema that can be used to construct gpu buffers.
125
- * Describes arrays with fixed-size length, storing elements of the same type.
126
- *
127
- * @example
128
- * const LENGTH = 3;
129
- * const array = d.arrayOf(d.u32, LENGTH);
130
- *
131
- * @param elementType The type of elements in the array.
132
- * @param count The number of elements in the array.
133
- */
134
- declare const arrayOf: <TElement extends AnyTgpuData>(elementType: TElement, count: number) => TgpuArray<TElement>;
135
- /**
136
- * Array schema constructed via `d.looseArrayOf` function.
137
- *
138
- * Useful for defining vertex buffers.
139
- * Elements in the schema are not aligned in respect to their `byteAlignment`,
140
- * unless they are explicitly decorated with the custom align attribute
141
- * via `d.align` function.
142
- */
143
- interface TgpuLooseArray<TElement extends AnyTgpuData | AnyTgpuLooseData> extends TgpuBaseArray<TElement>, TgpuLooseData<Unwrap<TElement>[]> {
144
- }
145
- /**
146
- * Creates an array schema that can be used to construct vertex buffers.
147
- * Describes arrays with fixed-size length, storing elements of the same type.
148
- *
149
- * Elements in the schema are not aligned in respect to their `byteAlignment`,
150
- * unless they are explicitly decorated with the custom align attribute
151
- * via `d.align` function.
152
- *
153
- * @example
154
- * const looseArray = d.looseArrayOf(d.vec3f, 3); // packed array of vec3f
155
- *
156
- * @example
157
- * const looseArray = d.looseArrayOf(d.align(16, d.vec3f), 3);
158
- *
159
- * @param elementType The type of elements in the array.
160
- * @param count The number of elements in the array.
161
- */
162
- declare const looseArrayOf: <TElement extends AnyTgpuData | AnyTgpuLooseData>(elementType: TElement, count: number) => TgpuLooseArray<TElement>;
163
- /**
164
- * Checks whether passed in value is an array schema,
165
- * as opposed to, e.g., a looseArray schema.
166
- *
167
- * Array schemas can be used to describe uniform and storage buffers,
168
- * whereas looseArray schemas cannot.
169
- *
170
- * @example
171
- * isArraySchema(d.arrayOf(d.u32, 4)) // true
172
- * isArraySchema(d.looseArrayOf(d.u32, 4)) // false
173
- * isArraySchema(d.vec3f) // false
174
- */
175
- declare function isArraySchema<T extends TgpuArray<AnyTgpuData>>(schema: T | unknown): schema is T;
176
- /**
177
- * Checks whether the passed in value is a looseArray schema,
178
- * as opposed to, e.g., a regular array schema.
179
- *
180
- * Array schemas can be used to describe uniform and storage buffers,
181
- * whereas looseArray schemas cannot. Loose arrays are useful for
182
- * defining vertex buffers instead.
183
- *
184
- * @example
185
- * isLooseArraySchema(d.arrayOf(d.u32, 4)) // false
186
- * isLooseArraySchema(d.looseArrayOf(d.u32, 4)) // true
187
- * isLooseArraySchema(d.vec3f) // false
188
- */
189
- declare function isLooseArraySchema<T extends TgpuLooseArray<AnyTgpuData>>(schema: T | unknown): schema is T;
190
-
191
191
  interface matBase<TColumn> extends NumberArrayView {
192
192
  readonly columns: readonly TColumn[];
193
193
  elements(): Iterable<number>;