| 47 | {} |
| 48 | |
| 49 | std::unique_ptr<RenderGraphExe> RenderGraphCompiler::compile( |
| 50 | RenderGraph& graph, |
| 51 | RenderContext* pRenderContext, |
| 52 | const Dependencies& dependencies |
| 53 | ) |
| 54 | { |
| 55 | RenderGraphCompiler c = RenderGraphCompiler(graph, dependencies); |
| 56 | |
| 57 | // Register the external resources |
| 58 | auto pResourcesCache = std::make_unique<ResourceCache>(); |
| 59 | for (const auto& [name, pRes] : dependencies.externalResources) |
| 60 | pResourcesCache->registerExternalResource(name, pRes); |
| 61 | |
| 62 | c.resolveExecutionOrder(); |
| 63 | c.compilePasses(pRenderContext); |
| 64 | if (c.insertAutoPasses()) |
| 65 | c.resolveExecutionOrder(); |
| 66 | c.validateGraph(); |
| 67 | c.allocateResources(pRenderContext->getDevice(), pResourcesCache.get()); |
| 68 | |
| 69 | auto pExe = std::make_unique<RenderGraphExe>(); |
| 70 | pExe->mExecutionList.reserve(c.mExecutionList.size()); |
| 71 | |
| 72 | for (auto e : c.mExecutionList) |
| 73 | { |
| 74 | pExe->insertPass(e.name, e.pPass); |
| 75 | } |
| 76 | c.restoreCompilationChanges(); |
| 77 | pExe->mpResourceCache = std::move(pResourcesCache); |
| 78 | return pExe; |
| 79 | } |
| 80 | |
| 81 | void RenderGraphCompiler::validateGraph() const |
| 82 | { |
no test coverage detected