summaryrefslogtreecommitdiff
path: root/indra/llrender/llvertexbuffer.cpp
diff options
context:
space:
mode:
authorNat Goodspeed <nat@lindenlab.com>2016-12-16 17:03:45 -0500
committerNat Goodspeed <nat@lindenlab.com>2016-12-16 17:03:45 -0500
commit93268cb47a69b8432068c0922feedc01c96ae975 (patch)
tree55b825e089dd380a3c1aae0d636ff230fc501933 /indra/llrender/llvertexbuffer.cpp
parentaa5a591aa722c81de2b22d9126afa4a833d0c050 (diff)
DRTVWR-418: Put TYPE_INDEX within TYPE_MAX: stop undefined indexing.
LLVertexBuffer::TYPE_INDEX was past TYPE_MAX, which is used to set the maximum sizes of various (scattered) arrays, bleh. The alarm bells that this SHOULD set off are indeed correct: TYPE_INDEX was being used to index at least one of those arrays, meaning we've been indexing past the end of that array, meaning undefined behavior. The enum that defines both TYPE_INDEX and TYPE_MAX provides a helpful comment indicating what things must be updated when modifying the enum. (Far better to define things centrally in a single place... but another time.) Update the designated arrays to include a final TYPE_INDEX entry. Contents of those entries are wild guesses -- but even wild guesses are better than completely indeterminate data.
Diffstat (limited to 'indra/llrender/llvertexbuffer.cpp')
-rw-r--r--indra/llrender/llvertexbuffer.cpp7
1 files changed, 6 insertions, 1 deletions
diff --git a/indra/llrender/llvertexbuffer.cpp b/indra/llrender/llvertexbuffer.cpp
index 0fae600a90..59024b7730 100644
--- a/indra/llrender/llvertexbuffer.cpp
+++ b/indra/llrender/llvertexbuffer.cpp
@@ -339,6 +339,7 @@ S32 LLVertexBuffer::sTypeSize[LLVertexBuffer::TYPE_MAX] =
sizeof(LLVector4), // TYPE_WEIGHT4,
sizeof(LLVector4), // TYPE_CLOTHWEIGHT,
sizeof(LLVector4), // TYPE_TEXTURE_INDEX (actually exists as position.w), no extra data, but stride is 16 bytes
+ sizeof(U16), // TYPE_INDEX
};
static std::string vb_type_name[] =
@@ -356,8 +357,8 @@ static std::string vb_type_name[] =
"TYPE_WEIGHT4",
"TYPE_CLOTHWEIGHT",
"TYPE_TEXTURE_INDEX",
+ "TYPE_INDEX",
"TYPE_MAX",
- "TYPE_INDEX",
};
U32 LLVertexBuffer::sGLMode[LLRender::NUM_MODES] =
@@ -1368,6 +1369,7 @@ void LLVertexBuffer::setupVertexArray()
4, //TYPE_WEIGHT4,
4, //TYPE_CLOTHWEIGHT,
1, //TYPE_TEXTURE_INDEX
+ 1, //TYPE_INDEX
};
U32 attrib_type[] =
@@ -1385,6 +1387,7 @@ void LLVertexBuffer::setupVertexArray()
GL_FLOAT, //TYPE_WEIGHT4,
GL_FLOAT, //TYPE_CLOTHWEIGHT,
GL_UNSIGNED_INT, //TYPE_TEXTURE_INDEX
+ GL_UNSIGNED_INT, //TYPE_INDEX
};
bool attrib_integer[] =
@@ -1402,6 +1405,7 @@ void LLVertexBuffer::setupVertexArray()
false, //TYPE_WEIGHT4,
false, //TYPE_CLOTHWEIGHT,
true, //TYPE_TEXTURE_INDEX
+ true, //TYPE_INDEX
};
U32 attrib_normalized[] =
@@ -1419,6 +1423,7 @@ void LLVertexBuffer::setupVertexArray()
GL_FALSE, //TYPE_WEIGHT4,
GL_FALSE, //TYPE_CLOTHWEIGHT,
GL_FALSE, //TYPE_TEXTURE_INDEX
+ GL_FALSE, //TYPE_INDEX
};
bindGLBuffer(true);