Scanner: Many int16 and float16 fixes, including performance.
- fixes #1209, addresses most of #1187 - only query feature availability on seeing the feature (was doing it for every single token) - correct case-sensitive checks for multi-character suffixes
This commit is contained in:
parent
c043aadd25
commit
9c6f8cc29b
@ -52,8 +52,10 @@ ERROR: 0:209: 'assign' : cannot convert from ' const float' to ' temp 4-compone
|
|||||||
ERROR: 0:212: 'sampler2DRect' : Reserved word.
|
ERROR: 0:212: 'sampler2DRect' : Reserved word.
|
||||||
ERROR: 0:244: ':' : wrong operand types: no operation ':' exists that takes a left-hand operand of type ' global void' and a right operand of type ' const int' (or there is no acceptable conversion)
|
ERROR: 0:244: ':' : wrong operand types: no operation ':' exists that takes a left-hand operand of type ' global void' and a right operand of type ' const int' (or there is no acceptable conversion)
|
||||||
ERROR: 0:245: ':' : wrong operand types: no operation ':' exists that takes a left-hand operand of type ' const int' and a right operand of type ' global void' (or there is no acceptable conversion)
|
ERROR: 0:245: ':' : wrong operand types: no operation ':' exists that takes a left-hand operand of type ' const int' and a right operand of type ' global void' (or there is no acceptable conversion)
|
||||||
|
ERROR: 0:248: 'shader half float' : required extension not requested: GL_AMD_gpu_shader_half_float
|
||||||
|
ERROR: 0:248: 'half floating-point suffix' : not supported with this profile: none
|
||||||
ERROR: 0:248: '' : syntax error, unexpected IDENTIFIER, expecting COMMA or SEMICOLON
|
ERROR: 0:248: '' : syntax error, unexpected IDENTIFIER, expecting COMMA or SEMICOLON
|
||||||
ERROR: 54 compilation errors. No code generated.
|
ERROR: 56 compilation errors. No code generated.
|
||||||
|
|
||||||
|
|
||||||
Shader version: 120
|
Shader version: 120
|
||||||
|
@ -103,17 +103,6 @@ int TPpContext::lFloatConst(int len, int ch, TPpToken* ppToken)
|
|||||||
{
|
{
|
||||||
bool HasDecimalOrExponent = false;
|
bool HasDecimalOrExponent = false;
|
||||||
int isDouble = 0;
|
int isDouble = 0;
|
||||||
bool generateFloat16 = false;
|
|
||||||
bool acceptFloat16 = parseContext.intermediate.getSource() == EShSourceHlsl;
|
|
||||||
bool isFloat16 = false;
|
|
||||||
bool requireHF = false;
|
|
||||||
#ifdef AMD_EXTENSIONS
|
|
||||||
if (parseContext.extensionTurnedOn(E_GL_AMD_gpu_shader_half_float)) {
|
|
||||||
acceptFloat16 = true;
|
|
||||||
generateFloat16 = true;
|
|
||||||
requireHF = true;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
const auto saveName = [&](int ch) {
|
const auto saveName = [&](int ch) {
|
||||||
if (len <= MaxTokenLength)
|
if (len <= MaxTokenLength)
|
||||||
@ -182,7 +171,7 @@ int TPpContext::lFloatConst(int len, int ch, TPpToken* ppToken)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Suffix:
|
// Suffix:
|
||||||
|
bool isFloat16 = false;
|
||||||
if (ch == 'l' || ch == 'L') {
|
if (ch == 'l' || ch == 'L') {
|
||||||
parseContext.doubleCheck(ppToken->loc, "double floating-point suffix");
|
parseContext.doubleCheck(ppToken->loc, "double floating-point suffix");
|
||||||
if (! HasDecimalOrExponent)
|
if (! HasDecimalOrExponent)
|
||||||
@ -196,14 +185,14 @@ int TPpContext::lFloatConst(int len, int ch, TPpToken* ppToken)
|
|||||||
saveName(ch2);
|
saveName(ch2);
|
||||||
isDouble = 1;
|
isDouble = 1;
|
||||||
}
|
}
|
||||||
} else if (acceptFloat16 && (ch == 'h' || ch == 'H')) {
|
} else if (ch == 'h' || ch == 'H') {
|
||||||
#ifdef AMD_EXTENSIONS
|
#ifdef AMD_EXTENSIONS
|
||||||
if (generateFloat16)
|
if (parseContext.intermediate.getSource() == EShSourceGlsl)
|
||||||
parseContext.float16Check(ppToken->loc, "half floating-point suffix");
|
parseContext.float16Check(ppToken->loc, "half floating-point suffix");
|
||||||
#endif
|
#endif
|
||||||
if (!HasDecimalOrExponent)
|
if (!HasDecimalOrExponent)
|
||||||
parseContext.ppError(ppToken->loc, "float literal needs a decimal point or exponent", "", "");
|
parseContext.ppError(ppToken->loc, "float literal needs a decimal point or exponent", "", "");
|
||||||
if (requireHF) {
|
if (parseContext.intermediate.getSource() == EShSourceGlsl) {
|
||||||
int ch2 = getChar();
|
int ch2 = getChar();
|
||||||
if (ch2 != 'f' && ch2 != 'F') {
|
if (ch2 != 'f' && ch2 != 'F') {
|
||||||
ungetChar();
|
ungetChar();
|
||||||
@ -211,11 +200,11 @@ int TPpContext::lFloatConst(int len, int ch, TPpToken* ppToken)
|
|||||||
} else {
|
} else {
|
||||||
saveName(ch);
|
saveName(ch);
|
||||||
saveName(ch2);
|
saveName(ch2);
|
||||||
isFloat16 = generateFloat16;
|
isFloat16 = true;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
saveName(ch);
|
saveName(ch);
|
||||||
isFloat16 = generateFloat16;
|
isFloat16 = false;
|
||||||
}
|
}
|
||||||
} else if (ch == 'f' || ch == 'F') {
|
} else if (ch == 'f' || ch == 'F') {
|
||||||
parseContext.profileRequires(ppToken->loc, EEsProfile, 300, nullptr, "floating-point suffix");
|
parseContext.profileRequires(ppToken->loc, EEsProfile, 300, nullptr, "floating-point suffix");
|
||||||
@ -333,18 +322,10 @@ int TPpContext::tStringInput::scan(TPpToken* ppToken)
|
|||||||
int ch = 0;
|
int ch = 0;
|
||||||
int ii = 0;
|
int ii = 0;
|
||||||
unsigned long long ival = 0;
|
unsigned long long ival = 0;
|
||||||
#ifdef AMD_EXTENSIONS
|
|
||||||
bool enableInt16 = pp->parseContext.version >= 450 && pp->parseContext.extensionTurnedOn(E_GL_AMD_gpu_shader_int16);
|
|
||||||
#endif
|
|
||||||
bool acceptHalf = pp->parseContext.intermediate.getSource() == EShSourceHlsl;
|
|
||||||
#ifdef AMD_EXTENSIONS
|
|
||||||
if (pp->parseContext.extensionTurnedOn(E_GL_AMD_gpu_shader_half_float))
|
|
||||||
acceptHalf = true;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
const auto floatingPointChar = [&](int ch) { return ch == '.' || ch == 'e' || ch == 'E' ||
|
const auto floatingPointChar = [&](int ch) { return ch == '.' || ch == 'e' || ch == 'E' ||
|
||||||
ch == 'f' || ch == 'F' ||
|
ch == 'f' || ch == 'F' ||
|
||||||
(acceptHalf && (ch == 'h' || ch == 'H')); };
|
ch == 'h' || ch == 'H'; };
|
||||||
|
|
||||||
ppToken->ival = 0;
|
ppToken->ival = 0;
|
||||||
ppToken->i64val = 0;
|
ppToken->i64val = 0;
|
||||||
@ -461,22 +442,22 @@ int TPpContext::tStringInput::scan(TPpToken* ppToken)
|
|||||||
ungetch();
|
ungetch();
|
||||||
|
|
||||||
#ifdef AMD_EXTENSIONS
|
#ifdef AMD_EXTENSIONS
|
||||||
if (enableInt16) {
|
nextCh = getch();
|
||||||
int nextCh = getch();
|
if ((nextCh == 's' || nextCh == 'S') &&
|
||||||
if ((ch == 'u' && nextCh == 's') || (ch == 'U' && nextCh == 'S')) {
|
pp->parseContext.intermediate.getSource() == EShSourceGlsl) {
|
||||||
if (len < MaxTokenLength)
|
if (len < MaxTokenLength)
|
||||||
ppToken->name[len++] = (char)nextCh;
|
ppToken->name[len++] = (char)nextCh;
|
||||||
isInt16 = true;
|
isInt16 = true;
|
||||||
} else
|
} else
|
||||||
ungetch();
|
ungetch();
|
||||||
}
|
|
||||||
#endif
|
#endif
|
||||||
} else if (ch == 'l' || ch == 'L') {
|
} else if (ch == 'l' || ch == 'L') {
|
||||||
if (len < MaxTokenLength)
|
if (len < MaxTokenLength)
|
||||||
ppToken->name[len++] = (char)ch;
|
ppToken->name[len++] = (char)ch;
|
||||||
isInt64 = true;
|
isInt64 = true;
|
||||||
#ifdef AMD_EXTENSIONS
|
#ifdef AMD_EXTENSIONS
|
||||||
} else if (enableInt16 && (ch == 's' || ch == 'S')) {
|
} else if ((ch == 's' || ch == 'S') &&
|
||||||
|
pp->parseContext.intermediate.getSource() == EShSourceGlsl) {
|
||||||
if (len < MaxTokenLength)
|
if (len < MaxTokenLength)
|
||||||
ppToken->name[len++] = (char)ch;
|
ppToken->name[len++] = (char)ch;
|
||||||
isInt16 = true;
|
isInt16 = true;
|
||||||
@ -485,17 +466,21 @@ int TPpContext::tStringInput::scan(TPpToken* ppToken)
|
|||||||
ungetch();
|
ungetch();
|
||||||
ppToken->name[len] = '\0';
|
ppToken->name[len] = '\0';
|
||||||
|
|
||||||
if (isInt64) {
|
if (isInt64 && pp->parseContext.intermediate.getSource() == EShSourceGlsl) {
|
||||||
if (pp->parseContext.intermediate.getSource() == EShSourceGlsl) {
|
|
||||||
pp->parseContext.requireProfile(ppToken->loc, ~EEsProfile,
|
pp->parseContext.requireProfile(ppToken->loc, ~EEsProfile,
|
||||||
"64-bit hexadecimal literal");
|
"64-bit hexadecimal literal");
|
||||||
pp->parseContext.profileRequires(ppToken->loc, ~EEsProfile, 0, E_GL_ARB_gpu_shader_int64,
|
pp->parseContext.profileRequires(ppToken->loc, ~EEsProfile, 0, E_GL_ARB_gpu_shader_int64,
|
||||||
"64-bit hexadecimal literal");
|
"64-bit hexadecimal literal");
|
||||||
}
|
|
||||||
ppToken->i64val = ival;
|
ppToken->i64val = ival;
|
||||||
return isUnsigned ? PpAtomConstUint64 : PpAtomConstInt64;
|
return isUnsigned ? PpAtomConstUint64 : PpAtomConstInt64;
|
||||||
#ifdef AMD_EXTENSIONS
|
#ifdef AMD_EXTENSIONS
|
||||||
} else if (isInt16) {
|
} else if (isInt16) {
|
||||||
|
if (pp->parseContext.intermediate.getSource() == EShSourceGlsl) {
|
||||||
|
pp->parseContext.requireProfile(ppToken->loc, ~EEsProfile,
|
||||||
|
"16-bit hexadecimal literal");
|
||||||
|
pp->parseContext.profileRequires(ppToken->loc, ~EEsProfile, 0, E_GL_AMD_gpu_shader_int16,
|
||||||
|
"16-bit hexadecimal literal");
|
||||||
|
}
|
||||||
ppToken->ival = (int)ival;
|
ppToken->ival = (int)ival;
|
||||||
return isUnsigned ? PpAtomConstUint16 : PpAtomConstInt16;
|
return isUnsigned ? PpAtomConstUint16 : PpAtomConstInt16;
|
||||||
#endif
|
#endif
|
||||||
@ -559,7 +544,7 @@ int TPpContext::tStringInput::scan(TPpToken* ppToken)
|
|||||||
isUnsigned = true;
|
isUnsigned = true;
|
||||||
|
|
||||||
int nextCh = getch();
|
int nextCh = getch();
|
||||||
if ((ch == 'u' && nextCh == 'l') || (ch == 'U' && nextCh == 'L')) {
|
if (nextCh == 'l' || nextCh == 'L') {
|
||||||
if (len < MaxTokenLength)
|
if (len < MaxTokenLength)
|
||||||
ppToken->name[len++] = (char)nextCh;
|
ppToken->name[len++] = (char)nextCh;
|
||||||
isInt64 = true;
|
isInt64 = true;
|
||||||
@ -567,22 +552,22 @@ int TPpContext::tStringInput::scan(TPpToken* ppToken)
|
|||||||
ungetch();
|
ungetch();
|
||||||
|
|
||||||
#ifdef AMD_EXTENSIONS
|
#ifdef AMD_EXTENSIONS
|
||||||
if (enableInt16) {
|
nextCh = getch();
|
||||||
int nextCh = getch();
|
if ((nextCh == 's' || nextCh == 'S') &&
|
||||||
if ((ch == 'u' && nextCh == 's') || (ch == 'U' && nextCh == 'S')) {
|
pp->parseContext.intermediate.getSource() == EShSourceGlsl) {
|
||||||
if (len < MaxTokenLength)
|
if (len < MaxTokenLength)
|
||||||
ppToken->name[len++] = (char)nextCh;
|
ppToken->name[len++] = (char)nextCh;
|
||||||
isInt16 = true;
|
isInt16 = true;
|
||||||
} else
|
} else
|
||||||
ungetch();
|
ungetch();
|
||||||
}
|
|
||||||
#endif
|
#endif
|
||||||
} else if (ch == 'l' || ch == 'L') {
|
} else if (ch == 'l' || ch == 'L') {
|
||||||
if (len < MaxTokenLength)
|
if (len < MaxTokenLength)
|
||||||
ppToken->name[len++] = (char)ch;
|
ppToken->name[len++] = (char)ch;
|
||||||
isInt64 = true;
|
isInt64 = true;
|
||||||
#ifdef AMD_EXTENSIONS
|
#ifdef AMD_EXTENSIONS
|
||||||
} else if (enableInt16 && (ch == 's' || ch == 'S')) {
|
} else if ((ch == 's' || ch == 'S') &&
|
||||||
|
pp->parseContext.intermediate.getSource() == EShSourceGlsl) {
|
||||||
if (len < MaxTokenLength)
|
if (len < MaxTokenLength)
|
||||||
ppToken->name[len++] = (char)ch;
|
ppToken->name[len++] = (char)ch;
|
||||||
isInt16 = true;
|
isInt16 = true;
|
||||||
@ -597,17 +582,21 @@ int TPpContext::tStringInput::scan(TPpToken* ppToken)
|
|||||||
if (octalOverflow)
|
if (octalOverflow)
|
||||||
pp->parseContext.ppError(ppToken->loc, "octal literal too big", "", "");
|
pp->parseContext.ppError(ppToken->loc, "octal literal too big", "", "");
|
||||||
|
|
||||||
if (isInt64) {
|
if (isInt64 && pp->parseContext.intermediate.getSource() == EShSourceGlsl) {
|
||||||
if (pp->parseContext.intermediate.getSource() == EShSourceGlsl) {
|
|
||||||
pp->parseContext.requireProfile(ppToken->loc, ~EEsProfile,
|
pp->parseContext.requireProfile(ppToken->loc, ~EEsProfile,
|
||||||
"64-bit octal literal");
|
"64-bit octal literal");
|
||||||
pp->parseContext.profileRequires(ppToken->loc, ~EEsProfile, 0, E_GL_ARB_gpu_shader_int64,
|
pp->parseContext.profileRequires(ppToken->loc, ~EEsProfile, 0, E_GL_ARB_gpu_shader_int64,
|
||||||
"64-bit octal literal");
|
"64-bit octal literal");
|
||||||
}
|
|
||||||
ppToken->i64val = ival;
|
ppToken->i64val = ival;
|
||||||
return isUnsigned ? PpAtomConstUint64 : PpAtomConstInt64;
|
return isUnsigned ? PpAtomConstUint64 : PpAtomConstInt64;
|
||||||
#ifdef AMD_EXTENSIONS
|
#ifdef AMD_EXTENSIONS
|
||||||
} else if (isInt16) {
|
} else if (isInt16) {
|
||||||
|
if (pp->parseContext.intermediate.getSource() == EShSourceGlsl) {
|
||||||
|
pp->parseContext.requireProfile(ppToken->loc, ~EEsProfile,
|
||||||
|
"16-bit octal literal");
|
||||||
|
pp->parseContext.profileRequires(ppToken->loc, ~EEsProfile, 0, E_GL_AMD_gpu_shader_int16,
|
||||||
|
"16-bit octal literal");
|
||||||
|
}
|
||||||
ppToken->ival = (int)ival;
|
ppToken->ival = (int)ival;
|
||||||
return isUnsigned ? PpAtomConstUint16 : PpAtomConstInt16;
|
return isUnsigned ? PpAtomConstUint16 : PpAtomConstInt16;
|
||||||
#endif
|
#endif
|
||||||
@ -646,7 +635,7 @@ int TPpContext::tStringInput::scan(TPpToken* ppToken)
|
|||||||
isUnsigned = true;
|
isUnsigned = true;
|
||||||
|
|
||||||
int nextCh = getch();
|
int nextCh = getch();
|
||||||
if ((ch == 'u' && nextCh == 'l') || (ch == 'U' && nextCh == 'L')) {
|
if (nextCh == 'l' || nextCh == 'L') {
|
||||||
if (len < MaxTokenLength)
|
if (len < MaxTokenLength)
|
||||||
ppToken->name[len++] = (char)nextCh;
|
ppToken->name[len++] = (char)nextCh;
|
||||||
isInt64 = true;
|
isInt64 = true;
|
||||||
@ -654,22 +643,22 @@ int TPpContext::tStringInput::scan(TPpToken* ppToken)
|
|||||||
ungetch();
|
ungetch();
|
||||||
|
|
||||||
#ifdef AMD_EXTENSIONS
|
#ifdef AMD_EXTENSIONS
|
||||||
if (enableInt16) {
|
nextCh = getch();
|
||||||
int nextCh = getch();
|
if ((nextCh == 's' || nextCh == 'S') &&
|
||||||
if ((ch == 'u' && nextCh == 's') || (ch == 'U' && nextCh == 'S')) {
|
pp->parseContext.intermediate.getSource() == EShSourceGlsl) {
|
||||||
if (len < MaxTokenLength)
|
if (len < MaxTokenLength)
|
||||||
ppToken->name[len++] = (char)nextCh;
|
ppToken->name[len++] = (char)nextCh;
|
||||||
isInt16 = true;
|
isInt16 = true;
|
||||||
} else
|
} else
|
||||||
ungetch();
|
ungetch();
|
||||||
}
|
|
||||||
#endif
|
#endif
|
||||||
} else if (ch == 'l' || ch == 'L') {
|
} else if (ch == 'l' || ch == 'L') {
|
||||||
if (len < MaxTokenLength)
|
if (len < MaxTokenLength)
|
||||||
ppToken->name[len++] = (char)ch;
|
ppToken->name[len++] = (char)ch;
|
||||||
isInt64 = true;
|
isInt64 = true;
|
||||||
#ifdef AMD_EXTENSIONS
|
#ifdef AMD_EXTENSIONS
|
||||||
} else if (enableInt16 && (ch == 's' || ch == 'S')) {
|
} else if ((ch == 's' || ch == 'S') &&
|
||||||
|
pp->parseContext.intermediate.getSource() == EShSourceGlsl) {
|
||||||
if (len < MaxTokenLength)
|
if (len < MaxTokenLength)
|
||||||
ppToken->name[len++] = (char)ch;
|
ppToken->name[len++] = (char)ch;
|
||||||
isInt16 = true;
|
isInt16 = true;
|
||||||
@ -715,6 +704,12 @@ int TPpContext::tStringInput::scan(TPpToken* ppToken)
|
|||||||
return isUnsigned ? PpAtomConstUint64 : PpAtomConstInt64;
|
return isUnsigned ? PpAtomConstUint64 : PpAtomConstInt64;
|
||||||
#ifdef AMD_EXTENSIONS
|
#ifdef AMD_EXTENSIONS
|
||||||
} else if (isInt16) {
|
} else if (isInt16) {
|
||||||
|
if (pp->parseContext.intermediate.getSource() == EShSourceGlsl) {
|
||||||
|
pp->parseContext.requireProfile(ppToken->loc, ~EEsProfile,
|
||||||
|
"16-bit literal");
|
||||||
|
pp->parseContext.profileRequires(ppToken->loc, ~EEsProfile, 0, E_GL_AMD_gpu_shader_int16,
|
||||||
|
"16-bit literal");
|
||||||
|
}
|
||||||
ppToken->ival = (int)ival;
|
ppToken->ival = (int)ival;
|
||||||
return isUnsigned ? PpAtomConstUint16 : PpAtomConstInt16;
|
return isUnsigned ? PpAtomConstUint16 : PpAtomConstInt16;
|
||||||
#endif
|
#endif
|
||||||
|
Loading…
x
Reference in New Issue
Block a user