Commit e053ddf7 authored by Rye Mutt's avatar Rye Mutt 🍞
Browse files

Fix refreshing ALRenderUtil state on GL buffer recreation

parent 8e5e60df
......@@ -60,9 +60,6 @@ ALRenderUtil::ALRenderUtil()
gSavedSettings.getControl("RenderToneMapLottesB")->getSignal()->connect(boost::bind(&ALRenderUtil::setupTonemap, this));
gSavedSettings.getControl("RenderToneMapUchimuraA")->getSignal()->connect(boost::bind(&ALRenderUtil::setupTonemap, this));
gSavedSettings.getControl("RenderToneMapUchimuraB")->getSignal()->connect(boost::bind(&ALRenderUtil::setupTonemap, this));
// Shader setup
refreshState();
}
void ALRenderUtil::restoreVertexBuffers()
......@@ -218,108 +215,111 @@ bool ALRenderUtil::setupColorGrade()
mCGLut = 0;
}
std::string lut_name = gSavedSettings.getString("RenderColorGradeLUT");
if (!lut_name.empty())
if (LLPipeline::sRenderDeferred)
{
enum class ELutExt
std::string lut_name = gSavedSettings.getString("RenderColorGradeLUT");
if (!lut_name.empty())
{
EXT_IMG_TGA = 0,
EXT_IMG_PNG,
EXT_IMG_WEBP,
EXT_NONE
};
std::string lut_path = gDirUtilp->getExpandedFilename(LL_PATH_APP_SETTINGS, "colorlut", lut_name);
if (!lut_path.empty())
{
std::string temp_exten = gDirUtilp->getExtension(lut_path);
ELutExt extension = ELutExt::EXT_NONE;
if (temp_exten == "tga")
enum class ELutExt
{
extension = ELutExt::EXT_IMG_TGA;
}
else if (temp_exten == "png")
{
extension = ELutExt::EXT_IMG_PNG;
}
else if (temp_exten == "webp")
EXT_IMG_TGA = 0,
EXT_IMG_PNG,
EXT_IMG_WEBP,
EXT_NONE
};
std::string lut_path = gDirUtilp->getExpandedFilename(LL_PATH_APP_SETTINGS, "colorlut", lut_name);
if (!lut_path.empty())
{
extension = ELutExt::EXT_IMG_WEBP;
}
LLPointer<LLImageRaw> raw_image = new LLImageRaw;
bool decode_success = false;
std::string temp_exten = gDirUtilp->getExtension(lut_path);
switch (extension)
{
default:
break;
case ELutExt::EXT_IMG_TGA:
{
LLPointer<LLImageTGA> tga_image = new LLImageTGA;
if (tga_image->load(lut_path) && tga_image->decode(raw_image, 0.0f))
ELutExt extension = ELutExt::EXT_NONE;
if (temp_exten == "tga")
{
decode_success = true;
extension = ELutExt::EXT_IMG_TGA;
}
break;
}
case ELutExt::EXT_IMG_PNG:
{
LLPointer<LLImagePNG> png_image = new LLImagePNG;
if (png_image->load(lut_path) && png_image->decode(raw_image, 0.0f))
else if (temp_exten == "png")
{
decode_success = true;
extension = ELutExt::EXT_IMG_PNG;
}
break;
}
case ELutExt::EXT_IMG_WEBP:
{
LLPointer<LLImageWebP> webp_image = new LLImageWebP;
if (webp_image->load(lut_path) && webp_image->decode(raw_image, 0.0f))
else if (temp_exten == "webp")
{
decode_success = true;
extension = ELutExt::EXT_IMG_WEBP;
}
break;
}
}
if(decode_success)
{
U32 primary_format = 0;
U32 int_format = 0;
switch (raw_image->getComponents())
LLPointer<LLImageRaw> raw_image = new LLImageRaw;
bool decode_success = false;
switch (extension)
{
case 3:
default:
break;
case ELutExt::EXT_IMG_TGA:
{
primary_format = GL_RGB;
int_format = GL_RGB8;
LLPointer<LLImageTGA> tga_image = new LLImageTGA;
if (tga_image->load(lut_path) && tga_image->decode(raw_image, 0.0f))
{
decode_success = true;
}
break;
}
case 4:
case ELutExt::EXT_IMG_PNG:
{
primary_format = GL_RGBA;
int_format = GL_RGBA8;
LLPointer<LLImagePNG> png_image = new LLImagePNG;
if (png_image->load(lut_path) && png_image->decode(raw_image, 0.0f))
{
decode_success = true;
}
break;
}
default:
return true;
};
S32 image_height = raw_image->getHeight();
S32 image_width = raw_image->getWidth();
if ((image_height > 0 && image_height <= 64) // within dimension limit
&& !(image_height & (image_height - 1)) // height is power of 2
&& ((image_height * image_height) == image_width)) // width is height * height
case ELutExt::EXT_IMG_WEBP:
{
LLPointer<LLImageWebP> webp_image = new LLImageWebP;
if (webp_image->load(lut_path) && webp_image->decode(raw_image, 0.0f))
{
decode_success = true;
}
break;
}
}
if (decode_success)
{
mCGLutSize = LLVector4(1.f / image_width, 1.f / image_height, (F32)image_width, (F32)image_height);
LLImageGL::generateTextures(1, &mCGLut);
gGL.getTexUnit(0)->bindManual(LLTexUnit::TT_TEXTURE, mCGLut);
LLImageGL::setManualImage(LLTexUnit::getInternalType(LLTexUnit::TT_TEXTURE), 0, int_format, image_width,
image_height, primary_format, GL_UNSIGNED_BYTE, raw_image->getData(), false);
stop_glerror();
gGL.getTexUnit(0)->setTextureFilteringOption(LLTexUnit::TFO_BILINEAR);
gGL.getTexUnit(0)->setTextureAddressMode(LLTexUnit::TAM_CLAMP);
U32 primary_format = 0;
U32 int_format = 0;
switch (raw_image->getComponents())
{
case 3:
{
primary_format = GL_RGB;
int_format = GL_RGB8;
break;
}
case 4:
{
primary_format = GL_RGBA;
int_format = GL_RGBA8;
break;
}
default:
return true;
};
S32 image_height = raw_image->getHeight();
S32 image_width = raw_image->getWidth();
if ((image_height > 0 && image_height <= 64) // within dimension limit
&& !(image_height & (image_height - 1)) // height is power of 2
&& ((image_height * image_height) == image_width)) // width is height * height
{
mCGLutSize = LLVector4(1.f / image_width, 1.f / image_height, (F32)image_width, (F32)image_height);
LLImageGL::generateTextures(1, &mCGLut);
gGL.getTexUnit(0)->bindManual(LLTexUnit::TT_TEXTURE, mCGLut);
LLImageGL::setManualImage(LLTexUnit::getInternalType(LLTexUnit::TT_TEXTURE), 0, int_format, image_width,
image_height, primary_format, GL_UNSIGNED_BYTE, raw_image->getData(), false);
stop_glerror();
gGL.getTexUnit(0)->setTextureFilteringOption(LLTexUnit::TFO_BILINEAR);
gGL.getTexUnit(0)->setTextureAddressMode(LLTexUnit::TAM_CLAMP);
}
}
}
}
......
......@@ -1146,11 +1146,6 @@ void LLPipeline::updateRenderDeferred()
LLPipeline::sUseDepthTexture = true;
}
// [/RLVa:KB]
if (gPipeline.mALRenderUtil)
{
gPipeline.mALRenderUtil->refreshState();
}
}
// static
......@@ -1396,6 +1391,8 @@ void LLPipeline::createGLBuffers()
allocateScreenBuffer(resX, resY);
mALRenderUtil->refreshState();
if (sRenderDeferred)
{
if (!mNoiseMap)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment