move global pools into gfx driver
prevents double copy problems saves memory (needs to be optimized...)
This commit is contained in:
@@ -2,7 +2,6 @@
|
||||
|
||||
#include <cstddef>
|
||||
#include <pd/core/pool.hpp>
|
||||
#include <pd/lithium/pools.hpp>
|
||||
#include <pd/lithium/vertex.hpp>
|
||||
|
||||
namespace PD {
|
||||
@@ -12,54 +11,12 @@ class Command {
|
||||
Command() { Reset(); }
|
||||
~Command() {}
|
||||
|
||||
void Reserve(size_t vtx, size_t idx) {
|
||||
if (!FirstVertex) {
|
||||
FirstVertex = AllocateVertices(vtx, (PD::ptr)this);
|
||||
VertexCountMax = vtx;
|
||||
} else {
|
||||
ExpandVertices(vtx, (PD::ptr)this);
|
||||
VertexCountMax += vtx;
|
||||
}
|
||||
if (!FirstIndex) {
|
||||
FirstIndex = AllocateIndices(idx, (PD::ptr)this);
|
||||
IndexCountMax = idx;
|
||||
} else {
|
||||
ExpandIndices(idx, (PD::ptr)this);
|
||||
IndexCountMax += idx;
|
||||
}
|
||||
}
|
||||
void Reserve(size_t vtx, size_t idx);
|
||||
void Reset();
|
||||
|
||||
void Reset() {
|
||||
Layer = 0;
|
||||
Tex = 0;
|
||||
FirstIndex = 0;
|
||||
FirstVertex = 0;
|
||||
IndexCount = 0;
|
||||
VertexCount = 0;
|
||||
VertexCountMax = 0;
|
||||
IndexCountMax = 0;
|
||||
}
|
||||
|
||||
Command& Add(const Vertex& vtx) {
|
||||
if (VertexCount <= VertexCountMax)
|
||||
PutVertex(FirstVertex + VertexCount++, vtx, (PD::ptr)this);
|
||||
return *this;
|
||||
}
|
||||
Command& Add(u16 idx) {
|
||||
if (IndexCount <= IndexCountMax)
|
||||
PutIndex(FirstIndex + IndexCount++, VertexCount + idx, (PD::ptr)this);
|
||||
return *this;
|
||||
}
|
||||
Command& Add(u16 a, u16 b, u16 c) {
|
||||
if (IndexCount + 3 <= IndexCountMax) {
|
||||
size_t idx = FirstIndex + IndexCount;
|
||||
PutIndex(idx + 0, VertexCount + a, (PD::ptr)this);
|
||||
PutIndex(idx + 1, VertexCount + b, (PD::ptr)this);
|
||||
PutIndex(idx + 2, VertexCount + c, (PD::ptr)this);
|
||||
IndexCount += 3;
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
Command& Add(const Vertex& vtx);
|
||||
Command& Add(u16 idx);
|
||||
Command& Add(u16 a, u16 b, u16 c);
|
||||
|
||||
int Layer = 0;
|
||||
ptr Tex = 0;
|
||||
|
||||
@@ -4,5 +4,4 @@
|
||||
#include <pd/lithium/drawlist.hpp>
|
||||
#include <pd/lithium/font.hpp>
|
||||
#include <pd/lithium/math.hpp>
|
||||
#include <pd/lithium/pools.hpp>
|
||||
#include <pd/lithium/vertex.hpp>
|
||||
|
||||
@@ -1,26 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
#include <cstddef>
|
||||
#include <pd/lithium/vertex.hpp>
|
||||
|
||||
namespace PD {
|
||||
namespace Li {
|
||||
/**
|
||||
* Allocate an amount of vertices
|
||||
* returns the index of the first vertex
|
||||
*/
|
||||
PD_API size_t AllocateVertices(size_t count, PD::ptr accessor);
|
||||
/**
|
||||
* Allocate an amount of indices
|
||||
* returns the index of the first elem
|
||||
*/
|
||||
PD_API size_t AllocateIndices(size_t count, PD::ptr accessor);
|
||||
PD_API bool ExpandVertices(size_t count, PD::ptr accessor);
|
||||
PD_API bool ExpandIndices(size_t count, PD::ptr accessor);
|
||||
PD_API void PutVertex(size_t loc, const Vertex& vtx, PD::ptr accessor);
|
||||
PD_API void PutIndex(size_t loc, u16 idx, PD::ptr accessor);
|
||||
PD_API const Vertex& GetVertex(size_t loc);
|
||||
PD_API const u16& GetIndex(size_t loc);
|
||||
PD_API void ResetPools();
|
||||
} // namespace Li
|
||||
} // namespace PD
|
||||
Reference in New Issue
Block a user