move global pools into gfx driver

prevents double copy problems
saves memory
(needs to be optimized...)
This commit is contained in:
2026-09-02 08:04:50 +02:00
parent daaf473af7
commit 54584728c3
10 changed files with 161 additions and 162 deletions
+5 -48
View File
@@ -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;