Added more pixel types
このコミットが含まれているのは:
1 親
c8af56cbc4
コミット
92bc95b028
4ファイル変更
+262
検索条件に一致するファイルはありません
@@ -0,0 +1,81 @@
|
||||
using System;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Runtime.InteropServices;
|
||||
using ComputeSharp.__Internals;
|
||||
|
||||
#pragma warning disable CS0618
|
||||
|
||||
namespace ComputeSharp
|
||||
{
|
||||
/// <summary>
|
||||
/// Packed pixel type containing a single 8-bit unsigned normalized channel value.
|
||||
/// <para>
|
||||
/// Ranges from [0, 0, 0, 0] to [1, 0, 0, 0] in vector form.
|
||||
/// </para>
|
||||
/// </summary>
|
||||
[StructLayout(LayoutKind.Sequential)]
|
||||
public struct R8 : IEquatable<R8>, IUnorm<float>, IUnorm<double>
|
||||
{
|
||||
/// <summary>
|
||||
/// The red component.
|
||||
/// </summary>
|
||||
public byte R;
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="R8"/> struct.
|
||||
/// </summary>
|
||||
/// <param name="r">The red component.</param>
|
||||
public R8(byte r)
|
||||
{
|
||||
R = r;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the packed representation of the Rgba32 struct.
|
||||
/// </summary>
|
||||
public byte PackedValue
|
||||
{
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
readonly get => Unsafe.As<R8, byte>(ref Unsafe.AsRef(this));
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
set => Unsafe.As<R8, byte>(ref this) = value;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Compares two <see cref="R8"/> objects for equality.
|
||||
/// </summary>
|
||||
/// <param name="left">The <see cref="R8"/> on the left side of the operand.</param>
|
||||
/// <param name="right">The <see cref="R8"/> on the right side of the operand.</param>
|
||||
/// <returns>
|
||||
/// True if the <paramref name="left"/> parameter is equal to the <paramref name="right"/> parameter; otherwise, false.
|
||||
/// </returns>
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static bool operator ==(R8 left, R8 right) => left.Equals(right);
|
||||
|
||||
/// <summary>
|
||||
/// Compares two <see cref="R8"/> objects for equality.
|
||||
/// </summary>
|
||||
/// <param name="left">The <see cref="R8"/> on the left side of the operand.</param>
|
||||
/// <param name="right">The <see cref="R8"/> on the right side of the operand.</param>
|
||||
/// <returns>
|
||||
/// True if the <paramref name="left"/> parameter is not equal to the <paramref name="right"/> parameter; otherwise, false.
|
||||
/// </returns>
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static bool operator !=(R8 left, R8 right) => !left.Equals(right);
|
||||
|
||||
/// <inheritdoc/>
|
||||
public override readonly bool Equals(object obj) => obj is R8 R8 && Equals(R8);
|
||||
|
||||
/// <inheritdoc/>
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public readonly bool Equals(R8 other) => PackedValue.Equals(other.PackedValue);
|
||||
|
||||
/// <inheritdoc/>
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public override readonly int GetHashCode() => PackedValue.GetHashCode();
|
||||
|
||||
/// <inheritdoc/>
|
||||
public override readonly string ToString() => $"{nameof(R8)}({this.R})";
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,89 @@
|
||||
using System;
|
||||
using System.Numerics;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Runtime.InteropServices;
|
||||
using ComputeSharp.__Internals;
|
||||
|
||||
#pragma warning disable CS0618
|
||||
|
||||
namespace ComputeSharp
|
||||
{
|
||||
/// <summary>
|
||||
/// Packed pixel type containing two 8-bit unsigned normalized values ranging from 0 to 255.
|
||||
/// <para>
|
||||
/// Ranges from [0, 0, 0, 0] to [1, 1, 0, 0] in vector form.
|
||||
/// </para>
|
||||
/// </summary>
|
||||
[StructLayout(LayoutKind.Sequential)]
|
||||
public struct Rg16 : IEquatable<Rg16>, IUnorm<Vector2>, IUnorm<Float2>, IUnorm<Double2>
|
||||
{
|
||||
/// <summary>
|
||||
/// The red component.
|
||||
/// </summary>
|
||||
public byte R;
|
||||
|
||||
/// <summary>
|
||||
/// The green component.
|
||||
/// </summary>
|
||||
public byte G;
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="Rg16"/> struct.
|
||||
/// </summary>
|
||||
/// <param name="x">The x-component</param>
|
||||
/// <param name="y">The y-component</param>
|
||||
public Rg16(byte r, byte g)
|
||||
{
|
||||
R = r;
|
||||
G = g;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the packed representation of the Rg16 struct.
|
||||
/// </summary>
|
||||
public ushort PackedValue
|
||||
{
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
readonly get => Unsafe.As<Rg16, ushort>(ref Unsafe.AsRef(this));
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
set => Unsafe.As<Rg16, ushort>(ref this) = value;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Compares two <see cref="Rg16"/> objects for equality.
|
||||
/// </summary>
|
||||
/// <param name="left">The <see cref="Rg16"/> on the left side of the operand.</param>
|
||||
/// <param name="right">The <see cref="Rg16"/> on the right side of the operand.</param>
|
||||
/// <returns>
|
||||
/// True if the <paramref name="left"/> parameter is equal to the <paramref name="right"/> parameter; otherwise, false.
|
||||
/// </returns>
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static bool operator ==(Rg16 left, Rg16 right) => left.Equals(right);
|
||||
|
||||
/// <summary>
|
||||
/// Compares two <see cref="Rg16"/> objects for equality.
|
||||
/// </summary>
|
||||
/// <param name="left">The <see cref="Rg16"/> on the left side of the operand.</param>
|
||||
/// <param name="right">The <see cref="Rg16"/> on the right side of the operand.</param>
|
||||
/// <returns>
|
||||
/// True if the <paramref name="left"/> parameter is not equal to the <paramref name="right"/> parameter; otherwise, false.
|
||||
/// </returns>
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static bool operator !=(Rg16 left, Rg16 right) => !left.Equals(right);
|
||||
|
||||
/// <inheritdoc/>
|
||||
public override readonly bool Equals(object obj) => obj is Rg16 rgba32 && Equals(rgba32);
|
||||
|
||||
/// <inheritdoc/>
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public readonly bool Equals(Rg16 other) => PackedValue.Equals(other.PackedValue);
|
||||
|
||||
/// <inheritdoc/>
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public override readonly int GetHashCode() => PackedValue.GetHashCode();
|
||||
|
||||
/// <inheritdoc/>
|
||||
public override readonly string ToString() => $"{nameof(Rg16)}({this.R}, {this.G})";
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,89 @@
|
||||
using System;
|
||||
using System.Numerics;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Runtime.InteropServices;
|
||||
using ComputeSharp.__Internals;
|
||||
|
||||
#pragma warning disable CS0618
|
||||
|
||||
namespace ComputeSharp
|
||||
{
|
||||
/// <summary>
|
||||
/// Packed pixel type containing two 16-bit unsigned normalized values ranging from 0 to 255.
|
||||
/// <para>
|
||||
/// Ranges from [0, 0, 0, 0] to [1, 1, 0, 0] in vector form.
|
||||
/// </para>
|
||||
/// </summary>
|
||||
[StructLayout(LayoutKind.Sequential)]
|
||||
public struct Rg32 : IEquatable<Rg32>, IUnorm<Vector2>, IUnorm<Float2>, IUnorm<Double2>
|
||||
{
|
||||
/// <summary>
|
||||
/// The red component.
|
||||
/// </summary>
|
||||
public ushort R;
|
||||
|
||||
/// <summary>
|
||||
/// The green component.
|
||||
/// </summary>
|
||||
public ushort G;
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="Rg32"/> struct.
|
||||
/// </summary>
|
||||
/// <param name="x">The x-component</param>
|
||||
/// <param name="y">The y-component</param>
|
||||
public Rg32(ushort r, ushort g)
|
||||
{
|
||||
R = r;
|
||||
G = g;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the packed representation of the Rg32 struct.
|
||||
/// </summary>
|
||||
public uint PackedValue
|
||||
{
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
readonly get => Unsafe.As<Rg32, uint>(ref Unsafe.AsRef(this));
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
set => Unsafe.As<Rg32, uint>(ref this) = value;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Compares two <see cref="Rg32"/> objects for equality.
|
||||
/// </summary>
|
||||
/// <param name="left">The <see cref="Rg32"/> on the left side of the operand.</param>
|
||||
/// <param name="right">The <see cref="Rg32"/> on the right side of the operand.</param>
|
||||
/// <returns>
|
||||
/// True if the <paramref name="left"/> parameter is equal to the <paramref name="right"/> parameter; otherwise, false.
|
||||
/// </returns>
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static bool operator ==(Rg32 left, Rg32 right) => left.Equals(right);
|
||||
|
||||
/// <summary>
|
||||
/// Compares two <see cref="Rg32"/> objects for equality.
|
||||
/// </summary>
|
||||
/// <param name="left">The <see cref="Rg32"/> on the left side of the operand.</param>
|
||||
/// <param name="right">The <see cref="Rg32"/> on the right side of the operand.</param>
|
||||
/// <returns>
|
||||
/// True if the <paramref name="left"/> parameter is not equal to the <paramref name="right"/> parameter; otherwise, false.
|
||||
/// </returns>
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static bool operator !=(Rg32 left, Rg32 right) => !left.Equals(right);
|
||||
|
||||
/// <inheritdoc/>
|
||||
public override readonly bool Equals(object obj) => obj is Rg32 rgba32 && Equals(rgba32);
|
||||
|
||||
/// <inheritdoc/>
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public readonly bool Equals(Rg32 other) => PackedValue.Equals(other.PackedValue);
|
||||
|
||||
/// <inheritdoc/>
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public override readonly int GetHashCode() => PackedValue.GetHashCode();
|
||||
|
||||
/// <inheritdoc/>
|
||||
public override readonly string ToString() => $"{nameof(Rg32)}({this.R}, {this.G})";
|
||||
}
|
||||
}
|
||||
@@ -41,6 +41,9 @@ namespace ComputeSharp.Graphics.Helpers
|
||||
else if (typeof(T) == typeof(Bgra32)) return DXGI_FORMAT_B8G8R8A8_UNORM;
|
||||
else if (typeof(T) == typeof(Rgba32)) return DXGI_FORMAT_R8G8B8A8_UNORM;
|
||||
else if (typeof(T) == typeof(Rgba64)) return DXGI_FORMAT_R16G16B16A16_UNORM;
|
||||
else if (typeof(T) == typeof(R8)) return DXGI_FORMAT_R8_UNORM;
|
||||
else if (typeof(T) == typeof(Rg16)) return DXGI_FORMAT_R8G8_UNORM;
|
||||
else if (typeof(T) == typeof(Rg32)) return DXGI_FORMAT_R16G16_UNORM;
|
||||
else return ThrowHelper.ThrowArgumentException<DXGI_FORMAT>("Invalid texture type");
|
||||
}
|
||||
}
|
||||
|
||||
新しいイシューから参照
ユーザーをブロックする