@forgeax/engine-render-graph 0.1.6 → 0.1.19
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/dist/.tsbuildinfo +1 -1
- package/dist/builder.d.ts.map +1 -1
- package/dist/compiled-graph.d.ts +7 -2
- package/dist/compiled-graph.d.ts.map +1 -1
- package/dist/errors.d.ts +14 -0
- package/dist/errors.d.ts.map +1 -1
- package/dist/index.d.ts +2 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.mjs +63 -3
- package/dist/index.mjs.map +1 -1
- package/dist/types.d.ts +23 -0
- package/dist/types.d.ts.map +1 -1
- package/package.json +4 -4
- package/src/__tests__/render-graph-builder.unit.test.ts +32 -1
- package/src/__tests__/render-graph.unit.test.ts +15 -0
- package/src/builder.ts +53 -1
- package/src/compiled-graph.ts +21 -0
- package/src/errors.ts +22 -0
- package/src/index.ts +4 -0
- package/src/pipeline/__tests__/color-value-domain.test.ts +8 -0
- package/src/types.ts +26 -0
package/dist/types.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { Buffer, ComputePassDescriptor, RhiCommandEncoder, RhiComputePassEncoder, RhiDevice, RhiRenderPassEncoder, Texture, TextureFormat, TextureView } from '@forgeax/engine-rhi';
|
|
2
2
|
import type { RenderGraphError, Result } from './errors.js';
|
|
3
|
+
import type { ColorValueDomain } from './pipeline/color-value-domain.js';
|
|
3
4
|
declare const graphTextureBrand: unique symbol;
|
|
4
5
|
declare const graphTextureViewBrand: unique symbol;
|
|
5
6
|
declare const graphBufferBrand: unique symbol;
|
|
@@ -24,10 +25,14 @@ export type GraphExtent = 'surface' | 'half-surface' | {
|
|
|
24
25
|
export interface GraphTextureDescriptor {
|
|
25
26
|
readonly format: TextureFormat;
|
|
26
27
|
readonly size: GraphExtent;
|
|
28
|
+
/** Additional RHI usage required by an external diagnostic consumer. */
|
|
29
|
+
readonly usage?: number | undefined;
|
|
27
30
|
readonly mipLevelCount?: number | undefined;
|
|
28
31
|
readonly sampleCount?: number | undefined;
|
|
29
32
|
readonly dimension?: GPUTextureDimension | undefined;
|
|
30
33
|
readonly viewFormats?: readonly TextureFormat[] | undefined;
|
|
34
|
+
/** Explicit semantic color domain; never inferred from the attachment format. */
|
|
35
|
+
readonly domain?: ColorValueDomain | undefined;
|
|
31
36
|
}
|
|
32
37
|
export interface ImportedTextureDescriptor extends GraphTextureDescriptor {
|
|
33
38
|
readonly usage: number;
|
|
@@ -129,6 +134,23 @@ export interface GraphAccessInfo {
|
|
|
129
134
|
readonly resource: string;
|
|
130
135
|
readonly usage: GraphBufferAccess | GraphTextureAccess;
|
|
131
136
|
}
|
|
137
|
+
/** Detached physical allocation facts for one compiled graph resource. */
|
|
138
|
+
export type CompiledResourceDescriptor = {
|
|
139
|
+
readonly kind: 'texture';
|
|
140
|
+
readonly format: TextureFormat;
|
|
141
|
+
/** Explicit semantic color domain retained in detached graph facts. */
|
|
142
|
+
readonly domain?: ColorValueDomain | undefined;
|
|
143
|
+
/** Authored extent retained so consumers can validate the allocation contract. */
|
|
144
|
+
readonly size: GraphExtent;
|
|
145
|
+
readonly width: number;
|
|
146
|
+
readonly height: number;
|
|
147
|
+
readonly depthOrArrayLayers: number;
|
|
148
|
+
readonly mipLevelCount: number;
|
|
149
|
+
readonly sampleCount: number;
|
|
150
|
+
} | {
|
|
151
|
+
readonly kind: 'buffer';
|
|
152
|
+
readonly size: number;
|
|
153
|
+
};
|
|
132
154
|
export interface CompiledRenderGraphInfo {
|
|
133
155
|
readonly passes: readonly {
|
|
134
156
|
readonly name: string;
|
|
@@ -141,6 +163,7 @@ export interface CompiledRenderGraphInfo {
|
|
|
141
163
|
readonly label: string;
|
|
142
164
|
readonly kind: GraphResourceKind;
|
|
143
165
|
readonly origin: GraphResourceOrigin;
|
|
166
|
+
readonly descriptor: CompiledResourceDescriptor;
|
|
144
167
|
readonly firstUse: number | null;
|
|
145
168
|
readonly lastUse: number | null;
|
|
146
169
|
readonly derivedUsage: number;
|
package/dist/types.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,MAAM,EACN,qBAAqB,EACrB,iBAAiB,EACjB,qBAAqB,EACrB,SAAS,EACT,oBAAoB,EACpB,OAAO,EACP,aAAa,EACb,WAAW,EACZ,MAAM,qBAAqB,CAAC;AAC7B,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,MAAM,EACN,qBAAqB,EACrB,iBAAiB,EACjB,qBAAqB,EACrB,SAAS,EACT,oBAAoB,EACpB,OAAO,EACP,aAAa,EACb,WAAW,EACZ,MAAM,qBAAqB,CAAC;AAC7B,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAC5D,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,kCAAkC,CAAC;AAEzE,OAAO,CAAC,MAAM,iBAAiB,EAAE,OAAO,MAAM,CAAC;AAC/C,OAAO,CAAC,MAAM,qBAAqB,EAAE,OAAO,MAAM,CAAC;AACnD,OAAO,CAAC,MAAM,gBAAgB,EAAE,OAAO,MAAM,CAAC;AAE9C,MAAM,WAAW,YAAY;IAC3B,QAAQ,CAAC,CAAC,iBAAiB,CAAC,EAAE,IAAI,CAAC;CACpC;AAED,MAAM,WAAW,gBAAgB;IAC/B,QAAQ,CAAC,CAAC,qBAAqB,CAAC,EAAE,IAAI,CAAC;CACxC;AAED,MAAM,WAAW,WAAW;IAC1B,QAAQ,CAAC,CAAC,gBAAgB,CAAC,EAAE,IAAI,CAAC;CACnC;AAED,MAAM,MAAM,aAAa,GAAG,YAAY,GAAG,gBAAgB,GAAG,WAAW,CAAC;AAC1E,MA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,CAAC,IAAI,EAAE,aAAa,CAAC;IAC7B,QAAQ,CAAC,cAAc,EAAE,MAAM,CAAC;CACjC;AAED,MAAM,MAAM,qBAAqB,GAAG,CAAC,IAAI,EAAE,wBAAwB,EAAE,MAAM,EAAE,MAAM,IAAI,KAAK,IAAI,CAAC;AAEjG,MAAM,WAAW,yBAAyB;IACxC,QAAQ,CAAC,MAAM,EAAE,SAAS,CAAC;IAC3B,QAAQ,CAAC,WAAW,EAAE;QAAE,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;QAAC,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAA;KAAE,CAAC;CAC3E;AAED,MAAM,WAAW,mBAAmB,CAAC,QAAQ,SAAS,gBAAgB;IACpE,OAAO,CAAC,KAAK,EAAE,QAAQ,EAAE,OAAO,CAAC,EAAE,qBAAqB,GAAG,MAAM,CAAC,IAAI,EAAE,gBAAgB,CAAC,CAAC;IAC1F,OAAO,IAAI,uBAAuB,CAAC;IACnC,MAAM,IAAI,OAAO,CAAC,MAAM,CAAC,IAAI,EAAE,gBAAgB,CAAC,CAAC,CAAC;CACnD"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@forgeax/engine-render-graph",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.19",
|
|
4
4
|
"private": false,
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -22,12 +22,12 @@
|
|
|
22
22
|
"LICENSE"
|
|
23
23
|
],
|
|
24
24
|
"dependencies": {
|
|
25
|
-
"@forgeax/engine-rhi": "0.1.
|
|
26
|
-
"@forgeax/engine-types": "0.1.
|
|
25
|
+
"@forgeax/engine-rhi": "0.1.19",
|
|
26
|
+
"@forgeax/engine-types": "0.1.19",
|
|
27
27
|
"@webgpu/types": "^0.1.71"
|
|
28
28
|
},
|
|
29
29
|
"devDependencies": {
|
|
30
|
-
"@forgeax/engine-rhi-null": "0.1.
|
|
30
|
+
"@forgeax/engine-rhi-null": "0.1.19"
|
|
31
31
|
},
|
|
32
32
|
"forgeax": {
|
|
33
33
|
"metrics": {
|
|
@@ -121,6 +121,37 @@ describe('RenderGraphBuilder resource and temporal contracts', () => {
|
|
|
121
121
|
if (compiled.ok) expect(compiled.value.inspect().passes).toEqual([]);
|
|
122
122
|
});
|
|
123
123
|
|
|
124
|
+
it('deep freezes compiled texture extent objects', () => {
|
|
125
|
+
const graph = new RenderGraphBuilder<Frame>();
|
|
126
|
+
const texture = value(
|
|
127
|
+
graph.createTexture('sized', {
|
|
128
|
+
format: 'rgba8unorm',
|
|
129
|
+
size: { width: 7, height: 5, depthOrArrayLayers: 2 },
|
|
130
|
+
}),
|
|
131
|
+
);
|
|
132
|
+
const view = graph.view(texture).unwrap();
|
|
133
|
+
graph.addRasterPass('write-sized', {
|
|
134
|
+
accesses: [{ resource: view, usage: 'color-attachment' }],
|
|
135
|
+
colorAttachments: [{ view, loadOp: 'clear', storeOp: 'store' }],
|
|
136
|
+
encode: () => undefined,
|
|
137
|
+
});
|
|
138
|
+
const compiled = graph.compile({ device: mockDevice(), surfaceSize: { width: 1, height: 1 } });
|
|
139
|
+
expect(compiled.ok).toBe(true);
|
|
140
|
+
if (!compiled.ok) return;
|
|
141
|
+
const resource = compiled.value.inspect().resources.find(({ label }) => label === 'sized');
|
|
142
|
+
expect(resource).toBeDefined();
|
|
143
|
+
if (resource?.descriptor.kind !== 'texture') return;
|
|
144
|
+
expect(Object.isFrozen(resource.descriptor)).toBe(true);
|
|
145
|
+
expect(Object.isFrozen(resource.descriptor.size)).toBe(true);
|
|
146
|
+
const snapshot = JSON.stringify(resource);
|
|
147
|
+
try {
|
|
148
|
+
(resource.descriptor.size as { width: number }).width = 99;
|
|
149
|
+
} catch {
|
|
150
|
+
// Frozen snapshots reject mutation in strict mode.
|
|
151
|
+
}
|
|
152
|
+
expect(JSON.stringify(resource)).toBe(snapshot);
|
|
153
|
+
});
|
|
154
|
+
|
|
124
155
|
it('accepts imported first-read and rejects graph-created first-read', () => {
|
|
125
156
|
const importedGraph = new RenderGraphBuilder<Frame>();
|
|
126
157
|
const imported = value(
|
|
@@ -234,7 +265,7 @@ describe('RenderGraphBuilder resource and temporal contracts', () => {
|
|
|
234
265
|
const encoder = {
|
|
235
266
|
...mockEncoder(),
|
|
236
267
|
beginRenderPass: (descriptor: GPURenderPassDescriptor) => {
|
|
237
|
-
clearValue = descriptor.colorAttachments[0]?.clearValue;
|
|
268
|
+
clearValue = Array.from(descriptor.colorAttachments)[0]?.clearValue;
|
|
238
269
|
return { end: () => undefined } as never;
|
|
239
270
|
},
|
|
240
271
|
} as unknown as RhiCommandEncoder;
|
|
@@ -99,6 +99,21 @@ import { RenderGraph } from '../graph.js';
|
|
|
99
99
|
const result = graph.compile({ backendKind: 'null', caps });
|
|
100
100
|
expect(result.ok).toBe(true);
|
|
101
101
|
});
|
|
102
|
+
|
|
103
|
+
it('preserves explicit domain separately from format and view metadata', () => {
|
|
104
|
+
const graph = graphWithTargets('display-encoded', 'display-encoded');
|
|
105
|
+
graph.addPass('present', {
|
|
106
|
+
reads: ['source'],
|
|
107
|
+
writes: ['destination'],
|
|
108
|
+
colorConnections: [{ source: 'source', destination: 'destination' }],
|
|
109
|
+
} as never);
|
|
110
|
+
const result = graph.compile({ backendKind: 'null', caps });
|
|
111
|
+
expect(result.ok).toBe(true);
|
|
112
|
+
expect(graph.listResources().map((resource) => resource.key)).toEqual([
|
|
113
|
+
'source',
|
|
114
|
+
'destination',
|
|
115
|
+
]);
|
|
116
|
+
});
|
|
102
117
|
});
|
|
103
118
|
|
|
104
119
|
describe('whole-graph retirement', () => {
|
package/src/builder.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { Buffer, RhiCaps, Texture, TextureView } from '@forgeax/engine-rhi';
|
|
2
2
|
import { CompiledRenderGraphImpl } from './compiled-graph.js';
|
|
3
3
|
import { err, ok, RenderGraphError, type Result } from './errors.js';
|
|
4
|
+
import type { ResolvedColorTargetDescriptor } from './graph.js';
|
|
4
5
|
import {
|
|
5
6
|
accessResourceId,
|
|
6
7
|
bufferHandle,
|
|
@@ -17,6 +18,7 @@ import {
|
|
|
17
18
|
import type {
|
|
18
19
|
CompiledRenderGraph,
|
|
19
20
|
CompiledRenderGraphInfo,
|
|
21
|
+
CompiledResourceDescriptor,
|
|
20
22
|
ComputeGraphPass,
|
|
21
23
|
CopyGraphPass,
|
|
22
24
|
GraphAccess,
|
|
@@ -151,6 +153,12 @@ function rangesOverlap(
|
|
|
151
153
|
}
|
|
152
154
|
|
|
153
155
|
function freezeInfo(info: CompiledRenderGraphInfo): CompiledRenderGraphInfo {
|
|
156
|
+
const freezeDescriptor = (descriptor: CompiledResourceDescriptor) => {
|
|
157
|
+
if (descriptor.kind !== 'texture') return Object.freeze({ ...descriptor });
|
|
158
|
+
const size =
|
|
159
|
+
typeof descriptor.size === 'string' ? descriptor.size : Object.freeze({ ...descriptor.size });
|
|
160
|
+
return Object.freeze({ ...descriptor, size });
|
|
161
|
+
};
|
|
154
162
|
return Object.freeze({
|
|
155
163
|
passes: Object.freeze(
|
|
156
164
|
info.passes.map((pass) =>
|
|
@@ -161,7 +169,14 @@ function freezeInfo(info: CompiledRenderGraphInfo): CompiledRenderGraphInfo {
|
|
|
161
169
|
}),
|
|
162
170
|
),
|
|
163
171
|
),
|
|
164
|
-
resources: Object.freeze(
|
|
172
|
+
resources: Object.freeze(
|
|
173
|
+
info.resources.map((resource) =>
|
|
174
|
+
Object.freeze({
|
|
175
|
+
...resource,
|
|
176
|
+
descriptor: freezeDescriptor(resource.descriptor),
|
|
177
|
+
}),
|
|
178
|
+
),
|
|
179
|
+
),
|
|
165
180
|
});
|
|
166
181
|
}
|
|
167
182
|
|
|
@@ -356,12 +371,42 @@ export class RenderGraphBuilder<FrameCtx extends RenderGraphFrame> {
|
|
|
356
371
|
label: resource.record.label,
|
|
357
372
|
kind: resource.record.kind,
|
|
358
373
|
origin: resource.record.origin,
|
|
374
|
+
descriptor:
|
|
375
|
+
resource.record.kind === 'texture'
|
|
376
|
+
? {
|
|
377
|
+
kind: 'texture' as const,
|
|
378
|
+
format: resource.record.descriptor.format,
|
|
379
|
+
...(resource.record.descriptor.domain === undefined
|
|
380
|
+
? {}
|
|
381
|
+
: { domain: resource.record.descriptor.domain }),
|
|
382
|
+
size: resource.record.descriptor.size,
|
|
383
|
+
...this.resolveExtent(resource.record.descriptor.size, options.surfaceSize),
|
|
384
|
+
mipLevelCount: resource.record.descriptor.mipLevelCount ?? 1,
|
|
385
|
+
sampleCount: resource.record.descriptor.sampleCount ?? 1,
|
|
386
|
+
}
|
|
387
|
+
: {
|
|
388
|
+
kind: 'buffer' as const,
|
|
389
|
+
size: resource.record.descriptor.size,
|
|
390
|
+
},
|
|
359
391
|
firstUse: resource.firstUse,
|
|
360
392
|
lastUse: resource.lastUse,
|
|
361
393
|
derivedUsage: resource.usage,
|
|
362
394
|
})),
|
|
363
395
|
});
|
|
364
396
|
|
|
397
|
+
const colorTargetDescriptors = new Map<string, ResolvedColorTargetDescriptor>();
|
|
398
|
+
for (const resource of allocated.value.resources.values()) {
|
|
399
|
+
if (resource.record.kind !== 'texture' || resource.texture === undefined) continue;
|
|
400
|
+
const extent = this.resolveExtent(resource.record.descriptor.size, options.surfaceSize);
|
|
401
|
+
colorTargetDescriptors.set(resource.record.label, {
|
|
402
|
+
texture: resource.texture,
|
|
403
|
+
format: resource.record.descriptor.format,
|
|
404
|
+
size: { width: extent.width, height: extent.height },
|
|
405
|
+
usage: resource.usage,
|
|
406
|
+
sample: resource.record.descriptor.sampleCount ?? 1,
|
|
407
|
+
});
|
|
408
|
+
}
|
|
409
|
+
|
|
365
410
|
return ok(
|
|
366
411
|
new CompiledRenderGraphImpl(
|
|
367
412
|
nextGeneration++,
|
|
@@ -371,6 +416,7 @@ export class RenderGraphBuilder<FrameCtx extends RenderGraphFrame> {
|
|
|
371
416
|
allocated.value.views,
|
|
372
417
|
Object.freeze(analyzed.value.passes),
|
|
373
418
|
info,
|
|
419
|
+
colorTargetDescriptors,
|
|
374
420
|
),
|
|
375
421
|
);
|
|
376
422
|
}
|
|
@@ -431,6 +477,12 @@ export class RenderGraphBuilder<FrameCtx extends RenderGraphFrame> {
|
|
|
431
477
|
const compiledPasses: CompiledPass<FrameCtx>[] = [];
|
|
432
478
|
const history: NormalizedAccess[] = [];
|
|
433
479
|
|
|
480
|
+
for (const resource of this.resources.values()) {
|
|
481
|
+
if (resource.kind !== 'texture' || resource.origin !== 'created') continue;
|
|
482
|
+
const usage = resource.descriptor.usage ?? 0;
|
|
483
|
+
if (usage !== 0) usageByResource.set(resource.id, usage);
|
|
484
|
+
}
|
|
485
|
+
|
|
434
486
|
for (let passIndex = 0; passIndex < this.passes.length; passIndex++) {
|
|
435
487
|
const pass = this.passes[passIndex];
|
|
436
488
|
if (pass === undefined) continue;
|
package/src/compiled-graph.ts
CHANGED
|
@@ -8,6 +8,7 @@ import type {
|
|
|
8
8
|
TextureView,
|
|
9
9
|
} from '@forgeax/engine-rhi';
|
|
10
10
|
import { err, ok, RenderGraphError, type Result } from './errors.js';
|
|
11
|
+
import type { ResolvedColorTargetDescriptor } from './graph.js';
|
|
11
12
|
import type {
|
|
12
13
|
CompiledPass,
|
|
13
14
|
CompiledResource,
|
|
@@ -55,12 +56,32 @@ export class CompiledRenderGraphImpl<FrameCtx extends RenderGraphFrame>
|
|
|
55
56
|
private readonly views: ReadonlyMap<number, CompiledView<FrameCtx>>,
|
|
56
57
|
private readonly passes: readonly CompiledPass<FrameCtx>[],
|
|
57
58
|
private readonly info: CompiledRenderGraphInfo,
|
|
59
|
+
private readonly colorTargetDescriptors: ReadonlyMap<string, ResolvedColorTargetDescriptor>,
|
|
58
60
|
) {}
|
|
59
61
|
|
|
60
62
|
inspect(): CompiledRenderGraphInfo {
|
|
61
63
|
return this.info;
|
|
62
64
|
}
|
|
63
65
|
|
|
66
|
+
getColorTargetView(name: string): TextureView | undefined {
|
|
67
|
+
for (const view of this.views.values()) {
|
|
68
|
+
const resource = this.resources.get(view.record.textureId);
|
|
69
|
+
if (resource?.record.label === name) return view.view;
|
|
70
|
+
}
|
|
71
|
+
return undefined;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
getColorTargetTexture(name: string): Texture | undefined {
|
|
75
|
+
for (const resource of this.resources.values()) {
|
|
76
|
+
if (resource.record.label === name) return resource.texture;
|
|
77
|
+
}
|
|
78
|
+
return undefined;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
getColorTargetDescriptor(name: string): ResolvedColorTargetDescriptor | undefined {
|
|
82
|
+
return this.colorTargetDescriptors.get(name);
|
|
83
|
+
}
|
|
84
|
+
|
|
64
85
|
execute(frame: FrameCtx, runPass?: RenderGraphPassRunner): Result<void, RenderGraphError> {
|
|
65
86
|
if (this.retired) {
|
|
66
87
|
return err(
|
package/src/errors.ts
CHANGED
|
@@ -66,6 +66,28 @@ export type RenderGraphErrorCode = keyof RenderGraphErrorDetailByCode;
|
|
|
66
66
|
/** Detail union projected from the private code-to-detail map. */
|
|
67
67
|
export type RenderGraphErrorDetail = RenderGraphErrorDetailByCode[RenderGraphErrorCode];
|
|
68
68
|
|
|
69
|
+
/** Failure stages for the shared float/output surface contract. */
|
|
70
|
+
export type SurfaceFailureKind =
|
|
71
|
+
| 'allocation'
|
|
72
|
+
| 'attachment'
|
|
73
|
+
| 'sampled-read'
|
|
74
|
+
| 'view-domain'
|
|
75
|
+
| 'raw-endpoint';
|
|
76
|
+
|
|
77
|
+
/** Closed error codes derived from the surface failure kinds. */
|
|
78
|
+
export type SurfaceFailureCode = `surface-${SurfaceFailureKind}-failed`;
|
|
79
|
+
|
|
80
|
+
/** Shared detail for graph and render-surface recovery. */
|
|
81
|
+
export interface RenderSurfaceFailureDetail {
|
|
82
|
+
readonly lane: string;
|
|
83
|
+
readonly stage: string;
|
|
84
|
+
readonly target: string;
|
|
85
|
+
readonly format: string;
|
|
86
|
+
readonly domain: string;
|
|
87
|
+
readonly endpoint: string;
|
|
88
|
+
readonly capability: string;
|
|
89
|
+
}
|
|
90
|
+
|
|
69
91
|
/**
|
|
70
92
|
* Constructor arguments correlated by code. `detail` remains optional to
|
|
71
93
|
* preserve the existing envelope behavior for callers that only need the
|
package/src/index.ts
CHANGED
|
@@ -14,10 +14,13 @@ export {
|
|
|
14
14
|
RenderGraphError,
|
|
15
15
|
type RenderGraphErrorCode,
|
|
16
16
|
type RenderGraphErrorDetail,
|
|
17
|
+
type RenderSurfaceFailureDetail,
|
|
17
18
|
type ResourceAllocFailedDetail,
|
|
18
19
|
type Result,
|
|
19
20
|
type ResultErr,
|
|
20
21
|
type ResultOk,
|
|
22
|
+
type SurfaceFailureCode,
|
|
23
|
+
type SurfaceFailureKind,
|
|
21
24
|
} from './errors.js';
|
|
22
25
|
export type {
|
|
23
26
|
BufferRole,
|
|
@@ -65,6 +68,7 @@ export {
|
|
|
65
68
|
export type {
|
|
66
69
|
CompiledRenderGraph,
|
|
67
70
|
CompiledRenderGraphInfo,
|
|
71
|
+
CompiledResourceDescriptor,
|
|
68
72
|
ComputeGraphPass,
|
|
69
73
|
CopyGraphPass,
|
|
70
74
|
GraphAccess,
|
|
@@ -32,6 +32,14 @@ describe('ColorValueDomain', () => {
|
|
|
32
32
|
expect(JSON.parse(serializeColorResourceDescriptor(descriptor))).toEqual(descriptor);
|
|
33
33
|
});
|
|
34
34
|
|
|
35
|
+
it('keeps display-encoded as an explicit domain for float storage', () => {
|
|
36
|
+
const descriptor: ColorResourceDescriptor = {
|
|
37
|
+
domain: 'display-encoded',
|
|
38
|
+
format: 'rgba16float',
|
|
39
|
+
};
|
|
40
|
+
expect(JSON.parse(serializeColorResourceDescriptor(descriptor))).toEqual(descriptor);
|
|
41
|
+
});
|
|
42
|
+
|
|
35
43
|
it.each([undefined, 'gamma-magic'])('rejects a missing or unknown domain: %s', (value) => {
|
|
36
44
|
const result = deserializeColorValueDomain(value);
|
|
37
45
|
expect(result.ok).toBe(false);
|
package/src/types.ts
CHANGED
|
@@ -10,6 +10,7 @@ import type {
|
|
|
10
10
|
TextureView,
|
|
11
11
|
} from '@forgeax/engine-rhi';
|
|
12
12
|
import type { RenderGraphError, Result } from './errors.js';
|
|
13
|
+
import type { ColorValueDomain } from './pipeline/color-value-domain.js';
|
|
13
14
|
|
|
14
15
|
declare const graphTextureBrand: unique symbol;
|
|
15
16
|
declare const graphTextureViewBrand: unique symbol;
|
|
@@ -44,10 +45,14 @@ export type GraphExtent =
|
|
|
44
45
|
export interface GraphTextureDescriptor {
|
|
45
46
|
readonly format: TextureFormat;
|
|
46
47
|
readonly size: GraphExtent;
|
|
48
|
+
/** Additional RHI usage required by an external diagnostic consumer. */
|
|
49
|
+
readonly usage?: number | undefined;
|
|
47
50
|
readonly mipLevelCount?: number | undefined;
|
|
48
51
|
readonly sampleCount?: number | undefined;
|
|
49
52
|
readonly dimension?: GPUTextureDimension | undefined;
|
|
50
53
|
readonly viewFormats?: readonly TextureFormat[] | undefined;
|
|
54
|
+
/** Explicit semantic color domain; never inferred from the attachment format. */
|
|
55
|
+
readonly domain?: ColorValueDomain | undefined;
|
|
51
56
|
}
|
|
52
57
|
|
|
53
58
|
export interface ImportedTextureDescriptor extends GraphTextureDescriptor {
|
|
@@ -174,6 +179,26 @@ export interface GraphAccessInfo {
|
|
|
174
179
|
readonly usage: GraphBufferAccess | GraphTextureAccess;
|
|
175
180
|
}
|
|
176
181
|
|
|
182
|
+
/** Detached physical allocation facts for one compiled graph resource. */
|
|
183
|
+
export type CompiledResourceDescriptor =
|
|
184
|
+
| {
|
|
185
|
+
readonly kind: 'texture';
|
|
186
|
+
readonly format: TextureFormat;
|
|
187
|
+
/** Explicit semantic color domain retained in detached graph facts. */
|
|
188
|
+
readonly domain?: ColorValueDomain | undefined;
|
|
189
|
+
/** Authored extent retained so consumers can validate the allocation contract. */
|
|
190
|
+
readonly size: GraphExtent;
|
|
191
|
+
readonly width: number;
|
|
192
|
+
readonly height: number;
|
|
193
|
+
readonly depthOrArrayLayers: number;
|
|
194
|
+
readonly mipLevelCount: number;
|
|
195
|
+
readonly sampleCount: number;
|
|
196
|
+
}
|
|
197
|
+
| {
|
|
198
|
+
readonly kind: 'buffer';
|
|
199
|
+
readonly size: number;
|
|
200
|
+
};
|
|
201
|
+
|
|
177
202
|
export interface CompiledRenderGraphInfo {
|
|
178
203
|
readonly passes: readonly {
|
|
179
204
|
readonly name: string;
|
|
@@ -186,6 +211,7 @@ export interface CompiledRenderGraphInfo {
|
|
|
186
211
|
readonly label: string;
|
|
187
212
|
readonly kind: GraphResourceKind;
|
|
188
213
|
readonly origin: GraphResourceOrigin;
|
|
214
|
+
readonly descriptor: CompiledResourceDescriptor;
|
|
189
215
|
readonly firstUse: number | null;
|
|
190
216
|
readonly lastUse: number | null;
|
|
191
217
|
readonly derivedUsage: number;
|