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