Remove all QUADS usage. Replaced with TRIANGLES and TRIANGLE_STRIP. May do another pass and replace un-textured TRIANGLE_STRIPs with TRIANGLES to reduce flush calls.
This commit is contained in:
@@ -70,6 +70,8 @@ const F32 PIXEL_CORRECTION_DISTANCE = 0.01f;
|
||||
const F32 PAD_UVY = 0.5f; // half of vertical padding between glyphs in the glyph texture
|
||||
const F32 DROP_SHADOW_SOFT_STRENGTH = 0.3f;
|
||||
|
||||
const U32 GLYPH_VERTICES = 6;
|
||||
|
||||
LLFontGL::LLFontGL()
|
||||
{
|
||||
clearEmbeddedChars();
|
||||
@@ -255,9 +257,9 @@ S32 LLFontGL::render(const LLWString &wstr, S32 begin_offset, F32 x, F32 y, cons
|
||||
const LLFontGlyphInfo* next_glyph = NULL;
|
||||
|
||||
const S32 GLYPH_BATCH_SIZE = 30;
|
||||
static LL_ALIGN_16(LLVector4a vertices[GLYPH_BATCH_SIZE * 4]);
|
||||
static LLVector2 uvs[GLYPH_BATCH_SIZE * 4];
|
||||
static LLColor4U colors[GLYPH_BATCH_SIZE * 4];
|
||||
static LL_ALIGN_16(LLVector4a vertices[GLYPH_BATCH_SIZE * GLYPH_VERTICES]);
|
||||
static LLVector2 uvs[GLYPH_BATCH_SIZE * GLYPH_VERTICES];
|
||||
static LLColor4U colors[GLYPH_BATCH_SIZE * GLYPH_VERTICES];
|
||||
|
||||
LLColor4U text_color(color);
|
||||
|
||||
@@ -302,18 +304,18 @@ S32 LLFontGL::render(const LLWString &wstr, S32 begin_offset, F32 x, F32 y, cons
|
||||
|
||||
if (glyph_count > 0)
|
||||
{
|
||||
gGL.begin(LLRender::QUADS);
|
||||
gGL.begin(LLRender::TRIANGLES);
|
||||
{
|
||||
gGL.vertexBatchPreTransformed(vertices, uvs, colors, glyph_count * 4);
|
||||
gGL.vertexBatchPreTransformed(vertices, uvs, colors, glyph_count * GLYPH_VERTICES);
|
||||
}
|
||||
gGL.end();
|
||||
glyph_count = 0;
|
||||
}
|
||||
renderQuad(vertices, uvs, colors, screen_rect, uv_rect, LLColor4U::white, 0);
|
||||
//No batching here. It will never happen.
|
||||
gGL.begin(LLRender::QUADS);
|
||||
gGL.begin(LLRender::TRIANGLES);
|
||||
{
|
||||
gGL.vertexBatchPreTransformed(vertices, uvs, colors, 4);
|
||||
gGL.vertexBatchPreTransformed(vertices, uvs, colors, GLYPH_VERTICES);
|
||||
}
|
||||
gGL.end();
|
||||
|
||||
@@ -358,9 +360,9 @@ S32 LLFontGL::render(const LLWString &wstr, S32 begin_offset, F32 x, F32 y, cons
|
||||
// otherwise the queued glyphs will be taken from wrong textures.
|
||||
if (glyph_count > 0)
|
||||
{
|
||||
gGL.begin(LLRender::QUADS);
|
||||
gGL.begin(LLRender::TRIANGLES);
|
||||
{
|
||||
gGL.vertexBatchPreTransformed(vertices, uvs, colors, glyph_count * 4);
|
||||
gGL.vertexBatchPreTransformed(vertices, uvs, colors, glyph_count * GLYPH_VERTICES);
|
||||
}
|
||||
gGL.end();
|
||||
glyph_count = 0;
|
||||
@@ -391,9 +393,9 @@ S32 LLFontGL::render(const LLWString &wstr, S32 begin_offset, F32 x, F32 y, cons
|
||||
|
||||
if (glyph_count >= GLYPH_BATCH_SIZE)
|
||||
{
|
||||
gGL.begin(LLRender::QUADS);
|
||||
gGL.begin(LLRender::TRIANGLES);
|
||||
{
|
||||
gGL.vertexBatchPreTransformed(vertices, uvs, colors, glyph_count * 4);
|
||||
gGL.vertexBatchPreTransformed(vertices, uvs, colors, glyph_count * GLYPH_VERTICES);
|
||||
}
|
||||
gGL.end();
|
||||
|
||||
@@ -428,9 +430,9 @@ S32 LLFontGL::render(const LLWString &wstr, S32 begin_offset, F32 x, F32 y, cons
|
||||
|
||||
if(glyph_count)
|
||||
{
|
||||
gGL.begin(LLRender::QUADS);
|
||||
gGL.begin(LLRender::TRIANGLES);
|
||||
{
|
||||
gGL.vertexBatchPreTransformed(vertices, uvs, colors, glyph_count * 4);
|
||||
gGL.vertexBatchPreTransformed(vertices, uvs, colors, glyph_count * GLYPH_VERTICES);
|
||||
}
|
||||
gGL.end();
|
||||
}
|
||||
@@ -1271,13 +1273,23 @@ void LLFontGL::renderQuad(LLVector4a* vertex_out, LLVector2* uv_out, LLColor4U*
|
||||
{
|
||||
S32 index = 0;
|
||||
|
||||
vertex_out[index].set(screen_rect.mLeft, screen_rect.mTop, 0.f);
|
||||
uv_out[index] = LLVector2(uv_rect.mLeft, uv_rect.mTop);
|
||||
colors_out[index] = color;
|
||||
index++;
|
||||
|
||||
vertex_out[index].set(screen_rect.mLeft + slant_amt, screen_rect.mBottom, 0.f);
|
||||
uv_out[index] = LLVector2(uv_rect.mLeft, uv_rect.mBottom);
|
||||
colors_out[index] = color;
|
||||
index++;
|
||||
|
||||
vertex_out[index].set(screen_rect.mRight, screen_rect.mTop, 0.f);
|
||||
uv_out[index] = LLVector2(uv_rect.mRight, uv_rect.mTop);
|
||||
colors_out[index] = color;
|
||||
index++;
|
||||
|
||||
vertex_out[index].set(screen_rect.mLeft, screen_rect.mTop, 0.f);
|
||||
uv_out[index] = LLVector2(uv_rect.mLeft, uv_rect.mTop);
|
||||
vertex_out[index].set(screen_rect.mRight, screen_rect.mTop, 0.f);
|
||||
uv_out[index] = LLVector2(uv_rect.mRight, uv_rect.mTop);
|
||||
colors_out[index] = color;
|
||||
index++;
|
||||
|
||||
@@ -1305,7 +1317,8 @@ void LLFontGL::drawGlyph(S32& glyph_count, LLVector4a* vertex_out, LLVector2* uv
|
||||
LLRectf screen_rect_offset = screen_rect;
|
||||
|
||||
screen_rect_offset.translate((F32)(pass * BOLD_OFFSET), 0.f);
|
||||
renderQuad(&vertex_out[glyph_count * 4], &uv_out[glyph_count * 4], &colors_out[glyph_count * 4], screen_rect_offset, uv_rect, color, slant_offset);
|
||||
const U32 idx = glyph_count * GLYPH_VERTICES;
|
||||
renderQuad(&vertex_out[idx], &uv_out[idx], &colors_out[idx], screen_rect_offset, uv_rect, color, slant_offset);
|
||||
glyph_count++;
|
||||
}
|
||||
}
|
||||
@@ -1336,10 +1349,12 @@ void LLFontGL::drawGlyph(S32& glyph_count, LLVector4a* vertex_out, LLVector2* uv
|
||||
break;
|
||||
}
|
||||
|
||||
renderQuad(&vertex_out[glyph_count * 4], &uv_out[glyph_count * 4], &colors_out[glyph_count * 4], screen_rect_offset, uv_rect, shadow_color, slant_offset);
|
||||
const U32 idx = glyph_count * GLYPH_VERTICES;
|
||||
renderQuad(&vertex_out[idx], &uv_out[idx], &colors_out[idx], screen_rect_offset, uv_rect, shadow_color, slant_offset);
|
||||
glyph_count++;
|
||||
}
|
||||
renderQuad(&vertex_out[glyph_count * 4], &uv_out[glyph_count * 4], &colors_out[glyph_count * 4], screen_rect, uv_rect, color, slant_offset);
|
||||
const U32 idx = glyph_count * GLYPH_VERTICES;
|
||||
renderQuad(&vertex_out[idx], &uv_out[idx], &colors_out[idx], screen_rect, uv_rect, color, slant_offset);
|
||||
glyph_count++;
|
||||
}
|
||||
else if (shadow == DROP_SHADOW)
|
||||
@@ -1348,14 +1363,17 @@ void LLFontGL::drawGlyph(S32& glyph_count, LLVector4a* vertex_out, LLVector2* uv
|
||||
shadow_color.mV[VALPHA] = U8(color.mV[VALPHA] * drop_shadow_strength);
|
||||
LLRectf screen_rect_shadow = screen_rect;
|
||||
screen_rect_shadow.translate(1.f, -1.f);
|
||||
renderQuad(&vertex_out[glyph_count * 4], &uv_out[glyph_count * 4], &colors_out[glyph_count * 4], screen_rect_shadow, uv_rect, shadow_color, slant_offset);
|
||||
U32 idx = glyph_count * GLYPH_VERTICES;
|
||||
renderQuad(&vertex_out[idx], &uv_out[idx], &colors_out[idx], screen_rect_shadow, uv_rect, shadow_color, slant_offset);
|
||||
glyph_count++;
|
||||
renderQuad(&vertex_out[glyph_count * 4], &uv_out[glyph_count * 4], &colors_out[glyph_count * 4], screen_rect, uv_rect, color, slant_offset);
|
||||
idx = glyph_count * GLYPH_VERTICES;
|
||||
renderQuad(&vertex_out[idx], &uv_out[idx], &colors_out[idx], screen_rect, uv_rect, color, slant_offset);
|
||||
glyph_count++;
|
||||
}
|
||||
else // normal rendering
|
||||
{
|
||||
renderQuad(&vertex_out[glyph_count * 4], &uv_out[glyph_count * 4], &colors_out[glyph_count * 4], screen_rect, uv_rect, color, slant_offset);
|
||||
const U32 idx = glyph_count * GLYPH_VERTICES;
|
||||
renderQuad(&vertex_out[idx], &uv_out[idx], &colors_out[idx], screen_rect, uv_rect, color, slant_offset);
|
||||
glyph_count++;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1041,7 +1041,6 @@ LLRender::eBlendFactor blendfunc_debug[4]={LLRender::BF_UNDEF};
|
||||
LLRender::LLRender()
|
||||
: mDirty(false),
|
||||
mCount(0),
|
||||
mQuadCycle(0),
|
||||
mMode(LLRender::TRIANGLES),
|
||||
mCurrTextureUnitIndex(0),
|
||||
mMaxAnisotropy(0.f)
|
||||
@@ -2055,13 +2054,7 @@ void LLRender::begin(const GLuint& mode)
|
||||
{
|
||||
if (mode != mMode)
|
||||
{
|
||||
if (mode == LLRender::QUADS)
|
||||
{
|
||||
mQuadCycle = 1;
|
||||
}
|
||||
|
||||
if (mMode == LLRender::QUADS ||
|
||||
mMode == LLRender::LINES ||
|
||||
if (mMode == LLRender::LINES ||
|
||||
mMode == LLRender::TRIANGLES ||
|
||||
mMode == LLRender::POINTS)
|
||||
{
|
||||
@@ -2084,8 +2077,7 @@ void LLRender::end()
|
||||
//IMM_ERRS << "GL begin and end called with no vertices specified." << LL_ENDL;
|
||||
}
|
||||
|
||||
if ((mMode != LLRender::QUADS &&
|
||||
mMode != LLRender::LINES &&
|
||||
if ((mMode != LLRender::LINES &&
|
||||
mMode != LLRender::TRIANGLES &&
|
||||
mMode != LLRender::POINTS) ||
|
||||
mCount > 2048)
|
||||
@@ -2147,14 +2139,6 @@ void LLRender::flush()
|
||||
|
||||
if (gDebugGL)
|
||||
{
|
||||
if (mMode == LLRender::QUADS && !sGLCoreProfile)
|
||||
{
|
||||
if (mCount%4 != 0)
|
||||
{
|
||||
LL_ERRS() << "Incomplete quad rendered." << LL_ENDL;
|
||||
}
|
||||
}
|
||||
|
||||
if (mMode == LLRender::TRIANGLES)
|
||||
{
|
||||
if (mCount%3 != 0)
|
||||
@@ -2186,15 +2170,7 @@ void LLRender::flush()
|
||||
mBuffer->flush();
|
||||
mBuffer->setBuffer(immediate_mask);
|
||||
|
||||
if (mMode == LLRender::QUADS && sGLCoreProfile)
|
||||
{
|
||||
mBuffer->drawArrays(LLRender::TRIANGLES, 0, count);
|
||||
mQuadCycle = 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
mBuffer->drawArrays(mMode, 0, count);
|
||||
}
|
||||
mBuffer->drawArrays(mMode, 0, count);
|
||||
|
||||
mVerticesp[0] = mVerticesp[count];
|
||||
mTexcoordsp[0] = mTexcoordsp[count];
|
||||
@@ -2213,7 +2189,6 @@ void LLRender::vertex4a(const LLVector4a& vertex)
|
||||
{
|
||||
case LLRender::POINTS: flush(); break;
|
||||
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;
|
||||
}
|
||||
}
|
||||
@@ -2235,25 +2210,6 @@ void LLRender::vertex4a(const LLVector4a& vertex)
|
||||
mVerticesp[mCount].mul(mUIScale.back());
|
||||
}
|
||||
|
||||
if (mMode == LLRender::QUADS && LLRender::sGLCoreProfile)
|
||||
{
|
||||
mQuadCycle++;
|
||||
if (mQuadCycle == 4)
|
||||
{ //copy two vertices so fourth quad element will add a triangle
|
||||
mQuadCycle = 0;
|
||||
|
||||
mCount++;
|
||||
mVerticesp[mCount] = mVerticesp[mCount-3];
|
||||
mColorsp[mCount] = mColorsp[mCount-3];
|
||||
mTexcoordsp[mCount] = mTexcoordsp[mCount-3];
|
||||
|
||||
mCount++;
|
||||
mVerticesp[mCount] = mVerticesp[mCount-2];
|
||||
mColorsp[mCount] = mColorsp[mCount-2];
|
||||
mTexcoordsp[mCount] = mTexcoordsp[mCount-2];
|
||||
}
|
||||
}
|
||||
|
||||
mCount++;
|
||||
mVerticesp[mCount] = mVerticesp[mCount-1];
|
||||
mColorsp[mCount] = mColorsp[mCount-1];
|
||||
@@ -2268,50 +2224,13 @@ void LLRender::vertexBatchPreTransformed(LLVector4a* verts, S32 vert_count)
|
||||
return;
|
||||
}
|
||||
|
||||
if (sGLCoreProfile && mMode == LLRender::QUADS)
|
||||
{ //quads are deprecated, convert to triangle list
|
||||
S32 i = 0;
|
||||
|
||||
while (i < vert_count)
|
||||
{
|
||||
//read first three
|
||||
mVerticesp[mCount++] = verts[i++];
|
||||
mTexcoordsp[mCount] = mTexcoordsp[mCount-1];
|
||||
mColorsp[mCount] = mColorsp[mCount-1];
|
||||
|
||||
mVerticesp[mCount++] = verts[i++];
|
||||
mTexcoordsp[mCount] = mTexcoordsp[mCount-1];
|
||||
mColorsp[mCount] = mColorsp[mCount-1];
|
||||
|
||||
mVerticesp[mCount++] = verts[i++];
|
||||
mTexcoordsp[mCount] = mTexcoordsp[mCount-1];
|
||||
mColorsp[mCount] = mColorsp[mCount-1];
|
||||
|
||||
//copy two
|
||||
mVerticesp[mCount++] = verts[i-3];
|
||||
mTexcoordsp[mCount] = mTexcoordsp[mCount-1];
|
||||
mColorsp[mCount] = mColorsp[mCount-1];
|
||||
|
||||
mVerticesp[mCount++] = verts[i-1];
|
||||
mTexcoordsp[mCount] = mTexcoordsp[mCount-1];
|
||||
mColorsp[mCount] = mColorsp[mCount-1];
|
||||
|
||||
//copy last one
|
||||
mVerticesp[mCount++] = verts[i++];
|
||||
mTexcoordsp[mCount] = mTexcoordsp[mCount-1];
|
||||
mColorsp[mCount] = mColorsp[mCount-1];
|
||||
}
|
||||
}
|
||||
else
|
||||
for (S32 i = 0; i < vert_count; i++)
|
||||
{
|
||||
for (S32 i = 0; i < vert_count; i++)
|
||||
{
|
||||
mVerticesp[mCount] = verts[i];
|
||||
mVerticesp[mCount] = verts[i];
|
||||
|
||||
mCount++;
|
||||
mTexcoordsp[mCount] = mTexcoordsp[mCount-1];
|
||||
mColorsp[mCount] = mColorsp[mCount-1];
|
||||
}
|
||||
mCount++;
|
||||
mTexcoordsp[mCount] = mTexcoordsp[mCount-1];
|
||||
mColorsp[mCount] = mColorsp[mCount-1];
|
||||
}
|
||||
|
||||
mVerticesp[mCount] = mVerticesp[mCount-1];
|
||||
@@ -2325,52 +2244,15 @@ void LLRender::vertexBatchPreTransformed(LLVector4a* verts, LLVector2* uvs, S32
|
||||
return;
|
||||
}
|
||||
|
||||
if (sGLCoreProfile && mMode == LLRender::QUADS)
|
||||
{ //quads are deprecated, convert to triangle list
|
||||
S32 i = 0;
|
||||
|
||||
while (i < vert_count)
|
||||
{
|
||||
//read first three
|
||||
mVerticesp[mCount] = verts[i];
|
||||
mTexcoordsp[mCount++] = uvs[i++];
|
||||
mColorsp[mCount] = mColorsp[mCount-1];
|
||||
|
||||
mVerticesp[mCount] = verts[i];
|
||||
mTexcoordsp[mCount++] = uvs[i++];
|
||||
mColorsp[mCount] = mColorsp[mCount-1];
|
||||
|
||||
mVerticesp[mCount] = verts[i];
|
||||
mTexcoordsp[mCount++] = uvs[i++];
|
||||
mColorsp[mCount] = mColorsp[mCount-1];
|
||||
|
||||
//copy last two
|
||||
mVerticesp[mCount] = verts[i-3];
|
||||
mTexcoordsp[mCount++] = uvs[i-3];
|
||||
mColorsp[mCount] = mColorsp[mCount-1];
|
||||
|
||||
mVerticesp[mCount] = verts[i-1];
|
||||
mTexcoordsp[mCount++] = uvs[i-1];
|
||||
mColorsp[mCount] = mColorsp[mCount-1];
|
||||
|
||||
//copy last one
|
||||
mVerticesp[mCount] = verts[i];
|
||||
mTexcoordsp[mCount++] = uvs[i++];
|
||||
mColorsp[mCount] = mColorsp[mCount-1];
|
||||
}
|
||||
}
|
||||
else
|
||||
for (S32 i = 0; i < vert_count; i++)
|
||||
{
|
||||
for (S32 i = 0; i < vert_count; i++)
|
||||
{
|
||||
mVerticesp[mCount] = verts[i];
|
||||
mTexcoordsp[mCount] = uvs[i];
|
||||
mVerticesp[mCount] = verts[i];
|
||||
mTexcoordsp[mCount] = uvs[i];
|
||||
|
||||
mCount++;
|
||||
mColorsp[mCount] = mColorsp[mCount-1];
|
||||
}
|
||||
mCount++;
|
||||
mColorsp[mCount] = mColorsp[mCount-1];
|
||||
}
|
||||
|
||||
|
||||
mVerticesp[mCount] = mVerticesp[mCount-1];
|
||||
mTexcoordsp[mCount] = mTexcoordsp[mCount-1];
|
||||
}
|
||||
@@ -2384,50 +2266,13 @@ void LLRender::vertexBatchPreTransformed(LLVector4a* verts, LLVector2* uvs, LLCo
|
||||
}
|
||||
|
||||
|
||||
if (sGLCoreProfile && mMode == LLRender::QUADS)
|
||||
{ //quads are deprecated, convert to triangle list
|
||||
S32 i = 0;
|
||||
|
||||
while (i < vert_count)
|
||||
{
|
||||
//read first three
|
||||
mVerticesp[mCount] = verts[i];
|
||||
mTexcoordsp[mCount] = uvs[i];
|
||||
mColorsp[mCount++] = colors[i++];
|
||||
|
||||
mVerticesp[mCount] = verts[i];
|
||||
mTexcoordsp[mCount] = uvs[i];
|
||||
mColorsp[mCount++] = colors[i++];
|
||||
|
||||
mVerticesp[mCount] = verts[i];
|
||||
mTexcoordsp[mCount] = uvs[i];
|
||||
mColorsp[mCount++] = colors[i++];
|
||||
|
||||
//copy last two
|
||||
mVerticesp[mCount] = verts[i-3];
|
||||
mTexcoordsp[mCount] = uvs[i-3];
|
||||
mColorsp[mCount++] = colors[i-3];
|
||||
|
||||
mVerticesp[mCount] = verts[i-1];
|
||||
mTexcoordsp[mCount] = uvs[i-1];
|
||||
mColorsp[mCount++] = colors[i-1];
|
||||
|
||||
//copy last one
|
||||
mVerticesp[mCount] = verts[i];
|
||||
mTexcoordsp[mCount] = uvs[i];
|
||||
mColorsp[mCount++] = colors[i++];
|
||||
}
|
||||
}
|
||||
else
|
||||
for (S32 i = 0; i < vert_count; i++)
|
||||
{
|
||||
for (S32 i = 0; i < vert_count; i++)
|
||||
{
|
||||
mVerticesp[mCount] = verts[i];
|
||||
mTexcoordsp[mCount] = uvs[i];
|
||||
mColorsp[mCount] = colors[i];
|
||||
|
||||
mCount++;
|
||||
}
|
||||
mVerticesp[mCount] = verts[i];
|
||||
mTexcoordsp[mCount] = uvs[i];
|
||||
mColorsp[mCount] = colors[i];
|
||||
|
||||
mCount++;
|
||||
}
|
||||
|
||||
mVerticesp[mCount] = mVerticesp[mCount-1];
|
||||
|
||||
@@ -281,7 +281,6 @@ public:
|
||||
POINTS,
|
||||
LINES,
|
||||
LINE_STRIP,
|
||||
QUADS,
|
||||
LINE_LOOP,
|
||||
NUM_MODES
|
||||
} eGeomModes;
|
||||
@@ -471,7 +470,6 @@ private:
|
||||
LLColor4 mAmbientLightColor;
|
||||
|
||||
bool mDirty;
|
||||
U32 mQuadCycle;
|
||||
U32 mCount;
|
||||
U32 mMode;
|
||||
U32 mCurrTextureUnitIndex;
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -371,7 +371,6 @@ U32 LLVertexBuffer::sGLMode[LLRender::NUM_MODES] =
|
||||
GL_POINTS,
|
||||
GL_LINES,
|
||||
GL_LINE_STRIP,
|
||||
GL_QUADS,
|
||||
GL_LINE_LOOP,
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user