aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/linden/indra/llrender/llvertexbuffer.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'linden/indra/llrender/llvertexbuffer.cpp')
-rw-r--r--linden/indra/llrender/llvertexbuffer.cpp65
1 files changed, 39 insertions, 26 deletions
diff --git a/linden/indra/llrender/llvertexbuffer.cpp b/linden/indra/llrender/llvertexbuffer.cpp
index ce80343..4c663e2 100644
--- a/linden/indra/llrender/llvertexbuffer.cpp
+++ b/linden/indra/llrender/llvertexbuffer.cpp
@@ -60,7 +60,6 @@ U32 LLVertexBuffer::sLastMask = 0;
60BOOL LLVertexBuffer::sVBOActive = FALSE; 60BOOL LLVertexBuffer::sVBOActive = FALSE;
61BOOL LLVertexBuffer::sIBOActive = FALSE; 61BOOL LLVertexBuffer::sIBOActive = FALSE;
62U32 LLVertexBuffer::sAllocatedBytes = 0; 62U32 LLVertexBuffer::sAllocatedBytes = 0;
63BOOL LLVertexBuffer::sRenderActive = FALSE;
64BOOL LLVertexBuffer::sMapped = FALSE; 63BOOL LLVertexBuffer::sMapped = FALSE;
65 64
66std::vector<U32> LLVertexBuffer::sDeleteList; 65std::vector<U32> LLVertexBuffer::sDeleteList;
@@ -84,16 +83,18 @@ U32 LLVertexBuffer::sGLMode[LLVertexBuffer::NUM_MODES] =
84 GL_TRIANGLE_FAN, 83 GL_TRIANGLE_FAN,
85 GL_POINTS, 84 GL_POINTS,
86 GL_LINES, 85 GL_LINES,
87 GL_LINE_STRIP 86 GL_LINE_STRIP,
87 GL_QUADS,
88 GL_LINE_LOOP,
88}; 89};
89 90
90//static 91//static
91void LLVertexBuffer::setupClientArrays(U32 data_mask) 92void LLVertexBuffer::setupClientArrays(U32 data_mask)
92{ 93{
93 if (LLGLImmediate::sStarted) 94 /*if (LLGLImmediate::sStarted)
94 { 95 {
95 llerrs << "Cannot use LLGLImmediate and LLVertexBuffer simultaneously!" << llendl; 96 llerrs << "Cannot use LLGLImmediate and LLVertexBuffer simultaneously!" << llendl;
96 } 97 }*/
97 98
98 if (sLastMask != data_mask) 99 if (sLastMask != data_mask)
99 { 100 {
@@ -186,6 +187,11 @@ void LLVertexBuffer::drawRange(U32 mode, U32 start, U32 end, U32 count, U32 indi
186 llerrs << "Wrong vertex buffer bound." << llendl; 187 llerrs << "Wrong vertex buffer bound." << llendl;
187 } 188 }
188 189
190 if (mode > NUM_MODES)
191 {
192 llerrs << "Invalid draw mode: " << mode << llendl;
193 }
194
189 glDrawRangeElements(sGLMode[mode], start, end, count, GL_UNSIGNED_SHORT, 195 glDrawRangeElements(sGLMode[mode], start, end, count, GL_UNSIGNED_SHORT,
190 ((U16*) getIndicesPointer()) + indices_offset); 196 ((U16*) getIndicesPointer()) + indices_offset);
191} 197}
@@ -208,10 +214,37 @@ void LLVertexBuffer::draw(U32 mode, U32 count, U32 indices_offset) const
208 llerrs << "Wrong vertex buffer bound." << llendl; 214 llerrs << "Wrong vertex buffer bound." << llendl;
209 } 215 }
210 216
217 if (mode > NUM_MODES)
218 {
219 llerrs << "Invalid draw mode: " << mode << llendl;
220 }
221
211 glDrawElements(sGLMode[mode], count, GL_UNSIGNED_SHORT, 222 glDrawElements(sGLMode[mode], count, GL_UNSIGNED_SHORT,
212 ((U16*) getIndicesPointer()) + indices_offset); 223 ((U16*) getIndicesPointer()) + indices_offset);
213} 224}
214 225
226void LLVertexBuffer::drawArrays(U32 mode, U32 first, U32 count) const
227{
228
229 if (first >= (U32) mRequestedNumVerts ||
230 first + count > (U32) mRequestedNumVerts)
231 {
232 llerrs << "Bad vertex buffer draw range: [" << first << ", " << first+count << "]" << llendl;
233 }
234
235 if (mGLBuffer != sGLRenderBuffer)
236 {
237 llerrs << "Wrong vertex buffer bound." << llendl;
238 }
239
240 if (mode > NUM_MODES)
241 {
242 llerrs << "Invalid draw mode: " << mode << llendl;
243 }
244
245 glDrawArrays(sGLMode[mode], first, count);
246}
247
215//static 248//static
216void LLVertexBuffer::initClass(bool use_vbo) 249void LLVertexBuffer::initClass(bool use_vbo)
217{ 250{
@@ -246,24 +279,8 @@ void LLVertexBuffer::unbind()
246void LLVertexBuffer::cleanupClass() 279void LLVertexBuffer::cleanupClass()
247{ 280{
248 LLMemType mt(LLMemType::MTYPE_VERTEX_DATA); 281 LLMemType mt(LLMemType::MTYPE_VERTEX_DATA);
249 startRender();
250 stopRender();
251 clientCopy(); // deletes GL buffers
252}
253
254//static, call before rendering VBOs
255void LLVertexBuffer::startRender()
256{
257 LLMemType mt(LLMemType::MTYPE_VERTEX_DATA);
258
259 unbind();
260 sRenderActive = TRUE;
261}
262
263void LLVertexBuffer::stopRender()
264{
265 unbind(); 282 unbind();
266 sRenderActive = FALSE; 283 clientCopy(); // deletes GL buffers
267} 284}
268 285
269void LLVertexBuffer::clientCopy(F64 max_time) 286void LLVertexBuffer::clientCopy(F64 max_time)
@@ -717,7 +734,7 @@ BOOL LLVertexBuffer::useVBOs() const
717 return FALSE; 734 return FALSE;
718 } 735 }
719#endif 736#endif
720 return sEnableVBOs; // && (!sRenderActive || !mLocked); 737 return sEnableVBOs;
721} 738}
722 739
723//---------------------------------------------------------------------------- 740//----------------------------------------------------------------------------
@@ -1000,10 +1017,6 @@ void LLVertexBuffer::setBuffer(U32 data_mask)
1000 sGLRenderBuffer = mGLBuffer; 1017 sGLRenderBuffer = mGLBuffer;
1001 if (data_mask && setup) 1018 if (data_mask && setup)
1002 { 1019 {
1003 if (!sRenderActive)
1004 {
1005 llwarns << "Vertex buffer set for rendering outside of render frame." << llendl;
1006 }
1007 setupVertexBuffer(data_mask); // subclass specific setup (virtual function) 1020 setupVertexBuffer(data_mask); // subclass specific setup (virtual function)
1008 sSetCount++; 1021 sSetCount++;
1009 } 1022 }