#include "Rendering/Pipelines/BuiltinForwardPipeline.h" #include "Debug/Logger.h" #include "Rendering/Pipelines/Internal/BuiltinForwardSceneSetup.h" namespace XCEngine { namespace Rendering { namespace Pipelines { ScenePhaseExecutionContext BuiltinForwardPipeline::BuildScenePhaseExecutionContext( const FrameExecutionContext& executionContext, ScenePhase scenePhase) const { return ScenePhaseExecutionContext( executionContext, scenePhase, ShouldSampleMainDirectionalShadowMap(executionContext.sceneData)); } DrawSettings BuiltinForwardPipeline::BuildDrawSettings(ScenePhase scenePhase) const { DrawSettings drawSettings = {}; drawSettings.scenePhase = scenePhase; switch (scenePhase) { case ScenePhase::Opaque: drawSettings.rendererListType = RendererListType::Opaque; break; case ScenePhase::Transparent: drawSettings.rendererListType = RendererListType::Transparent; break; default: drawSettings.rendererListType = RendererListType::AllVisible; break; } return drawSettings; } bool BuiltinForwardPipeline::ExecuteBuiltinScenePhase( const ScenePhaseExecutionContext& executionContext) { switch (executionContext.scenePhase) { case ScenePhase::Opaque: return ExecuteForwardOpaquePass(executionContext); case ScenePhase::Skybox: return ExecuteForwardSkyboxPass(BuildRenderPassContext(executionContext)); case ScenePhase::Transparent: return ExecuteForwardTransparentPass(executionContext); default: Debug::Logger::Get().Error( Debug::LogCategory::Rendering, (Containers::String("BuiltinForwardPipeline::ExecuteBuiltinScenePhase does not support scene phase: ") + ToString(executionContext.scenePhase)).CStr()); return false; } } bool BuiltinForwardPipeline::ExecuteForwardScene( const FrameExecutionContext& executionContext) { return ExecuteForwardSceneSteps( executionContext, 0u, Internal::GetBuiltinForwardSceneSteps().size()); } bool BuiltinForwardPipeline::ExecuteForwardSceneSteps( const FrameExecutionContext& executionContext, size_t beginStepIndex, size_t endStepIndex) { const auto& steps = Internal::GetBuiltinForwardSceneSteps(); if (beginStepIndex > endStepIndex || endStepIndex > steps.size()) { Debug::Logger::Get().Error( Debug::LogCategory::Rendering, "BuiltinForwardPipeline::ExecuteForwardSceneSteps received an invalid step range"); return false; } for (size_t stepIndex = beginStepIndex; stepIndex < endStepIndex; ++stepIndex) { const Internal::ForwardSceneStep& step = steps[stepIndex]; if (step.type == Internal::ForwardSceneStepType::InjectionPoint) { if (m_forwardSceneFeatureHost.Execute(executionContext, step.injectionPoint)) { continue; } Debug::Logger::Get().Error( Debug::LogCategory::Rendering, (Containers::String("BuiltinForwardPipeline::ExecuteForwardScene failed at injection point: ") + ToString(step.injectionPoint)).CStr()); return false; } const ScenePhaseExecutionContext scenePhaseExecutionContext = BuildScenePhaseExecutionContext(executionContext, step.scenePhase); if (!ExecuteBuiltinScenePhase(scenePhaseExecutionContext)) { Debug::Logger::Get().Error( Debug::LogCategory::Rendering, (Containers::String("BuiltinForwardPipeline::ExecuteForwardScene failed during builtin phase: ") + ToString(step.scenePhase)).CStr()); return false; } } return true; } } // namespace Pipelines } // namespace Rendering } // namespace XCEngine