Provisional light culling

This commit is contained in:
Dynamitos
2021-05-10 23:57:55 +02:00
parent 0cf13bcff5
commit e00b382d4a
41 changed files with 1072 additions and 330 deletions
@@ -1,16 +1,17 @@
#pragma once
#include "RenderPass.h"
#include "Graphics/GraphicsResources.h"
namespace Seele
{
DECLARE_REF(CameraActor)
DECLARE_REF(CameraComponent)
DECLARE_NAME_REF(Gfx, Viewport)
DECLARE_NAME_REF(Gfx, Graphics)
DECLARE_REF(Scene)
DECLARE_REF(Viewport)
class LightCullingPass : public RenderPass
{
public:
LightCullingPass(PRenderGraph renderGraph, Gfx::PViewport viewport, Gfx::PGraphics graphics, PCameraActor camera);
LightCullingPass(PRenderGraph renderGraph, const PScene scene, Gfx::PGraphics graphics, Gfx::PViewport viewport, PCameraActor camera);
virtual ~LightCullingPass();
virtual void beginFrame() override;
virtual void render() override;
@@ -19,7 +20,9 @@ public:
virtual void createRenderPass() override;
static void modifyRenderPassMacros(Map<const char*, const char*>& defines);
private:
void setupFrustums();
static constexpr uint32 BLOCK_SIZE = 8;
static constexpr uint32 INDEX_LIGHT_ENV = 1;
_declspec(align(16)) struct DispatchParams
{
glm::uvec3 numThreadGroups;
@@ -39,13 +42,36 @@ private:
{
Plane planes[4];
};
struct ScreenToView
{
Matrix4 inverseProjection;
Vector2 screenDimensions;
};
PScene scene;
Gfx::PViewport viewport;
Gfx::PGraphics graphics;
Gfx::PStructuredBuffer frustumBuffer;
Gfx::PUniformBuffer dispatchParamsBuffer;
Gfx::PUniformBuffer viewParamsBuffer;
Gfx::PDescriptorSet frustumDescriptorSet;
Gfx::PComputeShader frustumShader;
Gfx::PPipelineLayout frustumLayout;
Gfx::PComputePipeline frustumPipeline;
Gfx::PTexture2D depthAttachment;
//Gfx::PTexture2D depthComputeTexture;
Gfx::PStructuredBuffer frustums;
Gfx::PStructuredBuffer oLightIndexCounter;
Gfx::PStructuredBuffer tLightIndexCounter;
Gfx::PStructuredBuffer oLightIndexList;
Gfx::PStructuredBuffer tLightIndexList;
Gfx::PTexture2D oLightGrid;
Gfx::PTexture2D tLightGrid;
Gfx::PDescriptorSet lightEnvDescriptorSet;
Gfx::PDescriptorSet cullingDescriptorSet;
Gfx::PDescriptorLayout lightEnvDescriptorLayout;
Gfx::PDescriptorLayout cullingDescriptorLayout;
Gfx::PComputeShader cullingShader;
Gfx::PPipelineLayout cullingLayout;
Gfx::PComputePipeline cullingPipeline;
PCameraComponent source;
};
DEFINE_REF(LightCullingPass)
} // namespace Seele