32 return selection->usesTernaryOperator();
49 mDeclaringVariables(
false),
50 mClampingStrategy(clampingStrategy),
51 mHashFunction(hashFunction),
53 mSymbolTable(symbolTable)
64 else if (visit ==
InVisit && inStr)
97 for (TIntermSequence::const_iterator iter = args.begin();
98 iter != args.end(); ++iter)
113 if (iter != args.end() - 1)
129 for (
size_t i = 0;
i < fields.size(); ++
i)
131 const TType* fieldType = fields[
i]->type();
134 if (
i != fields.size() - 1) out <<
", ";
141 bool writeType = size > 1;
143 for (
size_t i = 0;
i <
size; ++
i, ++pConstUnion)
145 switch (pConstUnion->
getType())
152 if (
i != size - 1) out <<
", ";
154 if (writeType) out <<
")";
178 bool visitChildren =
true;
180 switch (node->
getOp())
187 mDeclaringVariables =
false;
212 out <<
"[int(clamp(float(";
214 out <<
"[webgl_int_clamp(";
234 out <<
"), 0.0, float(" << maxSize <<
")))]";
236 out <<
", 0, " << maxSize <<
")]";
263 visitChildren =
false;
272 for (TIntermSequence::iterator sit = sequence.begin(); sit != sequence.end(); ++sit)
279 switch (data.getIConst())
281 case 0: out <<
"x";
break;
282 case 1: out <<
"y";
break;
283 case 2: out <<
"z";
break;
284 case 3: out <<
"w";
break;
288 visitChildren =
false;
319 return visitChildren;
327 switch (node->
getOp())
342 case 1: preString =
"bool(";
break;
343 case 2: preString =
"bvec2(";
break;
344 case 3: preString =
"bvec3(";
break;
345 case 4: preString =
"bvec4(";
break;
353 case 1: preString =
"float(";
break;
354 case 2: preString =
"vec2(";
break;
355 case 3: preString =
"vec3(";
break;
356 case 4: preString =
"vec4(";
break;
364 case 1: preString =
"int(";
break;
365 case 2: preString =
"ivec2(";
break;
366 case 3: preString =
"ivec3(";
break;
367 case 4: preString =
"ivec4(";
break;
372 case EOpRadians: preString =
"radians(";
break;
373 case EOpDegrees: preString =
"degrees(";
break;
374 case EOpSin: preString =
"sin(";
break;
375 case EOpCos: preString =
"cos(";
break;
376 case EOpTan: preString =
"tan(";
break;
377 case EOpAsin: preString =
"asin(";
break;
378 case EOpAcos: preString =
"acos(";
break;
379 case EOpAtan: preString =
"atan(";
break;
381 case EOpExp: preString =
"exp(";
break;
382 case EOpLog: preString =
"log(";
break;
383 case EOpExp2: preString =
"exp2(";
break;
384 case EOpLog2: preString =
"log2(";
break;
385 case EOpSqrt: preString =
"sqrt(";
break;
388 case EOpAbs: preString =
"abs(";
break;
389 case EOpSign: preString =
"sign(";
break;
390 case EOpFloor: preString =
"floor(";
break;
391 case EOpCeil: preString =
"ceil(";
break;
392 case EOpFract: preString =
"fract(";
break;
394 case EOpLength: preString =
"length(";
break;
397 case EOpDFdx: preString =
"dFdx(";
break;
398 case EOpDFdy: preString =
"dFdy(";
break;
399 case EOpFwidth: preString =
"fwidth(";
break;
401 case EOpAny: preString =
"any(";
break;
402 case EOpAll: preString =
"all(";
break;
453 bool visitChildren =
true;
456 bool delayedWrite =
false;
457 switch (node->
getOp())
461 if (
depth > 0) out <<
"{\n";
465 for (TIntermSequence::const_iterator iter = sequence.begin();
466 iter != sequence.end(); ++iter)
472 if (isSingleStatement(node))
478 if (
depth > 0) out <<
"}\n";
479 visitChildren =
false;
492 visitChildren =
false;
506 ASSERT((sequence.size() == 1) || (sequence.size() == 2));
507 TIntermSequence::const_iterator seqIter = sequence.begin();
517 (*seqIter)->getAsAggregate() :
NULL;
522 visitChildren =
false;
546 visitChildren =
false;
557 mDeclaringVariables =
true;
562 mDeclaringVariables =
true;
566 mDeclaringVariables =
false;
602 case EOpLessThan: preString =
"lessThan("; delayedWrite =
true;
break;
603 case EOpGreaterThan: preString =
"greaterThan("; delayedWrite =
true;
break;
604 case EOpLessThanEqual: preString =
"lessThanEqual("; delayedWrite =
true;
break;
606 case EOpVectorEqual: preString =
"equal("; delayedWrite =
true;
break;
610 case EOpMod: preString =
"mod("; delayedWrite =
true;
break;
611 case EOpPow: preString =
"pow("; delayedWrite =
true;
break;
612 case EOpAtan: preString =
"atan("; delayedWrite =
true;
break;
613 case EOpMin: preString =
"min("; delayedWrite =
true;
break;
614 case EOpMax: preString =
"max("; delayedWrite =
true;
break;
615 case EOpClamp: preString =
"clamp("; delayedWrite =
true;
break;
616 case EOpMix: preString =
"mix("; delayedWrite =
true;
break;
617 case EOpStep: preString =
"step("; delayedWrite =
true;
break;
618 case EOpSmoothStep: preString =
"smoothstep("; delayedWrite =
true;
break;
620 case EOpDistance: preString =
"distance("; delayedWrite =
true;
break;
621 case EOpDot: preString =
"dot("; delayedWrite =
true;
break;
622 case EOpCross: preString =
"cross("; delayedWrite =
true;
break;
623 case EOpFaceForward: preString =
"faceforward("; delayedWrite =
true;
break;
624 case EOpReflect: preString =
"reflect("; delayedWrite =
true;
break;
625 case EOpRefract: preString =
"refract("; delayedWrite =
true;
break;
626 case EOpMul: preString =
"matrixCompMult("; delayedWrite =
true;
break;
634 return visitChildren;
679 mLoopUnroll.
Push(indexInfo);
728 if (isSingleStatement(node))
750 case EbtInt: out <<
"ivec";
break;
751 case EbtBool: out <<
"bvec";
break;
768 if (mHashFunction ==
NULL || name.empty())
770 NameMap::const_iterator it = mNameMap.find(name.c_str());
771 if (it != mNameMap.end())
772 return it->second.c_str();
774 mNameMap[name.c_str()] = hashedName.c_str();
793 bool TOutputGLSLBase::structDeclared(
const TStructure* structure)
const
795 return mDeclaredStructs.find(structure->
name()) != mDeclaredStructs.end();
798 void TOutputGLSLBase::declareStruct(
const TStructure* structure)
802 out <<
"struct " <<
hashName(structure->
name()) <<
"{\n";
804 for (
size_t i = 0;
i < fields.size(); ++
i)
806 const TField* field = fields[
i];
816 mDeclaredStructs.insert(structure->
name());
TInfoSinkBase & objSink()
void writeVariableType(const TType &type)
TIntermSequence & getSequence()
TIntermNode * getTrueBlock() const
TIntermTyped * getCondition()
GLint GLenum GLsizei GLsizei GLsizei GLint GLenum GLenum type
TOutputGLSLBase(TInfoSinkBase &objSink, ShArrayIndexClampingStrategy clampingStrategy, ShHashFunction64 hashFunction, NameMap &nameMap, TSymbolTable &symbolTable)
TIntermTyped * getLeft() const
virtual TIntermAggregate * getAsAggregate()
virtual TIntermSymbol * getAsSymbolNode()
khronos_uint64_t(* ShHashFunction64)(const char *, size_t)
const TString & name() const
TString hashVariableName(const TString &name)
TIntermNode * getFalseBlock() const
TIntermTyped * getRight() const
const char * getQualifierString() const
std::map< TPersistString, TPersistString > NameMap
virtual bool visitSelection(Visit visit, TIntermSelection *node)
TBasicType getBasicType() const
virtual TIntermConstantUnion * getAsConstantUnion()
TBasicType getBasicType() const
int getNominalSize() const
EGLImageKHR EGLint * name
const TString & name() const
TString hashFunctionName(const TString &mangled_name)
virtual bool visitAggregate(Visit visit, TIntermAggregate *node)
ShArrayIndexClampingStrategy
bool getUseEmulatedFunction()
TString getTypeName(const TType &type)
void FillLoopIndexInfo(TIntermLoop *node, TLoopIndexInfo &info)
virtual TIntermConstantUnion * getAsConstantUnion()
TPrecision getPrecision() const
static TString GetEmulatedFunctionName(const TString &name)
virtual void visitConstantUnion(TIntermConstantUnion *node)
TSymbol * findBuiltIn(const TString &name)
void visitCodeBlock(TIntermNode *node)
#define ASSERT(expression)
TQualifier getQualifier() const
int GetLoopIndexValue(TIntermSymbol *symbol)
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
bool getUseEmulatedFunction()
virtual void traverse(TIntermTraverser *)=0
TIntermNode * getCondition() const
const TType & getType() const
static TString hash(const TString &name, ShHashFunction64 hashFunction)
ConstantUnion * getUnionArrayPointer() const
TBasicType getType() const
const TString & getName() const
TString hashName(const TString &name)
GLint GLenum GLsizei GLsizei GLsizei depth
static TString arrayBrackets(int index)
TIntermTyped * getOperand()
virtual void visitSymbol(TIntermSymbol *node)
void writeFunctionParameters(const TIntermSequence &args)
virtual bool visitLoop(Visit visit, TIntermLoop *node)
virtual TIntermLoop * getAsLoopNode()
virtual void traverse(TIntermTraverser *)
int getIConst(int index) const
std::basic_string< char, std::char_traits< char >, TStringAllocator > TString
bool usesTernaryOperator() const
static TString unmangleName(const TString &mangledName)
virtual bool visitBranch(Visit visit, TIntermBranch *node)
void Push(TLoopIndexInfo &info)
void writeTriplet(Visit visit, const char *preStr, const char *inStr, const char *postStr)
virtual bool visitBinary(Visit visit, TIntermBinary *node)
TIntermTyped * getExpression()
virtual bool writeVariablePrecision(TPrecision precision)=0
size_t getObjectSize() const
const char * getBasicString() const
const TFieldList & fields() const
TStructure * getStruct() const
const TString & getSymbol() const
const char * c_str() const
bool SatisfiesLoopCondition()
int getNominalSize() const
const ConstantUnion * writeConstantUnion(const TType &type, const ConstantUnion *pConstUnion)
bool NeedsToReplaceSymbolWithValue(TIntermSymbol *symbol)
virtual TIntermSelection * getAsSelectionNode()
virtual TIntermAggregate * getAsAggregate()
virtual bool visitUnary(Visit visit, TIntermUnary *node)
TLoopType getType() const