Files
XCEngine/engine/src/Rendering/SceneRenderFeaturePass.cpp

64 lines
2.1 KiB
C++
Raw Normal View History

#include "Rendering/SceneRenderFeaturePass.h"
#include <XCEngine/Rendering/RenderPassGraphContract.h>
#include <algorithm>
namespace XCEngine {
namespace Rendering {
bool SceneRenderFeaturePass::RecordRenderGraph(
const SceneRenderFeaturePassRenderGraphContext& context) {
const bool usesSourceColor = context.sourceColorTexture.IsValid();
const bool hasSourceSurfaceTemplate =
context.sourceSurface != nullptr || usesSourceColor;
const RenderSurface sourceSurfaceTemplate =
context.sourceSurface != nullptr
? *context.sourceSurface
: (usesSourceColor ? context.surface : RenderSurface());
const bool writesColor =
std::any_of(
context.colorTargets.begin(),
context.colorTargets.end(),
[](RenderGraphTextureHandle handle) {
return handle.IsValid();
});
const RenderPassGraphBeginCallback beginPassCallback =
context.beginPassCallback
? RenderPassGraphBeginCallback(
[beginPass = context.beginPassCallback,
clearAttachments = context.clearAttachments](
const RenderPassContext& passContext) {
return beginPass(passContext, clearAttachments);
})
: RenderPassGraphBeginCallback();
const RenderPassRenderGraphContext passContext = {
context.graphBuilder,
context.passName,
context.renderContext,
context.sceneData,
context.surface,
hasSourceSurfaceTemplate ? &sourceSurfaceTemplate : nullptr,
context.sourceColorView,
context.sourceColorState,
context.sourceColorTexture,
context.colorTargets,
context.depthTarget,
context.executionSucceeded,
beginPassCallback,
context.endPassCallback,
context.blackboard
};
return RecordRasterRenderPass(
*this,
passContext,
{
usesSourceColor,
writesColor,
context.depthTarget.IsValid()
});
}
} // namespace Rendering
} // namespace XCEngine