2026-04-14 16:49:06 +08:00
|
|
|
#include "Rendering/SceneRenderFeaturePass.h"
|
|
|
|
|
|
2026-04-15 12:40:31 +08:00
|
|
|
#include <XCEngine/Rendering/Graph/RenderGraphRecordingContext.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 writesColor =
|
|
|
|
|
std::any_of(
|
|
|
|
|
context.colorTargets.begin(),
|
|
|
|
|
context.colorTargets.end(),
|
|
|
|
|
[](RenderGraphTextureHandle handle) {
|
|
|
|
|
return handle.IsValid();
|
|
|
|
|
});
|
2026-04-15 13:01:04 +08:00
|
|
|
const RenderGraphRecordingContext baseRecordingContext =
|
2026-04-15 12:40:31 +08:00
|
|
|
BuildRenderGraphRecordingContext(context);
|
|
|
|
|
const RenderSurface sourceSurfaceTemplate =
|
2026-04-15 13:01:04 +08:00
|
|
|
baseRecordingContext.sourceSurface != nullptr
|
|
|
|
|
? *baseRecordingContext.sourceSurface
|
2026-04-15 12:40:31 +08:00
|
|
|
: (usesSourceColor ? context.surface : RenderSurface());
|
2026-04-15 13:01:04 +08:00
|
|
|
RenderGraphRecordingContextOverrides overrides = {};
|
|
|
|
|
overrides.overrideSourceSurface =
|
|
|
|
|
baseRecordingContext.sourceSurface == nullptr && usesSourceColor;
|
|
|
|
|
overrides.sourceSurface =
|
|
|
|
|
overrides.overrideSourceSurface ? &sourceSurfaceTemplate : nullptr;
|
|
|
|
|
const RenderGraphRecordingContext recordingContext =
|
|
|
|
|
CloneRenderGraphRecordingContext(
|
|
|
|
|
baseRecordingContext,
|
|
|
|
|
overrides);
|
2026-04-15 12:40:31 +08:00
|
|
|
|
2026-04-14 21:11:04 +08:00
|
|
|
const RenderPassGraphBeginCallback beginPassCallback =
|
|
|
|
|
context.beginPassCallback
|
|
|
|
|
? RenderPassGraphBeginCallback(
|
|
|
|
|
[beginPass = context.beginPassCallback,
|
|
|
|
|
clearAttachments = context.clearAttachments](
|
|
|
|
|
const RenderPassContext& passContext) {
|
|
|
|
|
return beginPass(passContext, clearAttachments);
|
|
|
|
|
})
|
|
|
|
|
: RenderPassGraphBeginCallback();
|
2026-04-15 12:40:31 +08:00
|
|
|
const RenderPassRenderGraphContext passContext =
|
|
|
|
|
BuildRenderPassRenderGraphContext(
|
|
|
|
|
recordingContext,
|
|
|
|
|
beginPassCallback,
|
|
|
|
|
context.endPassCallback);
|
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
|