Skip to content

Commit

Permalink
Merge pull request #249 from Nielsbishere/uint64_t
Browse files Browse the repository at this point in the history
64-bit xint and 16-bit xint and float support (as well as vectors, matrices).
  • Loading branch information
tgjones authored Jul 30, 2023
2 parents 5468714 + ed5d67e commit 3638d7f
Show file tree
Hide file tree
Showing 9 changed files with 1,216 additions and 1,162 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,15 @@ public class DeclarationParsingTests
[Theory]
[InlineData("bool")]
[InlineData("int")]
[InlineData("int64_t")]
[InlineData("int16_t")]
[InlineData("unsigned int")]
[InlineData("dword")]
[InlineData("uint")]
[InlineData("uint64_t")]
[InlineData("uint16_t")]
[InlineData("half")]
[InlineData("float16_t")]
[InlineData("float")]
[InlineData("double")]
[InlineData("min16float")]
Expand All @@ -31,10 +36,34 @@ public class DeclarationParsingTests
[InlineData("half2")]
[InlineData("half3")]
[InlineData("half4")]
[InlineData("float16_t1")]
[InlineData("float16_t2")]
[InlineData("float16_t3")]
[InlineData("float16_t4")]
[InlineData("int1")]
[InlineData("int2")]
[InlineData("int3")]
[InlineData("int4")]
[InlineData("int64_t1")]
[InlineData("int64_t2")]
[InlineData("int64_t3")]
[InlineData("int64_t4")]
[InlineData("int16_t1")]
[InlineData("int16_t2")]
[InlineData("int16_t3")]
[InlineData("int16_t4")]
[InlineData("uint1")]
[InlineData("uint2")]
[InlineData("uint3")]
[InlineData("uint4")]
[InlineData("uint64_t1")]
[InlineData("uint64_t2")]
[InlineData("uint64_t3")]
[InlineData("uint64_t4")]
[InlineData("uint16_t1")]
[InlineData("uint16_t2")]
[InlineData("uint16_t3")]
[InlineData("uint16_t4")]
[InlineData("float1")]
[InlineData("float2")]
[InlineData("float3")]
Expand Down Expand Up @@ -112,6 +141,22 @@ public class DeclarationParsingTests
[InlineData("half4x2")]
[InlineData("half4x3")]
[InlineData("half4x4")]
[InlineData("float16_t1x1")]
[InlineData("float16_t1x2")]
[InlineData("float16_t1x3")]
[InlineData("float16_t1x4")]
[InlineData("float16_t2x1")]
[InlineData("float16_t2x2")]
[InlineData("float16_t2x3")]
[InlineData("float16_t2x4")]
[InlineData("float16_t3x1")]
[InlineData("float16_t3x2")]
[InlineData("float16_t3x3")]
[InlineData("float16_t3x4")]
[InlineData("float16_t4x1")]
[InlineData("float16_t4x2")]
[InlineData("float16_t4x3")]
[InlineData("float16_t4x4")]
[InlineData("float1x1")]
[InlineData("float1x2")]
[InlineData("float1x3")]
Expand Down Expand Up @@ -160,6 +205,70 @@ public class DeclarationParsingTests
[InlineData("uint4x2")]
[InlineData("uint4x3")]
[InlineData("uint4x4")]
[InlineData("int64_t1x1")]
[InlineData("int64_t1x2")]
[InlineData("int64_t1x3")]
[InlineData("int64_t1x4")]
[InlineData("int64_t2x1")]
[InlineData("int64_t2x2")]
[InlineData("int64_t2x3")]
[InlineData("int64_t2x4")]
[InlineData("int64_t3x1")]
[InlineData("int64_t3x2")]
[InlineData("int64_t3x3")]
[InlineData("int64_t3x4")]
[InlineData("int64_t4x1")]
[InlineData("int64_t4x2")]
[InlineData("int64_t4x3")]
[InlineData("int64_t4x4")]
[InlineData("uint64_t1x1")]
[InlineData("uint64_t1x2")]
[InlineData("uint64_t1x3")]
[InlineData("uint64_t1x4")]
[InlineData("uint64_t2x1")]
[InlineData("uint64_t2x2")]
[InlineData("uint64_t2x3")]
[InlineData("uint64_t2x4")]
[InlineData("uint64_t3x1")]
[InlineData("uint64_t3x2")]
[InlineData("uint64_t3x3")]
[InlineData("uint64_t3x4")]
[InlineData("uint64_t4x1")]
[InlineData("uint64_t4x2")]
[InlineData("uint64_t4x3")]
[InlineData("uint64_t4x4")]
[InlineData("int16_t1x1")]
[InlineData("int16_t1x2")]
[InlineData("int16_t1x3")]
[InlineData("int16_t1x4")]
[InlineData("int16_t2x1")]
[InlineData("int16_t2x2")]
[InlineData("int16_t2x3")]
[InlineData("int16_t2x4")]
[InlineData("int16_t3x1")]
[InlineData("int16_t3x2")]
[InlineData("int16_t3x3")]
[InlineData("int16_t3x4")]
[InlineData("int16_t4x1")]
[InlineData("int16_t4x2")]
[InlineData("int16_t4x3")]
[InlineData("int16_t4x4")]
[InlineData("uint16_t1x1")]
[InlineData("uint16_t1x2")]
[InlineData("uint16_t1x3")]
[InlineData("uint16_t1x4")]
[InlineData("uint16_t2x1")]
[InlineData("uint16_t2x2")]
[InlineData("uint16_t2x3")]
[InlineData("uint16_t2x4")]
[InlineData("uint16_t3x1")]
[InlineData("uint16_t3x2")]
[InlineData("uint16_t3x3")]
[InlineData("uint16_t3x4")]
[InlineData("uint16_t4x1")]
[InlineData("uint16_t4x2")]
[InlineData("uint16_t4x3")]
[InlineData("uint16_t4x4")]
[InlineData("min16float1x1")]
[InlineData("min16float1x2")]
[InlineData("min16float1x3")]
Expand Down
12 changes: 11 additions & 1 deletion src/ShaderTools.CodeAnalysis.Hlsl/Binding/Binder.Types.cs
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,17 @@ private BoundScalarType BindScalarType(ScalarTypeSyntax node)
return new BoundScalarType(IntrinsicTypes.Int);
case ScalarType.Uint:
return new BoundScalarType(IntrinsicTypes.Uint);
case ScalarType.Half:
case ScalarType.Int64_t:
return new BoundScalarType(IntrinsicTypes.Int64_t);
case ScalarType.Uint64_t:
return new BoundScalarType(IntrinsicTypes.Uint64_t);
case ScalarType.Int16_t:
return new BoundScalarType(IntrinsicTypes.Int16_t);
case ScalarType.Uint16_t:
return new BoundScalarType(IntrinsicTypes.Uint16_t);
case ScalarType.Float16_t:
return new BoundScalarType(IntrinsicTypes.Float16_t);
case ScalarType.Half:
return new BoundScalarType(IntrinsicTypes.Half);
case ScalarType.Float:
return new BoundScalarType(IntrinsicTypes.Float);
Expand Down
5 changes: 5 additions & 0 deletions src/ShaderTools.CodeAnalysis.Hlsl/Binding/SemanticFacts.cs
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,10 @@ public static bool IsIntegral(this ScalarType scalarType)
case ScalarType.Bool:
case ScalarType.Int:
case ScalarType.Uint:
case ScalarType.Int64_t:
case ScalarType.Uint64_t:
case ScalarType.Int16_t:
case ScalarType.Uint16_t:
case ScalarType.Min16Int:
case ScalarType.Min12Int:
case ScalarType.Min16Uint:
Expand All @@ -92,6 +96,7 @@ public static bool IsFloat(this ScalarType scalarType)
switch (scalarType)
{
case ScalarType.Half:
case ScalarType.Float16_t:
case ScalarType.Float:
case ScalarType.Double:
case ScalarType.Min16Float:
Expand Down
15 changes: 14 additions & 1 deletion src/ShaderTools.CodeAnalysis.Hlsl/Compilation/Conversion.cs
Original file line number Diff line number Diff line change
Expand Up @@ -87,13 +87,15 @@ private static ConversionTypes ClassifyTypeConversion(IntrinsicNumericTypeSymbol
switch (parameterScalarType)
{
case ScalarType.Half:
case ScalarType.Float16_t:
case ScalarType.Min10Float:
case ScalarType.Min16Float:
return ConversionTypes.FloatTruncation;
case ScalarType.Double:
return ConversionTypes.FloatPromotion;
}
break;
case ScalarType.Float16_t:
case ScalarType.Half:
switch (parameterScalarType)
{
Expand All @@ -109,6 +111,7 @@ private static ConversionTypes ClassifyTypeConversion(IntrinsicNumericTypeSymbol
switch (parameterScalarType)
{
case ScalarType.Half:
case ScalarType.Float16_t:
case ScalarType.Float:
case ScalarType.Min16Float:
case ScalarType.Min10Float:
Expand All @@ -122,6 +125,7 @@ private static ConversionTypes ClassifyTypeConversion(IntrinsicNumericTypeSymbol
case ScalarType.Double:
return ConversionTypes.FloatPromotion;
case ScalarType.Half:
case ScalarType.Float16_t:
case ScalarType.Min10Float:
return ConversionTypes.FloatTruncation;
}
Expand All @@ -130,6 +134,7 @@ private static ConversionTypes ClassifyTypeConversion(IntrinsicNumericTypeSymbol
switch (parameterScalarType)
{
case ScalarType.Half:
case ScalarType.Float16_t:
case ScalarType.Float:
case ScalarType.Double:
case ScalarType.Min16Float:
Expand All @@ -142,21 +147,29 @@ private static ConversionTypes ClassifyTypeConversion(IntrinsicNumericTypeSymbol
return ConversionTypes.IntToFloatConversion;
break;
case ScalarType.Int:
case ScalarType.Int64_t:
case ScalarType.Int16_t:
case ScalarType.Min16Int:
case ScalarType.Min12Int:
switch (parameterScalarType)
{
case ScalarType.Uint:
case ScalarType.Uint64_t:
case ScalarType.Uint16_t:
case ScalarType.Min16Uint:
return ConversionTypes.SignedToUnsigned;
}
break;
case ScalarType.Uint:
case ScalarType.Uint64_t:
case ScalarType.Uint16_t:
case ScalarType.Min16Uint:
switch (parameterScalarType)
{
case ScalarType.Int:
case ScalarType.Min16Int:
case ScalarType.Int64_t:
case ScalarType.Int16_t:
case ScalarType.Min16Int:
case ScalarType.Min12Int:
return ConversionTypes.UnsignedToSigned;
}
Expand Down
Loading

0 comments on commit 3638d7f

Please sign in to comment.