diff options
author | wolfbeast <mcwerewolf@gmail.com> | 2018-07-11 23:29:50 +0200 |
---|---|---|
committer | wolfbeast <mcwerewolf@gmail.com> | 2018-07-11 23:31:02 +0200 |
commit | 70dd5e7c66b1fe3f82e5b4db2406050baba15f05 (patch) | |
tree | 3f012200ef3c934f33db1a4ef2b790fae3141860 /gfx/angle/src/compiler/translator/RewriteTexelFetchOffset.cpp | |
parent | 3b7ffb477eec078c7036c92c6a51bb5de6de4f28 (diff) | |
parent | 8481fa25d246f1968d0a254ee3c6cdd82c60781a (diff) | |
download | UXP-70dd5e7c66b1fe3f82e5b4db2406050baba15f05.tar UXP-70dd5e7c66b1fe3f82e5b4db2406050baba15f05.tar.gz UXP-70dd5e7c66b1fe3f82e5b4db2406050baba15f05.tar.lz UXP-70dd5e7c66b1fe3f82e5b4db2406050baba15f05.tar.xz UXP-70dd5e7c66b1fe3f82e5b4db2406050baba15f05.zip |
Merge branch 'ANGLE-rollback'
This resolves #624
Note: Cherry-picked some fixes on top of the ANGLE version that we want to keep.
Diffstat (limited to 'gfx/angle/src/compiler/translator/RewriteTexelFetchOffset.cpp')
-rwxr-xr-x | gfx/angle/src/compiler/translator/RewriteTexelFetchOffset.cpp | 54 |
1 files changed, 31 insertions, 23 deletions
diff --git a/gfx/angle/src/compiler/translator/RewriteTexelFetchOffset.cpp b/gfx/angle/src/compiler/translator/RewriteTexelFetchOffset.cpp index 487c90991..4ceceb226 100755 --- a/gfx/angle/src/compiler/translator/RewriteTexelFetchOffset.cpp +++ b/gfx/angle/src/compiler/translator/RewriteTexelFetchOffset.cpp @@ -22,6 +22,7 @@ class Traverser : public TIntermTraverser { public: static void Apply(TIntermNode *root, + unsigned int *tempIndex, const TSymbolTable &symbolTable, int shaderVersion); @@ -42,10 +43,12 @@ Traverser::Traverser(const TSymbolTable &symbolTable, int shaderVersion) // static void Traverser::Apply(TIntermNode *root, + unsigned int *tempIndex, const TSymbolTable &symbolTable, int shaderVersion) { Traverser traverser(symbolTable, shaderVersion); + traverser.useTemporaryIndex(tempIndex); do { traverser.nextIteration(); @@ -60,6 +63,7 @@ void Traverser::Apply(TIntermNode *root, void Traverser::nextIteration() { mFound = false; + nextTemporaryIndex(); } bool Traverser::visitAggregate(Visit visit, TIntermAggregate *node) @@ -75,7 +79,7 @@ bool Traverser::visitAggregate(Visit visit, TIntermAggregate *node) return true; } - if (node->getFunctionSymbolInfo()->getName().compare(0, 16, "texelFetchOffset") != 0) + if (node->getName().compare(0, 16, "texelFetchOffset") != 0) { return true; } @@ -83,36 +87,42 @@ bool Traverser::visitAggregate(Visit visit, TIntermAggregate *node) // Potential problem case detected, apply workaround. const TIntermSequence *sequence = node->getSequence(); ASSERT(sequence->size() == 4u); + nextTemporaryIndex(); // Decide if there is a 2DArray sampler. - bool is2DArray = node->getFunctionSymbolInfo()->getName().find("s2a1") != TString::npos; + bool is2DArray = node->getName().find("s2a1") != TString::npos; // Create new argument list from node->getName(). // e.g. Get "(is2a1;vi3;i1;" from "texelFetchOffset(is2a1;vi3;i1;vi2;" - TString newArgs = node->getFunctionSymbolInfo()->getName().substr( - 16, node->getFunctionSymbolInfo()->getName().length() - 20); + TString newArgs = node->getName().substr(16, node->getName().length() - 20); TString newName = "texelFetch" + newArgs; TSymbol *texelFetchSymbol = symbolTable->findBuiltIn(newName, shaderVersion); ASSERT(texelFetchSymbol); int uniqueId = texelFetchSymbol->getUniqueId(); // Create new node that represents the call of function texelFetch. - // Its argument list will be: texelFetch(sampler, Position+offset, lod). TIntermAggregate *texelFetchNode = new TIntermAggregate(EOpFunctionCall); - texelFetchNode->getFunctionSymbolInfo()->setName(newName); - texelFetchNode->getFunctionSymbolInfo()->setId(uniqueId); + texelFetchNode->setName(newName); + texelFetchNode->setFunctionId(uniqueId); texelFetchNode->setType(node->getType()); texelFetchNode->setLine(node->getLine()); + // Create argument List of texelFetch(sampler, Position+offset, lod). + TIntermSequence newsequence; + // sampler - texelFetchNode->getSequence()->push_back(sequence->at(0)); + newsequence.push_back(sequence->at(0)); + // Position+offset + TIntermBinary *add = new TIntermBinary(EOpAdd); + add->setType(node->getType()); // Position TIntermTyped *texCoordNode = sequence->at(1)->getAsTyped(); ASSERT(texCoordNode); - + add->setLine(texCoordNode->getLine()); + add->setType(texCoordNode->getType()); + add->setLeft(texCoordNode); // offset - TIntermTyped *offsetNode = nullptr; ASSERT(sequence->at(3)->getAsTyped()); if (is2DArray) { @@ -122,31 +132,28 @@ bool Traverser::visitAggregate(Visit visit, TIntermAggregate *node) constructIVec3Node->setLine(texCoordNode->getLine()); constructIVec3Node->setType(texCoordNode->getType()); - constructIVec3Node->getSequence()->push_back(sequence->at(3)->getAsTyped()); + TIntermSequence ivec3Sequence; + ivec3Sequence.push_back(sequence->at(3)->getAsTyped()); TConstantUnion *zero = new TConstantUnion(); zero->setIConst(0); TType *intType = new TType(EbtInt); TIntermConstantUnion *zeroNode = new TIntermConstantUnion(zero, *intType); - constructIVec3Node->getSequence()->push_back(zeroNode); + ivec3Sequence.push_back(zeroNode); + constructIVec3Node->insertChildNodes(0, ivec3Sequence); - offsetNode = constructIVec3Node; + add->setRight(constructIVec3Node); } else { - offsetNode = sequence->at(3)->getAsTyped(); + add->setRight(sequence->at(3)->getAsTyped()); } - - // Position+offset - TIntermBinary *add = new TIntermBinary(EOpAdd, texCoordNode, offsetNode); - add->setLine(texCoordNode->getLine()); - texelFetchNode->getSequence()->push_back(add); + newsequence.push_back(add); // lod - texelFetchNode->getSequence()->push_back(sequence->at(2)); - - ASSERT(texelFetchNode->getSequence()->size() == 3u); + newsequence.push_back(sequence->at(2)); + texelFetchNode->insertChildNodes(0, newsequence); // Replace the old node by this new node. queueReplacement(node, texelFetchNode, OriginalNode::IS_DROPPED); @@ -157,6 +164,7 @@ bool Traverser::visitAggregate(Visit visit, TIntermAggregate *node) } // anonymous namespace void RewriteTexelFetchOffset(TIntermNode *root, + unsigned int *tempIndex, const TSymbolTable &symbolTable, int shaderVersion) { @@ -164,7 +172,7 @@ void RewriteTexelFetchOffset(TIntermNode *root, if (shaderVersion < 300) return; - Traverser::Apply(root, symbolTable, shaderVersion); + Traverser::Apply(root, tempIndex, symbolTable, shaderVersion); } } // namespace sh
\ No newline at end of file |