aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/linden/indra/llrender
diff options
context:
space:
mode:
Diffstat (limited to 'linden/indra/llrender')
-rw-r--r--linden/indra/llrender/files.lst2
-rw-r--r--linden/indra/llrender/llfontgl.cpp73
-rw-r--r--linden/indra/llrender/llglimmediate.cpp354
-rw-r--r--linden/indra/llrender/llglimmediate.h104
-rw-r--r--linden/indra/llrender/llimagegl.cpp18
-rw-r--r--linden/indra/llrender/llimagegl.h3
-rw-r--r--linden/indra/llrender/llrender.vcproj12
-rw-r--r--linden/indra/llrender/llrender_vc8.vcproj642
-rw-r--r--linden/indra/llrender/llrender_vc9.vcproj644
-rw-r--r--linden/indra/llrender/llrendertarget.cpp185
-rw-r--r--linden/indra/llrender/llrendertarget.h116
-rw-r--r--linden/indra/llrender/llvertexbuffer.cpp538
-rw-r--r--linden/indra/llrender/llvertexbuffer.h67
13 files changed, 1815 insertions, 943 deletions
diff --git a/linden/indra/llrender/files.lst b/linden/indra/llrender/files.lst
index a4d541e..3ada47b 100644
--- a/linden/indra/llrender/files.lst
+++ b/linden/indra/llrender/files.lst
@@ -1,5 +1,7 @@
1llrender/llfont.cpp 1llrender/llfont.cpp
2llrender/llfontgl.cpp 2llrender/llfontgl.cpp
3llrender/llgldbg.cpp 3llrender/llgldbg.cpp
4llrender/llglimmediate.cpp
4llrender/llimagegl.cpp 5llrender/llimagegl.cpp
6llrender/llrendertarget.cpp
5llrender/llvertexbuffer.cpp 7llrender/llvertexbuffer.cpp
diff --git a/linden/indra/llrender/llfontgl.cpp b/linden/indra/llrender/llfontgl.cpp
index 99f68d6..bb60b70 100644
--- a/linden/indra/llrender/llfontgl.cpp
+++ b/linden/indra/llrender/llfontgl.cpp
@@ -36,6 +36,7 @@
36#include "llfont.h" 36#include "llfont.h"
37#include "llfontgl.h" 37#include "llfontgl.h"
38#include "llgl.h" 38#include "llgl.h"
39#include "llglimmediate.h"
39#include "v4color.h" 40#include "v4color.h"
40#include "llstl.h" 41#include "llstl.h"
41 42
@@ -556,8 +557,8 @@ S32 LLFontGL::render(const LLWString &wstr,
556 BOOL use_embedded, 557 BOOL use_embedded,
557 BOOL use_ellipses) const 558 BOOL use_ellipses) const
558{ 559{
559 LLGLEnable texture_2d(GL_TEXTURE_2D); 560 LLGLEnable tex(GL_TEXTURE_2D);
560 561
561 if (wstr.empty()) 562 if (wstr.empty())
562 { 563 {
563 return 0; 564 return 0;
@@ -593,9 +594,9 @@ S32 LLFontGL::render(const LLWString &wstr,
593 } 594 }
594 } 595 }
595 596
596 glPushMatrix(); 597 gGL.pushMatrix();
597 glLoadIdentity(); 598 glLoadIdentity();
598 glTranslatef(floorf(sCurOrigin.mX*sScaleX), floorf(sCurOrigin.mY*sScaleY), sCurOrigin.mZ); 599 gGL.translatef(floorf(sCurOrigin.mX*sScaleX), floorf(sCurOrigin.mY*sScaleY), sCurOrigin.mZ);
599 //glScalef(sScaleX, sScaleY, 1.0f); 600 //glScalef(sScaleX, sScaleY, 1.0f);
600 601
601 // avoid half pixels 602 // avoid half pixels
@@ -604,20 +605,20 @@ S32 LLFontGL::render(const LLWString &wstr,
604 //F32 half_pixel_distance = llabs(fmodf(sCurOrigin.mX * sScaleX, 1.f) - 0.5f); 605 //F32 half_pixel_distance = llabs(fmodf(sCurOrigin.mX * sScaleX, 1.f) - 0.5f);
605 //if (half_pixel_distance < PIXEL_BORDER_THRESHOLD) 606 //if (half_pixel_distance < PIXEL_BORDER_THRESHOLD)
606 //{ 607 //{
607 glTranslatef(PIXEL_CORRECTION_DISTANCE*sScaleX, 0.f, 0.f); 608 gGL.translatef(PIXEL_CORRECTION_DISTANCE*sScaleX, 0.f, 0.f);
608 //} 609 //}
609 610
610 // this code would just snap to pixel grid, although it seems to introduce more jitter 611 // this code would just snap to pixel grid, although it seems to introduce more jitter
611 //F32 pixel_offset_x = llround(sCurOrigin.mX * sScaleX) - (sCurOrigin.mX * sScaleX); 612 //F32 pixel_offset_x = llround(sCurOrigin.mX * sScaleX) - (sCurOrigin.mX * sScaleX);
612 //F32 pixel_offset_y = llround(sCurOrigin.mY * sScaleY) - (sCurOrigin.mY * sScaleY); 613 //F32 pixel_offset_y = llround(sCurOrigin.mY * sScaleY) - (sCurOrigin.mY * sScaleY);
613 //glTranslatef(-pixel_offset_x, -pixel_offset_y, 0.f); 614 //gGL.translatef(-pixel_offset_x, -pixel_offset_y, 0.f);
614 615
615 // scale back to native pixel size 616 // scale back to native pixel size
616 //glScalef(1.f / sScaleX, 1.f / sScaleY, 1.f); 617 //glScalef(1.f / sScaleX, 1.f / sScaleY, 1.f);
617 //glScaled(1.0 / (F64) sScaleX, 1.0 / (F64) sScaleY, 1.0f); 618 //glScaled(1.0 / (F64) sScaleX, 1.0 / (F64) sScaleY, 1.0f);
618 LLFastTimer t(LLFastTimer::FTM_RENDER_FONTS); 619 LLFastTimer t(LLFastTimer::FTM_RENDER_FONTS);
619 620
620 glColor4fv( color.mV ); 621 gGL.color4fv( color.mV );
621 622
622 S32 chars_drawn = 0; 623 S32 chars_drawn = 0;
623 S32 i; 624 S32 i;
@@ -638,7 +639,7 @@ S32 LLFontGL::render(const LLWString &wstr,
638 639
639 mImageGLp->bind(0); 640 mImageGLp->bind(0);
640 641
641 glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); // Not guaranteed to be set correctly 642 gGL.blendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); // Not guaranteed to be set correctly
642 643
643 cur_x = ((F32)x * sScaleX); 644 cur_x = ((F32)x * sScaleX);
644 cur_y = ((F32)y * sScaleY); 645 cur_y = ((F32)y * sScaleY);
@@ -743,9 +744,9 @@ S32 LLFontGL::render(const LLWString &wstr,
743 744
744 if (!label.empty()) 745 if (!label.empty())
745 { 746 {
746 glPushMatrix(); 747 gGL.pushMatrix();
747 //glLoadIdentity(); 748 //glLoadIdentity();
748 //glTranslatef(sCurOrigin.mX, sCurOrigin.mY, 0.0f); 749 //gGL.translatef(sCurOrigin.mX, sCurOrigin.mY, 0.0f);
749 //glScalef(sScaleX, sScaleY, 1.f); 750 //glScalef(sScaleX, sScaleY, 1.f);
750 gExtCharFont->render(label, 0, 751 gExtCharFont->render(label, 0,
751 /*llfloor*/((ext_x + (F32)ext_image->getWidth() + EXT_X_BEARING) / sScaleX), 752 /*llfloor*/((ext_x + (F32)ext_image->getWidth() + EXT_X_BEARING) / sScaleX),
@@ -753,10 +754,10 @@ S32 LLFontGL::render(const LLWString &wstr,
753 color, 754 color,
754 halign, BASELINE, NORMAL, S32_MAX, S32_MAX, NULL, 755 halign, BASELINE, NORMAL, S32_MAX, S32_MAX, NULL,
755 TRUE ); 756 TRUE );
756 glPopMatrix(); 757 gGL.popMatrix();
757 } 758 }
758 759
759 glColor4fv(color.mV); 760 gGL.color4fv(color.mV);
760 761
761 chars_drawn++; 762 chars_drawn++;
762 cur_x += ext_advance; 763 cur_x += ext_advance;
@@ -836,10 +837,10 @@ S32 LLFontGL::render(const LLWString &wstr,
836 if (style & UNDERLINE) 837 if (style & UNDERLINE)
837 { 838 {
838 LLGLSNoTexture no_texture; 839 LLGLSNoTexture no_texture;
839 glBegin(GL_LINES); 840 gGL.begin(GL_LINES);
840 glVertex2f(start_x, cur_y - (mDescender)); 841 gGL.vertex2f(start_x, cur_y - (mDescender));
841 glVertex2f(cur_x, cur_y - (mDescender)); 842 gGL.vertex2f(cur_x, cur_y - (mDescender));
842 glEnd(); 843 gGL.end();
843 } 844 }
844 845
845 // *FIX: get this working in all alignment cases, etc. 846 // *FIX: get this working in all alignment cases, etc.
@@ -847,9 +848,9 @@ S32 LLFontGL::render(const LLWString &wstr,
847 { 848 {
848 // recursively render ellipses at end of string 849 // recursively render ellipses at end of string
849 // we've already reserved enough room 850 // we've already reserved enough room
850 glPushMatrix(); 851 gGL.pushMatrix();
851 //glLoadIdentity(); 852 //glLoadIdentity();
852 //glTranslatef(sCurOrigin.mX, sCurOrigin.mY, 0.0f); 853 //gGL.translatef(sCurOrigin.mX, sCurOrigin.mY, 0.0f);
853 //glScalef(sScaleX, sScaleY, 1.f); 854 //glScalef(sScaleX, sScaleY, 1.f);
854 renderUTF8("...", 855 renderUTF8("...",
855 0, 856 0,
@@ -860,10 +861,10 @@ S32 LLFontGL::render(const LLWString &wstr,
860 S32_MAX, max_pixels, 861 S32_MAX, max_pixels,
861 right_x, 862 right_x,
862 FALSE); 863 FALSE);
863 glPopMatrix(); 864 gGL.popMatrix();
864 } 865 }
865 866
866 glPopMatrix(); 867 gGL.popMatrix();
867 868
868 return chars_drawn; 869 return chars_drawn;
869} 870}
@@ -1309,20 +1310,20 @@ void LLFontGL::removeEmbeddedChar( llwchar wc )
1309 1310
1310void LLFontGL::renderQuad(const LLRectf& screen_rect, const LLRectf& uv_rect, F32 slant_amt) const 1311void LLFontGL::renderQuad(const LLRectf& screen_rect, const LLRectf& uv_rect, F32 slant_amt) const
1311{ 1312{
1312 glTexCoord2f(uv_rect.mRight, uv_rect.mTop); 1313 gGL.texCoord2f(uv_rect.mRight, uv_rect.mTop);
1313 glVertex2f(llfont_round_x(screen_rect.mRight), 1314 gGL.vertex2f(llfont_round_x(screen_rect.mRight),
1314 llfont_round_y(screen_rect.mTop)); 1315 llfont_round_y(screen_rect.mTop));
1315 1316
1316 glTexCoord2f(uv_rect.mLeft, uv_rect.mTop); 1317 gGL.texCoord2f(uv_rect.mLeft, uv_rect.mTop);
1317 glVertex2f(llfont_round_x(screen_rect.mLeft), 1318 gGL.vertex2f(llfont_round_x(screen_rect.mLeft),
1318 llfont_round_y(screen_rect.mTop)); 1319 llfont_round_y(screen_rect.mTop));
1319 1320
1320 glTexCoord2f(uv_rect.mLeft, uv_rect.mBottom); 1321 gGL.texCoord2f(uv_rect.mLeft, uv_rect.mBottom);
1321 glVertex2f(llfont_round_x(screen_rect.mLeft + slant_amt), 1322 gGL.vertex2f(llfont_round_x(screen_rect.mLeft + slant_amt),
1322 llfont_round_y(screen_rect.mBottom)); 1323 llfont_round_y(screen_rect.mBottom));
1323 1324
1324 glTexCoord2f(uv_rect.mRight, uv_rect.mBottom); 1325 gGL.texCoord2f(uv_rect.mRight, uv_rect.mBottom);
1325 glVertex2f(llfont_round_x(screen_rect.mRight + slant_amt), 1326 gGL.vertex2f(llfont_round_x(screen_rect.mRight + slant_amt),
1326 llfont_round_y(screen_rect.mBottom)); 1327 llfont_round_y(screen_rect.mBottom));
1327} 1328}
1328 1329
@@ -1331,13 +1332,13 @@ void LLFontGL::drawGlyph(const LLRectf& screen_rect, const LLRectf& uv_rect, con
1331 F32 slant_offset; 1332 F32 slant_offset;
1332 slant_offset = ((style & ITALIC) ? ( -mAscender * 0.2f) : 0.f); 1333 slant_offset = ((style & ITALIC) ? ( -mAscender * 0.2f) : 0.f);
1333 1334
1334 glBegin(GL_QUADS); 1335 gGL.begin(GL_QUADS);
1335 { 1336 {
1336 //FIXME: bold and drop shadow are mutually exclusive only for convenience 1337 //FIXME: bold and drop shadow are mutually exclusive only for convenience
1337 //Allow both when we need them. 1338 //Allow both when we need them.
1338 if (style & BOLD) 1339 if (style & BOLD)
1339 { 1340 {
1340 glColor4fv(color.mV); 1341 gGL.color4fv(color.mV);
1341 for (S32 pass = 0; pass < 2; pass++) 1342 for (S32 pass = 0; pass < 2; pass++)
1342 { 1343 {
1343 LLRectf screen_rect_offset = screen_rect; 1344 LLRectf screen_rect_offset = screen_rect;
@@ -1350,7 +1351,7 @@ void LLFontGL::drawGlyph(const LLRectf& screen_rect, const LLRectf& uv_rect, con
1350 { 1351 {
1351 LLColor4 shadow_color = LLFontGL::sShadowColor; 1352 LLColor4 shadow_color = LLFontGL::sShadowColor;
1352 shadow_color.mV[VALPHA] = color.mV[VALPHA] * drop_shadow_strength * DROP_SHADOW_SOFT_STRENGTH; 1353 shadow_color.mV[VALPHA] = color.mV[VALPHA] * drop_shadow_strength * DROP_SHADOW_SOFT_STRENGTH;
1353 glColor4fv(shadow_color.mV); 1354 gGL.color4fv(shadow_color.mV);
1354 for (S32 pass = 0; pass < 5; pass++) 1355 for (S32 pass = 0; pass < 5; pass++)
1355 { 1356 {
1356 LLRectf screen_rect_offset = screen_rect; 1357 LLRectf screen_rect_offset = screen_rect;
@@ -1376,28 +1377,28 @@ void LLFontGL::drawGlyph(const LLRectf& screen_rect, const LLRectf& uv_rect, con
1376 1377
1377 renderQuad(screen_rect_offset, uv_rect, slant_offset); 1378 renderQuad(screen_rect_offset, uv_rect, slant_offset);
1378 } 1379 }
1379 glColor4fv(color.mV); 1380 gGL.color4fv(color.mV);
1380 renderQuad(screen_rect, uv_rect, slant_offset); 1381 renderQuad(screen_rect, uv_rect, slant_offset);
1381 } 1382 }
1382 else if (style & DROP_SHADOW) 1383 else if (style & DROP_SHADOW)
1383 { 1384 {
1384 LLColor4 shadow_color = LLFontGL::sShadowColor; 1385 LLColor4 shadow_color = LLFontGL::sShadowColor;
1385 shadow_color.mV[VALPHA] = color.mV[VALPHA] * drop_shadow_strength; 1386 shadow_color.mV[VALPHA] = color.mV[VALPHA] * drop_shadow_strength;
1386 glColor4fv(shadow_color.mV); 1387 gGL.color4fv(shadow_color.mV);
1387 LLRectf screen_rect_shadow = screen_rect; 1388 LLRectf screen_rect_shadow = screen_rect;
1388 screen_rect_shadow.translate(1.f, -1.f); 1389 screen_rect_shadow.translate(1.f, -1.f);
1389 renderQuad(screen_rect_shadow, uv_rect, slant_offset); 1390 renderQuad(screen_rect_shadow, uv_rect, slant_offset);
1390 glColor4fv(color.mV); 1391 gGL.color4fv(color.mV);
1391 renderQuad(screen_rect, uv_rect, slant_offset); 1392 renderQuad(screen_rect, uv_rect, slant_offset);
1392 } 1393 }
1393 else // normal rendering 1394 else // normal rendering
1394 { 1395 {
1395 glColor4fv(color.mV); 1396 gGL.color4fv(color.mV);
1396 renderQuad(screen_rect, uv_rect, slant_offset); 1397 renderQuad(screen_rect, uv_rect, slant_offset);
1397 } 1398 }
1398 1399
1399 } 1400 }
1400 glEnd(); 1401 gGL.end();
1401} 1402}
1402 1403
1403// static 1404// static
diff --git a/linden/indra/llrender/llglimmediate.cpp b/linden/indra/llrender/llglimmediate.cpp
new file mode 100644
index 0000000..db62f3d
--- /dev/null
+++ b/linden/indra/llrender/llglimmediate.cpp
@@ -0,0 +1,354 @@
1/**
2 * @file llglimmediate.cpp
3 * @brief LLGLImmediate implementation
4 *
5 * $LicenseInfo:firstyear=2001&license=viewergpl$
6 *
7 * Copyright (c) 2001-2008, Linden Research, Inc.
8 *
9 * Second Life Viewer Source Code
10 * The source code in this file ("Source Code") is provided by Linden Lab
11 * to you under the terms of the GNU General Public License, version 2.0
12 * ("GPL"), unless you have obtained a separate licensing agreement
13 * ("Other License"), formally executed by you and Linden Lab. Terms of
14 * the GPL can be found in doc/GPL-license.txt in this distribution, or
15 * online at http://secondlifegrid.net/programs/open_source/licensing/gplv2
16 *
17 * There are special exceptions to the terms and conditions of the GPL as
18 * it is applied to this Source Code. View the full text of the exception
19 * in the file doc/FLOSS-exception.txt in this software distribution, or
20 * online at http://secondlifegrid.net/programs/open_source/licensing/flossexception
21 *
22 * By copying, modifying or distributing this software, you acknowledge
23 * that you have read and understood your obligations described above,
24 * and agree to abide by those obligations.
25 *
26 * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO
27 * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY,
28 * COMPLETENESS OR PERFORMANCE.
29 * $/LicenseInfo$
30 */
31
32#include "linden_common.h"
33
34#include "llglimmediate.h"
35#include "llvertexbuffer.h"
36
37LLGLImmediate gGL;
38
39#ifdef LL_RELEASE_FOR_DOWNLOAD
40#define IMM_ERRS llwarns
41#else
42#define IMM_ERRS llerrs
43#endif
44
45bool LLGLImmediate::sClever = false;
46
47static BOOL sStarted = FALSE;
48
49LLGLImmediate::LLGLImmediate()
50{
51 mCount = 0;
52 mMode = GL_TRIANGLES;
53 memset(mBuffer, 0, sizeof(Vertex)*4096);
54}
55
56void LLGLImmediate::start()
57{
58 if(sClever)
59 {
60 if (sStarted)
61 {
62 llerrs << "Redundant start." << llendl;
63 }
64
65 sStarted = TRUE;
66 LLVertexBuffer::unbind();
67
68 glEnableClientState(GL_VERTEX_ARRAY);
69 glEnableClientState(GL_TEXTURE_COORD_ARRAY);
70 glEnableClientState(GL_COLOR_ARRAY);
71
72 const U32 stride = sizeof(Vertex);
73
74 glVertexPointer(3, GL_FLOAT, stride, &(mBuffer[0].v));
75 glTexCoordPointer(2, GL_FLOAT, stride, &(mBuffer[0].uv));
76 glColorPointer(4, GL_UNSIGNED_BYTE, stride, &(mBuffer[0].c));
77
78 color4f(1,1,1,1);
79 }
80}
81
82void LLGLImmediate::stop()
83{
84 if (sClever)
85 {
86 if (!sStarted)
87 {
88 llerrs << "Redundant stop." << llendl;
89 }
90
91 flush();
92
93 sStarted = FALSE;
94
95 glDisableClientState(GL_TEXTURE_COORD_ARRAY);
96 glDisableClientState(GL_COLOR_ARRAY);
97 }
98}
99
100void LLGLImmediate::translatef(const GLfloat& x, const GLfloat& y, const GLfloat& z)
101{
102 flush();
103 glTranslatef(x,y,z);
104}
105
106void LLGLImmediate::pushMatrix()
107{
108 flush();
109 glPushMatrix();
110}
111
112void LLGLImmediate::popMatrix()
113{
114 flush();
115 glPopMatrix();
116}
117
118void LLGLImmediate::blendFunc(GLenum sfactor, GLenum dfactor)
119{
120 if (sStarted)
121 {
122 flush();
123 }
124 glBlendFunc(sfactor, dfactor);
125}
126
127void LLGLImmediate::begin(const GLuint& mode)
128{
129 if (sClever)
130 {
131 if (mode != mMode)
132 {
133 if (mMode == GL_QUADS ||
134 mMode == GL_LINES ||
135 mMode == GL_TRIANGLES ||
136 mMode == GL_POINTS)
137 {
138 flush();
139 }
140 else if (mCount != 0)
141 {
142 llerrs << "gGL.begin() called redundantly." << llendl;
143 }
144
145 mMode = mode;
146 }
147 }
148 else
149 {
150 glBegin(mode);
151 }
152}
153
154void LLGLImmediate::end()
155{
156 if (sClever)
157 {
158 if (mCount == 0)
159 {
160 IMM_ERRS << "GL begin and end called with no vertices specified." << llendl;
161 }
162
163 if ((mMode != GL_QUADS &&
164 mMode != GL_LINES &&
165 mMode != GL_TRIANGLES &&
166 mMode != GL_POINTS) ||
167 mCount > 2048)
168 {
169 flush();
170 }
171 }
172 else
173 {
174 glEnd();
175 }
176}
177
178void LLGLImmediate::flush()
179{
180 if (sClever)
181 {
182 if (mCount > 0)
183 {
184#if 0
185 if (!glIsEnabled(GL_VERTEX_ARRAY))
186 {
187 llerrs << "foo 1" << llendl;
188 }
189
190 if (!glIsEnabled(GL_COLOR_ARRAY))
191 {
192 llerrs << "foo 2" << llendl;
193 }
194
195 if (!glIsEnabled(GL_TEXTURE_COORD_ARRAY))
196 {
197 llerrs << "foo 3" << llendl;
198 }
199
200 if (glIsEnabled(GL_NORMAL_ARRAY))
201 {
202 llerrs << "foo 7" << llendl;
203 }
204
205 GLvoid* pointer;
206
207 glGetPointerv(GL_VERTEX_ARRAY_POINTER, &pointer);
208 if (pointer != &(mBuffer[0].v))
209 {
210 llerrs << "foo 4" << llendl;
211 }
212
213 glGetPointerv(GL_COLOR_ARRAY_POINTER, &pointer);
214 if (pointer != &(mBuffer[0].c))
215 {
216 llerrs << "foo 5" << llendl;
217 }
218
219 glGetPointerv(GL_TEXTURE_COORD_ARRAY_POINTER, &pointer);
220 if (pointer != &(mBuffer[0].uv))
221 {
222 llerrs << "foo 6" << llendl;
223 }
224#endif
225 if (!sStarted)
226 {
227 llerrs << "Drawing call issued outside start/stop." << llendl;
228 }
229 glDrawArrays(mMode, 0, mCount);
230 mBuffer[0] = mBuffer[mCount];
231 mCount = 0;
232 }
233 }
234}
235
236void LLGLImmediate::vertex3f(const GLfloat& x, const GLfloat& y, const GLfloat& z)
237{
238 if (sClever)
239 {
240 if (mCount >= 4096)
241 {
242 // llwarns << "GL immediate mode overflow. Some geometry not drawn." << llendl;
243 return;
244 }
245
246 mBuffer[mCount].v[0] = x;
247 mBuffer[mCount].v[1] = y;
248 mBuffer[mCount].v[2] = z;
249 mCount++;
250 if (mCount < 4096)
251 {
252 mBuffer[mCount] = mBuffer[mCount-1];
253 }
254 }
255 else
256 {
257 glVertex3f(x,y,z);
258 }
259}
260
261void LLGLImmediate::vertex2i(const GLint& x, const GLint& y)
262{
263 vertex3f((GLfloat) x, (GLfloat) y, 0);
264}
265
266void LLGLImmediate::vertex2f(const GLfloat& x, const GLfloat& y)
267{
268 vertex3f(x,y,0);
269}
270
271void LLGLImmediate::vertex2fv(const GLfloat* v)
272{
273 vertex3f(v[0], v[1], 0);
274}
275
276void LLGLImmediate::vertex3fv(const GLfloat* v)
277{
278 vertex3f(v[0], v[1], v[2]);
279}
280
281void LLGLImmediate::texCoord2f(const GLfloat& x, const GLfloat& y)
282{
283 if (sClever)
284 {
285 mBuffer[mCount].uv[0] = x;
286 mBuffer[mCount].uv[1] = y;
287 }
288 else
289 {
290 glTexCoord2f(x,y);
291 }
292}
293
294void LLGLImmediate::texCoord2i(const GLint& x, const GLint& y)
295{
296 texCoord2f((GLfloat) x, (GLfloat) y);
297}
298
299void LLGLImmediate::texCoord2fv(const GLfloat* tc)
300{
301 texCoord2f(tc[0], tc[1]);
302}
303
304void LLGLImmediate::color4ub(const GLubyte& r, const GLubyte& g, const GLubyte& b, const GLubyte& a)
305{
306 if (sClever)
307 {
308 mBuffer[mCount].c[0] = r;
309 mBuffer[mCount].c[1] = g;
310 mBuffer[mCount].c[2] = b;
311 mBuffer[mCount].c[3] = a;
312 }
313 else
314 {
315 glColor4ub(r,g,b,a);
316 }
317}
318
319void LLGLImmediate::color4ubv(const GLubyte* c)
320{
321 color4ub(c[0], c[1], c[2], c[3]);
322}
323
324void LLGLImmediate::color4f(const GLfloat& r, const GLfloat& g, const GLfloat& b, const GLfloat& a)
325{
326 color4ub((GLubyte) (llclamp(r, 0.f, 1.f)*255),
327 (GLubyte) (llclamp(g, 0.f, 1.f)*255),
328 (GLubyte) (llclamp(b, 0.f, 1.f)*255),
329 (GLubyte) (llclamp(a, 0.f, 1.f)*255));
330}
331
332void LLGLImmediate::color4fv(const GLfloat* c)
333{
334 color4f(c[0],c[1],c[2],c[3]);
335}
336
337void LLGLImmediate::color3f(const GLfloat& r, const GLfloat& g, const GLfloat& b)
338{
339 color4f(r,g,b,1);
340}
341
342void LLGLImmediate::color3fv(const GLfloat* c)
343{
344 color4f(c[0],c[1],c[2],1);
345}
346
347void LLGLImmediate::setClever(bool do_clever)
348{
349 llassert(!sStarted);
350 llassert(mCount == 0);
351
352 sClever = do_clever;
353}
354
diff --git a/linden/indra/llrender/llglimmediate.h b/linden/indra/llrender/llglimmediate.h
new file mode 100644
index 0000000..bf2f9ab
--- /dev/null
+++ b/linden/indra/llrender/llglimmediate.h
@@ -0,0 +1,104 @@
1/**
2 * @file llglimmediate.h
3 * @brief LLGLImmediate definition
4 *
5 * This class acts as a wrapper for OpenGL immediate calls concerning glBegin and glEnd.
6 * The goal of this class is to minimize the number of api calls due to legacy rendering
7 * code, and to define an interface for a multiple rendering API abstraction of the UI
8 * rendering.
9 *
10 * $LicenseInfo:firstyear=2001&license=viewergpl$
11 *
12 * Copyright (c) 2001-2008, Linden Research, Inc.
13 *
14 * Second Life Viewer Source Code
15 * The source code in this file ("Source Code") is provided by Linden Lab
16 * to you under the terms of the GNU General Public License, version 2.0
17 * ("GPL"), unless you have obtained a separate licensing agreement
18 * ("Other License"), formally executed by you and Linden Lab. Terms of
19 * the GPL can be found in doc/GPL-license.txt in this distribution, or
20 * online at http://secondlifegrid.net/programs/open_source/licensing/gplv2
21 *
22 * There are special exceptions to the terms and conditions of the GPL as
23 * it is applied to this Source Code. View the full text of the exception
24 * in the file doc/FLOSS-exception.txt in this software distribution, or
25 * online at http://secondlifegrid.net/programs/open_source/licensing/flossexception
26 *
27 * By copying, modifying or distributing this software, you acknowledge
28 * that you have read and understood your obligations described above,
29 * and agree to abide by those obligations.
30 *
31 * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO
32 * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY,
33 * COMPLETENESS OR PERFORMANCE.
34 * $/LicenseInfo$
35 */
36
37#ifndef LL_LLGLIMMEDIATE_H
38#define LL_LLGLIMMEDIATE_H
39
40#include "stdtypes.h"
41#include "llgltypes.h"
42#include "llglheaders.h"
43
44class LLGLImmediate
45{
46public:
47 LLGLImmediate();
48
49 void translatef(const GLfloat& x, const GLfloat& y, const GLfloat& z);
50 void pushMatrix();
51 void popMatrix();
52 void blendFunc(GLenum sfactor, GLenum dfactor);
53 void start();
54 void stop();
55 void flush();
56
57 void begin(const GLuint& mode);
58 void end();
59 void vertex2i(const GLint& x, const GLint& y);
60 void vertex2f(const GLfloat& x, const GLfloat& y);
61 void vertex3f(const GLfloat& x, const GLfloat& y, const GLfloat& z);
62 void vertex2fv(const GLfloat* v);
63 void vertex3fv(const GLfloat* v);
64
65 void texCoord2i(const GLint& x, const GLint& y);
66 void texCoord2f(const GLfloat& x, const GLfloat& y);
67 void texCoord2fv(const GLfloat* tc);
68
69 void color4ub(const GLubyte& r, const GLubyte& g, const GLubyte& b, const GLubyte& a);
70 void color4f(const GLfloat& r, const GLfloat& g, const GLfloat& b, const GLfloat& a);
71 void color4fv(const GLfloat* c);
72 void color3f(const GLfloat& r, const GLfloat& g, const GLfloat& b);
73 void color3fv(const GLfloat* c);
74 void color4ubv(const GLubyte* c);
75
76 // switch clever mode GL immediate rendering on or off. Setting to true builds
77 // client arrays manually, setting to false passes through the GL immediate mode
78 // commands to the GL implementation. Controllable by the RenderUseCleverUI
79 // debug setting.
80 // *NOTE: I have measured that this has about a 9% performance cost (0.6ms) for the
81 // Render/UI fasttimer vs the old #if CLEVER compile time switch. Dave Parks and I
82 // agreed that this was acceptable at the time due to it enabling better regression
83 // testing for QA.
84 // -Brad
85 void setClever(bool do_clever);
86
87 typedef struct Vertex
88 {
89 GLfloat v[3];
90 GLubyte c[4];
91 GLfloat uv[2];
92 };
93
94private:
95 static bool sClever;
96
97 U32 mCount;
98 U32 mMode;
99 Vertex mBuffer[4096];
100};
101
102extern LLGLImmediate gGL;
103
104#endif
diff --git a/linden/indra/llrender/llimagegl.cpp b/linden/indra/llrender/llimagegl.cpp
index b2b08e0..76c8252 100644
--- a/linden/indra/llrender/llimagegl.cpp
+++ b/linden/indra/llrender/llimagegl.cpp
@@ -41,6 +41,8 @@
41 41
42#include "llmath.h" 42#include "llmath.h"
43#include "llgl.h" 43#include "llgl.h"
44#include "llglimmediate.h"
45
44 46
45//---------------------------------------------------------------------------- 47//----------------------------------------------------------------------------
46 48
@@ -49,6 +51,8 @@ const F32 MIN_TEXTURE_LIFETIME = 10.f;
49//statics 51//statics
50LLGLuint LLImageGL::sCurrentBoundTextures[MAX_GL_TEXTURE_UNITS] = { 0 }; 52LLGLuint LLImageGL::sCurrentBoundTextures[MAX_GL_TEXTURE_UNITS] = { 0 };
51 53
54U32 LLImageGL::sUniqueCount = 0;
55U32 LLImageGL::sBindCount = 0;
52S32 LLImageGL::sGlobalTextureMemory = 0; 56S32 LLImageGL::sGlobalTextureMemory = 0;
53S32 LLImageGL::sBoundTextureMemory = 0; 57S32 LLImageGL::sBoundTextureMemory = 0;
54S32 LLImageGL::sCurBoundTextureMemory = 0; 58S32 LLImageGL::sCurBoundTextureMemory = 0;
@@ -123,6 +127,7 @@ S32 LLImageGL::dataFormatComponents(S32 dataformat)
123// static 127// static
124void LLImageGL::bindExternalTexture(LLGLuint gl_name, S32 stage, LLGLenum bind_target ) 128void LLImageGL::bindExternalTexture(LLGLuint gl_name, S32 stage, LLGLenum bind_target )
125{ 129{
130 gGL.flush();
126 glActiveTextureARB(GL_TEXTURE0_ARB + stage); 131 glActiveTextureARB(GL_TEXTURE0_ARB + stage);
127 glClientActiveTextureARB(GL_TEXTURE0_ARB + stage); 132 glClientActiveTextureARB(GL_TEXTURE0_ARB + stage);
128 glBindTexture(bind_target, gl_name); 133 glBindTexture(bind_target, gl_name);
@@ -135,6 +140,7 @@ void LLImageGL::unbindTexture(S32 stage, LLGLenum bind_target)
135 // LLGLSLShader can return -1 140 // LLGLSLShader can return -1
136 if (stage >= 0) 141 if (stage >= 0)
137 { 142 {
143 gGL.flush();
138 glActiveTextureARB(GL_TEXTURE0_ARB + stage); 144 glActiveTextureARB(GL_TEXTURE0_ARB + stage);
139 glClientActiveTextureARB(GL_TEXTURE0_ARB + stage); 145 glClientActiveTextureARB(GL_TEXTURE0_ARB + stage);
140 glBindTexture(bind_target, 0); 146 glBindTexture(bind_target, 0);
@@ -148,6 +154,7 @@ void LLImageGL::unbindTexture(S32 stage)
148 // LLGLSLShader can return -1 154 // LLGLSLShader can return -1
149 if (stage >= 0) 155 if (stage >= 0)
150 { 156 {
157 gGL.flush();
151 glActiveTextureARB(GL_TEXTURE0_ARB + stage); 158 glActiveTextureARB(GL_TEXTURE0_ARB + stage);
152 glClientActiveTextureARB(GL_TEXTURE0_ARB + stage); 159 glClientActiveTextureARB(GL_TEXTURE0_ARB + stage);
153 glBindTexture(GL_TEXTURE_2D, 0); 160 glBindTexture(GL_TEXTURE_2D, 0);
@@ -411,6 +418,7 @@ BOOL LLImageGL::bindTextureInternal(const S32 stage) const
411 llwarns << "Trying to bind a texture while GL is disabled!" << llendl; 418 llwarns << "Trying to bind a texture while GL is disabled!" << llendl;
412 } 419 }
413 420
421
414 glActiveTextureARB(GL_TEXTURE0_ARB + stage); 422 glActiveTextureARB(GL_TEXTURE0_ARB + stage);
415 423
416 if (sCurrentBoundTextures[stage] && sCurrentBoundTextures[stage] == mTexName) 424 if (sCurrentBoundTextures[stage] && sCurrentBoundTextures[stage] == mTexName)
@@ -425,12 +433,15 @@ BOOL LLImageGL::bindTextureInternal(const S32 stage) const
425 mMissed = ! getIsResident(TRUE); 433 mMissed = ! getIsResident(TRUE);
426#endif 434#endif
427 435
436 gGL.flush();
428 glBindTexture(mBindTarget, mTexName); 437 glBindTexture(mBindTarget, mTexName);
429 sCurrentBoundTextures[stage] = mTexName; 438 sCurrentBoundTextures[stage] = mTexName;
439 sBindCount++;
430 440
431 if (mLastBindTime != sLastFrameTime) 441 if (mLastBindTime != sLastFrameTime)
432 { 442 {
433 // we haven't accounted for this texture yet this frame 443 // we haven't accounted for this texture yet this frame
444 sUniqueCount++;
434 updateBoundTexMem(mTextureMemory); 445 updateBoundTexMem(mTextureMemory);
435 mLastBindTime = sLastFrameTime; 446 mLastBindTime = sLastFrameTime;
436 } 447 }
@@ -439,6 +450,7 @@ BOOL LLImageGL::bindTextureInternal(const S32 stage) const
439 } 450 }
440 else 451 else
441 { 452 {
453 gGL.flush();
442 glBindTexture(mBindTarget, 0); 454 glBindTexture(mBindTarget, 0);
443 sCurrentBoundTextures[stage] = 0; 455 sCurrentBoundTextures[stage] = 0;
444 return FALSE; 456 return FALSE;
@@ -665,7 +677,6 @@ void LLImageGL::setImage(const U8* data_in, BOOL data_hasmips)
665 } 677 }
666 mHasMipMaps = FALSE; 678 mHasMipMaps = FALSE;
667 } 679 }
668 glFlush();
669 stop_glerror(); 680 stop_glerror();
670} 681}
671 682
@@ -686,7 +697,7 @@ BOOL LLImageGL::setSubImage(const U8* datap, S32 data_width, S32 data_height, S3
686 return FALSE; 697 return FALSE;
687 } 698 }
688 699
689 if (x_pos == 0 && y_pos == 0 && width == getWidth() && height == getHeight()) 700 if (x_pos == 0 && y_pos == 0 && width == getWidth() && height == getHeight() && data_width == width && data_height == height)
690 { 701 {
691 setImage(datap, FALSE); 702 setImage(datap, FALSE);
692 } 703 }
@@ -759,7 +770,7 @@ BOOL LLImageGL::setSubImage(const U8* datap, S32 data_width, S32 data_height, S3
759 glPixelStorei(GL_UNPACK_ROW_LENGTH, 0); 770 glPixelStorei(GL_UNPACK_ROW_LENGTH, 0);
760 stop_glerror(); 771 stop_glerror();
761 } 772 }
762 glFlush(); 773
763 return TRUE; 774 return TRUE;
764} 775}
765 776
@@ -1046,6 +1057,7 @@ void LLImageGL::destroyGLTexture()
1046 { 1057 {
1047 unbindTexture(i, GL_TEXTURE_2D); 1058 unbindTexture(i, GL_TEXTURE_2D);
1048 stop_glerror(); 1059 stop_glerror();
1060 glActiveTextureARB(GL_TEXTURE0_ARB);
1049 } 1061 }
1050 } 1062 }
1051 1063
diff --git a/linden/indra/llrender/llimagegl.h b/linden/indra/llrender/llimagegl.h
index afcb763..efe94c2 100644
--- a/linden/indra/llrender/llimagegl.h
+++ b/linden/indra/llrender/llimagegl.h
@@ -185,7 +185,8 @@ public:
185 static S32 sGlobalTextureMemory; // Tracks main memory texmem 185 static S32 sGlobalTextureMemory; // Tracks main memory texmem
186 static S32 sBoundTextureMemory; // Tracks bound texmem for last completed frame 186 static S32 sBoundTextureMemory; // Tracks bound texmem for last completed frame
187 static S32 sCurBoundTextureMemory; // Tracks bound texmem for current frame 187 static S32 sCurBoundTextureMemory; // Tracks bound texmem for current frame
188 188 static U32 sBindCount; // Tracks number of texture binds for current frame
189 static U32 sUniqueCount; // Tracks number of unique texture binds for current frame
189 static BOOL sGlobalUseAnisotropic; 190 static BOOL sGlobalUseAnisotropic;
190 191
191#if DEBUG_MISS 192#if DEBUG_MISS
diff --git a/linden/indra/llrender/llrender.vcproj b/linden/indra/llrender/llrender.vcproj
index ac9aa2e..2c6e2d2 100644
--- a/linden/indra/llrender/llrender.vcproj
+++ b/linden/indra/llrender/llrender.vcproj
@@ -165,9 +165,15 @@
165 RelativePath=".\llgldbg.cpp"> 165 RelativePath=".\llgldbg.cpp">
166 </File> 166 </File>
167 <File 167 <File
168 RelativePath=".\llglimmediate.cpp">
169 </File>
170 <File
168 RelativePath=".\llimagegl.cpp"> 171 RelativePath=".\llimagegl.cpp">
169 </File> 172 </File>
170 <File 173 <File
174 RelativePath=".\llrendertarget.cpp">
175 </File>
176 <File
171 RelativePath=".\llvertexbuffer.cpp"> 177 RelativePath=".\llvertexbuffer.cpp">
172 </File> 178 </File>
173 </Filter> 179 </Filter>
@@ -200,9 +206,15 @@
200 RelativePath=".\llgldbg.h"> 206 RelativePath=".\llgldbg.h">
201 </File> 207 </File>
202 <File 208 <File
209 RelativePath=".\llglimmediate.h">
210 </File>
211 <File
203 RelativePath=".\llimagegl.h"> 212 RelativePath=".\llimagegl.h">
204 </File> 213 </File>
205 <File 214 <File
215 RelativePath=".\llrendertarget.h">
216 </File>
217 <File
206 RelativePath=".\llvertexbuffer.h"> 218 RelativePath=".\llvertexbuffer.h">
207 </File> 219 </File>
208 <File 220 <File
diff --git a/linden/indra/llrender/llrender_vc8.vcproj b/linden/indra/llrender/llrender_vc8.vcproj
index eb7a9e3..8c0f82a 100644
--- a/linden/indra/llrender/llrender_vc8.vcproj
+++ b/linden/indra/llrender/llrender_vc8.vcproj
@@ -1,313 +1,329 @@
1<?xml version="1.0" encoding="Windows-1252"?> 1<?xml version="1.0" encoding="Windows-1252"?>
2<VisualStudioProject 2<VisualStudioProject
3 ProjectType="Visual C++" 3 ProjectType="Visual C++"
4 Version="8.00" 4 Version="8.00"
5 Name="llrender" 5 Name="llrender"
6 ProjectGUID="{2ADE3C14-94C4-40BF-B033-70F3C954EE90}" 6 ProjectGUID="{2ADE3C14-94C4-40BF-B033-70F3C954EE90}"
7 RootNamespace="llrender" 7 RootNamespace="llrender"
8 Keyword="Win32Proj" 8 Keyword="Win32Proj"
9 > 9 >
10 <Platforms> 10 <Platforms>
11 <Platform 11 <Platform
12 Name="Win32" 12 Name="Win32"
13 /> 13 />
14 </Platforms> 14 </Platforms>
15 <ToolFiles> 15 <ToolFiles>
16 </ToolFiles> 16 </ToolFiles>
17 <Configurations> 17 <Configurations>
18 <Configuration 18 <Configuration
19 Name="Debug|Win32" 19 Name="Debug|Win32"
20 OutputDirectory="../lib_$(ConfigurationName)/i686-win32" 20 OutputDirectory="../lib_$(ConfigurationName)/i686-win32"
21 IntermediateDirectory="Debug" 21 IntermediateDirectory="Debug"
22 ConfigurationType="4" 22 ConfigurationType="4"
23 InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC71.vsprops" 23 InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC71.vsprops"
24 CharacterSet="1" 24 CharacterSet="1"
25 > 25 >
26 <Tool 26 <Tool
27 Name="VCPreBuildEventTool" 27 Name="VCPreBuildEventTool"
28 /> 28 />
29 <Tool 29 <Tool
30 Name="VCCustomBuildTool" 30 Name="VCCustomBuildTool"
31 /> 31 />
32 <Tool 32 <Tool
33 Name="VCXMLDataGeneratorTool" 33 Name="VCXMLDataGeneratorTool"
34 /> 34 />
35 <Tool 35 <Tool
36 Name="VCWebServiceProxyGeneratorTool" 36 Name="VCWebServiceProxyGeneratorTool"
37 /> 37 />
38 <Tool 38 <Tool
39 Name="VCMIDLTool" 39 Name="VCMIDLTool"
40 /> 40 />
41 <Tool 41 <Tool
42 Name="VCCLCompilerTool" 42 Name="VCCLCompilerTool"
43 Optimization="0" 43 Optimization="0"
44 AdditionalIncludeDirectories="..\llcommon;..\llmath;..\llvfs;..\llmessage;..\llimage;..\llwindow;..\..\libraries\i686-win32\include;..\..\libraries\include\" 44 AdditionalIncludeDirectories="..\llcommon;..\llmath;..\llvfs;..\llmessage;..\llimage;..\llwindow;..\..\libraries\i686-win32\include;..\..\libraries\include\"
45 PreprocessorDefinitions="WIN32;_DEBUG;_LIB;LL_WINDOWS;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE;_USE_32BIT_TIME_T;LL_DEBUG" 45 PreprocessorDefinitions="WIN32;_DEBUG;_LIB;LL_WINDOWS;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE;_USE_32BIT_TIME_T;LL_DEBUG"
46 MinimalRebuild="true" 46 MinimalRebuild="true"
47 BasicRuntimeChecks="3" 47 BasicRuntimeChecks="3"
48 RuntimeLibrary="1" 48 RuntimeLibrary="1"
49 StructMemberAlignment="4" 49 StructMemberAlignment="4"
50 TreatWChar_tAsBuiltInType="false" 50 TreatWChar_tAsBuiltInType="false"
51 ForceConformanceInForLoopScope="true" 51 ForceConformanceInForLoopScope="true"
52 UsePrecompiledHeader="0" 52 UsePrecompiledHeader="0"
53 WarningLevel="3" 53 WarningLevel="3"
54 WarnAsError="true" 54 WarnAsError="true"
55 Detect64BitPortabilityProblems="false" 55 Detect64BitPortabilityProblems="false"
56 DebugInformationFormat="4" 56 DebugInformationFormat="4"
57 /> 57 />
58 <Tool 58 <Tool
59 Name="VCManagedResourceCompilerTool" 59 Name="VCManagedResourceCompilerTool"
60 /> 60 />
61 <Tool 61 <Tool
62 Name="VCResourceCompilerTool" 62 Name="VCResourceCompilerTool"
63 /> 63 />
64 <Tool 64 <Tool
65 Name="VCPreLinkEventTool" 65 Name="VCPreLinkEventTool"
66 /> 66 />
67 <Tool 67 <Tool
68 Name="VCLibrarianTool" 68 Name="VCLibrarianTool"
69 OutputFile="$(OutDir)/llrender.lib" 69 OutputFile="$(OutDir)/llrender.lib"
70 /> 70 />
71 <Tool 71 <Tool
72 Name="VCALinkTool" 72 Name="VCALinkTool"
73 /> 73 />
74 <Tool 74 <Tool
75 Name="VCXDCMakeTool" 75 Name="VCXDCMakeTool"
76 /> 76 />
77 <Tool 77 <Tool
78 Name="VCBscMakeTool" 78 Name="VCBscMakeTool"
79 /> 79 />
80 <Tool 80 <Tool
81 Name="VCFxCopTool" 81 Name="VCFxCopTool"
82 /> 82 />
83 <Tool 83 <Tool
84 Name="VCPostBuildEventTool" 84 Name="VCPostBuildEventTool"
85 /> 85 />
86 </Configuration> 86 </Configuration>
87 <Configuration 87 <Configuration
88 Name="Release|Win32" 88 Name="Release|Win32"
89 OutputDirectory="../lib_$(ConfigurationName)/i686-win32" 89 OutputDirectory="../lib_$(ConfigurationName)/i686-win32"
90 IntermediateDirectory="Release" 90 IntermediateDirectory="Release"
91 ConfigurationType="4" 91 ConfigurationType="4"
92 InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC71.vsprops" 92 InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC71.vsprops"
93 CharacterSet="1" 93 CharacterSet="1"
94 > 94 >
95 <Tool 95 <Tool
96 Name="VCPreBuildEventTool" 96 Name="VCPreBuildEventTool"
97 /> 97 />
98 <Tool 98 <Tool
99 Name="VCCustomBuildTool" 99 Name="VCCustomBuildTool"
100 /> 100 />
101 <Tool 101 <Tool
102 Name="VCXMLDataGeneratorTool" 102 Name="VCXMLDataGeneratorTool"
103 /> 103 />
104 <Tool 104 <Tool
105 Name="VCWebServiceProxyGeneratorTool" 105 Name="VCWebServiceProxyGeneratorTool"
106 /> 106 />
107 <Tool 107 <Tool
108 Name="VCMIDLTool" 108 Name="VCMIDLTool"
109 /> 109 />
110 <Tool 110 <Tool
111 Name="VCCLCompilerTool" 111 Name="VCCLCompilerTool"
112 AdditionalOptions="/Oy-" 112 AdditionalOptions="/Oy-"
113 InlineFunctionExpansion="2" 113 InlineFunctionExpansion="2"
114 EnableIntrinsicFunctions="true" 114 EnableIntrinsicFunctions="true"
115 AdditionalIncludeDirectories="..\llcommon;..\llmath;..\llvfs;..\llmessage;..\llimage;..\llwindow;..\..\libraries\i686-win32\include;..\..\libraries\include\" 115 AdditionalIncludeDirectories="..\llcommon;..\llmath;..\llvfs;..\llmessage;..\llimage;..\llwindow;..\..\libraries\i686-win32\include;..\..\libraries\include\"
116 PreprocessorDefinitions="WIN32;NDEBUG;_LIB;LL_WINDOWS;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE;_USE_32BIT_TIME_T;LL_RELEASE" 116 PreprocessorDefinitions="WIN32;NDEBUG;_LIB;LL_WINDOWS;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE;_USE_32BIT_TIME_T;LL_RELEASE"
117 RuntimeLibrary="0" 117 RuntimeLibrary="0"
118 StructMemberAlignment="0" 118 StructMemberAlignment="0"
119 TreatWChar_tAsBuiltInType="false" 119 TreatWChar_tAsBuiltInType="false"
120 ForceConformanceInForLoopScope="true" 120 ForceConformanceInForLoopScope="true"
121 UsePrecompiledHeader="0" 121 UsePrecompiledHeader="0"
122 WarningLevel="3" 122 WarningLevel="3"
123 WarnAsError="true" 123 WarnAsError="true"
124 Detect64BitPortabilityProblems="false" 124 Detect64BitPortabilityProblems="false"
125 DebugInformationFormat="3" 125 DebugInformationFormat="3"
126 /> 126 />
127 <Tool 127 <Tool
128 Name="VCManagedResourceCompilerTool" 128 Name="VCManagedResourceCompilerTool"
129 /> 129 />
130 <Tool 130 <Tool
131 Name="VCResourceCompilerTool" 131 Name="VCResourceCompilerTool"
132 /> 132 />
133 <Tool 133 <Tool
134 Name="VCPreLinkEventTool" 134 Name="VCPreLinkEventTool"
135 /> 135 />
136 <Tool 136 <Tool
137 Name="VCLibrarianTool" 137 Name="VCLibrarianTool"
138 OutputFile="$(OutDir)/llrender.lib" 138 OutputFile="$(OutDir)/llrender.lib"
139 /> 139 />
140 <Tool 140 <Tool
141 Name="VCALinkTool" 141 Name="VCALinkTool"
142 /> 142 />
143 <Tool 143 <Tool
144 Name="VCXDCMakeTool" 144 Name="VCXDCMakeTool"
145 /> 145 />
146 <Tool 146 <Tool
147 Name="VCBscMakeTool" 147 Name="VCBscMakeTool"
148 /> 148 />
149 <Tool 149 <Tool
150 Name="VCFxCopTool" 150 Name="VCFxCopTool"
151 /> 151 />
152 <Tool 152 <Tool
153 Name="VCPostBuildEventTool" 153 Name="VCPostBuildEventTool"
154 /> 154 />
155 </Configuration> 155 </Configuration>
156 <Configuration 156 <Configuration
157 Name="ReleaseNoOpt|Win32" 157 Name="ReleaseNoOpt|Win32"
158 OutputDirectory="../lib_$(ConfigurationName)/i686-win32" 158 OutputDirectory="../lib_$(ConfigurationName)/i686-win32"
159 IntermediateDirectory="$(ConfigurationName)" 159 IntermediateDirectory="$(ConfigurationName)"
160 ConfigurationType="4" 160 ConfigurationType="4"
161 InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC71.vsprops" 161 InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC71.vsprops"
162 CharacterSet="1" 162 CharacterSet="1"
163 > 163 >
164 <Tool 164 <Tool
165 Name="VCPreBuildEventTool" 165 Name="VCPreBuildEventTool"
166 /> 166 />
167 <Tool 167 <Tool
168 Name="VCCustomBuildTool" 168 Name="VCCustomBuildTool"
169 /> 169 />
170 <Tool 170 <Tool
171 Name="VCXMLDataGeneratorTool" 171 Name="VCXMLDataGeneratorTool"
172 /> 172 />
173 <Tool 173 <Tool
174 Name="VCWebServiceProxyGeneratorTool" 174 Name="VCWebServiceProxyGeneratorTool"
175 /> 175 />
176 <Tool 176 <Tool
177 Name="VCMIDLTool" 177 Name="VCMIDLTool"
178 /> 178 />
179 <Tool 179 <Tool
180 Name="VCCLCompilerTool" 180 Name="VCCLCompilerTool"
181 AdditionalOptions="/Oy-" 181 AdditionalOptions="/Oy-"
182 Optimization="0" 182 Optimization="0"
183 AdditionalIncludeDirectories="..\llcommon;..\llmath;..\llvfs;..\llmessage;..\llimage;..\llwindow;..\..\libraries\i686-win32\include;..\..\libraries\include\" 183 AdditionalIncludeDirectories="..\llcommon;..\llmath;..\llvfs;..\llmessage;..\llimage;..\llwindow;..\..\libraries\i686-win32\include;..\..\libraries\include\"
184 PreprocessorDefinitions="WIN32;NDEBUG;_LIB;LL_WINDOWS;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE;_USE_32BIT_TIME_T;LL_RELEASE" 184 PreprocessorDefinitions="WIN32;NDEBUG;_LIB;LL_WINDOWS;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE;_USE_32BIT_TIME_T;LL_RELEASE"
185 RuntimeLibrary="0" 185 RuntimeLibrary="0"
186 StructMemberAlignment="0" 186 StructMemberAlignment="0"
187 TreatWChar_tAsBuiltInType="false" 187 TreatWChar_tAsBuiltInType="false"
188 ForceConformanceInForLoopScope="true" 188 ForceConformanceInForLoopScope="true"
189 UsePrecompiledHeader="0" 189 UsePrecompiledHeader="0"
190 WarningLevel="3" 190 WarningLevel="3"
191 WarnAsError="true" 191 WarnAsError="true"
192 Detect64BitPortabilityProblems="false" 192 Detect64BitPortabilityProblems="false"
193 DebugInformationFormat="3" 193 DebugInformationFormat="3"
194 /> 194 />
195 <Tool 195 <Tool
196 Name="VCManagedResourceCompilerTool" 196 Name="VCManagedResourceCompilerTool"
197 /> 197 />
198 <Tool 198 <Tool
199 Name="VCResourceCompilerTool" 199 Name="VCResourceCompilerTool"
200 /> 200 />
201 <Tool 201 <Tool
202 Name="VCPreLinkEventTool" 202 Name="VCPreLinkEventTool"
203 /> 203 />
204 <Tool 204 <Tool
205 Name="VCLibrarianTool" 205 Name="VCLibrarianTool"
206 OutputFile="$(OutDir)/llrender.lib" 206 OutputFile="$(OutDir)/llrender.lib"
207 /> 207 />
208 <Tool 208 <Tool
209 Name="VCALinkTool" 209 Name="VCALinkTool"
210 /> 210 />
211 <Tool 211 <Tool
212 Name="VCXDCMakeTool" 212 Name="VCXDCMakeTool"
213 /> 213 />
214 <Tool 214 <Tool
215 Name="VCBscMakeTool" 215 Name="VCBscMakeTool"
216 /> 216 />
217 <Tool 217 <Tool
218 Name="VCFxCopTool" 218 Name="VCFxCopTool"
219 /> 219 />
220 <Tool 220 <Tool
221 Name="VCPostBuildEventTool" 221 Name="VCPostBuildEventTool"
222 /> 222 />
223 </Configuration> 223 </Configuration>
224 </Configurations> 224 </Configurations>
225 <References> 225 <References>
226 </References> 226 </References>
227 <Files> 227 <Files>
228 <Filter 228 <Filter
229 Name="Source Files" 229 Name="Source Files"
230 Filter="cpp;c;cxx;def;odl;idl;hpj;bat;asm;asmx" 230 Filter="cpp;c;cxx;def;odl;idl;hpj;bat;asm;asmx"
231 UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}" 231 UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}"
232 > 232 >
233 <File 233 <File
234 RelativePath=".\llfont.cpp" 234 RelativePath=".\llfont.cpp"
235 > 235 >
236 </File> 236 </File>
237 <File 237 <File
238 RelativePath=".\llfontgl.cpp" 238 RelativePath=".\llfontgl.cpp"
239 > 239 >
240 </File> 240 </File>
241 <File 241 <File
242 RelativePath=".\llgldbg.cpp" 242 RelativePath=".\llgldbg.cpp"
243 > 243 >
244 </File> 244 </File>
245 <File 245 <File
246 RelativePath=".\llimagegl.cpp" 246 RelativePath=".\llglimmediate.cpp"
247 > 247 >
248 </File> 248 </File>
249 <File 249 <File
250 RelativePath=".\llvertexbuffer.cpp" 250 RelativePath=".\llimagegl.cpp"
251 > 251 >
252 </File> 252 </File>
253 </Filter> 253 <File
254 <Filter 254 RelativePath=".\llrendertarget.cpp"
255 Name="Header Files" 255 >
256 Filter="h;hpp;hxx;hm;inl;inc;xsd" 256 </File>
257 UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}" 257 <File
258 > 258 RelativePath=".\llvertexbuffer.cpp"
259 <File 259 >
260 RelativePath=".\glext.h" 260 </File>
261 > 261 </Filter>
262 </File> 262 <Filter
263 <File 263 Name="Header Files"
264 RelativePath=".\llagpmempool.h" 264 Filter="h;hpp;hxx;hm;inl;inc;xsd"
265 > 265 UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}"
266 </File> 266 >
267 <File 267 <File
268 RelativePath=".\llagpmempoolarb.h" 268 RelativePath=".\glext.h"
269 > 269 >
270 </File> 270 </File>
271 <File 271 <File
272 RelativePath=".\llagpmempoolati.h" 272 RelativePath=".\llagpmempool.h"
273 > 273 >
274 </File> 274 </File>
275 <File 275 <File
276 RelativePath=".\llagpmempoolnv.h" 276 RelativePath=".\llagpmempoolarb.h"
277 > 277 >
278 </File> 278 </File>
279 <File 279 <File
280 RelativePath=".\llfont.h" 280 RelativePath=".\llagpmempoolati.h"
281 > 281 >
282 </File> 282 </File>
283 <File 283 <File
284 RelativePath=".\llfontgl.h" 284 RelativePath=".\llagpmempoolnv.h"
285 > 285 >
286 </File> 286 </File>
287 <File 287 <File
288 RelativePath=".\llgldbg.h" 288 RelativePath=".\llfont.h"
289 > 289 >
290 </File> 290 </File>
291 <File 291 <File
292 RelativePath=".\llimagegl.h" 292 RelativePath=".\llfontgl.h"
293 > 293 >
294 </File> 294 </File>
295 <File 295 <File
296 RelativePath=".\llvertexbuffer.h" 296 RelativePath=".\llgldbg.h"
297 > 297 >
298 </File> 298 </File>
299 <File 299 <File
300 RelativePath=".\llvertexprogramgl.h" 300 RelativePath=".\llglimmediate.h"
301 > 301 >
302 </File> 302 </File>
303 </Filter> 303 <File
304 <Filter 304 RelativePath=".\llimagegl.h"
305 Name="Resource Files" 305 >
306 Filter="rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx" 306 </File>
307 UniqueIdentifier="{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}" 307 <File
308 > 308 RelativePath=".\llrendertarget.h"
309 </Filter> 309 >
310 </Files> 310 </File>
311 <Globals> 311 <File
312 </Globals> 312 RelativePath=".\llvertexbuffer.h"
313</VisualStudioProject> 313 >
314 </File>
315 <File
316 RelativePath=".\llvertexprogramgl.h"
317 >
318 </File>
319 </Filter>
320 <Filter
321 Name="Resource Files"
322 Filter="rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx"
323 UniqueIdentifier="{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}"
324 >
325 </Filter>
326 </Files>
327 <Globals>
328 </Globals>
329</VisualStudioProject>
diff --git a/linden/indra/llrender/llrender_vc9.vcproj b/linden/indra/llrender/llrender_vc9.vcproj
index e4bc1b6..08e3362 100644
--- a/linden/indra/llrender/llrender_vc9.vcproj
+++ b/linden/indra/llrender/llrender_vc9.vcproj
@@ -1,314 +1,330 @@
1<?xml version="1.0" encoding="Windows-1252"?> 1<?xml version="1.0" encoding="Windows-1252"?>
2<VisualStudioProject 2<VisualStudioProject
3 ProjectType="Visual C++" 3 ProjectType="Visual C++"
4 Version="9.00" 4 Version="9.00"
5 Name="llrender" 5 Name="llrender"
6 ProjectGUID="{2ADE3C14-94C4-40BF-B033-70F3C954EE90}" 6 ProjectGUID="{2ADE3C14-94C4-40BF-B033-70F3C954EE90}"
7 RootNamespace="llrender" 7 RootNamespace="llrender"
8 Keyword="Win32Proj" 8 Keyword="Win32Proj"
9 TargetFrameworkVersion="131072" 9 TargetFrameworkVersion="131072"
10 > 10 >
11 <Platforms> 11 <Platforms>
12 <Platform 12 <Platform
13 Name="Win32" 13 Name="Win32"
14 /> 14 />
15 </Platforms> 15 </Platforms>
16 <ToolFiles> 16 <ToolFiles>
17 </ToolFiles> 17 </ToolFiles>
18 <Configurations> 18 <Configurations>
19 <Configuration 19 <Configuration
20 Name="Debug|Win32" 20 Name="Debug|Win32"
21 OutputDirectory="../lib_$(ConfigurationName)/i686-win32" 21 OutputDirectory="../lib_$(ConfigurationName)/i686-win32"
22 IntermediateDirectory="Debug" 22 IntermediateDirectory="Debug"
23 ConfigurationType="4" 23 ConfigurationType="4"
24 InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC71.vsprops" 24 InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC71.vsprops"
25 CharacterSet="1" 25 CharacterSet="1"
26 > 26 >
27 <Tool 27 <Tool
28 Name="VCPreBuildEventTool" 28 Name="VCPreBuildEventTool"
29 /> 29 />
30 <Tool 30 <Tool
31 Name="VCCustomBuildTool" 31 Name="VCCustomBuildTool"
32 /> 32 />
33 <Tool 33 <Tool
34 Name="VCXMLDataGeneratorTool" 34 Name="VCXMLDataGeneratorTool"
35 /> 35 />
36 <Tool 36 <Tool
37 Name="VCWebServiceProxyGeneratorTool" 37 Name="VCWebServiceProxyGeneratorTool"
38 /> 38 />
39 <Tool 39 <Tool
40 Name="VCMIDLTool" 40 Name="VCMIDLTool"
41 /> 41 />
42 <Tool 42 <Tool
43 Name="VCCLCompilerTool" 43 Name="VCCLCompilerTool"
44 Optimization="0" 44 Optimization="0"
45 AdditionalIncludeDirectories="..\llcommon;..\llmath;..\llvfs;..\llmessage;..\llimage;..\llwindow;..\..\libraries\i686-win32\include;..\..\libraries\include\" 45 AdditionalIncludeDirectories="..\llcommon;..\llmath;..\llvfs;..\llmessage;..\llimage;..\llwindow;..\..\libraries\i686-win32\include;..\..\libraries\include\"
46 PreprocessorDefinitions="WIN32;_DEBUG;_LIB;LL_WINDOWS;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE;_USE_32BIT_TIME_T;LL_DEBUG" 46 PreprocessorDefinitions="WIN32;_DEBUG;_LIB;LL_WINDOWS;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE;_USE_32BIT_TIME_T;LL_DEBUG"
47 MinimalRebuild="true" 47 MinimalRebuild="true"
48 BasicRuntimeChecks="3" 48 BasicRuntimeChecks="3"
49 RuntimeLibrary="1" 49 RuntimeLibrary="1"
50 StructMemberAlignment="4" 50 StructMemberAlignment="4"
51 TreatWChar_tAsBuiltInType="false" 51 TreatWChar_tAsBuiltInType="false"
52 ForceConformanceInForLoopScope="true" 52 ForceConformanceInForLoopScope="true"
53 UsePrecompiledHeader="0" 53 UsePrecompiledHeader="0"
54 WarningLevel="3" 54 WarningLevel="3"
55 WarnAsError="true" 55 WarnAsError="true"
56 Detect64BitPortabilityProblems="false" 56 Detect64BitPortabilityProblems="false"
57 DebugInformationFormat="4" 57 DebugInformationFormat="4"
58 /> 58 />
59 <Tool 59 <Tool
60 Name="VCManagedResourceCompilerTool" 60 Name="VCManagedResourceCompilerTool"
61 /> 61 />
62 <Tool 62 <Tool
63 Name="VCResourceCompilerTool" 63 Name="VCResourceCompilerTool"
64 /> 64 />
65 <Tool 65 <Tool
66 Name="VCPreLinkEventTool" 66 Name="VCPreLinkEventTool"
67 /> 67 />
68 <Tool 68 <Tool
69 Name="VCLibrarianTool" 69 Name="VCLibrarianTool"
70 OutputFile="$(OutDir)/llrender.lib" 70 OutputFile="$(OutDir)/llrender.lib"
71 /> 71 />
72 <Tool 72 <Tool
73 Name="VCALinkTool" 73 Name="VCALinkTool"
74 /> 74 />
75 <Tool 75 <Tool
76 Name="VCXDCMakeTool" 76 Name="VCXDCMakeTool"
77 /> 77 />
78 <Tool 78 <Tool
79 Name="VCBscMakeTool" 79 Name="VCBscMakeTool"
80 /> 80 />
81 <Tool 81 <Tool
82 Name="VCFxCopTool" 82 Name="VCFxCopTool"
83 /> 83 />
84 <Tool 84 <Tool
85 Name="VCPostBuildEventTool" 85 Name="VCPostBuildEventTool"
86 /> 86 />
87 </Configuration> 87 </Configuration>
88 <Configuration 88 <Configuration
89 Name="Release|Win32" 89 Name="Release|Win32"
90 OutputDirectory="../lib_$(ConfigurationName)/i686-win32" 90 OutputDirectory="../lib_$(ConfigurationName)/i686-win32"
91 IntermediateDirectory="Release" 91 IntermediateDirectory="Release"
92 ConfigurationType="4" 92 ConfigurationType="4"
93 InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC71.vsprops" 93 InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC71.vsprops"
94 CharacterSet="1" 94 CharacterSet="1"
95 > 95 >
96 <Tool 96 <Tool
97 Name="VCPreBuildEventTool" 97 Name="VCPreBuildEventTool"
98 /> 98 />
99 <Tool 99 <Tool
100 Name="VCCustomBuildTool" 100 Name="VCCustomBuildTool"
101 /> 101 />
102 <Tool 102 <Tool
103 Name="VCXMLDataGeneratorTool" 103 Name="VCXMLDataGeneratorTool"
104 /> 104 />
105 <Tool 105 <Tool
106 Name="VCWebServiceProxyGeneratorTool" 106 Name="VCWebServiceProxyGeneratorTool"
107 /> 107 />
108 <Tool 108 <Tool
109 Name="VCMIDLTool" 109 Name="VCMIDLTool"
110 /> 110 />
111 <Tool 111 <Tool
112 Name="VCCLCompilerTool" 112 Name="VCCLCompilerTool"
113 AdditionalOptions="/Oy-" 113 AdditionalOptions="/Oy-"
114 InlineFunctionExpansion="2" 114 InlineFunctionExpansion="2"
115 EnableIntrinsicFunctions="true" 115 EnableIntrinsicFunctions="true"
116 AdditionalIncludeDirectories="..\llcommon;..\llmath;..\llvfs;..\llmessage;..\llimage;..\llwindow;..\..\libraries\i686-win32\include;..\..\libraries\include\" 116 AdditionalIncludeDirectories="..\llcommon;..\llmath;..\llvfs;..\llmessage;..\llimage;..\llwindow;..\..\libraries\i686-win32\include;..\..\libraries\include\"
117 PreprocessorDefinitions="WIN32;NDEBUG;_LIB;LL_WINDOWS;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE;_USE_32BIT_TIME_T;LL_RELEASE" 117 PreprocessorDefinitions="WIN32;NDEBUG;_LIB;LL_WINDOWS;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE;_USE_32BIT_TIME_T;LL_RELEASE"
118 RuntimeLibrary="0" 118 RuntimeLibrary="0"
119 StructMemberAlignment="0" 119 StructMemberAlignment="0"
120 TreatWChar_tAsBuiltInType="false" 120 TreatWChar_tAsBuiltInType="false"
121 ForceConformanceInForLoopScope="true" 121 ForceConformanceInForLoopScope="true"
122 UsePrecompiledHeader="0" 122 UsePrecompiledHeader="0"
123 WarningLevel="3" 123 WarningLevel="3"
124 WarnAsError="true" 124 WarnAsError="true"
125 Detect64BitPortabilityProblems="false" 125 Detect64BitPortabilityProblems="false"
126 DebugInformationFormat="3" 126 DebugInformationFormat="3"
127 /> 127 />
128 <Tool 128 <Tool
129 Name="VCManagedResourceCompilerTool" 129 Name="VCManagedResourceCompilerTool"
130 /> 130 />
131 <Tool 131 <Tool
132 Name="VCResourceCompilerTool" 132 Name="VCResourceCompilerTool"
133 /> 133 />
134 <Tool 134 <Tool
135 Name="VCPreLinkEventTool" 135 Name="VCPreLinkEventTool"
136 /> 136 />
137 <Tool 137 <Tool
138 Name="VCLibrarianTool" 138 Name="VCLibrarianTool"
139 OutputFile="$(OutDir)/llrender.lib" 139 OutputFile="$(OutDir)/llrender.lib"
140 /> 140 />
141 <Tool 141 <Tool
142 Name="VCALinkTool" 142 Name="VCALinkTool"
143 /> 143 />
144 <Tool 144 <Tool
145 Name="VCXDCMakeTool" 145 Name="VCXDCMakeTool"
146 /> 146 />
147 <Tool 147 <Tool
148 Name="VCBscMakeTool" 148 Name="VCBscMakeTool"
149 /> 149 />
150 <Tool 150 <Tool
151 Name="VCFxCopTool" 151 Name="VCFxCopTool"
152 /> 152 />
153 <Tool 153 <Tool
154 Name="VCPostBuildEventTool" 154 Name="VCPostBuildEventTool"
155 /> 155 />
156 </Configuration> 156 </Configuration>
157 <Configuration 157 <Configuration
158 Name="ReleaseNoOpt|Win32" 158 Name="ReleaseNoOpt|Win32"
159 OutputDirectory="../lib_$(ConfigurationName)/i686-win32" 159 OutputDirectory="../lib_$(ConfigurationName)/i686-win32"
160 IntermediateDirectory="$(ConfigurationName)" 160 IntermediateDirectory="$(ConfigurationName)"
161 ConfigurationType="4" 161 ConfigurationType="4"
162 InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC71.vsprops" 162 InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC71.vsprops"
163 CharacterSet="1" 163 CharacterSet="1"
164 > 164 >
165 <Tool 165 <Tool
166 Name="VCPreBuildEventTool" 166 Name="VCPreBuildEventTool"
167 /> 167 />
168 <Tool 168 <Tool
169 Name="VCCustomBuildTool" 169 Name="VCCustomBuildTool"
170 /> 170 />
171 <Tool 171 <Tool
172 Name="VCXMLDataGeneratorTool" 172 Name="VCXMLDataGeneratorTool"
173 /> 173 />
174 <Tool 174 <Tool
175 Name="VCWebServiceProxyGeneratorTool" 175 Name="VCWebServiceProxyGeneratorTool"
176 /> 176 />
177 <Tool 177 <Tool
178 Name="VCMIDLTool" 178 Name="VCMIDLTool"
179 /> 179 />
180 <Tool 180 <Tool
181 Name="VCCLCompilerTool" 181 Name="VCCLCompilerTool"
182 AdditionalOptions="/Oy-" 182 AdditionalOptions="/Oy-"
183 Optimization="0" 183 Optimization="0"
184 AdditionalIncludeDirectories="..\llcommon;..\llmath;..\llvfs;..\llmessage;..\llimage;..\llwindow;..\..\libraries\i686-win32\include;..\..\libraries\include\" 184 AdditionalIncludeDirectories="..\llcommon;..\llmath;..\llvfs;..\llmessage;..\llimage;..\llwindow;..\..\libraries\i686-win32\include;..\..\libraries\include\"
185 PreprocessorDefinitions="WIN32;NDEBUG;_LIB;LL_WINDOWS;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE;_USE_32BIT_TIME_T;LL_RELEASE" 185 PreprocessorDefinitions="WIN32;NDEBUG;_LIB;LL_WINDOWS;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE;_USE_32BIT_TIME_T;LL_RELEASE"
186 RuntimeLibrary="0" 186 RuntimeLibrary="0"
187 StructMemberAlignment="0" 187 StructMemberAlignment="0"
188 TreatWChar_tAsBuiltInType="false" 188 TreatWChar_tAsBuiltInType="false"
189 ForceConformanceInForLoopScope="true" 189 ForceConformanceInForLoopScope="true"
190 UsePrecompiledHeader="0" 190 UsePrecompiledHeader="0"
191 WarningLevel="3" 191 WarningLevel="3"
192 WarnAsError="true" 192 WarnAsError="true"
193 Detect64BitPortabilityProblems="false" 193 Detect64BitPortabilityProblems="false"
194 DebugInformationFormat="3" 194 DebugInformationFormat="3"
195 /> 195 />
196 <Tool 196 <Tool
197 Name="VCManagedResourceCompilerTool" 197 Name="VCManagedResourceCompilerTool"
198 /> 198 />
199 <Tool 199 <Tool
200 Name="VCResourceCompilerTool" 200 Name="VCResourceCompilerTool"
201 /> 201 />
202 <Tool 202 <Tool
203 Name="VCPreLinkEventTool" 203 Name="VCPreLinkEventTool"
204 /> 204 />
205 <Tool 205 <Tool
206 Name="VCLibrarianTool" 206 Name="VCLibrarianTool"
207 OutputFile="$(OutDir)/llrender.lib" 207 OutputFile="$(OutDir)/llrender.lib"
208 /> 208 />
209 <Tool 209 <Tool
210 Name="VCALinkTool" 210 Name="VCALinkTool"
211 /> 211 />
212 <Tool 212 <Tool
213 Name="VCXDCMakeTool" 213 Name="VCXDCMakeTool"
214 /> 214 />
215 <Tool 215 <Tool
216 Name="VCBscMakeTool" 216 Name="VCBscMakeTool"
217 /> 217 />
218 <Tool 218 <Tool
219 Name="VCFxCopTool" 219 Name="VCFxCopTool"
220 /> 220 />
221 <Tool 221 <Tool
222 Name="VCPostBuildEventTool" 222 Name="VCPostBuildEventTool"
223 /> 223 />
224 </Configuration> 224 </Configuration>
225 </Configurations> 225 </Configurations>
226 <References> 226 <References>
227 </References> 227 </References>
228 <Files> 228 <Files>
229 <Filter 229 <Filter
230 Name="Source Files" 230 Name="Source Files"
231 Filter="cpp;c;cxx;def;odl;idl;hpj;bat;asm;asmx" 231 Filter="cpp;c;cxx;def;odl;idl;hpj;bat;asm;asmx"
232 UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}" 232 UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}"
233 > 233 >
234 <File 234 <File
235 RelativePath=".\llfont.cpp" 235 RelativePath=".\llfont.cpp"
236 > 236 >
237 </File> 237 </File>
238 <File 238 <File
239 RelativePath=".\llfontgl.cpp" 239 RelativePath=".\llfontgl.cpp"
240 > 240 >
241 </File> 241 </File>
242 <File 242 <File
243 RelativePath=".\llgldbg.cpp" 243 RelativePath=".\llgldbg.cpp"
244 > 244 >
245 </File> 245 </File>
246 <File 246 <File
247 RelativePath=".\llimagegl.cpp" 247 RelativePath=".\llglimmediate.cpp"
248 > 248 >
249 </File> 249 </File>
250 <File 250 <File
251 RelativePath=".\llvertexbuffer.cpp" 251 RelativePath=".\llimagegl.cpp"
252 > 252 >
253 </File> 253 </File>
254 </Filter> 254 <File
255 <Filter 255 RelativePath=".\llrendertarget.cpp"
256 Name="Header Files" 256 >
257 Filter="h;hpp;hxx;hm;inl;inc;xsd" 257 </File>
258 UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}" 258 <File
259 > 259 RelativePath=".\llvertexbuffer.cpp"
260 <File 260 >
261 RelativePath=".\glext.h" 261 </File>
262 > 262 </Filter>
263 </File> 263 <Filter
264 <File 264 Name="Header Files"
265 RelativePath=".\llagpmempool.h" 265 Filter="h;hpp;hxx;hm;inl;inc;xsd"
266 > 266 UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}"
267 </File> 267 >
268 <File 268 <File
269 RelativePath=".\llagpmempoolarb.h" 269 RelativePath=".\glext.h"
270 > 270 >
271 </File> 271 </File>
272 <File 272 <File
273 RelativePath=".\llagpmempoolati.h" 273 RelativePath=".\llagpmempool.h"
274 > 274 >
275 </File> 275 </File>
276 <File 276 <File
277 RelativePath=".\llagpmempoolnv.h" 277 RelativePath=".\llagpmempoolarb.h"
278 > 278 >
279 </File> 279 </File>
280 <File 280 <File
281 RelativePath=".\llfont.h" 281 RelativePath=".\llagpmempoolati.h"
282 > 282 >
283 </File> 283 </File>
284 <File 284 <File
285 RelativePath=".\llfontgl.h" 285 RelativePath=".\llagpmempoolnv.h"
286 > 286 >
287 </File> 287 </File>
288 <File 288 <File
289 RelativePath=".\llgldbg.h" 289 RelativePath=".\llfont.h"
290 > 290 >
291 </File> 291 </File>
292 <File 292 <File
293 RelativePath=".\llimagegl.h" 293 RelativePath=".\llfontgl.h"
294 > 294 >
295 </File> 295 </File>
296 <File 296 <File
297 RelativePath=".\llvertexbuffer.h" 297 RelativePath=".\llgldbg.h"
298 > 298 >
299 </File> 299 </File>
300 <File 300 <File
301 RelativePath=".\llvertexprogramgl.h" 301 RelativePath=".\llglimmediate.h"
302 > 302 >
303 </File> 303 </File>
304 </Filter> 304 <File
305 <Filter 305 RelativePath=".\llimagegl.h"
306 Name="Resource Files" 306 >
307 Filter="rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx" 307 </File>
308 UniqueIdentifier="{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}" 308 <File
309 > 309 RelativePath=".\llrendertarget.h"
310 </Filter> 310 >
311 </Files> 311 </File>
312 <Globals> 312 <File
313 </Globals> 313 RelativePath=".\llvertexbuffer.h"
314</VisualStudioProject> 314 >
315 </File>
316 <File
317 RelativePath=".\llvertexprogramgl.h"
318 >
319 </File>
320 </Filter>
321 <Filter
322 Name="Resource Files"
323 Filter="rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx"
324 UniqueIdentifier="{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}"
325 >
326 </Filter>
327 </Files>
328 <Globals>
329 </Globals>
330</VisualStudioProject>
diff --git a/linden/indra/llrender/llrendertarget.cpp b/linden/indra/llrender/llrendertarget.cpp
new file mode 100644
index 0000000..974e0a2
--- /dev/null
+++ b/linden/indra/llrender/llrendertarget.cpp
@@ -0,0 +1,185 @@
1/**
2 * @file llrendertarget.cpp
3 * @brief LLRenderTarget implementation
4 *
5 * $LicenseInfo:firstyear=2001&license=viewergpl$
6 *
7 * Copyright (c) 2001-2008, Linden Research, Inc.
8 *
9 * Second Life Viewer Source Code
10 * The source code in this file ("Source Code") is provided by Linden Lab
11 * to you under the terms of the GNU General Public License, version 2.0
12 * ("GPL"), unless you have obtained a separate licensing agreement
13 * ("Other License"), formally executed by you and Linden Lab. Terms of
14 * the GPL can be found in doc/GPL-license.txt in this distribution, or
15 * online at http://secondlifegrid.net/programs/open_source/licensing/gplv2
16 *
17 * There are special exceptions to the terms and conditions of the GPL as
18 * it is applied to this Source Code. View the full text of the exception
19 * in the file doc/FLOSS-exception.txt in this software distribution, or
20 * online at http://secondlifegrid.net/programs/open_source/licensing/flossexception
21 *
22 * By copying, modifying or distributing this software, you acknowledge
23 * that you have read and understood your obligations described above,
24 * and agree to abide by those obligations.
25 *
26 * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO
27 * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY,
28 * COMPLETENESS OR PERFORMANCE.
29 * $/LicenseInfo$
30 */
31
32#include "linden_common.h"
33
34#include "llrendertarget.h"
35#include "llglimmediate.h"
36
37
38BOOL LLRenderTarget::sUseFBO = FALSE;
39
40LLRenderTarget::LLRenderTarget()
41{
42 mResX = mResY = mTex = mFBO = mDepth = 0;
43 mUseDepth = FALSE;
44 mUsage = GL_TEXTURE_2D;
45}
46
47LLRenderTarget::~LLRenderTarget()
48{
49 release();
50}
51
52void LLRenderTarget::allocate(U32 resx, U32 resy, U32 color_fmt, BOOL depth, U32 usage, BOOL force_fbo)
53{
54 mResX = resx;
55 mResY = resy;
56
57 mUsage = usage;
58 mUseDepth = depth;
59 release();
60
61 glGenTextures(1, (GLuint *) &mTex);
62 glBindTexture(mUsage, mTex);
63 glTexImage2D(mUsage, 0, color_fmt, mResX, mResY, 0, color_fmt, GL_UNSIGNED_BYTE, NULL);
64
65 glTexParameteri(mUsage, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
66 glTexParameteri(mUsage, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
67
68 if (mUsage != GL_TEXTURE_RECTANGLE_ARB)
69 {
70 glTexParameteri(mUsage, GL_TEXTURE_WRAP_S, GL_MIRRORED_REPEAT);
71 glTexParameteri(mUsage, GL_TEXTURE_WRAP_T, GL_MIRRORED_REPEAT);
72 }
73 else
74 {
75 // ATI doesn't support mirrored repeat for rectangular textures.
76 glTexParameteri(mUsage, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
77 glTexParameteri(mUsage, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
78 }
79
80 stop_glerror();
81
82 if (sUseFBO || force_fbo)
83 {
84 if (depth)
85 {
86 glGenRenderbuffersEXT(1, (GLuint *) &mDepth);
87 glBindRenderbufferEXT(GL_RENDERBUFFER_EXT, mDepth);
88 glRenderbufferStorageEXT(GL_RENDERBUFFER_EXT,GL_DEPTH_COMPONENT,mResX,mResY);
89 glBindRenderbufferEXT(GL_RENDERBUFFER_EXT, 0);
90 }
91
92 glGenFramebuffersEXT(1, (GLuint *) &mFBO);
93 glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, mFBO);
94
95 if (mDepth)
96 {
97 glFramebufferRenderbufferEXT(GL_FRAMEBUFFER_EXT, GL_DEPTH_ATTACHMENT_EXT,
98 GL_RENDERBUFFER_EXT, mDepth);
99 }
100 glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT,
101 mUsage, mTex, 0);
102
103
104 glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0);
105 }
106}
107
108void LLRenderTarget::release()
109{
110 if (mFBO)
111 {
112 glDeleteFramebuffersEXT(1, (GLuint *) &mFBO);
113 mFBO = 0;
114 }
115
116 if (mTex)
117 {
118 glDeleteTextures(1, (GLuint *) &mTex);
119 mTex = 0;
120 }
121
122 if (mDepth)
123 {
124 glDeleteRenderbuffersEXT(1, (GLuint *) &mDepth);
125 mDepth = 0;
126 }
127}
128
129void LLRenderTarget::bindTarget()
130{
131 if (mFBO)
132 {
133 glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, mFBO);
134 }
135
136 glViewport(0, 0, mResX, mResY);
137}
138
139void LLRenderTarget::clear()
140{
141 U32 mask = GL_COLOR_BUFFER_BIT;
142 if (mUseDepth)
143 {
144 mask |= GL_DEPTH_BUFFER_BIT;
145 }
146 if (mFBO)
147 {
148 glClear(mask);
149 }
150 else
151 {
152 LLGLEnable scissor(GL_SCISSOR_TEST);
153 glScissor(0, 0, mResX, mResY);
154 glClear(mask);
155 }
156}
157
158void LLRenderTarget::bindTexture()
159{
160 glBindTexture(mUsage, mTex);
161}
162
163void LLRenderTarget::flush()
164{
165 gGL.flush();
166 if (!mFBO)
167 {
168 bindTexture();
169 glCopyTexSubImage2D(mUsage, 0, 0, 0, 0, 0, mResX, mResY);
170 }
171}
172
173BOOL LLRenderTarget::isComplete() const
174{
175 return (mTex || mDepth) ? TRUE : FALSE;
176}
177
178void LLRenderTarget::getViewport(S32* viewport)
179{
180 viewport[0] = 0;
181 viewport[1] = 0;
182 viewport[2] = mResX;
183 viewport[3] = mResY;
184}
185
diff --git a/linden/indra/llrender/llrendertarget.h b/linden/indra/llrender/llrendertarget.h
new file mode 100644
index 0000000..cc36146
--- /dev/null
+++ b/linden/indra/llrender/llrendertarget.h
@@ -0,0 +1,116 @@
1/**
2 * @file llrendertarget.h
3 * @brief Off screen render target abstraction. Loose wrapper for GL_EXT_framebuffer_objects.
4 *
5 * $LicenseInfo:firstyear=2001&license=viewergpl$
6 *
7 * Copyright (c) 2001-2008, Linden Research, Inc.
8 *
9 * Second Life Viewer Source Code
10 * The source code in this file ("Source Code") is provided by Linden Lab
11 * to you under the terms of the GNU General Public License, version 2.0
12 * ("GPL"), unless you have obtained a separate licensing agreement
13 * ("Other License"), formally executed by you and Linden Lab. Terms of
14 * the GPL can be found in doc/GPL-license.txt in this distribution, or
15 * online at http://secondlifegrid.net/programs/open_source/licensing/gplv2
16 *
17 * There are special exceptions to the terms and conditions of the GPL as
18 * it is applied to this Source Code. View the full text of the exception
19 * in the file doc/FLOSS-exception.txt in this software distribution, or
20 * online at http://secondlifegrid.net/programs/open_source/licensing/flossexception
21 *
22 * By copying, modifying or distributing this software, you acknowledge
23 * that you have read and understood your obligations described above,
24 * and agree to abide by those obligations.
25 *
26 * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO
27 * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY,
28 * COMPLETENESS OR PERFORMANCE.
29 * $/LicenseInfo$
30 */
31
32#ifndef LL_LLRENDERTARGET_H
33#define LL_LLRENDERTARGET_H
34
35#include "llgl.h"
36
37/*
38 SAMPLE USAGE:
39
40 LLFBOTarget target;
41
42 ...
43
44 //allocate a 256x256 RGBA render target with depth buffer
45 target.allocate(256,256,GL_RGBA,TRUE);
46
47 //render to contents of offscreen buffer
48 target.bindTarget();
49 glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
50 ... <issue drawing commands> ...
51 target.flush();
52
53 ...
54
55 //use target as a texture
56 target.bindTexture();
57 ... <issue drawing commands> ...
58
59*/
60
61
62class LLRenderTarget
63{
64public:
65 //whether or not to use FBO implementation
66 static BOOL sUseFBO;
67
68 LLRenderTarget();
69 ~LLRenderTarget();
70
71 //allocate resources for rendering
72 //must be called before use
73 //multiple calls will release previously allocated resources
74 void allocate(U32 resx, U32 resy, U32 color_fmt, BOOL depth, U32 usage = GL_TEXTURE_2D, BOOL force_fbo = FALSE);
75
76 //free any allocated resources
77 //safe to call redundantly
78 void release();
79
80 //bind target for rendering
81 //applies appropriate viewport
82 void bindTarget();
83
84 //clear render targer, clears depth buffer if present,
85 //uses scissor rect if in copy-to-texture mode
86 void clear();
87
88 //get applied viewport
89 void getViewport(S32* viewport);
90
91 //bind results of render for sampling
92 void bindTexture();
93
94 //flush rendering operations
95 //must be called when rendering is complete
96 //should be used 1:1 with bindTarget
97 // call bindTarget once, do all your rendering, call flush once
98 void flush();
99
100 //Returns TRUE if target is ready to be rendered into.
101 //That is, if the target has been allocated with at least
102 //one renderable attachment (i.e. color buffer, depth buffer).
103 BOOL isComplete() const;
104
105private:
106 U32 mResX;
107 U32 mResY;
108 U32 mTex;
109 U32 mFBO;
110 U32 mDepth;
111 BOOL mUseDepth;
112 U32 mUsage;
113};
114
115#endif
116
diff --git a/linden/indra/llrender/llvertexbuffer.cpp b/linden/indra/llrender/llvertexbuffer.cpp
index d19e885..f3c6997 100644
--- a/linden/indra/llrender/llvertexbuffer.cpp
+++ b/linden/indra/llrender/llvertexbuffer.cpp
@@ -31,6 +31,8 @@
31 31
32#include "linden_common.h" 32#include "linden_common.h"
33 33
34#include <boost/static_assert.hpp>
35
34#include "llvertexbuffer.h" 36#include "llvertexbuffer.h"
35// #include "llrender.h" 37// #include "llrender.h"
36#include "llglheaders.h" 38#include "llglheaders.h"
@@ -40,8 +42,16 @@
40//============================================================================ 42//============================================================================
41 43
42//static 44//static
45LLVBOPool LLVertexBuffer::sStreamVBOPool;
46LLVBOPool LLVertexBuffer::sDynamicVBOPool;
47LLVBOPool LLVertexBuffer::sStreamIBOPool;
48LLVBOPool LLVertexBuffer::sDynamicIBOPool;
49
50U32 LLVertexBuffer::sBindCount = 0;
51U32 LLVertexBuffer::sSetCount = 0;
43S32 LLVertexBuffer::sCount = 0; 52S32 LLVertexBuffer::sCount = 0;
44S32 LLVertexBuffer::sGLCount = 0; 53S32 LLVertexBuffer::sGLCount = 0;
54S32 LLVertexBuffer::sMappedCount = 0;
45BOOL LLVertexBuffer::sEnableVBOs = TRUE; 55BOOL LLVertexBuffer::sEnableVBOs = TRUE;
46U32 LLVertexBuffer::sGLRenderBuffer = 0; 56U32 LLVertexBuffer::sGLRenderBuffer = 0;
47U32 LLVertexBuffer::sGLRenderIndices = 0; 57U32 LLVertexBuffer::sGLRenderIndices = 0;
@@ -50,9 +60,9 @@ BOOL LLVertexBuffer::sVBOActive = FALSE;
50BOOL LLVertexBuffer::sIBOActive = FALSE; 60BOOL LLVertexBuffer::sIBOActive = FALSE;
51U32 LLVertexBuffer::sAllocatedBytes = 0; 61U32 LLVertexBuffer::sAllocatedBytes = 0;
52BOOL LLVertexBuffer::sRenderActive = FALSE; 62BOOL LLVertexBuffer::sRenderActive = FALSE;
63BOOL LLVertexBuffer::sMapped = FALSE;
53 64
54std::vector<U32> LLVertexBuffer::sDeleteList; 65std::vector<U32> LLVertexBuffer::sDeleteList;
55LLVertexBuffer::buffer_list_t LLVertexBuffer::sLockedList;
56 66
57S32 LLVertexBuffer::sTypeOffsets[LLVertexBuffer::TYPE_MAX] = 67S32 LLVertexBuffer::sTypeOffsets[LLVertexBuffer::TYPE_MAX] =
58{ 68{
@@ -70,6 +80,10 @@ S32 LLVertexBuffer::sTypeOffsets[LLVertexBuffer::TYPE_MAX] =
70void LLVertexBuffer::initClass(bool use_vbo) 80void LLVertexBuffer::initClass(bool use_vbo)
71{ 81{
72 sEnableVBOs = use_vbo; 82 sEnableVBOs = use_vbo;
83 LLGLNamePool::registerPool(&sDynamicVBOPool);
84 LLGLNamePool::registerPool(&sDynamicIBOPool);
85 LLGLNamePool::registerPool(&sStreamVBOPool);
86 LLGLNamePool::registerPool(&sStreamIBOPool);
73} 87}
74 88
75//static 89//static
@@ -88,13 +102,13 @@ void LLVertexBuffer::unbind()
88 102
89 sGLRenderBuffer = 0; 103 sGLRenderBuffer = 0;
90 sGLRenderIndices = 0; 104 sGLRenderIndices = 0;
105 sLastMask = 0;
91} 106}
92 107
93//static 108//static
94void LLVertexBuffer::cleanupClass() 109void LLVertexBuffer::cleanupClass()
95{ 110{
96 LLMemType mt(LLMemType::MTYPE_VERTEX_DATA); 111 LLMemType mt(LLMemType::MTYPE_VERTEX_DATA);
97 sLockedList.clear();
98 startRender(); 112 startRender();
99 stopRender(); 113 stopRender();
100 clientCopy(); // deletes GL buffers 114 clientCopy(); // deletes GL buffers
@@ -127,41 +141,8 @@ void LLVertexBuffer::clientCopy(F64 max_time)
127{ 141{
128 if (!sDeleteList.empty()) 142 if (!sDeleteList.empty())
129 { 143 {
130 size_t num = sDeleteList.size();
131 glDeleteBuffersARB(sDeleteList.size(), (GLuint*) &(sDeleteList[0])); 144 glDeleteBuffersARB(sDeleteList.size(), (GLuint*) &(sDeleteList[0]));
132 sDeleteList.clear(); 145 sDeleteList.clear();
133 sGLCount -= num;
134 }
135
136 if (sEnableVBOs)
137 {
138 LLTimer timer;
139 BOOL reset = TRUE;
140 buffer_list_t::iterator iter = sLockedList.begin();
141 while(iter != sLockedList.end())
142 {
143 LLVertexBuffer* buffer = *iter;
144 if (buffer->isLocked() && buffer->useVBOs())
145 {
146 buffer->setBuffer(0);
147 }
148 ++iter;
149 if (reset)
150 {
151 reset = FALSE;
152 timer.reset(); //skip first copy (don't count pipeline stall)
153 }
154 else
155 {
156 if (timer.getElapsedTimeF64() > max_time)
157 {
158 break;
159 }
160 }
161
162 }
163
164 sLockedList.erase(sLockedList.begin(), iter);
165 } 146 }
166} 147}
167 148
@@ -175,27 +156,40 @@ LLVertexBuffer::LLVertexBuffer(U32 typemask, S32 usage) :
175 mFinal(FALSE), 156 mFinal(FALSE),
176 mFilthy(FALSE), 157 mFilthy(FALSE),
177 mEmpty(TRUE), 158 mEmpty(TRUE),
178 mResized(FALSE) 159 mResized(FALSE),
160 mDynamicSize(FALSE)
179{ 161{
180 LLMemType mt(LLMemType::MTYPE_VERTEX_DATA); 162 LLMemType mt(LLMemType::MTYPE_VERTEX_DATA);
181 if (!sEnableVBOs) 163 if (!sEnableVBOs)
182 { 164 {
183 mUsage = GL_STREAM_DRAW_ARB; 165 mUsage = 0 ;
184 } 166 }
185 167
168 S32 stride = calcStride(typemask, mOffsets);
169
170 mTypeMask = typemask;
171 mStride = stride;
172 sCount++;
173}
174
175//static
176S32 LLVertexBuffer::calcStride(const U32& typemask, S32* offsets)
177{
186 S32 stride = 0; 178 S32 stride = 0;
187 for (S32 i=0; i<TYPE_MAX; i++) 179 for (S32 i=0; i<TYPE_MAX; i++)
188 { 180 {
189 U32 mask = 1<<i; 181 U32 mask = 1<<i;
190 if (typemask & mask) 182 if (typemask & mask)
191 { 183 {
192 mOffsets[i] = stride; 184 if (offsets)
185 {
186 offsets[i] = stride;
187 }
193 stride += sTypeOffsets[i]; 188 stride += sTypeOffsets[i];
194 } 189 }
195 } 190 }
196 mTypeMask = typemask; 191
197 mStride = stride; 192 return stride;
198 sCount++;
199} 193}
200 194
201// protected, use unref() 195// protected, use unref()
@@ -206,23 +200,80 @@ LLVertexBuffer::~LLVertexBuffer()
206 destroyGLBuffer(); 200 destroyGLBuffer();
207 destroyGLIndices(); 201 destroyGLIndices();
208 sCount--; 202 sCount--;
209
210 if (mLocked)
211 {
212 //pull off of locked list
213 for (buffer_list_t::iterator i = sLockedList.begin(); i != sLockedList.end(); ++i)
214 {
215 if (*i == this)
216 {
217 sLockedList.erase(i);
218 break;
219 }
220 }
221 }
222}; 203};
223 204
224//---------------------------------------------------------------------------- 205//----------------------------------------------------------------------------
225 206
207void LLVertexBuffer::genBuffer()
208{
209 if (mUsage == GL_STREAM_DRAW_ARB)
210 {
211 mGLBuffer = sStreamVBOPool.allocate();
212 }
213 else if (mUsage == GL_DYNAMIC_DRAW_ARB)
214 {
215 mGLBuffer = sDynamicVBOPool.allocate();
216 }
217 else
218 {
219 BOOST_STATIC_ASSERT(sizeof(mGLBuffer) == sizeof(GLuint));
220 glGenBuffersARB(1, (GLuint*)&mGLBuffer);
221 }
222 sGLCount++;
223}
224
225void LLVertexBuffer::genIndices()
226{
227 if (mUsage == GL_STREAM_DRAW_ARB)
228 {
229 mGLIndices = sStreamIBOPool.allocate();
230 }
231 else if (mUsage == GL_DYNAMIC_DRAW_ARB)
232 {
233 mGLIndices = sDynamicIBOPool.allocate();
234 }
235 else
236 {
237 BOOST_STATIC_ASSERT(sizeof(mGLBuffer) == sizeof(GLuint));
238 glGenBuffersARB(1, (GLuint*)&mGLIndices);
239 }
240 sGLCount++;
241}
242
243void LLVertexBuffer::releaseBuffer()
244{
245 if (mUsage == GL_STREAM_DRAW_ARB)
246 {
247 sStreamVBOPool.release(mGLBuffer);
248 }
249 else if (mUsage == GL_DYNAMIC_DRAW_ARB)
250 {
251 sDynamicVBOPool.release(mGLBuffer);
252 }
253 else
254 {
255 sDeleteList.push_back(mGLBuffer);
256 }
257 sGLCount--;
258}
259
260void LLVertexBuffer::releaseIndices()
261{
262 if (mUsage == GL_STREAM_DRAW_ARB)
263 {
264 sStreamIBOPool.release(mGLIndices);
265 }
266 else if (mUsage == GL_DYNAMIC_DRAW_ARB)
267 {
268 sDynamicIBOPool.release(mGLIndices);
269 }
270 else
271 {
272 sDeleteList.push_back(mGLIndices);
273 }
274 sGLCount--;
275}
276
226void LLVertexBuffer::createGLBuffer() 277void LLVertexBuffer::createGLBuffer()
227{ 278{
228 LLMemType mt(LLMemType::MTYPE_VERTEX_DATA); 279 LLMemType mt(LLMemType::MTYPE_VERTEX_DATA);
@@ -238,20 +289,20 @@ void LLVertexBuffer::createGLBuffer()
238 return; 289 return;
239 } 290 }
240 291
241 mMappedData = new U8[size];
242 memset(mMappedData, 0, size);
243 mEmpty = TRUE; 292 mEmpty = TRUE;
244 293
245 if (useVBOs()) 294 if (useVBOs())
246 { 295 {
247 glGenBuffersARB(1, (GLuint*) &mGLBuffer); 296 mMappedData = NULL;
297 genBuffer();
248 mResized = TRUE; 298 mResized = TRUE;
249 sGLCount++;
250 } 299 }
251 else 300 else
252 { 301 {
253 static int gl_buffer_idx = 0; 302 static int gl_buffer_idx = 0;
254 mGLBuffer = ++gl_buffer_idx; 303 mGLBuffer = ++gl_buffer_idx;
304 mMappedData = new U8[size];
305 memset(mMappedData, 0, size);
255 } 306 }
256} 307}
257 308
@@ -270,18 +321,18 @@ void LLVertexBuffer::createGLIndices()
270 return; 321 return;
271 } 322 }
272 323
273 mMappedIndexData = new U8[size];
274 memset(mMappedIndexData, 0, size);
275 mEmpty = TRUE; 324 mEmpty = TRUE;
276 325
277 if (useVBOs()) 326 if (useVBOs())
278 { 327 {
279 glGenBuffersARB(1, (GLuint*) &mGLIndices); 328 mMappedIndexData = NULL;
329 genIndices();
280 mResized = TRUE; 330 mResized = TRUE;
281 sGLCount++;
282 } 331 }
283 else 332 else
284 { 333 {
334 mMappedIndexData = new U8[size];
335 memset(mMappedIndexData, 0, size);
285 static int gl_buffer_idx = 0; 336 static int gl_buffer_idx = 0;
286 mGLIndices = ++gl_buffer_idx; 337 mGLIndices = ++gl_buffer_idx;
287 } 338 }
@@ -294,12 +345,19 @@ void LLVertexBuffer::destroyGLBuffer()
294 { 345 {
295 if (useVBOs()) 346 if (useVBOs())
296 { 347 {
297 sDeleteList.push_back(mGLBuffer); 348 if (mMappedData || mMappedIndexData)
349 {
350 llerrs << "Vertex buffer destroyed while mapped!" << llendl;
351 }
352 releaseBuffer();
353 }
354 else
355 {
356 delete [] mMappedData;
357 mMappedData = NULL;
358 mEmpty = TRUE;
298 } 359 }
299 360
300 delete [] mMappedData;
301 mMappedData = NULL;
302 mEmpty = TRUE;
303 sAllocatedBytes -= getSize(); 361 sAllocatedBytes -= getSize();
304 } 362 }
305 363
@@ -313,12 +371,19 @@ void LLVertexBuffer::destroyGLIndices()
313 { 371 {
314 if (useVBOs()) 372 if (useVBOs())
315 { 373 {
316 sDeleteList.push_back(mGLIndices); 374 if (mMappedData || mMappedIndexData)
375 {
376 llerrs << "Vertex buffer destroyed while mapped." << llendl;
377 }
378 releaseIndices();
379 }
380 else
381 {
382 delete [] mMappedIndexData;
383 mMappedIndexData = NULL;
384 mEmpty = TRUE;
317 } 385 }
318 386
319 delete [] mMappedIndexData;
320 mMappedIndexData = NULL;
321 mEmpty = TRUE;
322 sAllocatedBytes -= getIndicesSize(); 387 sAllocatedBytes -= getIndicesSize();
323 } 388 }
324 389
@@ -328,6 +393,15 @@ void LLVertexBuffer::destroyGLIndices()
328void LLVertexBuffer::updateNumVerts(S32 nverts) 393void LLVertexBuffer::updateNumVerts(S32 nverts)
329{ 394{
330 LLMemType mt(LLMemType::MTYPE_VERTEX_DATA); 395 LLMemType mt(LLMemType::MTYPE_VERTEX_DATA);
396
397 if (nverts >= 65535)
398 {
399 llwarns << "Vertex buffer overflow!" << llendl;
400 nverts = 65535;
401 }
402
403 mRequestedNumVerts = nverts;
404
331 if (!mDynamicSize) 405 if (!mDynamicSize)
332 { 406 {
333 mNumVerts = nverts; 407 mNumVerts = nverts;
@@ -336,18 +410,19 @@ void LLVertexBuffer::updateNumVerts(S32 nverts)
336 nverts > mNumVerts || 410 nverts > mNumVerts ||
337 nverts < mNumVerts/2) 411 nverts < mNumVerts/2)
338 { 412 {
339 if (mUsage != GL_STATIC_DRAW_ARB) 413 if (mUsage != GL_STATIC_DRAW_ARB && nverts + nverts/4 <= 65535)
340 { 414 {
341 nverts += nverts/4; 415 nverts += nverts/4;
342 } 416 }
343
344 mNumVerts = nverts; 417 mNumVerts = nverts;
345 } 418 }
419
346} 420}
347 421
348void LLVertexBuffer::updateNumIndices(S32 nindices) 422void LLVertexBuffer::updateNumIndices(S32 nindices)
349{ 423{
350 LLMemType mt(LLMemType::MTYPE_VERTEX_DATA); 424 LLMemType mt(LLMemType::MTYPE_VERTEX_DATA);
425 mRequestedNumIndices = nindices;
351 if (!mDynamicSize) 426 if (!mDynamicSize)
352 { 427 {
353 mNumIndices = nindices; 428 mNumIndices = nindices;
@@ -365,54 +440,6 @@ void LLVertexBuffer::updateNumIndices(S32 nindices)
365 } 440 }
366} 441}
367 442
368void LLVertexBuffer::makeStatic()
369{
370 if (!sEnableVBOs)
371 {
372 return;
373 }
374
375 if (sRenderActive)
376 {
377 llerrs << "Make static called during render." << llendl;
378 }
379
380 if (mUsage != GL_STATIC_DRAW_ARB)
381 {
382 if (useVBOs())
383 {
384 if (mGLBuffer)
385 {
386 sDeleteList.push_back(mGLBuffer);
387 }
388 if (mGLIndices)
389 {
390 sDeleteList.push_back(mGLIndices);
391 }
392 }
393
394 if (mGLBuffer)
395 {
396 sGLCount++;
397 glGenBuffersARB(1, (GLuint*) &mGLBuffer);
398 }
399 if (mGLIndices)
400 {
401 sGLCount++;
402 glGenBuffersARB(1, (GLuint*) &mGLIndices);
403 }
404
405 mUsage = GL_STATIC_DRAW_ARB;
406 mResized = TRUE;
407
408 if (!mLocked)
409 {
410 mLocked = TRUE;
411 sLockedList.push_back(this);
412 }
413 }
414}
415
416void LLVertexBuffer::allocateBuffer(S32 nverts, S32 nindices, bool create) 443void LLVertexBuffer::allocateBuffer(S32 nverts, S32 nindices, bool create)
417{ 444{
418 LLMemType mt(LLMemType::MTYPE_VERTEX_DATA); 445 LLMemType mt(LLMemType::MTYPE_VERTEX_DATA);
@@ -435,6 +462,9 @@ void LLVertexBuffer::allocateBuffer(S32 nverts, S32 nindices, bool create)
435 462
436void LLVertexBuffer::resizeBuffer(S32 newnverts, S32 newnindices) 463void LLVertexBuffer::resizeBuffer(S32 newnverts, S32 newnindices)
437{ 464{
465 mRequestedNumVerts = newnverts;
466 mRequestedNumIndices = newnindices;
467
438 LLMemType mt(LLMemType::MTYPE_VERTEX_DATA); 468 LLMemType mt(LLMemType::MTYPE_VERTEX_DATA);
439 mDynamicSize = TRUE; 469 mDynamicSize = TRUE;
440 if (mUsage == GL_STATIC_DRAW_ARB) 470 if (mUsage == GL_STATIC_DRAW_ARB)
@@ -469,22 +499,25 @@ void LLVertexBuffer::resizeBuffer(S32 newnverts, S32 newnindices)
469 else 499 else
470 { 500 {
471 //delete old buffer, keep GL buffer for now 501 //delete old buffer, keep GL buffer for now
472 U8* old = mMappedData; 502 if (!useVBOs())
473 mMappedData = new U8[newsize]; 503 {
474 if (old) 504 U8* old = mMappedData;
475 { 505 mMappedData = new U8[newsize];
476 memcpy(mMappedData, old, llmin(newsize, oldsize)); 506 if (old)
477 if (newsize > oldsize) 507 {
508 memcpy(mMappedData, old, llmin(newsize, oldsize));
509 if (newsize > oldsize)
510 {
511 memset(mMappedData+oldsize, 0, newsize-oldsize);
512 }
513
514 delete [] old;
515 }
516 else
478 { 517 {
479 memset(mMappedData+oldsize, 0, newsize-oldsize); 518 memset(mMappedData, 0, newsize);
519 mEmpty = TRUE;
480 } 520 }
481
482 delete [] old;
483 }
484 else
485 {
486 memset(mMappedData, 0, newsize);
487 mEmpty = TRUE;
488 } 521 }
489 mResized = TRUE; 522 mResized = TRUE;
490 } 523 }
@@ -502,22 +535,26 @@ void LLVertexBuffer::resizeBuffer(S32 newnverts, S32 newnindices)
502 } 535 }
503 else 536 else
504 { 537 {
505 //delete old buffer, keep GL buffer for now 538 if (!useVBOs())
506 U8* old = mMappedIndexData; 539 {
507 mMappedIndexData = new U8[new_index_size]; 540 //delete old buffer, keep GL buffer for now
508 if (old) 541 U8* old = mMappedIndexData;
509 { 542 mMappedIndexData = new U8[new_index_size];
510 memcpy(mMappedIndexData, old, llmin(new_index_size, old_index_size)); 543
511 if (new_index_size > old_index_size) 544 if (old)
545 {
546 memcpy(mMappedIndexData, old, llmin(new_index_size, old_index_size));
547 if (new_index_size > old_index_size)
548 {
549 memset(mMappedIndexData+old_index_size, 0, new_index_size - old_index_size);
550 }
551 delete [] old;
552 }
553 else
512 { 554 {
513 memset(mMappedIndexData+old_index_size, 0, new_index_size - old_index_size); 555 memset(mMappedIndexData, 0, new_index_size);
556 mEmpty = TRUE;
514 } 557 }
515 delete [] old;
516 }
517 else
518 {
519 memset(mMappedIndexData, 0, new_index_size);
520 mEmpty = TRUE;
521 } 558 }
522 mResized = TRUE; 559 mResized = TRUE;
523 } 560 }
@@ -527,18 +564,29 @@ void LLVertexBuffer::resizeBuffer(S32 newnverts, S32 newnindices)
527 destroyGLIndices(); 564 destroyGLIndices();
528 } 565 }
529 } 566 }
567
568 if (mResized && useVBOs())
569 {
570 setBuffer(0);
571 }
530} 572}
531 573
532BOOL LLVertexBuffer::useVBOs() const 574BOOL LLVertexBuffer::useVBOs() const
533{ 575{
534 //it's generally ineffective to use VBO for things that are streaming 576 //it's generally ineffective to use VBO for things that are streaming on apple
535 //when we already have a client buffer around 577
536 if (mUsage == GL_STREAM_DRAW_ARB) 578#if LL_DARWIN
579 if (!mUsage || mUsage == GL_STREAM_DRAW_ARB)
537 { 580 {
538 return FALSE; 581 return FALSE;
539 } 582 }
540 583#else
541 return sEnableVBOs && (!sRenderActive || !mLocked); 584 if (!mUsage)
585 {
586 return FALSE;
587 }
588#endif
589 return sEnableVBOs; // && (!sRenderActive || !mLocked);
542} 590}
543 591
544//---------------------------------------------------------------------------- 592//----------------------------------------------------------------------------
@@ -547,27 +595,27 @@ BOOL LLVertexBuffer::useVBOs() const
547U8* LLVertexBuffer::mapBuffer(S32 access) 595U8* LLVertexBuffer::mapBuffer(S32 access)
548{ 596{
549 LLMemType mt(LLMemType::MTYPE_VERTEX_DATA); 597 LLMemType mt(LLMemType::MTYPE_VERTEX_DATA);
550 if (sRenderActive)
551 {
552 llwarns << "Buffer mapped during render frame!" << llendl;
553 }
554 if (!mGLBuffer && !mGLIndices)
555 {
556 llerrs << "LLVertexBuffer::mapBuffer() called before createGLBuffer" << llendl;
557 }
558 if (mFinal) 598 if (mFinal)
559 { 599 {
560 llerrs << "LLVertexBuffer::mapBuffer() called on a finalized buffer." << llendl; 600 llerrs << "LLVertexBuffer::mapBuffer() called on a finalized buffer." << llendl;
561 } 601 }
562 if (!mMappedData && !mMappedIndexData) 602 if (!useVBOs() && !mMappedData && !mMappedIndexData)
563 { 603 {
564 llerrs << "LLVertexBuffer::mapBuffer() called on unallocated buffer." << llendl; 604 llerrs << "LLVertexBuffer::mapBuffer() called on unallocated buffer." << llendl;
565 } 605 }
566 606
567 if (!mLocked && useVBOs()) 607 if (!mLocked && useVBOs())
568 { 608 {
609 setBuffer(0);
569 mLocked = TRUE; 610 mLocked = TRUE;
570 sLockedList.push_back(this); 611 mMappedData = (U8*) glMapBufferARB(GL_ARRAY_BUFFER_ARB, GL_WRITE_ONLY_ARB);
612 mMappedIndexData = (U8*) glMapBufferARB(GL_ELEMENT_ARRAY_BUFFER_ARB, GL_WRITE_ONLY_ARB);
613 /*if (sMapped)
614 {
615 llerrs << "Mapped two VBOs at the same time!" << llendl;
616 }
617 sMapped = TRUE;*/
618 sMappedCount++;
571 } 619 }
572 620
573 return mMappedData; 621 return mMappedData;
@@ -580,64 +628,19 @@ void LLVertexBuffer::unmapBuffer()
580 { 628 {
581 if (useVBOs() && mLocked) 629 if (useVBOs() && mLocked)
582 { 630 {
583 if (mGLBuffer) 631 glUnmapBufferARB(GL_ARRAY_BUFFER_ARB);
584 { 632 glUnmapBufferARB(GL_ELEMENT_ARRAY_BUFFER_ARB);
585 if (mResized) 633
586 { 634 /*if (!sMapped)
587 glBufferDataARB(GL_ARRAY_BUFFER_ARB, getSize(), mMappedData, mUsage);
588 }
589 else
590 {
591 if (mEmpty || mDirtyRegions.empty())
592 {
593 glBufferSubDataARB(GL_ARRAY_BUFFER_ARB, 0, getSize(), mMappedData);
594 }
595 else
596 {
597 for (std::vector<DirtyRegion>::iterator i = mDirtyRegions.begin(); i != mDirtyRegions.end(); ++i)
598 {
599 DirtyRegion& region = *i;
600 glBufferSubDataARB(GL_ARRAY_BUFFER_ARB, region.mIndex*mStride, region.mCount*mStride, mMappedData + region.mIndex*mStride);
601 }
602 }
603 }
604 }
605
606 if (mGLIndices)
607 { 635 {
608 if (mResized) 636 llerrs << "Redundantly unmapped VBO!" << llendl;
609 {
610 glBufferDataARB(GL_ELEMENT_ARRAY_BUFFER_ARB, getIndicesSize(), mMappedIndexData, mUsage);
611 }
612 else
613 {
614 if (mEmpty || mDirtyRegions.empty())
615 {
616 glBufferSubDataARB(GL_ELEMENT_ARRAY_BUFFER_ARB, 0, getIndicesSize(), mMappedIndexData);
617 }
618 else
619 {
620 for (std::vector<DirtyRegion>::iterator i = mDirtyRegions.begin(); i != mDirtyRegions.end(); ++i)
621 {
622 DirtyRegion& region = *i;
623 glBufferSubDataARB(GL_ELEMENT_ARRAY_BUFFER_ARB, region.mIndicesIndex*sizeof(U32),
624 region.mIndicesCount*sizeof(U32), mMappedIndexData + region.mIndicesIndex*sizeof(U32));
625 }
626 }
627 }
628 } 637 }
629 638 sMapped = FALSE;*/
630 mDirtyRegions.clear(); 639 sMappedCount--;
631 mFilthy = FALSE;
632 mResized = FALSE;
633 640
634 if (mUsage == GL_STATIC_DRAW_ARB) 641 if (mUsage == GL_STATIC_DRAW_ARB)
635 { //static draw buffers can only be mapped a single time 642 { //static draw buffers can only be mapped a single time
636 //throw out client data (we won't be using it again) 643 //throw out client data (we won't be using it again)
637 delete [] mMappedData;
638 delete [] mMappedIndexData;
639 mMappedIndexData = NULL;
640 mMappedData = NULL;
641 mEmpty = TRUE; 644 mEmpty = TRUE;
642 mFinal = TRUE; 645 mFinal = TRUE;
643 } 646 }
@@ -645,10 +648,11 @@ void LLVertexBuffer::unmapBuffer()
645 { 648 {
646 mEmpty = FALSE; 649 mEmpty = FALSE;
647 } 650 }
651
652 mMappedIndexData = NULL;
653 mMappedData = NULL;
648 654
649 mLocked = FALSE; 655 mLocked = FALSE;
650
651 glFlush();
652 } 656 }
653 } 657 }
654} 658}
@@ -690,9 +694,9 @@ bool LLVertexBuffer::getVertexStrider(LLStrider<LLVector3>& strider, S32 index)
690{ 694{
691 return VertexBufferStrider<LLVector3,TYPE_VERTEX>::get(*this, strider, index); 695 return VertexBufferStrider<LLVector3,TYPE_VERTEX>::get(*this, strider, index);
692} 696}
693bool LLVertexBuffer::getIndexStrider(LLStrider<U32>& strider, S32 index) 697bool LLVertexBuffer::getIndexStrider(LLStrider<U16>& strider, S32 index)
694{ 698{
695 return VertexBufferStrider<U32,TYPE_INDEX>::get(*this, strider, index); 699 return VertexBufferStrider<U16,TYPE_INDEX>::get(*this, strider, index);
696} 700}
697bool LLVertexBuffer::getTexCoordStrider(LLStrider<LLVector2>& strider, S32 index) 701bool LLVertexBuffer::getTexCoordStrider(LLStrider<LLVector2>& strider, S32 index)
698{ 702{
@@ -755,16 +759,46 @@ void LLVertexBuffer::setBuffer(U32 data_mask)
755 { 759 {
756 if (mGLBuffer && (mGLBuffer != sGLRenderBuffer || !sVBOActive)) 760 if (mGLBuffer && (mGLBuffer != sGLRenderBuffer || !sVBOActive))
757 { 761 {
762 /*if (sMapped)
763 {
764 llerrs << "VBO bound while another VBO mapped!" << llendl;
765 }*/
758 glBindBufferARB(GL_ARRAY_BUFFER_ARB, mGLBuffer); 766 glBindBufferARB(GL_ARRAY_BUFFER_ARB, mGLBuffer);
767 sBindCount++;
759 sVBOActive = TRUE; 768 sVBOActive = TRUE;
760 setup = TRUE; // ... or the bound buffer changed 769 setup = TRUE; // ... or the bound buffer changed
761 } 770 }
762 if (mGLIndices && (mGLIndices != sGLRenderIndices || !sIBOActive)) 771 if (mGLIndices && (mGLIndices != sGLRenderIndices || !sIBOActive))
763 { 772 {
773 /*if (sMapped)
774 {
775 llerrs << "VBO bound while another VBO mapped!" << llendl;
776 }*/
764 glBindBufferARB(GL_ELEMENT_ARRAY_BUFFER_ARB, mGLIndices); 777 glBindBufferARB(GL_ELEMENT_ARRAY_BUFFER_ARB, mGLIndices);
778 sBindCount++;
765 sIBOActive = TRUE; 779 sIBOActive = TRUE;
766 } 780 }
767 781
782 if (mResized)
783 {
784 if (mGLBuffer)
785 {
786 glBufferDataARB(GL_ARRAY_BUFFER_ARB, getSize(), NULL, mUsage);
787 }
788 if (mGLIndices)
789 {
790 glBufferDataARB(GL_ELEMENT_ARRAY_BUFFER_ARB, getIndicesSize(), NULL, mUsage);
791 }
792
793 mEmpty = TRUE;
794 mResized = FALSE;
795
796 if (data_mask != 0)
797 {
798 llerrs << "Buffer set for rendering before being filled after resize." << llendl;
799 }
800 }
801
768 unmapBuffer(); 802 unmapBuffer();
769 } 803 }
770 else 804 else
@@ -774,6 +808,7 @@ void LLVertexBuffer::setBuffer(U32 data_mask)
774 if (sEnableVBOs && sVBOActive) 808 if (sEnableVBOs && sVBOActive)
775 { 809 {
776 glBindBufferARB(GL_ARRAY_BUFFER_ARB, 0); 810 glBindBufferARB(GL_ARRAY_BUFFER_ARB, 0);
811 sBindCount++;
777 sVBOActive = FALSE; 812 sVBOActive = FALSE;
778 setup = TRUE; // ... or a VBO is deactivated 813 setup = TRUE; // ... or a VBO is deactivated
779 } 814 }
@@ -784,7 +819,12 @@ void LLVertexBuffer::setBuffer(U32 data_mask)
784 } 819 }
785 if (sEnableVBOs && mGLIndices && sIBOActive) 820 if (sEnableVBOs && mGLIndices && sIBOActive)
786 { 821 {
822 /*if (sMapped)
823 {
824 llerrs << "VBO unbound while potentially mapped!" << llendl;
825 }*/
787 glBindBufferARB(GL_ELEMENT_ARRAY_BUFFER_ARB, 0); 826 glBindBufferARB(GL_ELEMENT_ARRAY_BUFFER_ARB, 0);
827 sBindCount++;
788 sIBOActive = FALSE; 828 sIBOActive = FALSE;
789 } 829 }
790 } 830 }
@@ -803,9 +843,11 @@ void LLVertexBuffer::setBuffer(U32 data_mask)
803 llwarns << "Vertex buffer set for rendering outside of render frame." << llendl; 843 llwarns << "Vertex buffer set for rendering outside of render frame." << llendl;
804 } 844 }
805 setupVertexBuffer(data_mask); // subclass specific setup (virtual function) 845 setupVertexBuffer(data_mask); // subclass specific setup (virtual function)
806 sLastMask = data_mask; 846 sSetCount++;
807 } 847 }
808 } 848 }
849
850 sLastMask = data_mask;
809} 851}
810 852
811// virtual (default) 853// virtual (default)
@@ -821,10 +863,6 @@ void LLVertexBuffer::setupVertexBuffer(U32 data_mask) const
821 llerrs << "LLVertexBuffer::setupVertexBuffer missing required components for supplied data mask." << llendl; 863 llerrs << "LLVertexBuffer::setupVertexBuffer missing required components for supplied data mask." << llendl;
822 } 864 }
823 865
824 if (data_mask & MAP_VERTEX)
825 {
826 glVertexPointer(3,GL_FLOAT, stride, (void*)(base + 0));
827 }
828 if (data_mask & MAP_NORMAL) 866 if (data_mask & MAP_NORMAL)
829 { 867 {
830 glNormalPointer(GL_FLOAT, stride, (void*)(base + mOffsets[TYPE_NORMAL])); 868 glNormalPointer(GL_FLOAT, stride, (void*)(base + mOffsets[TYPE_NORMAL]));
@@ -855,49 +893,19 @@ void LLVertexBuffer::setupVertexBuffer(U32 data_mask) const
855 { 893 {
856 glVertexAttribPointerARB(4, 4, GL_FLOAT, TRUE, stride, (void*)(base + mOffsets[TYPE_CLOTHWEIGHT])); 894 glVertexAttribPointerARB(4, 4, GL_FLOAT, TRUE, stride, (void*)(base + mOffsets[TYPE_CLOTHWEIGHT]));
857 } 895 }
896 if (data_mask & MAP_VERTEX)
897 {
898 glVertexPointer(3,GL_FLOAT, stride, (void*)(base + 0));
899 }
858 900
859 llglassertok(); 901 llglassertok();
860} 902}
861 903
862void LLVertexBuffer::markDirty(U32 vert_index, U32 vert_count, U32 indices_index, U32 indices_count) 904void LLVertexBuffer::markDirty(U32 vert_index, U32 vert_count, U32 indices_index, U32 indices_count)
863{ 905{
864 if (useVBOs() && !mFilthy) 906 // TODO: use GL_APPLE_flush_buffer_range here
865 { 907 /*if (useVBOs() && !mFilthy)
866 if (!mDirtyRegions.empty())
867 {
868 DirtyRegion& region = *(mDirtyRegions.rbegin());
869
870 if (region.mIndex+region.mCount > vert_index)
871 {
872 //this buffer has received multiple updates since the last copy, mark it filthy
873 mFilthy = TRUE;
874 mDirtyRegions.clear();
875 return;
876 }
877
878 if (region.mIndex + region.mCount == vert_index &&
879 region.mIndicesIndex + region.mIndicesCount == indices_index)
880 {
881 region.mCount += vert_count;
882 region.mIndicesCount += indices_count;
883 return;
884 }
885 }
886
887 mDirtyRegions.push_back(DirtyRegion(vert_index,vert_count,indices_index,indices_count));
888 }
889}
890
891void LLVertexBuffer::markClean()
892{
893 if (!mResized && !mEmpty && !mFilthy)
894 { 908 {
895 buffer_list_t::reverse_iterator iter = sLockedList.rbegin(); 909
896 if (*iter == this) 910 }*/
897 {
898 mLocked = FALSE;
899 sLockedList.pop_back();
900 }
901 }
902} 911}
903
diff --git a/linden/indra/llrender/llvertexbuffer.h b/linden/indra/llrender/llvertexbuffer.h
index 43a32c9..3031b2d 100644
--- a/linden/indra/llrender/llvertexbuffer.h
+++ b/linden/indra/llrender/llvertexbuffer.h
@@ -50,12 +50,38 @@
50// be called as soon as getVertexPointer(), etc is called (which MUST ONLY be 50// be called as soon as getVertexPointer(), etc is called (which MUST ONLY be
51// called from the main (i.e OpenGL) thread) 51// called from the main (i.e OpenGL) thread)
52 52
53
54//============================================================================
55// gl name pools for dynamic and streaming buffers
56
57class LLVBOPool : public LLGLNamePool
58{
59protected:
60 virtual GLuint allocateName()
61 {
62 GLuint name;
63 glGenBuffersARB(1, &name);
64 return name;
65 }
66
67 virtual void releaseName(GLuint name)
68 {
69 glDeleteBuffersARB(1, &name);
70 }
71};
72
73
53//============================================================================ 74//============================================================================
54// base class 75// base class
55 76
56class LLVertexBuffer : public LLRefCount 77class LLVertexBuffer : public LLRefCount
57{ 78{
58public: 79public:
80 static LLVBOPool sStreamVBOPool;
81 static LLVBOPool sDynamicVBOPool;
82 static LLVBOPool sStreamIBOPool;
83 static LLVBOPool sDynamicIBOPool;
84
59 static void initClass(bool use_vbo); 85 static void initClass(bool use_vbo);
60 static void cleanupClass(); 86 static void cleanupClass();
61 static void startRender(); //between start and stop render, no client copies will occur 87 static void startRender(); //between start and stop render, no client copies will occur
@@ -63,6 +89,12 @@ public:
63 static void clientCopy(F64 max_time = 0.005); //copy data from client to GL 89 static void clientCopy(F64 max_time = 0.005); //copy data from client to GL
64 static void unbind(); //unbind any bound vertex buffer 90 static void unbind(); //unbind any bound vertex buffer
65 91
92 //get the size of a vertex with the given typemask
93 //if offsets is not NULL, its contents will be filled
94 //with the offset of each vertex component in the buffer,
95 // indexed by the following enum
96 static S32 calcStride(const U32& typemask, S32* offsets = NULL);
97
66 enum { 98 enum {
67 TYPE_VERTEX, 99 TYPE_VERTEX,
68 TYPE_NORMAL, 100 TYPE_NORMAL,
@@ -92,10 +124,16 @@ public:
92 }; 124 };
93 125
94protected: 126protected:
127 friend class LLGLImmediate;
128
95 virtual ~LLVertexBuffer(); // use unref() 129 virtual ~LLVertexBuffer(); // use unref()
96 130
97 virtual void setupVertexBuffer(U32 data_mask) const; // pure virtual, called from mapBuffer() 131 virtual void setupVertexBuffer(U32 data_mask) const; // pure virtual, called from mapBuffer()
98 132
133 void genBuffer();
134 void genIndices();
135 void releaseBuffer();
136 void releaseIndices();
99 void createGLBuffer(); 137 void createGLBuffer();
100 void createGLIndices(); 138 void createGLIndices();
101 void destroyGLBuffer(); 139 void destroyGLBuffer();
@@ -104,7 +142,7 @@ protected:
104 void updateNumIndices(S32 nindices); 142 void updateNumIndices(S32 nindices);
105 virtual BOOL useVBOs() const; 143 virtual BOOL useVBOs() const;
106 void unmapBuffer(); 144 void unmapBuffer();
107 145
108public: 146public:
109 LLVertexBuffer(U32 typemask, S32 usage); 147 LLVertexBuffer(U32 typemask, S32 usage);
110 148
@@ -115,8 +153,7 @@ public:
115 // allocate buffer 153 // allocate buffer
116 void allocateBuffer(S32 nverts, S32 nindices, bool create); 154 void allocateBuffer(S32 nverts, S32 nindices, bool create);
117 virtual void resizeBuffer(S32 newnverts, S32 newnindices); 155 virtual void resizeBuffer(S32 newnverts, S32 newnindices);
118 void makeStatic(); 156
119
120 // Only call each getVertexPointer, etc, once before calling unmapBuffer() 157 // Only call each getVertexPointer, etc, once before calling unmapBuffer()
121 // call unmapBuffer() after calls to getXXXStrider() before any cals to setBuffer() 158 // call unmapBuffer() after calls to getXXXStrider() before any cals to setBuffer()
122 // example: 159 // example:
@@ -125,7 +162,7 @@ public:
125 // setVertsNorms(verts, norms); 162 // setVertsNorms(verts, norms);
126 // vb->unmapBuffer(); 163 // vb->unmapBuffer();
127 bool getVertexStrider(LLStrider<LLVector3>& strider, S32 index=0); 164 bool getVertexStrider(LLStrider<LLVector3>& strider, S32 index=0);
128 bool getIndexStrider(LLStrider<U32>& strider, S32 index=0); 165 bool getIndexStrider(LLStrider<U16>& strider, S32 index=0);
129 bool getTexCoordStrider(LLStrider<LLVector2>& strider, S32 index=0); 166 bool getTexCoordStrider(LLStrider<LLVector2>& strider, S32 index=0);
130 bool getTexCoord2Strider(LLStrider<LLVector2>& strider, S32 index=0); 167 bool getTexCoord2Strider(LLStrider<LLVector2>& strider, S32 index=0);
131 bool getNormalStrider(LLStrider<LLVector3>& strider, S32 index=0); 168 bool getNormalStrider(LLStrider<LLVector3>& strider, S32 index=0);
@@ -138,13 +175,16 @@ public:
138 BOOL isLocked() const { return mLocked; } 175 BOOL isLocked() const { return mLocked; }
139 S32 getNumVerts() const { return mNumVerts; } 176 S32 getNumVerts() const { return mNumVerts; }
140 S32 getNumIndices() const { return mNumIndices; } 177 S32 getNumIndices() const { return mNumIndices; }
178 S32 getRequestedVerts() const { return mRequestedNumVerts; }
179 S32 getRequestedIndices() const { return mRequestedNumIndices; }
180
141 U8* getIndicesPointer() const { return useVBOs() ? NULL : mMappedIndexData; } 181 U8* getIndicesPointer() const { return useVBOs() ? NULL : mMappedIndexData; }
142 U8* getVerticesPointer() const { return useVBOs() ? NULL : mMappedData; } 182 U8* getVerticesPointer() const { return useVBOs() ? NULL : mMappedData; }
143 S32 getStride() const { return mStride; } 183 S32 getStride() const { return mStride; }
144 S32 getTypeMask() const { return mTypeMask; } 184 S32 getTypeMask() const { return mTypeMask; }
145 BOOL hasDataType(S32 type) const { return ((1 << type) & getTypeMask()) ? TRUE : FALSE; } 185 BOOL hasDataType(S32 type) const { return ((1 << type) & getTypeMask()) ? TRUE : FALSE; }
146 S32 getSize() const { return mNumVerts*mStride; } 186 S32 getSize() const { return mNumVerts*mStride; }
147 S32 getIndicesSize() const { return mNumIndices * sizeof(U32); } 187 S32 getIndicesSize() const { return mNumIndices * sizeof(U16); }
148 U8* getMappedData() const { return mMappedData; } 188 U8* getMappedData() const { return mMappedData; }
149 U8* getMappedIndices() const { return mMappedIndexData; } 189 U8* getMappedIndices() const { return mMappedIndexData; }
150 S32 getOffset(S32 type) const { return mOffsets[type]; } 190 S32 getOffset(S32 type) const { return mOffsets[type]; }
@@ -153,11 +193,13 @@ public:
153 void setStride(S32 type, S32 new_stride); 193 void setStride(S32 type, S32 new_stride);
154 194
155 void markDirty(U32 vert_index, U32 vert_count, U32 indices_index, U32 indices_count); 195 void markDirty(U32 vert_index, U32 vert_count, U32 indices_index, U32 indices_count);
156 void markClean();
157 196
158protected: 197protected:
159 S32 mNumVerts; // Number of vertices 198 S32 mNumVerts; // Number of vertices allocated
160 S32 mNumIndices; // Number of indices 199 S32 mNumIndices; // Number of indices allocated
200 S32 mRequestedNumVerts; // Number of vertices requested
201 S32 mRequestedNumIndices; // Number of indices requested
202
161 S32 mStride; 203 S32 mStride;
162 U32 mTypeMask; 204 U32 mTypeMask;
163 S32 mUsage; // GL usage 205 S32 mUsage; // GL usage
@@ -192,10 +234,11 @@ public:
192 static BOOL sRenderActive; 234 static BOOL sRenderActive;
193 static S32 sCount; 235 static S32 sCount;
194 static S32 sGLCount; 236 static S32 sGLCount;
237 static S32 sMappedCount;
238 static BOOL sMapped;
195 static std::vector<U32> sDeleteList; 239 static std::vector<U32> sDeleteList;
196 typedef std::list<LLVertexBuffer*> buffer_list_t; 240 typedef std::list<LLVertexBuffer*> buffer_list_t;
197 static buffer_list_t sLockedList; 241
198
199 static BOOL sEnableVBOs; 242 static BOOL sEnableVBOs;
200 static S32 sTypeOffsets[TYPE_MAX]; 243 static S32 sTypeOffsets[TYPE_MAX];
201 static U32 sGLRenderBuffer; 244 static U32 sGLRenderBuffer;
@@ -204,6 +247,8 @@ public:
204 static BOOL sIBOActive; 247 static BOOL sIBOActive;
205 static U32 sLastMask; 248 static U32 sLastMask;
206 static U32 sAllocatedBytes; 249 static U32 sAllocatedBytes;
250 static U32 sBindCount;
251 static U32 sSetCount;
207}; 252};
208 253
209 254