@forgeax/engine-render-graph 0.1.4 → 0.1.7
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.map +1 -1
- package/dist/graph.d.ts +5 -6
- package/dist/graph.d.ts.map +1 -1
- package/dist/index.mjs.map +1 -1
- package/dist/observation.d.ts +3 -3
- package/dist/observation.d.ts.map +1 -1
- package/dist/resource-registry.d.ts +3 -2
- package/dist/resource-registry.d.ts.map +1 -1
- package/dist/types.d.ts +1 -1
- package/dist/types.d.ts.map +1 -1
- package/package.json +4 -4
- package/src/__tests__/render-graph-builder.unit.test.ts +9 -0
- package/src/__tests__/render-graph-errors.test-d.ts +38 -0
- package/src/__tests__/render-graph.unit.test.ts +3 -1
- package/src/builder.ts +2 -2
- package/src/compiled-graph.ts +7 -7
- package/src/graph.ts +6 -7
- package/src/observation.ts +4 -4
- package/src/resource-registry.ts +3 -2
- package/src/types.ts +1 -2
- package/dist/__tests__/graph-pass-kind-owner.test-d.d.ts +0 -2
- package/dist/__tests__/graph-pass-kind-owner.test-d.d.ts.map +0 -1
- package/dist/__tests__/observation-lifetime-state-owner.test-d.d.ts +0 -2
- package/dist/__tests__/observation-lifetime-state-owner.test-d.d.ts.map +0 -1
- package/dist/__tests__/render-graph-capability-owner.test-d.d.ts +0 -2
- package/dist/__tests__/render-graph-capability-owner.test-d.d.ts.map +0 -1
- package/dist/__tests__/resource-kind-owner.test-d.d.ts +0 -2
- package/dist/__tests__/resource-kind-owner.test-d.d.ts.map +0 -1
- package/src/__tests__/graph-pass-kind-owner.test-d.ts +0 -35
- package/src/__tests__/observation-lifetime-state-owner.test-d.ts +0 -39
- package/src/__tests__/render-graph-capability-owner.test-d.ts +0 -32
- package/src/__tests__/resource-kind-owner.test-d.ts +0 -38
package/dist/observation.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { Texture } from '@forgeax/engine-rhi';
|
|
1
|
+
import type { Texture, TextureFormat } from '@forgeax/engine-rhi';
|
|
2
2
|
import { RenderGraphError, type Result } from './errors.js';
|
|
3
3
|
export { RenderGraphError } from './errors.js';
|
|
4
4
|
export interface ObservationSize {
|
|
@@ -8,7 +8,7 @@ export interface ObservationSize {
|
|
|
8
8
|
/** Generic producer-owned metadata for one current-frame texture. */
|
|
9
9
|
export interface CurrentFrameObservationDescriptor {
|
|
10
10
|
readonly texture: Texture;
|
|
11
|
-
readonly format:
|
|
11
|
+
readonly format: TextureFormat;
|
|
12
12
|
readonly size: ObservationSize;
|
|
13
13
|
readonly usage: number;
|
|
14
14
|
readonly frameId: number;
|
|
@@ -26,7 +26,7 @@ export interface CurrentFrameObservationSource {
|
|
|
26
26
|
export interface CurrentFrameObservationLease {
|
|
27
27
|
readonly descriptor: CurrentFrameObservationDescriptor;
|
|
28
28
|
readonly lifetime: CurrentFrameObservationLifetime;
|
|
29
|
-
readonly state:
|
|
29
|
+
readonly state: 'active' | 'retired';
|
|
30
30
|
beginReadback(): Result<CurrentFrameObservationSource, RenderGraphError>;
|
|
31
31
|
retire(): void;
|
|
32
32
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"observation.d.ts","sourceRoot":"","sources":["../src/observation.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAC;
|
|
1
|
+
{"version":3,"file":"observation.d.ts","sourceRoot":"","sources":["../src/observation.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAClE,OAAO,EAAW,gBAAgB,EAAE,KAAK,MAAM,EAAE,MAAM,aAAa,CAAC;AAErE,OAAO,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAI/C,MAAM,WAAW,eAAe;IAC9B,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;CACzB;AAED,qEAAqE;AACrE,MAAM,WAAW,iCAAiC;IAChD,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAC;IAC1B,QAAQ,CAAC,MAAM,EAAE,aAAa,CAAC;IAC/B,QAAQ,CAAC,IAAI,EAAE,eAAe,CAAC;IAC/B,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;CAC1B;AAED,MAAM,WAAW,+BAA+B;IAC9C,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,KAAK,EAAE,QAAQ,GAAG,SAAS,CAAC;CACtC;AAED,yEAAyE;AACzE,MAAM,WAAW,6BAA6B;IAC5C,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAC;IAC1B,QAAQ,CAAC,UAAU,EAAE,iCAAiC,CAAC;IACvD,QAAQ,CAAC,QAAQ,EAAE,+BAA+B,CAAC;CACpD;AAED,MAAM,WAAW,4BAA4B;IAC3C,QAAQ,CAAC,UAAU,EAAE,iCAAiC,CAAC;IACvD,QAAQ,CAAC,QAAQ,EAAE,+BAA+B,CAAC;IACnD,QAAQ,CAAC,KAAK,EAAE,QAAQ,GAAG,SAAS,CAAC;IACrC,aAAa,IAAI,MAAM,CAAC,6BAA6B,EAAE,gBAAgB,CAAC,CAAC;IACzE,MAAM,IAAI,IAAI,CAAC;CAChB;AAeD;;;GAGG;AACH,wBAAgB,kCAAkC,CAChD,UAAU,EAAE,iCAAiC,EAC7C,cAAc,EAAE,MAAM,GACrB,MAAM,CAAC,4BAA4B,EAAE,gBAAgB,CAAC,CAwExD"}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { TextureFormat } from '@forgeax/engine-rhi';
|
|
1
2
|
import { type CapMissingDetail, type DanglingReadDetail, type DuplicateResourceDetail, RenderGraphError, type Result } from './errors.js';
|
|
2
3
|
import type { ColorTargetDescriptor, ColorTargetSize, ResourceDescriptor, ResourceLifetime } from './graph.js';
|
|
3
4
|
import type { ColorValueDomain } from './pipeline/color-value-domain.js';
|
|
@@ -8,7 +9,7 @@ import type { ColorValueDomain } from './pipeline/color-value-domain.js';
|
|
|
8
9
|
* addResource it is undefined.
|
|
9
10
|
*/
|
|
10
11
|
export interface ColorTargetResourceMeta {
|
|
11
|
-
readonly format:
|
|
12
|
+
readonly format: TextureFormat;
|
|
12
13
|
readonly size: ColorTargetSize;
|
|
13
14
|
readonly sample: number;
|
|
14
15
|
readonly usage: number;
|
|
@@ -20,7 +21,7 @@ export interface ColorTargetResourceMeta {
|
|
|
20
21
|
* `bgra8unorm` storage texture plus a `bgra8unorm-srgb` view of the same
|
|
21
22
|
* texture for hardware sRGB encoding on store.
|
|
22
23
|
*/
|
|
23
|
-
readonly viewFormats?: readonly
|
|
24
|
+
readonly viewFormats?: readonly TextureFormat[] | undefined;
|
|
24
25
|
/**
|
|
25
26
|
* When set, this resource is an alias of the given source resource.
|
|
26
27
|
* The compile allocation phase folds the alias into the source's
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"resource-registry.d.ts","sourceRoot":"","sources":["../src/resource-registry.ts"],"names":[],"mappings":"AASA,OAAO,EAEL,KAAK,gBAAgB,EACrB,KAAK,kBAAkB,EACvB,KAAK,uBAAuB,EAG5B,gBAAgB,EAChB,KAAK,MAAM,EACZ,MAAM,aAAa,CAAC;AACrB,OAAO,KAAK,EACV,qBAAqB,EACrB,eAAe,EACf,kBAAkB,EAClB,gBAAgB,EACjB,MAAM,YAAY,CAAC;AACpB,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,kCAAkC,CAAC;AAEzE;;;;;GAKG;AACH,MAAM,WAAW,uBAAuB;IACtC,QAAQ,CAAC,MAAM,EAAE,
|
|
1
|
+
{"version":3,"file":"resource-registry.d.ts","sourceRoot":"","sources":["../src/resource-registry.ts"],"names":[],"mappings":"AASA,OAAO,KAAK,EAAE,aAAa,EA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,IAAI,EAAE,MAAM,EACZ,IAAI,EAAE,qBAAqB,GAC1B,MAAM,CAAC,aAAa,EAAE,gBAAgB,CAAC;IAmB1C;;;;OAIG;IACH,mBAAmB,CAAC,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,MAAM,CAAC,aAAa,EAAE,gBAAgB,CAAC;IA8B1F,OAAO,CAAC,iBAAiB;IAWzB,OAAO,CAAC,QAAQ;IAMhB,GAAG,CAAC,GAAG,EAAE,MAAM,GAAG,aAAa,GAAG,SAAS;IAI3C,kBAAkB,CAAC,GAAG,EAAE,MAAM,GAAG,uBAAuB,GAAG,SAAS;IAIpE,GAAG,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO;IAIzB,OAAO,IAAI,gBAAgB,CAAC,aAAa,CAAC;CAG3C;AAGD,YAAY,EAAE,gBAAgB,EAAE,kBAAkB,EAAE,uBAAuB,EAAE,CAAC"}
|
package/dist/types.d.ts
CHANGED
|
@@ -15,6 +15,7 @@ export interface GraphBuffer {
|
|
|
15
15
|
export type GraphResource = GraphTexture | GraphTextureView | GraphBuffer;
|
|
16
16
|
export type GraphResourceOrigin = 'created' | 'imported';
|
|
17
17
|
export type GraphResourceKind = 'texture' | 'buffer';
|
|
18
|
+
export type GraphPassKind = 'raster' | 'compute' | 'copy';
|
|
18
19
|
export type GraphExtent = 'surface' | 'half-surface' | {
|
|
19
20
|
readonly width: number;
|
|
20
21
|
readonly height: number;
|
|
@@ -124,7 +125,6 @@ export type GraphPass<FrameCtx> = {
|
|
|
124
125
|
readonly kind: 'copy';
|
|
125
126
|
readonly descriptor: CopyGraphPass<FrameCtx>;
|
|
126
127
|
};
|
|
127
|
-
export type GraphPassKind = GraphPass<unknown>['kind'];
|
|
128
128
|
export interface GraphAccessInfo {
|
|
129
129
|
readonly resource: string;
|
|
130
130
|
readonly usage: GraphBufferAccess | GraphTextureAccess;
|
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;AAE5D,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,MAAM,MAAM,mBAAmB,GAAG,SAAS,GAAG,UAAU,CAAC;AACzD,MAAM,MAAM,iBAAiB,GAAG,SAAS,GAAG,QAAQ,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;AAE5D,OAAO,CAAC,MAAM,iBA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,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.7",
|
|
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.7",
|
|
26
|
+
"@forgeax/engine-types": "0.1.7",
|
|
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.7"
|
|
31
31
|
},
|
|
32
32
|
"forgeax": {
|
|
33
33
|
"metrics": {
|
|
@@ -88,6 +88,15 @@ function value<T>(result: { readonly ok: true; readonly value: T } | { readonly
|
|
|
88
88
|
}
|
|
89
89
|
|
|
90
90
|
describe('RenderGraphBuilder resource and temporal contracts', () => {
|
|
91
|
+
it('keeps attachment format declarations closed at the graph boundary', () => {
|
|
92
|
+
const graph = new RenderGraphBuilder<Frame>();
|
|
93
|
+
const texture = graph.createTexture('format-checked', {
|
|
94
|
+
format: 'rgba8unorm',
|
|
95
|
+
size: 'surface',
|
|
96
|
+
});
|
|
97
|
+
expect(texture.ok).toBe(true);
|
|
98
|
+
});
|
|
99
|
+
|
|
91
100
|
it('rejects duplicate resource labels and duplicate pass names at declaration time', () => {
|
|
92
101
|
const graph = new RenderGraphBuilder<Frame>();
|
|
93
102
|
expect(graph.createBuffer('data', { size: 16 }).ok).toBe(true);
|
|
@@ -18,6 +18,7 @@ import {
|
|
|
18
18
|
type ResourceAccessDetail,
|
|
19
19
|
type ResourceAllocFailedDetail,
|
|
20
20
|
} from '../errors.js';
|
|
21
|
+
import type { GraphPassKind, GraphResourceKind } from '../types.js';
|
|
21
22
|
|
|
22
23
|
describe('RenderGraphError code/detail correlation', () => {
|
|
23
24
|
it('accepts every existing code with its matching detail interface', () => {
|
|
@@ -167,3 +168,40 @@ describe('RenderGraphError code/detail correlation', () => {
|
|
|
167
168
|
>();
|
|
168
169
|
});
|
|
169
170
|
});
|
|
171
|
+
|
|
172
|
+
function assertNever(value: never): never {
|
|
173
|
+
throw new Error(String(value));
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
function exhaustivePass(kind: GraphPassKind): string {
|
|
177
|
+
switch (kind) {
|
|
178
|
+
case 'raster':
|
|
179
|
+
return kind;
|
|
180
|
+
case 'compute':
|
|
181
|
+
return kind;
|
|
182
|
+
case 'copy':
|
|
183
|
+
return kind;
|
|
184
|
+
}
|
|
185
|
+
return assertNever(kind);
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
function exhaustiveResource(kind: GraphResourceKind): string {
|
|
189
|
+
switch (kind) {
|
|
190
|
+
case 'texture':
|
|
191
|
+
return kind;
|
|
192
|
+
case 'buffer':
|
|
193
|
+
return kind;
|
|
194
|
+
}
|
|
195
|
+
return assertNever(kind);
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
describe('M4 render graph closed unions', () => {
|
|
199
|
+
it('keeps pass and resource variants exhaustively handled without a default branch', () => {
|
|
200
|
+
expectTypeOf(exhaustivePass).returns.toEqualTypeOf<string>();
|
|
201
|
+
expectTypeOf(exhaustiveResource).returns.toEqualTypeOf<string>();
|
|
202
|
+
});
|
|
203
|
+
|
|
204
|
+
it('keeps RenderGraphErrorCode closed', () => {
|
|
205
|
+
expectTypeOf<RenderGraphErrorCode>().not.toEqualTypeOf<string>();
|
|
206
|
+
});
|
|
207
|
+
});
|
|
@@ -1315,7 +1315,9 @@ import { RenderGraph } from '../graph.js';
|
|
|
1315
1315
|
expect(createTextureViewCalls).toBe(1);
|
|
1316
1316
|
|
|
1317
1317
|
graph.addColorTarget('candidate', {
|
|
1318
|
-
|
|
1318
|
+
// Runtime malformed input is intentionally injected past the closed
|
|
1319
|
+
// declaration type so the validation error remains covered.
|
|
1320
|
+
format: 'not-a-gpu-texture-format' as never,
|
|
1319
1321
|
size: { w: 1, h: 1 },
|
|
1320
1322
|
usage: 0,
|
|
1321
1323
|
});
|
package/src/builder.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { Buffer, RhiCaps, Texture, TextureView } from '@forgeax/engine-rhi';
|
|
2
2
|
import { CompiledRenderGraphImpl } from './compiled-graph.js';
|
|
3
|
-
import {
|
|
3
|
+
import { err, ok, RenderGraphError, type Result } from './errors.js';
|
|
4
4
|
import {
|
|
5
5
|
accessResourceId,
|
|
6
6
|
bufferHandle,
|
|
@@ -628,7 +628,7 @@ export class RenderGraphBuilder<FrameCtx extends RenderGraphFrame> {
|
|
|
628
628
|
|
|
629
629
|
private capabilityError(
|
|
630
630
|
passName: string,
|
|
631
|
-
capability:
|
|
631
|
+
capability: 'compute' | 'storage-buffer' | 'storage-texture' | 'indirect',
|
|
632
632
|
access?: GraphAccess,
|
|
633
633
|
): Result<never, RenderGraphError> {
|
|
634
634
|
const resourceId = access === undefined ? undefined : accessResourceId(access);
|
package/src/compiled-graph.ts
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import type {
|
|
2
2
|
Buffer,
|
|
3
|
+
RenderPassColorAttachment,
|
|
4
|
+
RenderPassDepthStencilAttachment,
|
|
3
5
|
RhiComputePassEncoder,
|
|
4
6
|
RhiDevice,
|
|
5
7
|
Texture,
|
|
@@ -83,7 +85,7 @@ export class CompiledRenderGraphImpl<FrameCtx extends RenderGraphFrame>
|
|
|
83
85
|
switch (pass.pass.kind) {
|
|
84
86
|
case 'raster': {
|
|
85
87
|
const descriptor = pass.pass.descriptor;
|
|
86
|
-
const colorAttachments:
|
|
88
|
+
const colorAttachments: RenderPassColorAttachment[] = [];
|
|
87
89
|
for (const attachment of descriptor.colorAttachments) {
|
|
88
90
|
const view = resolver.textureView(attachment.view);
|
|
89
91
|
if (!view.ok) {
|
|
@@ -103,10 +105,8 @@ export class CompiledRenderGraphImpl<FrameCtx extends RenderGraphFrame>
|
|
|
103
105
|
? attachment.clearValue(frame)
|
|
104
106
|
: attachment.clearValue;
|
|
105
107
|
colorAttachments.push({
|
|
106
|
-
view: view.value
|
|
107
|
-
...(resolveTarget === undefined
|
|
108
|
-
? {}
|
|
109
|
-
: { resolveTarget: resolveTarget.value as unknown as GPUTextureView }),
|
|
108
|
+
view: view.value,
|
|
109
|
+
...(resolveTarget === undefined ? {} : { resolveTarget: resolveTarget.value }),
|
|
110
110
|
...(clearValue === undefined ? {} : { clearValue }),
|
|
111
111
|
loadOp: attachment.loadOp,
|
|
112
112
|
storeOp: attachment.storeOp,
|
|
@@ -115,7 +115,7 @@ export class CompiledRenderGraphImpl<FrameCtx extends RenderGraphFrame>
|
|
|
115
115
|
: { depthSlice: attachment.depthSlice }),
|
|
116
116
|
});
|
|
117
117
|
}
|
|
118
|
-
let depthStencilAttachment:
|
|
118
|
+
let depthStencilAttachment: RenderPassDepthStencilAttachment | undefined;
|
|
119
119
|
if (descriptor.depthStencilAttachment !== undefined) {
|
|
120
120
|
const attachment = descriptor.depthStencilAttachment;
|
|
121
121
|
const view = resolver.textureView(attachment.view);
|
|
@@ -124,7 +124,7 @@ export class CompiledRenderGraphImpl<FrameCtx extends RenderGraphFrame>
|
|
|
124
124
|
return;
|
|
125
125
|
}
|
|
126
126
|
depthStencilAttachment = {
|
|
127
|
-
view: view.value
|
|
127
|
+
view: view.value,
|
|
128
128
|
...(attachment.depthClearValue === undefined
|
|
129
129
|
? {}
|
|
130
130
|
: { depthClearValue: attachment.depthClearValue }),
|
package/src/graph.ts
CHANGED
|
@@ -37,11 +37,10 @@ import {
|
|
|
37
37
|
} from './pipeline/color-value-domain.js';
|
|
38
38
|
import type { ResourceEntry } from './resource-registry.js';
|
|
39
39
|
import { ResourceRegistry } from './resource-registry.js';
|
|
40
|
-
import type { GraphResourceKind } from './types.js';
|
|
41
40
|
|
|
42
41
|
// ── Declaration types ────────────────────────────────────────────
|
|
43
42
|
|
|
44
|
-
export type ResourceKind =
|
|
43
|
+
export type ResourceKind = 'texture' | 'buffer';
|
|
45
44
|
|
|
46
45
|
export type ResourceLifetime = 'transient' | 'persistent';
|
|
47
46
|
|
|
@@ -73,19 +72,19 @@ export type ColorTargetSize =
|
|
|
73
72
|
* store), so the consumer pre-declares the alternate format here.
|
|
74
73
|
*/
|
|
75
74
|
export interface ColorTargetDescriptor {
|
|
76
|
-
readonly format:
|
|
75
|
+
readonly format: TextureFormat;
|
|
77
76
|
readonly size: ColorTargetSize;
|
|
78
77
|
readonly lifetime?: ResourceLifetime | undefined;
|
|
79
78
|
readonly sample?: number | undefined;
|
|
80
79
|
readonly usage?: number | undefined;
|
|
81
|
-
readonly viewFormats?: readonly
|
|
80
|
+
readonly viewFormats?: readonly TextureFormat[] | undefined;
|
|
82
81
|
/** Semantic color domain. Omitted only for legacy graphs without domain connections. */
|
|
83
82
|
readonly domain?: ColorValueDomain | undefined;
|
|
84
83
|
}
|
|
85
84
|
|
|
86
85
|
export interface ResolvedColorTargetDescriptor {
|
|
87
86
|
readonly texture: Texture;
|
|
88
|
-
readonly format:
|
|
87
|
+
readonly format: TextureFormat;
|
|
89
88
|
readonly size: { readonly width: number; readonly height: number };
|
|
90
89
|
readonly usage: number;
|
|
91
90
|
readonly sample: number;
|
|
@@ -240,12 +239,12 @@ interface StagedColorTargetAllocation {
|
|
|
240
239
|
type DrainDevice = Pick<RhiDevice, 'destroyTexture' | 'queue'>;
|
|
241
240
|
|
|
242
241
|
function poolKey(meta: {
|
|
243
|
-
format:
|
|
242
|
+
format: TextureFormat;
|
|
244
243
|
width: number;
|
|
245
244
|
height: number;
|
|
246
245
|
usage: number;
|
|
247
246
|
sample: number;
|
|
248
|
-
viewFormats: readonly
|
|
247
|
+
viewFormats: readonly TextureFormat[];
|
|
249
248
|
}): string {
|
|
250
249
|
return `${meta.format}:${meta.width}x${meta.height}:${meta.usage}:${meta.sample}:${JSON.stringify(meta.viewFormats)}`;
|
|
251
250
|
}
|
package/src/observation.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { Texture } from '@forgeax/engine-rhi';
|
|
1
|
+
import type { Texture, TextureFormat } from '@forgeax/engine-rhi';
|
|
2
2
|
import { err, ok, RenderGraphError, type Result } from './errors.js';
|
|
3
3
|
|
|
4
4
|
export { RenderGraphError } from './errors.js';
|
|
@@ -13,7 +13,7 @@ export interface ObservationSize {
|
|
|
13
13
|
/** Generic producer-owned metadata for one current-frame texture. */
|
|
14
14
|
export interface CurrentFrameObservationDescriptor {
|
|
15
15
|
readonly texture: Texture;
|
|
16
|
-
readonly format:
|
|
16
|
+
readonly format: TextureFormat;
|
|
17
17
|
readonly size: ObservationSize;
|
|
18
18
|
readonly usage: number;
|
|
19
19
|
readonly frameId: number;
|
|
@@ -34,7 +34,7 @@ export interface CurrentFrameObservationSource {
|
|
|
34
34
|
export interface CurrentFrameObservationLease {
|
|
35
35
|
readonly descriptor: CurrentFrameObservationDescriptor;
|
|
36
36
|
readonly lifetime: CurrentFrameObservationLifetime;
|
|
37
|
-
readonly state:
|
|
37
|
+
readonly state: 'active' | 'retired';
|
|
38
38
|
beginReadback(): Result<CurrentFrameObservationSource, RenderGraphError>;
|
|
39
39
|
retire(): void;
|
|
40
40
|
}
|
|
@@ -101,7 +101,7 @@ export function createCurrentFrameObservationLease(
|
|
|
101
101
|
);
|
|
102
102
|
}
|
|
103
103
|
|
|
104
|
-
let state:
|
|
104
|
+
let state: 'active' | 'retired' = 'active';
|
|
105
105
|
const lifetime: CurrentFrameObservationLifetime = {
|
|
106
106
|
frameId: descriptor.frameId,
|
|
107
107
|
get state() {
|
package/src/resource-registry.ts
CHANGED
|
@@ -7,6 +7,7 @@
|
|
|
7
7
|
// - unknown-resource fail-fast at pass binding time
|
|
8
8
|
// - addColorTarget: color target registration with format/size/sample/usage
|
|
9
9
|
|
|
10
|
+
import type { TextureFormat } from '@forgeax/engine-rhi';
|
|
10
11
|
import {
|
|
11
12
|
type AliasSourceDetail,
|
|
12
13
|
type CapMissingDetail,
|
|
@@ -32,7 +33,7 @@ import type { ColorValueDomain } from './pipeline/color-value-domain.js';
|
|
|
32
33
|
* addResource it is undefined.
|
|
33
34
|
*/
|
|
34
35
|
export interface ColorTargetResourceMeta {
|
|
35
|
-
readonly format:
|
|
36
|
+
readonly format: TextureFormat;
|
|
36
37
|
readonly size: ColorTargetSize;
|
|
37
38
|
readonly sample: number;
|
|
38
39
|
readonly usage: number;
|
|
@@ -44,7 +45,7 @@ export interface ColorTargetResourceMeta {
|
|
|
44
45
|
* `bgra8unorm` storage texture plus a `bgra8unorm-srgb` view of the same
|
|
45
46
|
* texture for hardware sRGB encoding on store.
|
|
46
47
|
*/
|
|
47
|
-
readonly viewFormats?: readonly
|
|
48
|
+
readonly viewFormats?: readonly TextureFormat[] | undefined;
|
|
48
49
|
/**
|
|
49
50
|
* When set, this resource is an alias of the given source resource.
|
|
50
51
|
* The compile allocation phase folds the alias into the source's
|
package/src/types.ts
CHANGED
|
@@ -30,6 +30,7 @@ export interface GraphBuffer {
|
|
|
30
30
|
export type GraphResource = GraphTexture | GraphTextureView | GraphBuffer;
|
|
31
31
|
export type GraphResourceOrigin = 'created' | 'imported';
|
|
32
32
|
export type GraphResourceKind = 'texture' | 'buffer';
|
|
33
|
+
export type GraphPassKind = 'raster' | 'compute' | 'copy';
|
|
33
34
|
|
|
34
35
|
export type GraphExtent =
|
|
35
36
|
| 'surface'
|
|
@@ -168,8 +169,6 @@ export type GraphPass<FrameCtx> =
|
|
|
168
169
|
| { readonly kind: 'compute'; readonly descriptor: ComputeGraphPass<FrameCtx> }
|
|
169
170
|
| { readonly kind: 'copy'; readonly descriptor: CopyGraphPass<FrameCtx> };
|
|
170
171
|
|
|
171
|
-
export type GraphPassKind = GraphPass<unknown>['kind'];
|
|
172
|
-
|
|
173
172
|
export interface GraphAccessInfo {
|
|
174
173
|
readonly resource: string;
|
|
175
174
|
readonly usage: GraphBufferAccess | GraphTextureAccess;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"graph-pass-kind-owner.test-d.d.ts","sourceRoot":"","sources":["../../src/__tests__/graph-pass-kind-owner.test-d.ts"],"names":[],"mappings":""}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"observation-lifetime-state-owner.test-d.d.ts","sourceRoot":"","sources":["../../src/__tests__/observation-lifetime-state-owner.test-d.ts"],"names":[],"mappings":""}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"render-graph-capability-owner.test-d.d.ts","sourceRoot":"","sources":["../../src/__tests__/render-graph-capability-owner.test-d.ts"],"names":[],"mappings":""}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"resource-kind-owner.test-d.d.ts","sourceRoot":"","sources":["../../src/__tests__/resource-kind-owner.test-d.ts"],"names":[],"mappings":""}
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
import { describe, expectTypeOf, it } from 'vitest';
|
|
2
|
-
import type {
|
|
3
|
-
CompiledRenderGraphInfo,
|
|
4
|
-
GraphPass,
|
|
5
|
-
GraphPassKind,
|
|
6
|
-
RenderGraphPassExecution,
|
|
7
|
-
} from '../index.js';
|
|
8
|
-
|
|
9
|
-
type GraphPassKindOwner = GraphPass<unknown>['kind'];
|
|
10
|
-
type ExpectedGraphPassKind = 'raster' | 'compute' | 'copy';
|
|
11
|
-
type CompiledPassKind = CompiledRenderGraphInfo['passes'][number]['kind'];
|
|
12
|
-
type ExecutionPassKind = RenderGraphPassExecution['kind'];
|
|
13
|
-
|
|
14
|
-
describe('render-graph pass kind owner', () => {
|
|
15
|
-
it('keeps the exact raster, compute, and copy membership', () => {
|
|
16
|
-
expectTypeOf<GraphPassKindOwner>().toEqualTypeOf<ExpectedGraphPassKind>();
|
|
17
|
-
expectTypeOf<ExpectedGraphPassKind>().toEqualTypeOf<GraphPassKindOwner>();
|
|
18
|
-
expectTypeOf<GraphPassKind>().toEqualTypeOf<GraphPassKindOwner>();
|
|
19
|
-
expectTypeOf<GraphPassKindOwner>().toEqualTypeOf<GraphPassKind>();
|
|
20
|
-
|
|
21
|
-
const acceptsPassKind = (kind: GraphPassKindOwner): GraphPassKindOwner => kind;
|
|
22
|
-
acceptsPassKind('raster');
|
|
23
|
-
acceptsPassKind('compute');
|
|
24
|
-
acceptsPassKind('copy');
|
|
25
|
-
// @ts-expect-error unknown pass kinds remain outside the closed union.
|
|
26
|
-
acceptsPassKind('pass-kind-not-real');
|
|
27
|
-
});
|
|
28
|
-
|
|
29
|
-
it('keeps compiled and execution views equal to the owner', () => {
|
|
30
|
-
expectTypeOf<CompiledPassKind>().toEqualTypeOf<GraphPassKindOwner>();
|
|
31
|
-
expectTypeOf<GraphPassKindOwner>().toEqualTypeOf<CompiledPassKind>();
|
|
32
|
-
expectTypeOf<ExecutionPassKind>().toEqualTypeOf<GraphPassKindOwner>();
|
|
33
|
-
expectTypeOf<GraphPassKindOwner>().toEqualTypeOf<ExecutionPassKind>();
|
|
34
|
-
});
|
|
35
|
-
});
|
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
/// <reference types="node" />
|
|
2
|
-
|
|
3
|
-
import { readFileSync } from 'node:fs';
|
|
4
|
-
import { describe, expect, expectTypeOf, it } from 'vitest';
|
|
5
|
-
import type { CurrentFrameObservationLease, CurrentFrameObservationLifetime } from '../index.js';
|
|
6
|
-
|
|
7
|
-
const observationSource = readFileSync(new URL('../observation.ts', import.meta.url), 'utf8');
|
|
8
|
-
|
|
9
|
-
describe('current-frame observation lifetime state owner', () => {
|
|
10
|
-
it('keeps lease state bilaterally equal to the lifetime owner', () => {
|
|
11
|
-
type LifetimeState = CurrentFrameObservationLifetime['state'];
|
|
12
|
-
type LeaseState = CurrentFrameObservationLease['state'];
|
|
13
|
-
|
|
14
|
-
expectTypeOf<LeaseState>().toEqualTypeOf<LifetimeState>();
|
|
15
|
-
expectTypeOf<LifetimeState>().toEqualTypeOf<LeaseState>();
|
|
16
|
-
|
|
17
|
-
const acceptsLifetimeState = (state: LifetimeState): LifetimeState => state;
|
|
18
|
-
const acceptsLeaseState = (state: LeaseState): LeaseState => state;
|
|
19
|
-
acceptsLifetimeState('active');
|
|
20
|
-
acceptsLifetimeState('retired');
|
|
21
|
-
acceptsLeaseState('active');
|
|
22
|
-
acceptsLeaseState('retired');
|
|
23
|
-
// @ts-expect-error unknown observation lifetime states remain outside the closed union.
|
|
24
|
-
acceptsLifetimeState('pending');
|
|
25
|
-
// @ts-expect-error unknown lease states remain outside the closed union.
|
|
26
|
-
acceptsLeaseState('pending');
|
|
27
|
-
});
|
|
28
|
-
|
|
29
|
-
it('keeps the source annotations derived from the lifetime owner', () => {
|
|
30
|
-
expect(observationSource).toContain(
|
|
31
|
-
"readonly state: CurrentFrameObservationLifetime['state'];",
|
|
32
|
-
);
|
|
33
|
-
expect(observationSource).toContain(
|
|
34
|
-
"let state: CurrentFrameObservationLifetime['state'] = 'active';",
|
|
35
|
-
);
|
|
36
|
-
expect(observationSource.match(/readonly state: 'active' \| 'retired';/g)).toHaveLength(1);
|
|
37
|
-
expect(observationSource).not.toContain("let state: 'active' | 'retired' = 'active';");
|
|
38
|
-
});
|
|
39
|
-
});
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
/// <reference types="node" />
|
|
2
|
-
|
|
3
|
-
import { readFileSync } from 'node:fs';
|
|
4
|
-
import { describe, expect, expectTypeOf, it } from 'vitest';
|
|
5
|
-
import type { CapabilityDetail } from '../errors.js';
|
|
6
|
-
|
|
7
|
-
const builderSource = readFileSync(new URL('../builder.ts', import.meta.url), 'utf8');
|
|
8
|
-
|
|
9
|
-
type Capability = CapabilityDetail['capability'];
|
|
10
|
-
type ExpectedCapability = 'compute' | 'storage-buffer' | 'storage-texture' | 'indirect';
|
|
11
|
-
|
|
12
|
-
describe('RenderGraph capability owner', () => {
|
|
13
|
-
it('keeps the exact capability membership with bilateral equality', () => {
|
|
14
|
-
expectTypeOf<Capability>().toEqualTypeOf<ExpectedCapability>();
|
|
15
|
-
expectTypeOf<ExpectedCapability>().toEqualTypeOf<Capability>();
|
|
16
|
-
|
|
17
|
-
const acceptsCapability = (capability: Capability): Capability => capability;
|
|
18
|
-
acceptsCapability('compute');
|
|
19
|
-
acceptsCapability('storage-buffer');
|
|
20
|
-
acceptsCapability('storage-texture');
|
|
21
|
-
acceptsCapability('indirect');
|
|
22
|
-
// @ts-expect-error unknown capabilities remain outside the closed union.
|
|
23
|
-
acceptsCapability('capability-not-real');
|
|
24
|
-
});
|
|
25
|
-
|
|
26
|
-
it('derives the builder parameter from the structured error owner', () => {
|
|
27
|
-
expect(builderSource).toContain("capability: CapabilityDetail['capability'],");
|
|
28
|
-
expect(builderSource).not.toContain(
|
|
29
|
-
"capability: 'compute' | 'storage-buffer' | 'storage-texture' | 'indirect',",
|
|
30
|
-
);
|
|
31
|
-
});
|
|
32
|
-
});
|
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
/// <reference types="node" />
|
|
2
|
-
|
|
3
|
-
import { readFileSync } from 'node:fs';
|
|
4
|
-
import { describe, expect, expectTypeOf, it } from 'vitest';
|
|
5
|
-
import type {
|
|
6
|
-
GraphResourceKind,
|
|
7
|
-
ResourceDescriptor,
|
|
8
|
-
ResourceInfo,
|
|
9
|
-
ResourceKind,
|
|
10
|
-
} from '../index.js';
|
|
11
|
-
|
|
12
|
-
const graphSource = readFileSync(new URL('../graph.ts', import.meta.url), 'utf8');
|
|
13
|
-
|
|
14
|
-
describe('render-graph ResourceKind owner', () => {
|
|
15
|
-
it('keeps exact membership and projects the public resource shapes', () => {
|
|
16
|
-
expectTypeOf<GraphResourceKind>().toEqualTypeOf<'texture' | 'buffer'>();
|
|
17
|
-
expectTypeOf<ResourceKind>().toEqualTypeOf<GraphResourceKind>();
|
|
18
|
-
expectTypeOf<GraphResourceKind>().toEqualTypeOf<ResourceKind>();
|
|
19
|
-
expectTypeOf<ResourceDescriptor['kind']>().toEqualTypeOf<GraphResourceKind>();
|
|
20
|
-
expectTypeOf<ResourceInfo['kind']>().toEqualTypeOf<GraphResourceKind>();
|
|
21
|
-
|
|
22
|
-
const acceptResourceKind = (kind: ResourceKind): ResourceKind => kind;
|
|
23
|
-
const texture: GraphResourceKind = 'texture';
|
|
24
|
-
const buffer: GraphResourceKind = 'buffer';
|
|
25
|
-
acceptResourceKind(texture);
|
|
26
|
-
acceptResourceKind(buffer);
|
|
27
|
-
const graphKind: GraphResourceKind = acceptResourceKind('texture');
|
|
28
|
-
void graphKind;
|
|
29
|
-
|
|
30
|
-
// @ts-expect-error unknown resource kinds remain outside the closed union.
|
|
31
|
-
acceptResourceKind('resource-kind-not-real');
|
|
32
|
-
});
|
|
33
|
-
|
|
34
|
-
it('keeps ResourceKind as a type-only projection of GraphResourceKind', () => {
|
|
35
|
-
expect(graphSource).toContain('export type ResourceKind = GraphResourceKind;');
|
|
36
|
-
expect(graphSource).not.toContain("export type ResourceKind = 'texture' | 'buffer';");
|
|
37
|
-
});
|
|
38
|
-
});
|