Move Drawable draw call recording logic out of renderer
This commit is contained in:
34
openVulkanoCpp/Vulkan/Scene/SimpleDrawableVulkanEncoder.cpp
Normal file
34
openVulkanoCpp/Vulkan/Scene/SimpleDrawableVulkanEncoder.cpp
Normal file
@@ -0,0 +1,34 @@
|
||||
/*
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
|
||||
*/
|
||||
|
||||
#include "Scene/SimpleDrawable.hpp"
|
||||
#include "VulkanGeometry.hpp"
|
||||
#include "VulkanNode.hpp"
|
||||
#include "Vulkan/VulkanDrawContext.hpp"
|
||||
|
||||
using namespace openVulkanoCpp::Scene;
|
||||
|
||||
namespace openVulkanoCpp::Vulkan
|
||||
{
|
||||
void EncodeSimpleDrawable(Drawable* instance, Vulkan::VulkanDrawContext* drawContext)
|
||||
{
|
||||
Geometry* mesh = dynamic_cast<SimpleDrawable*>(instance)->GetMesh();
|
||||
VulkanGeometry* renderGeo = dynamic_cast<VulkanGeometry*>(mesh->renderGeo);
|
||||
if (!mesh->renderGeo) renderGeo = drawContext->renderer->GetResourceManager().PrepareGeometry(mesh);
|
||||
renderGeo->RecordBind(drawContext->commandBuffer);
|
||||
for(Node* node : instance->GetNodes())
|
||||
{
|
||||
if (!node->renderNode) drawContext->renderer->GetResourceManager().PrepareNode(node);
|
||||
dynamic_cast<VulkanNode*>(node->renderNode)->Record(drawContext->commandBuffer, drawContext->currentImageId);
|
||||
renderGeo->RecordDraw(drawContext->commandBuffer);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
namespace
|
||||
{
|
||||
void* simpleDrawableVulkanEncoderReg = DrawEncoder::RegisterVulkanEncodeFunction<SimpleDrawable>(&openVulkanoCpp::Vulkan::EncodeSimpleDrawable);
|
||||
}
|
||||
@@ -9,6 +9,7 @@
|
||||
#include "IRecordable.hpp"
|
||||
#include "Scene/Scene.hpp"
|
||||
#include "Scene/Geometry.hpp"
|
||||
#include "Vulkan/Resources/ManagedResource.hpp"
|
||||
|
||||
namespace openVulkanoCpp::Vulkan
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user