Commit 4dd06d5d by Olli Etuaho Committed by Commit Bot

Set proper symbol ids on temporary symbol nodes

Temporary symbols used to all have symbol id 0. Now they get assigned unique symbol ids. This makes it possible to keep track of them according to the symbol id instead of their name, paving way to more robust AST handling in the future. BUG=angleproject:1490 TEST=angle_unittests Change-Id: I292e2e483cc39173524fd30a30b48c4c808442e5 Reviewed-on: https://chromium-review.googlesource.com/559335Reviewed-by: 's avatarJamie Madill <jmadill@chromium.org> Reviewed-by: 's avatarCorentin Wallez <cwallez@chromium.org> Commit-Queue: Olli Etuaho <oetuaho@nvidia.com>
parent 69df242c
......@@ -60,7 +60,7 @@ TIntermAggregate *CreateReplacementCall(TIntermAggregate *originalCall,
class ArrayReturnValueToOutParameterTraverser : private TIntermTraverser
{
public:
static void apply(TIntermNode *root, unsigned int *temporaryIndex);
static void apply(TIntermNode *root, TSymbolUniqueId *temporaryId);
private:
ArrayReturnValueToOutParameterTraverser();
......@@ -74,10 +74,10 @@ class ArrayReturnValueToOutParameterTraverser : private TIntermTraverser
bool mInFunctionWithArrayReturnValue;
};
void ArrayReturnValueToOutParameterTraverser::apply(TIntermNode *root, unsigned int *temporaryIndex)
void ArrayReturnValueToOutParameterTraverser::apply(TIntermNode *root, TSymbolUniqueId *temporaryId)
{
ArrayReturnValueToOutParameterTraverser arrayReturnValueToOutParam;
arrayReturnValueToOutParam.useTemporaryIndex(temporaryIndex);
arrayReturnValueToOutParam.useTemporaryId(temporaryId);
root->traverse(&arrayReturnValueToOutParam);
arrayReturnValueToOutParam.updateTree();
}
......@@ -139,7 +139,7 @@ bool ArrayReturnValueToOutParameterTraverser::visitAggregate(Visit visit, TInter
TIntermBlock *parentBlock = getParentNode()->getAsBlock();
if (parentBlock)
{
nextTemporaryIndex();
nextTemporaryId();
TIntermSequence replacements;
replacements.push_back(createTempDeclaration(node->getType()));
TIntermSymbol *returnSymbol = createTempSymbol(node->getType());
......@@ -194,9 +194,9 @@ bool ArrayReturnValueToOutParameterTraverser::visitBinary(Visit visit, TIntermBi
} // namespace
void ArrayReturnValueToOutParameter(TIntermNode *root, unsigned int *temporaryIndex)
void ArrayReturnValueToOutParameter(TIntermNode *root, TSymbolUniqueId *temporaryId)
{
ArrayReturnValueToOutParameterTraverser::apply(root, temporaryIndex);
ArrayReturnValueToOutParameterTraverser::apply(root, temporaryId);
}
} // namespace sh
......@@ -12,9 +12,12 @@
namespace sh
{
class TIntermNode;
class TSymbolUniqueId;
void ArrayReturnValueToOutParameter(TIntermNode *root, TSymbolUniqueId *temporaryId);
void ArrayReturnValueToOutParameter(TIntermNode *root, unsigned int *temporaryIndex);
} // namespace sh
#endif // COMPILER_TRANSLATOR_ARRAYRETURNVALUETOOUTPARAMETER_H_
......@@ -240,7 +240,7 @@ TCompiler::TCompiler(sh::GLenum type, ShShaderSpec spec, ShShaderOutput output)
mDiagnostics(infoSink.info),
mSourcePath(nullptr),
mComputeShaderLocalSizeDeclared(false),
mTemporaryIndex(0)
mTemporaryId()
{
mComputeShaderLocalSize.fill(1);
}
......@@ -434,7 +434,7 @@ TIntermBlock *TCompiler::compileTreeImpl(const char *const shaderStrings[],
// This pass might emit short circuits so keep it before the short circuit unfolding
if (success && (compileOptions & SH_REWRITE_DO_WHILE_LOOPS))
RewriteDoWhile(root, getTemporaryIndex());
RewriteDoWhile(root, getTemporaryId());
if (success && (compileOptions & SH_ADD_AND_TRUE_TO_LOOP_CONDITION))
sh::AddAndTrueToLoopCondition(root);
......@@ -501,7 +501,7 @@ TIntermBlock *TCompiler::compileTreeImpl(const char *const shaderStrings[],
if (success && (compileOptions & SH_SCALARIZE_VEC_AND_MAT_CONSTRUCTOR_ARGS))
{
ScalarizeVecAndMatConstructorArgs(root, shaderType, fragmentPrecisionHigh,
&mTemporaryIndex);
getTemporaryId());
}
if (success && (compileOptions & SH_REGENERATE_STRUCT_NAMES))
......@@ -537,7 +537,7 @@ TIntermBlock *TCompiler::compileTreeImpl(const char *const shaderStrings[],
IntermNodePatternMatcher::kMultiDeclaration |
IntermNodePatternMatcher::kArrayDeclaration |
IntermNodePatternMatcher::kNamelessStructDeclaration,
getTemporaryIndex(), getSymbolTable(), getShaderVersion());
getTemporaryId(), getSymbolTable(), getShaderVersion());
}
// We only really need to separate array declarations and nameless struct declarations,
// but it's simpler to just use the regular SeparateDeclarations.
......@@ -742,7 +742,7 @@ void TCompiler::clearResults()
nameMap.clear();
mSourcePath = nullptr;
mTemporaryIndex = 0;
mTemporaryId = TSymbolUniqueId();
}
bool TCompiler::initCallDag(TIntermNode *root)
......
......@@ -157,7 +157,7 @@ class TCompiler : public TShHandleBase
const char *getSourcePath() const;
const TPragma &getPragma() const { return mPragma; }
void writePragma(ShCompileOptions compileOptions);
unsigned int *getTemporaryIndex() { return &mTemporaryIndex; }
TSymbolUniqueId *getTemporaryId() { return &mTemporaryId; }
// Relies on collectVariables having been called.
bool isVaryingDefined(const char *varyingName);
......@@ -248,7 +248,7 @@ class TCompiler : public TShHandleBase
TPragma mPragma;
unsigned int mTemporaryIndex;
TSymbolUniqueId mTemporaryId;
};
//
......
......@@ -22,7 +22,7 @@ namespace
class Traverser : public TIntermTraverser
{
public:
static void Apply(TIntermNode *root, unsigned int *tempIndex);
static void Apply(TIntermNode *root, TSymbolUniqueId *temporaryId);
private:
Traverser();
......@@ -33,10 +33,10 @@ class Traverser : public TIntermTraverser
};
// static
void Traverser::Apply(TIntermNode *root, unsigned int *tempIndex)
void Traverser::Apply(TIntermNode *root, TSymbolUniqueId *temporaryId)
{
Traverser traverser;
traverser.useTemporaryIndex(tempIndex);
traverser.useTemporaryId(temporaryId);
do
{
traverser.nextIteration();
......@@ -55,7 +55,7 @@ Traverser::Traverser() : TIntermTraverser(true, false, false)
void Traverser::nextIteration()
{
mFound = false;
nextTemporaryIndex();
nextTemporaryId();
}
bool Traverser::visitAggregate(Visit visit, TIntermAggregate *node)
......@@ -111,7 +111,7 @@ bool Traverser::visitAggregate(Visit visit, TIntermAggregate *node)
}
// Potential problem case detected, apply workaround.
nextTemporaryIndex();
nextTemporaryId();
TIntermTyped *lhs = sequence->at(0)->getAsTyped();
ASSERT(lhs);
......@@ -146,9 +146,9 @@ bool Traverser::visitAggregate(Visit visit, TIntermAggregate *node)
} // anonymous namespace
void ExpandIntegerPowExpressions(TIntermNode *root, unsigned int *tempIndex)
void ExpandIntegerPowExpressions(TIntermNode *root, TSymbolUniqueId *temporaryId)
{
Traverser::Apply(root, tempIndex);
Traverser::Apply(root, temporaryId);
}
} // namespace sh
......@@ -16,12 +16,13 @@
#ifndef COMPILER_TRANSLATOR_EXPANDINTEGERPOWEXPRESSIONS_H_
#define COMPILER_TRANSLATOR_EXPANDINTEGERPOWEXPRESSIONS_H_
class TIntermNode;
namespace sh
{
void ExpandIntegerPowExpressions(TIntermNode *root, unsigned int *tempIndex);
class TIntermNode;
class TSymbolUniqueId;
void ExpandIntegerPowExpressions(TIntermNode *root, TSymbolUniqueId *temporaryId);
} // namespace sh
......
......@@ -997,7 +997,7 @@ class TIntermTraverser : angle::NonCopyable
void updateTree();
// Start creating temporary symbols from the given temporary symbol index + 1.
void useTemporaryIndex(unsigned int *temporaryIndex);
void useTemporaryId(TSymbolUniqueId *temporaryId);
static TIntermFunctionPrototype *CreateInternalFunctionPrototypeNode(
const TType &returnType,
......@@ -1123,7 +1123,7 @@ class TIntermTraverser : angle::NonCopyable
// Create a node that assigns rightNode to the current temporary symbol.
TIntermBinary *createTempAssignment(TIntermTyped *rightNode);
// Increment temporary symbol index.
void nextTemporaryIndex();
void nextTemporaryId();
enum class OriginalNode
{
......@@ -1200,7 +1200,7 @@ class TIntermTraverser : angle::NonCopyable
// All the code blocks from the root to the current node's parent during traversal.
std::vector<ParentBlock> mParentBlockStack;
unsigned int *mTemporaryIndex;
TSymbolUniqueId *mTemporaryId;
};
// Traverser parent class that tracks where a node is a destination of a write operation and so is
......
......@@ -108,7 +108,7 @@ TIntermTraverser::TIntermTraverser(bool preVisit, bool inVisit, bool postVisit)
mDepth(-1),
mMaxDepth(0),
mInGlobalScope(true),
mTemporaryIndex(nullptr)
mTemporaryId(nullptr)
{
}
......@@ -167,11 +167,11 @@ TIntermSymbol *TIntermTraverser::createTempSymbol(const TType &type, TQualifier
// Each traversal uses at most one temporary variable, so the index stays the same within a
// single traversal.
TInfoSinkBase symbolNameOut;
ASSERT(mTemporaryIndex != nullptr);
symbolNameOut << "s" << (*mTemporaryIndex);
ASSERT(mTemporaryId != nullptr);
symbolNameOut << "s" << (mTemporaryId->get());
TString symbolName = symbolNameOut.c_str();
TIntermSymbol *node = new TIntermSymbol(0, symbolName, type);
TIntermSymbol *node = new TIntermSymbol(mTemporaryId->get(), symbolName, type);
node->setInternal(true);
ASSERT(qualifier == EvqTemporary || qualifier == EvqConst || qualifier == EvqGlobal);
......@@ -217,15 +217,15 @@ TIntermBinary *TIntermTraverser::createTempAssignment(TIntermTyped *rightNode)
return assignment;
}
void TIntermTraverser::useTemporaryIndex(unsigned int *temporaryIndex)
void TIntermTraverser::useTemporaryId(TSymbolUniqueId *temporaryId)
{
mTemporaryIndex = temporaryIndex;
mTemporaryId = temporaryId;
}
void TIntermTraverser::nextTemporaryIndex()
void TIntermTraverser::nextTemporaryId()
{
ASSERT(mTemporaryIndex != nullptr);
++(*mTemporaryIndex);
ASSERT(mTemporaryId != nullptr);
*mTemporaryId = TSymbolUniqueId();
}
void TLValueTrackingTraverser::addToFunctionMap(const TSymbolUniqueId &id,
......
......@@ -145,17 +145,17 @@ void RecordConstantPrecisionTraverser::visitConstantUnion(TIntermConstantUnion *
void RecordConstantPrecisionTraverser::nextIteration()
{
nextTemporaryIndex();
nextTemporaryId();
mFoundHigherPrecisionConstant = false;
}
} // namespace
void RecordConstantPrecision(TIntermNode *root, unsigned int *temporaryIndex)
void RecordConstantPrecision(TIntermNode *root, TSymbolUniqueId *temporaryId)
{
RecordConstantPrecisionTraverser traverser;
ASSERT(temporaryIndex != nullptr);
traverser.useTemporaryIndex(temporaryIndex);
ASSERT(temporaryId != nullptr);
traverser.useTemporaryId(temporaryId);
// Iterate as necessary, and reset the traverser between iterations.
do
{
......
......@@ -20,8 +20,9 @@
namespace sh
{
class TIntermNode;
class TSymbolUniqueId;
void RecordConstantPrecision(TIntermNode *root, unsigned int *temporaryIndex);
void RecordConstantPrecision(TIntermNode *root, TSymbolUniqueId *temporaryId);
} // namespace sh
#endif // COMPILER_TRANSLATOR_RECORDCONSTANTPRECISION_H_
......@@ -478,15 +478,15 @@ bool RemoveDynamicIndexingTraverser::visitBinary(Visit visit, TIntermBinary *nod
initIndex->setLine(node->getLine());
insertionsBefore.push_back(initIndex);
// Create a node for referring to the index after the nextTemporaryIndex() call
// Create a node for referring to the index after the nextTemporaryId() call
// below.
TIntermSymbol *tempIndex = createTempSymbol(indexInitializer->getType());
TIntermAggregate *indexingCall =
CreateIndexFunctionCall(node, tempIndex, indexingFunctionId);
nextTemporaryIndex(); // From now on, creating temporary symbols that refer to the
// field value.
nextTemporaryId(); // From now on, creating temporary symbols that refer to the
// field value.
insertionsBefore.push_back(createTempInitDeclaration(indexingCall));
TIntermAggregate *indexedWriteCall = CreateIndexedWriteFunctionCall(
......@@ -517,19 +517,19 @@ void RemoveDynamicIndexingTraverser::nextIteration()
{
mUsedTreeInsertion = false;
mRemoveIndexSideEffectsInSubtree = false;
nextTemporaryIndex();
nextTemporaryId();
}
} // namespace
void RemoveDynamicIndexing(TIntermNode *root,
unsigned int *temporaryIndex,
TSymbolUniqueId *temporaryId,
const TSymbolTable &symbolTable,
int shaderVersion)
{
RemoveDynamicIndexingTraverser traverser(symbolTable, shaderVersion);
ASSERT(temporaryIndex != nullptr);
traverser.useTemporaryIndex(temporaryIndex);
ASSERT(temporaryId != nullptr);
traverser.useTemporaryId(temporaryId);
do
{
traverser.nextIteration();
......
......@@ -15,9 +15,10 @@ namespace sh
class TIntermNode;
class TSymbolTable;
class TSymbolUniqueId;
void RemoveDynamicIndexing(TIntermNode *root,
unsigned int *temporaryIndex,
TSymbolUniqueId *temporaryId,
const TSymbolTable &symbolTable,
int shaderVersion);
......
......@@ -138,7 +138,7 @@ class DoWhileRewriter : public TIntermTraverser
node->replaceChildNodeWithMultiple(loop, replacement);
nextTemporaryIndex();
nextTemporaryId();
}
return true;
}
......@@ -146,12 +146,12 @@ class DoWhileRewriter : public TIntermTraverser
} // anonymous namespace
void RewriteDoWhile(TIntermNode *root, unsigned int *temporaryIndex)
void RewriteDoWhile(TIntermNode *root, TSymbolUniqueId *temporaryId)
{
ASSERT(temporaryIndex != 0);
ASSERT(temporaryId != 0);
DoWhileRewriter rewriter;
rewriter.useTemporaryIndex(temporaryIndex);
rewriter.useTemporaryId(temporaryId);
root->traverse(&rewriter);
}
......
......@@ -12,8 +12,12 @@
namespace sh
{
class TIntermNode;
void RewriteDoWhile(TIntermNode *root, unsigned int *temporaryIndex);
class TSymbolUniqueId;
void RewriteDoWhile(TIntermNode *root, TSymbolUniqueId *temporaryId);
} // namespace sh
#endif // COMPILER_TRANSLATOR_REWRITEDOWHILE_H_
......@@ -67,7 +67,7 @@ TIntermNode *ElseBlockRewriter::rewriteIfElse(TIntermIfElse *ifElse)
{
ASSERT(ifElse != nullptr);
nextTemporaryIndex();
nextTemporaryId();
TIntermDeclaration *storeCondition = createTempInitDeclaration(ifElse->getCondition());
......@@ -110,10 +110,10 @@ TIntermNode *ElseBlockRewriter::rewriteIfElse(TIntermIfElse *ifElse)
} // anonymous namespace
void RewriteElseBlocks(TIntermNode *node, unsigned int *temporaryIndex)
void RewriteElseBlocks(TIntermNode *node, TSymbolUniqueId *temporaryId)
{
ElseBlockRewriter rewriter;
rewriter.useTemporaryIndex(temporaryIndex);
rewriter.useTemporaryId(temporaryId);
node->traverse(&rewriter);
}
......
......@@ -15,7 +15,7 @@
namespace sh
{
void RewriteElseBlocks(TIntermNode *node, unsigned int *temporaryIndex);
void RewriteElseBlocks(TIntermNode *node, TSymbolUniqueId *temporaryId);
}
#endif // COMPILER_TRANSLATOR_REWRITEELSEBLOCKS_H_
......@@ -63,12 +63,12 @@ class ScalarizeArgsTraverser : public TIntermTraverser
public:
ScalarizeArgsTraverser(sh::GLenum shaderType,
bool fragmentPrecisionHigh,
unsigned int *temporaryIndex)
TSymbolUniqueId *temporaryId)
: TIntermTraverser(true, false, false),
mShaderType(shaderType),
mFragmentPrecisionHigh(fragmentPrecisionHigh)
{
useTemporaryIndex(temporaryIndex);
useTemporaryId(temporaryId);
}
protected:
......@@ -204,7 +204,7 @@ void ScalarizeArgsTraverser::scalarizeArgs(TIntermAggregate *aggregate,
void ScalarizeArgsTraverser::createTempVariable(TIntermTyped *original)
{
ASSERT(original);
nextTemporaryIndex();
nextTemporaryId();
TIntermDeclaration *decl = createTempInitDeclaration(original);
TType type = original->getType();
......@@ -230,9 +230,9 @@ void ScalarizeArgsTraverser::createTempVariable(TIntermTyped *original)
void ScalarizeVecAndMatConstructorArgs(TIntermBlock *root,
sh::GLenum shaderType,
bool fragmentPrecisionHigh,
unsigned int *temporaryIndex)
TSymbolUniqueId *temporaryId)
{
ScalarizeArgsTraverser scalarizer(shaderType, fragmentPrecisionHigh, temporaryIndex);
ScalarizeArgsTraverser scalarizer(shaderType, fragmentPrecisionHigh, temporaryId);
root->traverse(&scalarizer);
}
......
......@@ -16,11 +16,12 @@
namespace sh
{
class TIntermBlock;
class TSymbolUniqueId;
void ScalarizeVecAndMatConstructorArgs(TIntermBlock *root,
sh::GLenum shaderType,
bool fragmentPrecisionHigh,
unsigned int *temporaryIndex);
TSymbolUniqueId *temporaryId);
} // namespace sh
#endif // COMPILER_TRANSLATOR_SCALARIZEVECANDMATCONSTRUCTORARGS_H_
......@@ -105,16 +105,16 @@ bool SeparateExpressionsTraverser::visitAggregate(Visit visit, TIntermAggregate
void SeparateExpressionsTraverser::nextIteration()
{
mFoundArrayExpression = false;
nextTemporaryIndex();
nextTemporaryId();
}
} // namespace
void SeparateExpressionsReturningArrays(TIntermNode *root, unsigned int *temporaryIndex)
void SeparateExpressionsReturningArrays(TIntermNode *root, TSymbolUniqueId *temporaryId)
{
SeparateExpressionsTraverser traverser;
ASSERT(temporaryIndex != nullptr);
traverser.useTemporaryIndex(temporaryIndex);
ASSERT(temporaryId != nullptr);
traverser.useTemporaryId(temporaryId);
// Separate one expression at a time, and reset the traverser between iterations.
do
{
......
......@@ -15,8 +15,9 @@
namespace sh
{
class TIntermNode;
class TSymbolUniqueId;
void SeparateExpressionsReturningArrays(TIntermNode *root, unsigned int *temporaryIndex);
void SeparateExpressionsReturningArrays(TIntermNode *root, TSymbolUniqueId *temporaryId);
} // namespace sh
#endif // COMPILER_TRANSLATOR_SEPARATEEXPRESSIONSRETURNINGARRAYS_H_
......@@ -146,7 +146,7 @@ void SimplifyLoopConditionsTraverser::traverseLoop(TIntermLoop *node)
if (mFoundLoopToChange)
{
nextTemporaryIndex();
nextTemporaryId();
// Replace the loop condition with a boolean variable that's updated on each iteration.
TLoopType loopType = node->getType();
......@@ -284,13 +284,13 @@ void SimplifyLoopConditionsTraverser::traverseLoop(TIntermLoop *node)
void SimplifyLoopConditions(TIntermNode *root,
unsigned int conditionsToSimplifyMask,
unsigned int *temporaryIndex,
TSymbolUniqueId *temporaryId,
const TSymbolTable &symbolTable,
int shaderVersion)
{
SimplifyLoopConditionsTraverser traverser(conditionsToSimplifyMask, symbolTable, shaderVersion);
ASSERT(temporaryIndex != nullptr);
traverser.useTemporaryIndex(temporaryIndex);
ASSERT(temporaryId != nullptr);
traverser.useTemporaryId(temporaryId);
root->traverse(&traverser);
traverser.updateTree();
}
......
......@@ -15,10 +15,11 @@ namespace sh
{
class TIntermNode;
class TSymbolTable;
class TSymbolUniqueId;
void SimplifyLoopConditions(TIntermNode *root,
unsigned int conditionsToSimplify,
unsigned int *temporaryIndex,
TSymbolUniqueId *temporaryId,
const TSymbolTable &symbolTable,
int shaderVersion);
} // namespace sh
......
......@@ -57,7 +57,7 @@ void SplitSequenceOperatorTraverser::nextIteration()
{
mFoundExpressionToSplit = false;
mInsideSequenceOperator = 0;
nextTemporaryIndex();
nextTemporaryId();
}
bool SplitSequenceOperatorTraverser::visitAggregate(Visit visit, TIntermAggregate *node)
......@@ -138,13 +138,13 @@ bool SplitSequenceOperatorTraverser::visitTernary(Visit visit, TIntermTernary *n
void SplitSequenceOperator(TIntermNode *root,
int patternsToSplitMask,
unsigned int *temporaryIndex,
TSymbolUniqueId *temporaryId,
const TSymbolTable &symbolTable,
int shaderVersion)
{
SplitSequenceOperatorTraverser traverser(patternsToSplitMask, symbolTable, shaderVersion);
ASSERT(temporaryIndex != nullptr);
traverser.useTemporaryIndex(temporaryIndex);
ASSERT(temporaryId != nullptr);
traverser.useTemporaryId(temporaryId);
// Separate one expression at a time, and reset the traverser between iterations.
do
{
......
......@@ -17,10 +17,11 @@ namespace sh
class TIntermNode;
class TSymbolTable;
class TSymbolUniqueId;
void SplitSequenceOperator(TIntermNode *root,
int patternsToSplitMask,
unsigned int *temporaryIndex,
TSymbolUniqueId *temporaryId,
const TSymbolTable &symbolTable,
int shaderVersion);
......
......@@ -62,7 +62,7 @@ void TranslatorESSL::translate(TIntermBlock *root, ShCompileOptions compileOptio
emulatePrecision.writeEmulationHelpers(sink, shaderVer, SH_ESSL_OUTPUT);
}
RecordConstantPrecision(root, getTemporaryIndex());
RecordConstantPrecision(root, getTemporaryId());
// Write emulated built-in functions if needed.
if (!getBuiltInFunctionEmulator().isOutputEmpty())
......
......@@ -46,7 +46,7 @@ void TranslatorHLSL::translate(TIntermBlock *root, ShCompileOptions compileOptio
IntermNodePatternMatcher::kUnfoldedShortCircuitExpression |
IntermNodePatternMatcher::kDynamicIndexingOfVectorOrMatrixInLValue |
IntermNodePatternMatcher::kMultiDeclaration,
getTemporaryIndex(), getSymbolTable(), getShaderVersion());
getTemporaryId(), getSymbolTable(), getShaderVersion());
// Note that separate declarations need to be run before other AST transformations that
// generate new statements from expressions.
......@@ -56,31 +56,31 @@ void TranslatorHLSL::translate(TIntermBlock *root, ShCompileOptions compileOptio
IntermNodePatternMatcher::kExpressionReturningArray |
IntermNodePatternMatcher::kUnfoldedShortCircuitExpression |
IntermNodePatternMatcher::kDynamicIndexingOfVectorOrMatrixInLValue,
getTemporaryIndex(), getSymbolTable(), getShaderVersion());
getTemporaryId(), getSymbolTable(), getShaderVersion());
// Note that SeparateDeclarations needs to be run before UnfoldShortCircuitToIf.
UnfoldShortCircuitToIf(root, getTemporaryIndex());
UnfoldShortCircuitToIf(root, getTemporaryId());
SeparateExpressionsReturningArrays(root, getTemporaryIndex());
SeparateExpressionsReturningArrays(root, getTemporaryId());
// Note that SeparateDeclarations needs to be run before SeparateArrayInitialization.
SeparateArrayInitialization(root);
// HLSL doesn't support arrays as return values, we'll need to make functions that have an array
// as a return value to use an out parameter to transfer the array data instead.
ArrayReturnValueToOutParameter(root, getTemporaryIndex());
ArrayReturnValueToOutParameter(root, getTemporaryId());
if (!shouldRunLoopAndIndexingValidation(compileOptions))
{
// HLSL doesn't support dynamic indexing of vectors and matrices.
RemoveDynamicIndexing(root, getTemporaryIndex(), getSymbolTable(), getShaderVersion());
RemoveDynamicIndexing(root, getTemporaryId(), getSymbolTable(), getShaderVersion());
}
// Work around D3D9 bug that would manifest in vertex shaders with selection blocks which
// use a vertex attribute as a condition, and some related computation in the else block.
if (getOutputType() == SH_HLSL_3_0_OUTPUT && getShaderType() == GL_VERTEX_SHADER)
{
sh::RewriteElseBlocks(root, getTemporaryIndex());
sh::RewriteElseBlocks(root, getTemporaryId());
}
// Work around an HLSL compiler frontend aliasing optimization bug.
......@@ -103,7 +103,7 @@ void TranslatorHLSL::translate(TIntermBlock *root, ShCompileOptions compileOptio
if ((compileOptions & SH_EXPAND_SELECT_HLSL_INTEGER_POW_EXPRESSIONS) != 0)
{
sh::ExpandIntegerPowExpressions(root, getTemporaryIndex());
sh::ExpandIntegerPowExpressions(root, getTemporaryId());
}
if ((compileOptions & SH_REWRITE_TEXELFETCHOFFSET_TO_TEXELFETCH) != 0)
......
......@@ -165,16 +165,16 @@ bool UnfoldShortCircuitTraverser::visitTernary(Visit visit, TIntermTernary *node
void UnfoldShortCircuitTraverser::nextIteration()
{
mFoundShortCircuit = false;
nextTemporaryIndex();
nextTemporaryId();
}
} // namespace
void UnfoldShortCircuitToIf(TIntermNode *root, unsigned int *temporaryIndex)
void UnfoldShortCircuitToIf(TIntermNode *root, TSymbolUniqueId *temporaryId)
{
UnfoldShortCircuitTraverser traverser;
ASSERT(temporaryIndex != nullptr);
traverser.useTemporaryIndex(temporaryIndex);
ASSERT(temporaryId != nullptr);
traverser.useTemporaryId(temporaryId);
// Unfold one operator at a time, and reset the traverser between iterations.
do
{
......
......@@ -14,9 +14,12 @@
namespace sh
{
class TIntermNode;
class TSymbolUniqueId;
void UnfoldShortCircuitToIf(TIntermNode *root, TSymbolUniqueId *temporaryId);
void UnfoldShortCircuitToIf(TIntermNode *root, unsigned int *temporaryIndex);
} // namespace sh
#endif // COMPILER_TRANSLATOR_UNFOLDSHORTCIRCUIT_H_
......@@ -88,7 +88,9 @@ void TOutputTraverser::visitSymbol(TIntermSymbol *node)
OutputTreeText(sink, node, mDepth);
sink << "'" << node->getSymbol() << "' ";
sink << "(" << node->getCompleteString() << ")\n";
sink << "(symbol id " << node->getId() << ") ";
sink << "(" << node->getCompleteString() << ")";
sink << "\n";
}
bool TOutputTraverser::visitSwizzle(Visit visit, TIntermSwizzle *node)
......
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