diff --git a/Test/baseResults/hlsl.assoc.frag.out b/Test/baseResults/hlsl.assoc.frag.out new file mode 100755 index 000000000..0bba2ee20 --- /dev/null +++ b/Test/baseResults/hlsl.assoc.frag.out @@ -0,0 +1,113 @@ +hlsl.assoc.frag +Shader version: 100 +gl_FragCoord origin is upper left +0:? Sequence +0:12 Function Definition: PixelShaderFunction(vf4;vf4;vf4;vf4;vf4; (temp 4-component vector of float) +0:8 Function Parameters: +0:8 'a1' (temp 4-component vector of float) +0:8 'a2' (temp 4-component vector of float) +0:8 'a3' (temp 4-component vector of float) +0:8 'a4' (temp 4-component vector of float) +0:8 'a5' (temp 4-component vector of float) +0:? Sequence +0:9 move second child to first child (temp 4-component vector of float) +0:9 'a1' (temp 4-component vector of float) +0:9 move second child to first child (temp 4-component vector of float) +0:9 'a2' (temp 4-component vector of float) +0:9 move second child to first child (temp 4-component vector of float) +0:9 'a3' (temp 4-component vector of float) +0:9 move second child to first child (temp 4-component vector of float) +0:9 'a4' (temp 4-component vector of float) +0:9 'a5' (temp 4-component vector of float) +0:10 Branch: Return with expression +0:10 add (temp 4-component vector of float) +0:10 add (temp 4-component vector of float) +0:10 add (temp 4-component vector of float) +0:10 'a1' (temp 4-component vector of float) +0:10 'a2' (temp 4-component vector of float) +0:10 add (temp 4-component vector of float) +0:10 'a3' (temp 4-component vector of float) +0:10 'a4' (temp 4-component vector of float) +0:10 'a5' (temp 4-component vector of float) +0:? Linker Objects + + +Linked fragment stage: + + +Shader version: 100 +gl_FragCoord origin is upper left +0:? Sequence +0:12 Function Definition: PixelShaderFunction(vf4;vf4;vf4;vf4;vf4; (temp 4-component vector of float) +0:8 Function Parameters: +0:8 'a1' (temp 4-component vector of float) +0:8 'a2' (temp 4-component vector of float) +0:8 'a3' (temp 4-component vector of float) +0:8 'a4' (temp 4-component vector of float) +0:8 'a5' (temp 4-component vector of float) +0:? Sequence +0:9 move second child to first child (temp 4-component vector of float) +0:9 'a1' (temp 4-component vector of float) +0:9 move second child to first child (temp 4-component vector of float) +0:9 'a2' (temp 4-component vector of float) +0:9 move second child to first child (temp 4-component vector of float) +0:9 'a3' (temp 4-component vector of float) +0:9 move second child to first child (temp 4-component vector of float) +0:9 'a4' (temp 4-component vector of float) +0:9 'a5' (temp 4-component vector of float) +0:10 Branch: Return with expression +0:10 add (temp 4-component vector of float) +0:10 add (temp 4-component vector of float) +0:10 add (temp 4-component vector of float) +0:10 'a1' (temp 4-component vector of float) +0:10 'a2' (temp 4-component vector of float) +0:10 add (temp 4-component vector of float) +0:10 'a3' (temp 4-component vector of float) +0:10 'a4' (temp 4-component vector of float) +0:10 'a5' (temp 4-component vector of float) +0:? Linker Objects + +// Module Version 10000 +// Generated by (magic number): 80001 +// Id's are bound by 25 + + Capability Shader + 1: ExtInstImport "GLSL.std.450" + MemoryModel Logical GLSL450 + EntryPoint Fragment 4 "PixelShaderFunction" + ExecutionMode 4 OriginUpperLeft + Source HLSL 100 + Name 4 "PixelShaderFunction" + Name 9 "a1" + Name 10 "a2" + Name 11 "a3" + Name 12 "a4" + Name 13 "a5" + 2: TypeVoid + 3: TypeFunction 2 + 6: TypeFloat 32 + 7: TypeVector 6(float) 4 + 8: TypePointer Function 7(fvec4) +4(PixelShaderFunction): 2 Function None 3 + 5: Label + 9(a1): 8(ptr) Variable Function + 10(a2): 8(ptr) Variable Function + 11(a3): 8(ptr) Variable Function + 12(a4): 8(ptr) Variable Function + 13(a5): 8(ptr) Variable Function + 14: 7(fvec4) Load 13(a5) + Store 12(a4) 14 + Store 11(a3) 14 + Store 10(a2) 14 + Store 9(a1) 14 + 15: 7(fvec4) Load 9(a1) + 16: 7(fvec4) Load 10(a2) + 17: 7(fvec4) FAdd 15 16 + 18: 7(fvec4) Load 11(a3) + 19: 7(fvec4) Load 12(a4) + 20: 7(fvec4) FAdd 18 19 + 21: 7(fvec4) FAdd 17 20 + 22: 7(fvec4) Load 13(a5) + 23: 7(fvec4) FAdd 21 22 + ReturnValue 23 + FunctionEnd diff --git a/Test/baseResults/hlsl.float4.frag.out b/Test/baseResults/hlsl.float4.frag.out new file mode 100755 index 000000000..c827f4d20 --- /dev/null +++ b/Test/baseResults/hlsl.float4.frag.out @@ -0,0 +1,79 @@ +hlsl.float4.frag +Shader version: 100 +gl_FragCoord origin is upper left +0:? Sequence +0:1 move second child to first child (temp 4-component vector of float) +0:1 'AmbientColor' (temp 4-component vector of float) +0:? Constant: +0:? 1.000000 +0:? 0.500000 +0:? 0.000000 +0:? 1.000000 +0:7 Function Definition: ShaderFunction(vf4; (temp 4-component vector of float) +0:4 Function Parameters: +0:4 'input' (temp 4-component vector of float) +0:? Sequence +0:5 Branch: Return with expression +0:5 component-wise multiply (temp 4-component vector of float) +0:5 'input' (temp 4-component vector of float) +0:5 'AmbientColor' (temp 4-component vector of float) +0:? Linker Objects +0:? 'AmbientColor' (temp 4-component vector of float) + + +Linked fragment stage: + + +Shader version: 100 +gl_FragCoord origin is upper left +0:? Sequence +0:1 move second child to first child (temp 4-component vector of float) +0:1 'AmbientColor' (temp 4-component vector of float) +0:? Constant: +0:? 1.000000 +0:? 0.500000 +0:? 0.000000 +0:? 1.000000 +0:7 Function Definition: ShaderFunction(vf4; (temp 4-component vector of float) +0:4 Function Parameters: +0:4 'input' (temp 4-component vector of float) +0:? Sequence +0:5 Branch: Return with expression +0:5 component-wise multiply (temp 4-component vector of float) +0:5 'input' (temp 4-component vector of float) +0:5 'AmbientColor' (temp 4-component vector of float) +0:? Linker Objects +0:? 'AmbientColor' (temp 4-component vector of float) + +// Module Version 10000 +// Generated by (magic number): 80001 +// Id's are bound by 19 + + Capability Shader + 1: ExtInstImport "GLSL.std.450" + MemoryModel Logical GLSL450 + EntryPoint Fragment 4 "PixelShaderFunction" + ExecutionMode 4 OriginUpperLeft + Source HLSL 100 + Name 4 "PixelShaderFunction" + Name 11 "ShaderFunction(vf4;" + Name 10 "input" + Name 14 "AmbientColor" + 2: TypeVoid + 3: TypeFunction 2 + 6: TypeFloat 32 + 7: TypeVector 6(float) 4 + 8: TypePointer Function 7(fvec4) + 9: TypeFunction 7(fvec4) 8(ptr) +4(PixelShaderFunction): 2 Function None 3 + 5: Label + FunctionEnd +11(ShaderFunction(vf4;): 7(fvec4) Function None 9 + 10(input): 8(ptr) FunctionParameter + 12: Label +14(AmbientColor): 8(ptr) Variable Function + 13: 7(fvec4) Load 10(input) + 15: 7(fvec4) Load 14(AmbientColor) + 16: 7(fvec4) FMul 13 15 + ReturnValue 16 + FunctionEnd diff --git a/Test/baseResults/hlsl.max.frag.out b/Test/baseResults/hlsl.max.frag.out new file mode 100755 index 000000000..addc965cb --- /dev/null +++ b/Test/baseResults/hlsl.max.frag.out @@ -0,0 +1,60 @@ +hlsl.max.frag +Shader version: 100 +gl_FragCoord origin is upper left +0:? Sequence +0:5 Function Definition: PixelShaderFunction(vf4;vf4; (temp 4-component vector of float) +0:2 Function Parameters: +0:2 'input1' (temp 4-component vector of float) +0:2 'input2' (temp 4-component vector of float) +0:? Sequence +0:3 Branch: Return with expression +0:3 max (global 4-component vector of float) +0:3 'input1' (temp 4-component vector of float) +0:3 'input2' (temp 4-component vector of float) +0:? Linker Objects + + +Linked fragment stage: + + +Shader version: 100 +gl_FragCoord origin is upper left +0:? Sequence +0:5 Function Definition: PixelShaderFunction(vf4;vf4; (temp 4-component vector of float) +0:2 Function Parameters: +0:2 'input1' (temp 4-component vector of float) +0:2 'input2' (temp 4-component vector of float) +0:? Sequence +0:3 Branch: Return with expression +0:3 max (global 4-component vector of float) +0:3 'input1' (temp 4-component vector of float) +0:3 'input2' (temp 4-component vector of float) +0:? Linker Objects + +// Module Version 10000 +// Generated by (magic number): 80001 +// Id's are bound by 15 + + Capability Shader + 1: ExtInstImport "GLSL.std.450" + MemoryModel Logical GLSL450 + EntryPoint Fragment 4 "PixelShaderFunction" + ExecutionMode 4 OriginUpperLeft + Source HLSL 100 + Name 4 "PixelShaderFunction" + Name 9 "input1" + Name 11 "input2" + 2: TypeVoid + 3: TypeFunction 2 + 6: TypeFloat 32 + 7: TypeVector 6(float) 4 + 8: TypePointer Function 7(fvec4) +4(PixelShaderFunction): 2 Function None 3 + 5: Label + 9(input1): 8(ptr) Variable Function + 11(input2): 8(ptr) Variable Function + 10: 7(fvec4) Load 9(input1) + 12: 7(fvec4) Load 11(input2) + 13: 7(fvec4) ExtInst 1(GLSL.std.450) 40(FMax) 10 12 + ReturnValue 13 + FunctionEnd diff --git a/Test/baseResults/hlsl.precedence.frag.out b/Test/baseResults/hlsl.precedence.frag.out new file mode 100755 index 000000000..fc31f4b2f --- /dev/null +++ b/Test/baseResults/hlsl.precedence.frag.out @@ -0,0 +1,80 @@ +hlsl.precedence.frag +Shader version: 100 +gl_FragCoord origin is upper left +0:? Sequence +0:10 Function Definition: PixelShaderFunction(vf4;vf4;vf4;vf4; (temp 4-component vector of float) +0:7 Function Parameters: +0:7 'a1' (temp 4-component vector of float) +0:7 'a2' (temp 4-component vector of float) +0:7 'a3' (temp 4-component vector of float) +0:7 'a4' (temp 4-component vector of float) +0:? Sequence +0:8 Branch: Return with expression +0:8 add (temp 4-component vector of float) +0:8 add (temp 4-component vector of float) +0:8 'a1' (temp 4-component vector of float) +0:8 component-wise multiply (temp 4-component vector of float) +0:8 'a2' (temp 4-component vector of float) +0:8 'a3' (temp 4-component vector of float) +0:8 'a4' (temp 4-component vector of float) +0:? Linker Objects + + +Linked fragment stage: + + +Shader version: 100 +gl_FragCoord origin is upper left +0:? Sequence +0:10 Function Definition: PixelShaderFunction(vf4;vf4;vf4;vf4; (temp 4-component vector of float) +0:7 Function Parameters: +0:7 'a1' (temp 4-component vector of float) +0:7 'a2' (temp 4-component vector of float) +0:7 'a3' (temp 4-component vector of float) +0:7 'a4' (temp 4-component vector of float) +0:? Sequence +0:8 Branch: Return with expression +0:8 add (temp 4-component vector of float) +0:8 add (temp 4-component vector of float) +0:8 'a1' (temp 4-component vector of float) +0:8 component-wise multiply (temp 4-component vector of float) +0:8 'a2' (temp 4-component vector of float) +0:8 'a3' (temp 4-component vector of float) +0:8 'a4' (temp 4-component vector of float) +0:? Linker Objects + +// Module Version 10000 +// Generated by (magic number): 80001 +// Id's are bound by 21 + + Capability Shader + 1: ExtInstImport "GLSL.std.450" + MemoryModel Logical GLSL450 + EntryPoint Fragment 4 "PixelShaderFunction" + ExecutionMode 4 OriginUpperLeft + Source HLSL 100 + Name 4 "PixelShaderFunction" + Name 9 "a1" + Name 11 "a2" + Name 13 "a3" + Name 17 "a4" + 2: TypeVoid + 3: TypeFunction 2 + 6: TypeFloat 32 + 7: TypeVector 6(float) 4 + 8: TypePointer Function 7(fvec4) +4(PixelShaderFunction): 2 Function None 3 + 5: Label + 9(a1): 8(ptr) Variable Function + 11(a2): 8(ptr) Variable Function + 13(a3): 8(ptr) Variable Function + 17(a4): 8(ptr) Variable Function + 10: 7(fvec4) Load 9(a1) + 12: 7(fvec4) Load 11(a2) + 14: 7(fvec4) Load 13(a3) + 15: 7(fvec4) FMul 12 14 + 16: 7(fvec4) FAdd 10 15 + 18: 7(fvec4) Load 17(a4) + 19: 7(fvec4) FAdd 16 18 + ReturnValue 19 + FunctionEnd diff --git a/Test/baseResults/hlsl.precedence2.frag.out b/Test/baseResults/hlsl.precedence2.frag.out new file mode 100755 index 000000000..fc4ae025a --- /dev/null +++ b/Test/baseResults/hlsl.precedence2.frag.out @@ -0,0 +1,103 @@ +hlsl.precedence2.frag +Shader version: 100 +gl_FragCoord origin is upper left +0:? Sequence +0:10 Function Definition: PixelShaderFunction(i1;i1;i1;i1; (temp int) +0:7 Function Parameters: +0:7 'a1' (temp int) +0:7 'a2' (temp int) +0:7 'a3' (temp int) +0:7 'a4' (temp int) +0:? Sequence +0:8 Branch: Return with expression +0:8 add (temp int) +0:8 left-shift (temp int) +0:8 add (temp int) +0:8 component-wise multiply (temp int) +0:8 'a1' (temp int) +0:8 'a2' (temp int) +0:8 'a3' (temp int) +0:8 'a4' (temp int) +0:8 left-shift (temp int) +0:8 'a1' (temp int) +0:8 add (temp int) +0:8 'a2' (temp int) +0:8 component-wise multiply (temp int) +0:8 'a3' (temp int) +0:8 'a4' (temp int) +0:? Linker Objects + + +Linked fragment stage: + + +Shader version: 100 +gl_FragCoord origin is upper left +0:? Sequence +0:10 Function Definition: PixelShaderFunction(i1;i1;i1;i1; (temp int) +0:7 Function Parameters: +0:7 'a1' (temp int) +0:7 'a2' (temp int) +0:7 'a3' (temp int) +0:7 'a4' (temp int) +0:? Sequence +0:8 Branch: Return with expression +0:8 add (temp int) +0:8 left-shift (temp int) +0:8 add (temp int) +0:8 component-wise multiply (temp int) +0:8 'a1' (temp int) +0:8 'a2' (temp int) +0:8 'a3' (temp int) +0:8 'a4' (temp int) +0:8 left-shift (temp int) +0:8 'a1' (temp int) +0:8 add (temp int) +0:8 'a2' (temp int) +0:8 component-wise multiply (temp int) +0:8 'a3' (temp int) +0:8 'a4' (temp int) +0:? Linker Objects + +// Module Version 10000 +// Generated by (magic number): 80001 +// Id's are bound by 28 + + Capability Shader + 1: ExtInstImport "GLSL.std.450" + MemoryModel Logical GLSL450 + EntryPoint Fragment 4 "PixelShaderFunction" + ExecutionMode 4 OriginUpperLeft + Source HLSL 100 + Name 4 "PixelShaderFunction" + Name 8 "a1" + Name 10 "a2" + Name 13 "a3" + Name 16 "a4" + 2: TypeVoid + 3: TypeFunction 2 + 6: TypeInt 32 1 + 7: TypePointer Function 6(int) +4(PixelShaderFunction): 2 Function None 3 + 5: Label + 8(a1): 7(ptr) Variable Function + 10(a2): 7(ptr) Variable Function + 13(a3): 7(ptr) Variable Function + 16(a4): 7(ptr) Variable Function + 9: 6(int) Load 8(a1) + 11: 6(int) Load 10(a2) + 12: 6(int) IMul 9 11 + 14: 6(int) Load 13(a3) + 15: 6(int) IAdd 12 14 + 17: 6(int) Load 16(a4) + 18: 6(int) ShiftLeftLogical 15 17 + 19: 6(int) Load 8(a1) + 20: 6(int) Load 10(a2) + 21: 6(int) Load 13(a3) + 22: 6(int) Load 16(a4) + 23: 6(int) IMul 21 22 + 24: 6(int) IAdd 20 23 + 25: 6(int) ShiftLeftLogical 19 24 + 26: 6(int) IAdd 18 25 + ReturnValue 26 + FunctionEnd diff --git a/Test/baseResults/hlsl.sin.frag.out b/Test/baseResults/hlsl.sin.frag.out new file mode 100755 index 000000000..7d4f626d1 --- /dev/null +++ b/Test/baseResults/hlsl.sin.frag.out @@ -0,0 +1,53 @@ +hlsl.sin.frag +Shader version: 100 +gl_FragCoord origin is upper left +0:? Sequence +0:5 Function Definition: PixelShaderFunction(vf4; (temp 4-component vector of float) +0:2 Function Parameters: +0:2 'input' (temp 4-component vector of float) +0:? Sequence +0:3 Branch: Return with expression +0:3 sine (global 4-component vector of float) +0:3 'input' (temp 4-component vector of float) +0:? Linker Objects + + +Linked fragment stage: + + +Shader version: 100 +gl_FragCoord origin is upper left +0:? Sequence +0:5 Function Definition: PixelShaderFunction(vf4; (temp 4-component vector of float) +0:2 Function Parameters: +0:2 'input' (temp 4-component vector of float) +0:? Sequence +0:3 Branch: Return with expression +0:3 sine (global 4-component vector of float) +0:3 'input' (temp 4-component vector of float) +0:? Linker Objects + +// Module Version 10000 +// Generated by (magic number): 80001 +// Id's are bound by 13 + + Capability Shader + 1: ExtInstImport "GLSL.std.450" + MemoryModel Logical GLSL450 + EntryPoint Fragment 4 "PixelShaderFunction" + ExecutionMode 4 OriginUpperLeft + Source HLSL 100 + Name 4 "PixelShaderFunction" + Name 9 "input" + 2: TypeVoid + 3: TypeFunction 2 + 6: TypeFloat 32 + 7: TypeVector 6(float) 4 + 8: TypePointer Function 7(fvec4) +4(PixelShaderFunction): 2 Function None 3 + 5: Label + 9(input): 8(ptr) Variable Function + 10: 7(fvec4) Load 9(input) + 11: 7(fvec4) ExtInst 1(GLSL.std.450) 13(Sin) 10 + ReturnValue 11 + FunctionEnd diff --git a/Test/hlsl.assoc.frag b/Test/hlsl.assoc.frag new file mode 100644 index 000000000..8ce1050cd --- /dev/null +++ b/Test/hlsl.assoc.frag @@ -0,0 +1,11 @@ +float4 PixelShaderFunction( + float4 a1, + float4 a2, + float4 a3, + float4 a4, + float4 a5 + ) : COLOR0 +{ + a1 = a2 = a3 = a4 = a5; + return a1 + a2 + a3 + a4 + a5; +} diff --git a/Test/hlsl.float4.frag b/Test/hlsl.float4.frag new file mode 100644 index 000000000..8ed4eab17 --- /dev/null +++ b/Test/hlsl.float4.frag @@ -0,0 +1,6 @@ +float4 AmbientColor = float4(1, 0.5, 0, 1); + +float4 ShaderFunction(float4 input) : COLOR0 +{ + return input * AmbientColor; +} diff --git a/Test/hlsl.max.frag b/Test/hlsl.max.frag new file mode 100644 index 000000000..6d1ea0b12 --- /dev/null +++ b/Test/hlsl.max.frag @@ -0,0 +1,4 @@ +float4 PixelShaderFunction(float4 input1, float4 input2) : COLOR0 +{ + return max(input1, input2); +} diff --git a/Test/hlsl.precedence.frag b/Test/hlsl.precedence.frag new file mode 100644 index 000000000..eae0435e0 --- /dev/null +++ b/Test/hlsl.precedence.frag @@ -0,0 +1,9 @@ +float4 PixelShaderFunction( + float4 a1, + float4 a2, + float4 a3, + float4 a4 + ) : COLOR0 +{ + return a1 + a2 * a3 + a4; +} diff --git a/Test/hlsl.precedence2.frag b/Test/hlsl.precedence2.frag new file mode 100644 index 000000000..0d3f583a8 --- /dev/null +++ b/Test/hlsl.precedence2.frag @@ -0,0 +1,9 @@ +int PixelShaderFunction( + int a1, + int a2, + int a3, + int a4 + ) : COLOR0 +{ + return (a1 * a2 + a3 << a4) + (a1 << a2 + a3 * a4); +} diff --git a/Test/hlsl.sin.frag b/Test/hlsl.sin.frag new file mode 100644 index 000000000..edf087deb --- /dev/null +++ b/Test/hlsl.sin.frag @@ -0,0 +1,4 @@ +float4 PixelShaderFunction(float4 input) : COLOR0 +{ + return sin(input); +} diff --git a/gtests/Hlsl.FromFile.cpp b/gtests/Hlsl.FromFile.cpp index 6105185bd..825179df7 100644 --- a/gtests/Hlsl.FromFile.cpp +++ b/gtests/Hlsl.FromFile.cpp @@ -71,7 +71,12 @@ TEST_P(HlslCompileTest, FromFile) INSTANTIATE_TEST_CASE_P( ToSpirv, HlslCompileTest, ::testing::ValuesIn(std::vector{ - {"hlsl.frag", "PixelShaderFunction"}, + {"hlsl.assoc.frag", "PixelShaderFunction"}, + {"hlsl.float4.frag", "PixelShaderFunction"}, + {"hlsl.max.frag", "PixelShaderFunction"}, + {"hlsl.precedence.frag", "PixelShaderFunction"}, + {"hlsl.precedence2.frag", "PixelShaderFunction"}, + {"hlsl.sin.frag", "PixelShaderFunction"}, }), FileNameAsCustomTestSuffix );