Commit f0286e63 by Shahbaz Youssefi Committed by Commit Bot

Translator: Stop allocating TIntermSequence

The functions that take a TIntermSequence always copy out / Swap the contents away. This change makes all TIntermSequences live on the stack instead of being newed. Bug: angleproject:5535 Change-Id: I942f1c5e57b00199d5308183f71bd9e18b0608bd Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/2636679Reviewed-by: 's avatarJamie Madill <jmadill@chromium.org> Reviewed-by: 's avatarTim Van Patten <timvp@google.com> Commit-Queue: Shahbaz Youssefi <syoussefi@chromium.org>
parent 137271ff
...@@ -1054,9 +1054,9 @@ TIntermAggregate::TIntermAggregate(const TIntermAggregate &node) ...@@ -1054,9 +1054,9 @@ TIntermAggregate::TIntermAggregate(const TIntermAggregate &node)
TIntermAggregate *TIntermAggregate::shallowCopy() const TIntermAggregate *TIntermAggregate::shallowCopy() const
{ {
TIntermSequence *copySeq = new TIntermSequence(); TIntermSequence copySeq;
copySeq->insert(copySeq->begin(), getSequence()->begin(), getSequence()->end()); copySeq.insert(copySeq.begin(), getSequence()->begin(), getSequence()->end());
TIntermAggregate *copyNode = new TIntermAggregate(mFunction, mType, mOp, copySeq); TIntermAggregate *copyNode = new TIntermAggregate(mFunction, mType, mOp, &copySeq);
copyNode->setLine(mLine); copyNode->setLine(mLine);
return copyNode; return copyNode;
} }
......
...@@ -88,7 +88,7 @@ ANGLE_NO_DISCARD bool InitializeUnusedOutputs(TIntermBlock *root, ...@@ -88,7 +88,7 @@ ANGLE_NO_DISCARD bool InitializeUnusedOutputs(TIntermBlock *root,
return true; return true;
} }
TIntermSequence *insertSequence = new TIntermSequence; TIntermSequence insertSequence;
for (const sh::ShaderVariable &var : unusedVars) for (const sh::ShaderVariable &var : unusedVars)
{ {
...@@ -96,18 +96,19 @@ ANGLE_NO_DISCARD bool InitializeUnusedOutputs(TIntermBlock *root, ...@@ -96,18 +96,19 @@ ANGLE_NO_DISCARD bool InitializeUnusedOutputs(TIntermBlock *root,
const TIntermSymbol *symbol = FindSymbolNode(root, var.name); const TIntermSymbol *symbol = FindSymbolNode(root, var.name);
ASSERT(symbol); ASSERT(symbol);
TIntermSequence *initCode = CreateInitCode(symbol, false, false, symbolTable); TIntermSequence initCode;
CreateInitCode(symbol, false, false, &initCode, symbolTable);
insertSequence->insert(insertSequence->end(), initCode->begin(), initCode->end()); insertSequence.insert(insertSequence.end(), initCode.begin(), initCode.end());
} }
if (insertSequence) if (!insertSequence.empty())
{ {
TIntermFunctionDefinition *main = FindMain(root); TIntermFunctionDefinition *main = FindMain(root);
TIntermSequence *mainSequence = main->getBody()->getSequence(); TIntermSequence *mainSequence = main->getBody()->getSequence();
// Insert init code at the start of main() // Insert init code at the start of main()
mainSequence->insert(mainSequence->begin(), insertSequence->begin(), insertSequence->end()); mainSequence->insert(mainSequence->begin(), insertSequence.begin(), insertSequence.end());
} }
return true; return true;
...@@ -320,10 +321,10 @@ ANGLE_NO_DISCARD bool TranslatorMetal::insertSampleMaskWritingLogic( ...@@ -320,10 +321,10 @@ ANGLE_NO_DISCARD bool TranslatorMetal::insertSampleMaskWritingLogic(
// { // {
// ANGLEWriteSampleMask(ANGLEUniforms.coverageMask); // ANGLEWriteSampleMask(ANGLEUniforms.coverageMask);
// } // }
TIntermSequence *args = new TIntermSequence; TIntermSequence args;
args->push_back(coverageMask); args.push_back(coverageMask);
TIntermAggregate *callSampleMaskWriteFunc = TIntermAggregate *callSampleMaskWriteFunc =
TIntermAggregate::CreateFunctionCall(*sampleMaskWriteFunc, args); TIntermAggregate::CreateFunctionCall(*sampleMaskWriteFunc, &args);
TIntermBlock *callBlock = new TIntermBlock; TIntermBlock *callBlock = new TIntermBlock;
callBlock->appendStatement(callSampleMaskWriteFunc); callBlock->appendStatement(callSampleMaskWriteFunc);
...@@ -359,14 +360,14 @@ ANGLE_NO_DISCARD bool TranslatorMetal::insertRasterizerDiscardLogic(TIntermBlock ...@@ -359,14 +360,14 @@ ANGLE_NO_DISCARD bool TranslatorMetal::insertRasterizerDiscardLogic(TIntermBlock
TIntermSymbol *positionRef = new TIntermSymbol(position); TIntermSymbol *positionRef = new TIntermSymbol(position);
// Create vec4(-3, -3, -3, 1): // Create vec4(-3, -3, -3, 1):
auto vec4Type = new TType(EbtFloat, 4); auto vec4Type = new TType(EbtFloat, 4);
TIntermSequence *vec4Args = new TIntermSequence(); TIntermSequence vec4Args;
vec4Args->push_back(CreateFloatNode(-3.0f)); vec4Args.push_back(CreateFloatNode(-3.0f));
vec4Args->push_back(CreateFloatNode(-3.0f)); vec4Args.push_back(CreateFloatNode(-3.0f));
vec4Args->push_back(CreateFloatNode(-3.0f)); vec4Args.push_back(CreateFloatNode(-3.0f));
vec4Args->push_back(CreateFloatNode(1.0f)); vec4Args.push_back(CreateFloatNode(1.0f));
TIntermAggregate *constVarConstructor = TIntermAggregate *constVarConstructor =
TIntermAggregate::CreateConstructor(*vec4Type, vec4Args); TIntermAggregate::CreateConstructor(*vec4Type, &vec4Args);
// Create the assignment "gl_Position = vec4(-3, -3, -3, 1)" // Create the assignment "gl_Position = vec4(-3, -3, -3, 1)"
TIntermBinary *assignment = TIntermBinary *assignment =
......
...@@ -229,10 +229,11 @@ ANGLE_NO_DISCARD bool RotateAndFlipBuiltinVariable(TCompiler *compiler, ...@@ -229,10 +229,11 @@ ANGLE_NO_DISCARD bool RotateAndFlipBuiltinVariable(TCompiler *compiler,
TIntermBinary *plusPivot = new TIntermBinary(EOpAdd, inverseXY, pivot->deepCopy()); TIntermBinary *plusPivot = new TIntermBinary(EOpAdd, inverseXY, pivot->deepCopy());
// Create the corrected variable and copy the value of the original builtin. // Create the corrected variable and copy the value of the original builtin.
TIntermSequence *sequence = new TIntermSequence(); TIntermSequence sequence;
sequence->push_back(builtinRef->deepCopy()); sequence.push_back(builtinRef->deepCopy());
TIntermAggregate *aggregate = TIntermAggregate::CreateConstructor(builtin->getType(), sequence); TIntermAggregate *aggregate =
TIntermBinary *assignment = new TIntermBinary(EOpInitialize, flippedBuiltinRef, aggregate); TIntermAggregate::CreateConstructor(builtin->getType(), &sequence);
TIntermBinary *assignment = new TIntermBinary(EOpInitialize, flippedBuiltinRef, aggregate);
// Create an assignment to the replaced variable's .xy. // Create an assignment to the replaced variable's .xy.
TIntermSwizzle *correctedXY = TIntermSwizzle *correctedXY =
...@@ -293,12 +294,12 @@ TVariable *AddANGLEPositionVaryingDeclaration(TIntermBlock *root, ...@@ -293,12 +294,12 @@ TVariable *AddANGLEPositionVaryingDeclaration(TIntermBlock *root,
TIntermDeclaration *varyingDecl = new TIntermDeclaration; TIntermDeclaration *varyingDecl = new TIntermDeclaration;
varyingDecl->appendDeclarator(varyingDeclarator); varyingDecl->appendDeclarator(varyingDeclarator);
TIntermSequence *insertSequence = new TIntermSequence; TIntermSequence insertSequence;
insertSequence->push_back(varyingDecl); insertSequence.push_back(varyingDecl);
// Insert the declarations before Main. // Insert the declarations before Main.
size_t mainIndex = FindMainIndex(root); size_t mainIndex = FindMainIndex(root);
root->insertChildNodes(mainIndex, *insertSequence); root->insertChildNodes(mainIndex, insertSequence);
return varyingVar; return varyingVar;
} }
......
...@@ -36,11 +36,11 @@ bool ClampPointSize(TCompiler *compiler, ...@@ -36,11 +36,11 @@ bool ClampPointSize(TCompiler *compiler,
new TIntermConstantUnion(maxPointSizeConstant, TType(EbtFloat, EbpHigh, EvqConst)); new TIntermConstantUnion(maxPointSizeConstant, TType(EbtFloat, EbpHigh, EvqConst));
// min(gl_PointSize, maxPointSize) // min(gl_PointSize, maxPointSize)
TIntermSequence *minArguments = new TIntermSequence(); TIntermSequence minArguments;
minArguments->push_back(pointSizeNode->deepCopy()); minArguments.push_back(pointSizeNode->deepCopy());
minArguments->push_back(maxPointSizeNode); minArguments.push_back(maxPointSizeNode);
TIntermTyped *clampedPointSize = TIntermTyped *clampedPointSize =
CreateBuiltInFunctionCallNode("min", minArguments, *symbolTable, 100); CreateBuiltInFunctionCallNode("min", &minArguments, *symbolTable, 100);
// gl_PointSize = min(gl_PointSize, maxPointSize) // gl_PointSize = min(gl_PointSize, maxPointSize)
TIntermBinary *assignPointSize = new TIntermBinary(EOpAssign, pointSizeNode, clampedPointSize); TIntermBinary *assignPointSize = new TIntermBinary(EOpAssign, pointSizeNode, clampedPointSize);
......
...@@ -45,20 +45,20 @@ void InitializeViewIDAndInstanceID(const TVariable *viewID, ...@@ -45,20 +45,20 @@ void InitializeViewIDAndInstanceID(const TVariable *viewID,
new TIntermConstantUnion(numberOfViewsUnsignedConstant, TType(EbtUInt, EbpHigh, EvqConst)); new TIntermConstantUnion(numberOfViewsUnsignedConstant, TType(EbtUInt, EbpHigh, EvqConst));
// Create a uint(gl_InstanceID) node. // Create a uint(gl_InstanceID) node.
TIntermSequence *glInstanceIDSymbolCastArguments = new TIntermSequence(); TIntermSequence glInstanceIDSymbolCastArguments;
glInstanceIDSymbolCastArguments->push_back(new TIntermSymbol(BuiltInVariable::gl_InstanceID())); glInstanceIDSymbolCastArguments.push_back(new TIntermSymbol(BuiltInVariable::gl_InstanceID()));
TIntermAggregate *glInstanceIDAsUint = TIntermAggregate::CreateConstructor( TIntermAggregate *glInstanceIDAsUint = TIntermAggregate::CreateConstructor(
TType(EbtUInt, EbpHigh, EvqTemporary), glInstanceIDSymbolCastArguments); TType(EbtUInt, EbpHigh, EvqTemporary), &glInstanceIDSymbolCastArguments);
// Create a uint(gl_InstanceID) / numberOfViews node. // Create a uint(gl_InstanceID) / numberOfViews node.
TIntermBinary *normalizedInstanceID = TIntermBinary *normalizedInstanceID =
new TIntermBinary(EOpDiv, glInstanceIDAsUint, numberOfViewsUint); new TIntermBinary(EOpDiv, glInstanceIDAsUint, numberOfViewsUint);
// Create an int(uint(gl_InstanceID) / numberOfViews) node. // Create an int(uint(gl_InstanceID) / numberOfViews) node.
TIntermSequence *normalizedInstanceIDCastArguments = new TIntermSequence(); TIntermSequence normalizedInstanceIDCastArguments;
normalizedInstanceIDCastArguments->push_back(normalizedInstanceID); normalizedInstanceIDCastArguments.push_back(normalizedInstanceID);
TIntermAggregate *normalizedInstanceIDAsInt = TIntermAggregate::CreateConstructor( TIntermAggregate *normalizedInstanceIDAsInt = TIntermAggregate::CreateConstructor(
TType(EbtInt, EbpHigh, EvqTemporary), normalizedInstanceIDCastArguments); TType(EbtInt, EbpHigh, EvqTemporary), &normalizedInstanceIDCastArguments);
// Create an InstanceID = int(uint(gl_InstanceID) / numberOfViews) node. // Create an InstanceID = int(uint(gl_InstanceID) / numberOfViews) node.
TIntermBinary *instanceIDInitializer = TIntermBinary *instanceIDInitializer =
...@@ -83,10 +83,10 @@ void SelectViewIndexInVertexShader(const TVariable *viewID, ...@@ -83,10 +83,10 @@ void SelectViewIndexInVertexShader(const TVariable *viewID,
const TSymbolTable &symbolTable) const TSymbolTable &symbolTable)
{ {
// Create an int(ViewID_OVR) node. // Create an int(ViewID_OVR) node.
TIntermSequence *viewIDSymbolCastArguments = new TIntermSequence(); TIntermSequence viewIDSymbolCastArguments;
viewIDSymbolCastArguments->push_back(new TIntermSymbol(viewID)); viewIDSymbolCastArguments.push_back(new TIntermSymbol(viewID));
TIntermAggregate *viewIDAsInt = TIntermAggregate::CreateConstructor( TIntermAggregate *viewIDAsInt = TIntermAggregate::CreateConstructor(
TType(EbtInt, EbpHigh, EvqTemporary), viewIDSymbolCastArguments); TType(EbtInt, EbpHigh, EvqTemporary), &viewIDSymbolCastArguments);
// Create a gl_ViewportIndex node. // Create a gl_ViewportIndex node.
TIntermSymbol *viewportIndexSymbol = new TIntermSymbol(BuiltInVariable::gl_ViewportIndex()); TIntermSymbol *viewportIndexSymbol = new TIntermSymbol(BuiltInVariable::gl_ViewportIndex());
...@@ -157,9 +157,9 @@ bool DeclareAndInitBuiltinsForInstancedMultiview(TCompiler *compiler, ...@@ -157,9 +157,9 @@ bool DeclareAndInitBuiltinsForInstancedMultiview(TCompiler *compiler,
return false; return false;
} }
TIntermSequence *initializers = new TIntermSequence(); TIntermSequence initializers;
InitializeViewIDAndInstanceID(viewID, instanceID, numberOfViews, *symbolTable, InitializeViewIDAndInstanceID(viewID, instanceID, numberOfViews, *symbolTable,
initializers); &initializers);
// The AST transformation which adds the expression to select the viewport index should // The AST transformation which adds the expression to select the viewport index should
// be done only for the GLSL and ESSL output. // be done only for the GLSL and ESSL output.
...@@ -179,13 +179,13 @@ bool DeclareAndInitBuiltinsForInstancedMultiview(TCompiler *compiler, ...@@ -179,13 +179,13 @@ bool DeclareAndInitBuiltinsForInstancedMultiview(TCompiler *compiler,
// Setting a value to gl_ViewportIndex or gl_Layer should happen after ViewID_OVR's // Setting a value to gl_ViewportIndex or gl_Layer should happen after ViewID_OVR's
// initialization. // initialization.
SelectViewIndexInVertexShader(viewID, multiviewBaseViewLayerIndex, initializers, SelectViewIndexInVertexShader(viewID, multiviewBaseViewLayerIndex, &initializers,
*symbolTable); *symbolTable);
} }
// Insert initializers at the beginning of main(). // Insert initializers at the beginning of main().
TIntermBlock *initializersBlock = new TIntermBlock(); TIntermBlock *initializersBlock = new TIntermBlock();
initializersBlock->getSequence()->swap(*initializers); initializersBlock->getSequence()->swap(initializers);
TIntermBlock *mainBody = FindMainBody(root); TIntermBlock *mainBody = FindMainBody(root);
mainBody->getSequence()->insert(mainBody->getSequence()->begin(), initializersBlock); mainBody->getSequence()->insert(mainBody->getSequence()->begin(), initializersBlock);
} }
......
...@@ -91,10 +91,11 @@ void GetDeferredInitializers(TIntermDeclaration *declaration, ...@@ -91,10 +91,11 @@ void GetDeferredInitializers(TIntermDeclaration *declaration,
if (symbolNode->getQualifier() == EvqGlobal) if (symbolNode->getQualifier() == EvqGlobal)
{ {
TIntermSequence *initCode = CreateInitCode(symbolNode, canUseLoopsToInitialize, TIntermSequence initCode;
highPrecisionSupported, symbolTable); CreateInitCode(symbolNode, canUseLoopsToInitialize, highPrecisionSupported, &initCode,
deferredInitializersOut->insert(deferredInitializersOut->end(), initCode->begin(), symbolTable);
initCode->end()); deferredInitializersOut->insert(deferredInitializersOut->end(), initCode.begin(),
initCode.end());
} }
} }
} }
...@@ -117,8 +118,9 @@ void InsertInitCallToMain(TIntermBlock *root, ...@@ -117,8 +118,9 @@ void InsertInitCallToMain(TIntermBlock *root,
CreateInternalFunctionDefinitionNode(*initGlobalsFunction, initGlobalsBlock); CreateInternalFunctionDefinitionNode(*initGlobalsFunction, initGlobalsBlock);
root->appendStatement(initGlobalsFunctionDefinition); root->appendStatement(initGlobalsFunctionDefinition);
TIntermSequence emptySequence;
TIntermAggregate *initGlobalsCall = TIntermAggregate *initGlobalsCall =
TIntermAggregate::CreateFunctionCall(*initGlobalsFunction, new TIntermSequence()); TIntermAggregate::CreateFunctionCall(*initGlobalsFunction, &emptySequence);
TIntermBlock *mainBody = FindMainBody(root); TIntermBlock *mainBody = FindMainBody(root);
mainBody->getSequence()->insert(mainBody->getSequence()->begin(), initGlobalsCall); mainBody->getSequence()->insert(mainBody->getSequence()->begin(), initGlobalsCall);
...@@ -133,7 +135,7 @@ bool DeferGlobalInitializers(TCompiler *compiler, ...@@ -133,7 +135,7 @@ bool DeferGlobalInitializers(TCompiler *compiler,
bool highPrecisionSupported, bool highPrecisionSupported,
TSymbolTable *symbolTable) TSymbolTable *symbolTable)
{ {
TIntermSequence *deferredInitializers = new TIntermSequence(); TIntermSequence deferredInitializers;
std::vector<const TVariable *> variablesToReplace; std::vector<const TVariable *> variablesToReplace;
// Loop over all global statements and process the declarations. This is simpler than using a // Loop over all global statements and process the declarations. This is simpler than using a
...@@ -145,14 +147,14 @@ bool DeferGlobalInitializers(TCompiler *compiler, ...@@ -145,14 +147,14 @@ bool DeferGlobalInitializers(TCompiler *compiler,
{ {
GetDeferredInitializers(declaration, initializeUninitializedGlobals, GetDeferredInitializers(declaration, initializeUninitializedGlobals,
canUseLoopsToInitialize, highPrecisionSupported, canUseLoopsToInitialize, highPrecisionSupported,
deferredInitializers, &variablesToReplace, symbolTable); &deferredInitializers, &variablesToReplace, symbolTable);
} }
} }
// Add the function with initialization and the call to that. // Add the function with initialization and the call to that.
if (!deferredInitializers->empty()) if (!deferredInitializers.empty())
{ {
InsertInitCallToMain(root, deferredInitializers, symbolTable); InsertInitCallToMain(root, &deferredInitializers, symbolTable);
} }
// Replace constant variables with non-constant global variables. // Replace constant variables with non-constant global variables.
......
...@@ -724,8 +724,8 @@ TIntermAggregate *EmulatePrecision::createRoundingFunctionCallNode(TIntermTyped ...@@ -724,8 +724,8 @@ TIntermAggregate *EmulatePrecision::createRoundingFunctionCallNode(TIntermTyped
const ImmutableString *roundFunctionName = &kAngleFrmString; const ImmutableString *roundFunctionName = &kAngleFrmString;
if (roundedChild->getPrecision() == EbpLow) if (roundedChild->getPrecision() == EbpLow)
roundFunctionName = &kAngleFrlString; roundFunctionName = &kAngleFrlString;
TIntermSequence *arguments = new TIntermSequence(); TIntermSequence arguments;
arguments->push_back(roundedChild); arguments.push_back(roundedChild);
TVector<const TVariable *> parameters; TVector<const TVariable *> parameters;
TType *paramType = new TType(roundedChild->getType()); TType *paramType = new TType(roundedChild->getType());
...@@ -736,9 +736,9 @@ TIntermAggregate *EmulatePrecision::createRoundingFunctionCallNode(TIntermTyped ...@@ -736,9 +736,9 @@ TIntermAggregate *EmulatePrecision::createRoundingFunctionCallNode(TIntermTyped
SymbolType::AngleInternal)); SymbolType::AngleInternal));
return TIntermAggregate::CreateRawFunctionCall( return TIntermAggregate::CreateRawFunctionCall(
*getInternalFunction(*roundFunctionName, roundedChild->getType(), arguments, parameters, *getInternalFunction(*roundFunctionName, roundedChild->getType(), &arguments, parameters,
true), true),
arguments); &arguments);
} }
TIntermAggregate *EmulatePrecision::createCompoundAssignmentFunctionCallNode(TIntermTyped *left, TIntermAggregate *EmulatePrecision::createCompoundAssignmentFunctionCallNode(TIntermTyped *left,
...@@ -751,9 +751,9 @@ TIntermAggregate *EmulatePrecision::createCompoundAssignmentFunctionCallNode(TIn ...@@ -751,9 +751,9 @@ TIntermAggregate *EmulatePrecision::createCompoundAssignmentFunctionCallNode(TIn
else else
strstr << "angle_compound_" << opNameStr << "_frl"; strstr << "angle_compound_" << opNameStr << "_frl";
ImmutableString functionName = ImmutableString(strstr.str()); ImmutableString functionName = ImmutableString(strstr.str());
TIntermSequence *arguments = new TIntermSequence(); TIntermSequence arguments;
arguments->push_back(left); arguments.push_back(left);
arguments->push_back(right); arguments.push_back(right);
TVector<const TVariable *> parameters; TVector<const TVariable *> parameters;
TType *leftParamType = new TType(left->getType()); TType *leftParamType = new TType(left->getType());
...@@ -770,8 +770,8 @@ TIntermAggregate *EmulatePrecision::createCompoundAssignmentFunctionCallNode(TIn ...@@ -770,8 +770,8 @@ TIntermAggregate *EmulatePrecision::createCompoundAssignmentFunctionCallNode(TIn
SymbolType::AngleInternal)); SymbolType::AngleInternal));
return TIntermAggregate::CreateRawFunctionCall( return TIntermAggregate::CreateRawFunctionCall(
*getInternalFunction(functionName, left->getType(), arguments, parameters, false), *getInternalFunction(functionName, left->getType(), &arguments, parameters, false),
arguments); &arguments);
} }
} // namespace sh } // namespace sh
...@@ -199,9 +199,10 @@ void InsertInitCode(TCompiler *compiler, ...@@ -199,9 +199,10 @@ void InsertInitCode(TCompiler *compiler,
} }
ASSERT(initializedSymbol != nullptr); ASSERT(initializedSymbol != nullptr);
TIntermSequence *initCode = CreateInitCode(initializedSymbol, canUseLoopsToInitialize, TIntermSequence initCode;
highPrecisionSupported, symbolTable); CreateInitCode(initializedSymbol, canUseLoopsToInitialize, highPrecisionSupported,
mainBody->insert(mainBody->begin(), initCode->begin(), initCode->end()); &initCode, symbolTable);
mainBody->insert(mainBody->begin(), initCode.begin(), initCode.end());
} }
} }
...@@ -251,9 +252,10 @@ class InitializeLocalsTraverser : public TIntermTraverser ...@@ -251,9 +252,10 @@ class InitializeLocalsTraverser : public TIntermTraverser
// about further declarators in this declaration depending on the effects of // about further declarators in this declaration depending on the effects of
// this declarator. // this declarator.
ASSERT(node->getSequence()->size() == 1); ASSERT(node->getSequence()->size() == 1);
insertStatementsInParentBlock( TIntermSequence initCode;
TIntermSequence(), *CreateInitCode(symbol, mCanUseLoopsToInitialize, CreateInitCode(symbol, mCanUseLoopsToInitialize, mHighPrecisionSupported,
mHighPrecisionSupported, mSymbolTable)); &initCode, mSymbolTable);
insertStatementsInParentBlock(TIntermSequence(), initCode);
} }
else else
{ {
...@@ -274,15 +276,14 @@ class InitializeLocalsTraverser : public TIntermTraverser ...@@ -274,15 +276,14 @@ class InitializeLocalsTraverser : public TIntermTraverser
} // namespace } // namespace
TIntermSequence *CreateInitCode(const TIntermTyped *initializedSymbol, void CreateInitCode(const TIntermTyped *initializedSymbol,
bool canUseLoopsToInitialize, bool canUseLoopsToInitialize,
bool highPrecisionSupported, bool highPrecisionSupported,
TSymbolTable *symbolTable) TIntermSequence *initCode,
TSymbolTable *symbolTable)
{ {
TIntermSequence *initCode = new TIntermSequence();
AddZeroInitSequence(initializedSymbol, canUseLoopsToInitialize, highPrecisionSupported, AddZeroInitSequence(initializedSymbol, canUseLoopsToInitialize, highPrecisionSupported,
initCode, symbolTable); initCode, symbolTable);
return initCode;
} }
bool InitializeUninitializedLocals(TCompiler *compiler, bool InitializeUninitializedLocals(TCompiler *compiler,
......
...@@ -22,12 +22,13 @@ typedef std::vector<sh::ShaderVariable> InitVariableList; ...@@ -22,12 +22,13 @@ typedef std::vector<sh::ShaderVariable> InitVariableList;
// For all of the functions below: If canUseLoopsToInitialize is set, for loops are used instead of // For all of the functions below: If canUseLoopsToInitialize is set, for loops are used instead of
// a large number of initializers where it can make sense, such as for initializing large arrays. // a large number of initializers where it can make sense, such as for initializing large arrays.
// Return a sequence of assignment operations to initialize "initializedSymbol". initializedSymbol // Populate a sequence of assignment operations to initialize "initializedSymbol". initializedSymbol
// may be an array, struct or any combination of these, as long as it contains only basic types. // may be an array, struct or any combination of these, as long as it contains only basic types.
TIntermSequence *CreateInitCode(const TIntermTyped *initializedSymbol, void CreateInitCode(const TIntermTyped *initializedSymbol,
bool canUseLoopsToInitialize, bool canUseLoopsToInitialize,
bool highPrecisionSupported, bool highPrecisionSupported,
TSymbolTable *symbolTable); TIntermSequence *initCode,
TSymbolTable *symbolTable);
// Initialize all uninitialized local variables, so that undefined behavior is avoided. // Initialize all uninitialized local variables, so that undefined behavior is avoided.
ANGLE_NO_DISCARD bool InitializeUninitializedLocals(TCompiler *compiler, ANGLE_NO_DISCARD bool InitializeUninitializedLocals(TCompiler *compiler,
......
...@@ -82,9 +82,9 @@ TIntermTyped *EnsureSignedInt(TIntermTyped *node) ...@@ -82,9 +82,9 @@ TIntermTyped *EnsureSignedInt(TIntermTyped *node)
if (node->getBasicType() == EbtInt) if (node->getBasicType() == EbtInt)
return node; return node;
TIntermSequence *arguments = new TIntermSequence(); TIntermSequence arguments;
arguments->push_back(node); arguments.push_back(node);
return TIntermAggregate::CreateConstructor(TType(EbtInt), arguments); return TIntermAggregate::CreateConstructor(TType(EbtInt), &arguments);
} }
TType *GetFieldType(const TType &indexedType) TType *GetFieldType(const TType &indexedType)
...@@ -329,12 +329,12 @@ TIntermAggregate *CreateIndexFunctionCall(TIntermBinary *node, ...@@ -329,12 +329,12 @@ TIntermAggregate *CreateIndexFunctionCall(TIntermBinary *node,
TFunction *indexingFunction) TFunction *indexingFunction)
{ {
ASSERT(node->getOp() == EOpIndexIndirect); ASSERT(node->getOp() == EOpIndexIndirect);
TIntermSequence *arguments = new TIntermSequence(); TIntermSequence arguments;
arguments->push_back(node->getLeft()); arguments.push_back(node->getLeft());
arguments->push_back(index); arguments.push_back(index);
TIntermAggregate *indexingCall = TIntermAggregate *indexingCall =
TIntermAggregate::CreateFunctionCall(*indexingFunction, arguments); TIntermAggregate::CreateFunctionCall(*indexingFunction, &arguments);
indexingCall->setLine(node->getLine()); indexingCall->setLine(node->getLine());
return indexingCall; return indexingCall;
} }
...@@ -345,14 +345,14 @@ TIntermAggregate *CreateIndexedWriteFunctionCall(TIntermBinary *node, ...@@ -345,14 +345,14 @@ TIntermAggregate *CreateIndexedWriteFunctionCall(TIntermBinary *node,
TFunction *indexedWriteFunction) TFunction *indexedWriteFunction)
{ {
ASSERT(node->getOp() == EOpIndexIndirect); ASSERT(node->getOp() == EOpIndexIndirect);
TIntermSequence *arguments = new TIntermSequence(); TIntermSequence arguments;
// Deep copy the child nodes so that two pointers to the same node don't end up in the tree. // Deep copy the child nodes so that two pointers to the same node don't end up in the tree.
arguments->push_back(node->getLeft()->deepCopy()); arguments.push_back(node->getLeft()->deepCopy());
arguments->push_back(CreateTempSymbolNode(index)); arguments.push_back(CreateTempSymbolNode(index));
arguments->push_back(CreateTempSymbolNode(writtenValue)); arguments.push_back(CreateTempSymbolNode(writtenValue));
TIntermAggregate *indexedWriteCall = TIntermAggregate *indexedWriteCall =
TIntermAggregate::CreateFunctionCall(*indexedWriteFunction, arguments); TIntermAggregate::CreateFunctionCall(*indexedWriteFunction, &arguments);
indexedWriteCall->setLine(node->getLine()); indexedWriteCall->setLine(node->getLine());
return indexedWriteCall; return indexedWriteCall;
} }
......
...@@ -57,18 +57,18 @@ bool RemovePowTraverser::visitAggregate(Visit visit, TIntermAggregate *node) ...@@ -57,18 +57,18 @@ bool RemovePowTraverser::visitAggregate(Visit visit, TIntermAggregate *node)
TIntermTyped *x = node->getSequence()->at(0)->getAsTyped(); TIntermTyped *x = node->getSequence()->at(0)->getAsTyped();
TIntermTyped *y = node->getSequence()->at(1)->getAsTyped(); TIntermTyped *y = node->getSequence()->at(1)->getAsTyped();
TIntermSequence *logArgs = new TIntermSequence(); TIntermSequence logArgs;
logArgs->push_back(x); logArgs.push_back(x);
TIntermTyped *log = CreateBuiltInFunctionCallNode("log2", logArgs, *mSymbolTable, 100); TIntermTyped *log = CreateBuiltInFunctionCallNode("log2", &logArgs, *mSymbolTable, 100);
log->setLine(node->getLine()); log->setLine(node->getLine());
TOperator op = TIntermBinary::GetMulOpBasedOnOperands(y->getType(), log->getType()); TOperator op = TIntermBinary::GetMulOpBasedOnOperands(y->getType(), log->getType());
TIntermBinary *mul = new TIntermBinary(op, y, log); TIntermBinary *mul = new TIntermBinary(op, y, log);
mul->setLine(node->getLine()); mul->setLine(node->getLine());
TIntermSequence *expArgs = new TIntermSequence(); TIntermSequence expArgs;
expArgs->push_back(mul); expArgs.push_back(mul);
TIntermTyped *exp = CreateBuiltInFunctionCallNode("exp2", expArgs, *mSymbolTable, 100); TIntermTyped *exp = CreateBuiltInFunctionCallNode("exp2", &expArgs, *mSymbolTable, 100);
exp->setLine(node->getLine()); exp->setLine(node->getLine());
queueReplacement(exp, OriginalNode::IS_DROPPED); queueReplacement(exp, OriginalNode::IS_DROPPED);
......
...@@ -100,10 +100,10 @@ bool Traverser::visitAggregate(Visit visit, TIntermAggregate *node) ...@@ -100,10 +100,10 @@ bool Traverser::visitAggregate(Visit visit, TIntermAggregate *node)
// Create new node that represents the call of function texelFetch. // Create new node that represents the call of function texelFetch.
// Its argument list will be: texelFetch(sampler, Position+offset, lod). // Its argument list will be: texelFetch(sampler, Position+offset, lod).
TIntermSequence *texelFetchArguments = new TIntermSequence(); TIntermSequence texelFetchArguments;
// sampler // sampler
texelFetchArguments->push_back(sequence->at(0)); texelFetchArguments.push_back(sequence->at(0));
// Position // Position
TIntermTyped *texCoordNode = sequence->at(1)->getAsTyped(); TIntermTyped *texCoordNode = sequence->at(1)->getAsTyped();
...@@ -116,14 +116,14 @@ bool Traverser::visitAggregate(Visit visit, TIntermAggregate *node) ...@@ -116,14 +116,14 @@ bool Traverser::visitAggregate(Visit visit, TIntermAggregate *node)
{ {
// For 2DArray samplers, Position is ivec3 and offset is ivec2; // For 2DArray samplers, Position is ivec3 and offset is ivec2;
// So offset must be converted into an ivec3 before being added to Position. // So offset must be converted into an ivec3 before being added to Position.
TIntermSequence *constructOffsetIvecArguments = new TIntermSequence(); TIntermSequence constructOffsetIvecArguments;
constructOffsetIvecArguments->push_back(sequence->at(3)->getAsTyped()); constructOffsetIvecArguments.push_back(sequence->at(3)->getAsTyped());
TIntermTyped *zeroNode = CreateZeroNode(TType(EbtInt)); TIntermTyped *zeroNode = CreateZeroNode(TType(EbtInt));
constructOffsetIvecArguments->push_back(zeroNode); constructOffsetIvecArguments.push_back(zeroNode);
offsetNode = TIntermAggregate::CreateConstructor(texCoordNode->getType(), offsetNode = TIntermAggregate::CreateConstructor(texCoordNode->getType(),
constructOffsetIvecArguments); &constructOffsetIvecArguments);
offsetNode->setLine(texCoordNode->getLine()); offsetNode->setLine(texCoordNode->getLine());
} }
else else
...@@ -134,14 +134,14 @@ bool Traverser::visitAggregate(Visit visit, TIntermAggregate *node) ...@@ -134,14 +134,14 @@ bool Traverser::visitAggregate(Visit visit, TIntermAggregate *node)
// Position+offset // Position+offset
TIntermBinary *add = new TIntermBinary(EOpAdd, texCoordNode, offsetNode); TIntermBinary *add = new TIntermBinary(EOpAdd, texCoordNode, offsetNode);
add->setLine(texCoordNode->getLine()); add->setLine(texCoordNode->getLine());
texelFetchArguments->push_back(add); texelFetchArguments.push_back(add);
// lod // lod
texelFetchArguments->push_back(sequence->at(2)); texelFetchArguments.push_back(sequence->at(2));
ASSERT(texelFetchArguments->size() == 3u); ASSERT(texelFetchArguments.size() == 3u);
TIntermTyped *texelFetchNode = CreateBuiltInFunctionCallNode("texelFetch", texelFetchArguments, TIntermTyped *texelFetchNode = CreateBuiltInFunctionCallNode("texelFetch", &texelFetchArguments,
*symbolTable, shaderVersion); *symbolTable, shaderVersion);
texelFetchNode->setLine(node->getLine()); texelFetchNode->setLine(node->getLine());
......
...@@ -59,17 +59,17 @@ TIntermAggregate *ArrayReturnValueToOutParameterTraverser::createReplacementCall ...@@ -59,17 +59,17 @@ TIntermAggregate *ArrayReturnValueToOutParameterTraverser::createReplacementCall
TIntermAggregate *originalCall, TIntermAggregate *originalCall,
TIntermTyped *returnValueTarget) TIntermTyped *returnValueTarget)
{ {
TIntermSequence *replacementArguments = new TIntermSequence(); TIntermSequence replacementArguments;
TIntermSequence *originalArguments = originalCall->getSequence(); TIntermSequence *originalArguments = originalCall->getSequence();
for (auto &arg : *originalArguments) for (auto &arg : *originalArguments)
{ {
replacementArguments->push_back(arg); replacementArguments.push_back(arg);
} }
replacementArguments->push_back(returnValueTarget); replacementArguments.push_back(returnValueTarget);
ASSERT(originalCall->getFunction()); ASSERT(originalCall->getFunction());
const TSymbolUniqueId &originalId = originalCall->getFunction()->uniqueId(); const TSymbolUniqueId &originalId = originalCall->getFunction()->uniqueId();
TIntermAggregate *replacementCall = TIntermAggregate::CreateFunctionCall( TIntermAggregate *replacementCall = TIntermAggregate::CreateFunctionCall(
*mChangedFunctions[originalId.get()].func, replacementArguments); *mChangedFunctions[originalId.get()].func, &replacementArguments);
replacementCall->setLine(originalCall->getLine()); replacementCall->setLine(originalCall->getLine());
return replacementCall; return replacementCall;
} }
......
...@@ -38,12 +38,12 @@ bool ClampFragDepth(TCompiler *compiler, TIntermBlock *root, TSymbolTable *symbo ...@@ -38,12 +38,12 @@ bool ClampFragDepth(TCompiler *compiler, TIntermBlock *root, TSymbolTable *symbo
new TIntermConstantUnion(maxFragDepthConstant, TType(EbtFloat, EbpHigh, EvqConst)); new TIntermConstantUnion(maxFragDepthConstant, TType(EbtFloat, EbpHigh, EvqConst));
// clamp(gl_FragDepth, 0.0, 1.0) // clamp(gl_FragDepth, 0.0, 1.0)
TIntermSequence *clampArguments = new TIntermSequence(); TIntermSequence clampArguments;
clampArguments->push_back(fragDepthNode->deepCopy()); clampArguments.push_back(fragDepthNode->deepCopy());
clampArguments->push_back(minFragDepthNode); clampArguments.push_back(minFragDepthNode);
clampArguments->push_back(maxFragDepthNode); clampArguments.push_back(maxFragDepthNode);
TIntermTyped *clampedFragDepth = TIntermTyped *clampedFragDepth =
CreateBuiltInFunctionCallNode("clamp", clampArguments, *symbolTable, 100); CreateBuiltInFunctionCallNode("clamp", &clampArguments, *symbolTable, 100);
// gl_FragDepth = clamp(gl_FragDepth, 0.0, 1.0) // gl_FragDepth = clamp(gl_FragDepth, 0.0, 1.0)
TIntermBinary *assignFragDepth = new TIntermBinary(EOpAssign, fragDepthNode, clampedFragDepth); TIntermBinary *assignFragDepth = new TIntermBinary(EOpAssign, fragDepthNode, clampedFragDepth);
......
...@@ -116,13 +116,14 @@ TIntermSymbol *CopyToTempVariable(TSymbolTable *symbolTable, ...@@ -116,13 +116,14 @@ TIntermSymbol *CopyToTempVariable(TSymbolTable *symbolTable,
TIntermAggregate *CreateStructCopyCall(const TFunction *copyFunc, TIntermTyped *expression) TIntermAggregate *CreateStructCopyCall(const TFunction *copyFunc, TIntermTyped *expression)
{ {
return TIntermAggregate::CreateFunctionCall(*copyFunc, new TIntermSequence({expression})); TIntermSequence args = {expression};
return TIntermAggregate::CreateFunctionCall(*copyFunc, &args);
} }
TIntermTyped *CreateTransposeCall(TSymbolTable *symbolTable, TIntermTyped *expression) TIntermTyped *CreateTransposeCall(TSymbolTable *symbolTable, TIntermTyped *expression)
{ {
return CreateBuiltInFunctionCallNode("transpose", new TIntermSequence({expression}), TIntermSequence args = {expression};
*symbolTable, 300); return CreateBuiltInFunctionCallNode("transpose", &args, *symbolTable, 300);
} }
TOperator GetIndex(TSymbolTable *symbolTable, TOperator GetIndex(TSymbolTable *symbolTable,
......
...@@ -68,8 +68,8 @@ class Traverser : public TIntermTraverser ...@@ -68,8 +68,8 @@ class Traverser : public TIntermTraverser
TIntermDeclaration *structDeclaration = new TIntermDeclaration; TIntermDeclaration *structDeclaration = new TIntermDeclaration;
structDeclaration->appendDeclarator(structDeclarator); structDeclaration->appendDeclarator(structDeclarator);
TIntermSequence *newSequence = new TIntermSequence; TIntermSequence newSequence;
newSequence->push_back(structDeclaration); newSequence.push_back(structDeclaration);
// uniform <structName> <structUniformName>; // uniform <structName> <structUniformName>;
TIntermSymbol *asSymbol = declarator->getAsSymbolNode(); TIntermSymbol *asSymbol = declarator->getAsSymbolNode();
...@@ -84,10 +84,11 @@ class Traverser : public TIntermTraverser ...@@ -84,10 +84,11 @@ class Traverser : public TIntermTraverser
TIntermSymbol *newSymbol = new TIntermSymbol(newVar); TIntermSymbol *newSymbol = new TIntermSymbol(newVar);
namedDecl->appendDeclarator(newSymbol); namedDecl->appendDeclarator(newSymbol);
newSequence->push_back(namedDecl); newSequence.push_back(namedDecl);
} }
mMultiReplacements.emplace_back(getParentNode()->getAsBlock(), decl, *newSequence); mMultiReplacements.emplace_back(getParentNode()->getAsBlock(), decl,
std::move(newSequence));
} }
}; };
} // anonymous namespace } // anonymous namespace
......
...@@ -245,8 +245,9 @@ class RewriteAtomicCountersTraverser : public TIntermTraverser ...@@ -245,8 +245,9 @@ class RewriteAtomicCountersTraverser : public TIntermTraverser
// |memoryBarrierBuffer|. // |memoryBarrierBuffer|.
if (node->getFunction()->name() == "memoryBarrierAtomicCounter") if (node->getFunction()->name() == "memoryBarrierAtomicCounter")
{ {
TIntermSequence emptySequence;
TIntermTyped *substituteCall = CreateBuiltInFunctionCallNode( TIntermTyped *substituteCall = CreateBuiltInFunctionCallNode(
"memoryBarrierBuffer", new TIntermSequence, *mSymbolTable, 310); "memoryBarrierBuffer", &emptySequence, *mSymbolTable, 310);
queueReplacement(substituteCall, OriginalNode::IS_DROPPED); queueReplacement(substituteCall, OriginalNode::IS_DROPPED);
return true; return true;
} }
...@@ -284,13 +285,13 @@ class RewriteAtomicCountersTraverser : public TIntermTraverser ...@@ -284,13 +285,13 @@ class RewriteAtomicCountersTraverser : public TIntermTraverser
TIntermTyped *param = (*node->getSequence())[0]->getAsTyped(); TIntermTyped *param = (*node->getSequence())[0]->getAsTyped();
TIntermSequence *substituteArguments = new TIntermSequence; TIntermSequence substituteArguments;
substituteArguments->push_back( substituteArguments.push_back(
CreateAtomicCounterRef(param, mAtomicCounters, mAcbBufferOffsets)); CreateAtomicCounterRef(param, mAtomicCounters, mAcbBufferOffsets));
substituteArguments->push_back(CreateUIntNode(valueChange)); substituteArguments.push_back(CreateUIntNode(valueChange));
TIntermTyped *substituteCall = CreateBuiltInFunctionCallNode( TIntermTyped *substituteCall = CreateBuiltInFunctionCallNode(
kAtomicAddFunction, substituteArguments, *mSymbolTable, 310); kAtomicAddFunction, &substituteArguments, *mSymbolTable, 310);
// Note that atomicCounterDecrement returns the *new* value instead of the prior value, // Note that atomicCounterDecrement returns the *new* value instead of the prior value,
// unlike atomicAdd. So we need to do a -1 on the result as well. // unlike atomicAdd. So we need to do a -1 on the result as well.
......
...@@ -150,9 +150,9 @@ bool Traverser::visitUnaryWithRotation(Visit visit, TIntermUnary *node) ...@@ -150,9 +150,9 @@ bool Traverser::visitUnaryWithRotation(Visit visit, TIntermUnary *node)
TIntermBinary *rotatedFlipXY = new TIntermBinary(EOpMul, flipXY, halfRotationMat); TIntermBinary *rotatedFlipXY = new TIntermBinary(EOpMul, flipXY, halfRotationMat);
const TType *vec2Type = StaticType::GetBasic<EbtFloat, 2>(); const TType *vec2Type = StaticType::GetBasic<EbtFloat, 2>();
TIntermSymbol *tmpRotFlipXY = new TIntermSymbol(CreateTempVariable(mSymbolTable, vec2Type)); TIntermSymbol *tmpRotFlipXY = new TIntermSymbol(CreateTempVariable(mSymbolTable, vec2Type));
TIntermSequence *tmpDecl = new TIntermSequence; TIntermSequence tmpDecl;
tmpDecl->push_back(CreateTempInitDeclarationNode(&tmpRotFlipXY->variable(), rotatedFlipXY)); tmpDecl.push_back(CreateTempInitDeclarationNode(&tmpRotFlipXY->variable(), rotatedFlipXY));
insertStatementsInParentBlock(*tmpDecl); insertStatementsInParentBlock(tmpDecl);
// Get the .x and .y swizzles to use as multipliers // Get the .x and .y swizzles to use as multipliers
TVector<int> swizzleOffsetX = {0}; TVector<int> swizzleOffsetX = {0};
......
...@@ -94,9 +94,9 @@ bool Traverser::visitAggregate(Visit visit, TIntermAggregate *node) ...@@ -94,9 +94,9 @@ bool Traverser::visitAggregate(Visit visit, TIntermAggregate *node)
const TIntermSequence *sequence = node->getSequence(); const TIntermSequence *sequence = node->getSequence();
ASSERT(sequence->size() == 2u); ASSERT(sequence->size() == 2u);
TIntermSequence *interpolateAtOffsetArguments = new TIntermSequence(); TIntermSequence interpolateAtOffsetArguments;
// interpolant node // interpolant node
interpolateAtOffsetArguments->push_back(sequence->at(0)); interpolateAtOffsetArguments.push_back(sequence->at(0));
// offset // offset
TIntermTyped *offsetNode = sequence->at(1)->getAsTyped(); TIntermTyped *offsetNode = sequence->at(1)->getAsTyped();
ASSERT(offsetNode->getType() == *(StaticType::GetBasic<EbtFloat, 2>())); ASSERT(offsetNode->getType() == *(StaticType::GetBasic<EbtFloat, 2>()));
...@@ -124,10 +124,10 @@ bool Traverser::visitAggregate(Visit visit, TIntermAggregate *node) ...@@ -124,10 +124,10 @@ bool Traverser::visitAggregate(Visit visit, TIntermAggregate *node)
TIntermBinary *correctedOffset = new TIntermBinary(EOpMul, offsetNode, rotatedXY); TIntermBinary *correctedOffset = new TIntermBinary(EOpMul, offsetNode, rotatedXY);
correctedOffset->setLine(offsetNode->getLine()); correctedOffset->setLine(offsetNode->getLine());
interpolateAtOffsetArguments->push_back(correctedOffset); interpolateAtOffsetArguments.push_back(correctedOffset);
TIntermTyped *interpolateAtOffsetNode = CreateBuiltInFunctionCallNode( TIntermTyped *interpolateAtOffsetNode = CreateBuiltInFunctionCallNode(
"interpolateAtOffset", interpolateAtOffsetArguments, *symbolTable, shaderVersion); "interpolateAtOffset", &interpolateAtOffsetArguments, *symbolTable, shaderVersion);
interpolateAtOffsetNode->setLine(node->getLine()); interpolateAtOffsetNode->setLine(node->getLine());
// Replace the old node by this new node. // Replace the old node by this new node.
......
...@@ -354,7 +354,7 @@ class RewriteStructSamplersTraverser final : public TIntermTraverser ...@@ -354,7 +354,7 @@ class RewriteStructSamplersTraverser final : public TIntermTraverser
return false; return false;
} }
TIntermSequence *newSequence = new TIntermSequence; TIntermSequence newSequence;
if (type.isStructSpecifier()) if (type.isStructSpecifier())
{ {
...@@ -363,7 +363,7 @@ class RewriteStructSamplersTraverser final : public TIntermTraverser ...@@ -363,7 +363,7 @@ class RewriteStructSamplersTraverser final : public TIntermTraverser
const TStructure *structure = type.getStruct(); const TStructure *structure = type.getStruct();
ASSERT(structure && mStructureMap.find(structure) == mStructureMap.end()); ASSERT(structure && mStructureMap.find(structure) == mStructureMap.end());
stripStructSpecifierSamplers(structure, newSequence); stripStructSpecifierSamplers(structure, &newSequence);
} }
else else
{ {
...@@ -373,7 +373,7 @@ class RewriteStructSamplersTraverser final : public TIntermTraverser ...@@ -373,7 +373,7 @@ class RewriteStructSamplersTraverser final : public TIntermTraverser
// version first. // version first.
if (mStructureMap.find(structure) == mStructureMap.end()) if (mStructureMap.find(structure) == mStructureMap.end())
{ {
stripStructSpecifierSamplers(structure, newSequence); stripStructSpecifierSamplers(structure, &newSequence);
} }
// Then, extract the samplers from the struct and create global-scope variables instead. // Then, extract the samplers from the struct and create global-scope variables instead.
...@@ -382,10 +382,11 @@ class RewriteStructSamplersTraverser final : public TIntermTraverser ...@@ -382,10 +382,11 @@ class RewriteStructSamplersTraverser final : public TIntermTraverser
const TVariable &variable = asSymbol->variable(); const TVariable &variable = asSymbol->variable();
ASSERT(variable.symbolType() != SymbolType::Empty); ASSERT(variable.symbolType() != SymbolType::Empty);
extractStructSamplerUniforms(variable, structure, newSequence); extractStructSamplerUniforms(variable, structure, &newSequence);
} }
mMultiReplacements.emplace_back(getParentNode()->getAsBlock(), decl, *newSequence); mMultiReplacements.emplace_back(getParentNode()->getAsBlock(), decl,
std::move(newSequence));
return false; return false;
} }
......
...@@ -86,7 +86,7 @@ TIntermTyped *CreateZeroNode(const TType &type) ...@@ -86,7 +86,7 @@ TIntermTyped *CreateZeroNode(const TType &type)
return node; return node;
} }
TIntermSequence *arguments = new TIntermSequence(); TIntermSequence arguments;
if (type.isArray()) if (type.isArray())
{ {
...@@ -96,7 +96,7 @@ TIntermTyped *CreateZeroNode(const TType &type) ...@@ -96,7 +96,7 @@ TIntermTyped *CreateZeroNode(const TType &type)
size_t arraySize = type.getOutermostArraySize(); size_t arraySize = type.getOutermostArraySize();
for (size_t i = 0; i < arraySize; ++i) for (size_t i = 0; i < arraySize; ++i)
{ {
arguments->push_back(CreateZeroNode(elementType)); arguments.push_back(CreateZeroNode(elementType));
} }
} }
else else
...@@ -106,11 +106,11 @@ TIntermTyped *CreateZeroNode(const TType &type) ...@@ -106,11 +106,11 @@ TIntermTyped *CreateZeroNode(const TType &type)
const TStructure *structure = type.getStruct(); const TStructure *structure = type.getStruct();
for (const auto &field : structure->fields()) for (const auto &field : structure->fields())
{ {
arguments->push_back(CreateZeroNode(*field->type())); arguments.push_back(CreateZeroNode(*field->type()));
} }
} }
return TIntermAggregate::CreateConstructor(constType, arguments); return TIntermAggregate::CreateConstructor(constType, &arguments);
} }
TIntermConstantUnion *CreateFloatNode(float value) TIntermConstantUnion *CreateFloatNode(float value)
...@@ -253,11 +253,11 @@ const TVariable *DeclareInterfaceBlock(TIntermBlock *root, ...@@ -253,11 +253,11 @@ const TVariable *DeclareInterfaceBlock(TIntermBlock *root,
interfaceBlockDecl->appendDeclarator(interfaceBlockDeclarator); interfaceBlockDecl->appendDeclarator(interfaceBlockDeclarator);
// Insert the declarations before the first function. // Insert the declarations before the first function.
TIntermSequence *insertSequence = new TIntermSequence; TIntermSequence insertSequence;
insertSequence->push_back(interfaceBlockDecl); insertSequence.push_back(interfaceBlockDecl);
size_t firstFunctionIndex = FindFirstFunctionDefinitionIndex(root); size_t firstFunctionIndex = FindFirstFunctionDefinitionIndex(root);
root->insertChildNodes(firstFunctionIndex, *insertSequence); root->insertChildNodes(firstFunctionIndex, insertSequence);
return interfaceBlockVar; return interfaceBlockVar;
} }
......
...@@ -89,8 +89,8 @@ void WrapMainAndAppend(TIntermBlock *root, ...@@ -89,8 +89,8 @@ void WrapMainAndAppend(TIntermBlock *root,
// codeToRun // codeToRun
// } // }
TIntermBlock *newMainBody = new TIntermBlock(); TIntermBlock *newMainBody = new TIntermBlock();
TIntermAggregate *oldMainCall = TIntermSequence emptySequence;
TIntermAggregate::CreateFunctionCall(*oldMain, new TIntermSequence()); TIntermAggregate *oldMainCall = TIntermAggregate::CreateFunctionCall(*oldMain, &emptySequence);
newMainBody->appendStatement(oldMainCall); newMainBody->appendStatement(oldMainCall);
newMainBody->appendStatement(codeToRun); newMainBody->appendStatement(codeToRun);
......
...@@ -61,14 +61,14 @@ constexpr Mat2x2EnumMap kHalfRenderAreaRotationMatrices = { ...@@ -61,14 +61,14 @@ constexpr Mat2x2EnumMap kHalfRenderAreaRotationMatrices = {
// Returns mat2(m0, m1, m2, m3) // Returns mat2(m0, m1, m2, m3)
TIntermAggregate *CreateMat2x2(const Mat2x2EnumMap &matrix, vk::SurfaceRotation rotation) TIntermAggregate *CreateMat2x2(const Mat2x2EnumMap &matrix, vk::SurfaceRotation rotation)
{ {
auto mat2Type = new TType(EbtFloat, 2, 2); auto mat2Type = new TType(EbtFloat, 2, 2);
TIntermSequence *mat2Args = new TIntermSequence(); TIntermSequence mat2Args;
mat2Args->push_back(CreateFloatNode(matrix[rotation][0])); mat2Args.push_back(CreateFloatNode(matrix[rotation][0]));
mat2Args->push_back(CreateFloatNode(matrix[rotation][1])); mat2Args.push_back(CreateFloatNode(matrix[rotation][1]));
mat2Args->push_back(CreateFloatNode(matrix[rotation][2])); mat2Args.push_back(CreateFloatNode(matrix[rotation][2]));
mat2Args->push_back(CreateFloatNode(matrix[rotation][3])); mat2Args.push_back(CreateFloatNode(matrix[rotation][3]));
TIntermAggregate *constVarConstructor = TIntermAggregate *constVarConstructor =
TIntermAggregate::CreateConstructor(*mat2Type, mat2Args); TIntermAggregate::CreateConstructor(*mat2Type, &mat2Args);
return constVarConstructor; return constVarConstructor;
} }
...@@ -79,17 +79,16 @@ TIntermTyped *GenerateMat2x2ArrayWithIndex(const Mat2x2EnumMap &matrix, TIntermS ...@@ -79,17 +79,16 @@ TIntermTyped *GenerateMat2x2ArrayWithIndex(const Mat2x2EnumMap &matrix, TIntermS
TType *typeMat2Array = new TType(*mat2Type); TType *typeMat2Array = new TType(*mat2Type);
typeMat2Array->makeArray(static_cast<unsigned int>(vk::SurfaceRotation::EnumCount)); typeMat2Array->makeArray(static_cast<unsigned int>(vk::SurfaceRotation::EnumCount));
TIntermSequence *sequences; TIntermSequence sequences = {
sequences = CreateMat2x2(matrix, vk::SurfaceRotation::Identity),
new TIntermSequence({CreateMat2x2(matrix, vk::SurfaceRotation::Identity), CreateMat2x2(matrix, vk::SurfaceRotation::Rotated90Degrees),
CreateMat2x2(matrix, vk::SurfaceRotation::Rotated90Degrees), CreateMat2x2(matrix, vk::SurfaceRotation::Rotated180Degrees),
CreateMat2x2(matrix, vk::SurfaceRotation::Rotated180Degrees), CreateMat2x2(matrix, vk::SurfaceRotation::Rotated270Degrees),
CreateMat2x2(matrix, vk::SurfaceRotation::Rotated270Degrees), CreateMat2x2(matrix, vk::SurfaceRotation::FlippedIdentity),
CreateMat2x2(matrix, vk::SurfaceRotation::FlippedIdentity), CreateMat2x2(matrix, vk::SurfaceRotation::FlippedRotated90Degrees),
CreateMat2x2(matrix, vk::SurfaceRotation::FlippedRotated90Degrees), CreateMat2x2(matrix, vk::SurfaceRotation::FlippedRotated180Degrees),
CreateMat2x2(matrix, vk::SurfaceRotation::FlippedRotated180Degrees), CreateMat2x2(matrix, vk::SurfaceRotation::FlippedRotated270Degrees)};
CreateMat2x2(matrix, vk::SurfaceRotation::FlippedRotated270Degrees)}); TIntermTyped *array = TIntermAggregate::CreateConstructor(*typeMat2Array, &sequences);
TIntermTyped *array = TIntermAggregate::CreateConstructor(*typeMat2Array, sequences);
return new TIntermBinary(EOpIndexDirect, array, rotation); return new TIntermBinary(EOpIndexDirect, array, rotation);
} }
...@@ -119,12 +118,12 @@ constexpr Vec2 CalcFragRotationMultiplyFlipXY(vk::SurfaceRotation rotation) ...@@ -119,12 +118,12 @@ constexpr Vec2 CalcFragRotationMultiplyFlipXY(vk::SurfaceRotation rotation)
// Returns vec2(vec2Values.x, vec2Values.y*yscale) // Returns vec2(vec2Values.x, vec2Values.y*yscale)
TIntermAggregate *CreateVec2(Vec2EnumMap vec2Values, float yscale, vk::SurfaceRotation rotation) TIntermAggregate *CreateVec2(Vec2EnumMap vec2Values, float yscale, vk::SurfaceRotation rotation)
{ {
auto vec2Type = new TType(EbtFloat, 2); auto vec2Type = new TType(EbtFloat, 2);
TIntermSequence *vec2Args = new TIntermSequence(); TIntermSequence vec2Args;
vec2Args->push_back(CreateFloatNode(vec2Values[rotation][0])); vec2Args.push_back(CreateFloatNode(vec2Values[rotation][0]));
vec2Args->push_back(CreateFloatNode(vec2Values[rotation][1] * yscale)); vec2Args.push_back(CreateFloatNode(vec2Values[rotation][1] * yscale));
TIntermAggregate *constVarConstructor = TIntermAggregate *constVarConstructor =
TIntermAggregate::CreateConstructor(*vec2Type, vec2Args); TIntermAggregate::CreateConstructor(*vec2Type, &vec2Args);
return constVarConstructor; return constVarConstructor;
} }
...@@ -137,17 +136,16 @@ TIntermTyped *CreateVec2ArrayWithIndex(Vec2EnumMap vec2Values, ...@@ -137,17 +136,16 @@ TIntermTyped *CreateVec2ArrayWithIndex(Vec2EnumMap vec2Values,
TType *typeVec2Array = new TType(*vec2Type); TType *typeVec2Array = new TType(*vec2Type);
typeVec2Array->makeArray(static_cast<unsigned int>(vk::SurfaceRotation::EnumCount)); typeVec2Array->makeArray(static_cast<unsigned int>(vk::SurfaceRotation::EnumCount));
TIntermSequence *sequences; TIntermSequence sequences = {
sequences = new TIntermSequence( CreateVec2(vec2Values, yscale, vk::SurfaceRotation::Identity),
{CreateVec2(vec2Values, yscale, vk::SurfaceRotation::Identity), CreateVec2(vec2Values, yscale, vk::SurfaceRotation::Rotated90Degrees),
CreateVec2(vec2Values, yscale, vk::SurfaceRotation::Rotated90Degrees), CreateVec2(vec2Values, yscale, vk::SurfaceRotation::Rotated180Degrees),
CreateVec2(vec2Values, yscale, vk::SurfaceRotation::Rotated180Degrees), CreateVec2(vec2Values, yscale, vk::SurfaceRotation::Rotated270Degrees),
CreateVec2(vec2Values, yscale, vk::SurfaceRotation::Rotated270Degrees), CreateVec2(vec2Values, yscale, vk::SurfaceRotation::FlippedIdentity),
CreateVec2(vec2Values, yscale, vk::SurfaceRotation::FlippedIdentity), CreateVec2(vec2Values, yscale, vk::SurfaceRotation::FlippedRotated90Degrees),
CreateVec2(vec2Values, yscale, vk::SurfaceRotation::FlippedRotated90Degrees), CreateVec2(vec2Values, yscale, vk::SurfaceRotation::FlippedRotated180Degrees),
CreateVec2(vec2Values, yscale, vk::SurfaceRotation::FlippedRotated180Degrees), CreateVec2(vec2Values, yscale, vk::SurfaceRotation::FlippedRotated270Degrees)};
CreateVec2(vec2Values, yscale, vk::SurfaceRotation::FlippedRotated270Degrees)}); TIntermTyped *vec2Array = TIntermAggregate::CreateConstructor(*typeVec2Array, &sequences);
TIntermTyped *vec2Array = TIntermAggregate::CreateConstructor(*typeVec2Array, sequences);
return new TIntermBinary(EOpIndexDirect, vec2Array, rotation); return new TIntermBinary(EOpIndexDirect, vec2Array, rotation);
} }
...@@ -207,20 +205,19 @@ TIntermTyped *CreateFloatArrayWithRotationIndex(const Vec2EnumMap &valuesEnumMap ...@@ -207,20 +205,19 @@ TIntermTyped *CreateFloatArrayWithRotationIndex(const Vec2EnumMap &valuesEnumMap
TType *typeFloat8 = new TType(*floatType); TType *typeFloat8 = new TType(*floatType);
typeFloat8->makeArray(static_cast<unsigned int>(vk::SurfaceRotation::EnumCount)); typeFloat8->makeArray(static_cast<unsigned int>(vk::SurfaceRotation::EnumCount));
TIntermSequence *sequences; TIntermSequence sequences = {
sequences = new TIntermSequence( CreateFloatNode(valuesEnumMap[vk::SurfaceRotation::Identity][subscript] * scale),
{CreateFloatNode(valuesEnumMap[vk::SurfaceRotation::Identity][subscript] * scale), CreateFloatNode(valuesEnumMap[vk::SurfaceRotation::Rotated90Degrees][subscript] * scale),
CreateFloatNode(valuesEnumMap[vk::SurfaceRotation::Rotated90Degrees][subscript] * scale), CreateFloatNode(valuesEnumMap[vk::SurfaceRotation::Rotated180Degrees][subscript] * scale),
CreateFloatNode(valuesEnumMap[vk::SurfaceRotation::Rotated180Degrees][subscript] * scale), CreateFloatNode(valuesEnumMap[vk::SurfaceRotation::Rotated270Degrees][subscript] * scale),
CreateFloatNode(valuesEnumMap[vk::SurfaceRotation::Rotated270Degrees][subscript] * scale), CreateFloatNode(valuesEnumMap[vk::SurfaceRotation::FlippedIdentity][subscript] * scale),
CreateFloatNode(valuesEnumMap[vk::SurfaceRotation::FlippedIdentity][subscript] * scale), CreateFloatNode(valuesEnumMap[vk::SurfaceRotation::FlippedRotated90Degrees][subscript] *
CreateFloatNode(valuesEnumMap[vk::SurfaceRotation::FlippedRotated90Degrees][subscript] * scale),
scale), CreateFloatNode(valuesEnumMap[vk::SurfaceRotation::FlippedRotated180Degrees][subscript] *
CreateFloatNode(valuesEnumMap[vk::SurfaceRotation::FlippedRotated180Degrees][subscript] * scale),
scale), CreateFloatNode(valuesEnumMap[vk::SurfaceRotation::FlippedRotated270Degrees][subscript] *
CreateFloatNode(valuesEnumMap[vk::SurfaceRotation::FlippedRotated270Degrees][subscript] * scale)};
scale)}); TIntermTyped *array = TIntermAggregate::CreateConstructor(*typeFloat8, &sequences);
TIntermTyped *array = TIntermAggregate::CreateConstructor(*typeFloat8, sequences);
return new TIntermBinary(EOpIndexDirect, array, rotation); return new TIntermBinary(EOpIndexDirect, array, rotation);
} }
...@@ -450,12 +447,12 @@ TIntermBinary *SpecConst::getHalfRenderArea() ...@@ -450,12 +447,12 @@ TIntermBinary *SpecConst::getHalfRenderArea()
} }
// vec2 drawableSize(drawableWidth, drawableHeight) // vec2 drawableSize(drawableWidth, drawableHeight)
auto vec2Type = new TType(EbtFloat, 2); auto vec2Type = new TType(EbtFloat, 2);
TIntermSequence *widthHeightArgs = new TIntermSequence(); TIntermSequence widthHeightArgs;
widthHeightArgs->push_back(getDrawableWidth()); widthHeightArgs.push_back(getDrawableWidth());
widthHeightArgs->push_back(getDrawableHeight()); widthHeightArgs.push_back(getDrawableHeight());
TIntermAggregate *drawableSize = TIntermAggregate *drawableSize =
TIntermAggregate::CreateConstructor(*vec2Type, widthHeightArgs); TIntermAggregate::CreateConstructor(*vec2Type, &widthHeightArgs);
// drawableSize * 0.5f // drawableSize * 0.5f
TIntermBinary *halfRenderArea = TIntermBinary *halfRenderArea =
......
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