52 lines
1.4 KiB
C++
52 lines
1.4 KiB
C++
#pragma once
|
|
|
|
#include <XCEngine/Rendering/RenderSurface.h>
|
|
|
|
namespace XCEngine {
|
|
namespace RHI {
|
|
class RHIDevice;
|
|
class RHIResourceView;
|
|
class RHITexture;
|
|
} // namespace RHI
|
|
|
|
namespace Rendering {
|
|
|
|
struct DirectionalShadowRenderPlan;
|
|
struct RenderContext;
|
|
|
|
struct DirectionalShadowSurfaceAllocation {
|
|
RenderSurface surface = {};
|
|
RHI::RHIResourceView* depthShaderView = nullptr;
|
|
|
|
bool IsValid() const {
|
|
return surface.GetDepthAttachment() != nullptr &&
|
|
depthShaderView != nullptr;
|
|
}
|
|
};
|
|
|
|
class DirectionalShadowSurfaceCache {
|
|
public:
|
|
DirectionalShadowSurfaceCache() = default;
|
|
DirectionalShadowSurfaceCache(const DirectionalShadowSurfaceCache&) = delete;
|
|
DirectionalShadowSurfaceCache& operator=(const DirectionalShadowSurfaceCache&) = delete;
|
|
~DirectionalShadowSurfaceCache();
|
|
|
|
const DirectionalShadowSurfaceAllocation* Resolve(
|
|
const RenderContext& context,
|
|
const DirectionalShadowRenderPlan& plan);
|
|
|
|
private:
|
|
bool Matches(const RenderContext& context, const DirectionalShadowRenderPlan& plan) const;
|
|
void Reset();
|
|
|
|
RHI::RHIDevice* m_device = nullptr;
|
|
uint32_t m_width = 0;
|
|
uint32_t m_height = 0;
|
|
RHI::RHITexture* m_depthTexture = nullptr;
|
|
RHI::RHIResourceView* m_depthView = nullptr;
|
|
DirectionalShadowSurfaceAllocation m_allocation = {};
|
|
};
|
|
|
|
} // namespace Rendering
|
|
} // namespace XCEngine
|