refactor(rendering): infer raster pass graph io from declared context

This commit is contained in:
2026-04-15 13:07:09 +08:00
parent 2605608685
commit 3f0f279000
4 changed files with 59 additions and 22 deletions

View File

@@ -2,6 +2,8 @@
#include <XCEngine/Rendering/RenderPass.h>
#include <algorithm>
namespace XCEngine {
namespace Rendering {
@@ -27,6 +29,22 @@ inline RenderPassGraphIO BuildColorDepthRasterPassGraphIO() {
};
}
inline RenderPassGraphIO BuildDeclaredRasterPassGraphIO(
const RenderPassRenderGraphContext& context) {
const bool writesColor =
std::any_of(
context.colorTargets.begin(),
context.colorTargets.end(),
[](RenderGraphTextureHandle handle) {
return handle.IsValid();
});
return {
context.sourceSurface != nullptr || context.sourceColorTexture.IsValid(),
writesColor,
context.depthTarget.IsValid()
};
}
using RenderPassGraphExecutePassCallback =
std::function<bool(const RenderPassContext&)>;
@@ -59,6 +77,15 @@ inline bool RecordColorDepthRasterPass(
BuildColorDepthRasterPassGraphIO());
}
inline bool RecordDeclaredRasterPass(
RenderPass& pass,
const RenderPassRenderGraphContext& context) {
return RecordRasterRenderPass(
pass,
context,
BuildDeclaredRasterPassGraphIO(context));
}
inline bool RecordSourceColorFullscreenCallbackRasterPass(
const RenderPassRenderGraphContext& context,
RenderPassGraphExecutePassCallback executePassCallback,