Add D2D1 pixel option types and APIs

このコミットが含まれているのは:
Sergio Pedri committed 2022-05-08 21:50:17 +02:00
1 親 6a83c6827d
コミット 6fbdef8ce4
5ファイル変更
+72

検索条件に一致するファイルはありません

+1
ファイルの表示
@@ -68,6 +68,7 @@
<Compile Include="..\ComputeSharp.D2D1\Attributes\Enums\D2D1BufferPrecision.cs" Link="ComputeSharp.D2D1\Attributes\Enums\D2D1BufferPrecision.cs" />
<Compile Include="..\ComputeSharp.D2D1\Attributes\Enums\D2D1ChannelDepth.cs" Link="ComputeSharp.D2D1\Attributes\Enums\D2D1ChannelDepth.cs" />
<Compile Include="..\ComputeSharp.D2D1\Attributes\Enums\D2D1Filter.cs" Link="ComputeSharp.D2D1\Attributes\Enums\D2D1Filter.cs" />
<Compile Include="..\ComputeSharp.D2D1\Attributes\Enums\D2D1PixelOption.cs" Link="ComputeSharp.D2D1\Attributes\Enums\D2D1PixelOption.cs" />
<Compile Include="..\ComputeSharp.D2D1\Attributes\D2DEmbeddedBytecodeAttribute.cs" Link="ComputeSharp.D2D1\Attributes\D2DEmbeddedBytecodeAttribute.cs" />
<Compile Include="..\ComputeSharp.D2D1\Attributes\D2DInputComplexAttribute.cs" Link="ComputeSharp.D2D1\Attributes\D2DInputComplexAttribute.cs" />
<Compile Include="..\ComputeSharp.D2D1\Attributes\D2DInputCountAttribute.cs" Link="ComputeSharp.D2D1\Attributes\D2DInputCountAttribute.cs" />
+28
ファイルの表示
@@ -0,0 +1,28 @@
using System;
namespace ComputeSharp.D2D1;
/// <summary>
/// An attribute for a D2D1 shader indicating the pixel options to use.
/// Using this attribute is optional when defining a D2D1 shader.
/// </summary>
/// <remarks>
/// For more info, see <see href="https://docs.microsoft.com/windows/win32/api/d2d1effectauthor/ne-d2d1effectauthor-d2d1_pixel_options"/>.
/// </remarks>
[AttributeUsage(AttributeTargets.Struct, AllowMultiple = false)]
public sealed class D2DPixelOptionsAttribute : Attribute
{
/// <summary>
/// Creates a new instance of the <see cref="D2DPixelOptionsAttribute"/> type with the specified arguments.
/// </summary>
/// <param name="options">The options to specify for the shader.</param>
public D2DPixelOptionsAttribute(D2D1PixelOption options)
{
Options = options;
}
/// <summary>
/// Gets the options to specify for the shader.
/// </summary>
public D2D1PixelOption Options { get; }
}
+22
ファイルの表示
@@ -0,0 +1,22 @@
namespace ComputeSharp.D2D1;
/// <summary>
/// Indicates how the sampling of a D2D1 pixel shader will be restricted. This indicates whether the vertex buffer
/// is large and tends to change infrequently or smaller and changes frequently (typically frame over frame).
/// </summary>
/// <remarks>
/// This type exposes the available values in <see href="https://docs.microsoft.com/windows/win32/api/d2d1effectauthor/ne-d2d1effectauthor-d2d1_pixel_options"/>.
/// </remarks>
public enum D2D1PixelOption
{
/// <summary>
/// The pixel shader is not restricted in its sampling.
/// </summary>
None,
/// <summary>
/// The pixel shader samples inputs only at the same scene coordinate as the output pixel
/// and returns transparent black whenever the input pixels are also transparent black.
/// </summary>
TrivialSampling
}
+8
ファイルの表示
@@ -19,6 +19,14 @@ public interface ID2D1Shader
[Obsolete("This method is not intended to be called directly by user code")]
void InitializeFromDispatchData(ReadOnlySpan<byte> data);
/// <summary>
/// Gets the pixel options for the current shader.
/// </summary>
/// <returns>The pixel options for the current shader.</returns>
[EditorBrowsable(EditorBrowsableState.Never)]
[Obsolete("This method is not intended to be used directly by user code")]
uint GetPixelOptions();
/// <summary>
/// Gets the number of inputs for the current shader.
/// </summary>
+13
ファイルの表示
@@ -80,6 +80,19 @@ public static class D2D1PixelShader
return new ReadOnlySpan<byte>(bytecodePtr, bytecodeSize).ToArray();
}
/// <summary>
/// Gets the pixel options from an input D2D1 pixel shader.
/// </summary>
/// <typeparam name="T">The type of D2D1 pixel shader to get the pixel options for.</typeparam>
/// <returns>The pixel options for the D2D1 pixel shader of type <typeparamref name="T"/>.</returns>
public static D2D1PixelOption GetPixelOptions<T>()
where T : unmanaged, ID2D1PixelShader
{
Unsafe.SkipInit(out T shader);
return (D2D1PixelOption)shader.GetPixelOptions();
}
/// <summary>
/// Gets the number of inputs from an input D2D1 pixel shader.
/// </summary>