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