A pass at cleaning up LLVertexBuffer a bit. Also removing extra unbinds that caused synchronization issues with mapped vbos.

This commit is contained in:
Shyotl
2011-07-21 01:48:46 -05:00
parent cc19a4c2da
commit 48ef9904c1
4 changed files with 14 additions and 24 deletions

View File

@@ -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_VERTEX,
sizeof(LLVector4), // TYPE_NORMAL, sizeof(LLVector4), // TYPE_NORMAL,
@@ -506,7 +506,7 @@ S32 LLVertexBuffer::calcStride(const U32& typemask, S32* offsets)
{ {
offsets[i] = stride; offsets[i] = stride;
} }
stride += sTypeOffsets[i]; stride += sTypeSize[i];
} }
} }
@@ -690,7 +690,7 @@ void LLVertexBuffer::destroyGLBuffer()
} }
mGLBuffer = 0; mGLBuffer = 0;
unbind(); //unbind();
} }
void LLVertexBuffer::destroyGLIndices() void LLVertexBuffer::destroyGLIndices()
@@ -719,7 +719,7 @@ void LLVertexBuffer::destroyGLIndices()
} }
mGLIndices = 0; mGLIndices = 0;
unbind(); //unbind();
} }
void LLVertexBuffer::updateNumVerts(S32 nverts) 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; llerrs << "LLVertexBuffer::setOffset called with mNumVerts = " << mNumVerts << llendl;
} }
// This code assumes that setStride() will only be called once per VBO per type. // 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<TYPE_MAX; i++) for (S32 i=type+1; i<TYPE_MAX; i++)
{ {
if (mTypeMask & (1<<i)) if (mTypeMask & (1<<i))

View File

@@ -81,6 +81,7 @@ public:
llerrs << "Illegal operation!" << llendl; llerrs << "Illegal operation!" << llendl;
return *this; return *this;
} }
static LLVBOPool sStreamVBOPool; static LLVBOPool sStreamVBOPool;
static LLVBOPool sDynamicVBOPool; static LLVBOPool sDynamicVBOPool;
static LLVBOPool sStreamIBOPool; static LLVBOPool sStreamIBOPool;
@@ -91,11 +92,12 @@ public:
static BOOL sUseStreamDraw; static BOOL sUseStreamDraw;
static BOOL sOmitBlank; static BOOL sOmitBlank;
static BOOL sPreferStreamDraw; static BOOL sPreferStreamDraw;
static void initClass(bool use_vbo, bool no_vbo_mapping); static void initClass(bool use_vbo, bool no_vbo_mapping);
static void cleanupClass(); static void cleanupClass();
static void setupClientArrays(U32 data_mask); static void setupClientArrays(U32 data_mask);
static void drawArrays(U32 mode, const std::vector<LLVector3>& pos, const std::vector<LLVector3>& norm); static void drawArrays(U32 mode, const std::vector<LLVector3>& pos, const std::vector<LLVector3>& norm);
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 static void unbind(); //unbind any bound vertex buffer
@@ -197,8 +199,8 @@ public:
S32 getRequestedVerts() const { return mRequestedNumVerts; } S32 getRequestedVerts() const { return mRequestedNumVerts; }
S32 getRequestedIndices() const { return mRequestedNumIndices; } S32 getRequestedIndices() const { return mRequestedNumIndices; }
volatile U8* getIndicesPointer() const { return useVBOs() ? NULL : mMappedIndexData; } volatile U8* getIndicesPointer() const { return useVBOs() ? (U8*) mAlignedIndexOffset : mMappedIndexData; }
volatile U8* getVerticesPointer() const { return useVBOs() ? NULL : mMappedData; } volatile U8* getVerticesPointer() const { return useVBOs() ? (U8*) mAlignedOffset : mMappedData; }
S32 getStride() const { return mStride; } S32 getStride() const { return mStride; }
S32 getTypeMask() const { return mTypeMask; } S32 getTypeMask() const { return mTypeMask; }
BOOL hasDataType(S32 type) const { return ((1 << type) & getTypeMask()) ? TRUE : FALSE; } 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) BOOL mDynamicSize; // if TRUE, buffer has been resized at least once (and should be padded)
S32 mOffsets[TYPE_MAX]; 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<DirtyRegion> mDirtyRegions; //vector of dirty regions to rebuild
public: public:
static S32 sCount; static S32 sCount;
static S32 sGLCount; static S32 sGLCount;
@@ -271,7 +258,7 @@ public:
static BOOL sDisableVBOMapping; //disable glMapBufferARB static BOOL sDisableVBOMapping; //disable glMapBufferARB
static BOOL sEnableVBOs; static BOOL sEnableVBOs;
static S32 sTypeOffsets[TYPE_MAX]; static S32 sTypeSize[TYPE_MAX];
static U32 sGLMode[LLRender::NUM_MODES]; static U32 sGLMode[LLRender::NUM_MODES];
static U32 sGLRenderBuffer; static U32 sGLRenderBuffer;
static U32 sGLRenderIndices; static U32 sGLRenderIndices;

View File

@@ -70,6 +70,7 @@ void LLDrawPoolSky::prerender()
void LLDrawPoolSky::render(S32 pass) void LLDrawPoolSky::render(S32 pass)
{ {
gGL.flush(); gGL.flush();
if (mDrawFace.empty()) if (mDrawFace.empty())
{ {
return; return;

View File

@@ -222,6 +222,8 @@ void LLDrawPoolTerrain::render(S32 pass)
sShader->unbind(); sShader->unbind();
sShader = &gObjectFullbrightProgram; sShader = &gObjectFullbrightProgram;
sShader->bind(); sShader->bind();
LLGLEnable polyOffset(GL_POLYGON_OFFSET_FILL);
glPolygonOffset(-1.0f, -1.0f);
renderOwnership(); renderOwnership();
sShader = old_shader; sShader = old_shader;
sShader->bind(); sShader->bind();