@forgeax/engine-render-graph 0.1.32 → 0.1.34

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/README.md CHANGED
@@ -168,7 +168,19 @@ timestamp descriptor.
168
168
  - allocates transactionally, rolling back all staged handles on failure;
169
169
  - returns a separate immutable `CompiledRenderGraph`.
170
170
 
171
- `execute(frame)` resolves imported handles for that frame and encodes passes in declaration order. `inspect()` returns a frozen projection of pass kinds, accesses, dependencies, resource origin, derived usage, and lifetime bounds.
171
+ `execute(frame)` resolves imported handles for that frame and encodes passes in declaration order. `inspect()` returns a frozen projection of pass kinds, accesses, dependencies, resource origin, derived usage, lifetime bounds, and (for graph-created resources) `resourceAllocation`.
172
+
173
+ `inspect().resourceAllocation` is the single compiled-graph logical ledger:
174
+ `liveBytes` are graph-created handles currently live, and
175
+ `pendingRetirementBytes` are handles moved to retirement while the submission
176
+ fence is outstanding. `peakBytes` is that graph generation's simultaneous
177
+ logical high-water mark. Imported resources contribute an explicit owner row
178
+ and unknown byte size; they are never counted as graph-owned physical bytes.
179
+ `retire()` removes a token only after the RHI destroy call succeeds. A destroy
180
+ refusal, throw, or queue-fence failure leaves the bytes pending and returns
181
+ `resource-retire-failed`, so the renderer-wide cross-generation receipt can
182
+ keep the failed owner visible. For active/candidate/retiring generations,
183
+ read [`@forgeax/engine-render`'s allocation inspection](../render/README.md#renderer-wide-graph-allocation-inspection).
172
184
 
173
185
  `retire()` first waits for `device.queue.onSubmittedWorkDone()`, then destroys graph-created resources exactly once. Imported resources are never destroyed by the graph.
174
186
 
@@ -1 +1 @@
1
- {"version":3,"file":"builder.d.ts","sourceRoot":"","sources":["../src/builder.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAW,OAAO,EAAe,MAAM,qBAAqB,CAAC;AAEjF,OAAO,EAAW,gBAAgB,EAAE,KAAK,MAAM,EAAE,MAAM,aAAa,CAAC;AAgBrE,OAAO,KAAK,EACV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A6GhB,OAAO,CAAC,aAAa;IAmBrB,OAAO,CAAC,cAAc;IAatB,OAAO,CAAC,YAAY;IAepB,OAAO,CAAC,kBAAkB;CAQ3B"}
@@ -14,6 +14,7 @@ export declare class CompiledRenderGraphImpl<FrameCtx extends RenderGraphFrame>
14
14
  private readonly colorTargetDescriptors;
15
15
  private retired;
16
16
  private retireResult;
17
+ private readonly allocationLedger;
17
18
  constructor(generation: number, owner: object, device: RhiDevice, resources: ReadonlyMap<number, CompiledResource<FrameCtx>>, views: ReadonlyMap<number, CompiledView<FrameCtx>>, passes: readonly CompiledPass<FrameCtx>[], info: CompiledRenderGraphInfo, colorTargetDescriptors: ReadonlyMap<string, ResolvedColorTargetDescriptor>);
18
19
  inspect(): CompiledRenderGraphInfo;
19
20
  getColorTargetView(name: string): TextureView | undefined;
@@ -1 +1 @@
1
- {"version":3,"file":"compiled-graph.d.ts","sourceRoot":"","sources":["../src/compiled-graph.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAKV,SAAS,EACT,OAAO,EACP,WAAW,EACZ,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAAW,gBAAgB,EAAE,KAAK,MAAM,EAAE,MAAM,aAAa,CAAC;AACrE,OAAO,KAAK,EAAE,6BAA6B,EAAE,MAAM,YAAY,CAAC;AAChE,OAAO,KAAK,EACV,YAAY,EACZ,gBAAgB,EAChB,YAAY,EAEb,MAAM,sBAAsB,CAAC;AAE9B,OAAO,KAAK,EACV,mBAAmB,EACnB,uBAAuB,EAKvB,gBAAgB,EAChB,8BAA8B,EAC9B,qBAAqB,EACtB,MAAM,YAAY,CAAC;AAiBpB,qBAAa,uBAAuB,CAAC,QAAQ,SAAS,gBAAgB,CACpE,YAAW,mBAAmB,CAAC,QAAQ,CAAC;IAMtC,OAAO,CAAC,QAAQ,CAAC,UAAU;IAC3B,OAAO,CAAC,QAAQ,CAAC,KAAK;IACtB,OAAO,CAAC,QAAQ,CAAC,MAAM;IACvB,OAAO,CAAC,QAAQ,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C,MAAM,EAAE,6BAA6B,CAAC;IAuB7F,OAAO,IAAI,uBAAuB;IAIlC,kBAAkB,CAAC,IAAI,EAAE,MAAM,GAAG,WAAW,GAAG,SAAS;IAQzD,qBAAqB,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,GAAG,SAAS;IAOxD,wBAAwB,CAAC,IAAI,EAAE,MAAM,GAAG,6BAA6B,GAAG,SAAS;IAIjF,OAAO,CACL,KAAK,EAAE,QAAQ,EACf,OAAO,CAAC,EAAE,qBAAqB,EAC/B,eAAe,CAAC,EAAE,8BAA8B,CAAC,QAAQ,CAAC,GACzD,MAAM,CAAC,IAAI,EAAE,gBAAgB,CAAC;IAqKjC,MAAM,IAAI,OAAO,CAAC,MAAM,CAAC,IAAI,EAAE,gBAAgB,CAAC,CAAC;YAOnC,YAAY;IAwD1B,OAAO,CAAC,qBAAqB;IAiD7B,OAAO,CAAC,kBAAkB;CAwE3B"}
package/dist/index.d.ts CHANGED
@@ -4,5 +4,5 @@ export type { BufferRole, ColorTargetDescriptor, ColorTargetHandle, ColorTargetS
4
4
  export { RenderGraph } from './graph.js';
5
5
  export { type CurrentFrameObservationDescriptor, type CurrentFrameObservationLease, type CurrentFrameObservationLifetime, type CurrentFrameObservationSource, createCurrentFrameObservationLease, type ObservationSize, } from './observation.js';
6
6
  export { COLOR_VALUE_DOMAINS, type ColorDomainConnection, type ColorDomainConversion, type ColorDomainValidation, type ColorResourceDescriptor, type ColorValueDomain, deserializeColorResourceDescriptor, deserializeColorValueDomain, isColorValueDomain, serializeColorResourceDescriptor, serializeColorValueDomain, validateColorDomainConnection, } from './pipeline/color-value-domain.js';
7
- export type { CompiledRenderGraph, CompiledRenderGraphInfo, CompiledResourceDescriptor, ComputeGraphPass, CopyGraphPass, GraphAccess, GraphAccessInfo, GraphBuffer, GraphBufferAccess, GraphBufferDescriptor, GraphExtent, GraphPass, GraphPassKind, GraphResource, GraphResourceKind, GraphResourceOrigin, GraphResourceResolver, GraphTexture, GraphTextureAccess, GraphTextureDescriptor, GraphTextureView, GraphTextureViewDescriptor, ImportedBufferDescriptor, ImportedTextureDescriptor, ImportedTextureViewResolver, RasterColorAttachment, RasterDepthStencilAttachment, RasterGraphPass, RenderGraphCompileOptions, RenderGraphFrame, RenderGraphPassExecution, RenderGraphPassInstrumentation, RenderGraphPassInstrumentationScope, RenderGraphPassRunner, } from './types.js';
7
+ export type { CompiledRenderGraph, CompiledRenderGraphInfo, CompiledResourceByteSizeUnknownReason, CompiledResourceDescriptor, ComputeGraphPass, CopyGraphPass, GraphAccess, GraphAccessInfo, GraphBuffer, GraphBufferAccess, GraphBufferDescriptor, GraphExtent, GraphPass, GraphPassKind, GraphResource, GraphResourceKind, GraphResourceOrigin, GraphResourceResolver, GraphTexture, GraphTextureAccess, GraphTextureDescriptor, GraphTextureView, GraphTextureViewDescriptor, ImportedBufferDescriptor, ImportedTextureDescriptor, ImportedTextureViewResolver, RasterColorAttachment, RasterDepthStencilAttachment, RasterGraphPass, RenderGraphCompileOptions, RenderGraphFrame, RenderGraphGenerationAllocationEntry, RenderGraphGenerationAllocationInspection, RenderGraphPassExecution, RenderGraphPassInstrumentation, RenderGraphPassInstrumentationScope, RenderGraphPassRunner, RenderGraphResourceAllocationInspection, } from './types.js';
8
8
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAQA,OAAO,EAAE,kBAAkB,EAAE,MAAM,cAAc,CAAC;AAClD,OAAO,EACL,GAAG,EACH,KAAK,mBAAmB,EACxB,EAAE,EACF,gBAAgB,EAChB,KAAK,oBAAoB,EACzB,KAAK,sBAAsB,EAC3B,KAAK,0BAA0B,EAC/B,KAAK,yBAAyB,EAC9B,KAAK,MAAM,EACX,KAAK,SAAS,EACd,KAAK,QAAQ,EACb,KAAK,kBAAkB,EACvB,KAAK,kBAAkB,GACxB,MAAM,aAAa,CAAC;AACrB,YAAY,EACV,UAAU,EACV,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SAAS,EACT,aAAa,EACb,aAAa,EACb,iBAAiB,EACjB,mBAAmB,EACnB,qBAAqB,EACrB,YAAY,EACZ,kBAAkB,EAClB,sBAAsB,EACtB,gBAAgB,EAChB,0BAA0B,EAC1B,wBAAwB,EACxB,yBAAyB,EACzB,2BAA2B,EAC3B,qBAAqB,EACrB,4BAA4B,EAC5B,eAAe,EACf,yBAAyB,EACzB,gBAAgB,EAChB,oCAAoC,EACpC,yCAAyC,EACzC,wBAAwB,EACxB,8BAA8B,EAC9B,mCAAmC,EACnC,qBAAqB,EACrB,uCAAuC,GACxC,MAAM,YAAY,CAAC"}
package/dist/index.mjs CHANGED
@@ -48,6 +48,84 @@ function accessResourceId(access) {
48
48
  }
49
49
 
50
50
  // src/compiled-graph.ts
51
+ var RenderGraphAllocationLedger = class {
52
+ live = /* @__PURE__ */ new Map();
53
+ pending = /* @__PURE__ */ new Map();
54
+ liveBytes = 0;
55
+ pendingBytes = 0;
56
+ peakBytes = 0;
57
+ successfulAllocationCount = 0;
58
+ successfulAllocationBytes = 0;
59
+ retiredBytes = 0;
60
+ unknownByteSizeCount = 0;
61
+ importedResourceCount;
62
+ constructor(entries, importedResourceCount) {
63
+ this.importedResourceCount = importedResourceCount;
64
+ for (const entry of entries) this.allocate(entry.handle, entry.bytes);
65
+ }
66
+ inspect() {
67
+ return {
68
+ unit: "engine-allocation-bytes",
69
+ physicalResidency: "unknown",
70
+ liveBytes: this.liveBytes,
71
+ pendingRetirementBytes: this.pendingBytes,
72
+ peakBytes: this.peakBytes,
73
+ successfulAllocationCount: this.successfulAllocationCount,
74
+ successfulAllocationBytes: this.successfulAllocationBytes,
75
+ pendingRetirementCount: this.pending.size,
76
+ retiredBytes: this.retiredBytes,
77
+ failedAllocationRollbacks: 0,
78
+ failedAllocationRollbackBytes: 0,
79
+ unknownByteSizeCount: this.unknownByteSizeCount,
80
+ importedResourceCount: this.importedResourceCount
81
+ };
82
+ }
83
+ retireAll() {
84
+ for (const handle of [...this.live.keys()]) this.retire(handle);
85
+ }
86
+ release(handle) {
87
+ const pendingBytes = this.pending.get(handle);
88
+ if (pendingBytes !== void 0 || this.pending.has(handle)) {
89
+ this.pending.delete(handle);
90
+ if (pendingBytes !== void 0) this.pendingBytes -= pendingBytes;
91
+ if (pendingBytes === void 0) this.unknownByteSizeCount -= 1;
92
+ this.retiredBytes += pendingBytes ?? 0;
93
+ return;
94
+ }
95
+ const liveBytes = this.live.get(handle);
96
+ if (liveBytes !== void 0 || this.live.has(handle)) {
97
+ this.live.delete(handle);
98
+ if (liveBytes !== void 0) this.liveBytes -= liveBytes;
99
+ if (liveBytes === void 0) this.unknownByteSizeCount -= 1;
100
+ this.retiredBytes += liveBytes ?? 0;
101
+ }
102
+ }
103
+ allocate(handle, bytes) {
104
+ if (this.live.has(handle) || this.pending.has(handle)) return;
105
+ this.live.set(handle, bytes);
106
+ this.successfulAllocationCount += 1;
107
+ if (bytes === void 0) this.unknownByteSizeCount += 1;
108
+ else {
109
+ this.liveBytes += bytes;
110
+ this.successfulAllocationBytes += bytes;
111
+ }
112
+ this.updatePeak();
113
+ }
114
+ retire(handle) {
115
+ const bytes = this.live.get(handle);
116
+ if (bytes === void 0 && !this.live.has(handle)) return;
117
+ this.live.delete(handle);
118
+ if (bytes !== void 0) {
119
+ this.liveBytes -= bytes;
120
+ this.pendingBytes += bytes;
121
+ }
122
+ this.pending.set(handle, bytes);
123
+ this.updatePeak();
124
+ }
125
+ updatePeak() {
126
+ this.peakBytes = Math.max(this.peakBytes, this.liveBytes + this.pendingBytes);
127
+ }
128
+ };
51
129
  function resolutionError(label, cause) {
52
130
  return new RenderGraphError({
53
131
  code: "resource-resolution-failed",
@@ -66,6 +144,25 @@ var CompiledRenderGraphImpl = class {
66
144
  this.passes = passes;
67
145
  this.info = info;
68
146
  this.colorTargetDescriptors = colorTargetDescriptors;
147
+ const infoByLabel = new Map(info.resources.map((resource) => [resource.label, resource]));
148
+ const seen = /* @__PURE__ */ new Set();
149
+ const entries = [];
150
+ let importedResourceCount = 0;
151
+ for (const compiled of resources.values()) {
152
+ if (compiled.usage === 0) continue;
153
+ const handle = compiled.texture ?? compiled.buffer;
154
+ if (compiled.record.origin === "imported") {
155
+ importedResourceCount += 1;
156
+ continue;
157
+ }
158
+ if (handle === void 0 || seen.has(handle)) continue;
159
+ seen.add(handle);
160
+ entries.push({
161
+ handle,
162
+ bytes: infoByLabel.get(compiled.record.label)?.byteSize
163
+ });
164
+ }
165
+ this.allocationLedger = new RenderGraphAllocationLedger(entries, importedResourceCount);
69
166
  }
70
167
  generation;
71
168
  owner;
@@ -77,8 +174,9 @@ var CompiledRenderGraphImpl = class {
77
174
  colorTargetDescriptors;
78
175
  retired = false;
79
176
  retireResult;
177
+ allocationLedger;
80
178
  inspect() {
81
- return this.info;
179
+ return { ...this.info, resourceAllocation: this.allocationLedger.inspect() };
82
180
  }
83
181
  getColorTargetView(name) {
84
182
  for (const view of this.views.values()) {
@@ -234,6 +332,7 @@ var CompiledRenderGraphImpl = class {
234
332
  return this.retireResult;
235
333
  }
236
334
  async finishRetire() {
335
+ this.allocationLedger.retireAll();
237
336
  try {
238
337
  await this.device.queue.onSubmittedWorkDone();
239
338
  } catch (cause) {
@@ -250,8 +349,10 @@ var CompiledRenderGraphImpl = class {
250
349
  for (const compiled of this.resources.values()) {
251
350
  if (compiled.record.origin === "imported") continue;
252
351
  if (compiled.texture === void 0 && compiled.buffer === void 0) continue;
352
+ let destroyedSuccessfully = false;
253
353
  try {
254
354
  const destroyed = compiled.record.kind === "texture" ? this.device.destroyTexture(compiled.texture) : this.device.destroyBuffer(compiled.buffer);
355
+ destroyedSuccessfully = destroyed.ok;
255
356
  if (!destroyed.ok && firstFailure === void 0) {
256
357
  firstFailure = new RenderGraphError({
257
358
  code: "resource-retire-failed",
@@ -271,6 +372,9 @@ var CompiledRenderGraphImpl = class {
271
372
  hint: "inspect detail.cause for the RHI destroy failure",
272
373
  detail: { generation: this.generation, resourceLabel: compiled.record.label, cause }
273
374
  });
375
+ } finally {
376
+ if (destroyedSuccessfully)
377
+ this.allocationLedger.release(compiled.texture ?? compiled.buffer);
274
378
  }
275
379
  }
276
380
  return firstFailure === void 0 ? ok(void 0) : err(firstFailure);
@@ -499,7 +603,7 @@ var TEXTURE_USAGE = {
499
603
  renderAttachment: 16
500
604
  };
501
605
  var nextGeneration = 1;
502
- function textureByteSize(format, extent, mipLevelCount) {
606
+ function textureByteSize(format, dimension, extent, mipLevelCount, sampleCount) {
503
607
  const bytesPerTexel = format === "r8unorm" || format === "r8snorm" || format === "r8uint" || format === "r8sint" ? 1 : format === "rg8unorm" || format === "rg8snorm" || format === "rg8uint" || format === "rg8sint" ? 2 : format === "rgba8unorm" || format === "rgba8unorm-srgb" || format === "rgba8snorm" || format === "rgba8uint" || format === "rgba8sint" || format === "r32float" || format === "r32uint" || format === "r32sint" ? 4 : format === "rg16float" || format === "rg16uint" || format === "rg16sint" || format === "rg16snorm" || format === "rg16unorm" ? 4 : format === "rgba16float" || format === "rgba16uint" || format === "rgba16sint" || format === "rgba16snorm" || format === "rgba16unorm" || format === "rg32float" || format === "rg32uint" || format === "rg32sint" ? 8 : format === "rgba32float" || format === "rgba32uint" || format === "rgba32sint" ? 16 : void 0;
504
608
  if (bytesPerTexel === void 0) return void 0;
505
609
  let bytes = 0;
@@ -507,10 +611,10 @@ function textureByteSize(format, extent, mipLevelCount) {
507
611
  let height = extent.height;
508
612
  let depth = extent.depthOrArrayLayers;
509
613
  for (let level = 0; level < mipLevelCount; level += 1) {
510
- bytes += width * height * depth * bytesPerTexel;
614
+ bytes += width * height * depth * bytesPerTexel * sampleCount;
511
615
  width = Math.max(1, Math.floor(width / 2));
512
616
  height = Math.max(1, Math.floor(height / 2));
513
- depth = Math.max(1, Math.floor(depth / 2));
617
+ if (dimension === "3d") depth = Math.max(1, Math.floor(depth / 2));
514
618
  }
515
619
  return bytes;
516
620
  }
@@ -765,6 +869,14 @@ var RenderGraphBuilder = class {
765
869
  const buffer = resource.record.kind === "buffer" ? resource.record.descriptor : void 0;
766
870
  const allocationKey = physicalKey(resource);
767
871
  const extent = texture === void 0 ? void 0 : this.resolveExtent(texture.size, options.surfaceSize);
872
+ const knownByteSize = resource.record.origin === "imported" || resource.usage === 0 ? void 0 : texture === void 0 ? buffer?.size : textureByteSize(
873
+ texture.format,
874
+ texture.dimension ?? "2d",
875
+ this.resolveExtent(texture.size, options.surfaceSize),
876
+ texture.mipLevelCount ?? 1,
877
+ texture.sampleCount ?? 1
878
+ );
879
+ const byteSizeUnknownReason = resource.record.origin === "imported" ? "imported-owner" : resource.usage === 0 ? "not-allocated" : knownByteSize === void 0 ? "format-or-layout-unknown" : void 0;
768
880
  return {
769
881
  label: resource.record.label,
770
882
  kind: resource.record.kind,
@@ -788,13 +900,8 @@ var RenderGraphBuilder = class {
788
900
  derivedUsage: resource.usage,
789
901
  ...allocationKey === void 0 ? {} : { physicalAllocationKey: allocationKey },
790
902
  ...texture === void 0 ? {} : { format: texture.format },
791
- ...texture === void 0 ? buffer === void 0 ? {} : { byteSize: buffer.size } : {
792
- byteSize: textureByteSize(
793
- texture.format,
794
- this.resolveExtent(texture.size, options.surfaceSize),
795
- texture.mipLevelCount ?? 1
796
- )
797
- },
903
+ ...knownByteSize === void 0 ? {} : { byteSize: knownByteSize },
904
+ ...byteSizeUnknownReason === void 0 ? {} : { byteSizeUnknownReason },
798
905
  ...texture === void 0 ? {} : {
799
906
  dimension: texture.dimension ?? "2d",
800
907
  extent