Commit cc7bbafa by Jamie Madill

ES3: Fix off-by-one max enabled attrib.

In some cases we would have a 'max enabled' attrib that was checked incorrectly, and this could lead to edge cases which crash when we have a vertex attribute and buffer both NULL. BUG=angleproject:1081 TEST=dEQP-GLES3.functional.lifetime.attach.deleted_input.buffer_vertex_array Change-Id: I62a9fa79f38340c99a708e54751d2b67dd4b6c1f Reviewed-on: https://chromium-review.googlesource.com/286854Reviewed-by: 's avatarGeoff Lang <geofflang@chromium.org> Tested-by: 's avatarJamie Madill <jmadill@chromium.org>
parent 375c37c9
...@@ -87,11 +87,12 @@ void VertexArray::enableAttribute(size_t attributeIndex, bool enabledState) ...@@ -87,11 +87,12 @@ void VertexArray::enableAttribute(size_t attributeIndex, bool enabledState)
// Update state cache // Update state cache
if (enabledState) if (enabledState)
{ {
mData.mMaxEnabledAttribute = std::max(attributeIndex, mData.mMaxEnabledAttribute); mData.mMaxEnabledAttribute = std::max(attributeIndex + 1, mData.mMaxEnabledAttribute);
} }
else if (mData.mMaxEnabledAttribute == attributeIndex) else if (mData.mMaxEnabledAttribute == attributeIndex + 1)
{ {
while (mData.mMaxEnabledAttribute > 0 && !mData.mVertexAttributes[mData.mMaxEnabledAttribute].enabled) while (mData.mMaxEnabledAttribute > 0 &&
!mData.mVertexAttributes[mData.mMaxEnabledAttribute - 1].enabled)
{ {
--mData.mMaxEnabledAttribute; --mData.mMaxEnabledAttribute;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment