Implement shader compiler support for uint scalars.
Bug 19331817
Change-Id: Ie901756ef4fdbab1dfa6ae01c77104fc84de247f
Reviewed-on: https://swiftshader-review.googlesource.com/2312
Reviewed-by: Alexis Hétu <sugoi@google.com>
Reviewed-by: Nicolas Capens <capn@google.com>
Tested-by: Nicolas Capens <capn@google.com>
diff --git a/src/OpenGL/compiler/ParseHelper.cpp b/src/OpenGL/compiler/ParseHelper.cpp
index b1df907..8e6e3a0 100644
--- a/src/OpenGL/compiler/ParseHelper.cpp
+++ b/src/OpenGL/compiler/ParseHelper.cpp
@@ -391,7 +391,7 @@
//
bool TParseContext::integerErrorCheck(TIntermTyped* node, const char* token)
{
- if (node->getBasicType() == EbtInt && node->getNominalSize() == 1)
+ if (node->isScalarInt())
return false;
error(node->getLine(), "integer expression required", token);
@@ -657,17 +657,35 @@
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;