summaryrefslogtreecommitdiffstats
path: root/gfx/angle/src/compiler/translator/RewriteTexelFetchOffset.cpp
diff options
context:
space:
mode:
authorwolfbeast <mcwerewolf@gmail.com>2018-07-11 18:11:13 +0200
committerwolfbeast <mcwerewolf@gmail.com>2018-07-11 18:11:13 +0200
commit4f2ecd53a9daaf88bb7d075745eefb6e2e4741e0 (patch)
treef000dd831240707a03b8c806db292c2a15cde3ce /gfx/angle/src/compiler/translator/RewriteTexelFetchOffset.cpp
parent3b7ffb477eec078c7036c92c6a51bb5de6de4f28 (diff)
downloadUXP-4f2ecd53a9daaf88bb7d075745eefb6e2e4741e0.tar
UXP-4f2ecd53a9daaf88bb7d075745eefb6e2e4741e0.tar.gz
UXP-4f2ecd53a9daaf88bb7d075745eefb6e2e4741e0.tar.lz
UXP-4f2ecd53a9daaf88bb7d075745eefb6e2e4741e0.tar.xz
UXP-4f2ecd53a9daaf88bb7d075745eefb6e2e4741e0.zip
Roll back to ANGLE/2845
Diffstat (limited to 'gfx/angle/src/compiler/translator/RewriteTexelFetchOffset.cpp')
-rwxr-xr-xgfx/angle/src/compiler/translator/RewriteTexelFetchOffset.cpp54
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