Use a correct method to detect last queue texture
This commit is contained in:
parent
27fcc4e266
commit
498ce3ebc9
@ -366,13 +366,13 @@ void STKTexManager::checkThreadedLoadTextures(bool util_queue_empty)
|
||||
{
|
||||
for (ThreadedTexLoader* ttl : m_all_tex_loaders)
|
||||
{
|
||||
ttl->lock();
|
||||
if (ttl->hasCompletedTextures())
|
||||
if (ttl->lastQueueReady())
|
||||
{
|
||||
ttl->lock();
|
||||
ttl->setFinishLoading();
|
||||
uploaded = true;
|
||||
ttl->unlock(false/*finish_it*/);
|
||||
}
|
||||
ttl->unlock(false/*finish_it*/);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
@ -33,6 +33,7 @@ void* ThreadedTexLoader::startRoutine(void *obj)
|
||||
{
|
||||
pthread_mutex_lock(&ttl->m_mutex);
|
||||
bool finished = ttl->finishedLoading();
|
||||
bool has_completed_tex = !ttl->m_completed_textures.empty();
|
||||
pthread_mutex_unlock(&ttl->m_mutex);
|
||||
if (finished)
|
||||
{
|
||||
@ -40,6 +41,7 @@ void* ThreadedTexLoader::startRoutine(void *obj)
|
||||
}
|
||||
pthread_mutex_lock(ttl->m_texture_queue_mutex);
|
||||
bool waiting = ttl->m_stktm->isThreadedLoadTexturesEmpty();
|
||||
ttl->m_last_queue_ready.setAtomic(has_completed_tex && waiting);
|
||||
while (waiting)
|
||||
{
|
||||
pthread_cond_wait(ttl->m_cond_request, ttl->m_texture_queue_mutex);
|
||||
|
@ -20,9 +20,9 @@
|
||||
|
||||
#include "utils/can_be_deleted.hpp"
|
||||
#include "utils/no_copy.hpp"
|
||||
#include "utils/synchronised.hpp"
|
||||
#include "utils/types.hpp"
|
||||
|
||||
#include <pthread.h>
|
||||
#include <vector>
|
||||
|
||||
namespace irr
|
||||
@ -54,6 +54,8 @@ private:
|
||||
|
||||
bool m_finished_loading, m_locked;
|
||||
|
||||
Synchronised<bool> m_last_queue_ready;
|
||||
|
||||
std::vector<irr::video::ITexture*> m_completed_textures;
|
||||
|
||||
public:
|
||||
@ -67,7 +69,7 @@ public:
|
||||
m_pbo_ptr(pbo_ptr), m_texture_queue_mutex(mutex),
|
||||
m_cond_request(cond), m_stktm(stktm),
|
||||
m_tex_size_loaded(0), m_finished_loading(false),
|
||||
m_locked(false)
|
||||
m_locked(false), m_last_queue_ready(false)
|
||||
{
|
||||
pthread_mutex_init(&m_mutex, NULL);
|
||||
pthread_create(&m_thread, NULL, &startRoutine, this);
|
||||
@ -83,11 +85,12 @@ public:
|
||||
// ------------------------------------------------------------------------
|
||||
void setFinishLoading()
|
||||
{
|
||||
m_last_queue_ready.setAtomic(false);
|
||||
m_finished_loading = true;
|
||||
m_tex_size_loaded = 0;
|
||||
}
|
||||
// ------------------------------------------------------------------------
|
||||
bool hasCompletedTextures() const { return !m_completed_textures.empty(); }
|
||||
bool lastQueueReady() const { return m_last_queue_ready.getAtomic(); }
|
||||
// ------------------------------------------------------------------------
|
||||
void handleCompletedTextures();
|
||||
// ------------------------------------------------------------------------
|
||||
|
Loading…
Reference in New Issue
Block a user