Commit ebeeece6 by John Kessenich

Add uint type (big change). For both int/uint, add the operators >>, <<, &, |,…

Add uint type (big change). For both int/uint, add the operators >>, <<, &, |, and ^. Also added unsigned literals and uint precision support. Also fixed how int/uint literal underflow/overflow is handled. git-svn-id: https://cvs.khronos.org/svn/repos/ogl/trunk/ecosystem/public/sdk/tools/glslang@21054 e7fa87d3-cd2b-0410-9028-fcbf551c1848
parent ae722a62
...@@ -11,6 +11,10 @@ lowp vec2 foo(mediump vec3 mv3) ...@@ -11,6 +11,10 @@ lowp vec2 foo(mediump vec3 mv3)
int global_medium; int global_medium;
precision highp int; precision highp int;
precision highp ivec2; // ERROR
precision mediump int[2]; // ERROR
precision lowp uint; // ERROR
precision mediump vec4; // ERROR
int global_high; int global_high;
......
...@@ -3,22 +3,22 @@ ...@@ -3,22 +3,22 @@
#extension GL_3DL_array_objects : enable #extension GL_3DL_array_objects : enable
int a = 0xffffffff; // 32 bits, a gets the value -1 int a = 0xffffffff; // 32 bits, a gets the value -1
//int b = 0xffffffffU; // ERROR: can't convert uint to int int b = 0xffffffffU; // ERROR: can't convert uint to int
uint c = 0xffffffff; // 32 bits, c gets the value 0xFFFFFFFF uint c = 0xffffffff; // 32 bits, c gets the value 0xFFFFFFFF
//uint d = 0xffffffffU; // 32 bits, d gets the value 0xFFFFFFFF uint d = 0xffffffffU; // 32 bits, d gets the value 0xFFFFFFFF
int e = -1; // the literal is "1", then negation is performed, int e = -1; // the literal is "1", then negation is performed,
// and the resulting non-literal 32-bit signed // and the resulting non-literal 32-bit signed
// bit pattern of 0xFFFFFFFF is assigned, giving e // bit pattern of 0xFFFFFFFF is assigned, giving e
// the value of -1. // the value of -1.
//uint f = -1u; // the literal is "1u", then negation is performed, uint f = -1u; // the literal is "1u", then negation is performed,
// and the resulting non-literal 32-bit unsigned // and the resulting non-literal 32-bit unsigned
// bit pattern of 0xFFFFFFFF is assigned, giving f // bit pattern of 0xFFFFFFFF is assigned, giving f
// the value of 0xFFFFFFFF. // the value of 0xFFFFFFFF.
int g = 3000000000; // a signed decimal literal taking 32 bits, int g = 3000000000; // a signed decimal literal taking 32 bits,
// setting the sign bit, g gets -1294967296 // setting the sign bit, g gets -1294967296
int h = 0xA0000000; // okay, 32-bit signed hexadecimal int h = 0xA0000000; // okay, 32-bit signed hexadecimal
//int i = 5000000000; // ERROR: needs more than 32 bits int i = 5000000000; // ERROR: needs more than 32 bits
//int j = 0xFFFFFFFFF; // ERROR: needs more that 32 bits int j = 0xFFFFFFFFF; // ERROR: needs more that 32 bits
int k = 0x80000000; // k gets -2147483648 == 0x80000000 int k = 0x80000000; // k gets -2147483648 == 0x80000000
int l = 2147483648; // l gets -2147483648 (the literal set the sign bit) int l = 2147483648; // l gets -2147483648 (the literal set the sign bit)
......
...@@ -29,3 +29,4 @@ constErrors.frag ...@@ -29,3 +29,4 @@ constErrors.frag
constFold.frag constFold.frag
errors.frag errors.frag
forwardRef.frag forwardRef.frag
uint.frag
#version 300 es
in uvec2 t;
in float f;
in vec2 tc;
uniform uvec4 v;
uniform int i;
uniform bool b;
out uvec4 c;
uniform usampler2D usampler;
void main()
{
int count = 1;
uint u = t.y + 3u;
const uint cu1error = 0xFFFFFFFF; // ERROR
const uint cu1 = 0xFFFFFFFFU;
const uint cu2 = -1u; // 0xFFFFFFFF
const uint cu3 = 1U;
const uint cu4error = 1; // ERROR
const uint cu4 = 1u;
if (cu1 == cu2)
count *= 2; // done
if (cu3 == cu4)
count *= 3; // done
if (cu2 == cu3)
count *= 5; // not done
const uint cushiftediierror = 0xFFFFFFFF >> 10; // ERROR
const int cshiftedii = 0xFFFFFFFF >> 10;
const uint cushiftedui = 0xFFFFFFFFu >> 10;
const uint cushiftediuerror = 0xFFFFFFFF >> 10u; // ERROR
const int cshiftediu = 0xFFFFFFFF >> 10u;
const uint cushifteduu = 0xFFFFFFFFu >> 10u;
if (cshiftedii == cshiftediu)
count *= 7; // done
if (cushiftedui == cushifteduu)
count *= 11; // done
if (cshiftedii == int(cushiftedui))
count *= 13; // not done
uint shiftediierror = 0xFFFFFFFF >> 10; // ERROR
int shiftedii = 0xFFFFFFFF >> 10;
uint shiftedui = 0xFFFFFFFFu >> 10;
uint shiftediuerror = 0xFFFFFFFF >> 10u; // ERROR
int shiftediu = 0xFFFFFFFF >> 10u;
uint shifteduu = 0xFFFFFFFFu >> 10u;
if (shiftedii == shiftediu)
c = texture(usampler, tc);
if (shiftedui == shifteduu)
c = texture(usampler, tc + float(1u));
if (shiftedii == int(shiftedui))
c = texture(usampler, tc - vec2(2u));
if (t.x > 4u) {
float af = float(u);
bool ab = bool(u);
int ai = int(u);
c += uvec4(uint(af), uint(ab), uint(ai), count);
}
const uint cmask1 = 0x0A1u;
const uint cmask2 = 0xA10u;
const uint cmask3 = cmask1 << 4;
const uint cmask4 = 0xAB1u;
if (cmask3 == cmask2)
count *= 17; // done
if ((cmask3 & cmask1) != 0u)
count *= 19; // not done
if ((cmask1 | cmask3) == cmask4)
count *= 23; // done
if ((cmask1 ^ cmask4) == 0xA10u)
count *= 27; // done
uint mask1 = 0x0A1u;
uint mask2 = 0xA10u;
uint mask3 = mask1 << 4;
uint mask4 = 0xAB1u;
if (mask3 == mask2)
count *= 100;
if ((mask3 & mask1) != 0u)
count *= 101;
if ((mask1 | mask3) == mask4)
count *= 102;
if ((mask1 ^ mask4) == 0xA10u)
count *= 103;
c += uvec4(count);
}
...@@ -285,12 +285,23 @@ public: ...@@ -285,12 +285,23 @@ public:
constUnion operator>>(const constUnion& constant) const constUnion operator>>(const constUnion& constant) const
{ {
constUnion returnValue; constUnion returnValue;
assert(type == constant.type);
switch (type) { switch (type) {
case EbtInt:
switch (constant.type) {
case EbtInt: returnValue.setIConst(iConst >> constant.iConst); break; case EbtInt: returnValue.setIConst(iConst >> constant.iConst); break;
case EbtUint: returnValue.setIConst(iConst >> constant.uConst); break;
default: assert(false && "Default missing");
}
break;
case EbtUint:
switch (constant.type) {
case EbtInt: returnValue.setUConst(uConst >> constant.iConst); break;
case EbtUint: returnValue.setUConst(uConst >> constant.uConst); break; case EbtUint: returnValue.setUConst(uConst >> constant.uConst); break;
default: assert(false && "Default missing"); default: assert(false && "Default missing");
} }
break;
default: assert(false && "Default missing");
}
return returnValue; return returnValue;
} }
...@@ -298,12 +309,23 @@ public: ...@@ -298,12 +309,23 @@ public:
constUnion operator<<(const constUnion& constant) const constUnion operator<<(const constUnion& constant) const
{ {
constUnion returnValue; constUnion returnValue;
assert(type == constant.type);
switch (type) { switch (type) {
case EbtInt:
switch (constant.type) {
case EbtInt: returnValue.setIConst(iConst << constant.iConst); break; case EbtInt: returnValue.setIConst(iConst << constant.iConst); break;
case EbtUint: returnValue.setIConst(iConst << constant.uConst); break;
default: assert(false && "Default missing");
}
break;
case EbtUint:
switch (constant.type) {
case EbtInt: returnValue.setUConst(uConst << constant.iConst); break;
case EbtUint: returnValue.setUConst(uConst << constant.uConst); break; case EbtUint: returnValue.setUConst(uConst << constant.uConst); break;
default: assert(false && "Default missing"); default: assert(false && "Default missing");
} }
break;
default: assert(false && "Default missing");
}
return returnValue; return returnValue;
} }
......
...@@ -269,6 +269,11 @@ public: ...@@ -269,6 +269,11 @@ public:
matrixCols = c; matrixCols = c;
vectorSize = 0; vectorSize = 0;
} }
bool isScalar()
{
return matrixCols == 0 && vectorSize == 1 && arraySizes == 0 && userDef == 0;
}
}; };
typedef std::map<TTypeList*, TTypeList*> TStructureMap; typedef std::map<TTypeList*, TTypeList*> TStructureMap;
......
...@@ -75,11 +75,25 @@ enum TOperator { ...@@ -75,11 +75,25 @@ enum TOperator {
EOpPreDecrement, EOpPreDecrement,
EOpConvIntToBool, EOpConvIntToBool,
EOpConvUintToBool,
EOpConvFloatToBool, EOpConvFloatToBool,
EOpConvDoubleToBool,
EOpConvBoolToFloat, EOpConvBoolToFloat,
EOpConvIntToFloat, EOpConvIntToFloat,
EOpConvUintToFloat,
EOpConvDoubleToFloat,
EOpConvUintToInt,
EOpConvFloatToInt, EOpConvFloatToInt,
EOpConvBoolToInt, EOpConvBoolToInt,
EOpConvDoubleToInt,
EOpConvIntToUint,
EOpConvFloatToUint,
EOpConvBoolToUint,
EOpConvDoubleToUint,
EOpConvIntToDouble,
EOpConvUintToDouble,
EOpConvFloatToDouble,
EOpConvBoolToDouble,
// //
// binary operations // binary operations
...@@ -192,6 +206,7 @@ enum TOperator { ...@@ -192,6 +206,7 @@ enum TOperator {
EOpConstructGuardStart, EOpConstructGuardStart,
EOpConstructInt, EOpConstructInt,
EOpConstructUint,
EOpConstructBool, EOpConstructBool,
EOpConstructFloat, EOpConstructFloat,
EOpConstructDouble, EOpConstructDouble,
...@@ -207,6 +222,9 @@ enum TOperator { ...@@ -207,6 +222,9 @@ enum TOperator {
EOpConstructIVec2, EOpConstructIVec2,
EOpConstructIVec3, EOpConstructIVec3,
EOpConstructIVec4, EOpConstructIVec4,
EOpConstructUVec2,
EOpConstructUVec3,
EOpConstructUVec4,
EOpConstructMat2x2, EOpConstructMat2x2,
EOpConstructMat2x3, EOpConstructMat2x3,
EOpConstructMat2x4, EOpConstructMat2x4,
......
...@@ -120,11 +120,6 @@ TIntermTyped* TIntermConstantUnion::fold(TOperator op, TIntermTyped* constantNod ...@@ -120,11 +120,6 @@ TIntermTyped* TIntermConstantUnion::fold(TOperator op, TIntermTyped* constantNod
TIntermConstantUnion *node = constantNode->getAsConstantUnion(); TIntermConstantUnion *node = constantNode->getAsConstantUnion();
constUnion *rightUnionArray = node->getUnionArrayPointer(); constUnion *rightUnionArray = node->getUnionArrayPointer();
if (getType().getBasicType() != node->getBasicType()) {
infoSink.info.message(EPrefixInternalError, "Constant folding basic types don't match", getLine());
return 0;
}
if (constantNode->getType().getObjectSize() == 1 && objectSize > 1) { if (constantNode->getType().getObjectSize() == 1 && objectSize > 1) {
// for a case like float f = vec4(2,3,4,5) + 1.2; // for a case like float f = vec4(2,3,4,5) + 1.2;
rightUnionArray = new constUnion[objectSize]; rightUnionArray = new constUnion[objectSize];
...@@ -190,6 +185,13 @@ TIntermTyped* TIntermConstantUnion::fold(TOperator op, TIntermTyped* constantNod ...@@ -190,6 +185,13 @@ TIntermTyped* TIntermConstantUnion::fold(TOperator op, TIntermTyped* constantNod
} else } else
newConstArray[i].setIConst(unionArray[i].getIConst() / rightUnionArray[i].getIConst()); newConstArray[i].setIConst(unionArray[i].getIConst() / rightUnionArray[i].getIConst());
break; break;
case EbtUint:
if (rightUnionArray[i] == 0) {
newConstArray[i].setUConst(0xFFFFFFFF);
} else
newConstArray[i].setUConst(unionArray[i].getUConst() / rightUnionArray[i].getUConst());
break;
default: default:
infoSink.info.message(EPrefixInternalError, "Constant folding cannot be done for \"/\"", getLine()); infoSink.info.message(EPrefixInternalError, "Constant folding cannot be done for \"/\"", getLine());
return 0; return 0;
...@@ -388,6 +390,7 @@ TIntermTyped* TIntermConstantUnion::fold(TOperator op, const TType& returnType, ...@@ -388,6 +390,7 @@ TIntermTyped* TIntermConstantUnion::fold(TOperator op, const TType& returnType,
switch (getType().getBasicType()) { switch (getType().getBasicType()) {
case EbtFloat: newConstArray[i].setFConst(-unionArray[i].getFConst()); break; case EbtFloat: newConstArray[i].setFConst(-unionArray[i].getFConst()); break;
case EbtInt: newConstArray[i].setIConst(-unionArray[i].getIConst()); break; case EbtInt: newConstArray[i].setIConst(-unionArray[i].getIConst()); break;
case EbtUint: newConstArray[i].setUConst(static_cast<unsigned int>(-static_cast<int>(unionArray[i].getUConst()))); break;
default: default:
infoSink.info.message(EPrefixInternalError, "Unary operation not folded into constant", getLine()); infoSink.info.message(EPrefixInternalError, "Unary operation not folded into constant", getLine());
return 0; return 0;
......
...@@ -54,12 +54,14 @@ TParseContext::TParseContext(TSymbolTable& symt, TIntermediate& interm, int v, E ...@@ -54,12 +54,14 @@ TParseContext::TParseContext(TSymbolTable& symt, TIntermediate& interm, int v, E
switch (language) { switch (language) {
case EShLangVertex: case EShLangVertex:
defaultPrecision[EbtInt] = EpqHigh; defaultPrecision[EbtInt] = EpqHigh;
defaultPrecision[EbtUint] = EpqHigh;
defaultPrecision[EbtFloat] = EpqHigh; defaultPrecision[EbtFloat] = EpqHigh;
defaultPrecision[EbtSampler] = EpqLow; defaultPrecision[EbtSampler] = EpqLow;
// TODO: functionality: need default precisions per sampler type // TODO: functionality: need default precisions per sampler type
break; break;
case EShLangFragment: case EShLangFragment:
defaultPrecision[EbtInt] = EpqMedium; defaultPrecision[EbtInt] = EpqMedium;
defaultPrecision[EbtUint] = EpqMedium;
defaultPrecision[EbtSampler] = EpqLow; defaultPrecision[EbtSampler] = EpqLow;
// TODO: give error when using float in frag shader without default precision // TODO: give error when using float in frag shader without default precision
break; break;
...@@ -399,10 +401,10 @@ bool TParseContext::constErrorCheck(TIntermTyped* node) ...@@ -399,10 +401,10 @@ bool TParseContext::constErrorCheck(TIntermTyped* node)
// //
bool TParseContext::integerErrorCheck(TIntermTyped* node, const char* token) bool TParseContext::integerErrorCheck(TIntermTyped* node, const char* token)
{ {
if (node->getBasicType() == EbtInt && node->getVectorSize() == 1) if ((node->getBasicType() == EbtInt || node->getBasicType() == EbtUint) && node->getVectorSize() == 1 && ! node->isArray())
return false; return false;
error(node->getLine(), "integer expression required", token, ""); error(node->getLine(), "scalar integer expression required", token, "");
return true; return true;
} }
...@@ -728,14 +730,22 @@ bool TParseContext::mergeQualifiersErrorCheck(int line, TPublicType& left, const ...@@ -728,14 +730,22 @@ bool TParseContext::mergeQualifiersErrorCheck(int line, TPublicType& left, const
return bad; return bad;
} }
void TParseContext::setDefaultPrecision(int line, TBasicType type, TPrecisionQualifier qualifier) void TParseContext::setDefaultPrecision(int line, TPublicType& publicType, TPrecisionQualifier qualifier)
{ {
if (type == EbtSampler || type == EbtInt || type == EbtFloat) { TBasicType basicType = publicType.type;
defaultPrecision[type] = qualifier;
} else { if (basicType == EbtSampler || basicType == EbtInt || basicType == EbtFloat) {
error(line, "cannot apply precision statement to this type", TType::getBasicString(type), ""); if (publicType.isScalar()) {
recover(); defaultPrecision[basicType] = qualifier;
if (basicType == EbtInt)
defaultPrecision[EbtUint] = qualifier;
return; // all is well
}
} }
error(line, "cannot apply precision statement to this type; use 'float', 'int' or a sampler type", TType::getBasicString(basicType), "");
recover();
} }
bool TParseContext::parameterSamplerErrorCheck(int line, TStorageQualifier qualifier, const TType& type) bool TParseContext::parameterSamplerErrorCheck(int line, TStorageQualifier qualifier, const TType& type)
...@@ -800,7 +810,7 @@ bool TParseContext::insertBuiltInArrayAtGlobalLevel() ...@@ -800,7 +810,7 @@ bool TParseContext::insertBuiltInArrayAtGlobalLevel()
bool TParseContext::arraySizeErrorCheck(int line, TIntermTyped* expr, int& size) bool TParseContext::arraySizeErrorCheck(int line, TIntermTyped* expr, int& size)
{ {
TIntermConstantUnion* constant = expr->getAsConstantUnion(); TIntermConstantUnion* constant = expr->getAsConstantUnion();
if (constant == 0 || constant->getBasicType() != EbtInt) { if (constant == 0 || (constant->getBasicType() != EbtInt && constant->getBasicType() != EbtUint)) {
error(line, "array size must be a constant integer expression", "", ""); error(line, "array size must be a constant integer expression", "", "");
size = 1; size = 1;
return true; return true;
...@@ -1299,6 +1309,13 @@ TIntermTyped* TParseContext::constructBuiltIn(const TType& type, TOperator op, T ...@@ -1299,6 +1309,13 @@ TIntermTyped* TParseContext::constructBuiltIn(const TType& type, TOperator op, T
basicOp = EOpConstructInt; basicOp = EOpConstructInt;
break; break;
case EOpConstructUVec2:
case EOpConstructUVec3:
case EOpConstructUVec4:
case EOpConstructUint:
basicOp = EOpConstructUint;
break;
case EOpConstructBVec2: case EOpConstructBVec2:
case EOpConstructBVec3: case EOpConstructBVec3:
case EOpConstructBVec4: case EOpConstructBVec4:
......
...@@ -123,7 +123,7 @@ struct TParseContext { ...@@ -123,7 +123,7 @@ struct TParseContext {
bool globalQualifierFixAndErrorCheck(int line, TQualifier&); bool globalQualifierFixAndErrorCheck(int line, TQualifier&);
bool structQualifierErrorCheck(int line, const TPublicType& pType); bool structQualifierErrorCheck(int line, const TPublicType& pType);
bool mergeQualifiersErrorCheck(int line, TPublicType& left, const TPublicType& right); bool mergeQualifiersErrorCheck(int line, TPublicType& left, const TPublicType& right);
void setDefaultPrecision(int line, TBasicType, TPrecisionQualifier); void setDefaultPrecision(int line, TPublicType&, TPrecisionQualifier);
bool parameterSamplerErrorCheck(int line, TStorageQualifier qualifier, const TType& type); bool parameterSamplerErrorCheck(int line, TStorageQualifier qualifier, const TType& type);
bool containsSampler(const TType& type); bool containsSampler(const TType& type);
bool nonInitConstErrorCheck(int line, TString& identifier, TPublicType& type); bool nonInitConstErrorCheck(int line, TString& identifier, TPublicType& type);
...@@ -146,6 +146,8 @@ struct TParseContext { ...@@ -146,6 +146,8 @@ struct TParseContext {
void profileRequires(int line, EProfile callingProfile, int minVersion, const char* extension, const char *featureDesc); void profileRequires(int line, EProfile callingProfile, int minVersion, const char* extension, const char *featureDesc);
void checkDeprecated(int line, EProfile callingProfile, int depVersion, const char *featureDesc); void checkDeprecated(int line, EProfile callingProfile, int depVersion, const char *featureDesc);
void requireNotRemoved(int line, EProfile callingProfile, int removedVersion, const char *featureDesc); void requireNotRemoved(int line, EProfile callingProfile, int removedVersion, const char *featureDesc);
void fullIntegerCheck(int line, const char* op);
void doubleCheck(int line, const char* op);
}; };
int PaParseStrings(char* argv[], int strLen[], int argc, TParseContext&); int PaParseStrings(char* argv[], int strLen[], int argc, TParseContext&);
......
...@@ -59,6 +59,7 @@ void TType::buildMangledName(TString& mangledName) ...@@ -59,6 +59,7 @@ void TType::buildMangledName(TString& mangledName)
case EbtFloat: mangledName += 'f'; break; case EbtFloat: mangledName += 'f'; break;
case EbtDouble: mangledName += 'd'; break; case EbtDouble: mangledName += 'd'; break;
case EbtInt: mangledName += 'i'; break; case EbtInt: mangledName += 'i'; break;
case EbtUint: mangledName += 'u'; break;
case EbtBool: mangledName += 'b'; break; case EbtBool: mangledName += 'b'; break;
case EbtSampler: case EbtSampler:
switch (sampler.type) { switch (sampler.type) {
......
...@@ -160,3 +160,16 @@ void TParseContext::requireNotRemoved(int line, EProfile callingProfile, int rem ...@@ -160,3 +160,16 @@ void TParseContext::requireNotRemoved(int line, EProfile callingProfile, int rem
} }
} }
} }
void TParseContext::fullIntegerCheck(int line, const char* op)
{
profileRequires(line, ENoProfile, 130, 0, op);
profileRequires(line, EEsProfile, 300, 0, op);
}
void TParseContext::doubleCheck(int line, const char* op)
{
requireProfile(line, (EProfileMask)(ECoreProfileMask | ECompatibilityProfileMask), op);
profileRequires(line, ECoreProfile, 400, 0, op);
profileRequires(line, ECompatibilityProfile, 400, 0, op);
}
...@@ -355,15 +355,15 @@ int yy_input(char* buf, int max_size); ...@@ -355,15 +355,15 @@ int yy_input(char* buf, int max_size);
return PaIdentOrType(*pyylval->lex.string, parseContext, pyylval->lex.symbol); return PaIdentOrType(*pyylval->lex.string, parseContext, pyylval->lex.symbol);
} }
0[xX]{H}+ { pyylval->lex.line = yylineno; pyylval->lex.i = strtol(yytext, 0, 0); return(INTCONSTANT); } 0[xX]{H}+ { pyylval->lex.line = yylineno; pyylval->lex.i = strtoul(yytext, 0, 0); return(INTCONSTANT); }
0{O}+ { pyylval->lex.line = yylineno; pyylval->lex.i = strtol(yytext, 0, 0); return(INTCONSTANT); } 0{O}+ { pyylval->lex.line = yylineno; pyylval->lex.i = strtoul(yytext, 0, 0); return(INTCONSTANT); }
0{D}+ { pyylval->lex.line = yylineno; parseContext.error(yylineno, "Invalid Octal number.", yytext, "", ""); parseContext.recover(); return 0;} 0{D}+ { pyylval->lex.line = yylineno; parseContext.error(yylineno, "Invalid Octal number.", yytext, "", ""); parseContext.recover(); return 0;}
{D}+ { pyylval->lex.line = yylineno; pyylval->lex.i = strtol(yytext, 0, 0); return(INTCONSTANT); } {D}+ { pyylval->lex.line = yylineno; pyylval->lex.i = strtoul(yytext, 0, 0); return(INTCONSTANT); }
0[xX]{H}+{U} { pyylval->lex.line = yylineno; pyylval->lex.i = strtol(yytext, 0, 0); return(UINTCONSTANT); } 0[xX]{H}+{U} { pyylval->lex.line = yylineno; pyylval->lex.u = strtoul(yytext, 0, 0); return(UINTCONSTANT); }
0{O}+{U} { pyylval->lex.line = yylineno; pyylval->lex.i = strtol(yytext, 0, 0); return(UINTCONSTANT); } 0{O}+{U} { pyylval->lex.line = yylineno; pyylval->lex.u = strtoul(yytext, 0, 0); return(UINTCONSTANT); }
0{D}+{U} { pyylval->lex.line = yylineno; parseContext.error(yylineno, "Invalid Octal number.", yytext, "", ""); parseContext.recover(); return 0;} 0{D}+{U} { pyylval->lex.line = yylineno; parseContext.error(yylineno, "Invalid Octal number.", yytext, "", ""); parseContext.recover(); return 0;}
{D}+{U} { pyylval->lex.line = yylineno; pyylval->lex.i = strtol(yytext, 0, 0); return(UINTCONSTANT); } {D}+{U} { pyylval->lex.line = yylineno; pyylval->lex.u = strtoul(yytext, 0, 0); return(UINTCONSTANT); }
{D}+{F} { pyylval->lex.line = yylineno; pyylval->lex.f = static_cast<float>(atof(yytext)); return(FLOATCONSTANT); } {D}+{F} { pyylval->lex.line = yylineno; pyylval->lex.f = static_cast<float>(atof(yytext)); return(FLOATCONSTANT); }
{D}+{E}{F}? { pyylval->lex.line = yylineno; pyylval->lex.f = static_cast<float>(atof(yytext)); return(FLOATCONSTANT); } {D}+{E}{F}? { pyylval->lex.line = yylineno; pyylval->lex.f = static_cast<float>(atof(yytext)); return(FLOATCONSTANT); }
......
...@@ -177,11 +177,25 @@ bool OutputUnary(bool /* preVisit */, TIntermUnary* node, TIntermTraverser* it) ...@@ -177,11 +177,25 @@ bool OutputUnary(bool /* preVisit */, TIntermUnary* node, TIntermTraverser* it)
case EOpPreDecrement: out.debug << "Pre-Decrement"; break; case EOpPreDecrement: out.debug << "Pre-Decrement"; break;
case EOpConvIntToBool: out.debug << "Convert int to bool"; break; case EOpConvIntToBool: out.debug << "Convert int to bool"; break;
case EOpConvFloatToBool:out.debug << "Convert float to bool";break; case EOpConvUintToBool: out.debug << "Convert uint to bool"; break;
case EOpConvBoolToFloat:out.debug << "Convert bool to float";break; case EOpConvFloatToBool: out.debug << "Convert float to bool"; break;
case EOpConvDoubleToBool: out.debug << "Convert double to bool"; break;
case EOpConvIntToFloat: out.debug << "Convert int to float"; break; case EOpConvIntToFloat: out.debug << "Convert int to float"; break;
case EOpConvUintToFloat: out.debug << "Convert uint to float"; break;
case EOpConvDoubleToFloat: out.debug << "Convert double to float"; break;
case EOpConvBoolToFloat: out.debug << "Convert bool to float"; break;
case EOpConvUintToInt: out.debug << "Convert uint to int"; break;
case EOpConvFloatToInt: out.debug << "Convert float to int"; break; case EOpConvFloatToInt: out.debug << "Convert float to int"; break;
case EOpConvDoubleToInt: out.debug << "Convert double to int"; break;
case EOpConvBoolToInt: out.debug << "Convert bool to int"; break; case EOpConvBoolToInt: out.debug << "Convert bool to int"; break;
case EOpConvIntToUint: out.debug << "Convert int to uint"; break;
case EOpConvFloatToUint: out.debug << "Convert float to uint"; break;
case EOpConvDoubleToUint: out.debug << "Convert double to uint"; break;
case EOpConvBoolToUint: out.debug << "Convert bool to uint"; break;
case EOpConvIntToDouble: out.debug << "Convert int to double"; break;
case EOpConvUintToDouble: out.debug << "Convert uint to double"; break;
case EOpConvFloatToDouble: out.debug << "Convert float to double"; break;
case EOpConvBoolToDouble: out.debug << "Convert bool to double"; break;
case EOpRadians: out.debug << "radians"; break; case EOpRadians: out.debug << "radians"; break;
case EOpDegrees: out.debug << "degrees"; break; case EOpDegrees: out.debug << "degrees"; break;
...@@ -258,6 +272,10 @@ bool OutputAggregate(bool /* preVisit */, TIntermAggregate* node, TIntermTravers ...@@ -258,6 +272,10 @@ bool OutputAggregate(bool /* preVisit */, TIntermAggregate* node, TIntermTravers
case EOpConstructIVec2: out.debug << "Construct ivec2"; break; case EOpConstructIVec2: out.debug << "Construct ivec2"; break;
case EOpConstructIVec3: out.debug << "Construct ivec3"; break; case EOpConstructIVec3: out.debug << "Construct ivec3"; break;
case EOpConstructIVec4: out.debug << "Construct ivec4"; break; case EOpConstructIVec4: out.debug << "Construct ivec4"; break;
case EOpConstructUint: out.debug << "Construct uint"; break;
case EOpConstructUVec2: out.debug << "Construct uvec2"; break;
case EOpConstructUVec3: out.debug << "Construct uvec3"; break;
case EOpConstructUVec4: out.debug << "Construct uvec4"; break;
case EOpConstructMat2x2: out.debug << "Construct mat2"; break; case EOpConstructMat2x2: out.debug << "Construct mat2"; break;
case EOpConstructMat2x3: out.debug << "Construct mat2x3"; break; case EOpConstructMat2x3: out.debug << "Construct mat2x3"; break;
case EOpConstructMat2x4: out.debug << "Construct mat2x4"; break; case EOpConstructMat2x4: out.debug << "Construct mat2x4"; break;
...@@ -398,6 +416,15 @@ void OutputConstantUnion(TIntermConstantUnion* node, TIntermTraverser* it) ...@@ -398,6 +416,15 @@ void OutputConstantUnion(TIntermConstantUnion* node, TIntermTraverser* it)
out.debug << buf << "\n"; out.debug << buf << "\n";
} }
break; break;
case EbtUint:
{
const int maxSize = 300;
char buf[maxSize];
snprintf(buf, maxSize, "%u (%s)", node->getUnionArrayPointer()[i].getUConst(), "const uint");
out.debug << buf << "\n";
}
break;
default: default:
out.info.message(EPrefixInternalError, "Unknown constant", node->getLine()); out.info.message(EPrefixInternalError, "Unknown constant", node->getLine());
break; break;
......
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