@forgeax/engine-render-graph 0.1.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/LICENSE +202 -0
- package/README.md +184 -0
- package/dist/.tsbuildinfo +1 -0
- package/dist/__tests__/graph-pass-kind-owner.test-d.d.ts +2 -0
- package/dist/__tests__/graph-pass-kind-owner.test-d.d.ts.map +1 -0
- package/dist/__tests__/observation-lifetime-state-owner.test-d.d.ts +2 -0
- package/dist/__tests__/observation-lifetime-state-owner.test-d.d.ts.map +1 -0
- package/dist/__tests__/observation.unit.test.d.ts +2 -0
- package/dist/__tests__/observation.unit.test.d.ts.map +1 -0
- package/dist/__tests__/render-graph-alias-source.unit.test.d.ts +2 -0
- package/dist/__tests__/render-graph-alias-source.unit.test.d.ts.map +1 -0
- package/dist/__tests__/render-graph-builder.unit.test.d.ts +2 -0
- package/dist/__tests__/render-graph-builder.unit.test.d.ts.map +1 -0
- package/dist/__tests__/render-graph-capability-owner.test-d.d.ts +2 -0
- package/dist/__tests__/render-graph-capability-owner.test-d.d.ts.map +1 -0
- package/dist/__tests__/render-graph-errors.test-d.d.ts +2 -0
- package/dist/__tests__/render-graph-errors.test-d.d.ts.map +1 -0
- package/dist/__tests__/render-graph-regressions.unit.test.d.ts +2 -0
- package/dist/__tests__/render-graph-regressions.unit.test.d.ts.map +1 -0
- package/dist/__tests__/render-graph-rhi-null.integration.test.d.ts +2 -0
- package/dist/__tests__/render-graph-rhi-null.integration.test.d.ts.map +1 -0
- package/dist/__tests__/render-graph.unit.test.d.ts +2 -0
- package/dist/__tests__/render-graph.unit.test.d.ts.map +1 -0
- package/dist/__tests__/resource-declaration-collision.test.d.ts +2 -0
- package/dist/__tests__/resource-declaration-collision.test.d.ts.map +1 -0
- package/dist/__tests__/resource-kind-owner.test-d.d.ts +2 -0
- package/dist/__tests__/resource-kind-owner.test-d.d.ts.map +1 -0
- package/dist/builder.d.ts +42 -0
- package/dist/builder.d.ts.map +1 -0
- package/dist/compiled-graph.d.ts +23 -0
- package/dist/compiled-graph.d.ts.map +1 -0
- package/dist/errors.d.ts +148 -0
- package/dist/errors.d.ts.map +1 -0
- package/dist/graph.d.ts +404 -0
- package/dist/graph.d.ts.map +1 -0
- package/dist/index.d.ts +8 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.mjs +2256 -0
- package/dist/index.mjs.map +1 -0
- package/dist/kernel-internal.d.ts +84 -0
- package/dist/kernel-internal.d.ts.map +1 -0
- package/dist/observation.d.ts +38 -0
- package/dist/observation.d.ts.map +1 -0
- package/dist/pass-registry.d.ts +12 -0
- package/dist/pass-registry.d.ts.map +1 -0
- package/dist/pipeline/__tests__/color-value-domain.test.d.ts +2 -0
- package/dist/pipeline/__tests__/color-value-domain.test.d.ts.map +1 -0
- package/dist/pipeline/color-value-domain.d.ts +35 -0
- package/dist/pipeline/color-value-domain.d.ts.map +1 -0
- package/dist/resource-registry.d.ts +61 -0
- package/dist/resource-registry.d.ts.map +1 -0
- package/dist/types.d.ts +171 -0
- package/dist/types.d.ts.map +1 -0
- package/package.json +61 -0
- package/src/__tests__/graph-pass-kind-owner.test-d.ts +35 -0
- package/src/__tests__/observation-lifetime-state-owner.test-d.ts +39 -0
- package/src/__tests__/observation.unit.test.ts +103 -0
- package/src/__tests__/render-graph-alias-source.unit.test.ts +118 -0
- package/src/__tests__/render-graph-builder.unit.test.ts +664 -0
- package/src/__tests__/render-graph-capability-owner.test-d.ts +32 -0
- package/src/__tests__/render-graph-errors.test-d.ts +169 -0
- package/src/__tests__/render-graph-regressions.unit.test.ts +126 -0
- package/src/__tests__/render-graph-rhi-null.integration.test.ts +86 -0
- package/src/__tests__/render-graph.unit.test.ts +2549 -0
- package/src/__tests__/resource-declaration-collision.test.ts +151 -0
- package/src/__tests__/resource-kind-owner.test-d.ts +38 -0
- package/src/builder.ts +1009 -0
- package/src/compiled-graph.ts +383 -0
- package/src/errors.ts +205 -0
- package/src/graph.ts +1270 -0
- package/src/index.ts +97 -0
- package/src/kernel-internal.ts +148 -0
- package/src/observation.ts +134 -0
- package/src/pass-registry.ts +43 -0
- package/src/pipeline/__tests__/color-value-domain.test.ts +43 -0
- package/src/pipeline/color-value-domain.ts +139 -0
- package/src/resource-registry.ts +173 -0
- package/src/types.ts +217 -0
|
@@ -0,0 +1,173 @@
|
|
|
1
|
+
// @forgeax/engine-render-graph/src/resource-registry.ts — resource
|
|
2
|
+
// declaration registry (plan-strategy 3.1).
|
|
3
|
+
//
|
|
4
|
+
// Shape (D-4/D-6.1):
|
|
5
|
+
// - string key -> ResourceDescriptor + bufferRole + lifetime
|
|
6
|
+
// - duplicate-resource fail-fast across every declaration form
|
|
7
|
+
// - unknown-resource fail-fast at pass binding time
|
|
8
|
+
// - addColorTarget: color target registration with format/size/sample/usage
|
|
9
|
+
|
|
10
|
+
import {
|
|
11
|
+
type AliasSourceDetail,
|
|
12
|
+
type CapMissingDetail,
|
|
13
|
+
type DanglingReadDetail,
|
|
14
|
+
type DuplicateResourceDetail,
|
|
15
|
+
err,
|
|
16
|
+
ok,
|
|
17
|
+
RenderGraphError,
|
|
18
|
+
type Result,
|
|
19
|
+
} from './errors.js';
|
|
20
|
+
import type {
|
|
21
|
+
ColorTargetDescriptor,
|
|
22
|
+
ColorTargetSize,
|
|
23
|
+
ResourceDescriptor,
|
|
24
|
+
ResourceLifetime,
|
|
25
|
+
} from './graph.js';
|
|
26
|
+
import type { ColorValueDomain } from './pipeline/color-value-domain.js';
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* Per-resource GPU allocation metadata carried through compile.
|
|
30
|
+
* When the resource was registered via addColorTarget, colorTarget
|
|
31
|
+
* carries the format/size/sample/usage fields (w5); when via
|
|
32
|
+
* addResource it is undefined.
|
|
33
|
+
*/
|
|
34
|
+
export interface ColorTargetResourceMeta {
|
|
35
|
+
readonly format: string;
|
|
36
|
+
readonly size: ColorTargetSize;
|
|
37
|
+
readonly sample: number;
|
|
38
|
+
readonly usage: number;
|
|
39
|
+
/** Explicit semantic color domain; never derived from format. */
|
|
40
|
+
readonly domain?: ColorValueDomain | undefined;
|
|
41
|
+
/**
|
|
42
|
+
* Extra texture view formats pre-declared at GPU texture creation. Mirrors
|
|
43
|
+
* GPUTextureDescriptor.viewFormats. Used by the LDR MSAA path which needs a
|
|
44
|
+
* `bgra8unorm` storage texture plus a `bgra8unorm-srgb` view of the same
|
|
45
|
+
* texture for hardware sRGB encoding on store.
|
|
46
|
+
*/
|
|
47
|
+
readonly viewFormats?: readonly string[] | undefined;
|
|
48
|
+
/**
|
|
49
|
+
* When set, this resource is an alias of the given source resource.
|
|
50
|
+
* The compile allocation phase folds the alias into the source's
|
|
51
|
+
* physical texture (KB-1 MoveNode pattern, D-2).
|
|
52
|
+
*/
|
|
53
|
+
readonly aliasedFrom?: string | undefined;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
export interface ResourceEntry {
|
|
57
|
+
readonly key: string;
|
|
58
|
+
readonly descriptor: ResourceDescriptor;
|
|
59
|
+
readonly lifetime: ResourceLifetime;
|
|
60
|
+
/** Present when the resource was registered via addColorTarget (w5). */
|
|
61
|
+
readonly colorTarget?: ColorTargetResourceMeta | undefined;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
export class ResourceRegistry {
|
|
65
|
+
private readonly resources = new Map<string, ResourceEntry>();
|
|
66
|
+
|
|
67
|
+
add(key: string, descriptor: ResourceDescriptor): Result<ResourceEntry, RenderGraphError> {
|
|
68
|
+
const entry: ResourceEntry = {
|
|
69
|
+
key,
|
|
70
|
+
descriptor,
|
|
71
|
+
lifetime: descriptor.lifetime,
|
|
72
|
+
};
|
|
73
|
+
return this.register(entry);
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
/**
|
|
77
|
+
* Register a color target resource (D-8).
|
|
78
|
+
* Same semantics as addResource with kind:'texture' plus GPU texture
|
|
79
|
+
* allocation metadata. Existing callers default to a transient target.
|
|
80
|
+
*/
|
|
81
|
+
addColorTarget(
|
|
82
|
+
name: string,
|
|
83
|
+
desc: ColorTargetDescriptor,
|
|
84
|
+
): Result<ResourceEntry, RenderGraphError> {
|
|
85
|
+
const lifetime = desc.lifetime ?? 'transient';
|
|
86
|
+
const colorTargetMeta: ColorTargetResourceMeta = {
|
|
87
|
+
format: desc.format,
|
|
88
|
+
size: desc.size,
|
|
89
|
+
sample: desc.sample ?? 1,
|
|
90
|
+
usage: desc.usage ?? 0x10 | 0x04, // RENDER_ATTACHMENT | TEXTURE_BINDING
|
|
91
|
+
...(desc.domain !== undefined ? { domain: desc.domain } : {}),
|
|
92
|
+
...(desc.viewFormats !== undefined ? { viewFormats: desc.viewFormats } : {}),
|
|
93
|
+
};
|
|
94
|
+
const entry: ResourceEntry = {
|
|
95
|
+
key: name,
|
|
96
|
+
descriptor: { kind: 'texture', lifetime },
|
|
97
|
+
lifetime,
|
|
98
|
+
colorTarget: colorTargetMeta,
|
|
99
|
+
};
|
|
100
|
+
return this.register(entry);
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
/**
|
|
104
|
+
* Register a color target alias that folds into the source's physical
|
|
105
|
+
* texture at compile time (KB-1 MoveNode pattern, D-2).
|
|
106
|
+
* The source must already be registered via addColorTarget.
|
|
107
|
+
*/
|
|
108
|
+
addColorTargetAlias(name: string, source: string): Result<ResourceEntry, RenderGraphError> {
|
|
109
|
+
if (this.resources.has(name)) return this.duplicateResource(name);
|
|
110
|
+
const sourceMeta = this.resources.get(source)?.colorTarget;
|
|
111
|
+
if (sourceMeta === undefined) {
|
|
112
|
+
return err(
|
|
113
|
+
new RenderGraphError({
|
|
114
|
+
code: 'alias-source-missing',
|
|
115
|
+
expected: `alias '${name}' source '${source}' must be a registered color target`,
|
|
116
|
+
hint: `call addColorTarget('${source}', ...) before retrying alias '${name}'`,
|
|
117
|
+
detail: { aliasKey: name, sourceKey: source } satisfies AliasSourceDetail,
|
|
118
|
+
}),
|
|
119
|
+
);
|
|
120
|
+
}
|
|
121
|
+
const entry: ResourceEntry = {
|
|
122
|
+
key: name,
|
|
123
|
+
descriptor: { kind: 'texture', lifetime: 'transient' },
|
|
124
|
+
lifetime: 'transient',
|
|
125
|
+
colorTarget: {
|
|
126
|
+
format: sourceMeta.format,
|
|
127
|
+
size: sourceMeta.size,
|
|
128
|
+
sample: sourceMeta.sample,
|
|
129
|
+
usage: sourceMeta.usage,
|
|
130
|
+
...(sourceMeta.domain !== undefined ? { domain: sourceMeta.domain } : {}),
|
|
131
|
+
...(sourceMeta.viewFormats !== undefined ? { viewFormats: sourceMeta.viewFormats } : {}),
|
|
132
|
+
aliasedFrom: source,
|
|
133
|
+
},
|
|
134
|
+
};
|
|
135
|
+
return this.register(entry);
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
private duplicateResource(key: string): Result<ResourceEntry, RenderGraphError> {
|
|
139
|
+
return err(
|
|
140
|
+
new RenderGraphError({
|
|
141
|
+
code: 'duplicate-resource',
|
|
142
|
+
expected: `resource key '${key}' registered exactly once`,
|
|
143
|
+
hint: `remove the duplicate resource declaration for '${key}' or use a different key`,
|
|
144
|
+
detail: { resourceKey: key } satisfies DuplicateResourceDetail,
|
|
145
|
+
}),
|
|
146
|
+
);
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
private register(entry: ResourceEntry): Result<ResourceEntry, RenderGraphError> {
|
|
150
|
+
if (this.resources.has(entry.key)) return this.duplicateResource(entry.key);
|
|
151
|
+
this.resources.set(entry.key, entry);
|
|
152
|
+
return ok(entry);
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
get(key: string): ResourceEntry | undefined {
|
|
156
|
+
return this.resources.get(key);
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
getColorTargetMeta(key: string): ColorTargetResourceMeta | undefined {
|
|
160
|
+
return this.resources.get(key)?.colorTarget;
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
has(key: string): boolean {
|
|
164
|
+
return this.resources.has(key);
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
entries(): IterableIterator<ResourceEntry> {
|
|
168
|
+
return this.resources.values();
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
// Re-export detail types for use by graph.ts compile fail-fast.
|
|
173
|
+
export type { CapMissingDetail, DanglingReadDetail, DuplicateResourceDetail };
|
package/src/types.ts
ADDED
|
@@ -0,0 +1,217 @@
|
|
|
1
|
+
import type {
|
|
2
|
+
Buffer,
|
|
3
|
+
ComputePassDescriptor,
|
|
4
|
+
RhiCommandEncoder,
|
|
5
|
+
RhiComputePassEncoder,
|
|
6
|
+
RhiDevice,
|
|
7
|
+
RhiRenderPassEncoder,
|
|
8
|
+
Texture,
|
|
9
|
+
TextureFormat,
|
|
10
|
+
TextureView,
|
|
11
|
+
} from '@forgeax/engine-rhi';
|
|
12
|
+
import type { RenderGraphError, Result } from './errors.js';
|
|
13
|
+
|
|
14
|
+
declare const graphTextureBrand: unique symbol;
|
|
15
|
+
declare const graphTextureViewBrand: unique symbol;
|
|
16
|
+
declare const graphBufferBrand: unique symbol;
|
|
17
|
+
|
|
18
|
+
export interface GraphTexture {
|
|
19
|
+
readonly [graphTextureBrand]: true;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export interface GraphTextureView {
|
|
23
|
+
readonly [graphTextureViewBrand]: true;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
export interface GraphBuffer {
|
|
27
|
+
readonly [graphBufferBrand]: true;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
export type GraphResource = GraphTexture | GraphTextureView | GraphBuffer;
|
|
31
|
+
export type GraphResourceOrigin = 'created' | 'imported';
|
|
32
|
+
export type GraphResourceKind = 'texture' | 'buffer';
|
|
33
|
+
|
|
34
|
+
export type GraphExtent =
|
|
35
|
+
| 'surface'
|
|
36
|
+
| 'half-surface'
|
|
37
|
+
| {
|
|
38
|
+
readonly width: number;
|
|
39
|
+
readonly height: number;
|
|
40
|
+
readonly depthOrArrayLayers?: number | undefined;
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
export interface GraphTextureDescriptor {
|
|
44
|
+
readonly format: TextureFormat;
|
|
45
|
+
readonly size: GraphExtent;
|
|
46
|
+
readonly mipLevelCount?: number | undefined;
|
|
47
|
+
readonly sampleCount?: number | undefined;
|
|
48
|
+
readonly dimension?: GPUTextureDimension | undefined;
|
|
49
|
+
readonly viewFormats?: readonly TextureFormat[] | undefined;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
export interface ImportedTextureDescriptor extends GraphTextureDescriptor {
|
|
53
|
+
readonly usage: number;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
export interface GraphTextureViewDescriptor {
|
|
57
|
+
readonly label?: string | undefined;
|
|
58
|
+
readonly format?: TextureFormat | undefined;
|
|
59
|
+
readonly dimension?: GPUTextureViewDimension | undefined;
|
|
60
|
+
readonly aspect?: GPUTextureAspect | undefined;
|
|
61
|
+
readonly baseMipLevel?: number | undefined;
|
|
62
|
+
readonly mipLevelCount?: number | undefined;
|
|
63
|
+
readonly baseArrayLayer?: number | undefined;
|
|
64
|
+
readonly arrayLayerCount?: number | undefined;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
export type ImportedTextureViewResolver<FrameCtx> = (frame: FrameCtx) => TextureView;
|
|
68
|
+
|
|
69
|
+
export interface GraphBufferDescriptor {
|
|
70
|
+
readonly size: number;
|
|
71
|
+
readonly mappedAtCreation?: boolean | undefined;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
export interface ImportedBufferDescriptor extends GraphBufferDescriptor {
|
|
75
|
+
readonly usage: number;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
export type GraphBufferAccess =
|
|
79
|
+
| 'uniform-read'
|
|
80
|
+
| 'storage-read'
|
|
81
|
+
| 'storage-write'
|
|
82
|
+
| 'storage-read-write'
|
|
83
|
+
| 'indirect-read'
|
|
84
|
+
| 'vertex-read'
|
|
85
|
+
| 'index-read'
|
|
86
|
+
| 'copy-src'
|
|
87
|
+
| 'copy-dst';
|
|
88
|
+
|
|
89
|
+
export type GraphTextureAccess =
|
|
90
|
+
| 'sampled-read'
|
|
91
|
+
| 'storage-read'
|
|
92
|
+
| 'storage-write'
|
|
93
|
+
| 'storage-read-write'
|
|
94
|
+
| 'color-attachment'
|
|
95
|
+
| 'depth-stencil-read'
|
|
96
|
+
| 'depth-stencil-write'
|
|
97
|
+
| 'copy-src'
|
|
98
|
+
| 'copy-dst';
|
|
99
|
+
|
|
100
|
+
export type GraphAccess =
|
|
101
|
+
| { readonly resource: GraphBuffer; readonly usage: GraphBufferAccess }
|
|
102
|
+
| { readonly resource: GraphTextureView; readonly usage: GraphTextureAccess };
|
|
103
|
+
|
|
104
|
+
export interface GraphResourceResolver {
|
|
105
|
+
buffer(resource: GraphBuffer): Result<Buffer, RenderGraphError>;
|
|
106
|
+
texture(resource: GraphTexture): Result<Texture, RenderGraphError>;
|
|
107
|
+
textureView(resource: GraphTextureView): Result<TextureView, RenderGraphError>;
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
export interface RasterColorAttachment<FrameCtx> {
|
|
111
|
+
readonly view: GraphTextureView;
|
|
112
|
+
readonly resolveTarget?: GraphTextureView | undefined;
|
|
113
|
+
readonly clearValue?: GPUColor | ((frame: FrameCtx) => GPUColor) | undefined;
|
|
114
|
+
readonly loadOp: GPULoadOp;
|
|
115
|
+
readonly storeOp: GPUStoreOp;
|
|
116
|
+
readonly depthSlice?: number | undefined;
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
export interface RasterDepthStencilAttachment {
|
|
120
|
+
readonly view: GraphTextureView;
|
|
121
|
+
readonly depthClearValue?: number | undefined;
|
|
122
|
+
readonly depthLoadOp?: GPULoadOp | undefined;
|
|
123
|
+
readonly depthStoreOp?: GPUStoreOp | undefined;
|
|
124
|
+
readonly depthReadOnly?: boolean | undefined;
|
|
125
|
+
readonly stencilClearValue?: number | undefined;
|
|
126
|
+
readonly stencilLoadOp?: GPULoadOp | undefined;
|
|
127
|
+
readonly stencilStoreOp?: GPUStoreOp | undefined;
|
|
128
|
+
readonly stencilReadOnly?: boolean | undefined;
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
export interface RasterGraphPass<FrameCtx> {
|
|
132
|
+
readonly accesses: readonly GraphAccess[];
|
|
133
|
+
readonly colorAttachments: readonly RasterColorAttachment<FrameCtx>[];
|
|
134
|
+
readonly depthStencilAttachment?: RasterDepthStencilAttachment | undefined;
|
|
135
|
+
readonly executeIf?: ((frame: FrameCtx) => boolean) | undefined;
|
|
136
|
+
encode(context: {
|
|
137
|
+
readonly pass: RhiRenderPassEncoder;
|
|
138
|
+
readonly frame: FrameCtx;
|
|
139
|
+
readonly resources: GraphResourceResolver;
|
|
140
|
+
}): void;
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
export interface ComputeGraphPass<FrameCtx> {
|
|
144
|
+
readonly accesses: readonly GraphAccess[];
|
|
145
|
+
readonly executeIf?: ((frame: FrameCtx) => boolean) | undefined;
|
|
146
|
+
readonly begin?: ((frame: FrameCtx) => ComputePassDescriptor) | undefined;
|
|
147
|
+
readonly onBeginError?: ((frame: FrameCtx, cause: unknown) => void) | undefined;
|
|
148
|
+
encode(context: {
|
|
149
|
+
readonly pass: RhiComputePassEncoder;
|
|
150
|
+
readonly frame: FrameCtx;
|
|
151
|
+
readonly resources: GraphResourceResolver;
|
|
152
|
+
}): void;
|
|
153
|
+
readonly after?: ((frame: FrameCtx) => void) | undefined;
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
export interface CopyGraphPass<FrameCtx> {
|
|
157
|
+
readonly accesses: readonly GraphAccess[];
|
|
158
|
+
readonly executeIf?: ((frame: FrameCtx) => boolean) | undefined;
|
|
159
|
+
encode(context: {
|
|
160
|
+
readonly encoder: RhiCommandEncoder;
|
|
161
|
+
readonly frame: FrameCtx;
|
|
162
|
+
readonly resources: GraphResourceResolver;
|
|
163
|
+
}): void;
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
export type GraphPass<FrameCtx> =
|
|
167
|
+
| { readonly kind: 'raster'; readonly descriptor: RasterGraphPass<FrameCtx> }
|
|
168
|
+
| { readonly kind: 'compute'; readonly descriptor: ComputeGraphPass<FrameCtx> }
|
|
169
|
+
| { readonly kind: 'copy'; readonly descriptor: CopyGraphPass<FrameCtx> };
|
|
170
|
+
|
|
171
|
+
export type GraphPassKind = GraphPass<unknown>['kind'];
|
|
172
|
+
|
|
173
|
+
export interface GraphAccessInfo {
|
|
174
|
+
readonly resource: string;
|
|
175
|
+
readonly usage: GraphBufferAccess | GraphTextureAccess;
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
export interface CompiledRenderGraphInfo {
|
|
179
|
+
readonly passes: readonly {
|
|
180
|
+
readonly name: string;
|
|
181
|
+
readonly kind: GraphPassKind;
|
|
182
|
+
readonly executionIndex: number;
|
|
183
|
+
readonly accesses: readonly GraphAccessInfo[];
|
|
184
|
+
readonly dependencies: readonly string[];
|
|
185
|
+
}[];
|
|
186
|
+
readonly resources: readonly {
|
|
187
|
+
readonly label: string;
|
|
188
|
+
readonly kind: GraphResourceKind;
|
|
189
|
+
readonly origin: GraphResourceOrigin;
|
|
190
|
+
readonly firstUse: number | null;
|
|
191
|
+
readonly lastUse: number | null;
|
|
192
|
+
readonly derivedUsage: number;
|
|
193
|
+
}[];
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
export interface RenderGraphFrame {
|
|
197
|
+
readonly encoder: RhiCommandEncoder;
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
export interface RenderGraphPassExecution {
|
|
201
|
+
readonly name: string;
|
|
202
|
+
readonly kind: GraphPassKind;
|
|
203
|
+
readonly executionIndex: number;
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
export type RenderGraphPassRunner = (pass: RenderGraphPassExecution, encode: () => void) => void;
|
|
207
|
+
|
|
208
|
+
export interface RenderGraphCompileOptions {
|
|
209
|
+
readonly device: RhiDevice;
|
|
210
|
+
readonly surfaceSize: { readonly width: number; readonly height: number };
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
export interface CompiledRenderGraph<FrameCtx extends RenderGraphFrame> {
|
|
214
|
+
execute(frame: FrameCtx, runPass?: RenderGraphPassRunner): Result<void, RenderGraphError>;
|
|
215
|
+
inspect(): CompiledRenderGraphInfo;
|
|
216
|
+
retire(): Promise<Result<void, RenderGraphError>>;
|
|
217
|
+
}
|