HLSL: Add more matrix types to the grammar.

This commit is contained in:
John Kessenich 2016-05-20 12:17:26 -06:00
parent 8d72f1a2c4
commit 0133c1233e
4 changed files with 231 additions and 0 deletions

View File

@ -0,0 +1,101 @@
hlsl.matType.frag
Shader version: 100
gl_FragCoord origin is upper left
0:? Sequence
0:1 move second child to first child (temp 1-component vector of float)
0:1 'f1' (temp 1-component vector of float)
0:1 Constant:
0:1 1.000000
0:11 Function Definition: ShaderFunction(vf1;f1; (temp 1-component vector of float)
0:9 Function Parameters:
0:9 'inFloat1' (temp 1-component vector of float)
0:9 'inScalar' (temp float)
0:? Linker Objects
0:? 'f1' (temp 1-component vector of float)
0:? 'fmat11' (temp 1X1 matrix of float)
0:? 'fmat41' (temp 1X4 matrix of float)
0:? 'fmat12' (temp 2X1 matrix of float)
0:? 'dmat23' (temp 3X2 matrix of double)
0:? 'int44' (temp 4X4 matrix of int)
Linked fragment stage:
Shader version: 100
gl_FragCoord origin is upper left
0:? Sequence
0:1 move second child to first child (temp 1-component vector of float)
0:1 'f1' (temp 1-component vector of float)
0:1 Constant:
0:1 1.000000
0:11 Function Definition: ShaderFunction(vf1;f1; (temp 1-component vector of float)
0:9 Function Parameters:
0:9 'inFloat1' (temp 1-component vector of float)
0:9 'inScalar' (temp float)
0:? Linker Objects
0:? 'f1' (temp 1-component vector of float)
0:? 'fmat11' (temp 1X1 matrix of float)
0:? 'fmat41' (temp 1X4 matrix of float)
0:? 'fmat12' (temp 2X1 matrix of float)
0:? 'dmat23' (temp 3X2 matrix of double)
0:? 'int44' (temp 4X4 matrix of int)
// Module Version 10000
// Generated by (magic number): 80001
// Id's are bound by 36
Capability Shader
Capability Float64
1: ExtInstImport "GLSL.std.450"
MemoryModel Logical GLSL450
EntryPoint Fragment 4 "PixelShaderFunction"
ExecutionMode 4 OriginUpperLeft
Source HLSL 100
Name 4 "PixelShaderFunction"
Name 11 "ShaderFunction(vf1;f1;"
Name 9 "inFloat1"
Name 10 "inScalar"
Name 14 "f1"
Name 18 "fmat11"
Name 22 "fmat41"
Name 25 "fmat12"
Name 30 "dmat23"
Name 35 "int44"
2: TypeVoid
3: TypeFunction 2
6: TypeFloat 32
7: TypePointer Function 6(float)
8: TypeFunction 6(float) 7(ptr) 7(ptr)
15: TypeVector 6(float) 1
16: TypeMatrix 15(fvec) 1
17: TypePointer Function 16
19: TypeVector 6(float) 4
20: TypeMatrix 19(fvec4) 1
21: TypePointer Function 20
23: TypeMatrix 15(fvec) 2
24: TypePointer Function 23
26: TypeFloat 64
27: TypeVector 26(float) 2
28: TypeMatrix 27(fvec2) 3
29: TypePointer Function 28
31: TypeInt 32 1
32: TypeVector 31(int) 4
33: TypeMatrix 32(ivec4) 4
34: TypePointer Function 33
4(PixelShaderFunction): 2 Function None 3
5: Label
FunctionEnd
11(ShaderFunction(vf1;f1;): 6(float) Function None 8
9(inFloat1): 7(ptr) FunctionParameter
10(inScalar): 7(ptr) FunctionParameter
12: Label
14(f1): 7(ptr) Variable Function
18(fmat11): 17(ptr) Variable Function
22(fmat41): 21(ptr) Variable Function
25(fmat12): 24(ptr) Variable Function
30(dmat23): 29(ptr) Variable Function
35(int44): 34(ptr) Variable Function
13: 6(float) Undef
ReturnValue 13
FunctionEnd

10
Test/hlsl.matType.frag Normal file
View File

@ -0,0 +1,10 @@
float1 f1 = float1(1.0);
float1x1 fmat11;
float4x1 fmat41;
float1x2 fmat12;
double2x3 dmat23;
int4x4 int44;
float1 ShaderFunction(float1 inFloat1, float inScalar) : COLOR0
{
}

View File

@ -74,6 +74,7 @@ INSTANTIATE_TEST_CASE_P(
{"hlsl.assoc.frag", "PixelShaderFunction"},
{"hlsl.float1.frag", "PixelShaderFunction"},
{"hlsl.float4.frag", "PixelShaderFunction"},
{"hlsl.matType.frag", "PixelShaderFunction"},
{"hlsl.max.frag", "PixelShaderFunction"},
{"hlsl.precedence.frag", "PixelShaderFunction"},
{"hlsl.precedence2.frag", "PixelShaderFunction"},

View File

@ -257,6 +257,70 @@ bool HlslGrammar::acceptType(TType& type)
new(&type) TType(EbtBool, EvqTemporary, 4);
break;
case EHTokInt1x1:
new(&type) TType(EbtInt, EvqTemporary, 0, 1, 1);
break;
case EHTokInt1x2:
new(&type) TType(EbtInt, EvqTemporary, 0, 2, 1);
break;
case EHTokInt1x3:
new(&type) TType(EbtInt, EvqTemporary, 0, 3, 1);
break;
case EHTokInt1x4:
new(&type) TType(EbtInt, EvqTemporary, 0, 4, 1);
break;
case EHTokInt2x1:
new(&type) TType(EbtInt, EvqTemporary, 0, 1, 2);
break;
case EHTokInt2x2:
new(&type) TType(EbtInt, EvqTemporary, 0, 2, 2);
break;
case EHTokInt2x3:
new(&type) TType(EbtInt, EvqTemporary, 0, 3, 2);
break;
case EHTokInt2x4:
new(&type) TType(EbtInt, EvqTemporary, 0, 4, 2);
break;
case EHTokInt3x1:
new(&type) TType(EbtInt, EvqTemporary, 0, 1, 3);
break;
case EHTokInt3x2:
new(&type) TType(EbtInt, EvqTemporary, 0, 2, 3);
break;
case EHTokInt3x3:
new(&type) TType(EbtInt, EvqTemporary, 0, 3, 3);
break;
case EHTokInt3x4:
new(&type) TType(EbtInt, EvqTemporary, 0, 4, 3);
break;
case EHTokInt4x1:
new(&type) TType(EbtInt, EvqTemporary, 0, 1, 4);
break;
case EHTokInt4x2:
new(&type) TType(EbtInt, EvqTemporary, 0, 2, 4);
break;
case EHTokInt4x3:
new(&type) TType(EbtInt, EvqTemporary, 0, 3, 4);
break;
case EHTokInt4x4:
new(&type) TType(EbtInt, EvqTemporary, 0, 4, 4);
break;
case EHTokFloat1x1:
new(&type) TType(EbtFloat, EvqTemporary, 0, 1, 1);
break;
case EHTokFloat1x2:
new(&type) TType(EbtFloat, EvqTemporary, 0, 2, 1);
break;
case EHTokFloat1x3:
new(&type) TType(EbtFloat, EvqTemporary, 0, 3, 1);
break;
case EHTokFloat1x4:
new(&type) TType(EbtFloat, EvqTemporary, 0, 4, 1);
break;
case EHTokFloat2x1:
new(&type) TType(EbtFloat, EvqTemporary, 0, 1, 2);
break;
case EHTokFloat2x2:
new(&type) TType(EbtFloat, EvqTemporary, 0, 2, 2);
break;
@ -266,6 +330,9 @@ bool HlslGrammar::acceptType(TType& type)
case EHTokFloat2x4:
new(&type) TType(EbtFloat, EvqTemporary, 0, 4, 2);
break;
case EHTokFloat3x1:
new(&type) TType(EbtFloat, EvqTemporary, 0, 1, 3);
break;
case EHTokFloat3x2:
new(&type) TType(EbtFloat, EvqTemporary, 0, 2, 3);
break;
@ -275,6 +342,9 @@ bool HlslGrammar::acceptType(TType& type)
case EHTokFloat3x4:
new(&type) TType(EbtFloat, EvqTemporary, 0, 4, 3);
break;
case EHTokFloat4x1:
new(&type) TType(EbtFloat, EvqTemporary, 0, 1, 4);
break;
case EHTokFloat4x2:
new(&type) TType(EbtFloat, EvqTemporary, 0, 2, 4);
break;
@ -285,6 +355,55 @@ bool HlslGrammar::acceptType(TType& type)
new(&type) TType(EbtFloat, EvqTemporary, 0, 4, 4);
break;
case EHTokDouble1x1:
new(&type) TType(EbtDouble, EvqTemporary, 0, 1, 1);
break;
case EHTokDouble1x2:
new(&type) TType(EbtDouble, EvqTemporary, 0, 2, 1);
break;
case EHTokDouble1x3:
new(&type) TType(EbtDouble, EvqTemporary, 0, 3, 1);
break;
case EHTokDouble1x4:
new(&type) TType(EbtDouble, EvqTemporary, 0, 4, 1);
break;
case EHTokDouble2x1:
new(&type) TType(EbtDouble, EvqTemporary, 0, 1, 2);
break;
case EHTokDouble2x2:
new(&type) TType(EbtDouble, EvqTemporary, 0, 2, 2);
break;
case EHTokDouble2x3:
new(&type) TType(EbtDouble, EvqTemporary, 0, 3, 2);
break;
case EHTokDouble2x4:
new(&type) TType(EbtDouble, EvqTemporary, 0, 4, 2);
break;
case EHTokDouble3x1:
new(&type) TType(EbtDouble, EvqTemporary, 0, 1, 3);
break;
case EHTokDouble3x2:
new(&type) TType(EbtDouble, EvqTemporary, 0, 2, 3);
break;
case EHTokDouble3x3:
new(&type) TType(EbtDouble, EvqTemporary, 0, 3, 3);
break;
case EHTokDouble3x4:
new(&type) TType(EbtDouble, EvqTemporary, 0, 4, 3);
break;
case EHTokDouble4x1:
new(&type) TType(EbtDouble, EvqTemporary, 0, 1, 4);
break;
case EHTokDouble4x2:
new(&type) TType(EbtDouble, EvqTemporary, 0, 2, 4);
break;
case EHTokDouble4x3:
new(&type) TType(EbtDouble, EvqTemporary, 0, 3, 4);
break;
case EHTokDouble4x4:
new(&type) TType(EbtDouble, EvqTemporary, 0, 4, 4);
break;
default:
return false;
}