From 421e52ff98b67398843482713d754678a7153f50 Mon Sep 17 00:00:00 2001 From: Dave Parks Date: Sat, 17 Sep 2011 02:36:43 -0500 Subject: SH-2243 work in progress -- gDEBugger guided removal of deprecated state changes --- indra/llrender/llimagegl.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'indra/llrender/llimagegl.cpp') diff --git a/indra/llrender/llimagegl.cpp b/indra/llrender/llimagegl.cpp index 7188b0fa44..128773df5a 100644 --- a/indra/llrender/llimagegl.cpp +++ b/indra/llrender/llimagegl.cpp @@ -36,7 +36,9 @@ #include "llmath.h" #include "llgl.h" +#include "llglslshader.h" #include "llrender.h" + //---------------------------------------------------------------------------- const F32 MIN_TEXTURE_LIFETIME = 10.f; @@ -723,7 +725,7 @@ void LLImageGL::setImage(const U8* data_in, BOOL data_hasmips) } else if (!is_compressed) { - if (mAutoGenMips) + if (mAutoGenMips && !LLGLSLShader::sNoFixedFunction) //auto-generating mipmaps is deprecated in GL 3.0 { glTexParameteri(LLTexUnit::getInternalType(mBindTarget), GL_GENERATE_MIPMAP_SGIS, TRUE); stop_glerror(); -- cgit v1.2.3 From 861b7eba60ab71c5f9c68e46e207d8767d3e07f7 Mon Sep 17 00:00:00 2001 From: Dave Parks Date: Sat, 17 Sep 2011 19:02:21 -0500 Subject: SH-2243 fix for mac build --- indra/llrender/llimagegl.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'indra/llrender/llimagegl.cpp') diff --git a/indra/llrender/llimagegl.cpp b/indra/llrender/llimagegl.cpp index 128773df5a..0fb4a7784a 100644 --- a/indra/llrender/llimagegl.cpp +++ b/indra/llrender/llimagegl.cpp @@ -725,7 +725,7 @@ void LLImageGL::setImage(const U8* data_in, BOOL data_hasmips) } else if (!is_compressed) { - if (mAutoGenMips && !LLGLSLShader::sNoFixedFunction) //auto-generating mipmaps is deprecated in GL 3.0 + if (mAutoGenMips) //auto-generating mipmaps is deprecated in GL 3.0 { glTexParameteri(LLTexUnit::getInternalType(mBindTarget), GL_GENERATE_MIPMAP_SGIS, TRUE); stop_glerror(); -- cgit v1.2.3 From a2d08a6d80c4be7456d30f728da1838e63eb397f Mon Sep 17 00:00:00 2001 From: Dave Parks Date: Thu, 22 Sep 2011 00:10:57 -0500 Subject: SH-2244 Fix "RenderGLCoreProfile" actually make a core profile context and modify viewer to run under said context without generating errors. --- indra/llrender/llimagegl.cpp | 99 ++++++++++++++++++++++++++++++++++++++------ 1 file changed, 87 insertions(+), 12 deletions(-) (limited to 'indra/llrender/llimagegl.cpp') diff --git a/indra/llrender/llimagegl.cpp b/indra/llrender/llimagegl.cpp index 0fb4a7784a..4da796dd1e 100644 --- a/indra/llrender/llimagegl.cpp +++ b/indra/llrender/llimagegl.cpp @@ -725,7 +725,7 @@ void LLImageGL::setImage(const U8* data_in, BOOL data_hasmips) } else if (!is_compressed) { - if (mAutoGenMips) //auto-generating mipmaps is deprecated in GL 3.0 + if (mAutoGenMips && !LLRender::sGLCoreProfile) //auto-generating mipmaps is deprecated in GL 3.0 { glTexParameteri(LLTexUnit::getInternalType(mBindTarget), GL_GENERATE_MIPMAP_SGIS, TRUE); stop_glerror(); @@ -877,6 +877,9 @@ void LLImageGL::setImage(const U8* data_in, BOOL data_hasmips) BOOL LLImageGL::preAddToAtlas(S32 discard_level, const LLImageRaw* raw_image) { + //not compatible with core GL profile + llassert(!LLRender::sGLCoreProfile); + if (gGLManager.mIsDisabled) { llwarns << "Trying to create a texture while GL is disabled!" << llendl; @@ -903,29 +906,29 @@ BOOL LLImageGL::preAddToAtlas(S32 discard_level, const LLImageRaw* raw_image) { switch (mComponents) { - case 1: + case 1: // Use luminance alpha (for fonts) mFormatInternal = GL_LUMINANCE8; mFormatPrimary = GL_LUMINANCE; mFormatType = GL_UNSIGNED_BYTE; break; - case 2: + case 2: // Use luminance alpha (for fonts) mFormatInternal = GL_LUMINANCE8_ALPHA8; mFormatPrimary = GL_LUMINANCE_ALPHA; mFormatType = GL_UNSIGNED_BYTE; break; - case 3: + case 3: mFormatInternal = GL_RGB8; mFormatPrimary = GL_RGB; mFormatType = GL_UNSIGNED_BYTE; break; - case 4: + case 4: mFormatInternal = GL_RGBA8; mFormatPrimary = GL_RGBA; mFormatType = GL_UNSIGNED_BYTE; break; - default: + default: llerrs << "Bad number of components for texture: " << (U32)getComponents() << llendl; } } @@ -1101,8 +1104,76 @@ void LLImageGL::deleteTextures(S32 numTextures, U32 *textures, bool immediate) // static void LLImageGL::setManualImage(U32 target, S32 miplevel, S32 intformat, S32 width, S32 height, U32 pixformat, U32 pixtype, const void *pixels) { - glTexImage2D(target, miplevel, intformat, width, height, 0, pixformat, pixtype, pixels); + bool use_scratch = false; + U32* scratch = NULL; + if (LLRender::sGLCoreProfile) + { + if (intformat == GL_ALPHA8 && pixformat == GL_ALPHA && pixtype == GL_UNSIGNED_BYTE) + { //GL_ALPHA is deprecated, convert to RGBA + use_scratch = true; + scratch = new U32[width*height]; + + U32 pixel_count = (U32) (width*height); + for (U32 i = 0; i < pixel_count; i++) + { + U8* pix = (U8*) &scratch[i]; + pix[0] = pix[1] = pix[2] = 0; + pix[3] = ((U8*) pixels)[i]; + } + + pixformat = GL_RGBA; + intformat = GL_RGBA8; + } + + if (intformat == GL_LUMINANCE8_ALPHA8 && pixformat == GL_LUMINANCE_ALPHA && pixtype == GL_UNSIGNED_BYTE) + { //GL_LUMINANCE_ALPHA is deprecated, convert to RGBA + use_scratch = true; + scratch = new U32[width*height]; + + U32 pixel_count = (U32) (width*height); + for (U32 i = 0; i < pixel_count; i++) + { + U8 lum = ((U8*) pixels)[i*2+0]; + U8 alpha = ((U8*) pixels)[i*2+1]; + + U8* pix = (U8*) &scratch[i]; + pix[0] = pix[1] = pix[2] = lum; + pix[3] = alpha; + } + + pixformat = GL_RGBA; + intformat = GL_RGBA8; + } + + if (intformat == GL_LUMINANCE8 && pixformat == GL_LUMINANCE && pixtype == GL_UNSIGNED_BYTE) + { //GL_LUMINANCE_ALPHA is deprecated, convert to RGB + use_scratch = true; + scratch = new U32[width*height]; + + U32 pixel_count = (U32) (width*height); + for (U32 i = 0; i < pixel_count; i++) + { + U8 lum = ((U8*) pixels)[i*2+0]; + U8 alpha = ((U8*) pixels)[i*2+1]; + + U8* pix = (U8*) &scratch[i]; + pix[0] = pix[1] = pix[2] = lum; + pix[3] = 255; + } + + pixformat = GL_RGBA; + intformat = GL_RGB8; + } + } + + stop_glerror(); + glTexImage2D(target, miplevel, intformat, width, height, 0, pixformat, pixtype, use_scratch ? scratch : pixels); stop_glerror(); + + if (use_scratch) + { + delete [] scratch; + } } //create an empty GL texture: just create a texture name @@ -1169,29 +1240,29 @@ BOOL LLImageGL::createGLTexture(S32 discard_level, const LLImageRaw* imageraw, S { switch (mComponents) { - case 1: + case 1: // Use luminance alpha (for fonts) mFormatInternal = GL_LUMINANCE8; mFormatPrimary = GL_LUMINANCE; mFormatType = GL_UNSIGNED_BYTE; break; - case 2: + case 2: // Use luminance alpha (for fonts) mFormatInternal = GL_LUMINANCE8_ALPHA8; mFormatPrimary = GL_LUMINANCE_ALPHA; mFormatType = GL_UNSIGNED_BYTE; break; - case 3: + case 3: mFormatInternal = GL_RGB8; mFormatPrimary = GL_RGB; mFormatType = GL_UNSIGNED_BYTE; break; - case 4: + case 4: mFormatInternal = GL_RGBA8; mFormatPrimary = GL_RGBA; mFormatType = GL_UNSIGNED_BYTE; break; - default: + default: llerrs << "Bad number of components for texture: " << (U32)getComponents() << llendl; } @@ -1214,6 +1285,7 @@ BOOL LLImageGL::createGLTexture(S32 discard_level, const LLImageRaw* imageraw, S BOOL LLImageGL::createGLTexture(S32 discard_level, const U8* data_in, BOOL data_hasmips, S32 usename) { llassert(data_in); + stop_glerror(); if (discard_level < 0) { @@ -1242,8 +1314,11 @@ BOOL LLImageGL::createGLTexture(S32 discard_level, const U8* data_in, BOOL data_ stop_glerror(); { llverify(gGL.getTexUnit(0)->bind(this)); + stop_glerror(); glTexParameteri(LLTexUnit::getInternalType(mBindTarget), GL_TEXTURE_BASE_LEVEL, 0); + stop_glerror(); glTexParameteri(LLTexUnit::getInternalType(mBindTarget), GL_TEXTURE_MAX_LEVEL, mMaxDiscardLevel-discard_level); + stop_glerror(); } } if (!mTexName) -- cgit v1.2.3 From 57620a9da903f3c6fe482627d18c44b6411e6910 Mon Sep 17 00:00:00 2001 From: Dave Parks Date: Fri, 23 Sep 2011 17:59:05 -0500 Subject: SH-2244 Vertex buffer cleanup, fix for bad vertices in rigged attachments, added "RenderUseVAO" debug setting to control whether or not to use VAO's in non-core GL profiles. --- indra/llrender/llimagegl.cpp | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'indra/llrender/llimagegl.cpp') diff --git a/indra/llrender/llimagegl.cpp b/indra/llrender/llimagegl.cpp index 4da796dd1e..12089e5ad3 100644 --- a/indra/llrender/llimagegl.cpp +++ b/indra/llrender/llimagegl.cpp @@ -1153,9 +1153,8 @@ void LLImageGL::setManualImage(U32 target, S32 miplevel, S32 intformat, S32 widt U32 pixel_count = (U32) (width*height); for (U32 i = 0; i < pixel_count; i++) { - U8 lum = ((U8*) pixels)[i*2+0]; - U8 alpha = ((U8*) pixels)[i*2+1]; - + U8 lum = ((U8*) pixels)[i]; + U8* pix = (U8*) &scratch[i]; pix[0] = pix[1] = pix[2] = lum; pix[3] = 255; -- cgit v1.2.3 From 54ba56dbe995a3d215f85932c83948145a871ac4 Mon Sep 17 00:00:00 2001 From: Dave Parks Date: Mon, 26 Sep 2011 18:31:55 -0500 Subject: SH-2244 changes to run in a core context on AMD hardware without generating deprecation or performance warnings --- indra/llrender/llimagegl.cpp | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) (limited to 'indra/llrender/llimagegl.cpp') diff --git a/indra/llrender/llimagegl.cpp b/indra/llrender/llimagegl.cpp index 12089e5ad3..cbdb8f83f6 100644 --- a/indra/llrender/llimagegl.cpp +++ b/indra/llrender/llimagegl.cpp @@ -725,9 +725,12 @@ void LLImageGL::setImage(const U8* data_in, BOOL data_hasmips) } else if (!is_compressed) { - if (mAutoGenMips && !LLRender::sGLCoreProfile) //auto-generating mipmaps is deprecated in GL 3.0 + if (mAutoGenMips) { - glTexParameteri(LLTexUnit::getInternalType(mBindTarget), GL_GENERATE_MIPMAP_SGIS, TRUE); + if (!glGenerateMipmap) + { + glTexParameteri(LLTexUnit::getInternalType(mBindTarget), GL_GENERATE_MIPMAP_SGIS, TRUE); + } stop_glerror(); { // LLFastTimer t2(FTM_TEMP4); @@ -756,6 +759,11 @@ void LLImageGL::setImage(const U8* data_in, BOOL data_hasmips) stop_glerror(); } } + + if (glGenerateMipmap) + { + glGenerateMipmap(LLTexUnit::getInternalType(mBindTarget)); + } } else { -- cgit v1.2.3 From 872567c0c1a58272b276303c881585acf9ba9ac0 Mon Sep 17 00:00:00 2001 From: Dave Parks Date: Wed, 28 Sep 2011 16:51:23 -0500 Subject: SH-2244 Fix for mac build? --- indra/llrender/llimagegl.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'indra/llrender/llimagegl.cpp') diff --git a/indra/llrender/llimagegl.cpp b/indra/llrender/llimagegl.cpp index cbdb8f83f6..3d3c94ef3e 100644 --- a/indra/llrender/llimagegl.cpp +++ b/indra/llrender/llimagegl.cpp @@ -727,7 +727,7 @@ void LLImageGL::setImage(const U8* data_in, BOOL data_hasmips) { if (mAutoGenMips) { - if (!glGenerateMipmap) + if (!gGLManager.mHasFramebufferObject) { glTexParameteri(LLTexUnit::getInternalType(mBindTarget), GL_GENERATE_MIPMAP_SGIS, TRUE); } @@ -760,7 +760,7 @@ void LLImageGL::setImage(const U8* data_in, BOOL data_hasmips) } } - if (glGenerateMipmap) + if (gGLManager.mHasFramebufferObject) { glGenerateMipmap(LLTexUnit::getInternalType(mBindTarget)); } -- cgit v1.2.3 From fa5a0a90f451c0be63bda4a6a61350c2edc639d8 Mon Sep 17 00:00:00 2001 From: Dave Parks Date: Thu, 3 Nov 2011 15:00:40 -0500 Subject: SH-2240 Fix for core profile assertions when Debug GL enabled. --- indra/llrender/llimagegl.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'indra/llrender/llimagegl.cpp') diff --git a/indra/llrender/llimagegl.cpp b/indra/llrender/llimagegl.cpp index 3d3c94ef3e..7d73888151 100644 --- a/indra/llrender/llimagegl.cpp +++ b/indra/llrender/llimagegl.cpp @@ -1116,7 +1116,7 @@ void LLImageGL::setManualImage(U32 target, S32 miplevel, S32 intformat, S32 widt U32* scratch = NULL; if (LLRender::sGLCoreProfile) { - if (intformat == GL_ALPHA8 && pixformat == GL_ALPHA && pixtype == GL_UNSIGNED_BYTE) + if (pixformat == GL_ALPHA && pixtype == GL_UNSIGNED_BYTE) { //GL_ALPHA is deprecated, convert to RGBA use_scratch = true; scratch = new U32[width*height]; @@ -1133,7 +1133,7 @@ void LLImageGL::setManualImage(U32 target, S32 miplevel, S32 intformat, S32 widt intformat = GL_RGBA8; } - if (intformat == GL_LUMINANCE8_ALPHA8 && pixformat == GL_LUMINANCE_ALPHA && pixtype == GL_UNSIGNED_BYTE) + if (pixformat == GL_LUMINANCE_ALPHA && pixtype == GL_UNSIGNED_BYTE) { //GL_LUMINANCE_ALPHA is deprecated, convert to RGBA use_scratch = true; scratch = new U32[width*height]; @@ -1153,7 +1153,7 @@ void LLImageGL::setManualImage(U32 target, S32 miplevel, S32 intformat, S32 widt intformat = GL_RGBA8; } - if (intformat == GL_LUMINANCE8 && pixformat == GL_LUMINANCE && pixtype == GL_UNSIGNED_BYTE) + if (pixformat == GL_LUMINANCE && pixtype == GL_UNSIGNED_BYTE) { //GL_LUMINANCE_ALPHA is deprecated, convert to RGB use_scratch = true; scratch = new U32[width*height]; -- cgit v1.2.3 From 73d70b5d4562cf00f810446479918e64cbcb6008 Mon Sep 17 00:00:00 2001 From: Dave Parks Date: Tue, 15 Nov 2011 12:19:05 -0600 Subject: SH-2240 Make alpha mask cutoff a little less aggressive (err on the side of not creating an alpha mask) --- indra/llrender/llimagegl.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'indra/llrender/llimagegl.cpp') diff --git a/indra/llrender/llimagegl.cpp b/indra/llrender/llimagegl.cpp index 7d73888151..789402c4a9 100644 --- a/indra/llrender/llimagegl.cpp +++ b/indra/llrender/llimagegl.cpp @@ -1853,7 +1853,7 @@ void LLImageGL::analyzeAlpha(const void* data_in, U32 w, U32 h) upperhalftotal += sample[i]; } - if (midrangetotal > length/16 || // lots of midrange, or + if (midrangetotal > length/48 || // lots of midrange, or (lowerhalftotal == length && alphatotal != 0) || // all close to transparent but not all totally transparent, or (upperhalftotal == length && alphatotal != 255*length)) // all close to opaque but not all totally opaque { -- cgit v1.2.3 From dbef1616dc22ba8623a53f7d4d4daeabaeafa78a Mon Sep 17 00:00:00 2001 From: Dave Parks Date: Wed, 16 Nov 2011 12:40:51 -0600 Subject: SH-2240 Make alpha mask cutoff even less aggressive (fix for eyes on Curious Ringtail avatar) --- indra/llrender/llimagegl.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'indra/llrender/llimagegl.cpp') diff --git a/indra/llrender/llimagegl.cpp b/indra/llrender/llimagegl.cpp index 789402c4a9..78591ddd38 100644 --- a/indra/llrender/llimagegl.cpp +++ b/indra/llrender/llimagegl.cpp @@ -1838,7 +1838,7 @@ void LLImageGL::analyzeAlpha(const void* data_in, U32 w, U32 h) // this to be an intentional effect and don't treat as a mask. U32 midrangetotal = 0; - for (U32 i = 4; i < 11; i++) + for (U32 i = 2; i < 13; i++) { midrangetotal += sample[i]; } -- cgit v1.2.3