Hash :
b2d6a9be
Author :
Date :
2015-03-30T16:00:53
Stub simplifying array assignment for HLSL output Add an AST traverser that rejects shaders with expressions that use the return value of an assignment where an array is assigned to another array. In the future this should be made into a tool that can simplify these expressions so that return values of array assignments are not used. In its current form this code prevents OutputHLSL from producing garbage code when the original code contains expressions like a = (b = c); where a, b, and c are all arrays. BUG=angleproject:960 Change-Id: I11353d7ed7160c853e58a0ef3471ca439cb314c8 Reviewed-on: https://chromium-review.googlesource.com/263070 Reviewed-by: Jamie Madill <jmadill@chromium.org> Tested-by: Olli Etuaho <oetuaho@nvidia.com> Reviewed-by: Geoff Lang <geofflang@chromium.org>
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38
//
// Copyright (c) 2002-2015 The ANGLE Project Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
//
#include "compiler/translator/SimplifyArrayAssignment.h"
bool SimplifyArrayAssignment::visitBinary(Visit visit, TIntermBinary *node)
{
switch (node->getOp())
{
case EOpAssign:
{
TIntermNode *parent = getParentNode();
if (node->getLeft()->isArray() && parent != nullptr)
{
TIntermAggregate *parentAgg = parent->getAsAggregate();
if (parentAgg != nullptr && parentAgg->getOp() == EOpSequence)
{
// This case is fine, the result of the assignment is not used.
break;
}
// The result of the assignment needs to be stored into a temporary variable,
// the assignment needs to be replaced with a reference to the temporary variable,
// and the temporary variable needs to finally be assigned to the target variable.
// This also needs to interact correctly with unfolding short circuiting operators.
UNIMPLEMENTED();
}
}
break;
default:
break;
}
return true;
}