Reasonably safe changes.
Using accessor for vertexbuffer in LLFace Extra occlusion query lookup in llgl (unused) Const changes.
This commit is contained in:
@@ -67,6 +67,8 @@ U32 LLVertexBuffer::sAllocatedBytes = 0;
|
||||
BOOL LLVertexBuffer::sMapped = FALSE;
|
||||
BOOL LLVertexBuffer::sUseStreamDraw = TRUE;
|
||||
BOOL LLVertexBuffer::sOmitBlank = FALSE;
|
||||
BOOL LLVertexBuffer::sPreferStreamDraw = FALSE;
|
||||
S32 LLVertexBuffer::sWeight4Loc = -1;
|
||||
|
||||
std::vector<U32> LLVertexBuffer::sDeleteList;
|
||||
|
||||
@@ -88,15 +90,16 @@ void LLVBOPool::releaseName(GLuint name)
|
||||
|
||||
S32 LLVertexBuffer::sTypeOffsets[LLVertexBuffer::TYPE_MAX] =
|
||||
{
|
||||
sizeof(LLVector3), // TYPE_VERTEX,
|
||||
sizeof(LLVector3), // TYPE_NORMAL,
|
||||
sizeof(LLVector4), // TYPE_VERTEX,
|
||||
sizeof(LLVector4), // TYPE_NORMAL,
|
||||
sizeof(LLVector2), // TYPE_TEXCOORD0,
|
||||
sizeof(LLVector2), // TYPE_TEXCOORD1,
|
||||
sizeof(LLVector2), // TYPE_TEXCOORD2,
|
||||
sizeof(LLVector2), // TYPE_TEXCOORD3,
|
||||
sizeof(LLColor4U), // TYPE_COLOR,
|
||||
sizeof(LLVector3), // TYPE_BINORMAL,
|
||||
sizeof(LLVector4), // TYPE_BINORMAL,
|
||||
sizeof(F32), // TYPE_WEIGHT,
|
||||
sizeof(LLVector4), // TYPE_WEIGHT4,
|
||||
sizeof(LLVector4), // TYPE_CLOTHWEIGHT,
|
||||
};
|
||||
|
||||
@@ -156,11 +159,11 @@ void LLVertexBuffer::setupClientArrays(U32 data_mask)
|
||||
}
|
||||
else
|
||||
{ //was disabled
|
||||
if (data_mask & mask[i])
|
||||
if (data_mask & mask[i] && i > 0)
|
||||
{ //needs to be enabled
|
||||
glEnableClientState(array[i]);
|
||||
}
|
||||
else if (gDebugGL && glIsEnabled(array[i]))
|
||||
else if (gDebugGL && i > 0 && glIsEnabled(array[i]))
|
||||
{ //needs to be disabled, make sure it was (DEBUG TEMPORARY)
|
||||
llerrs << "Bad client state! " << array[i] << " enabled." << llendl;
|
||||
}
|
||||
@@ -209,23 +212,69 @@ void LLVertexBuffer::setupClientArrays(U32 data_mask)
|
||||
glClientActiveTextureARB(GL_TEXTURE0_ARB);
|
||||
}
|
||||
|
||||
if (sLastMask & MAP_WEIGHT4)
|
||||
{
|
||||
if (sWeight4Loc < 0)
|
||||
{
|
||||
llerrs << "Weighting disabled but vertex buffer still bound!" << llendl;
|
||||
}
|
||||
|
||||
if (!(data_mask & MAP_WEIGHT4))
|
||||
{ //disable 4-component skin weight
|
||||
glDisableVertexAttribArrayARB(sWeight4Loc);
|
||||
}
|
||||
}
|
||||
else if (data_mask & MAP_WEIGHT4)
|
||||
{
|
||||
if (sWeight4Loc >= 0)
|
||||
{ //enable 4-component skin weight
|
||||
glEnableVertexAttribArrayARB(sWeight4Loc);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
sLastMask = data_mask;
|
||||
}
|
||||
}
|
||||
|
||||
//static
|
||||
void LLVertexBuffer::drawArrays(U32 mode, const std::vector<LLVector3>& pos, const std::vector<LLVector3>& norm)
|
||||
{
|
||||
U32 count = pos.size();
|
||||
llassert(norm.size() >= pos.size());
|
||||
|
||||
unbind();
|
||||
|
||||
setupClientArrays(MAP_VERTEX | MAP_NORMAL);
|
||||
|
||||
glVertexPointer(3, GL_FLOAT, 0, pos[0].mV);
|
||||
glNormalPointer(GL_FLOAT, 0, norm[0].mV);
|
||||
|
||||
glDrawArrays(sGLMode[mode], 0, count);
|
||||
}
|
||||
|
||||
void LLVertexBuffer::validateRange(U32 start, U32 end, U32 count, U32 indices_offset) const
|
||||
{
|
||||
if (start >= (U32) mRequestedNumVerts ||
|
||||
end >= (U32) mRequestedNumVerts)
|
||||
{
|
||||
llerrs << "Bad vertex buffer draw range: [" << start << ", " << end << "] vs " << mRequestedNumVerts << llendl;
|
||||
}
|
||||
|
||||
llassert(mRequestedNumIndices >= 0);
|
||||
|
||||
if (indices_offset >= (U32) mRequestedNumIndices ||
|
||||
indices_offset + count > (U32) mRequestedNumIndices)
|
||||
{
|
||||
llerrs << "Bad index buffer draw range: [" << indices_offset << ", " << indices_offset+count << "]" << llendl;
|
||||
}
|
||||
}
|
||||
|
||||
void LLVertexBuffer::drawRange(U32 mode, U32 start, U32 end, U32 count, U32 indices_offset) const
|
||||
{
|
||||
if (start >= (U32) mRequestedNumVerts ||
|
||||
end >= (U32) mRequestedNumVerts)
|
||||
{
|
||||
llerrs << "Bad vertex buffer draw range: [" << start << ", " << end << "]" << llendl;
|
||||
}
|
||||
validateRange(start, end, count, indices_offset);
|
||||
|
||||
if (indices_offset >= (U32) mRequestedNumIndices ||
|
||||
indices_offset + count > (U32) mRequestedNumIndices)
|
||||
{
|
||||
llerrs << "Bad index buffer draw range: [" << indices_offset << ", " << indices_offset+count << "]" << llendl;
|
||||
}
|
||||
llassert(mRequestedNumVerts >= 0);
|
||||
|
||||
if (mGLIndices != sGLRenderIndices)
|
||||
{
|
||||
@@ -243,16 +292,19 @@ void LLVertexBuffer::drawRange(U32 mode, U32 start, U32 end, U32 count, U32 indi
|
||||
return;
|
||||
}
|
||||
|
||||
U16* idx = ((U16*) getIndicesPointer())+indices_offset;
|
||||
|
||||
stop_glerror();
|
||||
glDrawRangeElements(sGLMode[mode], start, end, count, GL_UNSIGNED_SHORT,
|
||||
((U16*) getIndicesPointer()) + indices_offset);
|
||||
idx);
|
||||
stop_glerror();
|
||||
}
|
||||
|
||||
void LLVertexBuffer::draw(U32 mode, U32 count, U32 indices_offset) const
|
||||
{
|
||||
llassert(mRequestedNumIndices >= 0);
|
||||
if (indices_offset >= (U32) mRequestedNumIndices ||
|
||||
indices_offset + count > (U32) mRequestedNumIndices)
|
||||
indices_offset + count > (U32) mRequestedNumIndices)
|
||||
{
|
||||
llerrs << "Bad index buffer draw range: [" << indices_offset << ", " << indices_offset+count << "]" << llendl;
|
||||
}
|
||||
@@ -281,6 +333,7 @@ void LLVertexBuffer::draw(U32 mode, U32 count, U32 indices_offset) const
|
||||
|
||||
void LLVertexBuffer::drawArrays(U32 mode, U32 first, U32 count) const
|
||||
{
|
||||
llassert(mRequestedNumVerts >= 0);
|
||||
if (first >= (U32) mRequestedNumVerts ||
|
||||
first + count > (U32) mRequestedNumVerts)
|
||||
{
|
||||
@@ -317,12 +370,8 @@ void LLVertexBuffer::initClass(bool use_vbo, bool no_vbo_mapping)
|
||||
{
|
||||
llinfos << "VBO is disabled." << llendl ;
|
||||
}
|
||||
|
||||
|
||||
sDisableVBOMapping = sEnableVBOs && no_vbo_mapping ;
|
||||
LLGLNamePool::registerPool(&sDynamicVBOPool);
|
||||
LLGLNamePool::registerPool(&sDynamicIBOPool);
|
||||
LLGLNamePool::registerPool(&sStreamVBOPool);
|
||||
LLGLNamePool::registerPool(&sStreamIBOPool);
|
||||
}
|
||||
|
||||
//static
|
||||
@@ -395,6 +444,11 @@ LLVertexBuffer::LLVertexBuffer(U32 typemask, S32 usage) :
|
||||
{
|
||||
mUsage = 0;
|
||||
}
|
||||
|
||||
if (mUsage == GL_DYNAMIC_DRAW_ARB && sPreferStreamDraw)
|
||||
{
|
||||
mUsage = GL_STREAM_DRAW_ARB;
|
||||
}
|
||||
|
||||
S32 stride = calcStride(typemask, mOffsets);
|
||||
|
||||
@@ -431,6 +485,8 @@ LLVertexBuffer::~LLVertexBuffer()
|
||||
destroyGLBuffer();
|
||||
destroyGLIndices();
|
||||
sCount--;
|
||||
|
||||
llassert_always(!mMappedData && !mMappedIndexData) ;
|
||||
};
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
@@ -679,6 +735,11 @@ void LLVertexBuffer::allocateBuffer(S32 nverts, S32 nindices, bool create)
|
||||
{
|
||||
LLMemType mt(LLMemType::MTYPE_VERTEX_DATA);
|
||||
|
||||
if (nverts < 0 || nindices < 0 ||
|
||||
nverts > 65536)
|
||||
{
|
||||
llerrs << "Bad vertex buffer allocation: " << nverts << " : " << nindices << llendl;
|
||||
}
|
||||
updateNumVerts(nverts);
|
||||
updateNumIndices(nindices);
|
||||
|
||||
@@ -697,6 +758,9 @@ void LLVertexBuffer::allocateBuffer(S32 nverts, S32 nindices, bool create)
|
||||
|
||||
void LLVertexBuffer::resizeBuffer(S32 newnverts, S32 newnindices)
|
||||
{
|
||||
llassert(newnverts >= 0);
|
||||
llassert(newnindices >= 0);
|
||||
|
||||
mRequestedNumVerts = newnverts;
|
||||
mRequestedNumIndices = newnindices;
|
||||
|
||||
@@ -1129,6 +1193,12 @@ bool LLVertexBuffer::getWeightStrider(LLStrider<F32>& strider, S32 index)
|
||||
{
|
||||
return VertexBufferStrider<F32,TYPE_WEIGHT>::get(*this, strider, index);
|
||||
}
|
||||
|
||||
bool LLVertexBuffer::getWeight4Strider(LLStrider<LLVector4>& strider, S32 index)
|
||||
{
|
||||
return VertexBufferStrider<LLVector4,TYPE_WEIGHT4>::get(*this, strider, index);
|
||||
}
|
||||
|
||||
bool LLVertexBuffer::getClothWeightStrider(LLStrider<LLVector4>& strider, S32 index)
|
||||
{
|
||||
return VertexBufferStrider<LLVector4,TYPE_CLOTHWEIGHT>::get(*this, strider, index);
|
||||
@@ -1382,6 +1452,12 @@ void LLVertexBuffer::setupVertexBuffer(U32 data_mask) const
|
||||
{
|
||||
glVertexAttribPointerARB(1, 1, GL_FLOAT, FALSE, stride, (void*)(base + mOffsets[TYPE_WEIGHT]));
|
||||
}
|
||||
|
||||
if (data_mask & MAP_WEIGHT4 && sWeight4Loc != -1)
|
||||
{
|
||||
glVertexAttribPointerARB(sWeight4Loc, 4, GL_FLOAT, FALSE, stride, (void*)(base+mOffsets[TYPE_WEIGHT4]));
|
||||
}
|
||||
|
||||
if (data_mask & MAP_CLOTHWEIGHT)
|
||||
{
|
||||
glVertexAttribPointerARB(4, 4, GL_FLOAT, TRUE, stride, (void*)(base + mOffsets[TYPE_CLOTHWEIGHT]));
|
||||
|
||||
Reference in New Issue
Block a user