master
Ansariel 2022-01-22 11:46:39 +01:00
commit 212e6d8fc1
4 changed files with 68 additions and 15 deletions

View File

@ -868,6 +868,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

View File

@ -618,6 +618,7 @@ namespace
specialSet.insert(SETTING_CLOUD_TEXTUREID);
specialSet.insert(SETTING_MOON_TEXTUREID);
specialSet.insert(SETTING_SUN_TEXTUREID);
specialSet.insert(SETTING_CLOUD_SHADOW); // due to being part of skips
}
return specialSet;
}
@ -658,6 +659,7 @@ namespace
template<>
void LLSettingsInjected<LLSettingsVOSky>::updateSpecial(const typename LLSettingsInjected<LLSettingsVOSky>::Injection::ptr_t &injection, typename LLSettingsBase::BlendFactor mix)
{
bool is_texture = true;
if (injection->mKeyName == SETTING_SUN_TEXTUREID)
{
mNextSunTextureId = injection->mValue.asUUID();
@ -682,9 +684,29 @@ namespace
{
mNextHaloTextureId = injection->mValue.asUUID();
}
else if (injection->mKeyName == LLSettingsSky::SETTING_CLOUD_SHADOW)
{
// Special case due to being texture dependent and part of skips
is_texture = false;
if (!injection->mBlendIn)
mix = 1.0 - mix;
stringset_t dummy;
LLUUID cloud_noise_id = getCloudNoiseTextureId();
F64 value = this->mSettings[injection->mKeyName].asReal();
if (this->getCloudNoiseTextureId().isNull())
{
value = 0; // there was no texture so start from zero coverage
}
// Ideally we need to check for texture in injection, but
// in this case user is setting value explicitly, potentially
// with different transitions, don't ignore it
F64 result = lerp(value, injection->mValue.asReal(), mix);
injection->mLastValue = LLSD::Real(result);
this->mSettings[injection->mKeyName] = injection->mLastValue;
}
// Unfortunately I don't have a per texture blend factor. We'll just pick the one that is furthest along.
if (getBlendFactor() < mix)
if (is_texture && getBlendFactor() < mix)
{
setBlendFactor(mix);
}

View File

@ -1748,10 +1748,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)
@ -1759,19 +1770,40 @@ void LLViewerFetchedTexture::scheduleCreateTexture()
mainq->postTo(
mImageQueue,
// work to be done on LLImageGL worker thread
#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]()
{
#if LL_IMAGEGL_THREAD_CHECK
mGLTexturep->mActiveThread = LLThread::currentID();
#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();

View File

@ -2202,15 +2202,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();
}