Merge pull request #369 from Sergio0694/dev/mul-operators

Add GLSL-style mul() operators to HLSL primitives
このコミットが含まれているのは:
Sergio Pedri authored and GitHub committed 2022-08-28 23:56:35 +02:00
コミット 87ea2139b2
17ファイル変更
+3716 -11

検索条件に一致するファイルはありません

+284
ファイルの表示
@@ -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" } },
};
#>
+1 -2
ファイルの表示
@@ -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" #>
+89
ファイルの表示
@@ -1,5 +1,6 @@
using System;
using System.Globalization;
using ComputeSharp.Core.Intrinsics.Attributes;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
#if !NET6_0_OR_GREATER
@@ -498,6 +499,94 @@ public unsafe partial struct Float2
/// <remarks>This method is an intrinsic and can only be used within a shader on the GPU. Using it on the CPU is undefined behavior.</remarks>
public static Float2 operator *(Float2 left, Float2 right) => default;
/// <summary>
/// Multiplies a pair of <see cref="Float2"/> and <see cref="float"/> values.
/// </summary>
/// <param name="left">The <see cref="Float2"/> value to multiply.</param>
/// <param name="right">The <see cref="float"/> value to multiply.</param>
/// <returns>The result of multiplying <paramref name="left"/> and <paramref name="right"/>.</returns>
/// <remarks>This method is an intrinsic and can only be used within a shader on the GPU. Using it on the CPU is undefined behavior.</remarks>
public static Float2 operator *(Float2 left, float right) => default;
/// <summary>
/// Multiplies a pair of <see cref="float"/> and <see cref="Float2"/> values.
/// </summary>
/// <param name="left">The <see cref="float"/> value to multiply.</param>
/// <param name="right">The <see cref="Float2"/> value to multiply.</param>
/// <returns>The result of multiplying <paramref name="left"/> and <paramref name="right"/>.</returns>
/// <remarks>This method is an intrinsic and can only be used within a shader on the GPU. Using it on the CPU is undefined behavior.</remarks>
public static Float2 operator *(float left, Float2 right) => default;
/// <summary>
/// Multiplies two values using matrix math.
/// </summary>
/// <param name="x">The first Float2 input value.</param>
/// <param name="y">The second Float2x1 input value.</param>
/// <returns>The result of <paramref name="x"/> times <paramref name="y"/>. The result has the dimension <paramref name="x"/>-rows by <paramref name="y"/>-columns.</returns>
/// <remarks>
/// <para>This operator is equivalent to using <see cref="Hlsl.Mul(Float2, Float2x1)"/> with the same input arguments.</para>
/// <para>For more info, see <see href="https://docs.microsoft.com/windows/win32/direct3dhlsl/dx-graphics-hlsl-mul"/>.</para>
/// <para>This method is an intrinsic and can only be used within a shader on the GPU. Using it on the CPU is undefined behavior.</para>
/// </remarks>
[HlslIntrinsicName("mul", RequiresParametersMatching = true)]
public static float operator *(Float2 x, Float2x1 y) => default;
/// <summary>
/// Multiplies two values using matrix math.
/// </summary>
/// <param name="x">The first Float2 input value.</param>
/// <param name="y">The second Float2x2 input value.</param>
/// <returns>The result of <paramref name="x"/> times <paramref name="y"/>. The result has the dimension <paramref name="x"/>-rows by <paramref name="y"/>-columns.</returns>
/// <remarks>
/// <para>This operator is equivalent to using <see cref="Hlsl.Mul(Float2, Float2x2)"/> with the same input arguments.</para>
/// <para>For more info, see <see href="https://docs.microsoft.com/windows/win32/direct3dhlsl/dx-graphics-hlsl-mul"/>.</para>
/// <para>This method is an intrinsic and can only be used within a shader on the GPU. Using it on the CPU is undefined behavior.</para>
/// </remarks>
[HlslIntrinsicName("mul", RequiresParametersMatching = true)]
public static Float2 operator *(Float2 x, Float2x2 y) => default;
/// <summary>
/// Multiplies two values using matrix math.
/// </summary>
/// <param name="x">The first Float2 input value.</param>
/// <param name="y">The second Float2x3 input value.</param>
/// <returns>The result of <paramref name="x"/> times <paramref name="y"/>. The result has the dimension <paramref name="x"/>-rows by <paramref name="y"/>-columns.</returns>
/// <remarks>
/// <para>This operator is equivalent to using <see cref="Hlsl.Mul(Float2, Float2x3)"/> with the same input arguments.</para>
/// <para>For more info, see <see href="https://docs.microsoft.com/windows/win32/direct3dhlsl/dx-graphics-hlsl-mul"/>.</para>
/// <para>This method is an intrinsic and can only be used within a shader on the GPU. Using it on the CPU is undefined behavior.</para>
/// </remarks>
[HlslIntrinsicName("mul", RequiresParametersMatching = true)]
public static Float3 operator *(Float2 x, Float2x3 y) => default;
/// <summary>
/// Multiplies two values using matrix math.
/// </summary>
/// <param name="x">The first Float2 input value.</param>
/// <param name="y">The second Float2x4 input value.</param>
/// <returns>The result of <paramref name="x"/> times <paramref name="y"/>. The result has the dimension <paramref name="x"/>-rows by <paramref name="y"/>-columns.</returns>
/// <remarks>
/// <para>This operator is equivalent to using <see cref="Hlsl.Mul(Float2, Float2x4)"/> with the same input arguments.</para>
/// <para>For more info, see <see href="https://docs.microsoft.com/windows/win32/direct3dhlsl/dx-graphics-hlsl-mul"/>.</para>
/// <para>This method is an intrinsic and can only be used within a shader on the GPU. Using it on the CPU is undefined behavior.</para>
/// </remarks>
[HlslIntrinsicName("mul", RequiresParametersMatching = true)]
public static Float4 operator *(Float2 x, Float2x4 y) => default;
/// <summary>
/// Multiplies two values using matrix math.
/// </summary>
/// <param name="x">The first Float2x2 input value.</param>
/// <param name="y">The second Float2 input value.</param>
/// <returns>The result of <paramref name="x"/> times <paramref name="y"/>. The result has the dimension <paramref name="x"/>-rows by <paramref name="y"/>-columns.</returns>
/// <remarks>
/// <para>This operator is equivalent to using <see cref="Hlsl.Mul(Float2x2, Float2)"/> with the same input arguments.</para>
/// <para>For more info, see <see href="https://docs.microsoft.com/windows/win32/direct3dhlsl/dx-graphics-hlsl-mul"/>.</para>
/// <para>This method is an intrinsic and can only be used within a shader on the GPU. Using it on the CPU is undefined behavior.</para>
/// </remarks>
[HlslIntrinsicName("mul", RequiresParametersMatching = true)]
public static Float2 operator *(Float2x2 x, Float2 y) => default;
/// <summary>
/// Subtracts two <see cref="Float2"/> values.
/// </summary>
+89
ファイルの表示
@@ -1,5 +1,6 @@
using System;
using System.Globalization;
using ComputeSharp.Core.Intrinsics.Attributes;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
#if !NET6_0_OR_GREATER
@@ -1584,6 +1585,94 @@ public unsafe partial struct Float3
/// <remarks>This method is an intrinsic and can only be used within a shader on the GPU. Using it on the CPU is undefined behavior.</remarks>
public static Float3 operator *(Float3 left, Float3 right) => default;
/// <summary>
/// Multiplies a pair of <see cref="Float3"/> and <see cref="float"/> values.
/// </summary>
/// <param name="left">The <see cref="Float3"/> value to multiply.</param>
/// <param name="right">The <see cref="float"/> value to multiply.</param>
/// <returns>The result of multiplying <paramref name="left"/> and <paramref name="right"/>.</returns>
/// <remarks>This method is an intrinsic and can only be used within a shader on the GPU. Using it on the CPU is undefined behavior.</remarks>
public static Float3 operator *(Float3 left, float right) => default;
/// <summary>
/// Multiplies a pair of <see cref="float"/> and <see cref="Float3"/> values.
/// </summary>
/// <param name="left">The <see cref="float"/> value to multiply.</param>
/// <param name="right">The <see cref="Float3"/> value to multiply.</param>
/// <returns>The result of multiplying <paramref name="left"/> and <paramref name="right"/>.</returns>
/// <remarks>This method is an intrinsic and can only be used within a shader on the GPU. Using it on the CPU is undefined behavior.</remarks>
public static Float3 operator *(float left, Float3 right) => default;
/// <summary>
/// Multiplies two values using matrix math.
/// </summary>
/// <param name="x">The first Float3 input value.</param>
/// <param name="y">The second Float3x1 input value.</param>
/// <returns>The result of <paramref name="x"/> times <paramref name="y"/>. The result has the dimension <paramref name="x"/>-rows by <paramref name="y"/>-columns.</returns>
/// <remarks>
/// <para>This operator is equivalent to using <see cref="Hlsl.Mul(Float3, Float3x1)"/> with the same input arguments.</para>
/// <para>For more info, see <see href="https://docs.microsoft.com/windows/win32/direct3dhlsl/dx-graphics-hlsl-mul"/>.</para>
/// <para>This method is an intrinsic and can only be used within a shader on the GPU. Using it on the CPU is undefined behavior.</para>
/// </remarks>
[HlslIntrinsicName("mul", RequiresParametersMatching = true)]
public static float operator *(Float3 x, Float3x1 y) => default;
/// <summary>
/// Multiplies two values using matrix math.
/// </summary>
/// <param name="x">The first Float3 input value.</param>
/// <param name="y">The second Float3x2 input value.</param>
/// <returns>The result of <paramref name="x"/> times <paramref name="y"/>. The result has the dimension <paramref name="x"/>-rows by <paramref name="y"/>-columns.</returns>
/// <remarks>
/// <para>This operator is equivalent to using <see cref="Hlsl.Mul(Float3, Float3x2)"/> with the same input arguments.</para>
/// <para>For more info, see <see href="https://docs.microsoft.com/windows/win32/direct3dhlsl/dx-graphics-hlsl-mul"/>.</para>
/// <para>This method is an intrinsic and can only be used within a shader on the GPU. Using it on the CPU is undefined behavior.</para>
/// </remarks>
[HlslIntrinsicName("mul", RequiresParametersMatching = true)]
public static Float2 operator *(Float3 x, Float3x2 y) => default;
/// <summary>
/// Multiplies two values using matrix math.
/// </summary>
/// <param name="x">The first Float3 input value.</param>
/// <param name="y">The second Float3x3 input value.</param>
/// <returns>The result of <paramref name="x"/> times <paramref name="y"/>. The result has the dimension <paramref name="x"/>-rows by <paramref name="y"/>-columns.</returns>
/// <remarks>
/// <para>This operator is equivalent to using <see cref="Hlsl.Mul(Float3, Float3x3)"/> with the same input arguments.</para>
/// <para>For more info, see <see href="https://docs.microsoft.com/windows/win32/direct3dhlsl/dx-graphics-hlsl-mul"/>.</para>
/// <para>This method is an intrinsic and can only be used within a shader on the GPU. Using it on the CPU is undefined behavior.</para>
/// </remarks>
[HlslIntrinsicName("mul", RequiresParametersMatching = true)]
public static Float3 operator *(Float3 x, Float3x3 y) => default;
/// <summary>
/// Multiplies two values using matrix math.
/// </summary>
/// <param name="x">The first Float3 input value.</param>
/// <param name="y">The second Float3x4 input value.</param>
/// <returns>The result of <paramref name="x"/> times <paramref name="y"/>. The result has the dimension <paramref name="x"/>-rows by <paramref name="y"/>-columns.</returns>
/// <remarks>
/// <para>This operator is equivalent to using <see cref="Hlsl.Mul(Float3, Float3x4)"/> with the same input arguments.</para>
/// <para>For more info, see <see href="https://docs.microsoft.com/windows/win32/direct3dhlsl/dx-graphics-hlsl-mul"/>.</para>
/// <para>This method is an intrinsic and can only be used within a shader on the GPU. Using it on the CPU is undefined behavior.</para>
/// </remarks>
[HlslIntrinsicName("mul", RequiresParametersMatching = true)]
public static Float4 operator *(Float3 x, Float3x4 y) => default;
/// <summary>
/// Multiplies two values using matrix math.
/// </summary>
/// <param name="x">The first Float3x3 input value.</param>
/// <param name="y">The second Float3 input value.</param>
/// <returns>The result of <paramref name="x"/> times <paramref name="y"/>. The result has the dimension <paramref name="x"/>-rows by <paramref name="y"/>-columns.</returns>
/// <remarks>
/// <para>This operator is equivalent to using <see cref="Hlsl.Mul(Float3x3, Float3)"/> with the same input arguments.</para>
/// <para>For more info, see <see href="https://docs.microsoft.com/windows/win32/direct3dhlsl/dx-graphics-hlsl-mul"/>.</para>
/// <para>This method is an intrinsic and can only be used within a shader on the GPU. Using it on the CPU is undefined behavior.</para>
/// </remarks>
[HlslIntrinsicName("mul", RequiresParametersMatching = true)]
public static Float3 operator *(Float3x3 x, Float3 y) => default;
/// <summary>
/// Subtracts two <see cref="Float3"/> values.
/// </summary>
+89
ファイルの表示
@@ -1,5 +1,6 @@
using System;
using System.Globalization;
using ComputeSharp.Core.Intrinsics.Attributes;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
#if !NET6_0_OR_GREATER
@@ -4230,6 +4231,94 @@ public unsafe partial struct Float4
/// <remarks>This method is an intrinsic and can only be used within a shader on the GPU. Using it on the CPU is undefined behavior.</remarks>
public static Float4 operator *(Float4 left, Float4 right) => default;
/// <summary>
/// Multiplies a pair of <see cref="Float4"/> and <see cref="float"/> values.
/// </summary>
/// <param name="left">The <see cref="Float4"/> value to multiply.</param>
/// <param name="right">The <see cref="float"/> value to multiply.</param>
/// <returns>The result of multiplying <paramref name="left"/> and <paramref name="right"/>.</returns>
/// <remarks>This method is an intrinsic and can only be used within a shader on the GPU. Using it on the CPU is undefined behavior.</remarks>
public static Float4 operator *(Float4 left, float right) => default;
/// <summary>
/// Multiplies a pair of <see cref="float"/> and <see cref="Float4"/> values.
/// </summary>
/// <param name="left">The <see cref="float"/> value to multiply.</param>
/// <param name="right">The <see cref="Float4"/> value to multiply.</param>
/// <returns>The result of multiplying <paramref name="left"/> and <paramref name="right"/>.</returns>
/// <remarks>This method is an intrinsic and can only be used within a shader on the GPU. Using it on the CPU is undefined behavior.</remarks>
public static Float4 operator *(float left, Float4 right) => default;
/// <summary>
/// Multiplies two values using matrix math.
/// </summary>
/// <param name="x">The first Float4 input value.</param>
/// <param name="y">The second Float4x1 input value.</param>
/// <returns>The result of <paramref name="x"/> times <paramref name="y"/>. The result has the dimension <paramref name="x"/>-rows by <paramref name="y"/>-columns.</returns>
/// <remarks>
/// <para>This operator is equivalent to using <see cref="Hlsl.Mul(Float4, Float4x1)"/> with the same input arguments.</para>
/// <para>For more info, see <see href="https://docs.microsoft.com/windows/win32/direct3dhlsl/dx-graphics-hlsl-mul"/>.</para>
/// <para>This method is an intrinsic and can only be used within a shader on the GPU. Using it on the CPU is undefined behavior.</para>
/// </remarks>
[HlslIntrinsicName("mul", RequiresParametersMatching = true)]
public static float operator *(Float4 x, Float4x1 y) => default;
/// <summary>
/// Multiplies two values using matrix math.
/// </summary>
/// <param name="x">The first Float4 input value.</param>
/// <param name="y">The second Float4x2 input value.</param>
/// <returns>The result of <paramref name="x"/> times <paramref name="y"/>. The result has the dimension <paramref name="x"/>-rows by <paramref name="y"/>-columns.</returns>
/// <remarks>
/// <para>This operator is equivalent to using <see cref="Hlsl.Mul(Float4, Float4x2)"/> with the same input arguments.</para>
/// <para>For more info, see <see href="https://docs.microsoft.com/windows/win32/direct3dhlsl/dx-graphics-hlsl-mul"/>.</para>
/// <para>This method is an intrinsic and can only be used within a shader on the GPU. Using it on the CPU is undefined behavior.</para>
/// </remarks>
[HlslIntrinsicName("mul", RequiresParametersMatching = true)]
public static Float2 operator *(Float4 x, Float4x2 y) => default;
/// <summary>
/// Multiplies two values using matrix math.
/// </summary>
/// <param name="x">The first Float4 input value.</param>
/// <param name="y">The second Float4x3 input value.</param>
/// <returns>The result of <paramref name="x"/> times <paramref name="y"/>. The result has the dimension <paramref name="x"/>-rows by <paramref name="y"/>-columns.</returns>
/// <remarks>
/// <para>This operator is equivalent to using <see cref="Hlsl.Mul(Float4, Float4x3)"/> with the same input arguments.</para>
/// <para>For more info, see <see href="https://docs.microsoft.com/windows/win32/direct3dhlsl/dx-graphics-hlsl-mul"/>.</para>
/// <para>This method is an intrinsic and can only be used within a shader on the GPU. Using it on the CPU is undefined behavior.</para>
/// </remarks>
[HlslIntrinsicName("mul", RequiresParametersMatching = true)]
public static Float3 operator *(Float4 x, Float4x3 y) => default;
/// <summary>
/// Multiplies two values using matrix math.
/// </summary>
/// <param name="x">The first Float4 input value.</param>
/// <param name="y">The second Float4x4 input value.</param>
/// <returns>The result of <paramref name="x"/> times <paramref name="y"/>. The result has the dimension <paramref name="x"/>-rows by <paramref name="y"/>-columns.</returns>
/// <remarks>
/// <para>This operator is equivalent to using <see cref="Hlsl.Mul(Float4, Float4x4)"/> with the same input arguments.</para>
/// <para>For more info, see <see href="https://docs.microsoft.com/windows/win32/direct3dhlsl/dx-graphics-hlsl-mul"/>.</para>
/// <para>This method is an intrinsic and can only be used within a shader on the GPU. Using it on the CPU is undefined behavior.</para>
/// </remarks>
[HlslIntrinsicName("mul", RequiresParametersMatching = true)]
public static Float4 operator *(Float4 x, Float4x4 y) => default;
/// <summary>
/// Multiplies two values using matrix math.
/// </summary>
/// <param name="x">The first Float4x4 input value.</param>
/// <param name="y">The second Float4 input value.</param>
/// <returns>The result of <paramref name="x"/> times <paramref name="y"/>. The result has the dimension <paramref name="x"/>-rows by <paramref name="y"/>-columns.</returns>
/// <remarks>
/// <para>This operator is equivalent to using <see cref="Hlsl.Mul(Float4x4, Float4)"/> with the same input arguments.</para>
/// <para>For more info, see <see href="https://docs.microsoft.com/windows/win32/direct3dhlsl/dx-graphics-hlsl-mul"/>.</para>
/// <para>This method is an intrinsic and can only be used within a shader on the GPU. Using it on the CPU is undefined behavior.</para>
/// </remarks>
[HlslIntrinsicName("mul", RequiresParametersMatching = true)]
public static Float4 operator *(Float4x4 x, Float4 y) => default;
/// <summary>
/// Subtracts two <see cref="Float4"/> values.
/// </summary>
ファイル差分が大きすぎるため表示されません。 差分を読み込み
+89
ファイルの表示
@@ -1,5 +1,6 @@
using System;
using System.Globalization;
using ComputeSharp.Core.Intrinsics.Attributes;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
#if !NET6_0_OR_GREATER
@@ -498,6 +499,94 @@ public unsafe partial struct Int2
/// <remarks>This method is an intrinsic and can only be used within a shader on the GPU. Using it on the CPU is undefined behavior.</remarks>
public static Int2 operator *(Int2 left, Int2 right) => default;
/// <summary>
/// Multiplies a pair of <see cref="Int2"/> and <see cref="int"/> values.
/// </summary>
/// <param name="left">The <see cref="Int2"/> value to multiply.</param>
/// <param name="right">The <see cref="int"/> value to multiply.</param>
/// <returns>The result of multiplying <paramref name="left"/> and <paramref name="right"/>.</returns>
/// <remarks>This method is an intrinsic and can only be used within a shader on the GPU. Using it on the CPU is undefined behavior.</remarks>
public static Int2 operator *(Int2 left, int right) => default;
/// <summary>
/// Multiplies a pair of <see cref="int"/> and <see cref="Int2"/> values.
/// </summary>
/// <param name="left">The <see cref="int"/> value to multiply.</param>
/// <param name="right">The <see cref="Int2"/> value to multiply.</param>
/// <returns>The result of multiplying <paramref name="left"/> and <paramref name="right"/>.</returns>
/// <remarks>This method is an intrinsic and can only be used within a shader on the GPU. Using it on the CPU is undefined behavior.</remarks>
public static Int2 operator *(int left, Int2 right) => default;
/// <summary>
/// Multiplies two values using matrix math.
/// </summary>
/// <param name="x">The first Int2 input value.</param>
/// <param name="y">The second Int2x1 input value.</param>
/// <returns>The result of <paramref name="x"/> times <paramref name="y"/>. The result has the dimension <paramref name="x"/>-rows by <paramref name="y"/>-columns.</returns>
/// <remarks>
/// <para>This operator is equivalent to using <see cref="Hlsl.Mul(Int2, Int2x1)"/> with the same input arguments.</para>
/// <para>For more info, see <see href="https://docs.microsoft.com/windows/win32/direct3dhlsl/dx-graphics-hlsl-mul"/>.</para>
/// <para>This method is an intrinsic and can only be used within a shader on the GPU. Using it on the CPU is undefined behavior.</para>
/// </remarks>
[HlslIntrinsicName("mul", RequiresParametersMatching = true)]
public static int operator *(Int2 x, Int2x1 y) => default;
/// <summary>
/// Multiplies two values using matrix math.
/// </summary>
/// <param name="x">The first Int2 input value.</param>
/// <param name="y">The second Int2x2 input value.</param>
/// <returns>The result of <paramref name="x"/> times <paramref name="y"/>. The result has the dimension <paramref name="x"/>-rows by <paramref name="y"/>-columns.</returns>
/// <remarks>
/// <para>This operator is equivalent to using <see cref="Hlsl.Mul(Int2, Int2x2)"/> with the same input arguments.</para>
/// <para>For more info, see <see href="https://docs.microsoft.com/windows/win32/direct3dhlsl/dx-graphics-hlsl-mul"/>.</para>
/// <para>This method is an intrinsic and can only be used within a shader on the GPU. Using it on the CPU is undefined behavior.</para>
/// </remarks>
[HlslIntrinsicName("mul", RequiresParametersMatching = true)]
public static Int2 operator *(Int2 x, Int2x2 y) => default;
/// <summary>
/// Multiplies two values using matrix math.
/// </summary>
/// <param name="x">The first Int2 input value.</param>
/// <param name="y">The second Int2x3 input value.</param>
/// <returns>The result of <paramref name="x"/> times <paramref name="y"/>. The result has the dimension <paramref name="x"/>-rows by <paramref name="y"/>-columns.</returns>
/// <remarks>
/// <para>This operator is equivalent to using <see cref="Hlsl.Mul(Int2, Int2x3)"/> with the same input arguments.</para>
/// <para>For more info, see <see href="https://docs.microsoft.com/windows/win32/direct3dhlsl/dx-graphics-hlsl-mul"/>.</para>
/// <para>This method is an intrinsic and can only be used within a shader on the GPU. Using it on the CPU is undefined behavior.</para>
/// </remarks>
[HlslIntrinsicName("mul", RequiresParametersMatching = true)]
public static Int3 operator *(Int2 x, Int2x3 y) => default;
/// <summary>
/// Multiplies two values using matrix math.
/// </summary>
/// <param name="x">The first Int2 input value.</param>
/// <param name="y">The second Int2x4 input value.</param>
/// <returns>The result of <paramref name="x"/> times <paramref name="y"/>. The result has the dimension <paramref name="x"/>-rows by <paramref name="y"/>-columns.</returns>
/// <remarks>
/// <para>This operator is equivalent to using <see cref="Hlsl.Mul(Int2, Int2x4)"/> with the same input arguments.</para>
/// <para>For more info, see <see href="https://docs.microsoft.com/windows/win32/direct3dhlsl/dx-graphics-hlsl-mul"/>.</para>
/// <para>This method is an intrinsic and can only be used within a shader on the GPU. Using it on the CPU is undefined behavior.</para>
/// </remarks>
[HlslIntrinsicName("mul", RequiresParametersMatching = true)]
public static Int4 operator *(Int2 x, Int2x4 y) => default;
/// <summary>
/// Multiplies two values using matrix math.
/// </summary>
/// <param name="x">The first Int2x2 input value.</param>
/// <param name="y">The second Int2 input value.</param>
/// <returns>The result of <paramref name="x"/> times <paramref name="y"/>. The result has the dimension <paramref name="x"/>-rows by <paramref name="y"/>-columns.</returns>
/// <remarks>
/// <para>This operator is equivalent to using <see cref="Hlsl.Mul(Int2x2, Int2)"/> with the same input arguments.</para>
/// <para>For more info, see <see href="https://docs.microsoft.com/windows/win32/direct3dhlsl/dx-graphics-hlsl-mul"/>.</para>
/// <para>This method is an intrinsic and can only be used within a shader on the GPU. Using it on the CPU is undefined behavior.</para>
/// </remarks>
[HlslIntrinsicName("mul", RequiresParametersMatching = true)]
public static Int2 operator *(Int2x2 x, Int2 y) => default;
/// <summary>
/// Subtracts two <see cref="Int2"/> values.
/// </summary>
+89
ファイルの表示
@@ -1,5 +1,6 @@
using System;
using System.Globalization;
using ComputeSharp.Core.Intrinsics.Attributes;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
#if !NET6_0_OR_GREATER
@@ -1584,6 +1585,94 @@ public unsafe partial struct Int3
/// <remarks>This method is an intrinsic and can only be used within a shader on the GPU. Using it on the CPU is undefined behavior.</remarks>
public static Int3 operator *(Int3 left, Int3 right) => default;
/// <summary>
/// Multiplies a pair of <see cref="Int3"/> and <see cref="int"/> values.
/// </summary>
/// <param name="left">The <see cref="Int3"/> value to multiply.</param>
/// <param name="right">The <see cref="int"/> value to multiply.</param>
/// <returns>The result of multiplying <paramref name="left"/> and <paramref name="right"/>.</returns>
/// <remarks>This method is an intrinsic and can only be used within a shader on the GPU. Using it on the CPU is undefined behavior.</remarks>
public static Int3 operator *(Int3 left, int right) => default;
/// <summary>
/// Multiplies a pair of <see cref="int"/> and <see cref="Int3"/> values.
/// </summary>
/// <param name="left">The <see cref="int"/> value to multiply.</param>
/// <param name="right">The <see cref="Int3"/> value to multiply.</param>
/// <returns>The result of multiplying <paramref name="left"/> and <paramref name="right"/>.</returns>
/// <remarks>This method is an intrinsic and can only be used within a shader on the GPU. Using it on the CPU is undefined behavior.</remarks>
public static Int3 operator *(int left, Int3 right) => default;
/// <summary>
/// Multiplies two values using matrix math.
/// </summary>
/// <param name="x">The first Int3 input value.</param>
/// <param name="y">The second Int3x1 input value.</param>
/// <returns>The result of <paramref name="x"/> times <paramref name="y"/>. The result has the dimension <paramref name="x"/>-rows by <paramref name="y"/>-columns.</returns>
/// <remarks>
/// <para>This operator is equivalent to using <see cref="Hlsl.Mul(Int3, Int3x1)"/> with the same input arguments.</para>
/// <para>For more info, see <see href="https://docs.microsoft.com/windows/win32/direct3dhlsl/dx-graphics-hlsl-mul"/>.</para>
/// <para>This method is an intrinsic and can only be used within a shader on the GPU. Using it on the CPU is undefined behavior.</para>
/// </remarks>
[HlslIntrinsicName("mul", RequiresParametersMatching = true)]
public static int operator *(Int3 x, Int3x1 y) => default;
/// <summary>
/// Multiplies two values using matrix math.
/// </summary>
/// <param name="x">The first Int3 input value.</param>
/// <param name="y">The second Int3x2 input value.</param>
/// <returns>The result of <paramref name="x"/> times <paramref name="y"/>. The result has the dimension <paramref name="x"/>-rows by <paramref name="y"/>-columns.</returns>
/// <remarks>
/// <para>This operator is equivalent to using <see cref="Hlsl.Mul(Int3, Int3x2)"/> with the same input arguments.</para>
/// <para>For more info, see <see href="https://docs.microsoft.com/windows/win32/direct3dhlsl/dx-graphics-hlsl-mul"/>.</para>
/// <para>This method is an intrinsic and can only be used within a shader on the GPU. Using it on the CPU is undefined behavior.</para>
/// </remarks>
[HlslIntrinsicName("mul", RequiresParametersMatching = true)]
public static Int2 operator *(Int3 x, Int3x2 y) => default;
/// <summary>
/// Multiplies two values using matrix math.
/// </summary>
/// <param name="x">The first Int3 input value.</param>
/// <param name="y">The second Int3x3 input value.</param>
/// <returns>The result of <paramref name="x"/> times <paramref name="y"/>. The result has the dimension <paramref name="x"/>-rows by <paramref name="y"/>-columns.</returns>
/// <remarks>
/// <para>This operator is equivalent to using <see cref="Hlsl.Mul(Int3, Int3x3)"/> with the same input arguments.</para>
/// <para>For more info, see <see href="https://docs.microsoft.com/windows/win32/direct3dhlsl/dx-graphics-hlsl-mul"/>.</para>
/// <para>This method is an intrinsic and can only be used within a shader on the GPU. Using it on the CPU is undefined behavior.</para>
/// </remarks>
[HlslIntrinsicName("mul", RequiresParametersMatching = true)]
public static Int3 operator *(Int3 x, Int3x3 y) => default;
/// <summary>
/// Multiplies two values using matrix math.
/// </summary>
/// <param name="x">The first Int3 input value.</param>
/// <param name="y">The second Int3x4 input value.</param>
/// <returns>The result of <paramref name="x"/> times <paramref name="y"/>. The result has the dimension <paramref name="x"/>-rows by <paramref name="y"/>-columns.</returns>
/// <remarks>
/// <para>This operator is equivalent to using <see cref="Hlsl.Mul(Int3, Int3x4)"/> with the same input arguments.</para>
/// <para>For more info, see <see href="https://docs.microsoft.com/windows/win32/direct3dhlsl/dx-graphics-hlsl-mul"/>.</para>
/// <para>This method is an intrinsic and can only be used within a shader on the GPU. Using it on the CPU is undefined behavior.</para>
/// </remarks>
[HlslIntrinsicName("mul", RequiresParametersMatching = true)]
public static Int4 operator *(Int3 x, Int3x4 y) => default;
/// <summary>
/// Multiplies two values using matrix math.
/// </summary>
/// <param name="x">The first Int3x3 input value.</param>
/// <param name="y">The second Int3 input value.</param>
/// <returns>The result of <paramref name="x"/> times <paramref name="y"/>. The result has the dimension <paramref name="x"/>-rows by <paramref name="y"/>-columns.</returns>
/// <remarks>
/// <para>This operator is equivalent to using <see cref="Hlsl.Mul(Int3x3, Int3)"/> with the same input arguments.</para>
/// <para>For more info, see <see href="https://docs.microsoft.com/windows/win32/direct3dhlsl/dx-graphics-hlsl-mul"/>.</para>
/// <para>This method is an intrinsic and can only be used within a shader on the GPU. Using it on the CPU is undefined behavior.</para>
/// </remarks>
[HlslIntrinsicName("mul", RequiresParametersMatching = true)]
public static Int3 operator *(Int3x3 x, Int3 y) => default;
/// <summary>
/// Subtracts two <see cref="Int3"/> values.
/// </summary>
+89
ファイルの表示
@@ -1,5 +1,6 @@
using System;
using System.Globalization;
using ComputeSharp.Core.Intrinsics.Attributes;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
#if !NET6_0_OR_GREATER
@@ -4230,6 +4231,94 @@ public unsafe partial struct Int4
/// <remarks>This method is an intrinsic and can only be used within a shader on the GPU. Using it on the CPU is undefined behavior.</remarks>
public static Int4 operator *(Int4 left, Int4 right) => default;
/// <summary>
/// Multiplies a pair of <see cref="Int4"/> and <see cref="int"/> values.
/// </summary>
/// <param name="left">The <see cref="Int4"/> value to multiply.</param>
/// <param name="right">The <see cref="int"/> value to multiply.</param>
/// <returns>The result of multiplying <paramref name="left"/> and <paramref name="right"/>.</returns>
/// <remarks>This method is an intrinsic and can only be used within a shader on the GPU. Using it on the CPU is undefined behavior.</remarks>
public static Int4 operator *(Int4 left, int right) => default;
/// <summary>
/// Multiplies a pair of <see cref="int"/> and <see cref="Int4"/> values.
/// </summary>
/// <param name="left">The <see cref="int"/> value to multiply.</param>
/// <param name="right">The <see cref="Int4"/> value to multiply.</param>
/// <returns>The result of multiplying <paramref name="left"/> and <paramref name="right"/>.</returns>
/// <remarks>This method is an intrinsic and can only be used within a shader on the GPU. Using it on the CPU is undefined behavior.</remarks>
public static Int4 operator *(int left, Int4 right) => default;
/// <summary>
/// Multiplies two values using matrix math.
/// </summary>
/// <param name="x">The first Int4 input value.</param>
/// <param name="y">The second Int4x1 input value.</param>
/// <returns>The result of <paramref name="x"/> times <paramref name="y"/>. The result has the dimension <paramref name="x"/>-rows by <paramref name="y"/>-columns.</returns>
/// <remarks>
/// <para>This operator is equivalent to using <see cref="Hlsl.Mul(Int4, Int4x1)"/> with the same input arguments.</para>
/// <para>For more info, see <see href="https://docs.microsoft.com/windows/win32/direct3dhlsl/dx-graphics-hlsl-mul"/>.</para>
/// <para>This method is an intrinsic and can only be used within a shader on the GPU. Using it on the CPU is undefined behavior.</para>
/// </remarks>
[HlslIntrinsicName("mul", RequiresParametersMatching = true)]
public static int operator *(Int4 x, Int4x1 y) => default;
/// <summary>
/// Multiplies two values using matrix math.
/// </summary>
/// <param name="x">The first Int4 input value.</param>
/// <param name="y">The second Int4x2 input value.</param>
/// <returns>The result of <paramref name="x"/> times <paramref name="y"/>. The result has the dimension <paramref name="x"/>-rows by <paramref name="y"/>-columns.</returns>
/// <remarks>
/// <para>This operator is equivalent to using <see cref="Hlsl.Mul(Int4, Int4x2)"/> with the same input arguments.</para>
/// <para>For more info, see <see href="https://docs.microsoft.com/windows/win32/direct3dhlsl/dx-graphics-hlsl-mul"/>.</para>
/// <para>This method is an intrinsic and can only be used within a shader on the GPU. Using it on the CPU is undefined behavior.</para>
/// </remarks>
[HlslIntrinsicName("mul", RequiresParametersMatching = true)]
public static Int2 operator *(Int4 x, Int4x2 y) => default;
/// <summary>
/// Multiplies two values using matrix math.
/// </summary>
/// <param name="x">The first Int4 input value.</param>
/// <param name="y">The second Int4x3 input value.</param>
/// <returns>The result of <paramref name="x"/> times <paramref name="y"/>. The result has the dimension <paramref name="x"/>-rows by <paramref name="y"/>-columns.</returns>
/// <remarks>
/// <para>This operator is equivalent to using <see cref="Hlsl.Mul(Int4, Int4x3)"/> with the same input arguments.</para>
/// <para>For more info, see <see href="https://docs.microsoft.com/windows/win32/direct3dhlsl/dx-graphics-hlsl-mul"/>.</para>
/// <para>This method is an intrinsic and can only be used within a shader on the GPU. Using it on the CPU is undefined behavior.</para>
/// </remarks>
[HlslIntrinsicName("mul", RequiresParametersMatching = true)]
public static Int3 operator *(Int4 x, Int4x3 y) => default;
/// <summary>
/// Multiplies two values using matrix math.
/// </summary>
/// <param name="x">The first Int4 input value.</param>
/// <param name="y">The second Int4x4 input value.</param>
/// <returns>The result of <paramref name="x"/> times <paramref name="y"/>. The result has the dimension <paramref name="x"/>-rows by <paramref name="y"/>-columns.</returns>
/// <remarks>
/// <para>This operator is equivalent to using <see cref="Hlsl.Mul(Int4, Int4x4)"/> with the same input arguments.</para>
/// <para>For more info, see <see href="https://docs.microsoft.com/windows/win32/direct3dhlsl/dx-graphics-hlsl-mul"/>.</para>
/// <para>This method is an intrinsic and can only be used within a shader on the GPU. Using it on the CPU is undefined behavior.</para>
/// </remarks>
[HlslIntrinsicName("mul", RequiresParametersMatching = true)]
public static Int4 operator *(Int4 x, Int4x4 y) => default;
/// <summary>
/// Multiplies two values using matrix math.
/// </summary>
/// <param name="x">The first Int4x4 input value.</param>
/// <param name="y">The second Int4 input value.</param>
/// <returns>The result of <paramref name="x"/> times <paramref name="y"/>. The result has the dimension <paramref name="x"/>-rows by <paramref name="y"/>-columns.</returns>
/// <remarks>
/// <para>This operator is equivalent to using <see cref="Hlsl.Mul(Int4x4, Int4)"/> with the same input arguments.</para>
/// <para>For more info, see <see href="https://docs.microsoft.com/windows/win32/direct3dhlsl/dx-graphics-hlsl-mul"/>.</para>
/// <para>This method is an intrinsic and can only be used within a shader on the GPU. Using it on the CPU is undefined behavior.</para>
/// </remarks>
[HlslIntrinsicName("mul", RequiresParametersMatching = true)]
public static Int4 operator *(Int4x4 x, Int4 y) => default;
/// <summary>
/// Subtracts two <see cref="Int4"/> values.
/// </summary>
ファイル差分が大きすぎるため表示されません。 差分を読み込み
+60 -2
ファイルの表示
@@ -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" #>
@@ -12,6 +11,12 @@ void GenerateAllMatrixProperties(string typeName, int elementSize)
#>
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
<#
if (typeName == "Float" || typeName == "Int")
{
WriteLine("using ComputeSharp.Core.Intrinsics.Attributes;");
}
#>
#if !NET6_0_OR_GREATER
using RuntimeHelpers = ComputeSharp.Core.NetStandard.System.Runtime.CompilerServices.RuntimeHelpers;
using MemoryMarshal = ComputeSharp.Core.NetStandard.System.Runtime.InteropServices.MemoryMarshal;
@@ -291,7 +296,60 @@ public unsafe partial struct <#=fullTypeName#>
/// <returns>The result of multiplying <paramref name="left"/> and <paramref name="right"/>.</returns>
/// <remarks>This method is an intrinsic and can only be used within a shader on the GPU. Using it on the CPU is undefined behavior.</remarks>
public static <#=fullTypeName#> operator *(<#=fullTypeName#> left, <#=fullTypeName#> right) => default;
<#
if (typeName == "Float" || typeName == "Int")
{
// Add explicit operators when needed, see notes in VectorType.ttinclude for info
WriteLine("");
#>
/// <summary>
/// Multiplies a pair of <see cref="<#=fullTypeName#>"/> and <see cref="<#=elementTypeName#>"/> values.
/// </summary>
/// <param name="left">The <see cref="<#=fullTypeName#>"/> value to multiply.</param>
/// <param name="right">The <see cref="<#=elementTypeName#>"/> value to multiply.</param>
/// <returns>The result of multiplying <paramref name="left"/> and <paramref name="right"/>.</returns>
/// <remarks>This method is an intrinsic and can only be used within a shader on the GPU. Using it on the CPU is undefined behavior.</remarks>
public static <#=fullTypeName#> operator *(<#=fullTypeName#> left, <#=elementTypeName#> right) => default;
/// <summary>
/// Multiplies a pair of <see cref="<#=elementTypeName#>"/> and <see cref="<#=fullTypeName#>"/> values.
/// </summary>
/// <param name="left">The <see cref="<#=elementTypeName#>"/> value to multiply.</param>
/// <param name="right">The <see cref="<#=fullTypeName#>"/> value to multiply.</param>
/// <returns>The result of multiplying <paramref name="left"/> and <paramref name="right"/>.</returns>
/// <remarks>This method is an intrinsic and can only be used within a shader on the GPU. Using it on the CPU is undefined behavior.</remarks>
public static <#=fullTypeName#> operator *(<#=elementTypeName#> left, <#=fullTypeName#> right) => default;
<#
// Process all operators for the mul() intrinsic (see comments in VectorType.ttinclude for info on the filters below)
foreach (var mulOverload in MulOverloads.Where(overload =>
!(overload.Params[0] == fullTypeName && overload.Params[1] == fullTypeName) &&
Regex.IsMatch(overload.Params[0], @"\d") &&
Regex.IsMatch(overload.Params[1], @"\d") &&
(overload.Return == fullTypeName && overload.Params.Contains(fullTypeName) ||
!overload.Params.Contains(overload.Return) && overload.Params[0] == fullTypeName)))
{
WriteLine("");
#>
/// <summary>
/// Multiplies two values using matrix math.
/// </summary>
/// <param name="x">The first <#=mulOverload.Params[0]#> input value.</param>
/// <param name="y">The second <#=mulOverload.Params[1]#> input value.</param>
/// <returns>The result of <paramref name="x"/> times <paramref name="y"/>. The result has the dimension <paramref name="x"/>-rows by <paramref name="y"/>-columns.</returns>
/// <remarks>
/// <para>This operator is equivalent to using <see cref="Hlsl.Mul(<#=mulOverload.Params[0]#>, <#=mulOverload.Params[1]#>)"/> with the same input arguments.</para>
/// <para>For more info, see <see href="https://docs.microsoft.com/windows/win32/direct3dhlsl/dx-graphics-hlsl-mul"/>.</para>
/// <para>This method is an intrinsic and can only be used within a shader on the GPU. Using it on the CPU is undefined behavior.</para>
/// </remarks>
[HlslIntrinsicName("mul", RequiresParametersMatching = true)]
public static <#=mulOverload.Return#> operator *(<#=mulOverload.Params[0]#> x, <#=mulOverload.Params[1]#> y) => default;
<#
}
}
WriteLine("");
#>
/// <summary>
/// Subtracts two <see cref="<#=fullTypeName#>"/> values.
/// </summary>
+76 -2
ファイルの表示
@@ -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" #>
@@ -59,6 +58,11 @@ void GenerateVectorProperties(string typeName, int elementSize)
WriteLine("using System;");
WriteLine("using System.Globalization;");
}
if (elementTypeName == "Float" || elementTypeName == "Int")
{
WriteLine("using ComputeSharp.Core.Intrinsics.Attributes;");
}
#>
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
@@ -355,7 +359,77 @@ public unsafe partial struct <#=typeName#>
/// <returns>The result of multiplying <paramref name="left"/> and <paramref name="right"/>.</returns>
/// <remarks>This method is an intrinsic and can only be used within a shader on the GPU. Using it on the CPU is undefined behavior.</remarks>
public static <#=typeName#> operator *(<#=typeName#> left, <#=typeName#> right) => default;
<#
if (elementTypeName == "Float" || elementTypeName == "Int")
{
// Note: for Float and Int vector types, we need to also add explicit operators doing scalar promotion,
// otherwise there would be an overload issue trying to resolve the right overload when just multiplying
// by a scalar (which is not using the mul() intrinsic, but just doing elementwise product with promotion).
WriteLine("");
#>
/// <summary>
/// Multiplies a pair of <see cref="<#=typeName#>"/> and <see cref="<#=hlslElementTypeName#>"/> values.
/// </summary>
/// <param name="left">The <see cref="<#=typeName#>"/> value to multiply.</param>
/// <param name="right">The <see cref="<#=hlslElementTypeName#>"/> value to multiply.</param>
/// <returns>The result of multiplying <paramref name="left"/> and <paramref name="right"/>.</returns>
/// <remarks>This method is an intrinsic and can only be used within a shader on the GPU. Using it on the CPU is undefined behavior.</remarks>
public static <#=typeName#> operator *(<#=typeName#> left, <#=hlslElementTypeName#> right) => default;
/// <summary>
/// Multiplies a pair of <see cref="<#=hlslElementTypeName#>"/> and <see cref="<#=typeName#>"/> values.
/// </summary>
/// <param name="left">The <see cref="<#=hlslElementTypeName#>"/> value to multiply.</param>
/// <param name="right">The <see cref="<#=typeName#>"/> value to multiply.</param>
/// <returns>The result of multiplying <paramref name="left"/> and <paramref name="right"/>.</returns>
/// <remarks>This method is an intrinsic and can only be used within a shader on the GPU. Using it on the CPU is undefined behavior.</remarks>
public static <#=typeName#> operator *(<#=hlslElementTypeName#> left, <#=typeName#> right) => default;
<#
// Process all operators for the mul() intrinsic. We apply the following filtering:
// 1) Operators where both arguments are of the containing type are skipped. This is because
// this operation is already defined as an elementwise product for all vector/matrix types.
// Defining the operator would cause a conflict, plus it would alter the semantics anyway.
// 2) Operators where either parameter is a primitive type (ie. not a vector) are skipped. This
// is because such operation is already implicitly defined (it's an elementwise product where
// the scalar is auto-promoted to the same vector/matrix type of the other argument). Again,
// defining the operator would cause the semantics of such expressions to change to a cross
// product, so these operators are intentionally skipped to keep code consistent with HLSL.
// 3) Among all available overloads, only either of these two cases are selected:
// - The containing type matches the return type and the first parameter type of the operator.
// This ensures that all overloads where the return type matches the containing type and the
// first parameter are generated inside the containing type, as one would do manually as well.
// - The return type is unlike both parameter types, but the containing type matches the type of
// the first parameter. This is the case when the operator (ie. the cross product) produces a
// result that's of a completely different type. In this case, the overload maps to a generated
// operator declared in the type that matches the type of the first parameter, as a convention.
foreach (var mulOverload in MulOverloads.Where(overload =>
!(overload.Params[0] == typeName && overload.Params[1] == typeName) &&
Regex.IsMatch(overload.Params[0], @"\d") &&
Regex.IsMatch(overload.Params[1], @"\d") &&
(overload.Return == typeName && overload.Params.Contains(typeName) ||
!overload.Params.Contains(overload.Return) && overload.Params[0] == typeName)))
{
WriteLine("");
#>
/// <summary>
/// Multiplies two values using matrix math.
/// </summary>
/// <param name="x">The first <#=mulOverload.Params[0]#> input value.</param>
/// <param name="y">The second <#=mulOverload.Params[1]#> input value.</param>
/// <returns>The result of <paramref name="x"/> times <paramref name="y"/>. The result has the dimension <paramref name="x"/>-rows by <paramref name="y"/>-columns.</returns>
/// <remarks>
/// <para>This operator is equivalent to using <see cref="Hlsl.Mul(<#=mulOverload.Params[0]#>, <#=mulOverload.Params[1]#>)"/> with the same input arguments.</para>
/// <para>For more info, see <see href="https://docs.microsoft.com/windows/win32/direct3dhlsl/dx-graphics-hlsl-mul"/>.</para>
/// <para>This method is an intrinsic and can only be used within a shader on the GPU. Using it on the CPU is undefined behavior.</para>
/// </remarks>
[HlslIntrinsicName("mul", RequiresParametersMatching = true)]
public static <#=mulOverload.Return#> operator *(<#=mulOverload.Params[0]#> x, <#=mulOverload.Params[1]#> y) => default;
<#
}
}
WriteLine("");
#>
/// <summary>
/// Subtracts two <see cref="<#=typeName#>"/> values.
/// </summary>
@@ -15,6 +15,7 @@
<Compile Include="$(MSBuildThisFileDirectory)Mappings\HlslKnownFields.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Mappings\HlslKnownKeywords.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Mappings\HlslKnownMethods.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Mappings\HlslKnownOperators.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Mappings\HlslKnownProperties.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Mappings\HlslKnownSizes.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Mappings\HlslKnownTypes.cs" />
+60
ファイルの表示
@@ -0,0 +1,60 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using ComputeSharp.Core.Intrinsics.Attributes;
namespace ComputeSharp.SourceGeneration.Mappings;
/// <summary>
/// A <see langword="class"/> that contains and maps known HLSL operators names to common .NET methods.
/// </summary>
internal static partial class HlslKnownOperators
{
/// <summary>
/// The mapping of supported known operators to HLSL names.
/// </summary>
private static readonly IReadOnlyDictionary<string, string> KnownOperators = BuildKnownOperatorsMap();
/// <summary>
/// Builds the mapping of supported known operators to HLSL names.
/// </summary>
private static IReadOnlyDictionary<string, string> BuildKnownOperatorsMap()
{
Dictionary<string, string> knownOperators = new();
// Programmatically load mappings for the intrinsic operators on each HLSL primitive type
foreach (var item in
from type in HlslKnownTypes.KnownVectorTypes.Concat(HlslKnownTypes.KnownMatrixTypes)
from method in type.GetMethods(BindingFlags.Static | BindingFlags.Public)
where method.IsSpecialName && method.Name.StartsWith("op_")
let attribute = method.GetCustomAttribute<HlslIntrinsicNameAttribute>()
where attribute is not null
select (Type: type, Operator: method, IntrinsicName: attribute.Name, attribute.RequiresParametersMatching))
{
if (!item.RequiresParametersMatching)
{
throw new NotSupportedException("All intrinsic operators must require parameter matching.");
}
// The key is in the format "<TYPE_NAME>.<METHOD_NAME>(<PARAMETER_TYPES>)"
knownOperators.Add(
$"{item.Type.FullName}{Type.Delimiter}{item.Operator.Name}({string.Join(", ", item.Operator.GetParameters().Select(static p => p.ParameterType.Name))})",
item.IntrinsicName);
}
return knownOperators;
}
/// <summary>
/// Tries to get the mapped HLSL-compatible method name for the input operator name.
/// </summary>
/// <param name="name">The input fully qualified operator name.</param>
/// <param name="parameterTypeNames">The sequence of type names for the method.</param>
/// <param name="mapped">The mapped name, if one is found.</param>
/// <returns>The HLSL-compatible method name that can be used in an HLSL shader.</returns>
public static bool TryGetMappedName(string name, IEnumerable<string> parameterTypeNames, out string? mapped)
{
return KnownOperators.TryGetValue($"{name}({string.Join(", ", parameterTypeNames)})", out mapped);
}
}
+52
ファイルの表示
@@ -291,6 +291,58 @@ internal abstract partial class HlslSourceRewriter : CSharpSyntaxRewriter
return updatedNode;
}
/// <inheritdoc/>
public override SyntaxNode? VisitAssignmentExpression(AssignmentExpressionSyntax node)
{
var updatedNode = (AssignmentExpressionSyntax)base.VisitAssignmentExpression(node)!;
if (SemanticModel.For(node).GetOperation(node) is ICompoundAssignmentOperation { OperatorMethod: { ContainingType.ContainingNamespace.Name: "ComputeSharp" } method })
{
// If the compound assignment is using an HLSL operator, replace the expression with an invocation and assignment.
// That is, do the following transformation:
//
// x *= y => x = <INTRINSIC>(x, y)
if (HlslKnownOperators.TryGetMappedName(method.GetFullMetadataName(), method.Parameters.Select(static p => p.Type.Name), out string? mapped))
{
return
AssignmentExpression(
SyntaxKind.SimpleAssignmentExpression,
updatedNode.Left,
InvocationExpression(IdentifierName(mapped!))
.AddArgumentListArguments(
Argument(updatedNode.Left),
Argument(updatedNode.Right)));
}
}
return updatedNode;
}
/// <inheritdoc/>
public override SyntaxNode? VisitBinaryExpression(BinaryExpressionSyntax node)
{
var updatedNode = (BinaryExpressionSyntax)base.VisitBinaryExpression(node)!;
// Process binary operations to see if the target operator method is an intrinsic
if (SemanticModel.For(node).GetOperation(node) is IBinaryOperation { OperatorMethod: { ContainingType.ContainingNamespace.Name: "ComputeSharp" } method })
{
// If the operator is indeed an HLSL overload, replace the expression with an invocation.
// That is, do the following transformation:
//
// x * y => <INTRINSIC>(x, y)
if (HlslKnownOperators.TryGetMappedName(method.GetFullMetadataName(), method.Parameters.Select(static p => p.Type.Name), out string? mapped))
{
return
InvocationExpression(IdentifierName(mapped!))
.AddArgumentListArguments(
Argument(updatedNode.Left),
Argument(updatedNode.Right));
}
}
return updatedNode;
}
/// <inheritdoc/>
public override SyntaxNode? VisitIdentifierName(IdentifierNameSyntax node)
{
+2 -2
ファイルの表示
@@ -85,7 +85,7 @@ public partial class ShaderMembersTests
}
}
// See: https://github.com/Sergio0694/ComputeSharp/issues/193
// See https://github.com/Sergio0694/ComputeSharp/issues/193
[CombinatorialTestMethod]
[AllDevices]
public void BoolInstanceFields(Device device)
@@ -135,7 +135,7 @@ public partial class ShaderMembersTests
}
}
// See: https://github.com/Sergio0694/ComputeSharp/issues/193
// See https://github.com/Sergio0694/ComputeSharp/issues/193
[CombinatorialTestMethod]
[AllDevices]
public void BoolInstanceFieldInCustomStruct(Device device)
+136 -3
ファイルの表示
@@ -84,7 +84,7 @@ public partial class ShaderRewriterTests
}
}
// See: https://github.com/Sergio0694/ComputeSharp/issues/233
// See https://github.com/Sergio0694/ComputeSharp/issues/233
[CombinatorialTestMethod]
[AllDevices]
public void CustomHlslOperators(Device device)
@@ -130,7 +130,7 @@ public partial class ShaderRewriterTests
}
}
// See: https://github.com/Sergio0694/ComputeSharp/issues/361
// See https://github.com/Sergio0694/ComputeSharp/issues/361
[CombinatorialTestMethod]
[AllDevices]
public void BitwiseHlslOperators(Device device)
@@ -394,7 +394,7 @@ public partial class ShaderRewriterTests
}
}
// See: https://github.com/Sergio0694/ComputeSharp/issues/259
// See https://github.com/Sergio0694/ComputeSharp/issues/259
[CombinatorialTestMethod]
[AllDevices]
public void ConstantsInShaderConstantFields(Device device)
@@ -577,4 +577,137 @@ public partial class ShaderRewriterTests
Hlsl.InterlockedCompareExchange(ref buffer[ThreadIds.X], ThreadIds.X, ThreadIds.X * 2, out _);
}
}
// See https://github.com/Sergio0694/ComputeSharp/issues/156
[CombinatorialTestMethod]
[AllDevices]
public void GlslStyleMulOperators(Device device)
{
float[] data1 = { 0.727829933f, 0.6413954f, 0.9373726f, 0.7044427f, 0.46349f, 0.8098116f, 0.604649544f, 0.309247822f, 0.470999569f, 0.7374923f, 0.6993038f, 0.518516064f, 0.44598946f };
int[] data2 = { 287, 295, 953, 465, 1011, 308, 982, 186, 323, 325, 156, 454, 580 };
using ReadOnlyBuffer<float> buffer1 = device.Get().AllocateReadOnlyBuffer(data1);
using ReadOnlyBuffer<int> buffer2 = device.Get().AllocateReadOnlyBuffer(data2);
using ReadWriteBuffer<float> buffer3 = device.Get().AllocateReadWriteBuffer<float>(22, AllocationMode.Clear);
using ReadWriteBuffer<int> buffer4 = device.Get().AllocateReadWriteBuffer<int>(22, AllocationMode.Clear);
device.Get().For(1, new GlslStyleMulOperatorsShader(buffer1, buffer2, buffer3, buffer4));
float[] results1 = buffer3.ToArray();
int[] results2 = buffer4.ToArray();
CollectionAssert.AreEqual(
expected: results1.AsSpan(11).ToArray(),
actual: results1.AsSpan(0, 11).ToArray());
CollectionAssert.AreEqual(
expected: results2.AsSpan(11).ToArray(),
actual: results2.AsSpan(0, 11).ToArray());
}
[AutoConstructor]
internal readonly partial struct GlslStyleMulOperatorsShader : IComputeShader
{
public readonly ReadOnlyBuffer<float> source1;
public readonly ReadOnlyBuffer<int> source2;
public readonly ReadWriteBuffer<float> destination1;
public readonly ReadWriteBuffer<int> destination2;
public void Execute()
{
float2 f2 = new(source1[0], source1[1]);
float f = source1[2];
float2x2 f22 = new(source1[3], source1[4], source1[5], source1[6]);
float2x3 f23 = new(source1[7], source1[8], source1[9], source1[10], source1[11], source1[12]);
float2 rf1 = f2 * f;
float2 rf2 = f * f2;
float2 rf3 = f2 * f22;
float3 rf4 = f2 * f23;
float2 f2_copy1 = f2;
f2_copy1 *= f22;
float2 rf5 = new(f2.X * f, f2.Y * f);
float2 rf6 = Hlsl.Mul(f, f2);
float2 rf7 = Hlsl.Mul(f2, f22);
float3 rf8 = Hlsl.Mul(f2, f23);
var f2_copy2 = f2;
f2_copy2 = Hlsl.Mul(f2_copy2, f22);
destination1[0] = rf1.X;
destination1[1] = rf1.Y;
destination1[2] = rf2.X;
destination1[3] = rf2.Y;
destination1[4] = rf3.X;
destination1[5] = rf3.Y;
destination1[6] = rf4.X;
destination1[7] = rf4.Y;
destination1[8] = rf4.Z;
destination1[9] = f2_copy1.X;
destination1[10] = f2_copy1.Y;
destination1[11] = rf5.X;
destination1[12] = rf5.Y;
destination1[13] = rf6.X;
destination1[14] = rf6.Y;
destination1[15] = rf7.X;
destination1[16] = rf7.Y;
destination1[17] = rf8.X;
destination1[18] = rf8.Y;
destination1[19] = rf8.Z;
destination1[20] = f2_copy2.X;
destination1[21] = f2_copy2.Y;
int2 i2 = new(source2[0], source2[1]);
int i = source2[2];
int2x2 i22 = new(source2[3], source2[4], source2[5], source2[6]);
int2x3 i23 = new(source2[7], source2[8], source2[9], source2[10], source2[11], source2[12]);
int2 ri1 = i2 * i;
int2 ri2 = i * i2;
int2 ri3 = i2 * i22;
int3 ri4 = i2 * i23;
int2 i2_copy1 = i2;
i2_copy1 *= i22;
int2 ri5 = new(i2.X * i, i2.Y * i);
int2 ri6 = Hlsl.Mul(i, i2);
int2 ri7 = Hlsl.Mul(i2, i22);
int3 ri8 = Hlsl.Mul(i2, i23);
var i2_copy2 = i2;
i2_copy2 = Hlsl.Mul(i2_copy2, i22);
destination2[0] = ri1.X;
destination2[1] = ri1.Y;
destination2[2] = ri2.X;
destination2[3] = ri2.Y;
destination2[4] = ri3.X;
destination2[5] = ri3.Y;
destination2[6] = ri4.X;
destination2[7] = ri4.Y;
destination2[8] = ri4.Z;
destination2[9] = i2_copy1.X;
destination2[10] = i2_copy1.Y;
destination2[11] = ri5.X;
destination2[12] = ri5.Y;
destination2[13] = ri6.X;
destination2[14] = ri6.Y;
destination2[15] = ri7.X;
destination2[16] = ri7.Y;
destination2[17] = ri8.X;
destination2[18] = ri8.Y;
destination2[19] = ri8.Z;
destination2[20] = i2_copy2.X;
destination2[21] = i2_copy2.Y;
}
}
}