diff --git a/indra/llrender/llrender.cpp b/indra/llrender/llrender.cpp index 2b6be9739f60ca6b8144627beeb6383b2372dab3..46e7d064077f80f8f83b817378ce2f97ce1e5894 100644 --- a/indra/llrender/llrender.cpp +++ b/indra/llrender/llrender.cpp @@ -1086,7 +1086,8 @@ LLRender::LLRender() mMode(LLRender::TRIANGLES), mCurrTextureUnitIndex(0), mLineWidth(1.f), - mDummyVAO(0) + mDummyVAO(0), + mPrimitiveReset(false) { mTexUnits.reserve(LL_NUM_TEXTURE_LAYERS); for (U32 i = 0; i < LL_NUM_TEXTURE_LAYERS; i++) @@ -1934,7 +1935,8 @@ void LLRender::begin(const GLuint& mode) if (mMode == LLRender::QUADS || mMode == LLRender::LINES || mMode == LLRender::TRIANGLES || - mMode == LLRender::POINTS) + mMode == LLRender::POINTS || + mMode == LLRender::TRIANGLE_STRIP ) { flush(); } @@ -1958,12 +1960,18 @@ void LLRender::end() if ((mMode != LLRender::QUADS && mMode != LLRender::LINES && mMode != LLRender::TRIANGLES && - mMode != LLRender::POINTS) || + mMode != LLRender::POINTS && + mMode != LLRender::TRIANGLE_STRIP) || mCount > 2048) { flush(); } + else if (mMode == LLRender::TRIANGLE_STRIP) + { + mPrimitiveReset = true; + } } + void LLRender::flush() { if (mCount > 0) @@ -2031,6 +2039,7 @@ void LLRender::flush() mColorsp[0] = mColorsp[count]; mCount = 0; + mPrimitiveReset = false; } } @@ -2045,6 +2054,21 @@ void LLRender::vertex4a(const LLVector4a& vertex) case LLRender::TRIANGLES: if (mCount%3==0) flush(); break; case LLRender::QUADS: if(mCount%4 == 0) flush(); break; case LLRender::LINES: if (mCount%2 == 0) flush(); break; + case LLRender::TRIANGLE_STRIP: + { + LLVector4a vert[] = { mVerticesp[mCount - 2], mVerticesp[mCount - 1], mVerticesp[mCount] }; + LLColor4U col[] = { mColorsp[mCount - 2], mColorsp[mCount - 1], mColorsp[mCount] }; + LLVector2 tc[] = { mTexcoordsp[mCount - 2], mTexcoordsp[mCount - 1], mTexcoordsp[mCount] }; + flush(); + for (int i = 0; i < LL_ARRAY_SIZE(vert); ++i) + { + mVerticesp[i] = vert[i]; + mColorsp[i] = col[i]; + mTexcoordsp[i] = tc[i]; + } + mCount = 2; + break; + } } } @@ -2054,6 +2078,18 @@ void LLRender::vertex4a(const LLVector4a& vertex) return; } + if (mPrimitiveReset && mCount) + { + // Insert degenerate + ++mCount; + mVerticesp[mCount] = mVerticesp[mCount - 1]; + mColorsp[mCount] = mColorsp[mCount - 1]; + mTexcoordsp[mCount] = mTexcoordsp[mCount - 1]; + mVerticesp[mCount - 1] = mVerticesp[mCount - 2]; + mColorsp[mCount - 1] = mColorsp[mCount - 2]; + mTexcoordsp[mCount - 1] = mTexcoordsp[mCount - 2]; + } + if (mUIOffset.empty()) { mVerticesp[mCount] = vertex; @@ -2087,6 +2123,16 @@ void LLRender::vertex4a(const LLVector4a& vertex) mVerticesp[mCount] = mVerticesp[mCount-1]; mColorsp[mCount] = mColorsp[mCount-1]; mTexcoordsp[mCount] = mTexcoordsp[mCount-1]; + + if (mPrimitiveReset && mCount) + { + mCount++; + mVerticesp[mCount] = mVerticesp[mCount - 1]; + mColorsp[mCount] = mColorsp[mCount - 1]; + mTexcoordsp[mCount] = mTexcoordsp[mCount - 1]; + } + + mPrimitiveReset = false; } void LLRender::vertexBatchPreTransformed(LLVector4a* verts, S32 vert_count) @@ -2133,6 +2179,21 @@ void LLRender::vertexBatchPreTransformed(LLVector4a* verts, S32 vert_count) } else { + if (mPrimitiveReset && mCount) + { + // Insert degenerate + ++mCount; + mVerticesp[mCount] = verts[0]; + mColorsp[mCount] = mColorsp[mCount - 1]; + mTexcoordsp[mCount] = mTexcoordsp[mCount - 1]; + mVerticesp[mCount - 1] = mVerticesp[mCount - 2]; + mColorsp[mCount - 1] = mColorsp[mCount - 2]; + mTexcoordsp[mCount - 1] = mTexcoordsp[mCount - 2]; + ++mCount; + mColorsp[mCount] = mColorsp[mCount - 1]; + mTexcoordsp[mCount] = mTexcoordsp[mCount - 1]; + } + mVerticesp.copyArray(mCount, verts, vert_count); for (S32 i = 0; i < vert_count; i++) { @@ -2145,6 +2206,7 @@ void LLRender::vertexBatchPreTransformed(LLVector4a* verts, S32 vert_count) if( mCount > 0 ) // ND: Guard against crashes if mCount is zero, yes it can happen mVerticesp[mCount] = mVerticesp[mCount-1]; + mPrimitiveReset = false; } void LLRender::vertexBatchPreTransformed(LLVector4a* verts, LLVector2* uvs, S32 vert_count) @@ -2191,6 +2253,21 @@ void LLRender::vertexBatchPreTransformed(LLVector4a* verts, LLVector2* uvs, S32 } else { + if (mPrimitiveReset && mCount) + { + // Insert degenerate + ++mCount; + mVerticesp[mCount] = verts[0]; + mColorsp[mCount] = mColorsp[mCount - 1]; + mTexcoordsp[mCount] = uvs[0]; + mVerticesp[mCount - 1] = mVerticesp[mCount - 2]; + mColorsp[mCount - 1] = mColorsp[mCount - 2]; + mTexcoordsp[mCount - 1] = mTexcoordsp[mCount - 2]; + ++mCount; + mColorsp[mCount] = mColorsp[mCount - 1]; + mTexcoordsp[mCount] = mTexcoordsp[mCount - 1]; + } + mVerticesp.copyArray(mCount, verts, vert_count); mTexcoordsp.copyArray(mCount, uvs, vert_count); @@ -2206,6 +2283,8 @@ void LLRender::vertexBatchPreTransformed(LLVector4a* verts, LLVector2* uvs, S32 mVerticesp[mCount] = mVerticesp[mCount - 1]; mTexcoordsp[mCount] = mTexcoordsp[mCount - 1]; } + + mPrimitiveReset = false; } void LLRender::vertexBatchPreTransformed(LLVector4a* verts, LLVector2* uvs, LLColor4U* colors, S32 vert_count) @@ -2253,6 +2332,21 @@ void LLRender::vertexBatchPreTransformed(LLVector4a* verts, LLVector2* uvs, LLCo } else { + if (mPrimitiveReset && mCount) + { + // Insert degenerate + ++mCount; + mVerticesp[mCount] = verts[0]; + mColorsp[mCount] = colors[mCount - 1]; + mTexcoordsp[mCount] = uvs[0]; + mVerticesp[mCount - 1] = mVerticesp[mCount - 2]; + mColorsp[mCount - 1] = mColorsp[mCount - 2]; + mTexcoordsp[mCount - 1] = mTexcoordsp[mCount - 2]; + ++mCount; + mColorsp[mCount] = mColorsp[mCount - 1]; + mTexcoordsp[mCount] = mTexcoordsp[mCount - 1]; + } + // Note: Batch copies instead of iterating. mVerticesp.copyArray(mCount, verts, vert_count); mTexcoordsp.copyArray(mCount, uvs, vert_count); @@ -2266,6 +2360,8 @@ void LLRender::vertexBatchPreTransformed(LLVector4a* verts, LLVector2* uvs, LLCo mTexcoordsp[mCount] = mTexcoordsp[mCount - 1]; mColorsp[mCount] = mColorsp[mCount - 1]; } + + mPrimitiveReset = false; } void LLRender::texCoord2f(const GLfloat& x, const GLfloat& y) diff --git a/indra/llrender/llrender.h b/indra/llrender/llrender.h index 076b68cd6b19016a7acad9f00fffb91c3e5aef60..7e438d644bfbe14cf287c18602abc7827140aeb9 100644 --- a/indra/llrender/llrender.h +++ b/indra/llrender/llrender.h @@ -523,6 +523,7 @@ class LLRender std::vector<LLVector4a, boost::alignment::aligned_allocator<LLVector4a, 64> > mUIOffset; std::vector<LLVector4a, boost::alignment::aligned_allocator<LLVector4a, 64> > mUIScale; + bool mPrimitiveReset; }; extern LLMatrix4a gGLModelView;