From f0ee13e243a8cbbc2a6f8516ef2034e6e7e26e11 Mon Sep 17 00:00:00 2001 From: Sergio Pedri Date: Sun, 28 Aug 2022 14:40:49 +0200 Subject: [PATCH] Move mul() overload info to separate .ttinclude file --- .../Intrinsics/Hlsl.MulOverloads.ttinclude | 284 ++++++++++++++++++ .../Intrinsics/Hlsl.ttinclude | 3 +- .../Primitives/VectorType.ttinclude | 3 +- 3 files changed, 286 insertions(+), 4 deletions(-) create mode 100644 src/ComputeSharp.Core/Intrinsics/Hlsl.MulOverloads.ttinclude diff --git a/src/ComputeSharp.Core/Intrinsics/Hlsl.MulOverloads.ttinclude b/src/ComputeSharp.Core/Intrinsics/Hlsl.MulOverloads.ttinclude new file mode 100644 index 00000000..ab6c8918 --- /dev/null +++ b/src/ComputeSharp.Core/Intrinsics/Hlsl.MulOverloads.ttinclude @@ -0,0 +1,284 @@ +<#@ template debug="false" hostspecific="false" language="C#" #> +<#@ assembly name="System.Core" #> +<# +var MulOverloads = new[] +{ + // 1 (scalars) + new { Return = "float", Params = new[] { "float", "float" } }, + new { Return = "int", Params = new[] { "int", "int" } }, + + // 2 (scalar by vector) + new { Return = "Float2", Params = new[] { "float", "Float2" } }, + new { Return = "Float3", Params = new[] { "float", "Float3" } }, + new { Return = "Float4", Params = new[] { "float", "Float4" } }, + new { Return = "Int2", Params = new[] { "int", "Int2" } }, + new { Return = "Int3", Params = new[] { "int", "Int3" } }, + new { Return = "Int4", Params = new[] { "int", "Int4" } }, + + // 3 (scalar by matrix) + new { Return = "Float1x1", Params = new[] { "float", "Float1x1" } }, + new { Return = "Float1x2", Params = new[] { "float", "Float1x2" } }, + new { Return = "Float1x3", Params = new[] { "float", "Float1x3" } }, + new { Return = "Float1x4", Params = new[] { "float", "Float1x4" } }, + new { Return = "Float2x1", Params = new[] { "float", "Float2x1" } }, + new { Return = "Float2x2", Params = new[] { "float", "Float2x2" } }, + new { Return = "Float2x3", Params = new[] { "float", "Float2x3" } }, + new { Return = "Float2x4", Params = new[] { "float", "Float2x4" } }, + new { Return = "Float3x1", Params = new[] { "float", "Float3x1" } }, + new { Return = "Float3x2", Params = new[] { "float", "Float3x2" } }, + new { Return = "Float3x3", Params = new[] { "float", "Float3x3" } }, + new { Return = "Float3x4", Params = new[] { "float", "Float3x4" } }, + new { Return = "Float4x1", Params = new[] { "float", "Float4x1" } }, + new { Return = "Float4x2", Params = new[] { "float", "Float4x2" } }, + new { Return = "Float4x3", Params = new[] { "float", "Float4x3" } }, + new { Return = "Float4x4", Params = new[] { "float", "Float4x4" } }, + new { Return = "Int1x1", Params = new[] { "int", "Int1x1" } }, + new { Return = "Int1x2", Params = new[] { "int", "Int1x2" } }, + new { Return = "Int1x3", Params = new[] { "int", "Int1x3" } }, + new { Return = "Int1x4", Params = new[] { "int", "Int1x4" } }, + new { Return = "Int2x1", Params = new[] { "int", "Int2x1" } }, + new { Return = "Int2x2", Params = new[] { "int", "Int2x2" } }, + new { Return = "Int2x3", Params = new[] { "int", "Int2x3" } }, + new { Return = "Int2x4", Params = new[] { "int", "Int2x4" } }, + new { Return = "Int3x1", Params = new[] { "int", "Int3x1" } }, + new { Return = "Int3x2", Params = new[] { "int", "Int3x2" } }, + new { Return = "Int3x3", Params = new[] { "int", "Int3x3" } }, + new { Return = "Int3x4", Params = new[] { "int", "Int3x4" } }, + new { Return = "Int4x1", Params = new[] { "int", "Int4x1" } }, + new { Return = "Int4x2", Params = new[] { "int", "Int4x2" } }, + new { Return = "Int4x3", Params = new[] { "int", "Int4x3" } }, + new { Return = "Int4x4", Params = new[] { "int", "Int4x4" } }, + + // 4 (vector by scalar) + new { Return = "Float2", Params = new[] { "Float2", "float" } }, + new { Return = "Float3", Params = new[] { "Float3", "float" } }, + new { Return = "Float4", Params = new[] { "Float4", "float" } }, + new { Return = "Int2", Params = new[] { "Int2", "int" } }, + new { Return = "Int3", Params = new[] { "Int3", "int" } }, + new { Return = "Int4", Params = new[] { "Int4", "int" } }, + + // 5 (vector by vector) + new { Return = "float", Params = new[] { "Float2", "Float2" } }, + new { Return = "float", Params = new[] { "Float3", "Float3" } }, + new { Return = "float", Params = new[] { "Float4", "Float4" } }, + new { Return = "int", Params = new[] { "Int2", "Int2" } }, + new { Return = "int", Params = new[] { "Int3", "Int3" } }, + new { Return = "int", Params = new[] { "Int4", "Int4" } }, + + // 6 (vector by matrix) + new { Return = "float", Params = new[] { "Float2", "Float2x1" } }, + new { Return = "Float2", Params = new[] { "Float2", "Float2x2" } }, + new { Return = "Float3", Params = new[] { "Float2", "Float2x3" } }, + new { Return = "Float4", Params = new[] { "Float2", "Float2x4" } }, + new { Return = "float", Params = new[] { "Float3", "Float3x1" } }, + new { Return = "Float2", Params = new[] { "Float3", "Float3x2" } }, + new { Return = "Float3", Params = new[] { "Float3", "Float3x3" } }, + new { Return = "Float4", Params = new[] { "Float3", "Float3x4" } }, + new { Return = "float", Params = new[] { "Float4", "Float4x1" } }, + new { Return = "Float2", Params = new[] { "Float4", "Float4x2" } }, + new { Return = "Float3", Params = new[] { "Float4", "Float4x3" } }, + new { Return = "Float4", Params = new[] { "Float4", "Float4x4" } }, + new { Return = "int", Params = new[] { "Int2", "Int2x1" } }, + new { Return = "Int2", Params = new[] { "Int2", "Int2x2" } }, + new { Return = "Int3", Params = new[] { "Int2", "Int2x3" } }, + new { Return = "Int4", Params = new[] { "Int2", "Int2x4" } }, + new { Return = "int", Params = new[] { "Int3", "Int3x1" } }, + new { Return = "Int2", Params = new[] { "Int3", "Int3x2" } }, + new { Return = "Int3", Params = new[] { "Int3", "Int3x3" } }, + new { Return = "Int4", Params = new[] { "Int3", "Int3x4" } }, + new { Return = "int", Params = new[] { "Int4", "Int4x1" } }, + new { Return = "Int2", Params = new[] { "Int4", "Int4x2" } }, + new { Return = "Int3", Params = new[] { "Int4", "Int4x3" } }, + new { Return = "Int4", Params = new[] { "Int4", "Int4x4" } }, + + // 7 (matrix by scalar) + new { Return = "Float1x1", Params = new[] { "Float1x1", "float" } }, + new { Return = "Float1x2", Params = new[] { "Float1x2", "float" } }, + new { Return = "Float1x3", Params = new[] { "Float1x3", "float" } }, + new { Return = "Float1x4", Params = new[] { "Float1x4", "float" } }, + new { Return = "Float2x1", Params = new[] { "Float2x1", "float" } }, + new { Return = "Float2x2", Params = new[] { "Float2x2", "float" } }, + new { Return = "Float2x3", Params = new[] { "Float2x3", "float" } }, + new { Return = "Float2x4", Params = new[] { "Float2x4", "float" } }, + new { Return = "Float3x1", Params = new[] { "Float3x1", "float" } }, + new { Return = "Float3x2", Params = new[] { "Float3x2", "float" } }, + new { Return = "Float3x3", Params = new[] { "Float3x3", "float" } }, + new { Return = "Float3x4", Params = new[] { "Float3x4", "float" } }, + new { Return = "Float4x1", Params = new[] { "Float4x1", "float" } }, + new { Return = "Float4x2", Params = new[] { "Float4x2", "float" } }, + new { Return = "Float4x3", Params = new[] { "Float4x3", "float" } }, + new { Return = "Float4x4", Params = new[] { "Float4x4", "float" } }, + new { Return = "Int1x1", Params = new[] { "Int1x1", "int" } }, + new { Return = "Int1x2", Params = new[] { "Int1x2", "int" } }, + new { Return = "Int1x3", Params = new[] { "Int1x3", "int" } }, + new { Return = "Int1x4", Params = new[] { "Int1x4", "int" } }, + new { Return = "Int2x1", Params = new[] { "Int2x1", "int" } }, + new { Return = "Int2x2", Params = new[] { "Int2x2", "int" } }, + new { Return = "Int2x3", Params = new[] { "Int2x3", "int" } }, + new { Return = "Int2x4", Params = new[] { "Int2x4", "int" } }, + new { Return = "Int3x1", Params = new[] { "Int3x1", "int" } }, + new { Return = "Int3x2", Params = new[] { "Int3x2", "int" } }, + new { Return = "Int3x3", Params = new[] { "Int3x3", "int" } }, + new { Return = "Int3x4", Params = new[] { "Int3x4", "int" } }, + new { Return = "Int4x1", Params = new[] { "Int4x1", "int" } }, + new { Return = "Int4x2", Params = new[] { "Int4x2", "int" } }, + new { Return = "Int4x3", Params = new[] { "Int4x3", "int" } }, + new { Return = "Int4x4", Params = new[] { "Int4x4", "int" } }, + + // 8 (matrix by vector) + new { Return = "float", Params = new[] { "Float1x2", "Float2" } }, + new { Return = "float", Params = new[] { "Float1x3", "Float3" } }, + new { Return = "float", Params = new[] { "Float1x4", "Float4" } }, + new { Return = "Float2", Params = new[] { "Float2x2", "Float2" } }, + new { Return = "Float2", Params = new[] { "Float2x3", "Float3" } }, + new { Return = "Float2", Params = new[] { "Float2x4", "Float4" } }, + new { Return = "Float3", Params = new[] { "Float3x2", "Float2" } }, + new { Return = "Float3", Params = new[] { "Float3x3", "Float3" } }, + new { Return = "Float3", Params = new[] { "Float3x4", "Float4" } }, + new { Return = "Float4", Params = new[] { "Float4x2", "Float2" } }, + new { Return = "Float4", Params = new[] { "Float4x3", "Float3" } }, + new { Return = "Float4", Params = new[] { "Float4x4", "Float4" } }, + new { Return = "int", Params = new[] { "Int1x2", "Int2" } }, + new { Return = "int", Params = new[] { "Int1x3", "Int3" } }, + new { Return = "int", Params = new[] { "Int1x4", "Int4" } }, + new { Return = "Int2", Params = new[] { "Int2x2", "Int2" } }, + new { Return = "Int2", Params = new[] { "Int2x3", "Int3" } }, + new { Return = "Int2", Params = new[] { "Int2x4", "Int4" } }, + new { Return = "Int3", Params = new[] { "Int3x2", "Int2" } }, + new { Return = "Int3", Params = new[] { "Int3x3", "Int3" } }, + new { Return = "Int3", Params = new[] { "Int3x4", "Int4" } }, + new { Return = "Int4", Params = new[] { "Int4x2", "Int2" } }, + new { Return = "Int4", Params = new[] { "Int4x3", "Int3" } }, + new { Return = "Int4", Params = new[] { "Int4x4", "Int4" } }, + + // 9 (matrix by matrix) + new { Return = "Float1x1", Params = new[] { "Float1x1", "Float1x1" } }, + new { Return = "Float1x2", Params = new[] { "Float1x1", "Float1x2" } }, + new { Return = "Float1x3", Params = new[] { "Float1x1", "Float1x3" } }, + new { Return = "Float1x4", Params = new[] { "Float1x1", "Float1x4" } }, + new { Return = "Float1x1", Params = new[] { "Float1x2", "Float2x1" } }, + new { Return = "Float1x2", Params = new[] { "Float1x2", "Float2x2" } }, + new { Return = "Float1x3", Params = new[] { "Float1x2", "Float2x3" } }, + new { Return = "Float1x4", Params = new[] { "Float1x2", "Float2x4" } }, + new { Return = "Float1x1", Params = new[] { "Float1x3", "Float3x1" } }, + new { Return = "Float1x2", Params = new[] { "Float1x3", "Float3x2" } }, + new { Return = "Float1x3", Params = new[] { "Float1x3", "Float3x3" } }, + new { Return = "Float1x4", Params = new[] { "Float1x3", "Float3x4" } }, + new { Return = "Float1x1", Params = new[] { "Float1x4", "Float4x1" } }, + new { Return = "Float1x2", Params = new[] { "Float1x4", "Float4x2" } }, + new { Return = "Float1x3", Params = new[] { "Float1x4", "Float4x3" } }, + new { Return = "Float1x4", Params = new[] { "Float1x4", "Float4x4" } }, + new { Return = "Float2x1", Params = new[] { "Float2x1", "Float1x1" } }, + new { Return = "Float2x2", Params = new[] { "Float2x1", "Float1x2" } }, + new { Return = "Float2x3", Params = new[] { "Float2x1", "Float1x3" } }, + new { Return = "Float2x4", Params = new[] { "Float2x1", "Float1x4" } }, + new { Return = "Float2x1", Params = new[] { "Float2x2", "Float2x1" } }, + new { Return = "Float2x2", Params = new[] { "Float2x2", "Float2x2" } }, + new { Return = "Float2x3", Params = new[] { "Float2x2", "Float2x3" } }, + new { Return = "Float2x4", Params = new[] { "Float2x2", "Float2x4" } }, + new { Return = "Float2x1", Params = new[] { "Float2x3", "Float3x1" } }, + new { Return = "Float2x2", Params = new[] { "Float2x3", "Float3x2" } }, + new { Return = "Float2x3", Params = new[] { "Float2x3", "Float3x3" } }, + new { Return = "Float2x4", Params = new[] { "Float2x3", "Float3x4" } }, + new { Return = "Float2x1", Params = new[] { "Float2x4", "Float4x1" } }, + new { Return = "Float2x2", Params = new[] { "Float2x4", "Float4x2" } }, + new { Return = "Float2x3", Params = new[] { "Float2x4", "Float4x3" } }, + new { Return = "Float2x4", Params = new[] { "Float2x4", "Float4x4" } }, + new { Return = "Float3x1", Params = new[] { "Float3x1", "Float1x1" } }, + new { Return = "Float3x2", Params = new[] { "Float3x1", "Float1x2" } }, + new { Return = "Float3x3", Params = new[] { "Float3x1", "Float1x3" } }, + new { Return = "Float3x4", Params = new[] { "Float3x1", "Float1x4" } }, + new { Return = "Float3x1", Params = new[] { "Float3x2", "Float2x1" } }, + new { Return = "Float3x2", Params = new[] { "Float3x2", "Float2x2" } }, + new { Return = "Float3x3", Params = new[] { "Float3x2", "Float2x3" } }, + new { Return = "Float3x4", Params = new[] { "Float3x2", "Float2x4" } }, + new { Return = "Float3x1", Params = new[] { "Float3x3", "Float3x1" } }, + new { Return = "Float3x2", Params = new[] { "Float3x3", "Float3x2" } }, + new { Return = "Float3x3", Params = new[] { "Float3x3", "Float3x3" } }, + new { Return = "Float3x4", Params = new[] { "Float3x3", "Float3x4" } }, + new { Return = "Float3x1", Params = new[] { "Float3x4", "Float4x1" } }, + new { Return = "Float3x2", Params = new[] { "Float3x4", "Float4x2" } }, + new { Return = "Float3x3", Params = new[] { "Float3x4", "Float4x3" } }, + new { Return = "Float3x4", Params = new[] { "Float3x4", "Float4x4" } }, + new { Return = "Float4x1", Params = new[] { "Float4x1", "Float1x1" } }, + new { Return = "Float4x2", Params = new[] { "Float4x1", "Float1x2" } }, + new { Return = "Float4x3", Params = new[] { "Float4x1", "Float1x3" } }, + new { Return = "Float4x4", Params = new[] { "Float4x1", "Float1x4" } }, + new { Return = "Float4x1", Params = new[] { "Float4x2", "Float2x1" } }, + new { Return = "Float4x2", Params = new[] { "Float4x2", "Float2x2" } }, + new { Return = "Float4x3", Params = new[] { "Float4x2", "Float2x3" } }, + new { Return = "Float4x4", Params = new[] { "Float4x2", "Float2x4" } }, + new { Return = "Float4x1", Params = new[] { "Float4x3", "Float3x1" } }, + new { Return = "Float4x2", Params = new[] { "Float4x3", "Float3x2" } }, + new { Return = "Float4x3", Params = new[] { "Float4x3", "Float3x3" } }, + new { Return = "Float4x4", Params = new[] { "Float4x3", "Float3x4" } }, + new { Return = "Float4x1", Params = new[] { "Float4x4", "Float4x1" } }, + new { Return = "Float4x2", Params = new[] { "Float4x4", "Float4x2" } }, + new { Return = "Float4x3", Params = new[] { "Float4x4", "Float4x3" } }, + new { Return = "Float4x4", Params = new[] { "Float4x4", "Float4x4" } }, + new { Return = "Int1x1", Params = new[] { "Int1x1", "Int1x1" } }, + new { Return = "Int1x2", Params = new[] { "Int1x1", "Int1x2" } }, + new { Return = "Int1x3", Params = new[] { "Int1x1", "Int1x3" } }, + new { Return = "Int1x4", Params = new[] { "Int1x1", "Int1x4" } }, + new { Return = "Int1x1", Params = new[] { "Int1x2", "Int2x1" } }, + new { Return = "Int1x2", Params = new[] { "Int1x2", "Int2x2" } }, + new { Return = "Int1x3", Params = new[] { "Int1x2", "Int2x3" } }, + new { Return = "Int1x4", Params = new[] { "Int1x2", "Int2x4" } }, + new { Return = "Int1x1", Params = new[] { "Int1x3", "Int3x1" } }, + new { Return = "Int1x2", Params = new[] { "Int1x3", "Int3x2" } }, + new { Return = "Int1x3", Params = new[] { "Int1x3", "Int3x3" } }, + new { Return = "Int1x4", Params = new[] { "Int1x3", "Int3x4" } }, + new { Return = "Int1x1", Params = new[] { "Int1x4", "Int4x1" } }, + new { Return = "Int1x2", Params = new[] { "Int1x4", "Int4x2" } }, + new { Return = "Int1x3", Params = new[] { "Int1x4", "Int4x3" } }, + new { Return = "Int1x4", Params = new[] { "Int1x4", "Int4x4" } }, + new { Return = "Int2x1", Params = new[] { "Int2x1", "Int1x1" } }, + new { Return = "Int2x2", Params = new[] { "Int2x1", "Int1x2" } }, + new { Return = "Int2x3", Params = new[] { "Int2x1", "Int1x3" } }, + new { Return = "Int2x4", Params = new[] { "Int2x1", "Int1x4" } }, + new { Return = "Int2x1", Params = new[] { "Int2x2", "Int2x1" } }, + new { Return = "Int2x2", Params = new[] { "Int2x2", "Int2x2" } }, + new { Return = "Int2x3", Params = new[] { "Int2x2", "Int2x3" } }, + new { Return = "Int2x4", Params = new[] { "Int2x2", "Int2x4" } }, + new { Return = "Int2x1", Params = new[] { "Int2x3", "Int3x1" } }, + new { Return = "Int2x2", Params = new[] { "Int2x3", "Int3x2" } }, + new { Return = "Int2x3", Params = new[] { "Int2x3", "Int3x3" } }, + new { Return = "Int2x4", Params = new[] { "Int2x3", "Int3x4" } }, + new { Return = "Int2x1", Params = new[] { "Int2x4", "Int4x1" } }, + new { Return = "Int2x2", Params = new[] { "Int2x4", "Int4x2" } }, + new { Return = "Int2x3", Params = new[] { "Int2x4", "Int4x3" } }, + new { Return = "Int2x4", Params = new[] { "Int2x4", "Int4x4" } }, + new { Return = "Int3x1", Params = new[] { "Int3x1", "Int1x1" } }, + new { Return = "Int3x2", Params = new[] { "Int3x1", "Int1x2" } }, + new { Return = "Int3x3", Params = new[] { "Int3x1", "Int1x3" } }, + new { Return = "Int3x4", Params = new[] { "Int3x1", "Int1x4" } }, + new { Return = "Int3x1", Params = new[] { "Int3x2", "Int2x1" } }, + new { Return = "Int3x2", Params = new[] { "Int3x2", "Int2x2" } }, + new { Return = "Int3x3", Params = new[] { "Int3x2", "Int2x3" } }, + new { Return = "Int3x4", Params = new[] { "Int3x2", "Int2x4" } }, + new { Return = "Int3x1", Params = new[] { "Int3x3", "Int3x1" } }, + new { Return = "Int3x2", Params = new[] { "Int3x3", "Int3x2" } }, + new { Return = "Int3x3", Params = new[] { "Int3x3", "Int3x3" } }, + new { Return = "Int3x4", Params = new[] { "Int3x3", "Int3x4" } }, + new { Return = "Int3x1", Params = new[] { "Int3x4", "Int4x1" } }, + new { Return = "Int3x2", Params = new[] { "Int3x4", "Int4x2" } }, + new { Return = "Int3x3", Params = new[] { "Int3x4", "Int4x3" } }, + new { Return = "Int3x4", Params = new[] { "Int3x4", "Int4x4" } }, + new { Return = "Int4x1", Params = new[] { "Int4x1", "Int1x1" } }, + new { Return = "Int4x2", Params = new[] { "Int4x1", "Int1x2" } }, + new { Return = "Int4x3", Params = new[] { "Int4x1", "Int1x3" } }, + new { Return = "Int4x4", Params = new[] { "Int4x1", "Int1x4" } }, + new { Return = "Int4x1", Params = new[] { "Int4x2", "Int2x1" } }, + new { Return = "Int4x2", Params = new[] { "Int4x2", "Int2x2" } }, + new { Return = "Int4x3", Params = new[] { "Int4x2", "Int2x3" } }, + new { Return = "Int4x4", Params = new[] { "Int4x2", "Int2x4" } }, + new { Return = "Int4x1", Params = new[] { "Int4x3", "Int3x1" } }, + new { Return = "Int4x2", Params = new[] { "Int4x3", "Int3x2" } }, + new { Return = "Int4x3", Params = new[] { "Int4x3", "Int3x3" } }, + new { Return = "Int4x4", Params = new[] { "Int4x3", "Int3x4" } }, + new { Return = "Int4x1", Params = new[] { "Int4x4", "Int4x1" } }, + new { Return = "Int4x2", Params = new[] { "Int4x4", "Int4x2" } }, + new { Return = "Int4x3", Params = new[] { "Int4x4", "Int4x3" } }, + new { Return = "Int4x4", Params = new[] { "Int4x4", "Int4x4" } }, +}; +#> \ No newline at end of file diff --git a/src/ComputeSharp.Core/Intrinsics/Hlsl.ttinclude b/src/ComputeSharp.Core/Intrinsics/Hlsl.ttinclude index 10f4e195..ba21edee 100644 --- a/src/ComputeSharp.Core/Intrinsics/Hlsl.ttinclude +++ b/src/ComputeSharp.Core/Intrinsics/Hlsl.ttinclude @@ -1,5 +1,4 @@ -<#@ template debug="false" hostspecific="false" language="C#" #> -<#@ assembly name="System.Core" #> +<#@include file="Hlsl.MulOverloads.ttinclude" #> <#@ import namespace="System.Linq" #> <#@ import namespace="System.Text" #> <#@ import namespace="System.Text.RegularExpressions" #> diff --git a/src/ComputeSharp.Core/Primitives/VectorType.ttinclude b/src/ComputeSharp.Core/Primitives/VectorType.ttinclude index e97ca1ec..22a5c954 100644 --- a/src/ComputeSharp.Core/Primitives/VectorType.ttinclude +++ b/src/ComputeSharp.Core/Primitives/VectorType.ttinclude @@ -1,5 +1,4 @@ -<#@ template debug="false" hostspecific="false" language="C#" #> -<#@ assembly name="System.Core" #> +<#@include file="..\Intrinsics\Hlsl.MulOverloads.ttinclude" #> <#@ import namespace="System.Linq" #> <#@ import namespace="System.Text" #> <#@ import namespace="System.Text.RegularExpressions" #>