From d9ef5c9742a0c3fb222a16b630923e6cd7a55556 Mon Sep 17 00:00:00 2001 From: Sergio Pedri Date: Sun, 25 Aug 2019 22:56:18 +0200 Subject: [PATCH] Added implicit operators for the Int2, Int3 and Int4 structs --- src/ComputeSharp.Shaders/Primitives/Int/Int2.cs | 6 ++++++ src/ComputeSharp.Shaders/Primitives/Int/Int3.cs | 6 ++++++ src/ComputeSharp.Shaders/Primitives/Int/Int4.cs | 6 ++++++ 3 files changed, 18 insertions(+) diff --git a/src/ComputeSharp.Shaders/Primitives/Int/Int2.cs b/src/ComputeSharp.Shaders/Primitives/Int/Int2.cs index ff77fd6b..3fb52e8d 100644 --- a/src/ComputeSharp.Shaders/Primitives/Int/Int2.cs +++ b/src/ComputeSharp.Shaders/Primitives/Int/Int2.cs @@ -113,5 +113,11 @@ namespace ComputeSharp.Shaders.Primitives.Int /// Gets an value with the value for all components /// public Int2 GG => throw new InvalidExecutionContextException($"{nameof(Int2)}.{nameof(GG)}"); + + /// + /// Creates a new value with the same value for all its components + /// + /// The value to use for the components of the new instance + public static implicit operator Int2(int x) => new Int2(x, x); } } diff --git a/src/ComputeSharp.Shaders/Primitives/Int/Int3.cs b/src/ComputeSharp.Shaders/Primitives/Int/Int3.cs index cdb62643..f4407028 100644 --- a/src/ComputeSharp.Shaders/Primitives/Int/Int3.cs +++ b/src/ComputeSharp.Shaders/Primitives/Int/Int3.cs @@ -529,5 +529,11 @@ namespace ComputeSharp.Shaders.Primitives.Int /// Gets an value with the value for all components /// public Int2 BBB => throw new InvalidExecutionContextException($"{nameof(Int3)}.{nameof(BBB)}"); + + /// + /// Creates a new value with the same value for all its components + /// + /// The value to use for the components of the new instance + public static implicit operator Int3(int x) => new Int3(x, x, x); } } diff --git a/src/ComputeSharp.Shaders/Primitives/Int/Int4.cs b/src/ComputeSharp.Shaders/Primitives/Int/Int4.cs index 9a8707d1..1a5a1888 100644 --- a/src/ComputeSharp.Shaders/Primitives/Int/Int4.cs +++ b/src/ComputeSharp.Shaders/Primitives/Int/Int4.cs @@ -3929,5 +3929,11 @@ namespace ComputeSharp.Shaders.Primitives.Int /// Gets an value with the value for all components /// public Int4 AAAA => throw new InvalidExecutionContextException($"{nameof(Int4)}.{nameof(AAAA)}"); + + /// + /// Creates a new value with the same value for all its components + /// + /// The value to use for the components of the new instance + public static implicit operator Int4(int x) => new Int4(x, x, x, x); } }