refactor: generalize renderer builtin post process
This commit is contained in:
@@ -32,14 +32,14 @@ struct ObjectIdRenderRequest {
|
||||
}
|
||||
};
|
||||
|
||||
struct BuiltinSceneViewPostProcessRequest {
|
||||
struct BuiltinPostProcessRequest {
|
||||
Passes::InfiniteGridPassData gridPassData = {};
|
||||
RHI::RHIResourceView* objectIdTextureView = nullptr;
|
||||
std::vector<uint64_t> selectedObjectIds = {};
|
||||
Passes::ObjectIdOutlineStyle outlineStyle = {};
|
||||
|
||||
bool IsRequested() const {
|
||||
return gridPassData.valid;
|
||||
return gridPassData.valid || !selectedObjectIds.empty();
|
||||
}
|
||||
};
|
||||
|
||||
@@ -49,7 +49,7 @@ struct CameraRenderRequest {
|
||||
RenderContext context;
|
||||
RenderSurface surface;
|
||||
ObjectIdRenderRequest objectId;
|
||||
BuiltinSceneViewPostProcessRequest builtinSceneViewPostProcess;
|
||||
BuiltinPostProcessRequest builtinPostProcess;
|
||||
float cameraDepth = 0.0f;
|
||||
uint8_t cameraStackOrder = 0;
|
||||
RenderClearFlags clearFlags = RenderClearFlags::All;
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
#include <XCEngine/Rendering/CameraRenderRequest.h>
|
||||
#include <XCEngine/Rendering/ObjectIdPass.h>
|
||||
#include <XCEngine/Rendering/Passes/BuiltinSceneViewPostPassSequenceBuilder.h>
|
||||
#include <XCEngine/Rendering/Passes/BuiltinPostProcessPassSequenceBuilder.h>
|
||||
#include <XCEngine/Rendering/RenderPipeline.h>
|
||||
|
||||
#include <memory>
|
||||
@@ -44,7 +44,7 @@ private:
|
||||
std::shared_ptr<const RenderPipelineAsset> m_pipelineAsset;
|
||||
std::unique_ptr<RenderPipeline> m_pipeline;
|
||||
std::unique_ptr<ObjectIdPass> m_objectIdPass;
|
||||
Passes::BuiltinSceneViewPostPassSequenceBuilder m_builtinSceneViewPostProcessBuilder;
|
||||
Passes::BuiltinPostProcessPassSequenceBuilder m_builtinPostProcessBuilder;
|
||||
};
|
||||
|
||||
} // namespace Rendering
|
||||
|
||||
@@ -0,0 +1,91 @@
|
||||
#pragma once
|
||||
|
||||
#include <cstdint>
|
||||
#include <vector>
|
||||
|
||||
namespace XCEngine {
|
||||
namespace Rendering {
|
||||
namespace Passes {
|
||||
|
||||
enum class BuiltinPostProcessPassStep : uint8_t {
|
||||
ColorToRenderTarget,
|
||||
InfiniteGrid,
|
||||
SelectionOutline,
|
||||
ColorToShaderResource,
|
||||
SelectionMaskDebug
|
||||
};
|
||||
|
||||
struct BuiltinPostProcessPassPlanInput {
|
||||
bool hasGridOverlay = false;
|
||||
bool hasSelection = false;
|
||||
bool debugSelectionMask = false;
|
||||
bool hasObjectIdShaderView = false;
|
||||
};
|
||||
|
||||
struct BuiltinPostProcessPassPlan {
|
||||
bool valid = false;
|
||||
std::vector<BuiltinPostProcessPassStep> steps;
|
||||
};
|
||||
|
||||
inline BuiltinPostProcessPassPlan BuildBuiltinPostProcessPassPlan(
|
||||
const BuiltinPostProcessPassPlanInput& input) {
|
||||
BuiltinPostProcessPassPlan plan = {};
|
||||
plan.valid = true;
|
||||
|
||||
if (input.debugSelectionMask) {
|
||||
if (input.hasSelection && input.hasObjectIdShaderView) {
|
||||
plan.steps = {
|
||||
BuiltinPostProcessPassStep::ColorToRenderTarget,
|
||||
BuiltinPostProcessPassStep::SelectionMaskDebug,
|
||||
BuiltinPostProcessPassStep::ColorToShaderResource
|
||||
};
|
||||
return plan;
|
||||
}
|
||||
|
||||
if (input.hasGridOverlay) {
|
||||
plan.steps = {
|
||||
BuiltinPostProcessPassStep::ColorToRenderTarget,
|
||||
BuiltinPostProcessPassStep::ColorToShaderResource
|
||||
};
|
||||
return plan;
|
||||
}
|
||||
|
||||
plan.valid = false;
|
||||
return plan;
|
||||
}
|
||||
|
||||
if (input.hasGridOverlay && input.hasSelection && input.hasObjectIdShaderView) {
|
||||
plan.steps = {
|
||||
BuiltinPostProcessPassStep::ColorToRenderTarget,
|
||||
BuiltinPostProcessPassStep::InfiniteGrid,
|
||||
BuiltinPostProcessPassStep::SelectionOutline,
|
||||
BuiltinPostProcessPassStep::ColorToShaderResource
|
||||
};
|
||||
return plan;
|
||||
}
|
||||
|
||||
if (input.hasGridOverlay) {
|
||||
plan.steps = {
|
||||
BuiltinPostProcessPassStep::ColorToRenderTarget,
|
||||
BuiltinPostProcessPassStep::InfiniteGrid,
|
||||
BuiltinPostProcessPassStep::ColorToShaderResource
|
||||
};
|
||||
return plan;
|
||||
}
|
||||
|
||||
if (input.hasSelection && input.hasObjectIdShaderView) {
|
||||
plan.steps = {
|
||||
BuiltinPostProcessPassStep::ColorToRenderTarget,
|
||||
BuiltinPostProcessPassStep::SelectionOutline,
|
||||
BuiltinPostProcessPassStep::ColorToShaderResource
|
||||
};
|
||||
return plan;
|
||||
}
|
||||
|
||||
plan.valid = false;
|
||||
return plan;
|
||||
}
|
||||
|
||||
} // namespace Passes
|
||||
} // namespace Rendering
|
||||
} // namespace XCEngine
|
||||
@@ -11,26 +11,26 @@ namespace XCEngine {
|
||||
namespace Rendering {
|
||||
namespace Passes {
|
||||
|
||||
struct BuiltinSceneViewPostPassSequenceInput {
|
||||
struct BuiltinPostProcessPassSequenceInput {
|
||||
InfiniteGridPassData gridPassData = {};
|
||||
RHI::RHIResourceView* objectIdTextureView = nullptr;
|
||||
std::vector<uint64_t> selectedObjectIds = {};
|
||||
ObjectIdOutlineStyle outlineStyle = {};
|
||||
};
|
||||
|
||||
struct BuiltinSceneViewPostPassSequenceBuildResult {
|
||||
struct BuiltinPostProcessPassSequenceBuildResult {
|
||||
bool valid = false;
|
||||
bool missingObjectIdTextureViewForSelection = false;
|
||||
};
|
||||
|
||||
class BuiltinSceneViewPostPassSequenceBuilder {
|
||||
class BuiltinPostProcessPassSequenceBuilder {
|
||||
public:
|
||||
~BuiltinSceneViewPostPassSequenceBuilder();
|
||||
~BuiltinPostProcessPassSequenceBuilder();
|
||||
|
||||
void Shutdown();
|
||||
|
||||
BuiltinSceneViewPostPassSequenceBuildResult Build(
|
||||
const BuiltinSceneViewPostPassSequenceInput& input,
|
||||
BuiltinPostProcessPassSequenceBuildResult Build(
|
||||
const BuiltinPostProcessPassSequenceInput& input,
|
||||
RenderPassSequence& outSequence);
|
||||
|
||||
private:
|
||||
@@ -1,67 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
#include <cstdint>
|
||||
#include <vector>
|
||||
|
||||
namespace XCEngine {
|
||||
namespace Rendering {
|
||||
namespace Passes {
|
||||
|
||||
enum class BuiltinSceneViewPostPassStep : uint8_t {
|
||||
ColorToRenderTarget,
|
||||
InfiniteGrid,
|
||||
SelectionOutline,
|
||||
ColorToShaderResource,
|
||||
SelectionMaskDebug
|
||||
};
|
||||
|
||||
struct BuiltinSceneViewPostPassPlanInput {
|
||||
bool overlayValid = false;
|
||||
bool hasSelection = false;
|
||||
bool debugSelectionMask = false;
|
||||
bool hasObjectIdShaderView = false;
|
||||
};
|
||||
|
||||
struct BuiltinSceneViewPostPassPlan {
|
||||
bool valid = false;
|
||||
std::vector<BuiltinSceneViewPostPassStep> steps;
|
||||
};
|
||||
|
||||
inline BuiltinSceneViewPostPassPlan BuildBuiltinSceneViewPostPassPlan(
|
||||
const BuiltinSceneViewPostPassPlanInput& input) {
|
||||
BuiltinSceneViewPostPassPlan plan = {};
|
||||
if (!input.overlayValid) {
|
||||
return plan;
|
||||
}
|
||||
|
||||
plan.valid = true;
|
||||
|
||||
if (input.debugSelectionMask) {
|
||||
plan.steps.push_back(BuiltinSceneViewPostPassStep::ColorToRenderTarget);
|
||||
if (input.hasSelection && input.hasObjectIdShaderView) {
|
||||
plan.steps.push_back(BuiltinSceneViewPostPassStep::SelectionMaskDebug);
|
||||
}
|
||||
plan.steps.push_back(BuiltinSceneViewPostPassStep::ColorToShaderResource);
|
||||
return plan;
|
||||
}
|
||||
|
||||
plan.steps.push_back(BuiltinSceneViewPostPassStep::ColorToRenderTarget);
|
||||
plan.steps.push_back(BuiltinSceneViewPostPassStep::InfiniteGrid);
|
||||
|
||||
if (input.hasSelection && input.hasObjectIdShaderView) {
|
||||
plan.steps = {
|
||||
BuiltinSceneViewPostPassStep::ColorToRenderTarget,
|
||||
BuiltinSceneViewPostPassStep::InfiniteGrid,
|
||||
BuiltinSceneViewPostPassStep::SelectionOutline,
|
||||
BuiltinSceneViewPostPassStep::ColorToShaderResource
|
||||
};
|
||||
return plan;
|
||||
}
|
||||
|
||||
plan.steps.push_back(BuiltinSceneViewPostPassStep::ColorToShaderResource);
|
||||
return plan;
|
||||
}
|
||||
|
||||
} // namespace Passes
|
||||
} // namespace Rendering
|
||||
} // namespace XCEngine
|
||||
Reference in New Issue
Block a user