summaryrefslogtreecommitdiff
path: root/indra/llrender
diff options
context:
space:
mode:
authorNat Goodspeed <nat@lindenlab.com>2021-11-05 12:33:31 -0400
committerNat Goodspeed <nat@lindenlab.com>2021-11-05 12:33:31 -0400
commitff5496239bffadaca111b1e4380a01447f85843a (patch)
tree990a2b72d8eea23f6ef7539079c515aab30625ac /indra/llrender
parent834e7ca088b5f417235327cd290b42459c733594 (diff)
SL-16202: Use WorkQueue::postTo() for texture create/post handshake.
That is, when LLViewerFetchedTexture::scheduleCreateTexture() wants to call createTexture() on the LLImageGLThread, but postCreateTexture() on the main thread, use the "mainloop" WorkQueue to set up the handshake. Give ThreadPool a public virtual run() method so a subclass can override with desired behavior. This necessitates a virtual destructor. Add accessors for embedded WorkQueue (for post calls), ThreadPool name and width (in threads). Allow LLSimpleton::createInstance() to forward arguments to the subject constructor. Make LLImageGLThread an LLSimpleton - that abstraction didn't yet exist at the time LLImageGLThread was coded. Also derive from ThreadPool rather than LLThread. Make it a single-thread "pool" with a very large queue capacity.
Diffstat (limited to 'indra/llrender')
-rw-r--r--indra/llrender/llimagegl.cpp22
-rw-r--r--indra/llrender/llimagegl.h11
2 files changed, 15 insertions, 18 deletions
diff --git a/indra/llrender/llimagegl.cpp b/indra/llrender/llimagegl.cpp
index 71c48801ac..1b6920fe3b 100644
--- a/indra/llrender/llimagegl.cpp
+++ b/indra/llrender/llimagegl.cpp
@@ -172,24 +172,19 @@ BOOL is_little_endian()
return (*c == 0x78) ;
}
-LLImageGLThread* LLImageGLThread::sInstance = nullptr;
-
//static
void LLImageGL::initClass(LLWindow* window, S32 num_catagories, BOOL skip_analyze_alpha /* = false */)
{
LL_PROFILE_ZONE_SCOPED;
sSkipAnalyzeAlpha = skip_analyze_alpha;
- LLImageGLThread::sInstance = new LLImageGLThread(window);
- LLImageGLThread::sInstance->start();
+ LLImageGLThread::createInstance(window);
}
//static
void LLImageGL::cleanupClass()
{
LL_PROFILE_ZONE_SCOPED;
- LLImageGLThread::sInstance->mFunctionQueue.close();
- delete LLImageGLThread::sInstance;
- LLImageGLThread::sInstance = nullptr;
+ LLImageGLThread::deleteSingleton();
}
//static
@@ -1532,8 +1527,7 @@ BOOL LLImageGL::createGLTexture(S32 discard_level, const U8* data_in, BOOL data_
}
//if we're on the image loading thread, be sure to delete old_texname and update mTexName on the main thread
- if (LLImageGLThread::sInstance != nullptr &&
- LLThread::currentID() == LLImageGLThread::sInstance->getID())
+ if (! on_main_thread())
{
{
LL_PROFILE_ZONE_NAMED("cglt - sync");
@@ -2257,7 +2251,11 @@ void LLImageGL::resetCurTexSizebar()
*/
LLImageGLThread::LLImageGLThread(LLWindow* window)
- : LLThread("LLImageGL"), mWindow(window)
+ // We want exactly one thread, but a very large capacity: we never want
+ // anyone, especially inner-loop render code, to have to block on post()
+ // because we're full.
+ : ThreadPool("LLImageGL", 1, 1024*1024)
+ , mWindow(window)
{
mFinished = false;
@@ -2266,9 +2264,11 @@ LLImageGLThread::LLImageGLThread(LLWindow* window)
void LLImageGLThread::run()
{
+ // We must perform setup on this thread before actually servicing our
+ // WorkQueue, likewise cleanup afterwards.
mWindow->makeContextCurrent(mContext);
gGL.init();
- mFunctionQueue.runUntilClose();
+ ThreadPool::run();
gGL.shutdown();
mWindow->destroySharedContext(mContext);
}
diff --git a/indra/llrender/llimagegl.h b/indra/llrender/llimagegl.h
index b9de481aae..27496def1d 100644
--- a/indra/llrender/llimagegl.h
+++ b/indra/llrender/llimagegl.h
@@ -37,6 +37,7 @@
#include "llunits.h"
#include "llthreadsafequeue.h"
#include "llrender.h"
+#include "threadpool.h"
#include "workqueue.h"
class LLTextureAtlas ;
@@ -307,7 +308,7 @@ public:
};
-class LLImageGLThread : public LLThread
+class LLImageGLThread : public LLSimpleton<LLImageGLThread>, LL::ThreadPool
{
public:
LLImageGLThread(LLWindow* window);
@@ -316,19 +317,15 @@ public:
template <typename CALLABLE>
bool post(CALLABLE&& func)
{
- return mFunctionQueue.postIfOpen(std::forward<CALLABLE>(func));
+ return getQueue().postIfOpen(std::forward<CALLABLE>(func));
}
void run() override;
- // Work Queue for background thread
- LL::WorkQueue mFunctionQueue;
-
+private:
LLWindow* mWindow;
void* mContext;
LLAtomicBool mFinished;
-
- static LLImageGLThread* sInstance;
};