This commit is contained in:
Renato Machado 2025-08-07 16:33:00 -03:00
parent c5f7b3ed84
commit aaf175e3d3
4 changed files with 29 additions and 2 deletions

View file

@ -177,6 +177,8 @@ void MapView::drawFloor()
}
tasks.wait();
g_drawPool.join();
} else for (const auto& tile : map.tiles)
drawTile(tile, _camera, alwaysTransparent);

View file

@ -63,8 +63,9 @@ void DrawPool::add(const Color& color, const TexturePtr& texture, DrawMethod&& m
}
}
if (textureAtlas && m_perThreadObjects.size() > 1) {
m_perThreadObjects[CURRENT_THREAD_ID].emplace_back(color, method, textureAtlas);
if (m_perThreadObjects.size() > 1) {
if (textureAtlas)
m_perThreadObjects[CURRENT_THREAD_ID].emplace_back(color, std::move(method), textureAtlas);
return;
}
@ -94,6 +95,27 @@ void DrawPool::add(const Color& color, const TexturePtr& texture, DrawMethod&& m
resetOnlyOnceParameters();
}
void DrawPool::join() {
for (auto& objs : m_perThreadObjects) {
for (const auto& obj : objs) {
if (!updateHash(obj.method, nullptr, obj.color, false))
continue;
auto& list = m_objects[DrawOrder::THIRD];
auto& state = getCurrentState();
if (!list.empty() && list.back().state == state) {
auto& last = list.back();
addCoords(*last.coords, obj.method);
} else {
auto& draw = list.emplace_back(getState(nullptr, obj.atlas, obj.color), getCoordsBuffer());
addCoords(*draw.coords, obj.method);
}
}
objs.clear();
}
}
void DrawPool::addCoords(CoordsBuffer& buffer, const DrawMethod& method)
{
if (method.type == DrawMethodType::BOUNDING_RECT) {

View file

@ -341,6 +341,8 @@ private:
m_parameters.erase(it);
}
void join();
void flush()
{
m_coords.clear();

View file

@ -106,6 +106,7 @@ public:
bool containsParameter(const std::string_view name) { return getCurrentPool()->containsParameter(name); }
void flush() const { if (getCurrentPool()) getCurrentPool()->flush(); }
void join() const { if (getCurrentPool()) getCurrentPool()->join(); }
DrawPoolType getCurrentType() const;