Preprocessor: UINT_MAX is translated to constant incorrectly.

This commit is contained in:
Rex Xu 2016-09-06 13:46:12 +08:00
parent cfd7ce87cd
commit 99c4dd16db
5 changed files with 665 additions and 630 deletions

File diff suppressed because it is too large Load Diff

View File

@ -7,12 +7,12 @@ Linked fragment stage:
// Module Version 10000 // Module Version 10000
// Generated by (magic number): 80001 // Generated by (magic number): 80001
// Id's are bound by 207 // Id's are bound by 213
Capability Shader Capability Shader
1: ExtInstImport "GLSL.std.450" 1: ExtInstImport "GLSL.std.450"
MemoryModel Logical GLSL450 MemoryModel Logical GLSL450
EntryPoint Fragment 4 "main" 15 68 77 200 202 204 EntryPoint Fragment 4 "main" 15 68 77 206 208 210
ExecutionMode 4 OriginUpperLeft ExecutionMode 4 OriginUpperLeft
Source ESSL 310 Source ESSL 310
Name 4 "main" Name 4 "main"
@ -33,10 +33,10 @@ Linked fragment stage:
Name 154 "mask2" Name 154 "mask2"
Name 156 "mask3" Name 156 "mask3"
Name 160 "mask4" Name 160 "mask4"
Name 200 "f" Name 206 "f"
Name 202 "v" Name 208 "v"
Name 204 "i" Name 210 "i"
Name 206 "b" Name 212 "b"
Decorate 8(count) RelaxedPrecision Decorate 8(count) RelaxedPrecision
Decorate 12(u) RelaxedPrecision Decorate 12(u) RelaxedPrecision
Decorate 15(t) RelaxedPrecision Decorate 15(t) RelaxedPrecision
@ -138,11 +138,13 @@ Linked fragment stage:
Decorate 196 RelaxedPrecision Decorate 196 RelaxedPrecision
Decorate 197 RelaxedPrecision Decorate 197 RelaxedPrecision
Decorate 198 RelaxedPrecision Decorate 198 RelaxedPrecision
Decorate 200(f) RelaxedPrecision Decorate 202 RelaxedPrecision
Decorate 202(v) RelaxedPrecision Decorate 203 RelaxedPrecision
Decorate 202(v) Flat Decorate 206(f) RelaxedPrecision
Decorate 204(i) RelaxedPrecision Decorate 208(v) RelaxedPrecision
Decorate 204(i) Flat Decorate 208(v) Flat
Decorate 210(i) RelaxedPrecision
Decorate 210(i) Flat
2: TypeVoid 2: TypeVoid
3: TypeFunction 2 3: TypeFunction 2
6: TypeInt 32 1 6: TypeInt 32 1
@ -193,14 +195,16 @@ Linked fragment stage:
155: 10(int) Constant 2576 155: 10(int) Constant 2576
158: 6(int) Constant 4 158: 6(int) Constant 4
161: 10(int) Constant 2737 161: 10(int) Constant 2737
199: TypePointer Input 74(float) 199: 10(int) Constant 4294967295
200(f): 199(ptr) Variable Input 200: TypePointer Output 10(int)
201: TypePointer Input 66(ivec4) 205: TypePointer Input 74(float)
202(v): 201(ptr) Variable Input 206(f): 205(ptr) Variable Input
203: TypePointer Input 6(int) 207: TypePointer Input 66(ivec4)
204(i): 203(ptr) Variable Input 208(v): 207(ptr) Variable Input
205: TypePointer Private 22(bool) 209: TypePointer Input 6(int)
206(b): 205(ptr) Variable Private 210(i): 209(ptr) Variable Input
211: TypePointer Private 22(bool)
212(b): 211(ptr) Variable Private
4(main): 2 Function None 3 4(main): 2 Function None 3
5: Label 5: Label
8(count): 7(ptr) Variable Function 8(count): 7(ptr) Variable Function
@ -434,5 +438,10 @@ Linked fragment stage:
197: 66(ivec4) Load 68(c) 197: 66(ivec4) Load 68(c)
198: 66(ivec4) IAdd 197 196 198: 66(ivec4) IAdd 197 196
Store 68(c) 198 Store 68(c) 198
201: 200(ptr) AccessChain 68(c) 103
202: 10(int) Load 201
203: 10(int) IAdd 202 199
204: 200(ptr) AccessChain 68(c) 103
Store 204 203
Return Return
FunctionEnd FunctionEnd

View File

@ -258,4 +258,7 @@ const uint64_t i_to_u64 = uint64_t(si);
// uint <-> int64 // uint <-> int64
const uint i64_to_u = uint(si64); const uint i64_to_u = uint(si64);
const int64_t u_to_i64 = int64_t(su); const int64_t u_to_i64 = int64_t(su);
#define UINT64_MAX 18446744073709551615ul
uint64_t u64Max = UINT64_MAX;

View File

@ -95,5 +95,8 @@ void main()
if ((mask1 ^ mask4) == 0xA10u) if ((mask1 ^ mask4) == 0xA10u)
count *= 7; // 341413380 count *= 7; // 341413380
c += uvec4(count); c += uvec4(count);
#define UINT_MAX 4294967295u
c.x += UINT_MAX;
} }

View File

@ -224,7 +224,6 @@ int TPpContext::ReadToken(TokenStream *pTok, TPpToken *ppToken)
ppToken->dval = atof(ppToken->name); ppToken->dval = atof(ppToken->name);
break; break;
case PpAtomConstInt: case PpAtomConstInt:
case PpAtomConstUint:
if (len > 0 && tokenText[0] == '0') { if (len > 0 && tokenText[0] == '0') {
if (len > 1 && (tokenText[1] == 'x' || tokenText[1] == 'X')) if (len > 1 && (tokenText[1] == 'x' || tokenText[1] == 'X'))
ppToken->ival = strtol(ppToken->name, 0, 16); ppToken->ival = strtol(ppToken->name, 0, 16);
@ -233,8 +232,16 @@ int TPpContext::ReadToken(TokenStream *pTok, TPpToken *ppToken)
} else } else
ppToken->ival = atoi(ppToken->name); ppToken->ival = atoi(ppToken->name);
break; break;
case PpAtomConstUint:
if (len > 0 && tokenText[0] == '0') {
if (len > 1 && (tokenText[1] == 'x' || tokenText[1] == 'X'))
ppToken->ival = (int)strtoul(ppToken->name, 0, 16);
else
ppToken->ival = (int)strtoul(ppToken->name, 0, 8);
} else
ppToken->ival = (int)strtoul(ppToken->name, 0, 10);
break;
case PpAtomConstInt64: case PpAtomConstInt64:
case PpAtomConstUint64:
if (len > 0 && tokenText[0] == '0') { if (len > 0 && tokenText[0] == '0') {
if (len > 1 && (tokenText[1] == 'x' || tokenText[1] == 'X')) if (len > 1 && (tokenText[1] == 'x' || tokenText[1] == 'X'))
ppToken->i64val = strtoll(ppToken->name, nullptr, 16); ppToken->i64val = strtoll(ppToken->name, nullptr, 16);
@ -243,6 +250,15 @@ int TPpContext::ReadToken(TokenStream *pTok, TPpToken *ppToken)
} else } else
ppToken->i64val = atoll(ppToken->name); ppToken->i64val = atoll(ppToken->name);
break; break;
case PpAtomConstUint64:
if (len > 0 && tokenText[0] == '0') {
if (len > 1 && (tokenText[1] == 'x' || tokenText[1] == 'X'))
ppToken->i64val = (long long)strtoull(ppToken->name, nullptr, 16);
else
ppToken->i64val = (long long)strtoull(ppToken->name, nullptr, 8);
} else
ppToken->i64val = (long long)strtoull(ppToken->name, 0, 10);
break;
} }
} }