Merge pull request #420 from steve-lunarg/uint-literal-fix
HLSL: allow uint literals, and add test for numeric suffixes
This commit is contained in:
commit
080fbe9615
181
Test/baseResults/hlsl.numericsuffixes.frag.out
Normal file
181
Test/baseResults/hlsl.numericsuffixes.frag.out
Normal file
@ -0,0 +1,181 @@
|
||||
hlsl.numericsuffixes.frag
|
||||
Shader version: 450
|
||||
gl_FragCoord origin is upper left
|
||||
0:? Sequence
|
||||
0:21 Function Definition: main( (global structure{temp 4-component vector of float color})
|
||||
0:5 Function Parameters:
|
||||
0:? Sequence
|
||||
0:7 Sequence
|
||||
0:7 move second child to first child (temp float)
|
||||
0:7 'r00' (temp float)
|
||||
0:7 Constant:
|
||||
0:7 1.000000
|
||||
0:8 Sequence
|
||||
0:8 move second child to first child (temp uint)
|
||||
0:8 'r01' (temp uint)
|
||||
0:8 Constant:
|
||||
0:8 1 (const uint)
|
||||
0:9 Sequence
|
||||
0:9 move second child to first child (temp uint)
|
||||
0:9 'r02' (temp uint)
|
||||
0:9 Constant:
|
||||
0:9 2 (const uint)
|
||||
0:10 Sequence
|
||||
0:10 move second child to first child (temp uint)
|
||||
0:10 'r03' (temp uint)
|
||||
0:10 Constant:
|
||||
0:10 2748 (const uint)
|
||||
0:11 Sequence
|
||||
0:11 move second child to first child (temp uint)
|
||||
0:11 'r04' (temp uint)
|
||||
0:11 Constant:
|
||||
0:11 2748 (const uint)
|
||||
0:12 Sequence
|
||||
0:12 move second child to first child (temp int)
|
||||
0:12 'r05' (temp int)
|
||||
0:12 Constant:
|
||||
0:12 5 (const int)
|
||||
0:13 Sequence
|
||||
0:13 move second child to first child (temp int)
|
||||
0:13 'r06' (temp int)
|
||||
0:13 Constant:
|
||||
0:13 6 (const int)
|
||||
0:14 Sequence
|
||||
0:14 move second child to first child (temp int)
|
||||
0:14 'r07' (temp int)
|
||||
0:14 Constant:
|
||||
0:14 57 (const int)
|
||||
0:15 Sequence
|
||||
0:15 move second child to first child (temp uint)
|
||||
0:15 'r08' (temp uint)
|
||||
0:15 Constant:
|
||||
0:15 58 (const uint)
|
||||
0:19 Branch: Return with expression
|
||||
0:19 'ps_output' (temp structure{temp 4-component vector of float color})
|
||||
0:? Linker Objects
|
||||
|
||||
|
||||
Linked fragment stage:
|
||||
|
||||
|
||||
Shader version: 450
|
||||
gl_FragCoord origin is upper left
|
||||
0:? Sequence
|
||||
0:21 Function Definition: main( (global structure{temp 4-component vector of float color})
|
||||
0:5 Function Parameters:
|
||||
0:? Sequence
|
||||
0:7 Sequence
|
||||
0:7 move second child to first child (temp float)
|
||||
0:7 'r00' (temp float)
|
||||
0:7 Constant:
|
||||
0:7 1.000000
|
||||
0:8 Sequence
|
||||
0:8 move second child to first child (temp uint)
|
||||
0:8 'r01' (temp uint)
|
||||
0:8 Constant:
|
||||
0:8 1 (const uint)
|
||||
0:9 Sequence
|
||||
0:9 move second child to first child (temp uint)
|
||||
0:9 'r02' (temp uint)
|
||||
0:9 Constant:
|
||||
0:9 2 (const uint)
|
||||
0:10 Sequence
|
||||
0:10 move second child to first child (temp uint)
|
||||
0:10 'r03' (temp uint)
|
||||
0:10 Constant:
|
||||
0:10 2748 (const uint)
|
||||
0:11 Sequence
|
||||
0:11 move second child to first child (temp uint)
|
||||
0:11 'r04' (temp uint)
|
||||
0:11 Constant:
|
||||
0:11 2748 (const uint)
|
||||
0:12 Sequence
|
||||
0:12 move second child to first child (temp int)
|
||||
0:12 'r05' (temp int)
|
||||
0:12 Constant:
|
||||
0:12 5 (const int)
|
||||
0:13 Sequence
|
||||
0:13 move second child to first child (temp int)
|
||||
0:13 'r06' (temp int)
|
||||
0:13 Constant:
|
||||
0:13 6 (const int)
|
||||
0:14 Sequence
|
||||
0:14 move second child to first child (temp int)
|
||||
0:14 'r07' (temp int)
|
||||
0:14 Constant:
|
||||
0:14 57 (const int)
|
||||
0:15 Sequence
|
||||
0:15 move second child to first child (temp uint)
|
||||
0:15 'r08' (temp uint)
|
||||
0:15 Constant:
|
||||
0:15 58 (const uint)
|
||||
0:19 Branch: Return with expression
|
||||
0:19 'ps_output' (temp structure{temp 4-component vector of float color})
|
||||
0:? Linker Objects
|
||||
|
||||
// Module Version 10000
|
||||
// Generated by (magic number): 80001
|
||||
// Id's are bound by 35
|
||||
|
||||
Capability Shader
|
||||
1: ExtInstImport "GLSL.std.450"
|
||||
MemoryModel Logical GLSL450
|
||||
EntryPoint Fragment 4 "main"
|
||||
ExecutionMode 4 OriginUpperLeft
|
||||
Source HLSL 450
|
||||
Name 4 "main"
|
||||
Name 8 "r00"
|
||||
Name 12 "r01"
|
||||
Name 14 "r02"
|
||||
Name 16 "r03"
|
||||
Name 18 "r04"
|
||||
Name 21 "r05"
|
||||
Name 23 "r06"
|
||||
Name 25 "r07"
|
||||
Name 27 "r08"
|
||||
Name 30 "PS_OUTPUT"
|
||||
MemberName 30(PS_OUTPUT) 0 "color"
|
||||
Name 32 "ps_output"
|
||||
2: TypeVoid
|
||||
3: TypeFunction 2
|
||||
6: TypeFloat 32
|
||||
7: TypePointer Function 6(float)
|
||||
9: 6(float) Constant 1065353216
|
||||
10: TypeInt 32 0
|
||||
11: TypePointer Function 10(int)
|
||||
13: 10(int) Constant 1
|
||||
15: 10(int) Constant 2
|
||||
17: 10(int) Constant 2748
|
||||
19: TypeInt 32 1
|
||||
20: TypePointer Function 19(int)
|
||||
22: 19(int) Constant 5
|
||||
24: 19(int) Constant 6
|
||||
26: 19(int) Constant 57
|
||||
28: 10(int) Constant 58
|
||||
29: TypeVector 6(float) 4
|
||||
30(PS_OUTPUT): TypeStruct 29(fvec4)
|
||||
31: TypePointer Function 30(PS_OUTPUT)
|
||||
4(main): 2 Function None 3
|
||||
5: Label
|
||||
8(r00): 7(ptr) Variable Function
|
||||
12(r01): 11(ptr) Variable Function
|
||||
14(r02): 11(ptr) Variable Function
|
||||
16(r03): 11(ptr) Variable Function
|
||||
18(r04): 11(ptr) Variable Function
|
||||
21(r05): 20(ptr) Variable Function
|
||||
23(r06): 20(ptr) Variable Function
|
||||
25(r07): 20(ptr) Variable Function
|
||||
27(r08): 11(ptr) Variable Function
|
||||
32(ps_output): 31(ptr) Variable Function
|
||||
Store 8(r00) 9
|
||||
Store 12(r01) 13
|
||||
Store 14(r02) 15
|
||||
Store 16(r03) 17
|
||||
Store 18(r04) 17
|
||||
Store 21(r05) 22
|
||||
Store 23(r06) 24
|
||||
Store 25(r07) 26
|
||||
Store 27(r08) 28
|
||||
33:30(PS_OUTPUT) Load 32(ps_output)
|
||||
ReturnValue 33
|
||||
FunctionEnd
|
20
Test/hlsl.numericsuffixes.frag
Normal file
20
Test/hlsl.numericsuffixes.frag
Normal file
@ -0,0 +1,20 @@
|
||||
|
||||
struct PS_OUTPUT { float4 color : SV_Target0; };
|
||||
|
||||
PS_OUTPUT main()
|
||||
{
|
||||
// Test numeric suffixes
|
||||
float r00 = 1.0f; // float
|
||||
uint r01 = 1u; // lower uint
|
||||
uint r02 = 2U; // upper uint
|
||||
uint r03 = 0xabcu; // lower hex uint
|
||||
uint r04 = 0xABCU; // upper hex uint (upper 0X is not accepted)
|
||||
int r05 = 5l; // lower long int
|
||||
int r06 = 6L; // upper long int
|
||||
int r07 = 071; // octal
|
||||
uint r08 = 072u; // unsigned octal
|
||||
|
||||
PS_OUTPUT ps_output;
|
||||
ps_output.color = r07; // gets 71 octal = 57 decimal
|
||||
return ps_output;
|
||||
}
|
@ -112,6 +112,7 @@ INSTANTIATE_TEST_CASE_P(
|
||||
{"hlsl.load.basic.dx10.vert", "main"},
|
||||
{"hlsl.load.offset.dx10.frag", "main"},
|
||||
{"hlsl.load.offsetarray.dx10.frag", "main"},
|
||||
{"hlsl.numericsuffixes.frag", "main"},
|
||||
{"hlsl.pp.line.frag", "main"},
|
||||
{"hlsl.sample.array.dx10.frag", "main"},
|
||||
{"hlsl.sample.basic.dx10.frag", "main"},
|
||||
|
@ -1960,6 +1960,9 @@ bool HlslGrammar::acceptLiteral(TIntermTyped*& node)
|
||||
case EHTokIntConstant:
|
||||
node = intermediate.addConstantUnion(token.i, token.loc, true);
|
||||
break;
|
||||
case EHTokUintConstant:
|
||||
node = intermediate.addConstantUnion(token.u, token.loc, true);
|
||||
break;
|
||||
case EHTokFloatConstant:
|
||||
node = intermediate.addConstantUnion(token.d, EbtFloat, token.loc, true);
|
||||
break;
|
||||
|
@ -51,7 +51,6 @@ public:
|
||||
|
||||
void setLimits(const TBuiltInResource&);
|
||||
bool parseShaderStrings(TPpContext&, TInputScanner& input, bool versionWillBeError = false);
|
||||
void getPreamble(std::string&);
|
||||
|
||||
void C_DECL error(const TSourceLoc&, const char* szReason, const char* szToken,
|
||||
const char* szExtraInfoFormat, ...);
|
||||
|
Loading…
x
Reference in New Issue
Block a user