HLSL: Correct some mistakes for min16 types

- Add missing constructor ops to support float16/int16/uint16 types
- Allow half float literals
- Correct two errors of double literal parse in HLSL: extension check and
  postfix
This commit is contained in:
Rex Xu 2018-03-12 23:15:11 +08:00
parent 845860d565
commit a00e51b5b2
5 changed files with 50 additions and 9 deletions

View file

@ -174,16 +174,22 @@ int TPpContext::lFloatConst(int len, int ch, TPpToken* ppToken)
// Suffix:
bool isFloat16 = false;
if (ch == 'l' || ch == 'L') {
parseContext.doubleCheck(ppToken->loc, "double floating-point suffix");
if (parseContext.intermediate.getSource() == EShSourceGlsl)
parseContext.doubleCheck(ppToken->loc, "double floating-point suffix");
if (! HasDecimalOrExponent)
parseContext.ppError(ppToken->loc, "float literal needs a decimal point or exponent", "", "");
int ch2 = getChar();
if (ch2 != 'f' && ch2 != 'F') {
ungetChar();
ungetChar();
} else {
if (parseContext.intermediate.getSource() == EShSourceGlsl) {
int ch2 = getChar();
if (ch2 != 'f' && ch2 != 'F') {
ungetChar();
ungetChar();
} else {
saveName(ch);
saveName(ch2);
isDouble = 1;
}
} else if (parseContext.intermediate.getSource() == EShSourceHlsl) {
saveName(ch);
saveName(ch2);
isDouble = 1;
}
} else if (ch == 'h' || ch == 'H') {
@ -201,9 +207,9 @@ int TPpContext::lFloatConst(int len, int ch, TPpToken* ppToken)
saveName(ch2);
isFloat16 = true;
}
} else {
} else if (parseContext.intermediate.getSource() == EShSourceHlsl) {
saveName(ch);
isFloat16 = false;
isFloat16 = true;
}
} else if (ch == 'f' || ch == 'F') {
parseContext.profileRequires(ppToken->loc, EEsProfile, 300, nullptr, "floating-point suffix");