summaryrefslogtreecommitdiff
path: root/indra/llrender/llvertexbuffer.cpp
diff options
context:
space:
mode:
authorNat Goodspeed <nat@lindenlab.com>2020-05-06 16:06:26 -0400
committerNat Goodspeed <nat@lindenlab.com>2020-05-06 16:06:26 -0400
commitca6f09292925a7bd936338cb598efb3ddc8524bf (patch)
tree3f27e75fc8443b84e91fcac400084fd83dfed26a /indra/llrender/llvertexbuffer.cpp
parent4768d092f611576b4e4e95574e9b16192e7ced5e (diff)
parent4a7fd0117a43dca9e30c58c6417ebdf6862561f6 (diff)
DRTVWR-476: Merge branch 'master' of lindenlab/viewer into DRTVWR-476-boost-1.72
Diffstat (limited to 'indra/llrender/llvertexbuffer.cpp')
-rw-r--r--indra/llrender/llvertexbuffer.cpp86
1 files changed, 47 insertions, 39 deletions
diff --git a/indra/llrender/llvertexbuffer.cpp b/indra/llrender/llvertexbuffer.cpp
index f89522ea57..6a02cd9c19 100644
--- a/indra/llrender/llvertexbuffer.cpp
+++ b/indra/llrender/llvertexbuffer.cpp
@@ -660,6 +660,9 @@ void LLVertexBuffer::drawElements(U32 mode, const LLVector4a* pos, const LLVecto
void LLVertexBuffer::validateRange(U32 start, U32 end, U32 count, U32 indices_offset) const
{
+ llassert(start < (U32)mNumVerts);
+ llassert(end < (U32)mNumVerts);
+
if (start >= (U32) mNumVerts ||
end >= (U32) mNumVerts)
{
@@ -679,6 +682,9 @@ void LLVertexBuffer::validateRange(U32 start, U32 end, U32 count, U32 indices_of
U16* idx = ((U16*) getIndicesPointer())+indices_offset;
for (U32 i = 0; i < count; ++i)
{
+ llassert(idx[i] >= start);
+ llassert(idx[i] <= end);
+
if (idx[i] < start || idx[i] > end)
{
LL_ERRS() << "Index out of range: " << idx[i] << " not in [" << start << ", " << end << "]" << LL_ENDL;
@@ -697,6 +703,7 @@ void LLVertexBuffer::validateRange(U32 start, U32 end, U32 count, U32 indices_of
for (U32 i = start; i < end; i++)
{
S32 idx = (S32) (v[i][3]+0.25f);
+ llassert(idx >= 0);
if (idx < 0 || idx >= shader->mFeatures.mIndexedTextureChannels)
{
LL_ERRS() << "Bad texture index found in vertex data stream." << LL_ENDL;
@@ -942,15 +949,15 @@ S32 LLVertexBuffer::determineUsage(S32 usage)
{ //only stream_draw and dynamic_draw are supported when using VBOs, dynamic draw is the default
if (ret_usage != GL_DYNAMIC_COPY_ARB)
{
- if (sDisableVBOMapping)
- { //always use stream draw if VBO mapping is disabled
- ret_usage = GL_STREAM_DRAW_ARB;
- }
- else
- {
- ret_usage = GL_DYNAMIC_DRAW_ARB;
- }
- }
+ if (sDisableVBOMapping)
+ { //always use stream draw if VBO mapping is disabled
+ ret_usage = GL_STREAM_DRAW_ARB;
+ }
+ else
+ {
+ ret_usage = GL_DYNAMIC_DRAW_ARB;
+ }
+ }
}
return ret_usage;
@@ -1511,10 +1518,10 @@ bool LLVertexBuffer::resizeBuffer(S32 newnverts, S32 newnindices)
llassert(newnverts >= 0);
llassert(newnindices >= 0);
- bool sucsess = true;
+ bool success = true;
- sucsess &= updateNumVerts(newnverts);
- sucsess &= updateNumIndices(newnindices);
+ success &= updateNumVerts(newnverts);
+ success &= updateNumIndices(newnindices);
if (useVBOs())
{
@@ -1526,7 +1533,7 @@ bool LLVertexBuffer::resizeBuffer(S32 newnverts, S32 newnindices)
}
}
- return sucsess;
+ return success;
}
bool LLVertexBuffer::useVBOs() const
@@ -2324,34 +2331,35 @@ void LLVertexBuffer::setBuffer(U32 data_mask)
{
U32 unsatisfied_mask = (required_mask & ~data_mask);
- U32 i = 0;
- while (i < TYPE_MAX)
- {
+ for (U32 i = 0; i < TYPE_MAX; i++)
+ {
U32 unsatisfied_flag = unsatisfied_mask & (1 << i);
- switch (unsatisfied_flag)
- {
- case MAP_VERTEX: LL_INFOS() << "Missing vert pos" << LL_ENDL; break;
- case MAP_NORMAL: LL_INFOS() << "Missing normals" << LL_ENDL; break;
- case MAP_TEXCOORD0: LL_INFOS() << "Missing TC 0" << LL_ENDL; break;
- case MAP_TEXCOORD1: LL_INFOS() << "Missing TC 1" << LL_ENDL; break;
- case MAP_TEXCOORD2: LL_INFOS() << "Missing TC 2" << LL_ENDL; break;
- case MAP_TEXCOORD3: LL_INFOS() << "Missing TC 3" << LL_ENDL; break;
- case MAP_COLOR: LL_INFOS() << "Missing vert color" << LL_ENDL; break;
- case MAP_EMISSIVE: LL_INFOS() << "Missing emissive" << LL_ENDL; break;
- case MAP_TANGENT: LL_INFOS() << "Missing tangent" << LL_ENDL; break;
- case MAP_WEIGHT: LL_INFOS() << "Missing weight" << LL_ENDL; break;
- case MAP_WEIGHT4: LL_INFOS() << "Missing weightx4" << LL_ENDL; break;
- case MAP_CLOTHWEIGHT: LL_INFOS() << "Missing clothweight" << LL_ENDL; break;
- case MAP_TEXTURE_INDEX: LL_INFOS() << "Missing tex index" << LL_ENDL; break;
- default: LL_INFOS() << "Missing who effin knows: " << unsatisfied_flag << LL_ENDL;
- }
- }
-
- if (unsatisfied_mask & (1 << TYPE_INDEX))
- {
- LL_INFOS() << "Missing indices" << LL_ENDL;
- }
+ switch (unsatisfied_flag)
+ {
+ case 0: break;
+ case MAP_VERTEX: LL_INFOS() << "Missing vert pos" << LL_ENDL; break;
+ case MAP_NORMAL: LL_INFOS() << "Missing normals" << LL_ENDL; break;
+ case MAP_TEXCOORD0: LL_INFOS() << "Missing TC 0" << LL_ENDL; break;
+ case MAP_TEXCOORD1: LL_INFOS() << "Missing TC 1" << LL_ENDL; break;
+ case MAP_TEXCOORD2: LL_INFOS() << "Missing TC 2" << LL_ENDL; break;
+ case MAP_TEXCOORD3: LL_INFOS() << "Missing TC 3" << LL_ENDL; break;
+ case MAP_COLOR: LL_INFOS() << "Missing vert color" << LL_ENDL; break;
+ case MAP_EMISSIVE: LL_INFOS() << "Missing emissive" << LL_ENDL; break;
+ case MAP_TANGENT: LL_INFOS() << "Missing tangent" << LL_ENDL; break;
+ case MAP_WEIGHT: LL_INFOS() << "Missing weight" << LL_ENDL; break;
+ case MAP_WEIGHT4: LL_INFOS() << "Missing weightx4" << LL_ENDL; break;
+ case MAP_CLOTHWEIGHT: LL_INFOS() << "Missing clothweight" << LL_ENDL; break;
+ case MAP_TEXTURE_INDEX: LL_INFOS() << "Missing tex index" << LL_ENDL; break;
+ default: LL_INFOS() << "Missing who effin knows: " << unsatisfied_flag << LL_ENDL;
+ }
+ }
+
+ // TYPE_INDEX is beyond TYPE_MAX, so check for it individually
+ if (unsatisfied_mask & (1 << TYPE_INDEX))
+ {
+ LL_INFOS() << "Missing indices" << LL_ENDL;
+ }
LL_ERRS() << "Shader consumption mismatches data provision." << LL_ENDL;
}