Skip to content

Commit f3f3c49

Browse files
Merge pull request #6 from sldevel/master
Fix a thread safety issue in the GL image worker.
2 parents 783926e + 9c5043d commit f3f3c49

File tree

3 files changed

+15
-10
lines changed

3 files changed

+15
-10
lines changed

indra/newview/lldrawpoolbump.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,9 @@ static S32 cube_channel = -1;
7777
static S32 diffuse_channel = -1;
7878
static S32 bump_channel = -1;
7979

80-
#define LL_BUMPLIST_MULTITHREADED 0 // TODO -- figure out why this doesn't work
80+
// Enabled after changing LLViewerTexture::mNeedsCreateTexture to an
81+
// LLAtomicBool; this should work just fine, now. HB
82+
#define LL_BUMPLIST_MULTITHREADED 1
8183

8284
// static
8385
void LLStandardBumpmap::init()

indra/newview/llviewertexture.cpp

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1118,7 +1118,7 @@ void LLViewerFetchedTexture::init(bool firstinit)
11181118
mLoadedCallbackDesiredDiscardLevel = S8_MAX;
11191119
mPauseLoadedCallBacks = FALSE;
11201120

1121-
mNeedsCreateTexture = FALSE;
1121+
mNeedsCreateTexture = false;
11221122

11231123
mIsRawImageValid = FALSE;
11241124
mRawDiscardLevel = INVALID_DISCARD_LEVEL;
@@ -1400,12 +1400,12 @@ void LLViewerFetchedTexture::addToCreateTexture()
14001400
{
14011401
//just update some variables, not to create a real GL texture.
14021402
createGLTexture(mRawDiscardLevel, mRawImage, 0, FALSE);
1403-
mNeedsCreateTexture = FALSE;
1403+
mNeedsCreateTexture = false;
14041404
destroyRawImage();
14051405
}
14061406
else if(!force_update && getDiscardLevel() > -1 && getDiscardLevel() <= mRawDiscardLevel)
14071407
{
1408-
mNeedsCreateTexture = FALSE;
1408+
mNeedsCreateTexture = false;
14091409
destroyRawImage();
14101410
}
14111411
else
@@ -1441,7 +1441,7 @@ void LLViewerFetchedTexture::addToCreateTexture()
14411441
mRawDiscardLevel += i;
14421442
if(mRawDiscardLevel >= getDiscardLevel() && getDiscardLevel() > 0)
14431443
{
1444-
mNeedsCreateTexture = FALSE;
1444+
mNeedsCreateTexture = false;
14451445
destroyRawImage();
14461446
return;
14471447
}
@@ -1473,7 +1473,7 @@ BOOL LLViewerFetchedTexture::preCreateTexture(S32 usename/*= 0*/)
14731473
destroyRawImage();
14741474
return FALSE;
14751475
}
1476-
mNeedsCreateTexture = FALSE;
1476+
mNeedsCreateTexture = false;
14771477

14781478
if (mRawImage.isNull())
14791479
{
@@ -1609,14 +1609,14 @@ void LLViewerFetchedTexture::postCreateTexture()
16091609
destroyRawImage();
16101610
}
16111611

1612-
mNeedsCreateTexture = FALSE;
1612+
mNeedsCreateTexture = false;
16131613
}
16141614

16151615
void LLViewerFetchedTexture::scheduleCreateTexture()
16161616
{
16171617
if (!mNeedsCreateTexture)
16181618
{
1619-
mNeedsCreateTexture = TRUE;
1619+
mNeedsCreateTexture = true;
16201620
if (preCreateTexture())
16211621
{
16221622
#if LL_IMAGEGL_THREAD_CHECK
@@ -1630,7 +1630,7 @@ void LLViewerFetchedTexture::scheduleCreateTexture()
16301630
memcpy(data_copy, data, size);
16311631
}
16321632
#endif
1633-
mNeedsCreateTexture = TRUE;
1633+
mNeedsCreateTexture = true;
16341634
auto mainq = LLImageGLThread::sEnabled ? mMainQueue.lock() : nullptr;
16351635
if (mainq)
16361636
{

indra/newview/llviewertexture.h

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
#ifndef LL_LLVIEWERTEXTURE_H
2828
#define LL_LLVIEWERTEXTURE_H
2929

30+
#include "llatomic.h"
3031
#include "llgltexture.h"
3132
#include "lltimer.h"
3233
#include "llframetimer.h"
@@ -528,7 +529,9 @@ class LLViewerFetchedTexture : public LLViewerTexture
528529
LLFrameTimer mStopFetchingTimer; // Time since mDecodePriority == 0.f.
529530

530531
BOOL mInImageList; // TRUE if image is in list (in which case don't reset priority!)
531-
BOOL mNeedsCreateTexture;
532+
// This needs to be atomic, since it is written both in the main thread
533+
// and in the GL image worker thread... HB
534+
LLAtomicBool mNeedsCreateTexture;
532535

533536
BOOL mForSculpt ; //a flag if the texture is used as sculpt data.
534537
BOOL mIsFetched ; //is loaded from remote or from cache, not generated locally.

0 commit comments

Comments
 (0)