HLSL: Add all int/float/bool/uint matrix types, void for functions, and a few others.
This commit is contained in:
@@ -213,20 +213,17 @@ bool HlslGrammar::acceptType(TType& type)
|
||||
return false;
|
||||
|
||||
switch (peek()) {
|
||||
case EHTokInt:
|
||||
case EHTokInt1:
|
||||
case EHTokDword:
|
||||
new(&type) TType(EbtInt);
|
||||
case EHTokVoid:
|
||||
new(&type) TType(EbtVoid);
|
||||
break;
|
||||
|
||||
case EHTokFloat:
|
||||
new(&type) TType(EbtFloat);
|
||||
break;
|
||||
|
||||
case EHTokFloat1:
|
||||
new(&type) TType(EbtFloat);
|
||||
type.makeVector();
|
||||
break;
|
||||
|
||||
case EHTokFloat2:
|
||||
new(&type) TType(EbtFloat, EvqTemporary, 2);
|
||||
break;
|
||||
@@ -237,6 +234,31 @@ bool HlslGrammar::acceptType(TType& type)
|
||||
new(&type) TType(EbtFloat, EvqTemporary, 4);
|
||||
break;
|
||||
|
||||
case EHTokDouble:
|
||||
new(&type) TType(EbtDouble);
|
||||
break;
|
||||
case EHTokDouble1:
|
||||
new(&type) TType(EbtDouble);
|
||||
type.makeVector();
|
||||
break;
|
||||
case EHTokDouble2:
|
||||
new(&type) TType(EbtDouble, EvqTemporary, 2);
|
||||
break;
|
||||
case EHTokDouble3:
|
||||
new(&type) TType(EbtDouble, EvqTemporary, 3);
|
||||
break;
|
||||
case EHTokDouble4:
|
||||
new(&type) TType(EbtDouble, EvqTemporary, 4);
|
||||
break;
|
||||
|
||||
case EHTokInt:
|
||||
case EHTokDword:
|
||||
new(&type) TType(EbtInt);
|
||||
break;
|
||||
case EHTokInt1:
|
||||
new(&type) TType(EbtInt);
|
||||
type.makeVector();
|
||||
break;
|
||||
case EHTokInt2:
|
||||
new(&type) TType(EbtInt, EvqTemporary, 2);
|
||||
break;
|
||||
@@ -247,6 +269,30 @@ bool HlslGrammar::acceptType(TType& type)
|
||||
new(&type) TType(EbtInt, EvqTemporary, 4);
|
||||
break;
|
||||
|
||||
case EHTokUint:
|
||||
new(&type) TType(EbtUint);
|
||||
break;
|
||||
case EHTokUint1:
|
||||
new(&type) TType(EbtUint);
|
||||
type.makeVector();
|
||||
break;
|
||||
case EHTokUint2:
|
||||
new(&type) TType(EbtUint, EvqTemporary, 2);
|
||||
break;
|
||||
case EHTokUint3:
|
||||
new(&type) TType(EbtUint, EvqTemporary, 3);
|
||||
break;
|
||||
case EHTokUint4:
|
||||
new(&type) TType(EbtUint, EvqTemporary, 4);
|
||||
break;
|
||||
|
||||
case EHTokBool:
|
||||
new(&type) TType(EbtBool);
|
||||
break;
|
||||
case EHTokBool1:
|
||||
new(&type) TType(EbtBool);
|
||||
type.makeVector();
|
||||
break;
|
||||
case EHTokBool2:
|
||||
new(&type) TType(EbtBool, EvqTemporary, 2);
|
||||
break;
|
||||
@@ -306,6 +352,104 @@ bool HlslGrammar::acceptType(TType& type)
|
||||
new(&type) TType(EbtInt, EvqTemporary, 0, 4, 4);
|
||||
break;
|
||||
|
||||
case EHTokUint1x1:
|
||||
new(&type) TType(EbtUint, EvqTemporary, 0, 1, 1);
|
||||
break;
|
||||
case EHTokUint1x2:
|
||||
new(&type) TType(EbtUint, EvqTemporary, 0, 2, 1);
|
||||
break;
|
||||
case EHTokUint1x3:
|
||||
new(&type) TType(EbtUint, EvqTemporary, 0, 3, 1);
|
||||
break;
|
||||
case EHTokUint1x4:
|
||||
new(&type) TType(EbtUint, EvqTemporary, 0, 4, 1);
|
||||
break;
|
||||
case EHTokUint2x1:
|
||||
new(&type) TType(EbtUint, EvqTemporary, 0, 1, 2);
|
||||
break;
|
||||
case EHTokUint2x2:
|
||||
new(&type) TType(EbtUint, EvqTemporary, 0, 2, 2);
|
||||
break;
|
||||
case EHTokUint2x3:
|
||||
new(&type) TType(EbtUint, EvqTemporary, 0, 3, 2);
|
||||
break;
|
||||
case EHTokUint2x4:
|
||||
new(&type) TType(EbtUint, EvqTemporary, 0, 4, 2);
|
||||
break;
|
||||
case EHTokUint3x1:
|
||||
new(&type) TType(EbtUint, EvqTemporary, 0, 1, 3);
|
||||
break;
|
||||
case EHTokUint3x2:
|
||||
new(&type) TType(EbtUint, EvqTemporary, 0, 2, 3);
|
||||
break;
|
||||
case EHTokUint3x3:
|
||||
new(&type) TType(EbtUint, EvqTemporary, 0, 3, 3);
|
||||
break;
|
||||
case EHTokUint3x4:
|
||||
new(&type) TType(EbtUint, EvqTemporary, 0, 4, 3);
|
||||
break;
|
||||
case EHTokUint4x1:
|
||||
new(&type) TType(EbtUint, EvqTemporary, 0, 1, 4);
|
||||
break;
|
||||
case EHTokUint4x2:
|
||||
new(&type) TType(EbtUint, EvqTemporary, 0, 2, 4);
|
||||
break;
|
||||
case EHTokUint4x3:
|
||||
new(&type) TType(EbtUint, EvqTemporary, 0, 3, 4);
|
||||
break;
|
||||
case EHTokUint4x4:
|
||||
new(&type) TType(EbtUint, EvqTemporary, 0, 4, 4);
|
||||
break;
|
||||
|
||||
case EHTokBool1x1:
|
||||
new(&type) TType(EbtBool, EvqTemporary, 0, 1, 1);
|
||||
break;
|
||||
case EHTokBool1x2:
|
||||
new(&type) TType(EbtBool, EvqTemporary, 0, 2, 1);
|
||||
break;
|
||||
case EHTokBool1x3:
|
||||
new(&type) TType(EbtBool, EvqTemporary, 0, 3, 1);
|
||||
break;
|
||||
case EHTokBool1x4:
|
||||
new(&type) TType(EbtBool, EvqTemporary, 0, 4, 1);
|
||||
break;
|
||||
case EHTokBool2x1:
|
||||
new(&type) TType(EbtBool, EvqTemporary, 0, 1, 2);
|
||||
break;
|
||||
case EHTokBool2x2:
|
||||
new(&type) TType(EbtBool, EvqTemporary, 0, 2, 2);
|
||||
break;
|
||||
case EHTokBool2x3:
|
||||
new(&type) TType(EbtBool, EvqTemporary, 0, 3, 2);
|
||||
break;
|
||||
case EHTokBool2x4:
|
||||
new(&type) TType(EbtBool, EvqTemporary, 0, 4, 2);
|
||||
break;
|
||||
case EHTokBool3x1:
|
||||
new(&type) TType(EbtBool, EvqTemporary, 0, 1, 3);
|
||||
break;
|
||||
case EHTokBool3x2:
|
||||
new(&type) TType(EbtBool, EvqTemporary, 0, 2, 3);
|
||||
break;
|
||||
case EHTokBool3x3:
|
||||
new(&type) TType(EbtBool, EvqTemporary, 0, 3, 3);
|
||||
break;
|
||||
case EHTokBool3x4:
|
||||
new(&type) TType(EbtBool, EvqTemporary, 0, 4, 3);
|
||||
break;
|
||||
case EHTokBool4x1:
|
||||
new(&type) TType(EbtBool, EvqTemporary, 0, 1, 4);
|
||||
break;
|
||||
case EHTokBool4x2:
|
||||
new(&type) TType(EbtBool, EvqTemporary, 0, 2, 4);
|
||||
break;
|
||||
case EHTokBool4x3:
|
||||
new(&type) TType(EbtBool, EvqTemporary, 0, 3, 4);
|
||||
break;
|
||||
case EHTokBool4x4:
|
||||
new(&type) TType(EbtBool, EvqTemporary, 0, 4, 4);
|
||||
break;
|
||||
|
||||
case EHTokFloat1x1:
|
||||
new(&type) TType(EbtFloat, EvqTemporary, 0, 1, 1);
|
||||
break;
|
||||
@@ -415,6 +559,7 @@ bool HlslGrammar::acceptType(TType& type)
|
||||
|
||||
// function_parameters
|
||||
// : LEFT_PAREN parameter_declaration COMMA parameter_declaration ... RIGHT_PAREN
|
||||
// | LEFT_PAREN VOID RIGHT_PAREN
|
||||
//
|
||||
bool HlslGrammar::acceptFunctionParameters(TFunction& function)
|
||||
{
|
||||
@@ -422,15 +567,18 @@ bool HlslGrammar::acceptFunctionParameters(TFunction& function)
|
||||
if (! acceptTokenClass(EHTokLeftParen))
|
||||
return false;
|
||||
|
||||
do {
|
||||
// parameter_declaration
|
||||
if (! acceptParameterDeclaration(function))
|
||||
break;
|
||||
// VOID RIGHT_PAREN
|
||||
if (! acceptTokenClass(EHTokVoid)) {
|
||||
do {
|
||||
// parameter_declaration
|
||||
if (! acceptParameterDeclaration(function))
|
||||
break;
|
||||
|
||||
// COMMA
|
||||
if (! acceptTokenClass(EHTokComma))
|
||||
break;
|
||||
} while (true);
|
||||
// COMMA
|
||||
if (! acceptTokenClass(EHTokComma))
|
||||
break;
|
||||
} while (true);
|
||||
}
|
||||
|
||||
// RIGHT_PAREN
|
||||
if (! acceptTokenClass(EHTokRightParen)) {
|
||||
|
||||
@@ -168,6 +168,38 @@ void HlslScanContext::fillInKeywordMap()
|
||||
(*KeywordMap)["int4x2"] = EHTokInt4x2;
|
||||
(*KeywordMap)["int4x3"] = EHTokInt4x3;
|
||||
(*KeywordMap)["int4x4"] = EHTokInt4x4;
|
||||
(*KeywordMap)["uint1x1"] = EHTokUint1x1;
|
||||
(*KeywordMap)["uint1x2"] = EHTokUint1x2;
|
||||
(*KeywordMap)["uint1x3"] = EHTokUint1x3;
|
||||
(*KeywordMap)["uint1x4"] = EHTokUint1x4;
|
||||
(*KeywordMap)["uint2x1"] = EHTokUint2x1;
|
||||
(*KeywordMap)["uint2x2"] = EHTokUint2x2;
|
||||
(*KeywordMap)["uint2x3"] = EHTokUint2x3;
|
||||
(*KeywordMap)["uint2x4"] = EHTokUint2x4;
|
||||
(*KeywordMap)["uint3x1"] = EHTokUint3x1;
|
||||
(*KeywordMap)["uint3x2"] = EHTokUint3x2;
|
||||
(*KeywordMap)["uint3x3"] = EHTokUint3x3;
|
||||
(*KeywordMap)["uint3x4"] = EHTokUint3x4;
|
||||
(*KeywordMap)["uint4x1"] = EHTokUint4x1;
|
||||
(*KeywordMap)["uint4x2"] = EHTokUint4x2;
|
||||
(*KeywordMap)["uint4x3"] = EHTokUint4x3;
|
||||
(*KeywordMap)["uint4x4"] = EHTokUint4x4;
|
||||
(*KeywordMap)["bool1x1"] = EHTokBool1x1;
|
||||
(*KeywordMap)["bool1x2"] = EHTokBool1x2;
|
||||
(*KeywordMap)["bool1x3"] = EHTokBool1x3;
|
||||
(*KeywordMap)["bool1x4"] = EHTokBool1x4;
|
||||
(*KeywordMap)["bool2x1"] = EHTokBool2x1;
|
||||
(*KeywordMap)["bool2x2"] = EHTokBool2x2;
|
||||
(*KeywordMap)["bool2x3"] = EHTokBool2x3;
|
||||
(*KeywordMap)["bool2x4"] = EHTokBool2x4;
|
||||
(*KeywordMap)["bool3x1"] = EHTokBool3x1;
|
||||
(*KeywordMap)["bool3x2"] = EHTokBool3x2;
|
||||
(*KeywordMap)["bool3x3"] = EHTokBool3x3;
|
||||
(*KeywordMap)["bool3x4"] = EHTokBool3x4;
|
||||
(*KeywordMap)["bool4x1"] = EHTokBool4x1;
|
||||
(*KeywordMap)["bool4x2"] = EHTokBool4x2;
|
||||
(*KeywordMap)["bool4x3"] = EHTokBool4x3;
|
||||
(*KeywordMap)["bool4x4"] = EHTokBool4x4;
|
||||
(*KeywordMap)["float1x1"] = EHTokFloat1x1;
|
||||
(*KeywordMap)["float1x2"] = EHTokFloat1x2;
|
||||
(*KeywordMap)["float1x3"] = EHTokFloat1x3;
|
||||
|
||||
@@ -119,6 +119,38 @@ enum EHlslTokenClass {
|
||||
EHTokInt4x2,
|
||||
EHTokInt4x3,
|
||||
EHTokInt4x4,
|
||||
EHTokUint1x1,
|
||||
EHTokUint1x2,
|
||||
EHTokUint1x3,
|
||||
EHTokUint1x4,
|
||||
EHTokUint2x1,
|
||||
EHTokUint2x2,
|
||||
EHTokUint2x3,
|
||||
EHTokUint2x4,
|
||||
EHTokUint3x1,
|
||||
EHTokUint3x2,
|
||||
EHTokUint3x3,
|
||||
EHTokUint3x4,
|
||||
EHTokUint4x1,
|
||||
EHTokUint4x2,
|
||||
EHTokUint4x3,
|
||||
EHTokUint4x4,
|
||||
EHTokBool1x1,
|
||||
EHTokBool1x2,
|
||||
EHTokBool1x3,
|
||||
EHTokBool1x4,
|
||||
EHTokBool2x1,
|
||||
EHTokBool2x2,
|
||||
EHTokBool2x3,
|
||||
EHTokBool2x4,
|
||||
EHTokBool3x1,
|
||||
EHTokBool3x2,
|
||||
EHTokBool3x3,
|
||||
EHTokBool3x4,
|
||||
EHTokBool4x1,
|
||||
EHTokBool4x2,
|
||||
EHTokBool4x3,
|
||||
EHTokBool4x4,
|
||||
EHTokFloat1x1,
|
||||
EHTokFloat1x2,
|
||||
EHTokFloat1x3,
|
||||
|
||||
Reference in New Issue
Block a user