mirror of
https://github.com/HifiExperiments/overte.git
synced 2025-08-04 03:04:40 +02:00
implement support for proper cleanup in BatchItemDetails
This commit is contained in:
parent
925b13cc93
commit
17e48554d8
2 changed files with 49 additions and 15 deletions
|
@ -40,6 +40,10 @@ GeometryCache::~GeometryCache() {
|
||||||
glDeleteBuffers(1, &vbo.first);
|
glDeleteBuffers(1, &vbo.first);
|
||||||
glDeleteBuffers(1, &vbo.second);
|
glDeleteBuffers(1, &vbo.second);
|
||||||
}
|
}
|
||||||
|
qDebug() << "GeometryCache::~GeometryCache()... ";
|
||||||
|
qDebug() << " _registeredLine3DVBOs.size():" << _registeredLine3DVBOs.size();
|
||||||
|
qDebug() << " _line3DVBOs.size():" << _line3DVBOs.size();
|
||||||
|
qDebug() << " BatchItemDetails... population:" << GeometryCache::BatchItemDetails::population;
|
||||||
}
|
}
|
||||||
|
|
||||||
void GeometryCache::renderHemisphere(int slices, int stacks) {
|
void GeometryCache::renderHemisphere(int slices, int stacks) {
|
||||||
|
@ -1400,11 +1404,51 @@ void GeometryCache::renderDashedLine(const glm::vec3& start, const glm::vec3& en
|
||||||
details.buffer.release();
|
details.buffer.release();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int GeometryCache::BatchItemDetails::population = 0;
|
||||||
|
GeometryCache::BatchItemDetails::BatchItemDetails() :
|
||||||
|
verticesBuffer(NULL),
|
||||||
|
colorBuffer(NULL),
|
||||||
|
streamFormat(NULL),
|
||||||
|
stream(NULL),
|
||||||
|
vertices(0),
|
||||||
|
vertexSize(0),
|
||||||
|
isCreated(false)
|
||||||
|
{
|
||||||
|
population++;
|
||||||
|
}
|
||||||
|
|
||||||
|
GeometryCache::BatchItemDetails::BatchItemDetails(const GeometryCache::BatchItemDetails& other) :
|
||||||
|
verticesBuffer(other.verticesBuffer),
|
||||||
|
colorBuffer(other.colorBuffer),
|
||||||
|
streamFormat(other.streamFormat),
|
||||||
|
stream(other.stream),
|
||||||
|
vertices(other.vertices),
|
||||||
|
vertexSize(other.vertexSize),
|
||||||
|
isCreated(other.isCreated)
|
||||||
|
{
|
||||||
|
population++;
|
||||||
|
}
|
||||||
|
|
||||||
|
GeometryCache::BatchItemDetails::~BatchItemDetails() {
|
||||||
|
population--;
|
||||||
|
clear();
|
||||||
|
qDebug() << "~BatchItemDetails()... population:" << population << "**********************************";
|
||||||
|
}
|
||||||
|
|
||||||
|
void GeometryCache::BatchItemDetails::clear() {
|
||||||
|
isCreated = false;
|
||||||
|
verticesBuffer.clear();
|
||||||
|
colorBuffer.clear();
|
||||||
|
streamFormat.clear();
|
||||||
|
stream.clear();
|
||||||
|
}
|
||||||
|
|
||||||
void GeometryCache::renderLine(const glm::vec3& p1, const glm::vec3& p2,
|
void GeometryCache::renderLine(const glm::vec3& p1, const glm::vec3& p2,
|
||||||
const glm::vec4& color1, const glm::vec4& color2, int id) {
|
const glm::vec4& color1, const glm::vec4& color2, int id) {
|
||||||
|
|
||||||
bool registered = (id != UNKNOWN_ID);
|
bool registered = (id != UNKNOWN_ID);
|
||||||
Vec3Pair key(p1, p2);
|
Vec3Pair key(p1, p2);
|
||||||
|
|
||||||
BatchItemDetails& details = registered ? _registeredLine3DVBOs[id] : _line3DVBOs[key];
|
BatchItemDetails& details = registered ? _registeredLine3DVBOs[id] : _line3DVBOs[key];
|
||||||
|
|
||||||
int compactColor1 = ((int(color1.x * 255.0f) & 0xFF)) |
|
int compactColor1 = ((int(color1.x * 255.0f) & 0xFF)) |
|
||||||
|
|
|
@ -156,6 +156,7 @@ private:
|
||||||
|
|
||||||
class BatchItemDetails {
|
class BatchItemDetails {
|
||||||
public:
|
public:
|
||||||
|
static int population;
|
||||||
gpu::BufferPointer verticesBuffer;
|
gpu::BufferPointer verticesBuffer;
|
||||||
gpu::BufferPointer colorBuffer;
|
gpu::BufferPointer colorBuffer;
|
||||||
gpu::Stream::FormatPointer streamFormat;
|
gpu::Stream::FormatPointer streamFormat;
|
||||||
|
@ -165,21 +166,10 @@ private:
|
||||||
int vertexSize;
|
int vertexSize;
|
||||||
bool isCreated;
|
bool isCreated;
|
||||||
|
|
||||||
BatchItemDetails() :
|
BatchItemDetails();
|
||||||
verticesBuffer(NULL),
|
BatchItemDetails(const GeometryCache::BatchItemDetails& other);
|
||||||
colorBuffer(NULL),
|
~BatchItemDetails();
|
||||||
streamFormat(NULL),
|
void clear();
|
||||||
stream(NULL),
|
|
||||||
vertices(0),
|
|
||||||
vertexSize(0),
|
|
||||||
isCreated(false)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
void clear() {
|
|
||||||
// TODO: add the proper de-allocation of the gpu items
|
|
||||||
isCreated = false;
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
QHash<IntPair, VerticesIndices> _hemisphereVBOs;
|
QHash<IntPair, VerticesIndices> _hemisphereVBOs;
|
||||||
|
|
Loading…
Reference in a new issue