From 40aa965c63c9702fbade4f88a314e5cde50a116e Mon Sep 17 00:00:00 2001 From: Sergio Pedri Date: Mon, 26 Aug 2019 03:36:26 +0200 Subject: [PATCH] Added operators to HLSL vector types --- .../Primitives/Double/Double2.cs | 28 +++++++++++++++++++ .../Primitives/Double/Double3.cs | 28 +++++++++++++++++++ .../Primitives/Double/Double4.cs | 28 +++++++++++++++++++ .../Primitives/Float/Float2.cs | 28 +++++++++++++++++++ .../Primitives/Float/Float3.cs | 28 +++++++++++++++++++ .../Primitives/Float/Float4.cs | 28 +++++++++++++++++++ .../Primitives/Int/Int2.cs | 28 +++++++++++++++++++ .../Primitives/Int/Int3.cs | 28 +++++++++++++++++++ .../Primitives/Int/Int4.cs | 28 +++++++++++++++++++ .../Primitives/UInt/UInt4.cs | 28 +++++++++++++++++++ .../Primitives/UInt/Uint2.cs | 28 +++++++++++++++++++ .../Primitives/UInt/Uint3.cs | 28 +++++++++++++++++++ 12 files changed, 336 insertions(+) diff --git a/src/ComputeSharp.Shaders/Primitives/Double/Double2.cs b/src/ComputeSharp.Shaders/Primitives/Double/Double2.cs index bb71df0d..92781131 100644 --- a/src/ComputeSharp.Shaders/Primitives/Double/Double2.cs +++ b/src/ComputeSharp.Shaders/Primitives/Double/Double2.cs @@ -139,5 +139,33 @@ namespace ComputeSharp /// /// The value to use for the components of the new instance public static implicit operator Double2(double x) => new Double2(x, x); + + /// + /// Sums two values + /// + /// The first value to sum + /// The second value to sum + public static Double2 operator +(Double2 left, Double2 right) => throw new InvalidExecutionContextException($"{nameof(Double2)}.+"); + + /// + /// Divides two values + /// + /// The first value to divide + /// The second value to divide + public static Double2 operator /(Double2 left, Double2 right) => throw new InvalidExecutionContextException($"{nameof(Double2)}./"); + + /// + /// Multiplies two values + /// + /// The first value to multiply + /// The second value to multiply + public static Double2 operator *(Double2 left, Double2 right) => throw new InvalidExecutionContextException($"{nameof(Double2)}.*"); + + /// + /// Subtracts two values + /// + /// The first value to subtract + /// The second value to subtract + public static Double2 operator -(Double2 left, Double2 right) => throw new InvalidExecutionContextException($"{nameof(Double2)}.-"); } } diff --git a/src/ComputeSharp.Shaders/Primitives/Double/Double3.cs b/src/ComputeSharp.Shaders/Primitives/Double/Double3.cs index 10978212..d23cf698 100644 --- a/src/ComputeSharp.Shaders/Primitives/Double/Double3.cs +++ b/src/ComputeSharp.Shaders/Primitives/Double/Double3.cs @@ -560,5 +560,33 @@ namespace ComputeSharp /// /// The value to use for the components of the new instance public static implicit operator Double3(double x) => new Double3(x, x, x); + + /// + /// Sums two values + /// + /// The first value to sum + /// The second value to sum + public static Double3 operator +(Double3 left, Double3 right) => throw new InvalidExecutionContextException($"{nameof(Double3)}.+"); + + /// + /// Divides two values + /// + /// The first value to divide + /// The second value to divide + public static Double3 operator /(Double3 left, Double3 right) => throw new InvalidExecutionContextException($"{nameof(Double3)}./"); + + /// + /// Multiplies two values + /// + /// The first value to multiply + /// The second value to multiply + public static Double3 operator *(Double3 left, Double3 right) => throw new InvalidExecutionContextException($"{nameof(Double3)}.*"); + + /// + /// Subtracts two values + /// + /// The first value to subtract + /// The second value to subtract + public static Double3 operator -(Double3 left, Double3 right) => throw new InvalidExecutionContextException($"{nameof(Double3)}.-"); } } diff --git a/src/ComputeSharp.Shaders/Primitives/Double/Double4.cs b/src/ComputeSharp.Shaders/Primitives/Double/Double4.cs index 3f5d6459..af1ac5c5 100644 --- a/src/ComputeSharp.Shaders/Primitives/Double/Double4.cs +++ b/src/ComputeSharp.Shaders/Primitives/Double/Double4.cs @@ -3965,5 +3965,33 @@ namespace ComputeSharp /// /// The value to use for the components of the new instance public static implicit operator Double4(double x) => new Double4(x, x, x, x); + + /// + /// Sums two values + /// + /// The first value to sum + /// The second value to sum + public static Double4 operator +(Double4 left, Double4 right) => throw new InvalidExecutionContextException($"{nameof(Double4)}.+"); + + /// + /// Divides two values + /// + /// The first value to divide + /// The second value to divide + public static Double4 operator /(Double4 left, Double4 right) => throw new InvalidExecutionContextException($"{nameof(Double4)}./"); + + /// + /// Multiplies two values + /// + /// The first value to multiply + /// The second value to multiply + public static Double4 operator *(Double4 left, Double4 right) => throw new InvalidExecutionContextException($"{nameof(Double4)}.*"); + + /// + /// Subtracts two values + /// + /// The first value to subtract + /// The second value to subtract + public static Double4 operator -(Double4 left, Double4 right) => throw new InvalidExecutionContextException($"{nameof(Double4)}.-"); } } diff --git a/src/ComputeSharp.Shaders/Primitives/Float/Float2.cs b/src/ComputeSharp.Shaders/Primitives/Float/Float2.cs index 4543b1c4..4172da9b 100644 --- a/src/ComputeSharp.Shaders/Primitives/Float/Float2.cs +++ b/src/ComputeSharp.Shaders/Primitives/Float/Float2.cs @@ -139,5 +139,33 @@ namespace ComputeSharp /// /// The value to use for the components of the new instance public static implicit operator Float2(float x) => new Float2(x, x); + + /// + /// Sums two values + /// + /// The first value to sum + /// The second value to sum + public static Float2 operator +(Float2 left, Float2 right) => throw new InvalidExecutionContextException($"{nameof(Float2)}.+"); + + /// + /// Divides two values + /// + /// The first value to divide + /// The second value to divide + public static Float2 operator /(Float2 left, Float2 right) => throw new InvalidExecutionContextException($"{nameof(Float2)}./"); + + /// + /// Multiplies two values + /// + /// The first value to multiply + /// The second value to multiply + public static Float2 operator *(Float2 left, Float2 right) => throw new InvalidExecutionContextException($"{nameof(Float2)}.*"); + + /// + /// Subtracts two values + /// + /// The first value to subtract + /// The second value to subtract + public static Float2 operator -(Float2 left, Float2 right) => throw new InvalidExecutionContextException($"{nameof(Float2)}.-"); } } diff --git a/src/ComputeSharp.Shaders/Primitives/Float/Float3.cs b/src/ComputeSharp.Shaders/Primitives/Float/Float3.cs index 27171126..836b8dd3 100644 --- a/src/ComputeSharp.Shaders/Primitives/Float/Float3.cs +++ b/src/ComputeSharp.Shaders/Primitives/Float/Float3.cs @@ -560,5 +560,33 @@ namespace ComputeSharp /// /// The value to use for the components of the new instance public static implicit operator Float3(float x) => new Float3(x, x, x); + + /// + /// Sums two values + /// + /// The first value to sum + /// The second value to sum + public static Float3 operator +(Float3 left, Float3 right) => throw new InvalidExecutionContextException($"{nameof(Float3)}.+"); + + /// + /// Divides two values + /// + /// The first value to divide + /// The second value to divide + public static Float3 operator /(Float3 left, Float3 right) => throw new InvalidExecutionContextException($"{nameof(Float3)}./"); + + /// + /// Multiplies two values + /// + /// The first value to multiply + /// The second value to multiply + public static Float3 operator *(Float3 left, Float3 right) => throw new InvalidExecutionContextException($"{nameof(Float3)}.*"); + + /// + /// Subtracts two values + /// + /// The first value to subtract + /// The second value to subtract + public static Float3 operator -(Float3 left, Float3 right) => throw new InvalidExecutionContextException($"{nameof(Float3)}.-"); } } diff --git a/src/ComputeSharp.Shaders/Primitives/Float/Float4.cs b/src/ComputeSharp.Shaders/Primitives/Float/Float4.cs index cef08153..cbbff71f 100644 --- a/src/ComputeSharp.Shaders/Primitives/Float/Float4.cs +++ b/src/ComputeSharp.Shaders/Primitives/Float/Float4.cs @@ -3965,5 +3965,33 @@ namespace ComputeSharp /// /// The value to use for the components of the new instance public static implicit operator Float4(float x) => new Float4(x, x, x, x); + + /// + /// Sums two values + /// + /// The first value to sum + /// The second value to sum + public static Float4 operator +(Float4 left, Float4 right) => throw new InvalidExecutionContextException($"{nameof(Float4)}.+"); + + /// + /// Divides two values + /// + /// The first value to divide + /// The second value to divide + public static Float4 operator /(Float4 left, Float4 right) => throw new InvalidExecutionContextException($"{nameof(Float4)}./"); + + /// + /// Multiplies two values + /// + /// The first value to multiply + /// The second value to multiply + public static Float4 operator *(Float4 left, Float4 right) => throw new InvalidExecutionContextException($"{nameof(Float4)}.*"); + + /// + /// Subtracts two values + /// + /// The first value to subtract + /// The second value to subtract + public static Float4 operator -(Float4 left, Float4 right) => throw new InvalidExecutionContextException($"{nameof(Float4)}.-"); } } diff --git a/src/ComputeSharp.Shaders/Primitives/Int/Int2.cs b/src/ComputeSharp.Shaders/Primitives/Int/Int2.cs index 5f8ed81a..857e2968 100644 --- a/src/ComputeSharp.Shaders/Primitives/Int/Int2.cs +++ b/src/ComputeSharp.Shaders/Primitives/Int/Int2.cs @@ -139,5 +139,33 @@ namespace ComputeSharp /// /// The value to use for the components of the new instance public static implicit operator Int2(int x) => new Int2(x, x); + + /// + /// Sums two values + /// + /// The first value to sum + /// The second value to sum + public static Int2 operator +(Int2 left, Int2 right) => throw new InvalidExecutionContextException($"{nameof(Int2)}.+"); + + /// + /// Divides two values + /// + /// The first value to divide + /// The second value to divide + public static Int2 operator /(Int2 left, Int2 right) => throw new InvalidExecutionContextException($"{nameof(Int2)}./"); + + /// + /// Multiplies two values + /// + /// The first value to multiply + /// The second value to multiply + public static Int2 operator *(Int2 left, Int2 right) => throw new InvalidExecutionContextException($"{nameof(Int2)}.*"); + + /// + /// Subtracts two values + /// + /// The first value to subtract + /// The second value to subtract + public static Int2 operator -(Int2 left, Int2 right) => throw new InvalidExecutionContextException($"{nameof(Int2)}.-"); } } diff --git a/src/ComputeSharp.Shaders/Primitives/Int/Int3.cs b/src/ComputeSharp.Shaders/Primitives/Int/Int3.cs index d243582f..b269bbc7 100644 --- a/src/ComputeSharp.Shaders/Primitives/Int/Int3.cs +++ b/src/ComputeSharp.Shaders/Primitives/Int/Int3.cs @@ -560,5 +560,33 @@ namespace ComputeSharp /// /// The value to use for the components of the new instance public static implicit operator Int3(int x) => new Int3(x, x, x); + + /// + /// Sums two values + /// + /// The first value to sum + /// The second value to sum + public static Int3 operator +(Int3 left, Int3 right) => throw new InvalidExecutionContextException($"{nameof(Int3)}.+"); + + /// + /// Divides two values + /// + /// The first value to divide + /// The second value to divide + public static Int3 operator /(Int3 left, Int3 right) => throw new InvalidExecutionContextException($"{nameof(Int3)}./"); + + /// + /// Multiplies two values + /// + /// The first value to multiply + /// The second value to multiply + public static Int3 operator *(Int3 left, Int3 right) => throw new InvalidExecutionContextException($"{nameof(Int3)}.*"); + + /// + /// Subtracts two values + /// + /// The first value to subtract + /// The second value to subtract + public static Int3 operator -(Int3 left, Int3 right) => throw new InvalidExecutionContextException($"{nameof(Int3)}.-"); } } diff --git a/src/ComputeSharp.Shaders/Primitives/Int/Int4.cs b/src/ComputeSharp.Shaders/Primitives/Int/Int4.cs index d49339bd..cf5bb27a 100644 --- a/src/ComputeSharp.Shaders/Primitives/Int/Int4.cs +++ b/src/ComputeSharp.Shaders/Primitives/Int/Int4.cs @@ -3965,5 +3965,33 @@ namespace ComputeSharp /// /// The value to use for the components of the new instance public static implicit operator Int4(int x) => new Int4(x, x, x, x); + + /// + /// Sums two values + /// + /// The first value to sum + /// The second value to sum + public static Int4 operator +(Int4 left, Int4 right) => throw new InvalidExecutionContextException($"{nameof(Int4)}.+"); + + /// + /// Divides two values + /// + /// The first value to divide + /// The second value to divide + public static Int4 operator /(Int4 left, Int4 right) => throw new InvalidExecutionContextException($"{nameof(Int4)}./"); + + /// + /// Multiplies two values + /// + /// The first value to multiply + /// The second value to multiply + public static Int4 operator *(Int4 left, Int4 right) => throw new InvalidExecutionContextException($"{nameof(Int4)}.*"); + + /// + /// Subtracts two values + /// + /// The first value to subtract + /// The second value to subtract + public static Int4 operator -(Int4 left, Int4 right) => throw new InvalidExecutionContextException($"{nameof(Int4)}.-"); } } diff --git a/src/ComputeSharp.Shaders/Primitives/UInt/UInt4.cs b/src/ComputeSharp.Shaders/Primitives/UInt/UInt4.cs index 73dc7c4e..0f1d3958 100644 --- a/src/ComputeSharp.Shaders/Primitives/UInt/UInt4.cs +++ b/src/ComputeSharp.Shaders/Primitives/UInt/UInt4.cs @@ -3965,5 +3965,33 @@ namespace ComputeSharp /// /// The value to use for the components of the new instance public static implicit operator UInt4(uint x) => new UInt4(x, x, x, x); + + /// + /// Sums two values + /// + /// The first value to sum + /// The second value to sum + public static UInt4 operator +(UInt4 left, UInt4 right) => throw new InvalidExecutionContextException($"{nameof(UInt4)}.+"); + + /// + /// Divides two values + /// + /// The first value to divide + /// The second value to divide + public static UInt4 operator /(UInt4 left, UInt4 right) => throw new InvalidExecutionContextException($"{nameof(UInt4)}./"); + + /// + /// Multiplies two values + /// + /// The first value to multiply + /// The second value to multiply + public static UInt4 operator *(UInt4 left, UInt4 right) => throw new InvalidExecutionContextException($"{nameof(UInt4)}.*"); + + /// + /// Subtracts two values + /// + /// The first value to subtract + /// The second value to subtract + public static UInt4 operator -(UInt4 left, UInt4 right) => throw new InvalidExecutionContextException($"{nameof(UInt4)}.-"); } } diff --git a/src/ComputeSharp.Shaders/Primitives/UInt/Uint2.cs b/src/ComputeSharp.Shaders/Primitives/UInt/Uint2.cs index ea384390..e4793006 100644 --- a/src/ComputeSharp.Shaders/Primitives/UInt/Uint2.cs +++ b/src/ComputeSharp.Shaders/Primitives/UInt/Uint2.cs @@ -139,5 +139,33 @@ namespace ComputeSharp /// /// The value to use for the components of the new instance public static implicit operator UInt2(uint x) => new UInt2(x, x); + + /// + /// Sums two values + /// + /// The first value to sum + /// The second value to sum + public static UInt2 operator +(UInt2 left, UInt2 right) => throw new InvalidExecutionContextException($"{nameof(UInt2)}.+"); + + /// + /// Divides two values + /// + /// The first value to divide + /// The second value to divide + public static UInt2 operator /(UInt2 left, UInt2 right) => throw new InvalidExecutionContextException($"{nameof(UInt2)}./"); + + /// + /// Multiplies two values + /// + /// The first value to multiply + /// The second value to multiply + public static UInt2 operator *(UInt2 left, UInt2 right) => throw new InvalidExecutionContextException($"{nameof(UInt2)}.*"); + + /// + /// Subtracts two values + /// + /// The first value to subtract + /// The second value to subtract + public static UInt2 operator -(UInt2 left, UInt2 right) => throw new InvalidExecutionContextException($"{nameof(UInt2)}.-"); } } diff --git a/src/ComputeSharp.Shaders/Primitives/UInt/Uint3.cs b/src/ComputeSharp.Shaders/Primitives/UInt/Uint3.cs index 88d09098..71ca09ae 100644 --- a/src/ComputeSharp.Shaders/Primitives/UInt/Uint3.cs +++ b/src/ComputeSharp.Shaders/Primitives/UInt/Uint3.cs @@ -560,5 +560,33 @@ namespace ComputeSharp /// /// The value to use for the components of the new instance public static implicit operator UInt3(uint x) => new UInt3(x, x, x); + + /// + /// Sums two values + /// + /// The first value to sum + /// The second value to sum + public static UInt3 operator +(UInt3 left, UInt3 right) => throw new InvalidExecutionContextException($"{nameof(UInt3)}.+"); + + /// + /// Divides two values + /// + /// The first value to divide + /// The second value to divide + public static UInt3 operator /(UInt3 left, UInt3 right) => throw new InvalidExecutionContextException($"{nameof(UInt3)}./"); + + /// + /// Multiplies two values + /// + /// The first value to multiply + /// The second value to multiply + public static UInt3 operator *(UInt3 left, UInt3 right) => throw new InvalidExecutionContextException($"{nameof(UInt3)}.*"); + + /// + /// Subtracts two values + /// + /// The first value to subtract + /// The second value to subtract + public static UInt3 operator -(UInt3 left, UInt3 right) => throw new InvalidExecutionContextException($"{nameof(UInt3)}.-"); } }