Restructuring renderpasses
This commit is contained in:
@@ -82,7 +82,6 @@ void BasePassMeshProcessor::clearCommands()
|
||||
BasePass::BasePass(PRenderGraph renderGraph, const PScene scene, Gfx::PGraphics graphics, Gfx::PViewport viewport, PCameraActor source)
|
||||
: RenderPass(renderGraph, graphics, viewport)
|
||||
, processor(new BasePassMeshProcessor(scene, viewport, graphics, false))
|
||||
, scene(scene)
|
||||
, descriptorSets(4)
|
||||
, source(source->getCameraComponent())
|
||||
{
|
||||
@@ -125,6 +124,11 @@ BasePass::~BasePass()
|
||||
{
|
||||
}
|
||||
|
||||
void BasePass::updateViewFrame(PViewFrame viewFrame)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void BasePass::beginFrame()
|
||||
{
|
||||
processor->clearCommands();
|
||||
@@ -145,10 +149,10 @@ void BasePass::beginFrame()
|
||||
descriptorSets[INDEX_VIEW_PARAMS] = viewLayout->allocateDescriptorSet();
|
||||
descriptorSets[INDEX_VIEW_PARAMS]->updateBuffer(0, viewParamBuffer);
|
||||
descriptorSets[INDEX_VIEW_PARAMS]->writeChanges();
|
||||
for(auto &&meshBatch : scene->getStaticMeshes())
|
||||
/*for(auto &&meshBatch : scene->getStaticMeshes())
|
||||
{
|
||||
meshBatch.material->updateDescriptorData();
|
||||
}
|
||||
}*/
|
||||
}
|
||||
|
||||
void BasePass::render()
|
||||
@@ -169,10 +173,10 @@ void BasePass::render()
|
||||
descriptorSets[INDEX_LIGHT_ENV]->updateTexture(5, oLightGrid);
|
||||
descriptorSets[INDEX_LIGHT_ENV]->writeChanges();
|
||||
graphics->beginRenderPass(renderPass);
|
||||
for (auto &&meshBatch : scene->getStaticMeshes())
|
||||
/*for (auto &&meshBatch : scene->getStaticMeshes())
|
||||
{
|
||||
processor->addMeshBatch(meshBatch, renderPass, basePassLayout, primitiveLayout, descriptorSets);
|
||||
}
|
||||
}*/
|
||||
graphics->executeCommands(processor->getRenderCommands());
|
||||
graphics->endRenderPass();
|
||||
}
|
||||
|
||||
@@ -31,11 +31,17 @@ private:
|
||||
DEFINE_REF(BasePassMeshProcessor)
|
||||
DECLARE_REF(CameraActor)
|
||||
DECLARE_REF(CameraComponent)
|
||||
struct BasePassData
|
||||
{
|
||||
const LightEnv lightEnv;
|
||||
const Array<StaticMeshBatch> staticDrawList;
|
||||
};
|
||||
class BasePass : public RenderPass
|
||||
{
|
||||
public:
|
||||
BasePass(PRenderGraph renderGraph, const PScene scene, Gfx::PGraphics graphics, Gfx::PViewport viewport, PCameraActor source);
|
||||
virtual ~BasePass();
|
||||
virtual void updateViewFrame(PViewFrame viewFrame) override;
|
||||
virtual void beginFrame() override;
|
||||
virtual void render() override;
|
||||
virtual void endFrame() override;
|
||||
@@ -47,7 +53,6 @@ private:
|
||||
Gfx::PTexture2D depthBuffer;
|
||||
UPBasePassMeshProcessor processor;
|
||||
|
||||
const PScene scene;
|
||||
Array<Gfx::PDescriptorSet> descriptorSets;
|
||||
PCameraComponent source;
|
||||
Gfx::PPipelineLayout basePassLayout;
|
||||
|
||||
@@ -81,7 +81,6 @@ void DepthPrepassMeshProcessor::clearCommands()
|
||||
DepthPrepass::DepthPrepass(PRenderGraph renderGraph, const PScene scene, Gfx::PGraphics graphics, Gfx::PViewport viewport, PCameraActor source)
|
||||
: RenderPass(renderGraph, graphics, viewport)
|
||||
, processor(new DepthPrepassMeshProcessor(scene, viewport, graphics))
|
||||
, scene(scene)
|
||||
, descriptorSets(3)
|
||||
, source(source->getCameraComponent())
|
||||
{
|
||||
@@ -108,7 +107,7 @@ DepthPrepass::~DepthPrepass()
|
||||
{
|
||||
}
|
||||
|
||||
void DepthPrepass::beginFrame()
|
||||
void DepthPrepass::beginFrame(UPViewFrame& viewFrame)
|
||||
{
|
||||
processor->clearCommands();
|
||||
primitiveLayout->reset();
|
||||
@@ -126,28 +125,28 @@ void DepthPrepass::beginFrame()
|
||||
descriptorSets[INDEX_VIEW_PARAMS] = viewLayout->allocateDescriptorSet();
|
||||
descriptorSets[INDEX_VIEW_PARAMS]->updateBuffer(0, viewParamBuffer);
|
||||
descriptorSets[INDEX_VIEW_PARAMS]->writeChanges();
|
||||
for(auto &&meshBatch : scene->getStaticMeshes())
|
||||
/*for(auto &&meshBatch : scene->getStaticMeshes())
|
||||
{
|
||||
meshBatch.material->updateDescriptorData();
|
||||
}
|
||||
}*/
|
||||
}
|
||||
|
||||
void DepthPrepass::render()
|
||||
void DepthPrepass::render(UPViewFrame& viewFrame)
|
||||
{
|
||||
depthAttachment->getTexture()->pipelineBarrier(
|
||||
Gfx::SE_ACCESS_SHADER_READ_BIT, Gfx::SE_PIPELINE_STAGE_COMPUTE_SHADER_BIT,
|
||||
Gfx::SE_ACCESS_DEPTH_STENCIL_ATTACHMENT_WRITE_BIT, Gfx::SE_PIPELINE_STAGE_EARLY_FRAGMENT_TESTS_BIT);
|
||||
depthAttachment->getTexture()->transferOwnership(Gfx::QueueType::GRAPHICS);
|
||||
graphics->beginRenderPass(renderPass);
|
||||
for (auto &&meshBatch : scene->getStaticMeshes())
|
||||
/*for (auto &&meshBatch : scene->getStaticMeshes())
|
||||
{
|
||||
processor->addMeshBatch(meshBatch, renderPass, depthPrepassLayout, primitiveLayout, descriptorSets);
|
||||
}
|
||||
}*/
|
||||
graphics->executeCommands(processor->getRenderCommands());
|
||||
graphics->endRenderPass();
|
||||
}
|
||||
|
||||
void DepthPrepass::endFrame()
|
||||
void DepthPrepass::endFrame(UPViewFrame& viewFrame)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
@@ -45,7 +45,6 @@ private:
|
||||
Gfx::PRenderTargetAttachment depthAttachment;
|
||||
Gfx::PTexture2D depthBuffer;
|
||||
UPDepthPrepassMeshProcessor processor;
|
||||
const PScene scene;
|
||||
|
||||
Array<Gfx::PDescriptorSet> descriptorSets;
|
||||
PCameraComponent source;
|
||||
|
||||
@@ -9,7 +9,6 @@ using namespace Seele;
|
||||
|
||||
LightCullingPass::LightCullingPass(PRenderGraph renderGraph, const PScene scene, Gfx::PGraphics graphics, Gfx::PViewport viewport, PCameraActor camera)
|
||||
: RenderPass(renderGraph, graphics, viewport)
|
||||
, scene(scene)
|
||||
, source(camera->getCameraComponent())
|
||||
{
|
||||
}
|
||||
@@ -19,7 +18,7 @@ LightCullingPass::~LightCullingPass()
|
||||
|
||||
}
|
||||
|
||||
void LightCullingPass::beginFrame()
|
||||
void LightCullingPass::beginFrame(UPViewFrame& viewFrame)
|
||||
{
|
||||
uint32_t viewportWidth = viewport->getSizeX();
|
||||
uint32_t viewportHeight = viewport->getSizeY();
|
||||
@@ -34,7 +33,7 @@ void LightCullingPass::beginFrame()
|
||||
uniformUpdate.data = (uint8*)&viewParams;
|
||||
viewParamsBuffer->updateContents(uniformUpdate);
|
||||
|
||||
LightEnv lightEnv = scene->getLightBuffer();
|
||||
/*LightEnv lightEnv = scene->getLightBuffer();
|
||||
for(uint32 i = 0; i < lightEnv.numPointLights; ++i)
|
||||
{
|
||||
lightEnv.pointLights[i].positionVS = lightEnv.pointLights[i].positionWS;
|
||||
@@ -42,7 +41,7 @@ void LightCullingPass::beginFrame()
|
||||
uniformUpdate.size = sizeof(PointLight) * MAX_POINT_LIGHTS;
|
||||
uniformUpdate.data = (uint8*)&lightEnv.pointLights;
|
||||
pointLightBuffer->updateContents(uniformUpdate);
|
||||
|
||||
*/
|
||||
BulkResourceData counterReset;
|
||||
uint32 reset = 0;
|
||||
counterReset.data = (uint8*)&reset;
|
||||
@@ -72,7 +71,7 @@ void LightCullingPass::beginFrame()
|
||||
lightEnvDescriptorSet->writeChanges();
|
||||
}
|
||||
|
||||
void LightCullingPass::render()
|
||||
void LightCullingPass::render(UPViewFrame& viewFrame)
|
||||
{
|
||||
oLightIndexList->pipelineBarrier(
|
||||
Gfx::SE_ACCESS_SHADER_READ_BIT, Gfx::SE_PIPELINE_STAGE_FRAGMENT_SHADER_BIT,
|
||||
@@ -98,7 +97,7 @@ void LightCullingPass::render()
|
||||
depthAttachment->transferOwnership(Gfx::QueueType::GRAPHICS);
|
||||
}
|
||||
|
||||
void LightCullingPass::endFrame()
|
||||
void LightCullingPass::endFrame(UPViewFrame& viewFrame)
|
||||
{
|
||||
|
||||
}
|
||||
@@ -133,23 +132,23 @@ void LightCullingPass::publishOutputs()
|
||||
tLightIndexList = graphics->createStructuredBuffer(structInfo);
|
||||
renderGraph->registerBufferOutput("LIGHTCULLING_OLIGHTLIST", oLightIndexList);
|
||||
renderGraph->registerBufferOutput("LIGHTCULLING_TLIGHTLIST", tLightIndexList);
|
||||
const LightEnv& lightEnv = scene->getLightBuffer();
|
||||
/*const LightEnv& lightEnv = scene->getLightBuffer();
|
||||
resourceData.size = sizeof(DirectionalLight) * MAX_DIRECTIONAL_LIGHTS;
|
||||
resourceData.data = (uint8*)&lightEnv.directionalLights;
|
||||
resourceData.data = (uint8*)&lightEnv.directionalLights;*/
|
||||
structInfo.resourceData = resourceData;
|
||||
structInfo.bDynamic = true;
|
||||
directLightBuffer = graphics->createStructuredBuffer(structInfo);
|
||||
resourceData.size = sizeof(PointLight) * MAX_POINT_LIGHTS;
|
||||
resourceData.data = (uint8*)&lightEnv.pointLights;
|
||||
//resourceData.data = (uint8*)&lightEnv.pointLights;
|
||||
structInfo.resourceData = resourceData;
|
||||
pointLightBuffer = graphics->createStructuredBuffer(structInfo);
|
||||
UniformBufferCreateInfo uniformInfo;
|
||||
resourceData.size = sizeof(uint32);
|
||||
resourceData.data = (uint8*)&lightEnv.numDirectionalLights;
|
||||
//resourceData.data = (uint8*)&lightEnv.numDirectionalLights;
|
||||
uniformInfo.resourceData = resourceData;
|
||||
uniformInfo.bDynamic = true;
|
||||
numDirLightBuffer = graphics->createUniformBuffer(uniformInfo);
|
||||
resourceData.data = (uint8*)&lightEnv.numPointLights;
|
||||
//resourceData.data = (uint8*)&lightEnv.numPointLights;
|
||||
uniformInfo.resourceData = resourceData;
|
||||
uniformInfo.bDynamic = true;
|
||||
numPointLightBuffer = graphics->createUniformBuffer(uniformInfo);
|
||||
|
||||
@@ -42,9 +42,7 @@ private:
|
||||
{
|
||||
Plane planes[4];
|
||||
};
|
||||
|
||||
PScene scene;
|
||||
|
||||
|
||||
Gfx::PStructuredBuffer frustumBuffer;
|
||||
Gfx::PUniformBuffer dispatchParamsBuffer;
|
||||
Gfx::PUniformBuffer viewParamsBuffer;
|
||||
@@ -54,7 +52,6 @@ private:
|
||||
Gfx::PComputePipeline frustumPipeline;
|
||||
|
||||
Gfx::PTexture2D depthAttachment;
|
||||
//Gfx::PTexture2D depthComputeTexture;
|
||||
Gfx::PStructuredBuffer frustums;
|
||||
Gfx::PStructuredBuffer oLightIndexCounter;
|
||||
Gfx::PStructuredBuffer tLightIndexCounter;
|
||||
|
||||
@@ -13,19 +13,35 @@ RenderGraph::~RenderGraph()
|
||||
|
||||
void RenderGraph::setup()
|
||||
{
|
||||
for(auto pass : renderPasses)
|
||||
for(auto& pass : renderPasses)
|
||||
{
|
||||
pass->publishOutputs();
|
||||
}
|
||||
for(auto pass : renderPasses)
|
||||
for(auto& pass : renderPasses)
|
||||
{
|
||||
pass->createRenderPass();
|
||||
}
|
||||
}
|
||||
|
||||
void RenderGraph::addRenderPass(PRenderPass renderPass)
|
||||
void RenderGraph::addRenderPass(UPRenderPass renderPass)
|
||||
{
|
||||
renderPasses.add(renderPass);
|
||||
renderPasses.add(std::move(renderPass));
|
||||
}
|
||||
|
||||
void RenderGraph::render(PViewFrame viewFrame)
|
||||
{
|
||||
for(auto& pass : renderPasses)
|
||||
{
|
||||
pass->beginFrame(viewFrame);
|
||||
}
|
||||
for(auto& pass : renderPasses)
|
||||
{
|
||||
pass->render(viewFrame);
|
||||
}
|
||||
for(auto& pass : renderPasses)
|
||||
{
|
||||
pass->endFrame(viewFrame);
|
||||
}
|
||||
}
|
||||
|
||||
Gfx::PRenderTargetAttachment RenderGraph::requestRenderTarget(const std::string& outputName)
|
||||
|
||||
@@ -5,13 +5,15 @@
|
||||
|
||||
namespace Seele
|
||||
{
|
||||
DECLARE_REF(ViewFrame)
|
||||
class RenderGraph
|
||||
{
|
||||
public:
|
||||
RenderGraph();
|
||||
~RenderGraph();
|
||||
void setup();
|
||||
void addRenderPass(PRenderPass renderPass);
|
||||
void addRenderPass(UPRenderPass renderPass);
|
||||
void render(PViewFrame viewFrame);
|
||||
Gfx::PRenderTargetAttachment requestRenderTarget(const std::string& outputName);
|
||||
Gfx::PTexture requestTexture(const std::string& outputName);
|
||||
Gfx::PStructuredBuffer requestBuffer(const std::string& outputName);
|
||||
@@ -25,7 +27,7 @@ private:
|
||||
Map<std::string, Gfx::PTexture> registeredTextures;
|
||||
Map<std::string, Gfx::PStructuredBuffer> registeredBuffers;
|
||||
Map<std::string, Gfx::PUniformBuffer> registeredUniforms;
|
||||
List<PRenderPass> renderPasses;
|
||||
List<UPRenderPass> renderPasses;
|
||||
};
|
||||
DEFINE_REF(RenderGraph)
|
||||
} // namespace Seele
|
||||
|
||||
@@ -13,6 +13,7 @@ class RenderPass
|
||||
public:
|
||||
RenderPass(PRenderGraph rendergraph, Gfx::PGraphics graphics, Gfx::PViewport viewport);
|
||||
virtual ~RenderPass();
|
||||
virtual void updateViewFrame(PViewFrame viewFrame) = 0;
|
||||
virtual void beginFrame() = 0;
|
||||
virtual void render() = 0;
|
||||
virtual void endFrame() = 0;
|
||||
|
||||
@@ -15,12 +15,12 @@ UIPass::~UIPass()
|
||||
|
||||
}
|
||||
|
||||
void UIPass::beginFrame()
|
||||
void UIPass::beginFrame(UPViewFrame& viewFrame)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void UIPass::render()
|
||||
void UIPass::render(UPViewFrame& viewFrame)
|
||||
{
|
||||
graphics->beginRenderPass(renderPass);
|
||||
Gfx::PRenderCommand command = graphics->createRenderCommand("UIPassCommand");
|
||||
@@ -31,7 +31,7 @@ void UIPass::render()
|
||||
graphics->endRenderPass();
|
||||
}
|
||||
|
||||
void UIPass::endFrame()
|
||||
void UIPass::endFrame(UPViewFrame& viewFrame)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
@@ -7,6 +7,10 @@ namespace Seele
|
||||
{
|
||||
DECLARE_NAME_REF(Gfx, Texture2D)
|
||||
DECLARE_NAME_REF(Gfx, RenderTargetAttachment)
|
||||
struct UIPassData
|
||||
{
|
||||
const UI::RenderHierarchy hierarchy;
|
||||
};
|
||||
class UIPass : public RenderPass
|
||||
{
|
||||
public:
|
||||
@@ -18,7 +22,7 @@ public:
|
||||
virtual void publishOutputs() override;
|
||||
virtual void createRenderPass() override;
|
||||
private:
|
||||
UI::RenderHierarchy hierarchy;
|
||||
PUIViewFrame uiFrame;
|
||||
Gfx::PRenderTargetAttachment renderTarget;
|
||||
Gfx::PRenderTargetAttachment depthAttachment;
|
||||
Gfx::PTexture2D depthBuffer;
|
||||
|
||||
Reference in New Issue
Block a user