diff options
author | Runitai Linden <davep@lindenlab.com> | 2022-01-19 10:35:58 -0600 |
---|---|---|
committer | Runitai Linden <davep@lindenlab.com> | 2022-01-19 10:35:58 -0600 |
commit | 1a440be5e1760ac95e9a1ef43e5c74b768726826 (patch) | |
tree | 5cb1d3bfd24c01f2b3b1d34c8524943a1e0dcdfe /indra | |
parent | 0da2ab228961f1e50c830121c37cfa77c431a980 (diff) |
SL-16653 Fix for some textures having incorrect texel colors after the first row (and add more paranoia checks on texture data).
Diffstat (limited to 'indra')
-rw-r--r-- | indra/llrender/llrender.cpp | 8 | ||||
-rw-r--r-- | indra/newview/llviewertexture.cpp | 42 | ||||
-rw-r--r-- | indra/newview/llviewerwindow.cpp | 9 |
3 files changed, 45 insertions, 14 deletions
diff --git a/indra/llrender/llrender.cpp b/indra/llrender/llrender.cpp index 3b46eef1b4..92d8e6193f 100644 --- a/indra/llrender/llrender.cpp +++ b/indra/llrender/llrender.cpp @@ -860,6 +860,14 @@ LLRender::~LLRender() void LLRender::init() { + glPixelStorei(GL_PACK_ALIGNMENT, 1); + glPixelStorei(GL_UNPACK_ALIGNMENT, 1); + + gGL.setSceneBlendType(LLRender::BT_ALPHA); + gGL.setAmbientLightColor(LLColor4::black); + + glCullFace(GL_BACK); + if (sGLCoreProfile && !LLVertexBuffer::sUseVAO) { //bind a dummy vertex array object so we're core profile compliant #ifdef GL_ARB_vertex_array_object diff --git a/indra/newview/llviewertexture.cpp b/indra/newview/llviewertexture.cpp index 06f623f1f8..5fed46f437 100644 --- a/indra/newview/llviewertexture.cpp +++ b/indra/newview/llviewertexture.cpp @@ -1626,10 +1626,21 @@ void LLViewerFetchedTexture::scheduleCreateTexture() { if (!mNeedsCreateTexture) { - ref(); mNeedsCreateTexture = TRUE; if (preCreateTexture()) { + ref(); +#if LL_IMAGEGL_THREAD_CHECK + //grab a copy of the raw image data to make sure it isn't modified pending texture creation + U8* data = mRawImage->getData(); + U8* data_copy = nullptr; + S32 size = mRawImage->getDataSize(); + if (data != nullptr && size > 0) + { + data_copy = new U8[size]; + memcpy(data_copy, data, size); + } +#endif mNeedsCreateTexture = TRUE; auto mainq = LLImageGLThread::sEnabled ? mMainQueue.lock() : nullptr; if (mainq) @@ -1637,19 +1648,40 @@ void LLViewerFetchedTexture::scheduleCreateTexture() mainq->postTo( mImageQueue, // work to be done on LLImageGL worker thread - [this]() - { #if LL_IMAGEGL_THREAD_CHECK + [this, data, data_copy, size]() + { mGLTexturep->mActiveThread = LLThread::currentID(); + //verify data is unmodified + llassert(data == mRawImage->getData()); + llassert(mRawImage->getDataSize() == size); + llassert(memcmp(data, data_copy, size) == 0); +#else + [this]() + { #endif //actually create the texture on a background thread createTexture(); + +#if LL_IMAGEGL_THREAD_CHECK + //verify data is unmodified + llassert(data == mRawImage->getData()); + llassert(mRawImage->getDataSize() == size); + llassert(memcmp(data, data_copy, size) == 0); +#endif }, // callback to be run on main thread - [this]() - { #if LL_IMAGEGL_THREAD_CHECK + [this, data, data_copy, size]() + { mGLTexturep->mActiveThread = LLThread::currentID(); + llassert(data == mRawImage->getData()); + llassert(mRawImage->getDataSize() == size); + llassert(memcmp(data, data_copy, size) == 0); + delete[] data_copy; +#else + [this]() + { #endif //finalize on main thread postCreateTexture(); diff --git a/indra/newview/llviewerwindow.cpp b/indra/newview/llviewerwindow.cpp index 2fc4e9d0bd..b9a5e90df0 100644 --- a/indra/newview/llviewerwindow.cpp +++ b/indra/newview/llviewerwindow.cpp @@ -2058,15 +2058,6 @@ std::string LLViewerWindow::getLastSnapshotDir() void LLViewerWindow::initGLDefaults() { - gGL.setSceneBlendType(LLRender::BT_ALPHA); - - glPixelStorei(GL_PACK_ALIGNMENT,1); - glPixelStorei(GL_UNPACK_ALIGNMENT,1); - - gGL.setAmbientLightColor(LLColor4::black); - - glCullFace(GL_BACK); - // RN: Need this for translation and stretch manip. gBox.prerender(); } |