Add full integer support to the shader language.

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@2400 736b8ea6-26fd-11df-bfd4-992fa37f6226
parent b4e07b89
...@@ -1116,17 +1116,34 @@ TPublicType TParseContext::addFullySpecifiedType(TQualifier qualifier, const TPu ...@@ -1116,17 +1116,34 @@ TPublicType TParseContext::addFullySpecifiedType(TQualifier qualifier, const TPu
returnType.setArray(false); returnType.setArray(false);
} }
if (qualifier == EvqAttribute && (typeSpecifier.type == EbtBool || typeSpecifier.type == EbtInt)) if (shaderVersion < 300)
{ {
error(typeSpecifier.line, "cannot be bool or int", getQualifierString(qualifier)); if (qualifier == EvqAttribute && (typeSpecifier.type == EbtBool || typeSpecifier.type == EbtInt))
recover(); {
} error(typeSpecifier.line, "cannot be bool or int", getQualifierString(qualifier));
recover();
}
if ((qualifier == EvqVaryingIn || qualifier == EvqVaryingOut) && if ((qualifier == EvqVaryingIn || qualifier == EvqVaryingOut) &&
(typeSpecifier.type == EbtBool || typeSpecifier.type == EbtInt)) (typeSpecifier.type == EbtBool || typeSpecifier.type == EbtInt))
{
error(typeSpecifier.line, "cannot be bool or int", getQualifierString(qualifier));
recover();
}
}
else
{ {
error(typeSpecifier.line, "cannot be bool or int", getQualifierString(qualifier)); if (qualifier == EvqAttribute && typeSpecifier.type == EbtBool)
recover(); {
error(typeSpecifier.line, "cannot be bool", getQualifierString(qualifier));
recover();
}
if ((qualifier == EvqVaryingIn || qualifier == EvqVaryingOut) && typeSpecifier.type == EbtBool)
{
error(typeSpecifier.line, "cannot be bool", getQualifierString(qualifier));
recover();
}
} }
return returnType; return returnType;
......
...@@ -223,14 +223,6 @@ primary_expression ...@@ -223,14 +223,6 @@ primary_expression
$$ = $1; $$ = $1;
} }
| INTCONSTANT { | INTCONSTANT {
//
// INT_TYPE is only 16-bit plus sign bit for vertex/fragment shaders,
// check for overflow for constants
//
if (abs($1.i) >= (1 << 16)) {
context->error($1.line, " integer constant overflow", "");
context->recover();
}
ConstantUnion *unionArray = new ConstantUnion[1]; ConstantUnion *unionArray = new ConstantUnion[1];
unionArray->setIConst($1.i); unionArray->setIConst($1.i);
$$ = context->intermediate.addConstantUnion(unionArray, TType(EbtInt, EbpUndefined, EvqConst), $1.line); $$ = context->intermediate.addConstantUnion(unionArray, TType(EbtInt, EbpUndefined, EvqConst), $1.line);
......
...@@ -726,29 +726,29 @@ static const yytype_int16 yyrhs[] = ...@@ -726,29 +726,29 @@ static const yytype_int16 yyrhs[] =
/* YYRLINE[YYN] -- source line where rule number YYN was defined. */ /* YYRLINE[YYN] -- source line where rule number YYN was defined. */
static const yytype_uint16 yyrline[] = static const yytype_uint16 yyrline[] =
{ {
0, 187, 187, 222, 225, 238, 243, 248, 254, 257, 0, 187, 187, 222, 225, 230, 235, 240, 246, 249,
260, 263, 266, 276, 289, 297, 397, 400, 408, 412, 252, 255, 258, 268, 281, 289, 389, 392, 400, 404,
419, 423, 430, 436, 445, 453, 508, 515, 525, 528, 411, 415, 422, 428, 437, 445, 500, 507, 517, 520,
538, 548, 569, 570, 571, 576, 577, 586, 598, 599, 530, 540, 561, 562, 563, 568, 569, 578, 590, 591,
607, 618, 622, 623, 633, 643, 653, 666, 667, 677, 599, 610, 614, 615, 625, 635, 645, 658, 659, 669,
690, 694, 698, 702, 703, 716, 717, 730, 731, 744, 682, 686, 690, 694, 695, 708, 709, 722, 723, 736,
745, 762, 763, 776, 777, 778, 779, 780, 784, 787, 737, 754, 755, 768, 769, 770, 771, 772, 776, 779,
798, 806, 814, 841, 846, 857, 861, 865, 872, 910, 790, 798, 806, 833, 838, 849, 853, 857, 864, 902,
913, 920, 928, 949, 970, 981, 1010, 1015, 1025, 1030, 905, 912, 920, 941, 962, 973, 1002, 1007, 1017, 1022,
1040, 1043, 1046, 1049, 1055, 1062, 1065, 1087, 1105, 1129, 1032, 1035, 1038, 1041, 1047, 1054, 1057, 1079, 1097, 1121,
1152, 1156, 1174, 1182, 1214, 1234, 1323, 1332, 1338, 1342, 1144, 1148, 1166, 1174, 1206, 1226, 1315, 1324, 1330, 1334,
1349, 1355, 1362, 1371, 1380, 1383, 1419, 1429, 1433, 1438, 1341, 1347, 1354, 1363, 1372, 1375, 1411, 1421, 1425, 1430,
1443, 1448, 1453, 1462, 1472, 1479, 1482, 1485, 1491, 1494, 1435, 1440, 1445, 1454, 1464, 1471, 1474, 1477, 1483, 1486,
1509, 1513, 1517, 1521, 1530, 1535, 1540, 1545, 1550, 1555, 1501, 1505, 1509, 1513, 1522, 1527, 1532, 1537, 1542, 1547,
1560, 1565, 1570, 1575, 1581, 1587, 1593, 1598, 1603, 1608, 1552, 1557, 1562, 1567, 1573, 1579, 1585, 1590, 1595, 1600,
1613, 1618, 1623, 1628, 1633, 1642, 1651, 1656, 1669, 1669, 1605, 1610, 1615, 1620, 1625, 1634, 1643, 1648, 1661, 1661,
1672, 1672, 1678, 1681, 1696, 1699, 1707, 1711, 1717, 1725, 1664, 1664, 1670, 1673, 1688, 1691, 1699, 1703, 1709, 1717,
1741, 1745, 1749, 1750, 1756, 1757, 1758, 1759, 1760, 1764, 1733, 1737, 1741, 1742, 1748, 1749, 1750, 1751, 1752, 1756,
1765, 1765, 1765, 1775, 1776, 1780, 1780, 1781, 1781, 1786, 1757, 1757, 1757, 1767, 1768, 1772, 1772, 1773, 1773, 1778,
1789, 1799, 1802, 1808, 1809, 1813, 1821, 1825, 1835, 1840, 1781, 1791, 1794, 1800, 1801, 1805, 1813, 1817, 1827, 1832,
1857, 1857, 1862, 1862, 1869, 1869, 1877, 1880, 1886, 1889, 1849, 1849, 1854, 1854, 1861, 1861, 1869, 1872, 1878, 1881,
1895, 1899, 1906, 1913, 1920, 1927, 1938, 1947, 1951, 1958, 1887, 1891, 1898, 1905, 1912, 1919, 1930, 1939, 1943, 1950,
1961, 1967, 1967 1953, 1959, 1959
}; };
#endif #endif
...@@ -2298,14 +2298,6 @@ yyreduce: ...@@ -2298,14 +2298,6 @@ yyreduce:
case 4: case 4:
{ {
//
// INT_TYPE is only 16-bit plus sign bit for vertex/fragment shaders,
// check for overflow for constants
//
if (abs((yyvsp[(1) - (1)].lex).i) >= (1 << 16)) {
context->error((yyvsp[(1) - (1)].lex).line, " integer constant overflow", "");
context->recover();
}
ConstantUnion *unionArray = new ConstantUnion[1]; ConstantUnion *unionArray = new ConstantUnion[1];
unionArray->setIConst((yyvsp[(1) - (1)].lex).i); unionArray->setIConst((yyvsp[(1) - (1)].lex).i);
(yyval.interm.intermTypedNode) = context->intermediate.addConstantUnion(unionArray, TType(EbtInt, EbpUndefined, EvqConst), (yyvsp[(1) - (1)].lex).line); (yyval.interm.intermTypedNode) = context->intermediate.addConstantUnion(unionArray, TType(EbtInt, EbpUndefined, EvqConst), (yyvsp[(1) - (1)].lex).line);
......
...@@ -46,6 +46,10 @@ namespace gl_d3d ...@@ -46,6 +46,10 @@ namespace gl_d3d
case GL_FLOAT_VEC2: return "float2"; case GL_FLOAT_VEC2: return "float2";
case GL_FLOAT_VEC3: return "float3"; case GL_FLOAT_VEC3: return "float3";
case GL_FLOAT_VEC4: return "float4"; case GL_FLOAT_VEC4: return "float4";
case GL_INT: return "int";
case GL_INT_VEC2: return "int2";
case GL_INT_VEC3: return "int3";
case GL_INT_VEC4: return "int4";
case GL_FLOAT_MAT2: return "float2x2"; case GL_FLOAT_MAT2: return "float2x2";
case GL_FLOAT_MAT3: return "float3x3"; case GL_FLOAT_MAT3: return "float3x3";
case GL_FLOAT_MAT4: return "float4x4"; case GL_FLOAT_MAT4: return "float4x4";
...@@ -1497,8 +1501,9 @@ std::string ProgramBinary::generateVaryingHLSL(FragmentShader *fragmentShader, c ...@@ -1497,8 +1501,9 @@ std::string ProgramBinary::generateVaryingHLSL(FragmentShader *fragmentShader, c
} }
std::string n = str(varying->reg + i * rows + j); std::string n = str(varying->reg + i * rows + j);
std::string typeString = gl_d3d::TypeString(UniformComponentType(transposedType)) + str(VariableColumnCount(transposedType));
varyingHLSL += "float" + str(VariableColumnCount(transposedType)) + " v" + n + " : " + varyingSemantic + n + ";\n"; varyingHLSL += typeString + " v" + n + " : " + varyingSemantic + n + ";\n";
} }
} }
} }
......
...@@ -517,6 +517,22 @@ GLenum Shader::parseType(const std::string &type) ...@@ -517,6 +517,22 @@ GLenum Shader::parseType(const std::string &type)
{ {
return GL_FLOAT_MAT4x3; return GL_FLOAT_MAT4x3;
} }
else if (type == "int")
{
return GL_INT;
}
else if (type == "int2")
{
return GL_INT_VEC2;
}
else if (type == "int3")
{
return GL_INT_VEC3;
}
else if (type == "int4")
{
return GL_INT_VEC4;
}
else UNREACHABLE(); else UNREACHABLE();
return GL_NONE; return GL_NONE;
...@@ -534,12 +550,16 @@ static void makeVaryingPriorityMap() ...@@ -534,12 +550,16 @@ static void makeVaryingPriorityMap()
varyingPriorities[GL_FLOAT_MAT4x2] = 40; varyingPriorities[GL_FLOAT_MAT4x2] = 40;
varyingPriorities[GL_FLOAT_MAT2] = 50; varyingPriorities[GL_FLOAT_MAT2] = 50;
varyingPriorities[GL_FLOAT_VEC4] = 60; varyingPriorities[GL_FLOAT_VEC4] = 60;
varyingPriorities[GL_INT_VEC4] = 61;
varyingPriorities[GL_FLOAT_MAT3] = 70; varyingPriorities[GL_FLOAT_MAT3] = 70;
varyingPriorities[GL_FLOAT_MAT2x3] = 80; varyingPriorities[GL_FLOAT_MAT2x3] = 80;
varyingPriorities[GL_FLOAT_MAT3x2] = 90; varyingPriorities[GL_FLOAT_MAT3x2] = 90;
varyingPriorities[GL_FLOAT_VEC3] = 100; varyingPriorities[GL_FLOAT_VEC3] = 100;
varyingPriorities[GL_INT_VEC3] = 101;
varyingPriorities[GL_FLOAT_VEC2] = 110; varyingPriorities[GL_FLOAT_VEC2] = 110;
varyingPriorities[GL_INT_VEC2] = 111;
varyingPriorities[GL_FLOAT] = 120; varyingPriorities[GL_FLOAT] = 120;
varyingPriorities[GL_INT] = 125;
} }
// true if varying x has a higher priority in packing than y // 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