mirror of
https://github.com/AxioDL/metaforce.git
synced 2025-12-09 21:07:42 +00:00
Avoid redundant pool destroy/allocs
This commit is contained in:
2
hecl/extern/boo
vendored
2
hecl/extern/boo
vendored
Submodule hecl/extern/boo updated: 8b0927ead0...21f9fcf914
@@ -65,7 +65,11 @@ private:
|
|||||||
Bucket& operator=(Bucket&& other) = default;
|
Bucket& operator=(Bucket&& other) = default;
|
||||||
|
|
||||||
void updateBuffer() {
|
void updateBuffer() {
|
||||||
if (cpuBuffer) {
|
if (useCount == 0) {
|
||||||
|
destroy();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (dirty && cpuBuffer) {
|
||||||
buffer->unmap();
|
buffer->unmap();
|
||||||
cpuBuffer = nullptr;
|
cpuBuffer = nullptr;
|
||||||
}
|
}
|
||||||
@@ -73,19 +77,21 @@ private:
|
|||||||
}
|
}
|
||||||
|
|
||||||
void increment(UniformBufferPool& pool) {
|
void increment(UniformBufferPool& pool) {
|
||||||
if (useCount.fetch_add(1) == 0)
|
if (useCount.fetch_add(1) == 0 && !buffer)
|
||||||
buffer = pool.m_factory->newPoolBuffer(boo::BufferUse::Uniform, pool.m_stride, pool.m_countPerBucket BooTrace);
|
buffer = pool.m_factory->newPoolBuffer(boo::BufferUse::Uniform, pool.m_stride, pool.m_countPerBucket BooTrace);
|
||||||
}
|
}
|
||||||
|
|
||||||
void decrement(UniformBufferPool& pool) {
|
void decrement(UniformBufferPool& pool) {
|
||||||
if (useCount.fetch_sub(1) == 1) {
|
--useCount;
|
||||||
|
}
|
||||||
|
|
||||||
|
void destroy() {
|
||||||
if (cpuBuffer) {
|
if (cpuBuffer) {
|
||||||
buffer->unmap();
|
buffer->unmap();
|
||||||
cpuBuffer = nullptr;
|
cpuBuffer = nullptr;
|
||||||
}
|
}
|
||||||
buffer.reset();
|
buffer.reset();
|
||||||
}
|
}
|
||||||
}
|
|
||||||
};
|
};
|
||||||
std::vector<std::unique_ptr<Bucket>> m_buckets;
|
std::vector<std::unique_ptr<Bucket>> m_buckets;
|
||||||
|
|
||||||
@@ -157,7 +163,6 @@ public:
|
|||||||
/** Load dirty buffer data into GPU */
|
/** Load dirty buffer data into GPU */
|
||||||
void updateBuffers() {
|
void updateBuffers() {
|
||||||
for (auto& bucket : m_buckets)
|
for (auto& bucket : m_buckets)
|
||||||
if (bucket->dirty)
|
|
||||||
bucket->updateBuffer();
|
bucket->updateBuffer();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -65,7 +65,11 @@ private:
|
|||||||
Bucket& operator=(Bucket&& other) = delete;
|
Bucket& operator=(Bucket&& other) = delete;
|
||||||
|
|
||||||
void updateBuffer() {
|
void updateBuffer() {
|
||||||
if (cpuBuffer) {
|
if (useCount == 0) {
|
||||||
|
destroy();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (dirty && cpuBuffer) {
|
||||||
buffer->unmap();
|
buffer->unmap();
|
||||||
cpuBuffer = nullptr;
|
cpuBuffer = nullptr;
|
||||||
}
|
}
|
||||||
@@ -73,19 +77,21 @@ private:
|
|||||||
}
|
}
|
||||||
|
|
||||||
void increment(VertexBufferPool& pool) {
|
void increment(VertexBufferPool& pool) {
|
||||||
if (useCount.fetch_add(1) == 0)
|
if (useCount.fetch_add(1) == 0 && !buffer)
|
||||||
buffer = pool.m_factory->newPoolBuffer(boo::BufferUse::Vertex, pool.m_stride, pool.m_countPerBucket BooTrace);
|
buffer = pool.m_factory->newPoolBuffer(boo::BufferUse::Vertex, pool.m_stride, pool.m_countPerBucket BooTrace);
|
||||||
}
|
}
|
||||||
|
|
||||||
void decrement(VertexBufferPool& pool) {
|
void decrement(VertexBufferPool& pool) {
|
||||||
if (useCount.fetch_sub(1) == 1) {
|
--useCount;
|
||||||
|
}
|
||||||
|
|
||||||
|
void destroy() {
|
||||||
if (cpuBuffer) {
|
if (cpuBuffer) {
|
||||||
buffer->unmap();
|
buffer->unmap();
|
||||||
cpuBuffer = nullptr;
|
cpuBuffer = nullptr;
|
||||||
}
|
}
|
||||||
buffer.reset();
|
buffer.reset();
|
||||||
}
|
}
|
||||||
}
|
|
||||||
};
|
};
|
||||||
std::vector<std::unique_ptr<Bucket>> m_buckets;
|
std::vector<std::unique_ptr<Bucket>> m_buckets;
|
||||||
|
|
||||||
@@ -162,7 +168,6 @@ public:
|
|||||||
/** Load dirty buffer data into GPU */
|
/** Load dirty buffer data into GPU */
|
||||||
void updateBuffers() {
|
void updateBuffers() {
|
||||||
for (auto& bucket : m_buckets)
|
for (auto& bucket : m_buckets)
|
||||||
if (bucket->dirty)
|
|
||||||
bucket->updateBuffer();
|
bucket->updateBuffer();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user