Commit 995c2ed2 by Jiawei-Shao Committed by Commit Bot

Initialize currentValueAttrib->binding in updateCurrentValueAttribs

This patch intends to fix a crash issue in the win-clang build of ANGLE by adding the missing currentValueAttrib->binding assignment in StateManager11.cpp::updateCurrentValueAttribs(). In D3D11 all vertex attributes (VertexAttribute and its VertexBinding) should be treated as a whole, so we should always ensure these two parts are availabe. This patch also add ASSERTs before using *translated->attrib and *translated->binding to prevent a TranslatedAttribute object having a null attrib or binding. BUG=chromium:721783, angleproject:1593 Change-Id: Id11d6f1d4c37daabad2265e01ea38eb51046b9cb Reviewed-on: https://chromium-review.googlesource.com/505928Reviewed-by: 's avatarGeoff Lang <geofflang@chromium.org> Reviewed-by: 's avatarCorentin Wallez <cwallez@chromium.org> Commit-Queue: Corentin Wallez <cwallez@chromium.org>
parent d5e8e196
......@@ -293,6 +293,7 @@ gl::Error VertexDataManager::prepareVertexData(const gl::State &state,
// static
void VertexDataManager::StoreDirectAttrib(TranslatedAttribute *directAttrib)
{
ASSERT(directAttrib->attribute && directAttrib->binding);
const auto &attrib = *directAttrib->attribute;
const auto &binding = *directAttrib->binding;
......@@ -314,6 +315,7 @@ void VertexDataManager::StoreDirectAttrib(TranslatedAttribute *directAttrib)
// static
gl::Error VertexDataManager::StoreStaticAttrib(TranslatedAttribute *translated)
{
ASSERT(translated->attribute && translated->binding);
const auto &attrib = *translated->attribute;
const auto &binding = *translated->binding;
......@@ -424,7 +426,9 @@ void VertexDataManager::PromoteDynamicAttribs(
for (auto attribIndex : dynamicAttribsMask)
{
const auto &dynamicAttrib = translatedAttribs[attribIndex];
ASSERT(dynamicAttrib.attribute && dynamicAttrib.binding);
const auto &binding = *dynamicAttrib.binding;
gl::Buffer *buffer = binding.buffer.get();
if (buffer)
{
......@@ -439,8 +443,10 @@ gl::Error VertexDataManager::reserveSpaceForAttrib(const TranslatedAttribute &tr
GLsizei count,
GLsizei instances) const
{
ASSERT(translatedAttrib.attribute && translatedAttrib.binding);
const auto &attrib = *translatedAttrib.attribute;
const auto &binding = *translatedAttrib.binding;
ASSERT(!DirectStoragePossible(attrib, binding));
gl::Buffer *buffer = binding.buffer.get();
......@@ -461,6 +467,7 @@ gl::Error VertexDataManager::storeDynamicAttrib(TranslatedAttribute *translated,
GLsizei count,
GLsizei instances)
{
ASSERT(translated->attribute && translated->binding);
const auto &attrib = *translated->attribute;
const auto &binding = *translated->binding;
......@@ -523,6 +530,7 @@ gl::Error VertexDataManager::storeCurrentValue(const gl::VertexAttribCurrentValu
if (cachedState->data != currentValue)
{
ASSERT(translated->attribute && translated->binding);
const auto &attrib = *translated->attribute;
const auto &binding = *translated->binding;
......
......@@ -1102,6 +1102,7 @@ gl::Error StateManager11::updateCurrentValueAttribs(const gl::State &state,
const auto &activeAttribsMask = state.getProgram()->getActiveAttribLocationsMask();
const auto &dirtyActiveAttribs = (activeAttribsMask & mDirtyCurrentValueAttribs);
const auto &vertexAttributes = state.getVertexArray()->getVertexAttributes();
const auto &vertexBindings = state.getVertexArray()->getVertexBindings();
for (auto attribIndex : dirtyActiveAttribs)
{
......@@ -1110,10 +1111,12 @@ gl::Error StateManager11::updateCurrentValueAttribs(const gl::State &state,
mDirtyCurrentValueAttribs.reset(attribIndex);
const auto *attrib = &vertexAttributes[attribIndex];
const auto &currentValue = state.getVertexAttribCurrentValue(attribIndex);
auto currentValueAttrib = &mCurrentValueAttribs[attribIndex];
currentValueAttrib->currentValueType = currentValue.Type;
currentValueAttrib->attribute = &vertexAttributes[attribIndex];
currentValueAttrib->attribute = attrib;
currentValueAttrib->binding = &vertexBindings[attrib->bindingIndex];
ANGLE_TRY(vertexDataManager->storeCurrentValue(currentValue, currentValueAttrib,
static_cast<size_t>(attribIndex)));
......
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