Repository navigation
Asset Dependency Graph
Asset reference tracking, dependency analysis, unused asset detection, circular dependency detection, and size budgeting for editor workflows.
Source: SparkEditor/Source/Panels/AssetAuditGraph.h (class SparkEditor::AssetAuditGraph)
Note: Prior to 2026-04-10 this class was named
AssetDependencyGraph, which collided with the unrelated build-system graph of the same name inAssetPipeline/AdvancedAssetPipeline.h. The class was renamed toAssetAuditGraphand itsAssetTypeenum toAuditAssetTypeto eliminate the ODR hazard. The two classes now coexist cleanly:AssetAuditGraphis the editor-facing audit/budget tool documented here, whileAssetPipeline::AssetDependencyGraphis the build-system topological graph used by the asset processor pipeline.
The Asset Dependency Graph builds and maintains a directed graph of all asset references in the project. Each node represents an asset (texture, material, mesh, etc.) with its file size and type. Directed edges represent "depends on" relationships -- for example, a material depends on its textures, and a scene depends on the prefabs it places.
The graph supports both forward queries (what does this asset depend on?) and reverse queries (what references this asset?). Transitive dependency resolution uses BFS to collect the full closure of an asset's dependency tree. This powers the Reference Viewer panel, which lets artists and designers understand the impact of changing or deleting an asset.
Two key audit features are built in: unused asset detection finds assets with no incoming references that are not marked as root assets (scenes/levels), and circular dependency detection uses DFS with path tracking to find and report dependency cycles. The size budget system computes the total transitive size for a scene or level, broken down by asset type, helping teams stay within memory and download budgets.
| Class / Struct | Description |
|---|---|
AssetDependencyGraph |
Singleton that owns the graph and provides all query/audit operations |
AssetNode |
A single asset: path, type, size, dependencies, reverse references, root flag |
AssetType |
Enum classifying assets: Texture, Material, Mesh, Animation, Audio, Scene, Prefab, Script, Shader, Font, Data, Video |
CircularDependency |
A detected cycle represented as a chain of asset paths |
SizeBudgetReport |
Total size, asset count, per-type breakdown, and top-N largest assets for a root |
AuditReport |
Project-wide summary: totals, unused count/size, circular dependency count, per-type breakdowns |
auto& graph = SparkEditor::AssetDependencyGraph::GetInstance();
graph.Initialize();
// Register assets and their relationships
graph.RegisterAsset("Materials/Metal.mat", SparkEditor::AssetType::Material, 2048);
graph.RegisterAsset("Textures/Metal_Albedo.png", SparkEditor::AssetType::Texture, 524288);
graph.RegisterAsset("Textures/Metal_Normal.png", SparkEditor::AssetType::Texture, 262144);
graph.AddDependency("Materials/Metal.mat", "Textures/Metal_Albedo.png");
graph.AddDependency("Materials/Metal.mat", "Textures/Metal_Normal.png");
// Mark scenes as root assets (they won't appear as "unused")
graph.SetRootAsset("Scenes/Level_01.scene");
// Query references
auto deps = graph.GetDependencies("Materials/Metal.mat"); // direct deps
auto refs = graph.GetReferencedBy("Textures/Metal_Albedo.png"); // who uses this?
auto all = graph.GetTransitiveDependencies("Scenes/Level_01.scene"); // full closure
// Audit
auto unused = graph.FindUnusedAssets();
auto cycles = graph.FindCircularDependencies();
auto budget = graph.GetSizeBudget("Scenes/Level_01.scene");
auto audit = graph.GenerateAudit();| Method | Return | Description |
|---|---|---|
RegisterAsset(path, type, sizeBytes) |
void |
Add an asset node to the graph |
AddDependency(from, to) |
void |
Add a directed edge: from depends on to
|
RemoveDependency(from, to) |
void |
Remove a dependency edge |
RemoveAsset(path) |
void |
Remove an asset and all its edges |
SetRootAsset(path, isRoot) |
void |
Mark/unmark an asset as a root (scene/level) |
Clear() |
void |
Remove all nodes and edges |
| Method | Return | Description |
|---|---|---|
GetDependencies(path) |
vector<string> |
Direct dependencies of an asset |
GetReferencedBy(path) |
vector<string> |
Assets that reference this asset |
GetTransitiveDependencies(path) |
vector<string> |
All recursive dependencies (BFS) |
GetAsset(path) |
const AssetNode* |
Get the full node for an asset |
GetAssetCount() |
size_t |
Total number of registered assets |
GetAllAssetPaths() |
vector<string> |
All asset paths in the graph |
| Method | Return | Description |
|---|---|---|
FindUnusedAssets() |
vector<string> |
Assets with no references and not marked as root |
FindCircularDependencies() |
vector<CircularDependency> |
All detected dependency cycles |
GetSizeBudget(rootPath) |
SizeBudgetReport |
Size breakdown for a scene and its transitive deps |
GenerateAudit() |
AuditReport |
Full project audit: totals, unused, cycles, per-type stats |
- Asset Browser -- displays assets with reference counts from this graph
- Editor Panels -- Reference Viewer and Asset Audit panels consume this data
- File Watcher -- triggers graph updates when assets change on disk
- Selection Manager -- selecting an asset in the browser can show its dependencies
Published from 2b03dc797148. Edit the canonical source in wiki/.
- Documentation
- Docs route
- Wiki index
- Guides
- Tutorials
- Samples
- Examples
- API Reference
- API route
- Reference
- Build Guide
- Dependencies
- FAQ
- Changelog
- Roadmap
- Contributing
- Code of Conduct
- Home
- FAQ
- Getting Started
- Quick-Start Tutorial
- Making Your First Game
- Making Your First Multiplayer Game
- Artist Workflow Guide
- Editor Walkthrough
- Migration Guide
- How SparkEngine Works
- Architecture Overview
- Engine Architecture Flowchart
- Creating a Game Module
- Game Modules (catalog)
- Entity Component System
- Rendering and Graphics
- Physics
- Cloth Simulation
- Audio
- Input System
- Camera System
- Scripting with AngelScript
- Visual Scripting
- AI and Navigation
- Animation
- 2D Systems
- Networking
- Dedicated Server
- Multiplayer Quick Start
- Area Server Architecture
- Scene Management
- Large World Support
- Collaborative Editing
- Coroutine System
- Event System
- Event Response System
- Job System
- UI System
- UI Layout Extensions
- Localization
- Dialogue System
- Destruction System
- Replay System
- Achievement System
- Loading System
- Mod System
- Content Delivery
- Tween System
- Memory Integrity
- Gameplay Systems
- Terrain and Procedural Generation
- Save System
- Persistence System
- Day Night Cycle and Weather
- Cinematic Sequencer
- Runtime Prefabs
- SparkEditor
- Editor Tutorials
- SparkConsole
- SparkDaemon
- Shader Pipeline
- Asset Pipeline
- Asset Validation
- Asset Migration
- Game Packaging
- Online Services
- DataTable System
- Loot and Crafting System
- CSG System
- Font System
- Timer Manager
- Movie Render Pipeline
- HLOD and World Partition
- Remote Debug System
- Selection Manager
- Asset Dependency Graph
- Editor Automation
- File Watcher
- Project Templates
- System Requirements
- VR Support
- Mobile Platform
- Accessibility
- Platform Input
- Platform Certification
- Cross-Compilation: Wine Testing
- RHI Abstraction Layer
- D3D11 Backend
- D3D12 Backend
- Vulkan Backend
- OpenGL Backend
- Metal Backend
- DXR Raytracing
- Hybrid Ray Tracing
- Upscaling (DLSS/FSR)
- Render Graph
- Shader Graph
- GPU Particles
- GPU-Driven Rendering
- Volumetric Fog
- Volumetric Clouds
- Global Illumination
- Virtual Texturing
- Water Rendering
- Clustered Lighting
- Material System
- Post-Processing
- Shadow System
- Particle System
- Decal System
- Sky and Atmosphere
- Foliage System
- Mesh Shaders
- Neural Rendering
- Configuration Reference
- Performance Tips
- Benchmark Framework
- Threading Model
- Fuzz Policy and Parser Security
- Memory Safety
- Memory Management Patterns
- Build System and CMake Modules
- Profiler and Debugging
- Performance Profiling Guide
- Telemetry System
- Crash Reporting
- Golden Image Testing
- Utilities
- Testing
- Fuzz Policy and Parser Security
- Codebase Statistics
- Codebase Health
- Error Handling Patterns
- Hot Reload Overview
- Troubleshooting
- Contributing
- Workflow Patterns
- Build Optimizations
- CI Reproducible Builds
- GitHub API and PR Checks
- Git Rebase Conflicts
- Clang-Format
- Code Quality Violations
- AI Bloat Pattern
- MinGW + Wine Cross-Compilation
- Live Editor Testing
- Engine & Renderer Landscape
- DuetOS Portability Catalog
- Five-Engine Analysis
- Eleven-Engine Analysis
- ThorVG / Unity Graphics Analysis
- Advanced Techniques Catalog
- Third-Party Library Evaluation
- Engine Viability Evaluation
- Engine Feature Recommendations
- Project Recommendations
- Mac Compatibility Analysis
- Codebase Observations
- Codebase Bloat Audit
- Test Suite Audit
- Documentation Coverage Audit
- ThirdParty Dependencies Audit
- Load Test Baseline
- Gameplay Systems Status
- SparkGame Module Status
- Stub and Abandoned Features
- Memory Integrity System
- Memory Safety Evaluation
- Hardware Acceleration Systems
- Jolt Physics Integration
- GPU/CPU Separation Plan
- Daemon Services Architecture
- Reflection & Polymorphism Refactoring Plan
- SparkBuild In-Tree
- Wine No-JobSystem Breakthrough
- Wine Role and Fallback Tiers