Fix allowing fragment shader invariant declarations.
Bug 18732025
Change-Id: I8a3024327533c3e6db72248caafc5e618808edf5
Reviewed-on: https://swiftshader-review.googlesource.com/1630
Tested-by: Nicolas Capens <nicolascapens@google.com>
Reviewed-by: Alexis Hétu <sugoi@google.com>
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
diff --git a/src/OpenGL/compiler/OutputASM.cpp b/src/OpenGL/compiler/OutputASM.cpp
index c3e08e2..6597507 100644
--- a/src/OpenGL/compiler/OutputASM.cpp
+++ b/src/OpenGL/compiler/OutputASM.cpp
@@ -154,11 +154,14 @@
void OutputASM::visitSymbol(TIntermSymbol *symbol)
{
+ // Vertex varyings don't have to be actively used to successfully link
+ // against pixel shaders that use them. So make sure they're declared.
if(symbol->getQualifier() == EvqVaryingOut || symbol->getQualifier() == EvqInvariantVaryingOut)
{
- // Vertex varyings don't have to be actively used to successfully link
- // against pixel shaders that use them. So make sure they're declared.
- declareVarying(symbol, -1);
+ if(symbol->getBasicType() != EbtInvariant) // Typeless declarations are not new varyings
+ {
+ declareVarying(symbol, -1);
+ }
}
}
diff --git a/src/OpenGL/compiler/glslang.y b/src/OpenGL/compiler/glslang.y
index eca0478..9d307dd 100644
--- a/src/OpenGL/compiler/glslang.y
+++ b/src/OpenGL/compiler/glslang.y
@@ -1363,7 +1363,6 @@
}
}
| INVARIANT IDENTIFIER {
- VERTEX_ONLY("invariant declaration", $1.line);
if (context->globalErrorCheck($1.line, context->symbolTable.atGlobalLevel(), "invariant varying"))
context->recover();
$$.type.setBasic(EbtInvariant, EvqInvariantVaryingOut, $2.line);
diff --git a/src/OpenGL/compiler/glslang_tab.cpp b/src/OpenGL/compiler/glslang_tab.cpp
index 9d6085f..d4c09b4 100644
--- a/src/OpenGL/compiler/glslang_tab.cpp
+++ b/src/OpenGL/compiler/glslang_tab.cpp
@@ -669,17 +669,17 @@
953, 961, 988, 993, 1003, 1041, 1044, 1051, 1059, 1080,
1101, 1112, 1141, 1146, 1156, 1161, 1171, 1174, 1177, 1180,
1186, 1193, 1196, 1218, 1236, 1260, 1283, 1287, 1305, 1313,
- 1345, 1365, 1454, 1463, 1486, 1489, 1495, 1503, 1511, 1519,
- 1529, 1536, 1539, 1542, 1548, 1551, 1566, 1570, 1574, 1578,
- 1587, 1592, 1597, 1602, 1607, 1612, 1617, 1622, 1627, 1632,
- 1638, 1644, 1650, 1655, 1660, 1669, 1674, 1687, 1687, 1701,
- 1701, 1710, 1713, 1728, 1764, 1768, 1774, 1782, 1798, 1802,
- 1806, 1807, 1813, 1814, 1815, 1816, 1817, 1821, 1822, 1822,
- 1822, 1832, 1833, 1837, 1837, 1838, 1838, 1843, 1846, 1856,
- 1859, 1865, 1866, 1870, 1878, 1882, 1892, 1897, 1914, 1914,
- 1919, 1919, 1926, 1926, 1934, 1937, 1943, 1946, 1952, 1956,
- 1963, 1970, 1977, 1984, 1995, 2004, 2008, 2015, 2018, 2024,
- 2024
+ 1345, 1365, 1453, 1462, 1485, 1488, 1494, 1502, 1510, 1518,
+ 1528, 1535, 1538, 1541, 1547, 1550, 1565, 1569, 1573, 1577,
+ 1586, 1591, 1596, 1601, 1606, 1611, 1616, 1621, 1626, 1631,
+ 1637, 1643, 1649, 1654, 1659, 1668, 1673, 1686, 1686, 1700,
+ 1700, 1709, 1712, 1727, 1763, 1767, 1773, 1781, 1797, 1801,
+ 1805, 1806, 1812, 1813, 1814, 1815, 1816, 1820, 1821, 1821,
+ 1821, 1831, 1832, 1836, 1836, 1837, 1837, 1842, 1845, 1855,
+ 1858, 1864, 1865, 1869, 1877, 1881, 1891, 1896, 1913, 1913,
+ 1918, 1918, 1925, 1925, 1933, 1936, 1942, 1945, 1951, 1955,
+ 1962, 1969, 1976, 1983, 1994, 2003, 2007, 2014, 2017, 2023,
+ 2023
};
#endif
@@ -3517,7 +3517,6 @@
case 101:
{
- VERTEX_ONLY("invariant declaration", (yyvsp[(1) - (2)].lex).line);
if (context->globalErrorCheck((yyvsp[(1) - (2)].lex).line, context->symbolTable.atGlobalLevel(), "invariant varying"))
context->recover();
(yyval.interm).type.setBasic(EbtInvariant, EvqInvariantVaryingOut, (yyvsp[(2) - (2)].lex).line);
diff --git a/src/OpenGL/libGLESv2/libGLESv2.cpp b/src/OpenGL/libGLESv2/libGLESv2.cpp
index dae58e4..cb2df49 100644
--- a/src/OpenGL/libGLESv2/libGLESv2.cpp
+++ b/src/OpenGL/libGLESv2/libGLESv2.cpp
@@ -507,8 +507,8 @@
}
void GL_APIENTRY glBufferData(GLenum target, GLsizeiptr size, const GLvoid* data, GLenum usage)
-{
- size = static_cast<GLint>(size); // Work around issues with some 64-bit applications
+{
+ size = static_cast<GLint>(size); // Work around issues with some 64-bit applications
TRACE("(GLenum target = 0x%X, GLsizeiptr size = %d, const GLvoid* data = 0x%0.8p, GLenum usage = %d)",
target, size, data, usage);
@@ -556,9 +556,9 @@
}
void GL_APIENTRY glBufferSubData(GLenum target, GLintptr offset, GLsizeiptr size, const GLvoid* data)
-{
- size = static_cast<GLint>(size); // Work around issues with some 64-bit applications
- offset = static_cast<GLint>(offset);
+{
+ size = static_cast<GLint>(size); // Work around issues with some 64-bit applications
+ offset = static_cast<GLint>(offset);
TRACE("(GLenum target = 0x%X, GLintptr offset = %d, GLsizeiptr size = %d, const GLvoid* data = 0x%0.8p)",
target, offset, size, data);