From c4e21cf2828517e761657eb70bf516d84f17fc77 Mon Sep 17 00:00:00 2001 From: Nicky Date: Sun, 24 Apr 2016 12:55:13 +0200 Subject: Fix a crash is drawn vertices is 0. (transplanted from 89b3e585218ddb8d6a3e62af29f8daf889371e5e) --- indra/llrender/llrender.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'indra/llrender') diff --git a/indra/llrender/llrender.cpp b/indra/llrender/llrender.cpp index 69420dd0bb..0e242a20f6 100644 --- a/indra/llrender/llrender.cpp +++ b/indra/llrender/llrender.cpp @@ -2039,7 +2039,8 @@ void LLRender::vertexBatchPreTransformed(LLVector3* verts, S32 vert_count) } } - mVerticesp[mCount] = mVerticesp[mCount-1]; + if( mCount > 0 ) // ND: Guard against crashes if mCount is zero, yes it can happen + mVerticesp[mCount] = mVerticesp[mCount-1]; } void LLRender::vertexBatchPreTransformed(LLVector3* verts, LLVector2* uvs, S32 vert_count) -- cgit v1.2.3 From 067468885a189bb26b465dbff2358de81cc6e392 Mon Sep 17 00:00:00 2001 From: Callum Prentice Date: Thu, 15 Dec 2016 10:58:23 -0800 Subject: BUG-41027 (FIX) Changing login location at the login screen crashes the viewer --- indra/llrender/llrender.cpp | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'indra/llrender') diff --git a/indra/llrender/llrender.cpp b/indra/llrender/llrender.cpp index 0e242a20f6..98d3ab8435 100644 --- a/indra/llrender/llrender.cpp +++ b/indra/llrender/llrender.cpp @@ -2156,9 +2156,12 @@ void LLRender::vertexBatchPreTransformed(LLVector3* verts, LLVector2* uvs, LLCol } } - mVerticesp[mCount] = mVerticesp[mCount-1]; - mTexcoordsp[mCount] = mTexcoordsp[mCount-1]; - mColorsp[mCount] = mColorsp[mCount-1]; + if (mCount > 0) + { + mVerticesp[mCount] = mVerticesp[mCount - 1]; + mTexcoordsp[mCount] = mTexcoordsp[mCount - 1]; + mColorsp[mCount] = mColorsp[mCount - 1]; + } } void LLRender::vertex2i(const GLint& x, const GLint& y) -- cgit v1.2.3 From 93268cb47a69b8432068c0922feedc01c96ae975 Mon Sep 17 00:00:00 2001 From: Nat Goodspeed Date: Fri, 16 Dec 2016 17:03:45 -0500 Subject: DRTVWR-418: Put TYPE_INDEX within TYPE_MAX: stop undefined indexing. LLVertexBuffer::TYPE_INDEX was past TYPE_MAX, which is used to set the maximum sizes of various (scattered) arrays, bleh. The alarm bells that this SHOULD set off are indeed correct: TYPE_INDEX was being used to index at least one of those arrays, meaning we've been indexing past the end of that array, meaning undefined behavior. The enum that defines both TYPE_INDEX and TYPE_MAX provides a helpful comment indicating what things must be updated when modifying the enum. (Far better to define things centrally in a single place... but another time.) Update the designated arrays to include a final TYPE_INDEX entry. Contents of those entries are wild guesses -- but even wild guesses are better than completely indeterminate data. --- indra/llrender/llshadermgr.cpp | 3 ++- indra/llrender/llvertexbuffer.cpp | 7 ++++++- indra/llrender/llvertexbuffer.h | 2 +- 3 files changed, 9 insertions(+), 3 deletions(-) (limited to 'indra/llrender') diff --git a/indra/llrender/llshadermgr.cpp b/indra/llrender/llshadermgr.cpp index 55f0791174..0a479feccc 100644 --- a/indra/llrender/llshadermgr.cpp +++ b/indra/llrender/llshadermgr.cpp @@ -986,7 +986,8 @@ void LLShaderMgr::initAttribsAndUniforms() mReservedAttribs.push_back("weight4"); mReservedAttribs.push_back("clothing"); mReservedAttribs.push_back("texture_index"); - + mReservedAttribs.push_back("index"); + //matrix state mReservedUniforms.push_back("modelview_matrix"); mReservedUniforms.push_back("projection_matrix"); diff --git a/indra/llrender/llvertexbuffer.cpp b/indra/llrender/llvertexbuffer.cpp index 0fae600a90..59024b7730 100644 --- a/indra/llrender/llvertexbuffer.cpp +++ b/indra/llrender/llvertexbuffer.cpp @@ -339,6 +339,7 @@ S32 LLVertexBuffer::sTypeSize[LLVertexBuffer::TYPE_MAX] = sizeof(LLVector4), // TYPE_WEIGHT4, sizeof(LLVector4), // TYPE_CLOTHWEIGHT, sizeof(LLVector4), // TYPE_TEXTURE_INDEX (actually exists as position.w), no extra data, but stride is 16 bytes + sizeof(U16), // TYPE_INDEX }; static std::string vb_type_name[] = @@ -356,8 +357,8 @@ static std::string vb_type_name[] = "TYPE_WEIGHT4", "TYPE_CLOTHWEIGHT", "TYPE_TEXTURE_INDEX", + "TYPE_INDEX", "TYPE_MAX", - "TYPE_INDEX", }; U32 LLVertexBuffer::sGLMode[LLRender::NUM_MODES] = @@ -1368,6 +1369,7 @@ void LLVertexBuffer::setupVertexArray() 4, //TYPE_WEIGHT4, 4, //TYPE_CLOTHWEIGHT, 1, //TYPE_TEXTURE_INDEX + 1, //TYPE_INDEX }; U32 attrib_type[] = @@ -1385,6 +1387,7 @@ void LLVertexBuffer::setupVertexArray() GL_FLOAT, //TYPE_WEIGHT4, GL_FLOAT, //TYPE_CLOTHWEIGHT, GL_UNSIGNED_INT, //TYPE_TEXTURE_INDEX + GL_UNSIGNED_INT, //TYPE_INDEX }; bool attrib_integer[] = @@ -1402,6 +1405,7 @@ void LLVertexBuffer::setupVertexArray() false, //TYPE_WEIGHT4, false, //TYPE_CLOTHWEIGHT, true, //TYPE_TEXTURE_INDEX + true, //TYPE_INDEX }; U32 attrib_normalized[] = @@ -1419,6 +1423,7 @@ void LLVertexBuffer::setupVertexArray() GL_FALSE, //TYPE_WEIGHT4, GL_FALSE, //TYPE_CLOTHWEIGHT, GL_FALSE, //TYPE_TEXTURE_INDEX + GL_FALSE, //TYPE_INDEX }; bindGLBuffer(true); diff --git a/indra/llrender/llvertexbuffer.h b/indra/llrender/llvertexbuffer.h index c05fd01595..36038eee7b 100644 --- a/indra/llrender/llvertexbuffer.h +++ b/indra/llrender/llvertexbuffer.h @@ -179,8 +179,8 @@ public: TYPE_WEIGHT4, TYPE_CLOTHWEIGHT, TYPE_TEXTURE_INDEX, + TYPE_INDEX, TYPE_MAX, - TYPE_INDEX, }; enum { MAP_VERTEX = (1< Date: Fri, 16 Dec 2016 19:08:24 -0500 Subject: DRTVWR-418: Work around dubious cast from S32 to GLvoid* when passing -- something -- to glVertexAttribPointerARB() in LLVertexBuffer::setupVertexArray(). --- indra/llrender/llvertexbuffer.cpp | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) (limited to 'indra/llrender') diff --git a/indra/llrender/llvertexbuffer.cpp b/indra/llrender/llvertexbuffer.cpp index 59024b7730..b6fae1ad26 100644 --- a/indra/llrender/llvertexbuffer.cpp +++ b/indra/llrender/llvertexbuffer.cpp @@ -1441,13 +1441,24 @@ void LLVertexBuffer::setupVertexArray() //glVertexattribIPointer requires GLSL 1.30 or later if (gGLManager.mGLSLVersionMajor > 1 || gGLManager.mGLSLVersionMinor >= 30) { - glVertexAttribIPointer(i, attrib_size[i], attrib_type[i], sTypeSize[i], (void*) mOffsets[i]); + glVertexAttribIPointer(i, attrib_size[i], attrib_type[i], sTypeSize[i], (const GLvoid*) mOffsets[i]); } #endif } else { - glVertexAttribPointerARB(i, attrib_size[i], attrib_type[i], attrib_normalized[i], sTypeSize[i], (void*) mOffsets[i]); + // nat 2016-12-16: With 64-bit clang compile, the compiler + // produces an error if we simply cast mOffsets[i] -- an S32 + // -- to (GLvoid *), the type of the parameter. It correctly + // points out that there's no way an S32 could fit a real + // pointer value. Since I do not know what we're trying to + // achieve here, I'm going to grit my teeth and try to + // persuade the compiler we know what we're doing, until + // someone who actually does know fixes it better. + uintptr_t fake_offset(mOffsets[i]); + glVertexAttribPointerARB(i, attrib_size[i], attrib_type[i], + attrib_normalized[i], sTypeSize[i], + reinterpret_cast(fake_offset)); } } else -- cgit v1.2.3 From 129896106638884ff41bdcd8441a5bcc221aa580 Mon Sep 17 00:00:00 2001 From: Nat Goodspeed Date: Sat, 17 Dec 2016 11:07:20 -0500 Subject: DRTVWR-418: Update dubious llvertexbuffer.cpp cast comment. Ruslan assures me that in fact this usage is valid. --- indra/llrender/llvertexbuffer.cpp | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) (limited to 'indra/llrender') diff --git a/indra/llrender/llvertexbuffer.cpp b/indra/llrender/llvertexbuffer.cpp index b6fae1ad26..8ec78f605b 100644 --- a/indra/llrender/llvertexbuffer.cpp +++ b/indra/llrender/llvertexbuffer.cpp @@ -1451,14 +1451,12 @@ void LLVertexBuffer::setupVertexArray() // produces an error if we simply cast mOffsets[i] -- an S32 // -- to (GLvoid *), the type of the parameter. It correctly // points out that there's no way an S32 could fit a real - // pointer value. Since I do not know what we're trying to - // achieve here, I'm going to grit my teeth and try to - // persuade the compiler we know what we're doing, until - // someone who actually does know fixes it better. - uintptr_t fake_offset(mOffsets[i]); + // pointer value. Ruslan asserts that in this case the last + // param is interpreted as an array data offset within the VBO + // rather than as an actual pointer, so it's okay. glVertexAttribPointerARB(i, attrib_size[i], attrib_type[i], attrib_normalized[i], sTypeSize[i], - reinterpret_cast(fake_offset)); + reinterpret_cast(mOffsets[i])); } } else -- cgit v1.2.3 From 4c95587dc3c0943d3cf455df6ecb5c7dcbf78738 Mon Sep 17 00:00:00 2001 From: Nat Goodspeed Date: Sat, 17 Dec 2016 11:09:09 -0500 Subject: Backed out changeset bb47510bda62: don't change TYPE_MAX. Ruslan points out that changing TYPE_MAX could lead to extra (useless) render passes. We will have to solve the TYPE_INDEX > TYPE_MAX problem another way. --- indra/llrender/llshadermgr.cpp | 3 +-- indra/llrender/llvertexbuffer.cpp | 7 +------ indra/llrender/llvertexbuffer.h | 2 +- 3 files changed, 3 insertions(+), 9 deletions(-) (limited to 'indra/llrender') diff --git a/indra/llrender/llshadermgr.cpp b/indra/llrender/llshadermgr.cpp index 0a479feccc..55f0791174 100644 --- a/indra/llrender/llshadermgr.cpp +++ b/indra/llrender/llshadermgr.cpp @@ -986,8 +986,7 @@ void LLShaderMgr::initAttribsAndUniforms() mReservedAttribs.push_back("weight4"); mReservedAttribs.push_back("clothing"); mReservedAttribs.push_back("texture_index"); - mReservedAttribs.push_back("index"); - + //matrix state mReservedUniforms.push_back("modelview_matrix"); mReservedUniforms.push_back("projection_matrix"); diff --git a/indra/llrender/llvertexbuffer.cpp b/indra/llrender/llvertexbuffer.cpp index 59024b7730..0fae600a90 100644 --- a/indra/llrender/llvertexbuffer.cpp +++ b/indra/llrender/llvertexbuffer.cpp @@ -339,7 +339,6 @@ S32 LLVertexBuffer::sTypeSize[LLVertexBuffer::TYPE_MAX] = sizeof(LLVector4), // TYPE_WEIGHT4, sizeof(LLVector4), // TYPE_CLOTHWEIGHT, sizeof(LLVector4), // TYPE_TEXTURE_INDEX (actually exists as position.w), no extra data, but stride is 16 bytes - sizeof(U16), // TYPE_INDEX }; static std::string vb_type_name[] = @@ -357,8 +356,8 @@ static std::string vb_type_name[] = "TYPE_WEIGHT4", "TYPE_CLOTHWEIGHT", "TYPE_TEXTURE_INDEX", - "TYPE_INDEX", "TYPE_MAX", + "TYPE_INDEX", }; U32 LLVertexBuffer::sGLMode[LLRender::NUM_MODES] = @@ -1369,7 +1368,6 @@ void LLVertexBuffer::setupVertexArray() 4, //TYPE_WEIGHT4, 4, //TYPE_CLOTHWEIGHT, 1, //TYPE_TEXTURE_INDEX - 1, //TYPE_INDEX }; U32 attrib_type[] = @@ -1387,7 +1385,6 @@ void LLVertexBuffer::setupVertexArray() GL_FLOAT, //TYPE_WEIGHT4, GL_FLOAT, //TYPE_CLOTHWEIGHT, GL_UNSIGNED_INT, //TYPE_TEXTURE_INDEX - GL_UNSIGNED_INT, //TYPE_INDEX }; bool attrib_integer[] = @@ -1405,7 +1402,6 @@ void LLVertexBuffer::setupVertexArray() false, //TYPE_WEIGHT4, false, //TYPE_CLOTHWEIGHT, true, //TYPE_TEXTURE_INDEX - true, //TYPE_INDEX }; U32 attrib_normalized[] = @@ -1423,7 +1419,6 @@ void LLVertexBuffer::setupVertexArray() GL_FALSE, //TYPE_WEIGHT4, GL_FALSE, //TYPE_CLOTHWEIGHT, GL_FALSE, //TYPE_TEXTURE_INDEX - GL_FALSE, //TYPE_INDEX }; bindGLBuffer(true); diff --git a/indra/llrender/llvertexbuffer.h b/indra/llrender/llvertexbuffer.h index 36038eee7b..c05fd01595 100644 --- a/indra/llrender/llvertexbuffer.h +++ b/indra/llrender/llvertexbuffer.h @@ -179,8 +179,8 @@ public: TYPE_WEIGHT4, TYPE_CLOTHWEIGHT, TYPE_TEXTURE_INDEX, - TYPE_INDEX, TYPE_MAX, + TYPE_INDEX, }; enum { MAP_VERTEX = (1< Date: Tue, 20 Dec 2016 14:41:46 -0500 Subject: move debugging globals to the "lowest" library they are referenced in --- indra/llrender/llgl.cpp | 1 - 1 file changed, 1 deletion(-) (limited to 'indra/llrender') diff --git a/indra/llrender/llgl.cpp b/indra/llrender/llgl.cpp index 7757198af5..18063e9700 100644 --- a/indra/llrender/llgl.cpp +++ b/indra/llrender/llgl.cpp @@ -55,7 +55,6 @@ BOOL gDebugSession = FALSE; -BOOL gDebugGL = FALSE; BOOL gClothRipple = FALSE; BOOL gHeadlessClient = FALSE; BOOL gGLActive = FALSE; -- cgit v1.2.3 From 7c5e92cec57f492c465ec075cd8297fb86aed3c5 Mon Sep 17 00:00:00 2001 From: Callum Prentice Date: Mon, 13 Mar 2017 11:13:43 -0700 Subject: SL-644 Add guard to mCount in LLRender.cpp --- indra/llrender/llrender.cpp | 49 +++++---------------------------------------- 1 file changed, 5 insertions(+), 44 deletions(-) (limited to 'indra/llrender') diff --git a/indra/llrender/llrender.cpp b/indra/llrender/llrender.cpp index 77c5921c9c..76f28bb43f 100644 --- a/indra/llrender/llrender.cpp +++ b/indra/llrender/llrender.cpp @@ -1829,48 +1829,6 @@ void LLRender::flush() { if (mCount > 0) { -#if 0 - if (!glIsEnabled(GL_VERTEX_ARRAY)) - { - LL_ERRS() << "foo 1" << LL_ENDL; - } - - if (!glIsEnabled(GL_COLOR_ARRAY)) - { - LL_ERRS() << "foo 2" << LL_ENDL; - } - - if (!glIsEnabled(GL_TEXTURE_COORD_ARRAY)) - { - LL_ERRS() << "foo 3" << LL_ENDL; - } - - if (glIsEnabled(GL_NORMAL_ARRAY)) - { - LL_ERRS() << "foo 7" << LL_ENDL; - } - - GLvoid* pointer; - - glGetPointerv(GL_VERTEX_ARRAY_POINTER, &pointer); - if (pointer != &(mBuffer[0].v)) - { - LL_ERRS() << "foo 4" << LL_ENDL; - } - - glGetPointerv(GL_COLOR_ARRAY_POINTER, &pointer); - if (pointer != &(mBuffer[0].c)) - { - LL_ERRS() << "foo 5" << LL_ENDL; - } - - glGetPointerv(GL_TEXTURE_COORD_ARRAY_POINTER, &pointer); - if (pointer != &(mBuffer[0].uv)) - { - LL_ERRS() << "foo 6" << LL_ENDL; - } -#endif - if (!mUIOffset.empty()) { sUICalls++; @@ -2104,8 +2062,11 @@ void LLRender::vertexBatchPreTransformed(LLVector3* verts, LLVector2* uvs, S32 v } } - mVerticesp[mCount] = mVerticesp[mCount-1]; - mTexcoordsp[mCount] = mTexcoordsp[mCount-1]; + if (mCount > 0) + { + mVerticesp[mCount] = mVerticesp[mCount - 1]; + mTexcoordsp[mCount] = mTexcoordsp[mCount - 1]; + } } void LLRender::vertexBatchPreTransformed(LLVector3* verts, LLVector2* uvs, LLColor4U* colors, S32 vert_count) -- cgit v1.2.3 From 46dc097516377889c217002e594189cc7107a686 Mon Sep 17 00:00:00 2001 From: ruslantproductengine Date: Thu, 14 Sep 2017 16:39:01 +0300 Subject: MAINT-7129 - [Project Alex Ivy][MAC] Materials and ALM shaders broken in Mac viewer FIXED --- indra/llrender/llshadermgr.cpp | 193 ++++++++++++++++++++++++++++------------- 1 file changed, 131 insertions(+), 62 deletions(-) (limited to 'indra/llrender') diff --git a/indra/llrender/llshadermgr.cpp b/indra/llrender/llshadermgr.cpp index 55f0791174..19a9ced321 100644 --- a/indra/llrender/llshadermgr.cpp +++ b/indra/llrender/llshadermgr.cpp @@ -575,10 +575,13 @@ GLhandleARB LLShaderMgr::loadShaderFile(const std::string& filename, S32 & shade //we can't have any lines longer than 1024 characters //or any shaders longer than 4096 lines... deal - DaveP - GLcharARB buff[1024]; - GLcharARB* text[4096]; - GLuint count = 0; - + GLcharARB buff[1024]; + GLcharARB *extra_code_text[1024]; + GLcharARB *shader_code_text[4096 + LL_ARRAY_SIZE(extra_code_text)] = { NULL }; + GLuint extra_code_count = 0, shader_code_count = 0; + BOOST_STATIC_ASSERT(LL_ARRAY_SIZE(extra_code_text) < LL_ARRAY_SIZE(shader_code_text)); + + S32 major_version = gGLManager.mGLSLVersionMajor; S32 minor_version = gGLManager.mGLSLVersionMinor; @@ -593,20 +596,20 @@ GLhandleARB LLShaderMgr::loadShaderFile(const std::string& filename, S32 & shade if (minor_version <= 19) { - text[count++] = strdup("#version 110\n"); - text[count++] = strdup("#define ATTRIBUTE attribute\n"); - text[count++] = strdup("#define VARYING varying\n"); - text[count++] = strdup("#define VARYING_FLAT varying\n"); + shader_code_text[shader_code_count++] = strdup("#version 110\n"); + extra_code_text[extra_code_count++] = strdup("#define ATTRIBUTE attribute\n"); + extra_code_text[extra_code_count++] = strdup("#define VARYING varying\n"); + extra_code_text[extra_code_count++] = strdup("#define VARYING_FLAT varying\n"); } else if (minor_version <= 29) { //set version to 1.20 - text[count++] = strdup("#version 120\n"); - text[count++] = strdup("#define FXAA_GLSL_120 1\n"); - text[count++] = strdup("#define FXAA_FAST_PIXEL_OFFSET 0\n"); - text[count++] = strdup("#define ATTRIBUTE attribute\n"); - text[count++] = strdup("#define VARYING varying\n"); - text[count++] = strdup("#define VARYING_FLAT varying\n"); + shader_code_text[shader_code_count++] = strdup("#version 120\n"); + extra_code_text[extra_code_count++] = strdup("#define FXAA_GLSL_120 1\n"); + extra_code_text[extra_code_count++] = strdup("#define FXAA_FAST_PIXEL_OFFSET 0\n"); + extra_code_text[extra_code_count++] = strdup("#define ATTRIBUTE attribute\n"); + extra_code_text[extra_code_count++] = strdup("#define VARYING varying\n"); + extra_code_text[extra_code_count++] = strdup("#define VARYING_FLAT varying\n"); } } else @@ -614,44 +617,43 @@ GLhandleARB LLShaderMgr::loadShaderFile(const std::string& filename, S32 & shade if (major_version < 4) { //set version to 1.30 - text[count++] = strdup("#version 130\n"); - + shader_code_text[shader_code_count++] = strdup("#version 130\n"); //some implementations of GLSL 1.30 require integer precision be explicitly declared - text[count++] = strdup("precision mediump int;\n"); - text[count++] = strdup("precision highp float;\n"); + extra_code_text[extra_code_count++] = strdup("precision mediump int;\n"); + extra_code_text[extra_code_count++] = strdup("precision highp float;\n"); } else { //set version to 400 - text[count++] = strdup("#version 400\n"); + shader_code_text[shader_code_count++] = strdup("#version 400\n"); } - text[count++] = strdup("#define DEFINE_GL_FRAGCOLOR 1\n"); - text[count++] = strdup("#define FXAA_GLSL_130 1\n"); + extra_code_text[extra_code_count++] = strdup("#define DEFINE_GL_FRAGCOLOR 1\n"); + extra_code_text[extra_code_count++] = strdup("#define FXAA_GLSL_130 1\n"); - text[count++] = strdup("#define ATTRIBUTE in\n"); + extra_code_text[extra_code_count++] = strdup("#define ATTRIBUTE in\n"); if (type == GL_VERTEX_SHADER_ARB) { //"varying" state is "out" in a vertex program, "in" in a fragment program // ("varying" is deprecated after version 1.20) - text[count++] = strdup("#define VARYING out\n"); - text[count++] = strdup("#define VARYING_FLAT flat out\n"); + extra_code_text[extra_code_count++] = strdup("#define VARYING out\n"); + extra_code_text[extra_code_count++] = strdup("#define VARYING_FLAT flat out\n"); } else { - text[count++] = strdup("#define VARYING in\n"); - text[count++] = strdup("#define VARYING_FLAT flat in\n"); + extra_code_text[extra_code_count++] = strdup("#define VARYING in\n"); + extra_code_text[extra_code_count++] = strdup("#define VARYING_FLAT flat in\n"); } //backwards compatibility with legacy texture lookup syntax - text[count++] = strdup("#define texture2D texture\n"); - text[count++] = strdup("#define textureCube texture\n"); - text[count++] = strdup("#define texture2DLod textureLod\n"); - text[count++] = strdup("#define shadow2D(a,b) vec2(texture(a,b))\n"); + extra_code_text[extra_code_count++] = strdup("#define texture2D texture\n"); + extra_code_text[extra_code_count++] = strdup("#define textureCube texture\n"); + extra_code_text[extra_code_count++] = strdup("#define texture2DLod textureLod\n"); + extra_code_text[extra_code_count++] = strdup("#define shadow2D(a,b) vec2(texture(a,b))\n"); if (major_version > 1 || minor_version >= 40) { //GLSL 1.40 replaces texture2DRect et al with texture - text[count++] = strdup("#define texture2DRect texture\n"); - text[count++] = strdup("#define shadow2DRect(a,b) vec2(texture(a,b))\n"); + extra_code_text[extra_code_count++] = strdup("#define texture2DRect texture\n"); + extra_code_text[extra_code_count++] = strdup("#define shadow2DRect(a,b) vec2(texture(a,b))\n"); } } @@ -660,13 +662,13 @@ GLhandleARB LLShaderMgr::loadShaderFile(const std::string& filename, S32 & shade for (boost::unordered_map::iterator iter = defines->begin(); iter != defines->end(); ++iter) { std::string define = "#define " + iter->first + " " + iter->second + "\n"; - text[count++] = (GLcharARB *) strdup(define.c_str()); + extra_code_text[extra_code_count++] = (GLcharARB *) strdup(define.c_str()); } } if( gGLManager.mIsATI ) { - text[ count++ ] = strdup( "#define IS_AMD_CARD 1\n" ); + extra_code_text[extra_code_count++] = strdup( "#define IS_AMD_CARD 1\n" ); } if (texture_index_channels > 0 && type == GL_FRAGMENT_SHADER_ARB) @@ -704,28 +706,28 @@ GLhandleARB LLShaderMgr::loadShaderFile(const std::string& filename, S32 & shade } */ - text[count++] = strdup("#define HAS_DIFFUSE_LOOKUP 1\n"); + extra_code_text[extra_code_count++] = strdup("#define HAS_DIFFUSE_LOOKUP 1\n"); //uniform declartion for (S32 i = 0; i < texture_index_channels; ++i) { std::string decl = llformat("uniform sampler2D tex%d;\n", i); - text[count++] = strdup(decl.c_str()); + extra_code_text[extra_code_count++] = strdup(decl.c_str()); } if (texture_index_channels > 1) { - text[count++] = strdup("VARYING_FLAT int vary_texture_index;\n"); + extra_code_text[extra_code_count++] = strdup("VARYING_FLAT int vary_texture_index;\n"); } - text[count++] = strdup("vec4 diffuseLookup(vec2 texcoord)\n"); - text[count++] = strdup("{\n"); + extra_code_text[extra_code_count++] = strdup("vec4 diffuseLookup(vec2 texcoord)\n"); + extra_code_text[extra_code_count++] = strdup("{\n"); if (texture_index_channels == 1) { //don't use flow control, that's silly - text[count++] = strdup("return texture2D(tex0, texcoord);\n"); - text[count++] = strdup("}\n"); + extra_code_text[extra_code_count++] = strdup("return texture2D(tex0, texcoord);\n"); + extra_code_text[extra_code_count++] = strdup("}\n"); } else if (major_version > 1 || minor_version >= 30) { //switches are supported in GLSL 1.30 and later @@ -734,27 +736,27 @@ GLhandleARB LLShaderMgr::loadShaderFile(const std::string& filename, S32 & shade for (U32 i = 0; i < texture_index_channels; ++i) { std::string if_string = llformat("\t%sif (vary_texture_index == %d) { return texture2D(tex%d, texcoord); }\n", i > 0 ? "else " : "", i, i); - text[count++] = strdup(if_string.c_str()); + extra_code_text[extra_code_count++] = strdup(if_string.c_str()); } - text[count++] = strdup("\treturn vec4(1,0,1,1);\n"); - text[count++] = strdup("}\n"); + extra_code_text[extra_code_count++] = strdup("\treturn vec4(1,0,1,1);\n"); + extra_code_text[extra_code_count++] = strdup("}\n"); } else { - text[count++] = strdup("\tvec4 ret = vec4(1,0,1,1);\n"); - text[count++] = strdup("\tswitch (vary_texture_index)\n"); - text[count++] = strdup("\t{\n"); + extra_code_text[extra_code_count++] = strdup("\tvec4 ret = vec4(1,0,1,1);\n"); + extra_code_text[extra_code_count++] = strdup("\tswitch (vary_texture_index)\n"); + extra_code_text[extra_code_count++] = strdup("\t{\n"); //switch body for (S32 i = 0; i < texture_index_channels; ++i) { std::string case_str = llformat("\t\tcase %d: return texture2D(tex%d, texcoord);\n", i, i); - text[count++] = strdup(case_str.c_str()); + extra_code_text[extra_code_count++] = strdup(case_str.c_str()); } - text[count++] = strdup("\t}\n"); - text[count++] = strdup("\treturn ret;\n"); - text[count++] = strdup("}\n"); + extra_code_text[extra_code_count++] = strdup("\t}\n"); + extra_code_text[extra_code_count++] = strdup("\treturn ret;\n"); + extra_code_text[extra_code_count++] = strdup("}\n"); } } else @@ -765,14 +767,81 @@ GLhandleARB LLShaderMgr::loadShaderFile(const std::string& filename, S32 & shade } else { - text[count++] = strdup("#define HAS_DIFFUSE_LOOKUP 0\n"); + extra_code_text[extra_code_count++] = strdup("#define HAS_DIFFUSE_LOOKUP 0\n"); } + //copy file into memory - while( fgets((char *)buff, 1024, file) != NULL && count < LL_ARRAY_SIZE(text) ) + enum { + flag_write_to_out_of_extra_block_area = 0x01 + , flag_extra_block_marker_was_found = 0x02 + }; + + unsigned char flags = flag_write_to_out_of_extra_block_area; + + GLuint out_of_extra_block_counter = 0, start_shader_code = shader_code_count; + + while(NULL != fgets((char *)buff, 1024, file) + && shader_code_count < (LL_ARRAY_SIZE(shader_code_text) - LL_ARRAY_SIZE(extra_code_text))) { - text[count++] = (GLcharARB *)strdup((char *)buff); + bool extra_block_area_found = NULL != strstr((const char*)buff, "[EXTRA_CODE_HERE]"); + + if(extra_block_area_found && !(flag_extra_block_marker_was_found & flags)) + { + if(!(flag_write_to_out_of_extra_block_area & flags)) + { + //shift + for(GLuint to = start_shader_code, from = extra_code_count + start_shader_code; + from < shader_code_count; ++to, ++from) + { + shader_code_text[to] = shader_code_text[from]; + } + + shader_code_count -= extra_code_count; + } + + //copy extra code + for(GLuint n = 0; n < extra_code_count + && shader_code_count < (LL_ARRAY_SIZE(shader_code_text) - LL_ARRAY_SIZE(extra_code_text)); ++n) + { + shader_code_text[shader_code_count++] = extra_code_text[n]; + } + + extra_code_count = 0; + + flags &= ~flag_write_to_out_of_extra_block_area; + flags |= flag_extra_block_marker_was_found; + continue; + } + + shader_code_text[shader_code_count] = (GLcharARB *)strdup((char *)buff); + + if(flag_write_to_out_of_extra_block_area & flags) + { + shader_code_text[extra_code_count + start_shader_code + out_of_extra_block_counter] + = shader_code_text[shader_code_count]; + out_of_extra_block_counter++; + + if(out_of_extra_block_counter == extra_code_count) + { + shader_code_count += extra_code_count; + flags &= ~flag_write_to_out_of_extra_block_area; + } + } + + ++shader_code_count; + } //while + + if(!(flag_extra_block_marker_was_found & flags)) + { + for(GLuint n = start_shader_code; n < extra_code_count + start_shader_code; ++n) + { + shader_code_text[n] = extra_code_text[n - start_shader_code]; + } + + extra_code_count = 0; } + fclose(file); //create shader object @@ -787,7 +856,7 @@ GLhandleARB LLShaderMgr::loadShaderFile(const std::string& filename, S32 & shade } //load source - glShaderSourceARB(ret, count, (const GLcharARB**) text, NULL); + glShaderSourceARB(ret, shader_code_count, (const GLcharARB**) shader_code_text, NULL); if (gDebugGL) { @@ -826,9 +895,9 @@ GLhandleARB LLShaderMgr::loadShaderFile(const std::string& filename, S32 & shade #if LL_WINDOWS std::stringstream ostr; //dump shader source for debugging - for (GLuint i = 0; i < count; i++) + for (GLuint i = 0; i < shader_code_count; i++) { - ostr << i << ": " << text[i]; + ostr << i << ": " << shader_code_text[i]; if (i % 128 == 0) { //dump every 128 lines @@ -843,8 +912,8 @@ GLhandleARB LLShaderMgr::loadShaderFile(const std::string& filename, S32 & shade #else std::string str; - for (GLuint i = 0; i < count; i++) { - str.append(text[i]); + for (GLuint i = 0; i < shader_code_count; i++) { + str.append(shader_code_text[i]); if (i % 128 == 0) { @@ -853,7 +922,7 @@ GLhandleARB LLShaderMgr::loadShaderFile(const std::string& filename, S32 & shade } } #endif - + ret = 0; } } @@ -865,9 +934,9 @@ GLhandleARB LLShaderMgr::loadShaderFile(const std::string& filename, S32 & shade stop_glerror(); //free memory - for (GLuint i = 0; i < count; i++) + for (GLuint i = 0; i < shader_code_count; i++) { - free(text[i]); + free(shader_code_text[i]); } //successfully loaded, save results -- cgit v1.2.3 From 6883c6b1f689335963775b43d109a93eb46e6b2f Mon Sep 17 00:00:00 2001 From: Oz Linden Date: Thu, 14 Sep 2017 16:56:51 -0400 Subject: replace a 'continue' with an 'else' --- indra/llrender/llshadermgr.cpp | 31 ++++++++++++++++--------------- 1 file changed, 16 insertions(+), 15 deletions(-) (limited to 'indra/llrender') diff --git a/indra/llrender/llshadermgr.cpp b/indra/llrender/llshadermgr.cpp index 19a9ced321..07356940f1 100644 --- a/indra/llrender/llshadermgr.cpp +++ b/indra/llrender/llshadermgr.cpp @@ -811,25 +811,26 @@ GLhandleARB LLShaderMgr::loadShaderFile(const std::string& filename, S32 & shade flags &= ~flag_write_to_out_of_extra_block_area; flags |= flag_extra_block_marker_was_found; - continue; } - - shader_code_text[shader_code_count] = (GLcharARB *)strdup((char *)buff); + else + { + shader_code_text[shader_code_count] = (GLcharARB *)strdup((char *)buff); - if(flag_write_to_out_of_extra_block_area & flags) - { - shader_code_text[extra_code_count + start_shader_code + out_of_extra_block_counter] - = shader_code_text[shader_code_count]; - out_of_extra_block_counter++; + if(flag_write_to_out_of_extra_block_area & flags) + { + shader_code_text[extra_code_count + start_shader_code + out_of_extra_block_counter] + = shader_code_text[shader_code_count]; + out_of_extra_block_counter++; - if(out_of_extra_block_counter == extra_code_count) - { - shader_code_count += extra_code_count; - flags &= ~flag_write_to_out_of_extra_block_area; - } - } + if(out_of_extra_block_counter == extra_code_count) + { + shader_code_count += extra_code_count; + flags &= ~flag_write_to_out_of_extra_block_area; + } + } - ++shader_code_count; + ++shader_code_count; + } } //while if(!(flag_extra_block_marker_was_found & flags)) -- cgit v1.2.3 From 0e9fb587fa267a296183b0d2093700e5fb53c950 Mon Sep 17 00:00:00 2001 From: ruslantproductengine Date: Mon, 18 Sep 2017 21:02:53 +0300 Subject: MAINT-7813 - 3D rendering broken on Windows in build 508618. 3D rendering starts before 2D login screen is cleared. FIXED --- indra/llrender/llshadermgr.cpp | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'indra/llrender') diff --git a/indra/llrender/llshadermgr.cpp b/indra/llrender/llshadermgr.cpp index 07356940f1..e721ad93fa 100644 --- a/indra/llrender/llshadermgr.cpp +++ b/indra/llrender/llshadermgr.cpp @@ -779,11 +779,13 @@ GLhandleARB LLShaderMgr::loadShaderFile(const std::string& filename, S32 & shade unsigned char flags = flag_write_to_out_of_extra_block_area; - GLuint out_of_extra_block_counter = 0, start_shader_code = shader_code_count; + GLuint out_of_extra_block_counter = 0, start_shader_code = shader_code_count, file_lines_count = 0; while(NULL != fgets((char *)buff, 1024, file) && shader_code_count < (LL_ARRAY_SIZE(shader_code_text) - LL_ARRAY_SIZE(extra_code_text))) { + file_lines_count++; + bool extra_block_area_found = NULL != strstr((const char*)buff, "[EXTRA_CODE_HERE]"); if(extra_block_area_found && !(flag_extra_block_marker_was_found & flags)) @@ -840,6 +842,11 @@ GLhandleARB LLShaderMgr::loadShaderFile(const std::string& filename, S32 & shade shader_code_text[n] = extra_code_text[n - start_shader_code]; } + if (file_lines_count < extra_code_count) + { + shader_code_count += extra_code_count; + } + extra_code_count = 0; } -- cgit v1.2.3 From d1ab470542af07425d2b462e284cc616c33dbb17 Mon Sep 17 00:00:00 2001 From: Nat Goodspeed Date: Wed, 20 Sep 2017 16:58:58 -0400 Subject: DRTVWR-418: Fix C++ errors detected by Xcode 9. You can't legitimately perform an ordered comparison between a pointer and an int, even 0. Fix a number of 'if (ptr > 0)' to plain 'if (ptr)'. Fix LLEditWearableDictionary::WearableEntry constructor to avoid varargs mechanism. It used to accept three different counts, followed by three different lists of enums, fetched in each case as 'int' -- dubious in itself. The constructor body performed three different loops to populate those enums into three different member vectors. Instead, make the constructor accept three vectors and initialize the member vectors from the passed vectors. Now that C++ has inline vector initialization, change existing constructor calls to pass temporary vectors initialized with what used to be the varargs enum values. --- indra/llrender/llglslshader.cpp | 34 +++++++++++++++++----------------- 1 file changed, 17 insertions(+), 17 deletions(-) (limited to 'indra/llrender') diff --git a/indra/llrender/llglslshader.cpp b/indra/llrender/llglslshader.cpp index 5d669fb955..970502f2d6 100644 --- a/indra/llrender/llglslshader.cpp +++ b/indra/llrender/llglslshader.cpp @@ -408,7 +408,7 @@ BOOL LLGLSLShader::createShader(std::vector * attributes, { GLhandleARB shaderhandle = LLShaderMgr::instance()->loadShaderFile((*fileIter).first, mShaderLevel, (*fileIter).second, &mDefines, mFeatures.mIndexedTextureChannels); LL_DEBUGS("ShaderLoading") << "SHADER FILE: " << (*fileIter).first << " mShaderLevel=" << mShaderLevel << LL_ENDL; - if (shaderhandle > 0) + if (shaderhandle) { attachObject(shaderhandle); } @@ -997,7 +997,7 @@ S32 LLGLSLShader::disableTexture(S32 uniform, LLTexUnit::eTextureType mode) void LLGLSLShader::uniform1i(U32 index, GLint x) { - if (mProgramObject > 0) + if (mProgramObject) { if (mUniform.size() <= index) { @@ -1019,7 +1019,7 @@ void LLGLSLShader::uniform1i(U32 index, GLint x) void LLGLSLShader::uniform1f(U32 index, GLfloat x) { - if (mProgramObject > 0) + if (mProgramObject) { if (mUniform.size() <= index) { @@ -1041,7 +1041,7 @@ void LLGLSLShader::uniform1f(U32 index, GLfloat x) void LLGLSLShader::uniform2f(U32 index, GLfloat x, GLfloat y) { - if (mProgramObject > 0) + if (mProgramObject) { if (mUniform.size() <= index) { @@ -1064,7 +1064,7 @@ void LLGLSLShader::uniform2f(U32 index, GLfloat x, GLfloat y) void LLGLSLShader::uniform3f(U32 index, GLfloat x, GLfloat y, GLfloat z) { - if (mProgramObject > 0) + if (mProgramObject) { if (mUniform.size() <= index) { @@ -1087,7 +1087,7 @@ void LLGLSLShader::uniform3f(U32 index, GLfloat x, GLfloat y, GLfloat z) void LLGLSLShader::uniform4f(U32 index, GLfloat x, GLfloat y, GLfloat z, GLfloat w) { - if (mProgramObject > 0) + if (mProgramObject) { if (mUniform.size() <= index) { @@ -1110,7 +1110,7 @@ void LLGLSLShader::uniform4f(U32 index, GLfloat x, GLfloat y, GLfloat z, GLfloat void LLGLSLShader::uniform1iv(U32 index, U32 count, const GLint* v) { - if (mProgramObject > 0) + if (mProgramObject) { if (mUniform.size() <= index) { @@ -1133,7 +1133,7 @@ void LLGLSLShader::uniform1iv(U32 index, U32 count, const GLint* v) void LLGLSLShader::uniform1fv(U32 index, U32 count, const GLfloat* v) { - if (mProgramObject > 0) + if (mProgramObject) { if (mUniform.size() <= index) { @@ -1156,7 +1156,7 @@ void LLGLSLShader::uniform1fv(U32 index, U32 count, const GLfloat* v) void LLGLSLShader::uniform2fv(U32 index, U32 count, const GLfloat* v) { - if (mProgramObject > 0) + if (mProgramObject) { if (mUniform.size() <= index) { @@ -1179,7 +1179,7 @@ void LLGLSLShader::uniform2fv(U32 index, U32 count, const GLfloat* v) void LLGLSLShader::uniform3fv(U32 index, U32 count, const GLfloat* v) { - if (mProgramObject > 0) + if (mProgramObject) { if (mUniform.size() <= index) { @@ -1202,7 +1202,7 @@ void LLGLSLShader::uniform3fv(U32 index, U32 count, const GLfloat* v) void LLGLSLShader::uniform4fv(U32 index, U32 count, const GLfloat* v) { - if (mProgramObject > 0) + if (mProgramObject) { if (mUniform.size() <= index) { @@ -1225,7 +1225,7 @@ void LLGLSLShader::uniform4fv(U32 index, U32 count, const GLfloat* v) void LLGLSLShader::uniformMatrix2fv(U32 index, U32 count, GLboolean transpose, const GLfloat *v) { - if (mProgramObject > 0) + if (mProgramObject) { if (mUniform.size() <= index) { @@ -1242,7 +1242,7 @@ void LLGLSLShader::uniformMatrix2fv(U32 index, U32 count, GLboolean transpose, c void LLGLSLShader::uniformMatrix3fv(U32 index, U32 count, GLboolean transpose, const GLfloat *v) { - if (mProgramObject > 0) + if (mProgramObject) { if (mUniform.size() <= index) { @@ -1259,7 +1259,7 @@ void LLGLSLShader::uniformMatrix3fv(U32 index, U32 count, GLboolean transpose, c void LLGLSLShader::uniformMatrix3x4fv(U32 index, U32 count, GLboolean transpose, const GLfloat *v) { - if (mProgramObject > 0) + if (mProgramObject) { if (mUniform.size() <= index) { @@ -1276,7 +1276,7 @@ void LLGLSLShader::uniformMatrix3x4fv(U32 index, U32 count, GLboolean transpose, void LLGLSLShader::uniformMatrix4fv(U32 index, U32 count, GLboolean transpose, const GLfloat *v) { - if (mProgramObject > 0) + if (mProgramObject) { if (mUniform.size() <= index) { @@ -1294,7 +1294,7 @@ void LLGLSLShader::uniformMatrix4fv(U32 index, U32 count, GLboolean transpose, c GLint LLGLSLShader::getUniformLocation(const LLStaticHashedString& uniform) { GLint ret = -1; - if (mProgramObject > 0) + if (mProgramObject) { LLStaticStringTable::iterator iter = mUniformMap.find(uniform); if (iter != mUniformMap.end()) @@ -1318,7 +1318,7 @@ GLint LLGLSLShader::getUniformLocation(const LLStaticHashedString& uniform) GLint LLGLSLShader::getUniformLocation(U32 index) { GLint ret = -1; - if (mProgramObject > 0) + if (mProgramObject) { llassert(index < mUniform.size()); return mUniform[index]; -- cgit v1.2.3