@vcollab/shader-library 0.0.0-stage → 2.0.0
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/CHANGELOG.md +92 -0
- package/LICENSE +8 -0
- package/README.md +111 -2
- package/dist/bind.d.ts +53 -0
- package/dist/blocks.d.ts +73 -0
- package/dist/bundled.cjs +272 -0
- package/dist/bundled.cjs.map +1 -0
- package/dist/bundled.d.ts +6 -0
- package/dist/bundled.js +22 -0
- package/dist/bundled.js.map +1 -0
- package/dist/chunk-A73KYX6T.js +298 -0
- package/dist/chunk-A73KYX6T.js.map +1 -0
- package/dist/derived/dispatch.d.ts +80 -0
- package/dist/derived/errors.d.ts +4 -0
- package/dist/derived/index.cjs +451 -0
- package/dist/derived/index.cjs.map +1 -0
- package/dist/derived/index.d.ts +62 -0
- package/dist/derived/index.js +417 -0
- package/dist/derived/index.js.map +1 -0
- package/dist/derived/kernels.d.ts +73 -0
- package/dist/encoding.d.ts +39 -0
- package/dist/index.cjs +736 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.ts +42 -0
- package/dist/index.js +418 -0
- package/dist/index.js.map +1 -0
- package/dist/load.d.ts +60 -0
- package/dist/manifest.d.ts +213 -0
- package/dist/pack.d.ts +69 -0
- package/dist/pick.d.ts +89 -0
- package/dist/select.d.ts +47 -0
- package/dist/version.d.ts +2 -0
- package/package.json +70 -3
|
@@ -0,0 +1,213 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The artifact set's documents, as types.
|
|
3
|
+
*
|
|
4
|
+
* These mirror what `vcti-shader-foundry` emits — `registry.json` and one
|
|
5
|
+
* envelope per pipeline — field for field. The foundry is the only thing that
|
|
6
|
+
* produces them; nothing here re-declares a contract or invents a field. When
|
|
7
|
+
* the emitted shape changes, {@link SCHEMA_VERSION} changes with it and a set
|
|
8
|
+
* carrying an unknown version is refused rather than misread.
|
|
9
|
+
*/
|
|
10
|
+
/** The emitted document shape this package understands. */
|
|
11
|
+
export declare const SCHEMA_VERSION = 3;
|
|
12
|
+
/** A shader language an artifact set can carry. Only `glsl` is emitted today. */
|
|
13
|
+
export type ShaderLanguage = "glsl" | "wgsl";
|
|
14
|
+
/** A stage of a pipeline. */
|
|
15
|
+
export type ShaderStage = "vertex" | "fragment";
|
|
16
|
+
/** One vertex attribute the pipeline reads. */
|
|
17
|
+
export interface AttributeSpec {
|
|
18
|
+
/** The name the attribute is declared under. */
|
|
19
|
+
readonly name: string;
|
|
20
|
+
/** Its GL type, e.g. `vec3`, `int`. */
|
|
21
|
+
readonly type: string;
|
|
22
|
+
/** What the attribute means — how a consumer matches its own buffer to it. */
|
|
23
|
+
readonly semantic: string;
|
|
24
|
+
}
|
|
25
|
+
/** One uniform block member the pipeline reads. */
|
|
26
|
+
export interface UniformSpec {
|
|
27
|
+
readonly name: string;
|
|
28
|
+
/** Its GL type, e.g. `vec3`, `mat4`, `int`. */
|
|
29
|
+
readonly type: string;
|
|
30
|
+
/**
|
|
31
|
+
* Named states for an integer selector, e.g. `u_colorSource`. The numbers
|
|
32
|
+
* are append-only across releases (see the foundry's stability rules).
|
|
33
|
+
*/
|
|
34
|
+
readonly namedValues?: Readonly<Record<string, number>>;
|
|
35
|
+
}
|
|
36
|
+
/** One fragment output. Its index in `outputs` is its location. */
|
|
37
|
+
export interface OutputSpec {
|
|
38
|
+
readonly name: string;
|
|
39
|
+
readonly type: string;
|
|
40
|
+
/**
|
|
41
|
+
* The attachment format the output requires, or `null` for no exact
|
|
42
|
+
* requirement. `null` is a claim, not an omission.
|
|
43
|
+
*/
|
|
44
|
+
readonly format: string | null;
|
|
45
|
+
}
|
|
46
|
+
/** A texture read at exact integer coordinates — a lookup table, not an image. */
|
|
47
|
+
export interface TableSpec {
|
|
48
|
+
readonly name: string;
|
|
49
|
+
readonly type: string;
|
|
50
|
+
readonly format: string;
|
|
51
|
+
readonly semantic: string;
|
|
52
|
+
}
|
|
53
|
+
/** An image sampled between texels. */
|
|
54
|
+
export interface TextureSpec {
|
|
55
|
+
readonly name: string;
|
|
56
|
+
readonly semantic: string;
|
|
57
|
+
readonly kind: string;
|
|
58
|
+
readonly component: string;
|
|
59
|
+
readonly format: string;
|
|
60
|
+
readonly requiresMipChain: boolean;
|
|
61
|
+
/** The name of a sampler this contract declares. */
|
|
62
|
+
readonly sampler: string;
|
|
63
|
+
/** The semantic of a uv attribute this contract carries. */
|
|
64
|
+
readonly uv: string;
|
|
65
|
+
readonly selection: string;
|
|
66
|
+
readonly neutral: readonly number[] | null;
|
|
67
|
+
}
|
|
68
|
+
/** Sampler state a texture is read through. */
|
|
69
|
+
export interface SamplerSpec {
|
|
70
|
+
readonly name: string;
|
|
71
|
+
readonly magFilter: string;
|
|
72
|
+
readonly minFilter: string;
|
|
73
|
+
readonly mipmapFilter: string;
|
|
74
|
+
readonly wrapS: string;
|
|
75
|
+
readonly wrapT: string;
|
|
76
|
+
}
|
|
77
|
+
/**
|
|
78
|
+
* A pipeline's binding surface: everything a caller must match.
|
|
79
|
+
*
|
|
80
|
+
* Order is significant. A uniform block's member order determines its byte
|
|
81
|
+
* offsets, which is why {@link RegistryEntry.contractSha256} is computed over
|
|
82
|
+
* this document with its sequences left unsorted.
|
|
83
|
+
*/
|
|
84
|
+
export interface PipelineContract {
|
|
85
|
+
readonly id: string;
|
|
86
|
+
readonly capabilities: readonly string[];
|
|
87
|
+
readonly inputs: readonly AttributeSpec[];
|
|
88
|
+
readonly uniforms: readonly UniformSpec[];
|
|
89
|
+
readonly outputs: readonly OutputSpec[];
|
|
90
|
+
readonly tables: readonly TableSpec[];
|
|
91
|
+
readonly textures: readonly TextureSpec[];
|
|
92
|
+
readonly samplers: readonly SamplerSpec[];
|
|
93
|
+
}
|
|
94
|
+
/** Versions of the three executables that compiled a set. `null` where unread. */
|
|
95
|
+
export interface ToolchainInfo {
|
|
96
|
+
readonly slangc: string | null;
|
|
97
|
+
readonly spirvCross: string | null;
|
|
98
|
+
readonly glslang: string | null;
|
|
99
|
+
}
|
|
100
|
+
/** What produced a set, and with what. */
|
|
101
|
+
export interface GeneratorInfo {
|
|
102
|
+
readonly name: string;
|
|
103
|
+
readonly version: string;
|
|
104
|
+
readonly toolchain: ToolchainInfo | null;
|
|
105
|
+
}
|
|
106
|
+
/**
|
|
107
|
+
* One index entry: enough to choose this pipeline, and where to go next.
|
|
108
|
+
*
|
|
109
|
+
* Not the contract. `contractSha256` names the envelope's content without
|
|
110
|
+
* repeating it, so a fetched envelope can be checked against the entry that
|
|
111
|
+
* pointed at it.
|
|
112
|
+
*/
|
|
113
|
+
export interface RegistryEntry {
|
|
114
|
+
readonly id: string;
|
|
115
|
+
readonly description: string;
|
|
116
|
+
readonly capabilities: readonly string[];
|
|
117
|
+
readonly contractSha256: string;
|
|
118
|
+
/** The envelope's path within the set, relative and POSIX. */
|
|
119
|
+
readonly envelope: string;
|
|
120
|
+
}
|
|
121
|
+
/** `registry.json`: the index a consumer selects from. */
|
|
122
|
+
export interface Registry {
|
|
123
|
+
readonly schemaVersion: number;
|
|
124
|
+
readonly generator: GeneratorInfo;
|
|
125
|
+
/** The closed set of tags any pipeline in this set may declare. */
|
|
126
|
+
readonly capabilityVocabulary: readonly string[];
|
|
127
|
+
readonly pipelines: readonly RegistryEntry[];
|
|
128
|
+
}
|
|
129
|
+
/**
|
|
130
|
+
* Where std140 placed one uniform block member.
|
|
131
|
+
*
|
|
132
|
+
* Read rather than recomputed: a second implementation of the padding rules is
|
|
133
|
+
* a second thing to be wrong, and it would diverge silently — on one pipeline,
|
|
134
|
+
* in one case, such as the sixteen-byte stride std140 gives the eight-byte
|
|
135
|
+
* elements of a `vec2[72]`.
|
|
136
|
+
*/
|
|
137
|
+
export interface UniformLayout {
|
|
138
|
+
/** Byte offset from the start of the block. */
|
|
139
|
+
readonly offset: number;
|
|
140
|
+
/** Total byte size, including any array padding. */
|
|
141
|
+
readonly size: number;
|
|
142
|
+
/**
|
|
143
|
+
* Bytes between array elements. For a member that is not an array it is
|
|
144
|
+
* what the reflection reports for its components: `4` for a vector, `0` for
|
|
145
|
+
* a scalar or a matrix. The packer reads it only for an array.
|
|
146
|
+
*/
|
|
147
|
+
readonly elementStride: number;
|
|
148
|
+
/** The element type — `float`, `vec3`, `mat4`, `ivec2`. */
|
|
149
|
+
readonly encoding: string | null;
|
|
150
|
+
/** `row` or `column`, present only for a matrix. */
|
|
151
|
+
readonly majorness?: "row" | "column";
|
|
152
|
+
}
|
|
153
|
+
/**
|
|
154
|
+
* One emitted sampler uniform, and the resource it was built from.
|
|
155
|
+
*
|
|
156
|
+
* The seam the declared names do not cross: GLSL ES 3.00 has no binding
|
|
157
|
+
* qualifier for samplers, so the cross-compiler pairs each texture with a
|
|
158
|
+
* sampler and names the combination itself. A consumer binds by
|
|
159
|
+
* {@link semantic}, then uses {@link uniform} and {@link unit}.
|
|
160
|
+
*/
|
|
161
|
+
export interface BindingRecord {
|
|
162
|
+
/** The semantic of the table or texture this was built from. */
|
|
163
|
+
readonly semantic: string;
|
|
164
|
+
/** The declared name of that resource. It does not reach the program. */
|
|
165
|
+
readonly texture: string;
|
|
166
|
+
/**
|
|
167
|
+
* The declared name of the sampler it was paired with, or `null` where the
|
|
168
|
+
* contract declares none — a table read at exact texel coordinates is paired
|
|
169
|
+
* with the cross-compiler's dummy sampler, which the contract never names.
|
|
170
|
+
*/
|
|
171
|
+
readonly sampler: string | null;
|
|
172
|
+
/** The uniform the emitted program actually declares. */
|
|
173
|
+
readonly uniform: string;
|
|
174
|
+
readonly component: string;
|
|
175
|
+
readonly stage: ShaderStage;
|
|
176
|
+
/** The texture unit to bind to, assigned deterministically at build. */
|
|
177
|
+
readonly unit: number;
|
|
178
|
+
}
|
|
179
|
+
/** One stage's emitted source and its hash. */
|
|
180
|
+
export interface StageSource {
|
|
181
|
+
readonly source: string;
|
|
182
|
+
readonly sha256: string;
|
|
183
|
+
}
|
|
184
|
+
/** Everything about one pipeline in one language. */
|
|
185
|
+
export interface LanguageBlock {
|
|
186
|
+
/**
|
|
187
|
+
* The reflected size of the whole uniform block, which is larger than the
|
|
188
|
+
* contract: the compiler emits its entire global block whatever entry point
|
|
189
|
+
* is compiled, so an undeformed pipeline's GLSL still carries deform members
|
|
190
|
+
* its contract does not list. Allocate this many bytes.
|
|
191
|
+
*/
|
|
192
|
+
readonly blockSize: number;
|
|
193
|
+
/** Placement of every member the block holds, by name. */
|
|
194
|
+
readonly layout: Readonly<Record<string, UniformLayout>>;
|
|
195
|
+
readonly bindings: readonly BindingRecord[];
|
|
196
|
+
readonly stages: Readonly<Partial<Record<ShaderStage, StageSource>>>;
|
|
197
|
+
}
|
|
198
|
+
/**
|
|
199
|
+
* One pipeline as a self-contained document: contract plus its shaders.
|
|
200
|
+
*
|
|
201
|
+
* The second projection of the manifest, for consumption rather than
|
|
202
|
+
* selection. Fetching one is a single request that cannot arrive half-stale.
|
|
203
|
+
*/
|
|
204
|
+
export interface Envelope {
|
|
205
|
+
readonly schemaVersion: number;
|
|
206
|
+
readonly generator: GeneratorInfo;
|
|
207
|
+
/** The contract, with the pipeline's description alongside it. */
|
|
208
|
+
readonly pipeline: PipelineContract & {
|
|
209
|
+
readonly description: string;
|
|
210
|
+
};
|
|
211
|
+
readonly contractSha256: string;
|
|
212
|
+
readonly languages: Readonly<Partial<Record<ShaderLanguage, LanguageBlock>>>;
|
|
213
|
+
}
|
package/dist/pack.d.ts
ADDED
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import type { LanguageBlock } from "./manifest.js";
|
|
2
|
+
/** Raised for a write this packer will not make. */
|
|
3
|
+
export declare class UniformPackError extends Error {
|
|
4
|
+
readonly name = "UniformPackError";
|
|
5
|
+
}
|
|
6
|
+
/** How a matrix's elements are ordered in memory. */
|
|
7
|
+
export type Majorness = "row" | "column";
|
|
8
|
+
/**
|
|
9
|
+
* One pipeline's uniform block, allocated and writable by member name.
|
|
10
|
+
*
|
|
11
|
+
* Create one per draw target and reuse it: the buffer is the thing uploaded,
|
|
12
|
+
* and rewriting a member in place is cheaper than rebuilding it. Members never
|
|
13
|
+
* written stay zero, which is the off state every always-present feature
|
|
14
|
+
* defines for itself — a plane count of zero, a scale of zero.
|
|
15
|
+
*
|
|
16
|
+
* ## Matrices, and why the transpose goes the other way
|
|
17
|
+
*
|
|
18
|
+
* Hand {@link UniformBlock.set} a conventional column-major matrix and the
|
|
19
|
+
* shaders apply that matrix. Getting there takes two corrections that happen
|
|
20
|
+
* to cancel, and only one of them is visible in the layout:
|
|
21
|
+
*
|
|
22
|
+
* 1. The block declares its matrices `row_major`, so each sixteen-byte slot
|
|
23
|
+
* holds a **row** of the GLSL variable rather than a column.
|
|
24
|
+
* 2. The features are authored in Slang, which multiplies the HLSL way round,
|
|
25
|
+
* and the emitted GLSL keeps it — `position * u_mvpMatrix`, never
|
|
26
|
+
* `u_mvpMatrix * position`. In GLSL `v * M` is `transpose(M) * v`, so the
|
|
27
|
+
* transform a shader applies is the transpose of the matrix it is given.
|
|
28
|
+
*
|
|
29
|
+
* Reading the layout and ignoring the multiply order gives a transposed
|
|
30
|
+
* camera. That is a rotation's inverse, so it survives casual inspection: an
|
|
31
|
+
* identity is unchanged by it, and so are the front, back, top and bottom
|
|
32
|
+
* views of a symmetric model. It shows up as left and right views that are
|
|
33
|
+
* mirrored, and as translations that travel along the wrong axis.
|
|
34
|
+
*
|
|
35
|
+
* So a column-major input is written through **untransposed** into a
|
|
36
|
+
* `row_major` block, and transposed into a `column_major` one — the opposite
|
|
37
|
+
* of what point 1 alone would ask for. `majorness` still describes the input
|
|
38
|
+
* array's own order and nothing else; it is not a way to ask for a transpose.
|
|
39
|
+
*/
|
|
40
|
+
export declare class UniformBlock {
|
|
41
|
+
#private;
|
|
42
|
+
/** The bytes to upload. */
|
|
43
|
+
readonly buffer: ArrayBuffer;
|
|
44
|
+
constructor(block: LanguageBlock);
|
|
45
|
+
/** The block's size in bytes. */
|
|
46
|
+
get byteLength(): number;
|
|
47
|
+
/** Whether the block declares `name`. */
|
|
48
|
+
has(name: string): boolean;
|
|
49
|
+
/** Every member the block declares. */
|
|
50
|
+
get members(): readonly string[];
|
|
51
|
+
/** Zero the whole block. */
|
|
52
|
+
clear(): this;
|
|
53
|
+
/**
|
|
54
|
+
* Write one member.
|
|
55
|
+
*
|
|
56
|
+
* Accepts what the member's shape needs: a number for a scalar, a flat array
|
|
57
|
+
* of components for a vector or matrix, and either a flat array or an array
|
|
58
|
+
* of elements for an array member.
|
|
59
|
+
*
|
|
60
|
+
* A matrix is taken as column-major — the order GL APIs and every mat4
|
|
61
|
+
* library produce — and is written so that the emitted shaders apply *that*
|
|
62
|
+
* transform. See {@link UniformBlock} on why the bytes that achieve it are
|
|
63
|
+
* not the ones the block's `row_major` qualifier alone would suggest. Pass
|
|
64
|
+
* `majorness: "row"` only when the input array is itself row-major.
|
|
65
|
+
*/
|
|
66
|
+
set(name: string, value: number | boolean | ArrayLike<number> | ReadonlyArray<ArrayLike<number>>, options?: {
|
|
67
|
+
majorness?: Majorness;
|
|
68
|
+
}): this;
|
|
69
|
+
}
|
package/dist/pick.d.ts
ADDED
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Reading back a pick texel.
|
|
3
|
+
*
|
|
4
|
+
* The pick pass writes per-pixel identifiers into an integer attachment
|
|
5
|
+
* instead of a color. Four unsigned 32-bit channels: the primitive id, the
|
|
6
|
+
* view depth, the group id and one reserved. Decoding them is arithmetic, not
|
|
7
|
+
* GPU work, so
|
|
8
|
+
* it lives here rather than in a renderer — a WebGPU consumer reads the same
|
|
9
|
+
* texel and must read it the same way.
|
|
10
|
+
*
|
|
11
|
+
* **Three things about the layout are easy to get wrong, and two fail
|
|
12
|
+
* silently**, which is why this is written once:
|
|
13
|
+
*
|
|
14
|
+
* - The depth channel holds the *bits* of a `float32`, not a number. Read as
|
|
15
|
+
* an integer it is a value in the billions.
|
|
16
|
+
* - A pixel where nothing was drawn carries {@link PICK_EMPTY} in every
|
|
17
|
+
* channel, and emptiness must be tested on the identifier alone. The group
|
|
18
|
+
* id's channel is not a substitute: a hit can carry any value there, the
|
|
19
|
+
* sentinel's bits included.
|
|
20
|
+
* - The target must be cleared to {@link PICK_EMPTY} before the pass. Cleared
|
|
21
|
+
* to zero, every empty pixel decodes as primitive 0.
|
|
22
|
+
*
|
|
23
|
+
* The layout is the `pick` feature's, mirrored from its Python.
|
|
24
|
+
*/
|
|
25
|
+
import type { Registry, RegistryEntry } from "./manifest.js";
|
|
26
|
+
/** The capability tag a pick pipeline declares. */
|
|
27
|
+
export declare const PICK_CAPABILITY = "pick";
|
|
28
|
+
/**
|
|
29
|
+
* The value every channel carries where no geometry was drawn, and what the
|
|
30
|
+
* target is cleared to before the pass.
|
|
31
|
+
*/
|
|
32
|
+
export declare const PICK_EMPTY = 4294967295;
|
|
33
|
+
/** What a fragment writes into the reserved channel. */
|
|
34
|
+
export declare const PICK_RESERVED = 0;
|
|
35
|
+
/** What each channel of the texel holds, in order. */
|
|
36
|
+
export declare const PICK_CHANNELS: readonly ["primitiveId", "depth", "groupId", "reserved"];
|
|
37
|
+
/** What one pick texel identifies. */
|
|
38
|
+
export interface Pick {
|
|
39
|
+
/** The primitive id the fragment carried, as the caller's data set it. */
|
|
40
|
+
readonly primitiveId: number;
|
|
41
|
+
/**
|
|
42
|
+
* Distance along the camera's forward axis — `-z` in view space, not a
|
|
43
|
+
* normalized depth. The caller owns the ray, so a depth is enough to place
|
|
44
|
+
* the point and costs one channel where a position would cost three.
|
|
45
|
+
*/
|
|
46
|
+
readonly depth: number;
|
|
47
|
+
/**
|
|
48
|
+
* The scene atom: `a_atomId + u_maskLutBase`, the row of the scene mask the
|
|
49
|
+
* fragment was drawn by. When each occurrence of a mesh is drawn with its own
|
|
50
|
+
* block of the scene mask, this names the occurrence and the atom in one
|
|
51
|
+
* number; two draws of one vertex buffer share their primitive ids, so it is
|
|
52
|
+
* what tells a click on one from the other. With the base at zero it is the
|
|
53
|
+
* mesh's own atom id, and occurrences cannot be told apart.
|
|
54
|
+
*/
|
|
55
|
+
readonly groupId: number;
|
|
56
|
+
}
|
|
57
|
+
/** Raised for a texel that cannot have come from a pick pass. */
|
|
58
|
+
export declare class PickDecodeError extends Error {
|
|
59
|
+
readonly name = "PickDecodeError";
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* Decode one texel of a pick readback, or `null` where nothing was drawn.
|
|
63
|
+
*
|
|
64
|
+
* @param texel the four channel values, as unsigned 32-bit integers — four
|
|
65
|
+
* elements of the `Uint32Array` a `readPixels` of an `rgba32ui` attachment
|
|
66
|
+
* fills, at the offset of the pixel wanted.
|
|
67
|
+
* @throws {PickDecodeError} if a channel does not fit in 32 bits, which means
|
|
68
|
+
* the readback was decoded at the wrong width and every field is suspect.
|
|
69
|
+
*/
|
|
70
|
+
export declare function decodePick(texel: ArrayLike<number>, offset?: number): Pick | null;
|
|
71
|
+
/**
|
|
72
|
+
* The pick pipeline that matches a color pipeline.
|
|
73
|
+
*
|
|
74
|
+
* Picking is a second draw of the same geometry, so the two passes must agree
|
|
75
|
+
* on everything the vertex stage does — above all the deform variant, or
|
|
76
|
+
* deformed geometry is picked where it is not drawn.
|
|
77
|
+
*
|
|
78
|
+
* Found by capability: a pick pipeline is compatible when it asks for nothing
|
|
79
|
+
* the color pass does not already have, and carries the color pipeline's
|
|
80
|
+
* deform variant (`deform3` or `deform6`) — the one difference that would put
|
|
81
|
+
* picked geometry somewhere other than where it is drawn, so it is required
|
|
82
|
+
* rather than preferred. Of the compatible ones, the one carrying the most
|
|
83
|
+
* capabilities keeps the most of the vertex stage in step.
|
|
84
|
+
*
|
|
85
|
+
* @throws {PipelineSelectionError} if the set has no compatible pick pipeline
|
|
86
|
+
* — including when it has pick pipelines, but none with the color
|
|
87
|
+
* pipeline's deform variant — or two equally good ones.
|
|
88
|
+
*/
|
|
89
|
+
export declare function pickPipelineFor(registry: Registry, color: RegistryEntry): RegistryEntry;
|
package/dist/select.d.ts
ADDED
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Choosing a pipeline.
|
|
3
|
+
*
|
|
4
|
+
* A pipeline's id names its vertex variant and its fragment shape; its
|
|
5
|
+
* capability set is what a consumer matches on. The match is **exact**: a
|
|
6
|
+
* capability set is a description of what the pipeline does, not a list of
|
|
7
|
+
* minimum requirements, and a pipeline carrying a capability you did not ask
|
|
8
|
+
* for will read an attribute you did not bind.
|
|
9
|
+
*
|
|
10
|
+
* Nothing here ranks. The artifact set carries no defaults, no preference
|
|
11
|
+
* order and no fallbacks, and inventing one in this package would make it a
|
|
12
|
+
* policy every consumer inherits without asking. What is here is the exact
|
|
13
|
+
* match, and the filters a caller needs to build its own choice.
|
|
14
|
+
*/
|
|
15
|
+
import type { Registry, RegistryEntry } from "./manifest.js";
|
|
16
|
+
/** Raised when a request cannot be resolved to one pipeline. */
|
|
17
|
+
export declare class PipelineSelectionError extends Error {
|
|
18
|
+
readonly name = "PipelineSelectionError";
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Check every tag against the set's own vocabulary.
|
|
22
|
+
*
|
|
23
|
+
* The vocabulary is closed per document, so a tag outside it can never match
|
|
24
|
+
* anything. Catching that here names the typo; leaving it to
|
|
25
|
+
* {@link matchCapabilities} would report only that nothing matched.
|
|
26
|
+
*/
|
|
27
|
+
export declare function validateCapabilities(registry: Registry, capabilities: Iterable<string>): void;
|
|
28
|
+
/** Every pipeline whose capability set is exactly `capabilities`. */
|
|
29
|
+
export declare function matchCapabilities(entries: readonly RegistryEntry[], capabilities: Iterable<string>): RegistryEntry[];
|
|
30
|
+
/**
|
|
31
|
+
* The one pipeline whose capability set is exactly `capabilities`.
|
|
32
|
+
*
|
|
33
|
+
* @throws {PipelineSelectionError} if none matches, or more than one does —
|
|
34
|
+
* an ambiguous match is a set whose matrix has two pipelines with the same
|
|
35
|
+
* capabilities, which is a question for the builder, not something to
|
|
36
|
+
* resolve by picking the first.
|
|
37
|
+
*/
|
|
38
|
+
export declare function resolvePipeline(registry: Registry, capabilities: Iterable<string>): RegistryEntry;
|
|
39
|
+
/** Every pipeline carrying all of `capabilities`, whatever else it carries. */
|
|
40
|
+
export declare function withCapabilities(entries: readonly RegistryEntry[], capabilities: Iterable<string>): RegistryEntry[];
|
|
41
|
+
/**
|
|
42
|
+
* Every tag any of `entries` declares, sorted.
|
|
43
|
+
*
|
|
44
|
+
* For building a chooser: the vocabulary is what the features offer, this is
|
|
45
|
+
* what this set actually reaches.
|
|
46
|
+
*/
|
|
47
|
+
export declare function capabilitiesInUse(entries: readonly RegistryEntry[]): string[];
|
package/package.json
CHANGED
|
@@ -1,6 +1,73 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vcollab/shader-library",
|
|
3
|
-
"version": "
|
|
4
|
-
"
|
|
5
|
-
"
|
|
3
|
+
"version": "2.0.0",
|
|
4
|
+
"description": "Runtime consumer of the VCollab shader artifact set: pipeline selection, std140 packing, and resource binding",
|
|
5
|
+
"author": "Visual Collaboration Technologies Inc.",
|
|
6
|
+
"license": "SEE LICENSE IN LICENSE",
|
|
7
|
+
"type": "module",
|
|
8
|
+
"sideEffects": false,
|
|
9
|
+
"main": "./dist/index.cjs",
|
|
10
|
+
"module": "./dist/index.js",
|
|
11
|
+
"types": "./dist/index.d.ts",
|
|
12
|
+
"exports": {
|
|
13
|
+
".": {
|
|
14
|
+
"types": "./dist/index.d.ts",
|
|
15
|
+
"import": "./dist/index.js",
|
|
16
|
+
"require": "./dist/index.cjs"
|
|
17
|
+
},
|
|
18
|
+
"./bundled": {
|
|
19
|
+
"types": "./dist/bundled.d.ts",
|
|
20
|
+
"import": "./dist/bundled.js",
|
|
21
|
+
"require": "./dist/bundled.cjs"
|
|
22
|
+
},
|
|
23
|
+
"./derived": {
|
|
24
|
+
"types": "./dist/derived/index.d.ts",
|
|
25
|
+
"import": "./dist/derived/index.js",
|
|
26
|
+
"require": "./dist/derived/index.cjs"
|
|
27
|
+
},
|
|
28
|
+
"./package.json": "./package.json"
|
|
29
|
+
},
|
|
30
|
+
"files": [
|
|
31
|
+
"dist",
|
|
32
|
+
"README.md",
|
|
33
|
+
"CHANGELOG.md",
|
|
34
|
+
"LICENSE"
|
|
35
|
+
],
|
|
36
|
+
"engines": {
|
|
37
|
+
"node": ">=22"
|
|
38
|
+
},
|
|
39
|
+
"publishConfig": {
|
|
40
|
+
"access": "public",
|
|
41
|
+
"provenance": false
|
|
42
|
+
},
|
|
43
|
+
"keywords": [
|
|
44
|
+
"shader",
|
|
45
|
+
"glsl",
|
|
46
|
+
"webgl2",
|
|
47
|
+
"cae",
|
|
48
|
+
"fringe",
|
|
49
|
+
"vcollab"
|
|
50
|
+
],
|
|
51
|
+
"dependencies": {
|
|
52
|
+
"@vcollab/shader-artifacts": "^2.0.0"
|
|
53
|
+
},
|
|
54
|
+
"devDependencies": {
|
|
55
|
+
"@types/node": "^26.6.1",
|
|
56
|
+
"@vitest/coverage-v8": "^5.0.1",
|
|
57
|
+
"rimraf": "^6.0.0",
|
|
58
|
+
"tsup": "^8.3.6",
|
|
59
|
+
"typescript": "^7.0.2",
|
|
60
|
+
"vitest": "^5.0.1"
|
|
61
|
+
},
|
|
62
|
+
"scripts": {
|
|
63
|
+
"build": "tsup && tsc -p tsconfig.build.json",
|
|
64
|
+
"typecheck": "tsc --noEmit",
|
|
65
|
+
"lint": "biome check .",
|
|
66
|
+
"lint:fix": "biome check --write .",
|
|
67
|
+
"format": "biome format --write .",
|
|
68
|
+
"test": "vitest run",
|
|
69
|
+
"test:watch": "vitest",
|
|
70
|
+
"coverage": "vitest run --coverage",
|
|
71
|
+
"clean": "rimraf dist"
|
|
72
|
+
}
|
|
6
73
|
}
|