From c57c530bf9bf006f48185ead57d9ec2bcf522725 Mon Sep 17 00:00:00 2001 From: Sergio Pedri Date: Sun, 25 Aug 2019 20:07:04 +0200 Subject: [PATCH] Added Int2 struct --- .../Primitives/Int/Int2.cs | 89 +++++++++++++++++++ 1 file changed, 89 insertions(+) create mode 100644 src/ComputeSharp.Shaders/Primitives/Int/Int2.cs diff --git a/src/ComputeSharp.Shaders/Primitives/Int/Int2.cs b/src/ComputeSharp.Shaders/Primitives/Int/Int2.cs new file mode 100644 index 00000000..10c47ebf --- /dev/null +++ b/src/ComputeSharp.Shaders/Primitives/Int/Int2.cs @@ -0,0 +1,89 @@ +using System.Runtime.InteropServices; +using ComputeSharp.Graphics.Exceptions; + +namespace ComputeSharp.Shaders.Primitives.Int +{ + /// + /// A that maps the int2 HLSL type + /// + [StructLayout(LayoutKind.Sequential, Size = sizeof(int) * 2)] + public struct Int2 + { + /// + /// Creates a new instance with the specified parameters + /// + /// The value to assign to the first vector component + /// The value to assign to the second vector component + public Int2(int x, int y) + { + X = x; + Y = y; + } + + /// + /// Gets or sets the value of the first vector component + /// + public int X { get; set; } + + /// + /// Gets or sets the value of the second vector component + /// + public int Y { get; set; } + + /// + /// Gets or sets the value of the first color component + /// + public float R + { + get => throw new InvalidExecutionContextException($"{nameof(Int2)}.{nameof(R)}"); + set => throw new InvalidExecutionContextException($"{nameof(Int2)}.{nameof(R)}"); + } + + /// + /// Gets or sets the value of the second color component + /// + public float G + { + get => throw new InvalidExecutionContextException($"{nameof(Int2)}.{nameof(G)}"); + set => throw new InvalidExecutionContextException($"{nameof(Int2)}.{nameof(G)}"); + } + + /// + /// Gets or sets a specific component in the current instance + /// + /// The index of the component to access + public float this[int i] + { + get => throw new InvalidExecutionContextException($"{nameof(Int2)}[int]"); + set => throw new InvalidExecutionContextException($"{nameof(Int2)}[int]"); + } + + /// + /// Gets an value with the value for all components + /// + public Int2 XX => throw new InvalidExecutionContextException($"{nameof(Int2)}.{nameof(XX)}"); + + /// + /// Gets or sets an value with the and values + /// + public Int2 XY + { + get => throw new InvalidExecutionContextException($"{nameof(Int2)}.{nameof(XY)}"); + set => throw new InvalidExecutionContextException($"{nameof(Int2)}.{nameof(XY)}"); + } + + /// + /// Gets an value with the and values + /// + public Int2 YX + { + get => throw new InvalidExecutionContextException($"{nameof(Int2)}.{nameof(YX)}"); + set => throw new InvalidExecutionContextException($"{nameof(Int2)}.{nameof(YX)}"); + } + + /// + /// Gets an value with the value for all components + /// + public Int2 YY => throw new InvalidExecutionContextException($"{nameof(Int2)}.{nameof(YY)}"); + } +}