Owner-authorized source migration: 31 helper-only translation units were merged into their callers or existing inline headers; both build manifests updated. Includes the preserved source payload, Lua configuration matching wowdecomp, and exact malloca expansion without diagnostic pragmas. 449 native units compiled locally and 449 staged units compiled by the pinned server toolchain. No previously byte-matched function regressed. Compiler mapping diagnostics remain recorded as needs_cleanup, not accepted or peer-confirmed. Existing independent review records are preserved. README.md is intentionally unchanged.
75 lines
1.9 KiB
C++
75 lines
1.9 KiB
C++
#include "Render/Primitives/RenderVertexPool.h"
|
|
|
|
#include <algorithm>
|
|
|
|
namespace {
|
|
void Append(std::vector<RenderVertex>& block, unsigned count) {
|
|
const unsigned first = static_cast<unsigned>(block.size());
|
|
block.resize(first + count);
|
|
|
|
for (unsigned index = first; index < block.size(); ++index) {
|
|
block[index].specular = 0xFF000000u;
|
|
}
|
|
}
|
|
}
|
|
|
|
// INLINED
|
|
RenderVertexPool::RenderVertexPool() : m_minimum(10240), m_used(0) {
|
|
this->Activate(this->m_minimum);
|
|
}
|
|
|
|
// OFFSET: 0x00559AA0
|
|
// FUNCTION: fn_02070
|
|
RenderVertexPool::Block& RenderVertexPool::Activate(unsigned capacity) {
|
|
auto previous = this->m_unused.before_begin();
|
|
|
|
for (auto current = this->m_unused.begin(); current != this->m_unused.end(); ++current) {
|
|
if ((*current)->capacity() >= capacity) {
|
|
this->m_active.splice_after(this->m_active.before_begin(), this->m_unused, previous);
|
|
return *this->m_active.front();
|
|
}
|
|
|
|
previous = current;
|
|
}
|
|
|
|
auto block = std::make_unique<Block>();
|
|
block->reserve(capacity);
|
|
this->m_active.push_front(std::move(block));
|
|
|
|
return *this->m_active.front();
|
|
}
|
|
|
|
// OFFSET: 0x00ABC950
|
|
// FUNCTION: fn_17537
|
|
RenderVertex* RenderVertexPool::Acquire(unsigned count) {
|
|
if (count == 0) {
|
|
return nullptr;
|
|
}
|
|
|
|
for (auto& block : this->m_active) {
|
|
if (block->capacity() - block->size() >= count) {
|
|
const unsigned first = static_cast<unsigned>(block->size());
|
|
Append(*block, count);
|
|
this->m_used += count;
|
|
|
|
return block->data() + first;
|
|
}
|
|
}
|
|
|
|
Block& block = this->Activate(std::max(this->m_minimum, count));
|
|
Append(block, count);
|
|
this->m_used += count;
|
|
|
|
return block.data();
|
|
}
|
|
|
|
// INLINED
|
|
void RenderVertexPool::Rewind() {
|
|
for (auto& block : this->m_active) {
|
|
block->clear();
|
|
}
|
|
|
|
this->m_unused.splice_after(this->m_unused.before_begin(), this->m_active);
|
|
this->m_used = 0;
|
|
this->Activate(this->m_minimum);
|
|
}
|