Commit d1bed175 by Kai Ninomiya Committed by Commit Bot

Reverse the order of array variable initialization

This works around a bug on Adreno 3xx in which array varying variables are assigned in the reverse order. BUG=chromium:709317 Change-Id: I86a345747f293ca8a2cb9a281bd1b752e66dcd3a Reviewed-on: https://chromium-review.googlesource.com/475979 Commit-Queue: Kai Ninomiya <kainino@chromium.org> Reviewed-by: 's avatarGeoff Lang <geofflang@chromium.org>
parent c1d770e8
......@@ -82,11 +82,17 @@ void VariableInitializer::insertInitCode(TIntermSequence *sequence)
TType arrayType = elementType;
arrayType.setArraySize(var.elementCount());
for (unsigned int i = 0; i < var.arraySize; ++i)
// Workaround for http://crbug.com/709317
// This loop is reversed to initialize elements in increasing
// order [0 1 2 ...]. Otherwise, they're initialized in
// decreasing order [... 2 1 0], due to
// `sequence->insert(sequence->begin(), ...)` below.
for (unsigned int i = var.arraySize; i > 0; --i)
{
unsigned int index = i - 1;
TIntermSymbol *arraySymbol = new TIntermSymbol(0, name, arrayType);
TIntermBinary *element = new TIntermBinary(EOpIndexDirect, arraySymbol,
TIntermTyped::CreateIndexNode(i));
TIntermTyped::CreateIndexNode(index));
TIntermTyped *zero = TIntermTyped::CreateZero(elementType);
TIntermBinary *assignment = new TIntermBinary(EOpAssign, element, zero);
......
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