Batch #1427 by Yommy: 0 byte-identical, 14 confirmed by peer review. - fn_02113 CRendererDX7::SetClearColor: logic confirmed by peer review (annotation added to existing code) - fn_02117 CRendererDX7::SetTextureFormat: logic confirmed by peer review (annotation added to existing code) - fn_02487 ?Color4444@?A0xa800f118@@YAGI@Z: logic confirmed by peer review (annotation added to existing code) - fn_02488 ?Color565@?A0xa800f118@@YAGI@Z: logic confirmed by peer review (annotation added to existing code) - fn_17486 RenderVertexPool::Block::Append: logic confirmed by peer review (annotation added to existing code) - fn_01953 DrawBlendedRectangle: logic confirmed by peer review (annotation added to existing code) - fn_01954 DrawTexturedRectangle: logic confirmed by peer review (annotation added to existing code) - fn_01955 DrawTextureRegion: logic confirmed by peer review (annotation added to existing code) - fn_01944 DrawScreenQuad: logic confirmed by peer review (annotation added to existing code) - fn_01951 DrawScreenLine: logic confirmed by peer review (annotation added to existing code) - fn_02101 RhwToDepth: logic confirmed by peer review (annotation added to existing code) - fn_10121 UIRPData::DrawStretched: logic confirmed by peer review (annotation added to existing code) - fn_10122 UIRPData::DrawNamed: logic confirmed by peer review (annotation added to existing code) - fn_10123 UIRPData::SetSolid: logic confirmed by peer review (annotation added to existing code) Reviewed-by: ragnarok-clanker
93 lines
2.3 KiB
C++
93 lines
2.3 KiB
C++
#include "Render/Primitives/RenderVertexPool.h"
|
|
|
|
#include <algorithm>
|
|
|
|
namespace {
|
|
// INLINED
|
|
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();
|
|
}
|
|
|
|
// OFFSET: 0x00AB77A0
|
|
// FUNCTION: fn_17486
|
|
RenderVertex* RenderVertexPool::Block::Append(unsigned count) {
|
|
const unsigned first = static_cast<unsigned>(this->size());
|
|
if (first + count > this->capacity()) {
|
|
return nullptr;
|
|
}
|
|
|
|
this->resize(first + count);
|
|
|
|
for (unsigned index = first; index < this->size(); ++index) {
|
|
(*this)[index].specular = 0xFF000000u;
|
|
}
|
|
|
|
return this->data() + (this->size() - count);
|
|
}
|
|
|
|
// 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);
|
|
}
|