Added more 4-channel pixel types
このコミットが含まれているのは:
1 親
b54fb3c7df
コミット
f68dd1222a
4ファイル変更
+247
検索条件に一致するファイルはありません
@@ -16,6 +16,7 @@ namespace ComputeSharp
|
||||
/// Ranges from [0, 0, 0, 0] to [1, 1, 1, 1] in vector form.
|
||||
/// </para>
|
||||
/// </summary>
|
||||
/// <remarks>This struct is fully mutable.</remarks>
|
||||
[StructLayout(LayoutKind.Sequential)]
|
||||
public struct Bgra32 : IEquatable<Bgra32>, IUnorm<Vector4>, IUnorm<Float4>, IUnorm<Double4>
|
||||
{
|
||||
@@ -108,9 +109,11 @@ namespace ComputeSharp
|
||||
public override readonly bool Equals(object? obj) => obj is Bgra32 other && Equals(other);
|
||||
|
||||
/// <inheritdoc/>
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public readonly bool Equals(Bgra32 other) => PackedValue.Equals(other.PackedValue);
|
||||
|
||||
/// <inheritdoc/>
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public override readonly int GetHashCode() => PackedValue.GetHashCode();
|
||||
|
||||
/// <inheritdoc />
|
||||
|
||||
@@ -0,0 +1,121 @@
|
||||
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 four 8-bit unsigned normalized values ranging from 0 to 255.
|
||||
/// The color components are stored in red, green, blue, and alpha order (least significant to most significant byte).
|
||||
/// <para>
|
||||
/// Ranges from [0, 0, 0, 0] to [1, 1, 1, 1] in vector form.
|
||||
/// </para>
|
||||
/// </summary>
|
||||
/// <remarks>This struct is fully mutable.</remarks>
|
||||
[StructLayout(LayoutKind.Sequential)]
|
||||
public struct Rgba32 : IEquatable<Rgba32>, IUnorm<Vector4>, IUnorm<Float4>, IUnorm<Double4>
|
||||
{
|
||||
/// <summary>
|
||||
/// The red component.
|
||||
/// </summary>
|
||||
public byte R;
|
||||
|
||||
/// <summary>
|
||||
/// The green component.
|
||||
/// </summary>
|
||||
public byte G;
|
||||
|
||||
/// <summary>
|
||||
/// The blue component.
|
||||
/// </summary>
|
||||
public byte B;
|
||||
|
||||
/// <summary>
|
||||
/// The alpha component.
|
||||
/// </summary>
|
||||
public byte A;
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="Rgba32"/> struct.
|
||||
/// </summary>
|
||||
/// <param name="r">The red component.</param>
|
||||
/// <param name="g">The green component.</param>
|
||||
/// <param name="b">The blue component.</param>
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public Rgba32(byte r, byte g, byte b)
|
||||
{
|
||||
this.R = r;
|
||||
this.G = g;
|
||||
this.B = b;
|
||||
this.A = byte.MaxValue;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="Rgba32"/> struct.
|
||||
/// </summary>
|
||||
/// <param name="r">The red component.</param>
|
||||
/// <param name="g">The green component.</param>
|
||||
/// <param name="b">The blue component.</param>
|
||||
/// <param name="a">The alpha component.</param>
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public Rgba32(byte r, byte g, byte b, byte a)
|
||||
{
|
||||
this.R = r;
|
||||
this.G = g;
|
||||
this.B = b;
|
||||
this.A = a;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the packed representation of the Rgba32 struct.
|
||||
/// </summary>
|
||||
public uint PackedValue
|
||||
{
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
readonly get => Unsafe.As<Rgba32, uint>(ref Unsafe.AsRef(this));
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
set => Unsafe.As<Rgba32, uint>(ref this) = value;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Compares two <see cref="Rgba32"/> objects for equality.
|
||||
/// </summary>
|
||||
/// <param name="left">The <see cref="Rgba32"/> on the left side of the operand.</param>
|
||||
/// <param name="right">The <see cref="Rgba32"/> 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 ==(Rgba32 left, Rgba32 right) => left.Equals(right);
|
||||
|
||||
/// <summary>
|
||||
/// Compares two <see cref="Rgba32"/> objects for equality.
|
||||
/// </summary>
|
||||
/// <param name="left">The <see cref="Rgba32"/> on the left side of the operand.</param>
|
||||
/// <param name="right">The <see cref="Rgba32"/> 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 !=(Rgba32 left, Rgba32 right) => !left.Equals(right);
|
||||
|
||||
/// <inheritdoc/>
|
||||
public override readonly bool Equals(object obj) => obj is Rgba32 rgba32 && Equals(rgba32);
|
||||
|
||||
/// <inheritdoc/>
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public readonly bool Equals(Rgba32 other) => PackedValue.Equals(other.PackedValue);
|
||||
|
||||
/// <inheritdoc/>
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public override readonly int GetHashCode() => PackedValue.GetHashCode();
|
||||
|
||||
/// <inheritdoc/>
|
||||
public override readonly string ToString() => $"{nameof(Rgba32)}({this.R}, {this.G}, {this.B}, {this.A})";
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,121 @@
|
||||
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 four 16-bit unsigned normalized values ranging from 0 to 255.
|
||||
/// The color components are stored in red, green, blue, and alpha order (least significant to most significant byte).
|
||||
/// <para>
|
||||
/// Ranges from [0, 0, 0, 0] to [1, 1, 1, 1] in vector form.
|
||||
/// </para>
|
||||
/// </summary>
|
||||
/// <remarks>This struct is fully mutable.</remarks>
|
||||
[StructLayout(LayoutKind.Sequential)]
|
||||
public struct Rgba64 : IEquatable<Rgba64>, IUnorm<Vector4>, IUnorm<Float4>, IUnorm<Double4>
|
||||
{
|
||||
/// <summary>
|
||||
/// The red component.
|
||||
/// </summary>
|
||||
public ushort R;
|
||||
|
||||
/// <summary>
|
||||
/// The green component.
|
||||
/// </summary>
|
||||
public ushort G;
|
||||
|
||||
/// <summary>
|
||||
/// The blue component.
|
||||
/// </summary>
|
||||
public ushort B;
|
||||
|
||||
/// <summary>
|
||||
/// The alpha component.
|
||||
/// </summary>
|
||||
public ushort A;
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="Rgba64"/> struct.
|
||||
/// </summary>
|
||||
/// <param name="r">The red component.</param>
|
||||
/// <param name="g">The green component.</param>
|
||||
/// <param name="b">The blue component.</param>
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public Rgba64(ushort r, ushort g, ushort b)
|
||||
{
|
||||
this.R = r;
|
||||
this.G = g;
|
||||
this.B = b;
|
||||
this.A = ushort.MaxValue;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="Rgba64"/> struct.
|
||||
/// </summary>
|
||||
/// <param name="r">The red component.</param>
|
||||
/// <param name="g">The green component.</param>
|
||||
/// <param name="b">The blue component.</param>
|
||||
/// <param name="a">The alpha component.</param>
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public Rgba64(ushort r, ushort g, ushort b, ushort a)
|
||||
{
|
||||
this.R = r;
|
||||
this.G = g;
|
||||
this.B = b;
|
||||
this.A = a;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the packed representation of the Rgba64 struct.
|
||||
/// </summary>
|
||||
public ulong PackedValue
|
||||
{
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
readonly get => Unsafe.As<Rgba64, ulong>(ref Unsafe.AsRef(this));
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
set => Unsafe.As<Rgba64, ulong>(ref this) = value;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Compares two <see cref="Rgba64"/> objects for equality.
|
||||
/// </summary>
|
||||
/// <param name="left">The <see cref="Rgba64"/> on the left side of the operand.</param>
|
||||
/// <param name="right">The <see cref="Rgba64"/> 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 ==(Rgba64 left, Rgba64 right) => left.Equals(right);
|
||||
|
||||
/// <summary>
|
||||
/// Compares two <see cref="Rgba64"/> objects for equality.
|
||||
/// </summary>
|
||||
/// <param name="left">The <see cref="Rgba64"/> on the left side of the operand.</param>
|
||||
/// <param name="right">The <see cref="Rgba64"/> 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 !=(Rgba64 left, Rgba64 right) => !left.Equals(right);
|
||||
|
||||
/// <inheritdoc/>
|
||||
public override readonly bool Equals(object obj) => obj is Rgba64 rgba32 && Equals(rgba32);
|
||||
|
||||
/// <inheritdoc/>
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public readonly bool Equals(Rgba64 other) => PackedValue.Equals(other.PackedValue);
|
||||
|
||||
/// <inheritdoc/>
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public override readonly int GetHashCode() => PackedValue.GetHashCode();
|
||||
|
||||
/// <inheritdoc/>
|
||||
public override readonly string ToString() => $"{nameof(Rgba64)}({this.R}, {this.G}, {this.B}, {this.A})";
|
||||
}
|
||||
}
|
||||
@@ -39,6 +39,8 @@ namespace ComputeSharp.Graphics.Helpers
|
||||
else if (typeof(T) == typeof(Vector3)) return DXGI_FORMAT_R32G32B32_FLOAT;
|
||||
else if (typeof(T) == typeof(Vector4)) return DXGI_FORMAT_R32G32B32A32_FLOAT;
|
||||
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 return ThrowHelper.ThrowArgumentException<DXGI_FORMAT>("Invalid texture type");
|
||||
}
|
||||
}
|
||||
|
||||
新しいイシューから参照
ユーザーをブロックする