@zenfg/inspector 0.1.0-beta.1

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.
Files changed (123) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +74 -0
  3. package/dist/FrameGraphInspector.d.ts +153 -0
  4. package/dist/FrameGraphInspector.d.ts.map +1 -0
  5. package/dist/FrameGraphInspector.js +580 -0
  6. package/dist/FrameGraphInspector.js.map +1 -0
  7. package/dist/debugCaptureModel.d.ts +166 -0
  8. package/dist/debugCaptureModel.d.ts.map +1 -0
  9. package/dist/debugCaptureModel.js +364 -0
  10. package/dist/debugCaptureModel.js.map +1 -0
  11. package/dist/index.d.ts +17 -0
  12. package/dist/index.d.ts.map +1 -0
  13. package/dist/index.js +15 -0
  14. package/dist/index.js.map +1 -0
  15. package/dist/panelAliasAnalysis.d.ts +20 -0
  16. package/dist/panelAliasAnalysis.d.ts.map +1 -0
  17. package/dist/panelAliasAnalysis.js +113 -0
  18. package/dist/panelAliasAnalysis.js.map +1 -0
  19. package/dist/panelCytoscapeGraphRenderer.d.ts +71 -0
  20. package/dist/panelCytoscapeGraphRenderer.d.ts.map +1 -0
  21. package/dist/panelCytoscapeGraphRenderer.js +559 -0
  22. package/dist/panelCytoscapeGraphRenderer.js.map +1 -0
  23. package/dist/panelDiagnosticsView.d.ts +22 -0
  24. package/dist/panelDiagnosticsView.d.ts.map +1 -0
  25. package/dist/panelDiagnosticsView.js +123 -0
  26. package/dist/panelDiagnosticsView.js.map +1 -0
  27. package/dist/panelDomHelpers.d.ts +26 -0
  28. package/dist/panelDomHelpers.d.ts.map +1 -0
  29. package/dist/panelDomHelpers.js +129 -0
  30. package/dist/panelDomHelpers.js.map +1 -0
  31. package/dist/panelGraphLayout.d.ts +28 -0
  32. package/dist/panelGraphLayout.d.ts.map +1 -0
  33. package/dist/panelGraphLayout.js +223 -0
  34. package/dist/panelGraphLayout.js.map +1 -0
  35. package/dist/panelGraphRenderer.d.ts +20 -0
  36. package/dist/panelGraphRenderer.d.ts.map +1 -0
  37. package/dist/panelGraphRenderer.js +2 -0
  38. package/dist/panelGraphRenderer.js.map +1 -0
  39. package/dist/panelGraphScene.d.ts +98 -0
  40. package/dist/panelGraphScene.d.ts.map +1 -0
  41. package/dist/panelGraphScene.js +559 -0
  42. package/dist/panelGraphScene.js.map +1 -0
  43. package/dist/panelGraphView.d.ts +9 -0
  44. package/dist/panelGraphView.d.ts.map +1 -0
  45. package/dist/panelGraphView.js +88 -0
  46. package/dist/panelGraphView.js.map +1 -0
  47. package/dist/panelGraphVisuals.d.ts +38 -0
  48. package/dist/panelGraphVisuals.d.ts.map +1 -0
  49. package/dist/panelGraphVisuals.js +330 -0
  50. package/dist/panelGraphVisuals.js.map +1 -0
  51. package/dist/panelIcons.d.ts +4 -0
  52. package/dist/panelIcons.d.ts.map +1 -0
  53. package/dist/panelIcons.js +43 -0
  54. package/dist/panelIcons.js.map +1 -0
  55. package/dist/panelInspectorView.d.ts +33 -0
  56. package/dist/panelInspectorView.d.ts.map +1 -0
  57. package/dist/panelInspectorView.js +357 -0
  58. package/dist/panelInspectorView.js.map +1 -0
  59. package/dist/panelMemoryView.d.ts +21 -0
  60. package/dist/panelMemoryView.d.ts.map +1 -0
  61. package/dist/panelMemoryView.js +134 -0
  62. package/dist/panelMemoryView.js.map +1 -0
  63. package/dist/panelPassesView.d.ts +31 -0
  64. package/dist/panelPassesView.d.ts.map +1 -0
  65. package/dist/panelPassesView.js +183 -0
  66. package/dist/panelPassesView.js.map +1 -0
  67. package/dist/panelResourcesView.d.ts +19 -0
  68. package/dist/panelResourcesView.d.ts.map +1 -0
  69. package/dist/panelResourcesView.js +89 -0
  70. package/dist/panelResourcesView.js.map +1 -0
  71. package/dist/panelSelection.d.ts +5 -0
  72. package/dist/panelSelection.d.ts.map +1 -0
  73. package/dist/panelSelection.js +88 -0
  74. package/dist/panelSelection.js.map +1 -0
  75. package/dist/panelTypes.d.ts +40 -0
  76. package/dist/panelTypes.d.ts.map +1 -0
  77. package/dist/panelTypes.js +2 -0
  78. package/dist/panelTypes.js.map +1 -0
  79. package/dist/panelVisualTheme.d.ts +76 -0
  80. package/dist/panelVisualTheme.d.ts.map +1 -0
  81. package/dist/panelVisualTheme.js +39 -0
  82. package/dist/panelVisualTheme.js.map +1 -0
  83. package/dist/panelWorkbenchHelpers.d.ts +34 -0
  84. package/dist/panelWorkbenchHelpers.d.ts.map +1 -0
  85. package/dist/panelWorkbenchHelpers.js +162 -0
  86. package/dist/panelWorkbenchHelpers.js.map +1 -0
  87. package/dist/panelWorkbenchView.d.ts +77 -0
  88. package/dist/panelWorkbenchView.d.ts.map +1 -0
  89. package/dist/panelWorkbenchView.js +409 -0
  90. package/dist/panelWorkbenchView.js.map +1 -0
  91. package/dist/query.d.ts +11 -0
  92. package/dist/query.d.ts.map +1 -0
  93. package/dist/query.js +21 -0
  94. package/dist/query.js.map +1 -0
  95. package/dist/styles.d.ts +8 -0
  96. package/dist/styles.d.ts.map +1 -0
  97. package/dist/styles.js +1073 -0
  98. package/dist/styles.js.map +1 -0
  99. package/package.json +29 -0
  100. package/src/FrameGraphInspector.ts +632 -0
  101. package/src/debugCaptureModel.ts +583 -0
  102. package/src/index.ts +21 -0
  103. package/src/panelAliasAnalysis.ts +164 -0
  104. package/src/panelCytoscapeGraphRenderer.ts +617 -0
  105. package/src/panelDiagnosticsView.ts +160 -0
  106. package/src/panelDomHelpers.ts +151 -0
  107. package/src/panelGraphLayout.ts +281 -0
  108. package/src/panelGraphRenderer.ts +21 -0
  109. package/src/panelGraphScene.ts +787 -0
  110. package/src/panelGraphView.ts +108 -0
  111. package/src/panelGraphVisuals.ts +364 -0
  112. package/src/panelIcons.ts +56 -0
  113. package/src/panelInspectorView.ts +377 -0
  114. package/src/panelMemoryView.ts +154 -0
  115. package/src/panelPassesView.ts +222 -0
  116. package/src/panelResourcesView.ts +115 -0
  117. package/src/panelSelection.ts +99 -0
  118. package/src/panelTypes.ts +28 -0
  119. package/src/panelVisualTheme.ts +39 -0
  120. package/src/panelWorkbenchHelpers.ts +216 -0
  121. package/src/panelWorkbenchView.ts +465 -0
  122. package/src/query.ts +22 -0
  123. package/src/styles.ts +1076 -0
@@ -0,0 +1,164 @@
1
+ import type {
2
+ FrameGraphDebugPhysicalAllocation,
3
+ FrameGraphDebugResource,
4
+ FrameGraphDebugViewModel,
5
+ } from './debugCaptureModel.ts';
6
+
7
+ export type AliasAnalysisResource = {
8
+ readonly resource: FrameGraphDebugResource;
9
+ readonly allocation?: FrameGraphDebugPhysicalAllocation;
10
+ readonly aliasStatus: 'aliased' | 'single' | 'not-transient' | 'not-allocated' | 'no-lifetime';
11
+ readonly nonAliasReasons: readonly string[];
12
+ };
13
+
14
+ export type AliasAnalysisAllocation = {
15
+ readonly allocation: FrameGraphDebugPhysicalAllocation;
16
+ readonly resources: readonly FrameGraphDebugResource[];
17
+ readonly aliases: boolean;
18
+ };
19
+
20
+ export type AliasAnalysis = {
21
+ readonly allocations: readonly AliasAnalysisAllocation[];
22
+ readonly resources: ReadonlyMap<string, AliasAnalysisResource>;
23
+ readonly minUse: number;
24
+ readonly maxUse: number;
25
+ };
26
+
27
+ export function analyzeSnapshotAliases(snapshot: FrameGraphDebugViewModel): AliasAnalysis {
28
+ const allocationById = snapshot.allocationById;
29
+ const resourcesById = snapshot.resourceById;
30
+ const allocationGroups = snapshot.physicalAllocations.map((allocation): AliasAnalysisAllocation => {
31
+ const resources = allocation.resourceIds
32
+ .map((resourceId) => resourcesById.get(resourceId))
33
+ .filter((resource): resource is FrameGraphDebugResource => resource !== undefined);
34
+ return {
35
+ allocation,
36
+ resources,
37
+ aliases: resources.length > 1,
38
+ };
39
+ });
40
+
41
+ const allocationGroupById = new Map(allocationGroups.map((group) => [group.allocation.id, group]));
42
+
43
+ let minUse = Number.POSITIVE_INFINITY;
44
+ let maxUse = Number.NEGATIVE_INFINITY;
45
+ for (const resource of snapshot.resources) {
46
+ if (!resource.lifetime) {
47
+ continue;
48
+ }
49
+ minUse = Math.min(minUse, resource.lifetime.firstUse);
50
+ maxUse = Math.max(maxUse, resource.lifetime.lastUse);
51
+ }
52
+ if (!Number.isFinite(minUse) || !Number.isFinite(maxUse)) {
53
+ minUse = 0;
54
+ maxUse = 0;
55
+ }
56
+
57
+ const resourceAnalysis = new Map<string, AliasAnalysisResource>();
58
+ for (const resource of snapshot.resources) {
59
+ const allocation = resource.physicalResourceId === undefined ? undefined : allocationById.get(resource.physicalResourceId);
60
+ const allocationResources = allocation
61
+ ? allocationGroupById.get(allocation.id)?.resources ?? []
62
+ : [];
63
+ const aliasStatus = resolveAliasStatus(resource, allocation, allocationResources);
64
+ resourceAnalysis.set(resource.id, {
65
+ resource,
66
+ allocation,
67
+ aliasStatus,
68
+ nonAliasReasons: resolveNonAliasReasons(resource, allocation, allocationGroups),
69
+ });
70
+ }
71
+
72
+ return {
73
+ allocations: allocationGroups,
74
+ resources: resourceAnalysis,
75
+ minUse,
76
+ maxUse,
77
+ };
78
+ }
79
+
80
+ function resolveAliasStatus(
81
+ resource: FrameGraphDebugResource,
82
+ allocation: FrameGraphDebugPhysicalAllocation | undefined,
83
+ allocationResources: readonly FrameGraphDebugResource[],
84
+ ): AliasAnalysisResource['aliasStatus'] {
85
+ if (resource.origin !== 'transient') {
86
+ return 'not-transient';
87
+ }
88
+ if (!resource.lifetime) {
89
+ return 'no-lifetime';
90
+ }
91
+ if (!allocation) {
92
+ return 'not-allocated';
93
+ }
94
+ return allocationResources.length > 1 ? 'aliased' : 'single';
95
+ }
96
+
97
+ function resolveNonAliasReasons(
98
+ resource: FrameGraphDebugResource,
99
+ allocation: FrameGraphDebugPhysicalAllocation | undefined,
100
+ allocations: readonly AliasAnalysisAllocation[],
101
+ ): readonly string[] {
102
+ if (resource.origin !== 'transient') {
103
+ return ['Imported or swapchain resources do not participate in transient aliasing.'];
104
+ }
105
+ if (!resource.lifetime) {
106
+ return ['No lifetime is available for this resource in the retained graph.'];
107
+ }
108
+ if (!allocation) {
109
+ return ['No physical allocation is associated with this transient resource.'];
110
+ }
111
+
112
+ const reasons = new Set<string>();
113
+ for (const group of allocations) {
114
+ if (group.allocation.id === allocation.id) {
115
+ continue;
116
+ }
117
+ for (const other of group.resources) {
118
+ if (other.id === resource.id || other.origin !== 'transient') {
119
+ continue;
120
+ }
121
+ if (other.kind !== resource.kind) {
122
+ reasons.add(`Different kind from ${labelDebugResource(other)}.`);
123
+ continue;
124
+ }
125
+ if (group.allocation.compatibilityClassId !== allocation.compatibilityClassId) {
126
+ reasons.add(`Different compatibility class from ${labelDebugResource(other)}.`);
127
+ continue;
128
+ }
129
+ if (!other.lifetime) {
130
+ reasons.add(`Missing lifetime for ${labelDebugResource(other)}.`);
131
+ continue;
132
+ }
133
+ if (lifetimesOverlap(resource.lifetime, other.lifetime)) {
134
+ reasons.add(`Lifetime overlaps ${labelDebugResource(other)} (${other.lifetime.firstUse}-${other.lifetime.lastUse}).`);
135
+ }
136
+ }
137
+ }
138
+
139
+ if (reasons.size === 0) {
140
+ return allocationResourcesFor(allocations, allocation.id).length > 1
141
+ ? ['Aliases with resources in the same physical allocation.']
142
+ : ['No compatible non-overlapping transient resource was found in this snapshot.'];
143
+ }
144
+
145
+ return Array.from(reasons).slice(0, 6);
146
+ }
147
+
148
+ function allocationResourcesFor(
149
+ allocations: readonly AliasAnalysisAllocation[],
150
+ allocationId: string,
151
+ ): readonly FrameGraphDebugResource[] {
152
+ return allocations.find((group) => group.allocation.id === allocationId)?.resources ?? [];
153
+ }
154
+
155
+ function lifetimesOverlap(
156
+ a: NonNullable<FrameGraphDebugResource['lifetime']>,
157
+ b: NonNullable<FrameGraphDebugResource['lifetime']>,
158
+ ): boolean {
159
+ return a.firstUse <= b.lastUse && b.firstUse <= a.lastUse;
160
+ }
161
+
162
+ function labelDebugResource(resource: FrameGraphDebugResource): string {
163
+ return resource.label ?? `${resource.kind}-${resource.id}`;
164
+ }