Refactoring jobs

This commit is contained in:
Dynamitos
2021-12-09 12:38:02 +01:00
parent 9e3a2446ce
commit f4ce5f9585
17 changed files with 113 additions and 60 deletions
+4 -2
View File
@@ -112,7 +112,7 @@ BasePass::~BasePass()
{
}
void BasePass::beginFrame()
MainJob BasePass::beginFrame()
{
processor->clearCommands();
primitiveLayout->reset();
@@ -132,6 +132,7 @@ void BasePass::beginFrame()
descriptorSets[INDEX_VIEW_PARAMS] = viewLayout->allocateDescriptorSet();
descriptorSets[INDEX_VIEW_PARAMS]->updateBuffer(0, viewParamBuffer);
descriptorSets[INDEX_VIEW_PARAMS]->writeChanges();
co_return;
}
MainJob BasePass::render()
@@ -161,8 +162,9 @@ MainJob BasePass::render()
graphics->endRenderPass();
}
void BasePass::endFrame()
MainJob BasePass::endFrame()
{
co_return;
}
void BasePass::publishOutputs()
+2 -2
View File
@@ -37,9 +37,9 @@ class BasePass : public RenderPass<BasePassData>
public:
BasePass(Gfx::PGraphics graphics, Gfx::PViewport viewport, PCameraActor source);
virtual ~BasePass();
virtual void beginFrame() override;
virtual MainJob beginFrame() override;
virtual MainJob render() override;
virtual void endFrame() override;
virtual MainJob endFrame() override;
virtual void publishOutputs() override;
virtual void createRenderPass() override;
static void modifyRenderPassMacros(Map<const char*, const char*>& defines);
@@ -93,7 +93,7 @@ DepthPrepass::~DepthPrepass()
{
}
void DepthPrepass::beginFrame()
MainJob DepthPrepass::beginFrame()
{
processor->clearCommands();
primitiveLayout->reset();
@@ -111,6 +111,7 @@ void DepthPrepass::beginFrame()
descriptorSets[INDEX_VIEW_PARAMS] = viewLayout->allocateDescriptorSet();
descriptorSets[INDEX_VIEW_PARAMS]->updateBuffer(0, viewParamBuffer);
descriptorSets[INDEX_VIEW_PARAMS]->writeChanges();
co_return;
}
MainJob DepthPrepass::render()
@@ -130,8 +131,9 @@ MainJob DepthPrepass::render()
graphics->endRenderPass();
}
void DepthPrepass::endFrame()
MainJob DepthPrepass::endFrame()
{
co_return;
}
void DepthPrepass::publishOutputs()
@@ -36,9 +36,9 @@ class DepthPrepass : public RenderPass<DepthPrepassData>
public:
DepthPrepass(Gfx::PGraphics graphics, Gfx::PViewport viewport, PCameraActor source);
~DepthPrepass();
virtual void beginFrame() override;
virtual MainJob beginFrame() override;
virtual MainJob render() override;
virtual void endFrame() override;
virtual MainJob endFrame() override;
virtual void publishOutputs() override;
virtual void createRenderPass() override;
static void modifyRenderPassMacros(Map<const char*, const char*>& defines);
@@ -18,7 +18,7 @@ LightCullingPass::~LightCullingPass()
}
void LightCullingPass::beginFrame()
MainJob LightCullingPass::beginFrame()
{
uint32_t viewportWidth = viewport->getSizeX();
uint32_t viewportHeight = viewport->getSizeY();
@@ -75,6 +75,7 @@ void LightCullingPass::beginFrame()
lightEnvDescriptorSet->updateBuffer(2, pointLightBuffer);
lightEnvDescriptorSet->updateBuffer(3, numPointLightBuffer);
lightEnvDescriptorSet->writeChanges();
co_return;
}
MainJob LightCullingPass::render()
@@ -104,8 +105,9 @@ MainJob LightCullingPass::render()
co_return;
}
void LightCullingPass::endFrame()
MainJob LightCullingPass::endFrame()
{
co_return;
}
void LightCullingPass::publishOutputs()
@@ -18,9 +18,9 @@ class LightCullingPass : public RenderPass<LightCullingPassData>
public:
LightCullingPass(Gfx::PGraphics graphics, Gfx::PViewport viewport, PCameraActor camera);
virtual ~LightCullingPass();
virtual void beginFrame() override;
virtual MainJob beginFrame() override;
virtual MainJob render() override;
virtual void endFrame() override;
virtual MainJob endFrame() override;
virtual void publishOutputs() override;
virtual void createRenderPass() override;
static void modifyRenderPassMacros(Map<const char*, const char*>& defines);
+2 -2
View File
@@ -22,9 +22,9 @@ public:
void updateViewFrame(RenderPassDataType viewFrame) {
passData = std::move(viewFrame);
}
virtual void beginFrame() = 0;
virtual MainJob beginFrame() = 0;
virtual MainJob render() = 0;
virtual void endFrame() = 0;
virtual MainJob endFrame() = 0;
virtual void publishOutputs() = 0;
virtual void createRenderPass() = 0;
void setResources(PRenderGraphResources resources) { this->resources = resources; }
+4 -2
View File
@@ -15,8 +15,9 @@ UIPass::~UIPass()
}
void UIPass::beginFrame()
MainJob UIPass::beginFrame()
{
co_return;
}
MainJob UIPass::render()
@@ -31,8 +32,9 @@ MainJob UIPass::render()
co_return;
}
void UIPass::endFrame()
MainJob UIPass::endFrame()
{
co_return;
}
void UIPass::publishOutputs()
+2 -2
View File
@@ -16,9 +16,9 @@ class UIPass : public RenderPass<UIPassData>
public:
UIPass(Gfx::PGraphics graphics, Gfx::PViewport viewport, Gfx::PRenderTargetAttachment renderTarget);
virtual ~UIPass();
virtual void beginFrame() override;
virtual MainJob beginFrame() override;
virtual MainJob render() override;
virtual void endFrame() override;
virtual MainJob endFrame() override;
virtual void publishOutputs() override;
virtual void createRenderPass() override;
private:
@@ -236,7 +236,7 @@ DescriptorAllocator::DescriptorAllocator(PGraphics graphics, DescriptorLayout &l
{
for(uint32 i = 0; i < cachedHandles.size(); ++i)
{
cachedHandles[i] = new DescriptorSet(graphics, this);
cachedHandles[i] = nullptr;
}
uint32 perTypeSizes[VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT]; // TODO: FIX ENUM
@@ -280,6 +280,10 @@ void DescriptorAllocator::allocateDescriptorSet(Gfx::PDescriptorSet &descriptorS
for(uint32 setIndex = 0; setIndex < cachedHandles.size(); ++setIndex)
{
if(cachedHandles[setIndex] == nullptr)
{
cachedHandles[setIndex] = new DescriptorSet(graphics, this);
}
if(cachedHandles[setIndex]->isCurrentlyBound() || cachedHandles[setIndex]->isCurrentlyInUse())
{
// Currently in use, skip
@@ -308,6 +312,10 @@ void DescriptorAllocator::reset()
{
for(uint32 i = 0; i < cachedHandles.size(); ++i)
{
if(cachedHandles[i] == nullptr)
{
return;
}
cachedHandles[i]->free();
}
}
@@ -142,7 +142,7 @@ public:
private:
PGraphics graphics;
DescriptorLayout &layout;
const static int maxSets = 512;
const static int maxSets = 64;
StaticArray<PDescriptorSet, maxSets> cachedHandles;
VkDescriptorPool poolHandle;
};