215 lines
7.1 KiB
C++
215 lines
7.1 KiB
C++
#pragma once
|
|
|
|
#include <XCEngine/Rendering/RenderPipeline.h>
|
|
#include <XCEngine/Rendering/SceneRenderFeaturePass.h>
|
|
|
|
namespace XCEngine {
|
|
namespace Rendering {
|
|
|
|
struct RenderGraphRecordingContext {
|
|
RenderGraphBuilder& graphBuilder;
|
|
Containers::String passName = {};
|
|
const RenderContext& renderContext;
|
|
const RenderSceneData& sceneData;
|
|
RenderSurface surface = {};
|
|
const RenderSurface* sourceSurface = nullptr;
|
|
RHI::RHIResourceView* sourceColorView = nullptr;
|
|
RHI::ResourceStates sourceColorState = RHI::ResourceStates::Common;
|
|
RenderGraphTextureHandle sourceColorTexture = {};
|
|
std::vector<RenderGraphTextureHandle> colorTargets = {};
|
|
RenderGraphTextureHandle depthTarget = {};
|
|
bool* executionSucceeded = nullptr;
|
|
RenderGraphBlackboard* blackboard = nullptr;
|
|
};
|
|
|
|
struct RenderGraphRecordingContextOverrides {
|
|
const Containers::String* passName = nullptr;
|
|
const RenderSurface* surface = nullptr;
|
|
bool overrideSourceSurface = false;
|
|
const RenderSurface* sourceSurface = nullptr;
|
|
bool overrideSourceColorView = false;
|
|
RHI::RHIResourceView* sourceColorView = nullptr;
|
|
bool overrideSourceColorState = false;
|
|
RHI::ResourceStates sourceColorState = RHI::ResourceStates::Common;
|
|
bool overrideSourceColorTexture = false;
|
|
RenderGraphTextureHandle sourceColorTexture = {};
|
|
bool overrideColorTargets = false;
|
|
std::vector<RenderGraphTextureHandle> colorTargets = {};
|
|
bool overrideDepthTarget = false;
|
|
RenderGraphTextureHandle depthTarget = {};
|
|
};
|
|
|
|
inline RenderGraphRecordingContext CloneRenderGraphRecordingContext(
|
|
const RenderGraphRecordingContext& context,
|
|
const RenderGraphRecordingContextOverrides& overrides) {
|
|
RenderGraphRecordingContext clone = {
|
|
context.graphBuilder,
|
|
overrides.passName != nullptr ? *overrides.passName : context.passName,
|
|
context.renderContext,
|
|
context.sceneData,
|
|
overrides.surface != nullptr ? *overrides.surface : context.surface,
|
|
overrides.overrideSourceSurface ? overrides.sourceSurface : context.sourceSurface,
|
|
overrides.overrideSourceColorView ? overrides.sourceColorView : context.sourceColorView,
|
|
overrides.overrideSourceColorState ? overrides.sourceColorState : context.sourceColorState,
|
|
overrides.overrideSourceColorTexture ? overrides.sourceColorTexture : context.sourceColorTexture,
|
|
overrides.overrideColorTargets ? overrides.colorTargets : context.colorTargets,
|
|
overrides.overrideDepthTarget ? overrides.depthTarget : context.depthTarget,
|
|
context.executionSucceeded,
|
|
context.blackboard
|
|
};
|
|
return clone;
|
|
}
|
|
|
|
inline RenderGraphRecordingContext CloneRenderGraphRecordingContext(
|
|
const RenderGraphRecordingContext& context,
|
|
const Containers::String& passName) {
|
|
const RenderGraphRecordingContextOverrides overrides = {
|
|
&passName
|
|
};
|
|
return CloneRenderGraphRecordingContext(
|
|
context,
|
|
overrides);
|
|
}
|
|
|
|
inline RenderGraphRecordingContext BuildRenderGraphRecordingContext(
|
|
const RenderPassRenderGraphContext& context) {
|
|
return {
|
|
context.graphBuilder,
|
|
context.passName,
|
|
context.renderContext,
|
|
context.sceneData,
|
|
context.surface,
|
|
context.sourceSurface,
|
|
context.sourceColorView,
|
|
context.sourceColorState,
|
|
context.sourceColorTexture,
|
|
context.colorTargets,
|
|
context.depthTarget,
|
|
context.executionSucceeded,
|
|
context.blackboard
|
|
};
|
|
}
|
|
|
|
inline RenderGraphRecordingContext BuildRenderGraphRecordingContext(
|
|
const SceneRenderFeaturePassRenderGraphContext& context) {
|
|
return {
|
|
context.graphBuilder,
|
|
context.passName,
|
|
context.renderContext,
|
|
context.sceneData,
|
|
context.surface,
|
|
context.sourceSurface,
|
|
context.sourceColorView,
|
|
context.sourceColorState,
|
|
context.sourceColorTexture,
|
|
context.colorTargets,
|
|
context.depthTarget,
|
|
context.executionSucceeded,
|
|
context.blackboard
|
|
};
|
|
}
|
|
|
|
inline RenderGraphRecordingContext BuildRenderGraphRecordingContext(
|
|
const RenderPipelineStageRenderGraphContext& context) {
|
|
return {
|
|
context.graphBuilder,
|
|
context.passName,
|
|
context.renderContext,
|
|
context.sceneData,
|
|
context.surfaceTemplate,
|
|
context.sourceSurface,
|
|
context.sourceColorView,
|
|
context.sourceColorState,
|
|
context.sourceColorTexture,
|
|
context.colorTargets,
|
|
context.depthTarget,
|
|
context.executionSucceeded,
|
|
context.blackboard
|
|
};
|
|
}
|
|
|
|
inline RenderPassRenderGraphContext BuildRenderPassRenderGraphContext(
|
|
const RenderGraphRecordingContext& common,
|
|
RenderPassGraphBeginCallback beginPassCallback = {},
|
|
RenderPassGraphEndCallback endPassCallback = {}) {
|
|
return {
|
|
common.graphBuilder,
|
|
common.passName,
|
|
common.renderContext,
|
|
common.sceneData,
|
|
common.surface,
|
|
common.sourceSurface,
|
|
common.sourceColorView,
|
|
common.sourceColorState,
|
|
common.sourceColorTexture,
|
|
common.colorTargets,
|
|
common.depthTarget,
|
|
common.executionSucceeded,
|
|
beginPassCallback,
|
|
endPassCallback,
|
|
common.blackboard
|
|
};
|
|
}
|
|
|
|
inline SceneRenderFeaturePassRenderGraphContext BuildSceneRenderFeaturePassRenderGraphContext(
|
|
const RenderGraphRecordingContext& common,
|
|
bool clearAttachments = false,
|
|
SceneRenderFeaturePassBeginCallback beginPassCallback = {},
|
|
SceneRenderFeaturePassEndCallback endPassCallback = {}) {
|
|
return {
|
|
common.graphBuilder,
|
|
common.passName,
|
|
common.renderContext,
|
|
common.sceneData,
|
|
common.surface,
|
|
common.sourceSurface,
|
|
common.sourceColorView,
|
|
common.sourceColorState,
|
|
common.sourceColorTexture,
|
|
common.colorTargets,
|
|
common.depthTarget,
|
|
clearAttachments,
|
|
common.executionSucceeded,
|
|
beginPassCallback,
|
|
endPassCallback,
|
|
common.blackboard
|
|
};
|
|
}
|
|
|
|
inline RenderPipelineStageRenderGraphContext BuildRenderPipelineStageRenderGraphContext(
|
|
const RenderGraphRecordingContext& common,
|
|
CameraFrameStage stage) {
|
|
return {
|
|
common.graphBuilder,
|
|
common.passName,
|
|
stage,
|
|
common.renderContext,
|
|
common.sceneData,
|
|
common.surface,
|
|
common.sourceSurface,
|
|
common.sourceColorView,
|
|
common.sourceColorState,
|
|
common.sourceColorTexture,
|
|
common.colorTargets,
|
|
common.depthTarget,
|
|
common.executionSucceeded,
|
|
common.blackboard
|
|
};
|
|
}
|
|
|
|
inline SceneRenderFeaturePassRenderGraphContext CloneSceneRenderFeaturePassRenderGraphContext(
|
|
const SceneRenderFeaturePassRenderGraphContext& context,
|
|
const Containers::String& passName,
|
|
bool clearAttachments) {
|
|
return BuildSceneRenderFeaturePassRenderGraphContext(
|
|
CloneRenderGraphRecordingContext(
|
|
BuildRenderGraphRecordingContext(context),
|
|
passName),
|
|
clearAttachments,
|
|
context.beginPassCallback,
|
|
context.endPassCallback);
|
|
}
|
|
|
|
} // namespace Rendering
|
|
} // namespace XCEngine
|