refactor: move object id outline pass into renderer
This commit is contained in:
@@ -0,0 +1,69 @@
|
||||
#pragma once
|
||||
|
||||
#include <XCEngine/Core/Math/Color.h>
|
||||
#include <XCEngine/Core/Math/Vector3.h>
|
||||
#include <XCEngine/Core/Math/Vector4.h>
|
||||
#include <XCEngine/Rendering/RenderContext.h>
|
||||
#include <XCEngine/Rendering/RenderSurface.h>
|
||||
|
||||
#include <XCEngine/RHI/RHIDescriptorPool.h>
|
||||
#include <XCEngine/RHI/RHIDescriptorSet.h>
|
||||
#include <XCEngine/RHI/RHIEnums.h>
|
||||
#include <XCEngine/RHI/RHIPipelineLayout.h>
|
||||
#include <XCEngine/RHI/RHIPipelineState.h>
|
||||
#include <XCEngine/RHI/RHIResourceView.h>
|
||||
|
||||
#include <array>
|
||||
#include <cstdint>
|
||||
#include <vector>
|
||||
|
||||
namespace XCEngine {
|
||||
namespace Rendering {
|
||||
namespace Passes {
|
||||
|
||||
struct ObjectIdOutlineStyle {
|
||||
Math::Color outlineColor = Math::Color(1.0f, 0.4f, 0.0f, 1.0f);
|
||||
float outlineWidthPixels = 2.0f;
|
||||
bool debugSelectionMask = false;
|
||||
};
|
||||
|
||||
class BuiltinObjectIdOutlinePass {
|
||||
public:
|
||||
~BuiltinObjectIdOutlinePass() = default;
|
||||
|
||||
static constexpr uint32_t kMaxSelectedObjectCount = 256u;
|
||||
|
||||
void Shutdown();
|
||||
|
||||
bool Render(
|
||||
const RenderContext& renderContext,
|
||||
const RenderSurface& surface,
|
||||
RHI::RHIResourceView* objectIdTextureView,
|
||||
const std::vector<uint64_t>& selectedObjectIds,
|
||||
const ObjectIdOutlineStyle& style = {});
|
||||
|
||||
private:
|
||||
struct OutlineConstants {
|
||||
Math::Vector4 viewportSizeAndTexelSize = Math::Vector4::Zero();
|
||||
Math::Vector4 outlineColor = Math::Vector4::Zero();
|
||||
Math::Vector4 selectedInfo = Math::Vector4::Zero();
|
||||
std::array<Math::Vector4, kMaxSelectedObjectCount> selectedObjectColors = {};
|
||||
};
|
||||
|
||||
bool EnsureInitialized(const RenderContext& renderContext);
|
||||
bool CreateResources(const RenderContext& renderContext);
|
||||
void DestroyResources();
|
||||
|
||||
RHI::RHIDevice* m_device = nullptr;
|
||||
RHI::RHIType m_backendType = RHI::RHIType::D3D12;
|
||||
RHI::RHIPipelineLayout* m_pipelineLayout = nullptr;
|
||||
RHI::RHIPipelineState* m_pipelineState = nullptr;
|
||||
RHI::RHIDescriptorPool* m_constantPool = nullptr;
|
||||
RHI::RHIDescriptorSet* m_constantSet = nullptr;
|
||||
RHI::RHIDescriptorPool* m_texturePool = nullptr;
|
||||
RHI::RHIDescriptorSet* m_textureSet = nullptr;
|
||||
};
|
||||
|
||||
} // namespace Passes
|
||||
} // namespace Rendering
|
||||
} // namespace XCEngine
|
||||
Reference in New Issue
Block a user