Changed batching system to use SHRenderable* instead of handles
This commit is contained in:
parent
ec40754eb9
commit
96ec1afcdd
|
@ -35,7 +35,7 @@ namespace SHADE
|
||||||
throw std::invalid_argument("Attempted to create a SHBatch with an invalid SHPipeline!");
|
throw std::invalid_argument("Attempted to create a SHBatch with an invalid SHPipeline!");
|
||||||
}
|
}
|
||||||
|
|
||||||
void SHBatch::Add(Handle<SHRenderable> renderable)
|
void SHBatch::Add(const SHRenderable* renderable)
|
||||||
{
|
{
|
||||||
// Check if we have a SubBatch with the same mesh yet
|
// Check if we have a SubBatch with the same mesh yet
|
||||||
auto subBatch = std::find_if(subBatches.begin(), subBatches.end(), [&](const SHSubBatch& batch)
|
auto subBatch = std::find_if(subBatches.begin(), subBatches.end(), [&](const SHSubBatch& batch)
|
||||||
|
@ -54,7 +54,7 @@ namespace SHADE
|
||||||
subBatch->Renderables.insert(renderable);
|
subBatch->Renderables.insert(renderable);
|
||||||
}
|
}
|
||||||
|
|
||||||
void SHBatch::Remove(Handle<SHRenderable> renderable)
|
void SHBatch::Remove(const SHRenderable* renderable)
|
||||||
{
|
{
|
||||||
// Check if we have a SubBatch with the same mesh yet
|
// Check if we have a SubBatch with the same mesh yet
|
||||||
auto subBatch = std::find_if(subBatches.begin(), subBatches.end(), [&](const SHSubBatch& batch)
|
auto subBatch = std::find_if(subBatches.begin(), subBatches.end(), [&](const SHSubBatch& batch)
|
||||||
|
@ -136,7 +136,7 @@ namespace SHADE
|
||||||
});
|
});
|
||||||
|
|
||||||
// Fill in buffers (CPU)
|
// Fill in buffers (CPU)
|
||||||
for (Handle<SHRenderable> renderable : subBatch.Renderables)
|
for (const SHRenderable* renderable : subBatch.Renderables)
|
||||||
{
|
{
|
||||||
// Transform
|
// Transform
|
||||||
transformData.emplace_back(renderable->TransformMatrix);
|
transformData.emplace_back(renderable->TransformMatrix);
|
||||||
|
|
|
@ -49,7 +49,7 @@ namespace SHADE
|
||||||
/* Data Members */
|
/* Data Members */
|
||||||
/*-----------------------------------------------------------------------------*/
|
/*-----------------------------------------------------------------------------*/
|
||||||
Handle<SHMesh> Mesh;
|
Handle<SHMesh> Mesh;
|
||||||
std::unordered_set<Handle<SHRenderable>> Renderables;
|
std::unordered_set<const SHRenderable*> Renderables;
|
||||||
};
|
};
|
||||||
/***********************************************************************************/
|
/***********************************************************************************/
|
||||||
/*!
|
/*!
|
||||||
|
@ -68,8 +68,8 @@ namespace SHADE
|
||||||
/*-----------------------------------------------------------------------------*/
|
/*-----------------------------------------------------------------------------*/
|
||||||
/* Usage Functions */
|
/* Usage Functions */
|
||||||
/*-----------------------------------------------------------------------------*/
|
/*-----------------------------------------------------------------------------*/
|
||||||
void Add(Handle<SHRenderable> renderable);
|
void Add(const SHRenderable* renderable);
|
||||||
void Remove(Handle<SHRenderable> renderable);
|
void Remove(const SHRenderable* renderable);
|
||||||
void Clear();
|
void Clear();
|
||||||
void Build(Handle<SHVkLogicalDevice> device, Handle<SHVkCommandBuffer> cmdBuffer);
|
void Build(Handle<SHVkLogicalDevice> device, Handle<SHVkCommandBuffer> cmdBuffer);
|
||||||
void Draw(Handle<SHVkCommandBuffer> cmdBuffer);
|
void Draw(Handle<SHVkCommandBuffer> cmdBuffer);
|
||||||
|
|
|
@ -21,6 +21,7 @@ of DigiPen Institute of Technology is prohibited.
|
||||||
#include "Graphics/Commands/SHVkCommandBuffer.h"
|
#include "Graphics/Commands/SHVkCommandBuffer.h"
|
||||||
#include "Graphics/MiddleEnd/Interface/SHMaterialInstance.h"
|
#include "Graphics/MiddleEnd/Interface/SHMaterialInstance.h"
|
||||||
#include "Graphics/Pipeline/SHVkPipeline.h"
|
#include "Graphics/Pipeline/SHVkPipeline.h"
|
||||||
|
#include "ECS_Base/Managers/SHComponentManager.h"
|
||||||
|
|
||||||
namespace SHADE
|
namespace SHADE
|
||||||
{
|
{
|
||||||
|
@ -30,7 +31,7 @@ namespace SHADE
|
||||||
void SHBatcher::Init(const std::vector<SHRenderable>& _renderables, Handle<SHRenderGraph> _renderGraph)
|
void SHBatcher::Init(const std::vector<SHRenderable>& _renderables, Handle<SHRenderGraph> _renderGraph)
|
||||||
{
|
{
|
||||||
renderables = &_renderables;
|
renderables = &_renderables;
|
||||||
renderGraph = _renderGraph;
|
renderGraph = _renderGraph;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*---------------------------------------------------------------------------------*/
|
/*---------------------------------------------------------------------------------*/
|
||||||
|
@ -38,8 +39,9 @@ namespace SHADE
|
||||||
/*---------------------------------------------------------------------------------*/
|
/*---------------------------------------------------------------------------------*/
|
||||||
void SHBatcher::PrepareBatches()
|
void SHBatcher::PrepareBatches()
|
||||||
{
|
{
|
||||||
// Iterate through all renderables and send it into the batching
|
// Iterate through all renderables and send it into the batching
|
||||||
for (auto iter = renderables->cbegin(); iter != renderables->cend(); ++iter)
|
auto& renderables = SHComponentManager::GetDense<SHRenderable>();
|
||||||
|
for (auto iter = renderables.cbegin(); iter != renderables.cend(); ++iter)
|
||||||
{
|
{
|
||||||
AddToBatch(iter->GetHandle());
|
AddToBatch(iter->GetHandle());
|
||||||
}
|
}
|
||||||
|
|
|
@ -30,7 +30,7 @@ namespace SHADE
|
||||||
/*---------------------------------------------------------------------------------*/
|
/*---------------------------------------------------------------------------------*/
|
||||||
/* Usage Functions */
|
/* Usage Functions */
|
||||||
/*---------------------------------------------------------------------------------*/
|
/*---------------------------------------------------------------------------------*/
|
||||||
void SHSuperBatch::Add(Handle<SHRenderable> renderable) noexcept
|
void SHSuperBatch::Add(const SHRenderable* renderable) noexcept
|
||||||
{
|
{
|
||||||
const Handle<SHVkPipeline> PIPELINE = renderable->GetMaterial()->GetBaseMaterial()->GetPipeline();
|
const Handle<SHVkPipeline> PIPELINE = renderable->GetMaterial()->GetBaseMaterial()->GetPipeline();
|
||||||
|
|
||||||
|
@ -52,7 +52,7 @@ namespace SHADE
|
||||||
batch->Add(renderable);
|
batch->Add(renderable);
|
||||||
}
|
}
|
||||||
|
|
||||||
void SHSuperBatch::Remove(Handle<SHRenderable> renderable) noexcept
|
void SHSuperBatch::Remove(const SHRenderable* renderable) noexcept
|
||||||
{
|
{
|
||||||
const Handle<SHVkPipeline> PIPELINE = renderable->GetMaterial()->GetBaseMaterial()->GetPipeline();
|
const Handle<SHVkPipeline> PIPELINE = renderable->GetMaterial()->GetBaseMaterial()->GetPipeline();
|
||||||
|
|
||||||
|
|
|
@ -52,8 +52,8 @@ namespace SHADE
|
||||||
/*-----------------------------------------------------------------------------*/
|
/*-----------------------------------------------------------------------------*/
|
||||||
/* Usage Functions */
|
/* Usage Functions */
|
||||||
/*-----------------------------------------------------------------------------*/
|
/*-----------------------------------------------------------------------------*/
|
||||||
void Add(Handle<SHRenderable> renderable) noexcept;
|
void Add(const SHRenderable* renderable) noexcept;
|
||||||
void Remove(Handle<SHRenderable> renderable) noexcept;
|
void Remove(const SHRenderable* renderable) noexcept;
|
||||||
void Clear() noexcept;
|
void Clear() noexcept;
|
||||||
void Build(Handle<SHVkLogicalDevice> device, Handle<SHVkCommandBuffer> cmdBuffer) noexcept;
|
void Build(Handle<SHVkLogicalDevice> device, Handle<SHVkCommandBuffer> cmdBuffer) noexcept;
|
||||||
void Draw(Handle<SHVkCommandBuffer> cmdBuffer) noexcept;
|
void Draw(Handle<SHVkCommandBuffer> cmdBuffer) noexcept;
|
||||||
|
|
Loading…
Reference in New Issue