Files
XCEngine/engine/include/XCEngine/Rendering/RenderSurface.h

84 lines
3.3 KiB
C++

#pragma once
#include <XCEngine/Core/Math/Color.h>
#include <XCEngine/Core/Math/Rect.h>
#include <XCEngine/RHI/RHIEnums.h>
#include <cstdint>
#include <vector>
namespace XCEngine {
namespace RHI {
class RHIResourceView;
} // namespace RHI
namespace Rendering {
class RenderSurface {
public:
RenderSurface() = default;
RenderSurface(uint32_t width, uint32_t height);
uint32_t GetWidth() const { return m_width; }
uint32_t GetHeight() const { return m_height; }
void SetSize(uint32_t width, uint32_t height);
void SetColorAttachment(RHI::RHIResourceView* colorAttachment);
void SetColorAttachments(const std::vector<RHI::RHIResourceView*>& colorAttachments);
const std::vector<RHI::RHIResourceView*>& GetColorAttachments() const { return m_colorAttachments; }
void SetDepthAttachment(RHI::RHIResourceView* depthAttachment) { m_depthAttachment = depthAttachment; }
RHI::RHIResourceView* GetDepthAttachment() const { return m_depthAttachment; }
void SetRenderArea(const Math::RectInt& renderArea);
void ResetRenderArea();
bool HasCustomRenderArea() const { return m_hasCustomRenderArea; }
Math::RectInt GetRenderArea() const;
uint32_t GetRenderAreaWidth() const;
uint32_t GetRenderAreaHeight() const;
void SetClearColorOverride(const Math::Color& clearColor);
void ClearClearColorOverride();
bool HasClearColorOverride() const { return m_hasClearColorOverride; }
const Math::Color& GetClearColorOverride() const { return m_clearColorOverride; }
void SetAutoTransitionEnabled(bool enabled) { m_autoTransition = enabled; }
bool IsAutoTransitionEnabled() const { return m_autoTransition; }
void SetColorStateBefore(RHI::ResourceStates state) { m_colorStateBefore = state; }
RHI::ResourceStates GetColorStateBefore() const { return m_colorStateBefore; }
void SetColorStateAfter(RHI::ResourceStates state) { m_colorStateAfter = state; }
RHI::ResourceStates GetColorStateAfter() const { return m_colorStateAfter; }
void SetDepthStateBefore(RHI::ResourceStates state) { m_depthStateBefore = state; }
RHI::ResourceStates GetDepthStateBefore() const { return m_depthStateBefore; }
void SetDepthStateAfter(RHI::ResourceStates state) { m_depthStateAfter = state; }
RHI::ResourceStates GetDepthStateAfter() const { return m_depthStateAfter; }
void SetSampleDesc(uint32_t sampleCount, uint32_t sampleQuality = 0);
uint32_t GetSampleCount() const { return m_sampleCount; }
uint32_t GetSampleQuality() const { return m_sampleQuality; }
private:
uint32_t m_width = 0;
uint32_t m_height = 0;
std::vector<RHI::RHIResourceView*> m_colorAttachments;
RHI::RHIResourceView* m_depthAttachment = nullptr;
bool m_hasCustomRenderArea = false;
Math::RectInt m_renderArea;
bool m_hasClearColorOverride = false;
Math::Color m_clearColorOverride = Math::Color::Black();
bool m_autoTransition = true;
RHI::ResourceStates m_colorStateBefore = RHI::ResourceStates::Present;
RHI::ResourceStates m_colorStateAfter = RHI::ResourceStates::Present;
RHI::ResourceStates m_depthStateBefore = RHI::ResourceStates::DepthWrite;
RHI::ResourceStates m_depthStateAfter = RHI::ResourceStates::DepthWrite;
uint32_t m_sampleCount = 1;
uint32_t m_sampleQuality = 0;
};
} // namespace Rendering
} // namespace XCEngine