Add support for the unsigned integer scalar type to the shader translator.

TRAC #23080 Signed-off-by: Nicolas Capens Signed-off-by: Shannon Woods Author: Jamie Madill git-svn-id: https://angleproject.googlecode.com/svn/branches/es3proto@2403 736b8ea6-26fd-11df-bfd4-992fa37f6226
parent 1885113c
......@@ -88,6 +88,7 @@ typedef enum {
typedef enum {
SH_NONE = 0,
SH_INT = 0x1404,
SH_UNSIGNED_INT = 0x1405,
SH_FLOAT = 0x1406,
SH_FLOAT_VEC2 = 0x8B50,
SH_FLOAT_VEC3 = 0x8B51,
......@@ -95,6 +96,9 @@ typedef enum {
SH_INT_VEC2 = 0x8B53,
SH_INT_VEC3 = 0x8B54,
SH_INT_VEC4 = 0x8B55,
SH_UNSIGNED_INT_VEC2 = 0x8DC6,
SH_UNSIGNED_INT_VEC3 = 0x8DC7,
SH_UNSIGNED_INT_VEC4 = 0x8DC8,
SH_BOOL = 0x8B56,
SH_BOOL_VEC2 = 0x8B57,
SH_BOOL_VEC3 = 0x8B58,
......
......@@ -326,6 +326,10 @@ void PrintActiveVariables(ShHandle compiler, ShShaderInfo varType, bool mapLongV
case SH_INT_VEC2: typeName = "GL_INT_VEC2"; break;
case SH_INT_VEC3: typeName = "GL_INT_VEC3"; break;
case SH_INT_VEC4: typeName = "GL_INT_VEC4"; break;
case SH_UNSIGNED_INT: typeName = "GL_UNSIGNED_INT"; break;
case SH_UNSIGNED_INT_VEC2: typeName = "GL_UNSIGNED_INT_VEC2"; break;
case SH_UNSIGNED_INT_VEC3: typeName = "GL_UNSIGNED_INT_VEC3"; break;
case SH_UNSIGNED_INT_VEC4: typeName = "GL_UNSIGNED_INT_VEC4"; break;
case SH_BOOL: typeName = "GL_BOOL"; break;
case SH_BOOL_VEC2: typeName = "GL_BOOL_VEC2"; break;
case SH_BOOL_VEC3: typeName = "GL_BOOL_VEC3"; break;
......
......@@ -164,6 +164,7 @@ int VariableRowCount(GLenum type)
case GL_BOOL:
case GL_FLOAT:
case GL_INT:
case GL_UNSIGNED_INT:
case GL_BOOL_VEC2:
case GL_FLOAT_VEC2:
case GL_INT_VEC2:
......@@ -204,6 +205,7 @@ int VariableColumnCount(GLenum type)
case GL_BOOL:
case GL_FLOAT:
case GL_INT:
case GL_UNSIGNED_INT:
case GL_SAMPLER_2D:
case GL_SAMPLER_CUBE:
return 1;
......
......@@ -77,16 +77,24 @@ const char* getOperatorString(TOperator op) {
// Fall-through.
case EOpConvIntToBool:
case EOpConvUnsignedIntToBool:
case EOpConvFloatToBool: return "bool";
// Fall-through.
case EOpConvBoolToFloat:
case EOpConvUnsignedIntToFloat:
case EOpConvIntToFloat: return "float";
// Fall-through.
case EOpConvFloatToInt:
case EOpConvUnsignedIntToInt:
case EOpConvBoolToInt: return "int";
// Fall-through.
case EOpConvIntToUnsignedInt:
case EOpConvFloatToUnsignedInt:
case EOpConvBoolToUnsignedInt: return "uint";
case EOpRadians: return "radians";
case EOpDegrees: return "degrees";
case EOpSin: return "sin";
......@@ -315,6 +323,7 @@ TIntermTyped* TIntermediate::addUnaryMath(TOperator op, TIntermNode* childNode,
TBasicType newType = EbtVoid;
switch (op) {
case EOpConstructInt: newType = EbtInt; break;
case EOpConstructUnsignedInt: newType = EbtUInt; break;
case EOpConstructBool: newType = EbtBool; break;
case EOpConstructFloat: newType = EbtFloat; break;
default: break;
......@@ -335,6 +344,7 @@ TIntermTyped* TIntermediate::addUnaryMath(TOperator op, TIntermNode* childNode,
//
switch (op) {
case EOpConstructInt:
case EOpConstructUnsignedInt:
case EOpConstructBool:
case EOpConstructFloat:
return child;
......@@ -462,6 +472,9 @@ TIntermTyped* TIntermediate::addConversion(TOperator op, const TType& type, TInt
case EOpConstructInt:
promoteTo = EbtInt;
break;
case EOpConstructUnsignedInt:
promoteTo = EbtUInt;
break;
default:
//
// implicit conversions were removed from the language.
......@@ -489,8 +502,9 @@ TIntermTyped* TIntermediate::addConversion(TOperator op, const TType& type, TInt
switch (promoteTo) {
case EbtFloat:
switch (node->getBasicType()) {
case EbtInt: newOp = EOpConvIntToFloat; break;
case EbtBool: newOp = EOpConvBoolToFloat; break;
case EbtInt: newOp = EOpConvIntToFloat; break;
case EbtUInt: newOp = EOpConvFloatToUnsignedInt; break;
case EbtBool: newOp = EOpConvBoolToFloat; break;
default:
infoSink.info.message(EPrefixInternalError, "Bad promotion node", node->getLine());
return 0;
......@@ -498,8 +512,9 @@ TIntermTyped* TIntermediate::addConversion(TOperator op, const TType& type, TInt
break;
case EbtBool:
switch (node->getBasicType()) {
case EbtInt: newOp = EOpConvIntToBool; break;
case EbtFloat: newOp = EOpConvFloatToBool; break;
case EbtInt: newOp = EOpConvIntToBool; break;
case EbtUInt: newOp = EOpConvBoolToUnsignedInt; break;
case EbtFloat: newOp = EOpConvFloatToBool; break;
default:
infoSink.info.message(EPrefixInternalError, "Bad promotion node", node->getLine());
return 0;
......@@ -507,8 +522,19 @@ TIntermTyped* TIntermediate::addConversion(TOperator op, const TType& type, TInt
break;
case EbtInt:
switch (node->getBasicType()) {
case EbtBool: newOp = EOpConvBoolToInt; break;
case EbtFloat: newOp = EOpConvFloatToInt; break;
case EbtUInt: newOp = EOpConvUnsignedIntToInt; break;
case EbtBool: newOp = EOpConvBoolToInt; break;
case EbtFloat: newOp = EOpConvFloatToInt; break;
default:
infoSink.info.message(EPrefixInternalError, "Bad promotion node", node->getLine());
return 0;
}
break;
case EbtUInt:
switch (node->getBasicType()) {
case EbtInt: newOp = EOpConvIntToUnsignedInt; break;
case EbtBool: newOp = EOpConvBoolToUnsignedInt; break;
case EbtFloat: newOp = EOpConvFloatToUnsignedInt; break;
default:
infoSink.info.message(EPrefixInternalError, "Bad promotion node", node->getLine());
return 0;
......@@ -803,6 +829,7 @@ bool TIntermOperator::isConstructor() const
case EOpConstructIVec3:
case EOpConstructIVec4:
case EOpConstructInt:
case EOpConstructUnsignedInt:
case EOpConstructBVec2:
case EOpConstructBVec3:
case EOpConstructBVec4:
......@@ -1281,7 +1308,7 @@ TIntermTyped* TIntermConstantUnion::fold(TOperator op, TIntermTyped* constantNod
{
switch (getType().getBasicType())
{
case EbtFloat:
case EbtFloat:
if (rightUnionArray[i] == 0.0f)
{
infoSink.info.message(EPrefixWarning, "Divide by zero error during constant folding", getLine());
......@@ -1293,7 +1320,7 @@ TIntermTyped* TIntermConstantUnion::fold(TOperator op, TIntermTyped* constantNod
}
break;
case EbtInt:
case EbtInt:
if (rightUnionArray[i] == 0)
{
infoSink.info.message(EPrefixWarning, "Divide by zero error during constant folding", getLine());
......@@ -1305,7 +1332,19 @@ TIntermTyped* TIntermConstantUnion::fold(TOperator op, TIntermTyped* constantNod
}
break;
default:
case EbtUInt:
if (rightUnionArray[i] == 0)
{
infoSink.info.message(EPrefixWarning, "Divide by zero error during constant folding", getLine());
tempConstArray[i].setUConst(UINT_MAX);
}
else
{
tempConstArray[i].setUConst(unionArray[i].getUConst() / rightUnionArray[i].getUConst());
}
break;
default:
infoSink.info.message(EPrefixInternalError, "Constant folding cannot be done for \"/\"", getLine());
return 0;
}
......@@ -1575,6 +1614,9 @@ TIntermTyped* TIntermediate::promoteConstantUnion(TBasicType promoteTo, TIntermC
case EbtInt:
leftUnionArray[i].setFConst(static_cast<float>(node->getIConst(i)));
break;
case EbtUInt:
leftUnionArray[i].setFConst(static_cast<float>(node->getUConst(i)));
break;
case EbtBool:
leftUnionArray[i].setFConst(static_cast<float>(node->getBConst(i)));
break;
......@@ -1591,6 +1633,9 @@ TIntermTyped* TIntermediate::promoteConstantUnion(TBasicType promoteTo, TIntermC
case EbtInt:
leftUnionArray[i].setIConst(static_cast<int>(node->getIConst(i)));
break;
case EbtUInt:
leftUnionArray[i].setIConst(static_cast<int>(node->getUConst(i)));
break;
case EbtBool:
leftUnionArray[i].setIConst(static_cast<int>(node->getBConst(i)));
break;
......@@ -1602,11 +1647,33 @@ TIntermTyped* TIntermediate::promoteConstantUnion(TBasicType promoteTo, TIntermC
return 0;
}
break;
case EbtUInt:
switch (node->getType().getBasicType()) {
case EbtInt:
leftUnionArray[i].setUConst(static_cast<unsigned int>(node->getIConst(i)));
break;
case EbtUInt:
leftUnionArray[i].setUConst(static_cast<unsigned int>(node->getUConst(i)));
break;
case EbtBool:
leftUnionArray[i].setUConst(static_cast<unsigned int>(node->getBConst(i)));
break;
case EbtFloat:
leftUnionArray[i].setUConst(static_cast<unsigned int>(node->getFConst(i)));
break;
default:
infoSink.info.message(EPrefixInternalError, "Cannot promote", node->getLine());
return 0;
}
break;
case EbtBool:
switch (node->getType().getBasicType()) {
case EbtInt:
leftUnionArray[i].setBConst(node->getIConst(i) != 0);
break;
case EbtUInt:
leftUnionArray[i].setBConst(node->getUConst(i) != 0);
break;
case EbtBool:
leftUnionArray[i].setBConst(node->getBConst(i));
break;
......
......@@ -1619,6 +1619,10 @@ bool OutputHLSL::visitBinary(Visit visit, TIntermBinary *node)
default: UNREACHABLE();
}
break;
case EbtUInt:
// TODO
UNIMPLEMENTED();
break;
case EbtBool:
switch (node->getLeft()->getNominalSize())
{
......@@ -1680,6 +1684,7 @@ bool OutputHLSL::visitUnary(Visit visit, TIntermUnary *node)
case EOpPreIncrement: outputTriplet(visit, "(++", "", ")"); break;
case EOpPreDecrement: outputTriplet(visit, "(--", "", ")"); break;
case EOpConvIntToBool:
case EOpConvUnsignedIntToBool:
case EOpConvFloatToBool:
switch (node->getOperand()->getType().getNominalSize())
{
......@@ -1692,6 +1697,7 @@ bool OutputHLSL::visitUnary(Visit visit, TIntermUnary *node)
break;
case EOpConvBoolToFloat:
case EOpConvIntToFloat:
case EOpConvUnsignedIntToFloat:
switch (node->getOperand()->getType().getNominalSize())
{
case 1: outputTriplet(visit, "float(", "", ")"); break;
......@@ -1703,6 +1709,7 @@ bool OutputHLSL::visitUnary(Visit visit, TIntermUnary *node)
break;
case EOpConvFloatToInt:
case EOpConvBoolToInt:
case EOpConvUnsignedIntToInt:
switch (node->getOperand()->getType().getNominalSize())
{
case 1: outputTriplet(visit, "int(", "", ")"); break;
......@@ -1712,6 +1719,18 @@ bool OutputHLSL::visitUnary(Visit visit, TIntermUnary *node)
default: UNREACHABLE();
}
break;
case EOpConvFloatToUnsignedInt:
case EOpConvBoolToUnsignedInt:
case EOpConvIntToUnsignedInt:
switch (node->getOperand()->getType().getCols())
{
case 1: outputTriplet(visit, "uint(", "", ")"); break;
case 2:
case 3:
case 4: UNIMPLEMENTED(); break;
default: UNREACHABLE();
}
break;
case EOpRadians: outputTriplet(visit, "radians(", "", ")"); break;
case EOpDegrees: outputTriplet(visit, "degrees(", "", ")"); break;
case EOpSin: outputTriplet(visit, "sin(", "", ")"); break;
......@@ -2201,6 +2220,10 @@ bool OutputHLSL::visitAggregate(Visit visit, TIntermAggregate *node)
addConstructor(node->getType(), "ivec4", &node->getSequence());
outputTriplet(visit, "ivec4(", ", ", ")");
break;
case EOpConstructUnsignedInt:
addConstructor(node->getType(), "uvec1", &node->getSequence());
outputTriplet(visit, "uvec1(", "", ")");
break;
case EOpConstructMat2:
addConstructor(node->getType(), "mat2", &node->getSequence());
outputTriplet(visit, "mat2(", ", ", ")");
......@@ -2856,6 +2879,12 @@ TString OutputHLSL::typeString(const TType &type)
case 3: return "int3";
case 4: return "int4";
}
case EbtUInt:
switch (type.getCols())
{
case 1: return "uint";
default: UNIMPLEMENTED(); return "error";
}
case EbtBool:
switch (type.getNominalSize())
{
......@@ -3184,6 +3213,7 @@ const ConstantUnion *OutputHLSL::writeConstantUnion(const TType &type, const Con
{
case EbtFloat: out << std::min(FLT_MAX, std::max(-FLT_MAX, constUnion->getFConst())); break;
case EbtInt: out << constUnion->getIConst(); break;
case EbtUInt: out << constUnion->getUConst(); break;
case EbtBool: out << constUnion->getBConst(); break;
default: UNREACHABLE();
}
......@@ -3417,6 +3447,18 @@ GLenum OutputHLSL::glVariableType(const TType &type)
}
else UNREACHABLE();
}
else if (type.getBasicType() == EbtUInt)
{
if (type.isScalar())
{
return GL_UNSIGNED_INT;
}
else if (type.isVector())
{
UNIMPLEMENTED();
}
else UNREACHABLE();
}
else if (type.getBasicType() == EbtBool)
{
if (type.isScalar())
......@@ -3462,7 +3504,7 @@ GLenum OutputHLSL::glVariablePrecision(const TType &type)
default: UNREACHABLE();
}
}
else if (type.getBasicType() == EbtInt)
else if (type.getBasicType() == EbtInt || type.getBasicType() == EbtUInt)
{
switch (type.getPrecision())
{
......
......@@ -396,7 +396,7 @@ bool TParseContext::constErrorCheck(TIntermTyped* node)
//
bool TParseContext::integerErrorCheck(TIntermTyped* node, const char* token)
{
if (node->getBasicType() == EbtInt && node->isScalar())
if (node->isScalarInt())
return false;
error(node->getLine(), "integer expression required", token);
......@@ -676,17 +676,35 @@ bool TParseContext::containsSampler(TType& type)
bool TParseContext::arraySizeErrorCheck(int line, TIntermTyped* expr, int& size)
{
TIntermConstantUnion* constant = expr->getAsConstantUnion();
if (constant == 0 || constant->getBasicType() != EbtInt) {
if (constant == 0 || !constant->isScalarInt())
{
error(line, "array size must be a constant integer expression", "");
return true;
}
size = constant->getIConst(0);
if (constant->getBasicType() == EbtUInt)
{
unsigned int uintSize = constant->getUConst(0);
if (uintSize > static_cast<unsigned int>(std::numeric_limits<int>::max()))
{
error(line, "array size too large", "");
size = 1;
return true;
}
if (size <= 0) {
error(line, "array size must be a positive integer", "");
size = 1;
return true;
size = static_cast<int>(uintSize);
}
else
{
size = constant->getIConst(0);
if (size <= 0)
{
error(line, "array size must be a positive integer", "");
size = 1;
return true;
}
}
return false;
......@@ -1193,6 +1211,14 @@ TFunction *TParseContext::addConstructorFunc(TPublicType publicType)
}
break;
case EbtUInt:
switch(publicType.getNominalSize())
{
case 1: op = EOpConstructUnsignedInt; break;
default: UNIMPLEMENTED(); break;
}
break;
case EbtBool:
switch(publicType.getNominalSize())
{
......@@ -1359,6 +1385,10 @@ TIntermTyped* TParseContext::constructBuiltIn(const TType* type, TOperator op, T
basicOp = EOpConstructInt;
break;
case EOpConstructUnsignedInt:
basicOp = EOpConstructUnsignedInt;
break;
case EOpConstructBVec2:
case EOpConstructBVec3:
case EOpConstructBVec4:
......
......@@ -44,6 +44,7 @@ void TType::buildMangledName(TString& mangledName)
switch (type) {
case EbtFloat: mangledName += 'f'; break;
case EbtInt: mangledName += 'i'; break;
case EbtUInt: mangledName += 'u'; break;
case EbtBool: mangledName += 'b'; break;
case EbtSampler2D: mangledName += "s2"; break;
case EbtSamplerCube: mangledName += "sC"; break;
......
......@@ -342,6 +342,10 @@ public:
// Searches down the precisionStack for a precision qualifier for the specified TBasicType
TPrecision getDefaultPrecision( TBasicType type){
// unsigned integers use the same precision as signed
if (type == EbtUInt) type = EbtInt;
if( type != EbtFloat && type != EbtInt ) return EbpUndefined;
int level = static_cast<int>(precisionStack.size()) - 1;
assert( level >= 0); // Just to be safe. Should not happen.
......
......@@ -195,6 +195,7 @@ public:
bool isVector() const { return primarySize > 1 && secondarySize == 1; }
bool isScalar() const { return primarySize == 1 && secondarySize == 1 && !structure; }
bool isScalarInt() const { return isScalar() && (type == EbtInt || type == EbtUInt); }
TTypeList* getStruct() const { return structure; }
void setStruct(TTypeList* s) { structure = s; computeDeepestStructNesting(); }
......
......@@ -79,6 +79,10 @@ public:
case EbtFloat:
mUsesFloatLoopIndex = true;
break;
case EbtUInt:
mUsesIntLoopIndex = true;
MarkLoopForUnroll(symbol, mLoopStack);
break;
case EbtInt:
mUsesIntLoopIndex = true;
MarkLoopForUnroll(symbol, mLoopStack);
......@@ -269,7 +273,7 @@ bool ValidateLimitations::validateForLoopInit(TIntermLoop* node,
}
// The loop index has type int or float.
TBasicType type = symbol->getBasicType();
if ((type != EbtInt) && (type != EbtFloat)) {
if ((type != EbtInt) && (type != EbtUInt) && (type != EbtFloat)) {
error(symbol->getLine(),
"Invalid type for loop index", getBasicString(type));
return false;
......@@ -492,7 +496,7 @@ bool ValidateLimitations::validateIndexing(TIntermBinary* node)
bool valid = true;
TIntermTyped* index = node->getRight();
// The index expression must have integral type.
if (!index->isScalar() || (index->getBasicType() != EbtInt)) {
if (!index->isScalarInt()) {
error(index->getLine(),
"Index expression must have integral type",
index->getCompleteString().c_str());
......
......@@ -69,6 +69,19 @@ static ShDataType getVariableDataType(const TType& type)
} else {
return SH_INT;
}
case EbtUInt:
if (type.isMatrix()) {
UNREACHABLE();
} else if (type.isVector()) {
switch (type.getCols()) {
case 2: return SH_UNSIGNED_INT_VEC2;
case 3: return SH_UNSIGNED_INT_VEC3;
case 4: return SH_UNSIGNED_INT_VEC4;
default: UNREACHABLE();
}
} else {
return SH_UNSIGNED_INT;
}
case EbtBool:
if (type.isMatrix()) {
UNREACHABLE();
......
......@@ -119,6 +119,7 @@ O [0-7]
"float" { context->lexAfterType = true; return(FLOAT_TYPE); }
"int" { context->lexAfterType = true; return(INT_TYPE); }
"uint" { return ES2_ident_ES3_keyword(context, UINT_TYPE); }
"void" { context->lexAfterType = true; return(VOID_TYPE); }
"bool" { context->lexAfterType = true; return(BOOL_TYPE); }
"true" { yylval->lex.b = true; return(BOOLCONSTANT); }
......
......@@ -122,7 +122,7 @@ extern void yyerror(TParseContext* context, const char* reason);
%}
%token <lex> INVARIANT HIGH_PRECISION MEDIUM_PRECISION LOW_PRECISION PRECISION
%token <lex> ATTRIBUTE CONST_QUAL BOOL_TYPE FLOAT_TYPE INT_TYPE
%token <lex> ATTRIBUTE CONST_QUAL BOOL_TYPE FLOAT_TYPE INT_TYPE UINT_TYPE
%token <lex> BREAK CONTINUE DO ELSE FOR IF DISCARD RETURN SWITCH CASE DEFAULT
%token <lex> BVEC2 BVEC3 BVEC4 IVEC2 IVEC3 IVEC4 VEC2 VEC3 VEC4
%token <lex> MATRIX2 MATRIX3 MATRIX4 IN_QUAL OUT_QUAL INOUT_QUAL UNIFORM VARYING
......@@ -1458,15 +1458,14 @@ type_specifier_nonarray
TQualifier qual = context->symbolTable.atGlobalLevel() ? EvqGlobal : EvqTemporary;
$$.setBasic(EbtInt, qual, $1.line);
}
| UINT_TYPE {
TQualifier qual = context->symbolTable.atGlobalLevel() ? EvqGlobal : EvqTemporary;
$$.setBasic(EbtUInt, qual, $1.line);
}
| BOOL_TYPE {
TQualifier qual = context->symbolTable.atGlobalLevel() ? EvqGlobal : EvqTemporary;
$$.setBasic(EbtBool, qual, $1.line);
}
// | UNSIGNED INT_TYPE {
// PACK_UNPACK_ONLY("unsigned", $1.line);
// TQualifier qual = context->symbolTable.atGlobalLevel() ? EvqGlobal : EvqTemporary;
// $$.setBasic(EbtInt, qual, $1.line);
// }
| VEC2 {
TQualifier qual = context->symbolTable.atGlobalLevel() ? EvqGlobal : EvqTemporary;
$$.setBasic(EbtFloat, qual, $1.line);
......
This source diff could not be displayed because it is too large. You can view the blob instead.
......@@ -56,104 +56,105 @@ extern int yydebug;
BOOL_TYPE = 265,
FLOAT_TYPE = 266,
INT_TYPE = 267,
BREAK = 268,
CONTINUE = 269,
DO = 270,
ELSE = 271,
FOR = 272,
IF = 273,
DISCARD = 274,
RETURN = 275,
SWITCH = 276,
CASE = 277,
DEFAULT = 278,
BVEC2 = 279,
BVEC3 = 280,
BVEC4 = 281,
IVEC2 = 282,
IVEC3 = 283,
IVEC4 = 284,
VEC2 = 285,
VEC3 = 286,
VEC4 = 287,
MATRIX2 = 288,
MATRIX3 = 289,
MATRIX4 = 290,
IN_QUAL = 291,
OUT_QUAL = 292,
INOUT_QUAL = 293,
UNIFORM = 294,
VARYING = 295,
MATRIX2x3 = 296,
MATRIX3x2 = 297,
MATRIX2x4 = 298,
MATRIX4x2 = 299,
MATRIX3x4 = 300,
MATRIX4x3 = 301,
CENTROID = 302,
FLAT = 303,
SMOOTH = 304,
STRUCT = 305,
VOID_TYPE = 306,
WHILE = 307,
SAMPLER2D = 308,
SAMPLERCUBE = 309,
SAMPLER_EXTERNAL_OES = 310,
SAMPLER2DRECT = 311,
SAMPLER3D = 312,
SAMPLER3DRECT = 313,
SAMPLER2DSHADOW = 314,
IDENTIFIER = 315,
TYPE_NAME = 316,
FLOATCONSTANT = 317,
INTCONSTANT = 318,
BOOLCONSTANT = 319,
FIELD_SELECTION = 320,
LEFT_OP = 321,
RIGHT_OP = 322,
INC_OP = 323,
DEC_OP = 324,
LE_OP = 325,
GE_OP = 326,
EQ_OP = 327,
NE_OP = 328,
AND_OP = 329,
OR_OP = 330,
XOR_OP = 331,
MUL_ASSIGN = 332,
DIV_ASSIGN = 333,
ADD_ASSIGN = 334,
MOD_ASSIGN = 335,
LEFT_ASSIGN = 336,
RIGHT_ASSIGN = 337,
AND_ASSIGN = 338,
XOR_ASSIGN = 339,
OR_ASSIGN = 340,
SUB_ASSIGN = 341,
LEFT_PAREN = 342,
RIGHT_PAREN = 343,
LEFT_BRACKET = 344,
RIGHT_BRACKET = 345,
LEFT_BRACE = 346,
RIGHT_BRACE = 347,
DOT = 348,
COMMA = 349,
COLON = 350,
EQUAL = 351,
SEMICOLON = 352,
BANG = 353,
DASH = 354,
TILDE = 355,
PLUS = 356,
STAR = 357,
SLASH = 358,
PERCENT = 359,
LEFT_ANGLE = 360,
RIGHT_ANGLE = 361,
VERTICAL_BAR = 362,
CARET = 363,
AMPERSAND = 364,
QUESTION = 365
UINT_TYPE = 268,
BREAK = 269,
CONTINUE = 270,
DO = 271,
ELSE = 272,
FOR = 273,
IF = 274,
DISCARD = 275,
RETURN = 276,
SWITCH = 277,
CASE = 278,
DEFAULT = 279,
BVEC2 = 280,
BVEC3 = 281,
BVEC4 = 282,
IVEC2 = 283,
IVEC3 = 284,
IVEC4 = 285,
VEC2 = 286,
VEC3 = 287,
VEC4 = 288,
MATRIX2 = 289,
MATRIX3 = 290,
MATRIX4 = 291,
IN_QUAL = 292,
OUT_QUAL = 293,
INOUT_QUAL = 294,
UNIFORM = 295,
VARYING = 296,
MATRIX2x3 = 297,
MATRIX3x2 = 298,
MATRIX2x4 = 299,
MATRIX4x2 = 300,
MATRIX3x4 = 301,
MATRIX4x3 = 302,
CENTROID = 303,
FLAT = 304,
SMOOTH = 305,
STRUCT = 306,
VOID_TYPE = 307,
WHILE = 308,
SAMPLER2D = 309,
SAMPLERCUBE = 310,
SAMPLER_EXTERNAL_OES = 311,
SAMPLER2DRECT = 312,
SAMPLER3D = 313,
SAMPLER3DRECT = 314,
SAMPLER2DSHADOW = 315,
IDENTIFIER = 316,
TYPE_NAME = 317,
FLOATCONSTANT = 318,
INTCONSTANT = 319,
BOOLCONSTANT = 320,
FIELD_SELECTION = 321,
LEFT_OP = 322,
RIGHT_OP = 323,
INC_OP = 324,
DEC_OP = 325,
LE_OP = 326,
GE_OP = 327,
EQ_OP = 328,
NE_OP = 329,
AND_OP = 330,
OR_OP = 331,
XOR_OP = 332,
MUL_ASSIGN = 333,
DIV_ASSIGN = 334,
ADD_ASSIGN = 335,
MOD_ASSIGN = 336,
LEFT_ASSIGN = 337,
RIGHT_ASSIGN = 338,
AND_ASSIGN = 339,
XOR_ASSIGN = 340,
OR_ASSIGN = 341,
SUB_ASSIGN = 342,
LEFT_PAREN = 343,
RIGHT_PAREN = 344,
LEFT_BRACKET = 345,
RIGHT_BRACKET = 346,
LEFT_BRACE = 347,
RIGHT_BRACE = 348,
DOT = 349,
COMMA = 350,
COLON = 351,
EQUAL = 352,
SEMICOLON = 353,
BANG = 354,
DASH = 355,
TILDE = 356,
PLUS = 357,
STAR = 358,
SLASH = 359,
PERCENT = 360,
LEFT_ANGLE = 361,
RIGHT_ANGLE = 362,
VERTICAL_BAR = 363,
CARET = 364,
AMPERSAND = 365,
QUESTION = 366
};
#endif
......
......@@ -153,11 +153,16 @@ bool TOutputTraverser::visitUnary(Visit visit, TIntermUnary* node)
case EOpPreDecrement: out << "Pre-Decrement"; break;
case EOpConvIntToBool: out << "Convert int to bool"; break;
case EOpConvUnsignedIntToBool: out << "Convert unsigned int to bool"; break;
case EOpConvFloatToBool:out << "Convert float to bool";break;
case EOpConvBoolToFloat:out << "Convert bool to float";break;
case EOpConvIntToFloat: out << "Convert int to float"; break;
case EOpConvUnsignedIntToFloat: out << "Convert unsigned int to float"; break;
case EOpConvFloatToInt: out << "Convert float to int"; break;
case EOpConvBoolToInt: out << "Convert bool to int"; break;
case EOpConvIntToUnsignedInt: out << "Convert int to unsigned int"; break;
case EOpConvFloatToUnsignedInt: out << "Convert float to unsigned int"; break;
case EOpConvBoolToUnsignedInt: out << "Convert bool to unsigned int"; break;
case EOpRadians: out << "radians"; break;
case EOpDegrees: out << "degrees"; break;
......@@ -230,6 +235,7 @@ bool TOutputTraverser::visitAggregate(Visit visit, TIntermAggregate* node)
case EOpConstructIVec2: out << "Construct ivec2"; break;
case EOpConstructIVec3: out << "Construct ivec3"; break;
case EOpConstructIVec4: out << "Construct ivec4"; break;
case EOpConstructUnsignedInt: out << "Construct uint"; break;
case EOpConstructMat2: out << "Construct mat2"; break;
case EOpConstructMat3: out << "Construct mat3"; break;
case EOpConstructMat4: out << "Construct mat4"; break;
......@@ -334,6 +340,10 @@ void TOutputTraverser::visitConstantUnion(TIntermConstantUnion* node)
out << node->getUnionArrayPointer()[i].getIConst();
out << " (const int)\n";
break;
case EbtUInt:
out << node->getUnionArrayPointer()[i].getUConst();
out << " (const uint)\n";
break;
default:
out.message(EPrefixInternalError, "Unknown constant", node->getLine());
break;
......
......@@ -49,11 +49,17 @@ enum TOperator {
EOpPreDecrement,
EOpConvIntToBool,
EOpConvUnsignedIntToBool,
EOpConvFloatToBool,
EOpConvBoolToFloat,
EOpConvIntToFloat,
EOpConvUnsignedIntToFloat,
EOpConvFloatToInt,
EOpConvBoolToInt,
EOpConvUnsignedIntToInt,
EOpConvIntToUnsignedInt,
EOpConvFloatToUnsignedInt,
EOpConvBoolToUnsignedInt,
//
// binary operations
......@@ -155,6 +161,7 @@ enum TOperator {
//
EOpConstructInt,
EOpConstructUnsignedInt,
EOpConstructBool,
EOpConstructFloat,
EOpConstructVec2,
......@@ -259,6 +266,7 @@ public:
bool isArray() const { return type.isArray(); }
bool isVector() const { return type.isVector(); }
bool isScalar() const { return type.isScalar(); }
bool isScalarInt() const { return type.isScalarInt(); }
const char* getBasicString() const { return type.getBasicString(); }
const char* getQualifierString() const { return type.getQualifierString(); }
TString getCompleteString() const { return type.getCompleteString(); }
......@@ -368,6 +376,7 @@ public:
ConstantUnion* getUnionArrayPointer() const { return unionArrayPointer; }
int getIConst(int index) const { return unionArrayPointer ? unionArrayPointer[index].getIConst() : 0; }
int getUConst(int index) const { return unionArrayPointer ? unionArrayPointer[index].getUConst() : 0; }
float getFConst(int index) const { return unionArrayPointer ? unionArrayPointer[index].getFConst() : 0.0f; }
bool getBConst(int index) const { return unionArrayPointer ? unionArrayPointer[index].getBConst() : false; }
......
......@@ -50,6 +50,7 @@ namespace gl_d3d
case GL_INT_VEC2: return "int2";
case GL_INT_VEC3: return "int3";
case GL_INT_VEC4: return "int4";
case GL_UNSIGNED_INT: return "uint";
case GL_FLOAT_MAT2: return "float2x2";
case GL_FLOAT_MAT3: return "float3x3";
case GL_FLOAT_MAT4: return "float4x4";
......
......@@ -533,6 +533,10 @@ GLenum Shader::parseType(const std::string &type)
{
return GL_INT_VEC4;
}
else if (type == "uint")
{
return GL_UNSIGNED_INT;
}
else UNREACHABLE();
return GL_NONE;
......@@ -560,6 +564,7 @@ static void makeVaryingPriorityMap()
varyingPriorities[GL_INT_VEC2] = 111;
varyingPriorities[GL_FLOAT] = 120;
varyingPriorities[GL_INT] = 125;
varyingPriorities[GL_UNSIGNED_INT] = 130;
}
// true if varying x has a higher priority in packing than y
......
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