diff options
author | Steven Bennetts <steve@lindenlab.com> | 2008-05-08 18:41:20 +0000 |
---|---|---|
committer | Steven Bennetts <steve@lindenlab.com> | 2008-05-08 18:41:20 +0000 |
commit | 63e7894148fdc7064b422bf65a0b75ffcf293496 (patch) | |
tree | 4cca89d9da518f264001e7cb4950f453647f2e5f /indra/llrender | |
parent | a75b85112ffa4b7140561083c2e5de05fb510805 (diff) |
QAR-570 maint-render-4 merge
merge -r 87067:87077 svn+ssh://svn.lindenlab.com/svn/linden/branches/maint-render/maint-render-4-merge -> release. dataserver-is-deprecated.
Diffstat (limited to 'indra/llrender')
-rw-r--r-- | indra/llrender/llfontgl.cpp | 4 | ||||
-rw-r--r-- | indra/llrender/llvertexbuffer.cpp | 81 | ||||
-rw-r--r-- | indra/llrender/llvertexbuffer.h | 8 |
3 files changed, 61 insertions, 32 deletions
diff --git a/indra/llrender/llfontgl.cpp b/indra/llrender/llfontgl.cpp index 4a3a64f955..1113959999 100644 --- a/indra/llrender/llfontgl.cpp +++ b/indra/llrender/llfontgl.cpp @@ -863,7 +863,7 @@ S32 LLFontGL::render(const LLWString &wstr, if (style & UNDERLINE) { LLGLSNoTexture no_texture; - gGL.begin(GL_LINES); + gGL.begin(LLVertexBuffer::LINES); gGL.vertex2f(start_x, cur_y - (mDescender)); gGL.vertex2f(cur_x, cur_y - (mDescender)); gGL.end(); @@ -1358,7 +1358,7 @@ void LLFontGL::drawGlyph(const LLRectf& screen_rect, const LLRectf& uv_rect, con F32 slant_offset; slant_offset = ((style & ITALIC) ? ( -mAscender * 0.2f) : 0.f); - gGL.begin(GL_QUADS); + gGL.begin(LLVertexBuffer::QUADS); { //FIXME: bold and drop shadow are mutually exclusive only for convenience //Allow both when we need them. diff --git a/indra/llrender/llvertexbuffer.cpp b/indra/llrender/llvertexbuffer.cpp index 99fd2b33d4..5a1079ac15 100644 --- a/indra/llrender/llvertexbuffer.cpp +++ b/indra/llrender/llvertexbuffer.cpp @@ -60,7 +60,6 @@ U32 LLVertexBuffer::sLastMask = 0; BOOL LLVertexBuffer::sVBOActive = FALSE; BOOL LLVertexBuffer::sIBOActive = FALSE; U32 LLVertexBuffer::sAllocatedBytes = 0; -BOOL LLVertexBuffer::sRenderActive = FALSE; BOOL LLVertexBuffer::sMapped = FALSE; std::vector<U32> LLVertexBuffer::sDeleteList; @@ -84,16 +83,18 @@ U32 LLVertexBuffer::sGLMode[LLVertexBuffer::NUM_MODES] = GL_TRIANGLE_FAN, GL_POINTS, GL_LINES, - GL_LINE_STRIP + GL_LINE_STRIP, + GL_QUADS, + GL_LINE_LOOP, }; //static void LLVertexBuffer::setupClientArrays(U32 data_mask) { - if (LLGLImmediate::sStarted) + /*if (LLGLImmediate::sStarted) { llerrs << "Cannot use LLGLImmediate and LLVertexBuffer simultaneously!" << llendl; - } + }*/ if (sLastMask != data_mask) { @@ -186,6 +187,11 @@ void LLVertexBuffer::drawRange(U32 mode, U32 start, U32 end, U32 count, U32 indi llerrs << "Wrong vertex buffer bound." << llendl; } + if (mode > NUM_MODES) + { + llerrs << "Invalid draw mode: " << mode << llendl; + } + glDrawRangeElements(sGLMode[mode], start, end, count, GL_UNSIGNED_SHORT, ((U16*) getIndicesPointer()) + indices_offset); } @@ -208,10 +214,37 @@ void LLVertexBuffer::draw(U32 mode, U32 count, U32 indices_offset) const llerrs << "Wrong vertex buffer bound." << llendl; } + if (mode > NUM_MODES) + { + llerrs << "Invalid draw mode: " << mode << llendl; + } + glDrawElements(sGLMode[mode], count, GL_UNSIGNED_SHORT, ((U16*) getIndicesPointer()) + indices_offset); } +void LLVertexBuffer::drawArrays(U32 mode, U32 first, U32 count) const +{ + + if (first >= (U32) mRequestedNumVerts || + first + count > (U32) mRequestedNumVerts) + { + llerrs << "Bad vertex buffer draw range: [" << first << ", " << first+count << "]" << llendl; + } + + if (mGLBuffer != sGLRenderBuffer) + { + llerrs << "Wrong vertex buffer bound." << llendl; + } + + if (mode > NUM_MODES) + { + llerrs << "Invalid draw mode: " << mode << llendl; + } + + glDrawArrays(sGLMode[mode], first, count); +} + //static void LLVertexBuffer::initClass(bool use_vbo) { @@ -246,24 +279,8 @@ void LLVertexBuffer::unbind() void LLVertexBuffer::cleanupClass() { LLMemType mt(LLMemType::MTYPE_VERTEX_DATA); - startRender(); - stopRender(); - clientCopy(); // deletes GL buffers -} - -//static, call before rendering VBOs -void LLVertexBuffer::startRender() -{ - LLMemType mt(LLMemType::MTYPE_VERTEX_DATA); - unbind(); - sRenderActive = TRUE; -} - -void LLVertexBuffer::stopRender() -{ - unbind(); - sRenderActive = FALSE; + clientCopy(); // deletes GL buffers } void LLVertexBuffer::clientCopy(F64 max_time) @@ -717,7 +734,7 @@ BOOL LLVertexBuffer::useVBOs() const return FALSE; } #endif - return sEnableVBOs; // && (!sRenderActive || !mLocked); + return sEnableVBOs; } //---------------------------------------------------------------------------- @@ -937,6 +954,22 @@ void LLVertexBuffer::setBuffer(U32 data_mask) if (mResized) { + if (gDebugGL) + { + GLint buff; + glGetIntegerv(GL_ARRAY_BUFFER_BINDING_ARB, &buff); + if (buff != mGLBuffer) + { + llerrs << "Invalid GL vertex buffer bound: " << buff << llendl; + } + + glGetIntegerv(GL_ELEMENT_ARRAY_BUFFER_BINDING_ARB, &buff); + if (buff != mGLIndices) + { + llerrs << "Invalid GL index buffer bound: " << buff << llendl; + } + } + if (mGLBuffer) { stop_glerror(); @@ -1000,10 +1033,6 @@ void LLVertexBuffer::setBuffer(U32 data_mask) sGLRenderBuffer = mGLBuffer; if (data_mask && setup) { - if (!sRenderActive) - { - llwarns << "Vertex buffer set for rendering outside of render frame." << llendl; - } setupVertexBuffer(data_mask); // subclass specific setup (virtual function) sSetCount++; } diff --git a/indra/llrender/llvertexbuffer.h b/indra/llrender/llvertexbuffer.h index 50f79cfc9d..2b5f4e200b 100644 --- a/indra/llrender/llvertexbuffer.h +++ b/indra/llrender/llvertexbuffer.h @@ -85,9 +85,7 @@ public: static void initClass(bool use_vbo); static void cleanupClass(); static void setupClientArrays(U32 data_mask); - static void startRender(); //between start and stop render, no client copies will occur - static void stopRender(); //any buffer not copied to GL will be rendered from client memory - static void clientCopy(F64 max_time = 0.005); //copy data from client to GL + static void clientCopy(F64 max_time = 0.005); //copy data from client to GL static void unbind(); //unbind any bound vertex buffer //get the size of a vertex with the given typemask @@ -131,6 +129,8 @@ public: POINTS, LINES, LINE_STRIP, + QUADS, + LINE_LOOP, NUM_MODES }; protected: @@ -205,6 +205,7 @@ public: void markDirty(U32 vert_index, U32 vert_count, U32 indices_index, U32 indices_count); void draw(U32 mode, U32 count, U32 indices_offset) const; + void drawArrays(U32 mode, U32 offset, U32 count) const; void drawRange(U32 mode, U32 start, U32 end, U32 count, U32 indices_offset) const; protected: @@ -244,7 +245,6 @@ protected: std::vector<DirtyRegion> mDirtyRegions; //vector of dirty regions to rebuild public: - static BOOL sRenderActive; static S32 sCount; static S32 sGLCount; static S32 sMappedCount; |