2026-04-14 16:49:06 +08:00
|
|
|
#include "Rendering/SceneRenderFeaturePass.h"
|
|
|
|
|
|
2026-04-15 07:39:28 +08:00
|
|
|
#include <XCEngine/Rendering/RenderPassGraphContract.h>
|
2026-04-14 21:11:04 +08:00
|
|
|
|
|
|
|
|
#include <algorithm>
|
2026-04-14 16:49:06 +08:00
|
|
|
|
|
|
|
|
namespace XCEngine {
|
|
|
|
|
namespace Rendering {
|
|
|
|
|
|
|
|
|
|
bool SceneRenderFeaturePass::RecordRenderGraph(
|
|
|
|
|
const SceneRenderFeaturePassRenderGraphContext& context) {
|
2026-04-14 21:11:04 +08:00
|
|
|
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
|
|
|
|
|
};
|
2026-04-15 07:39:28 +08:00
|
|
|
return RecordRasterRenderPass(
|
2026-04-14 21:11:04 +08:00
|
|
|
*this,
|
|
|
|
|
passContext,
|
|
|
|
|
{
|
|
|
|
|
usesSourceColor,
|
|
|
|
|
writesColor,
|
|
|
|
|
context.depthTarget.IsValid()
|
2026-04-14 16:49:06 +08:00
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
} // namespace Rendering
|
|
|
|
|
} // namespace XCEngine
|