From 48ef9904c1ee4150f83fa9f110ebbe534ad8b008 Mon Sep 17 00:00:00 2001 From: Shyotl Date: Thu, 21 Jul 2011 01:48:46 -0500 Subject: [PATCH] A pass at cleaning up LLVertexBuffer a bit. Also removing extra unbinds that caused synchronization issues with mapped vbos. --- indra/llrender/llvertexbuffer.cpp | 10 +++++----- indra/llrender/llvertexbuffer.h | 25 ++++++------------------- indra/newview/lldrawpoolsky.cpp | 1 + indra/newview/lldrawpoolterrain.cpp | 2 ++ 4 files changed, 14 insertions(+), 24 deletions(-) diff --git a/indra/llrender/llvertexbuffer.cpp b/indra/llrender/llvertexbuffer.cpp index 6062abcf4..e0c469544 100644 --- a/indra/llrender/llvertexbuffer.cpp +++ b/indra/llrender/llvertexbuffer.cpp @@ -88,7 +88,7 @@ void LLVBOPool::releaseName(GLuint name) } -S32 LLVertexBuffer::sTypeOffsets[LLVertexBuffer::TYPE_MAX] = +S32 LLVertexBuffer::sTypeSize[LLVertexBuffer::TYPE_MAX] = { sizeof(LLVector4), // TYPE_VERTEX, sizeof(LLVector4), // TYPE_NORMAL, @@ -506,7 +506,7 @@ S32 LLVertexBuffer::calcStride(const U32& typemask, S32* offsets) { offsets[i] = stride; } - stride += sTypeOffsets[i]; + stride += sTypeSize[i]; } } @@ -690,7 +690,7 @@ void LLVertexBuffer::destroyGLBuffer() } mGLBuffer = 0; - unbind(); + //unbind(); } void LLVertexBuffer::destroyGLIndices() @@ -719,7 +719,7 @@ void LLVertexBuffer::destroyGLIndices() } mGLIndices = 0; - unbind(); + //unbind(); } void LLVertexBuffer::updateNumVerts(S32 nverts) @@ -1277,7 +1277,7 @@ void LLVertexBuffer::setStride(S32 type, S32 new_stride) llerrs << "LLVertexBuffer::setOffset called with mNumVerts = " << mNumVerts << llendl; } // This code assumes that setStride() will only be called once per VBO per type. - S32 delta = new_stride - sTypeOffsets[type]; + S32 delta = new_stride - sTypeSize[type]; for (S32 i=type+1; i& pos, const std::vector& norm); + static void clientCopy(F64 max_time = 0.005); //copy data from client to GL static void unbind(); //unbind any bound vertex buffer @@ -197,8 +199,8 @@ public: S32 getRequestedVerts() const { return mRequestedNumVerts; } S32 getRequestedIndices() const { return mRequestedNumIndices; } - volatile U8* getIndicesPointer() const { return useVBOs() ? NULL : mMappedIndexData; } - volatile U8* getVerticesPointer() const { return useVBOs() ? NULL : mMappedData; } + volatile U8* getIndicesPointer() const { return useVBOs() ? (U8*) mAlignedIndexOffset : mMappedIndexData; } + volatile U8* getVerticesPointer() const { return useVBOs() ? (U8*) mAlignedOffset : mMappedData; } S32 getStride() const { return mStride; } S32 getTypeMask() const { return mTypeMask; } BOOL hasDataType(S32 type) const { return ((1 << type) & getTypeMask()) ? TRUE : FALSE; } @@ -246,21 +248,6 @@ protected: BOOL mDynamicSize; // if TRUE, buffer has been resized at least once (and should be padded) S32 mOffsets[TYPE_MAX]; - class DirtyRegion - { - public: - U32 mIndex; - U32 mCount; - U32 mIndicesIndex; - U32 mIndicesCount; - - DirtyRegion(U32 vi, U32 vc, U32 ii, U32 ic) - : mIndex(vi), mCount(vc), mIndicesIndex(ii), mIndicesCount(ic) - { } - }; - - std::vector mDirtyRegions; //vector of dirty regions to rebuild - public: static S32 sCount; static S32 sGLCount; @@ -271,7 +258,7 @@ public: static BOOL sDisableVBOMapping; //disable glMapBufferARB static BOOL sEnableVBOs; - static S32 sTypeOffsets[TYPE_MAX]; + static S32 sTypeSize[TYPE_MAX]; static U32 sGLMode[LLRender::NUM_MODES]; static U32 sGLRenderBuffer; static U32 sGLRenderIndices; diff --git a/indra/newview/lldrawpoolsky.cpp b/indra/newview/lldrawpoolsky.cpp index b5cc0d31d..f3f0d1a4a 100644 --- a/indra/newview/lldrawpoolsky.cpp +++ b/indra/newview/lldrawpoolsky.cpp @@ -70,6 +70,7 @@ void LLDrawPoolSky::prerender() void LLDrawPoolSky::render(S32 pass) { gGL.flush(); + if (mDrawFace.empty()) { return; diff --git a/indra/newview/lldrawpoolterrain.cpp b/indra/newview/lldrawpoolterrain.cpp index 97af1285b..b9654c57c 100644 --- a/indra/newview/lldrawpoolterrain.cpp +++ b/indra/newview/lldrawpoolterrain.cpp @@ -222,6 +222,8 @@ void LLDrawPoolTerrain::render(S32 pass) sShader->unbind(); sShader = &gObjectFullbrightProgram; sShader->bind(); + LLGLEnable polyOffset(GL_POLYGON_OFFSET_FILL); + glPolygonOffset(-1.0f, -1.0f); renderOwnership(); sShader = old_shader; sShader->bind();