#include "Rendering/SceneRenderFeaturePass.h" #include "Rendering/Graph/RenderGraph.h" namespace XCEngine { namespace Rendering { bool SceneRenderFeaturePass::RecordRenderGraph( const SceneRenderFeaturePassRenderGraphContext& context) { SceneRenderFeaturePass* const featurePass = this; const Containers::String passName = context.passName; const RenderContext* const renderContext = &context.renderContext; const RenderSceneData* const sceneData = &context.sceneData; const RenderSurface surface = context.surface; const RenderSurface* const sourceSurface = context.sourceSurface; RHI::RHIResourceView* const sourceColorView = context.sourceColorView; const RHI::ResourceStates sourceColorState = context.sourceColorState; const std::vector colorTargets = context.colorTargets; const RenderGraphTextureHandle depthTarget = context.depthTarget; const bool clearAttachments = context.clearAttachments; bool* const executionSucceeded = context.executionSucceeded; const SceneRenderFeaturePassBeginCallback beginPassCallback = context.beginPassCallback; const SceneRenderFeaturePassEndCallback endPassCallback = context.endPassCallback; context.graphBuilder.AddRasterPass( passName, [featurePass, renderContext, sceneData, surface, sourceSurface, sourceColorView, sourceColorState, colorTargets, depthTarget, clearAttachments, executionSucceeded, beginPassCallback, endPassCallback]( RenderGraphPassBuilder& passBuilder) { for (RenderGraphTextureHandle colorTarget : colorTargets) { if (colorTarget.IsValid()) { passBuilder.WriteTexture(colorTarget); } } if (depthTarget.IsValid()) { passBuilder.WriteDepthTexture(depthTarget); } passBuilder.SetExecuteCallback( [featurePass, renderContext, sceneData, surface, sourceSurface, sourceColorView, sourceColorState, clearAttachments, executionSucceeded, beginPassCallback, endPassCallback]( const RenderGraphExecutionContext&) { if (executionSucceeded != nullptr && !(*executionSucceeded)) { return; } const FrameExecutionContext executionContext( *renderContext, surface, *sceneData, sourceSurface, sourceColorView, sourceColorState); const RenderPassContext passContext = BuildRenderPassContext(executionContext); if (beginPassCallback && !beginPassCallback(passContext, clearAttachments)) { if (executionSucceeded != nullptr) { *executionSucceeded = false; } return; } const bool executeResult = featurePass->Execute(passContext); if (endPassCallback) { endPassCallback(passContext); } if (executionSucceeded != nullptr) { *executionSucceeded = executeResult; } }); }); return true; } } // namespace Rendering } // namespace XCEngine