mirror of
https://github.com/AxioDL/metaforce.git
synced 2025-07-01 22:53:32 +00:00
Avoid redundant pool destroy/allocs
This commit is contained in:
parent
f262e59e68
commit
3759bf1b3d
2
hecl/extern/boo
vendored
2
hecl/extern/boo
vendored
@ -1 +1 @@
|
|||||||
Subproject commit 8b0927ead0a13f0fcb1305688997191b026a9190
|
Subproject commit 21f9fcf914488a25926e781a99df4d4f19f4ee8a
|
@ -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();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user