Rename and tweak D2D1PixelOptions type
このコミットが含まれているのは:
1 親
a70ae6af38
コミット
ec1798cbe3
9ファイル変更
+25
-22
検索条件に一致するファイルはありません
@@ -68,7 +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\Enums\D2D1PixelOptions.cs" Link="ComputeSharp.D2D1\Attributes\Enums\D2D1PixelOptions.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" />
|
||||
|
||||
+1
-1
@@ -18,7 +18,7 @@ partial class ID2D1ShaderGenerator
|
||||
/// </summary>
|
||||
/// <param name="pixelOptions">The pixel options for the shader.</param>
|
||||
/// <returns>The resulting <see cref="MethodDeclarationSyntax"/> instance for the <c>GetPixelOptions</c> method.</returns>
|
||||
public static MethodDeclarationSyntax GetSyntax(D2D1PixelOption pixelOptions)
|
||||
public static MethodDeclarationSyntax GetSyntax(D2D1PixelOptions pixelOptions)
|
||||
{
|
||||
// This code produces a method declaration as follows:
|
||||
//
|
||||
|
||||
+3
-3
@@ -16,15 +16,15 @@ partial class ID2D1ShaderGenerator
|
||||
/// </summary>
|
||||
/// <param name="structDeclarationSymbol">The input <see cref="INamedTypeSymbol"/> instance to process.</param>
|
||||
/// <param name="pixelOptions">The pixel options for the shader.</param>
|
||||
public static void GetInfo(INamedTypeSymbol structDeclarationSymbol, out D2D1PixelOption pixelOptions)
|
||||
public static void GetInfo(INamedTypeSymbol structDeclarationSymbol, out D2D1PixelOptions pixelOptions)
|
||||
{
|
||||
if (structDeclarationSymbol.TryGetAttributeWithFullMetadataName("ComputeSharp.D2D1.D2DPixelOptionsAttribute", out AttributeData? attributeData))
|
||||
{
|
||||
pixelOptions = (D2D1PixelOption)attributeData!.ConstructorArguments[0].Value!;
|
||||
pixelOptions = (D2D1PixelOptions)attributeData!.ConstructorArguments[0].Value!;
|
||||
}
|
||||
else
|
||||
{
|
||||
pixelOptions = D2D1PixelOption.None;
|
||||
pixelOptions = D2D1PixelOptions.None;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -308,18 +308,18 @@ public sealed partial class ID2D1ShaderGenerator : IIncrementalGenerator
|
||||
|
||||
// Get the pixel options, again independently from other generation steps.
|
||||
// This can also be immediately cached at a fine grained level.
|
||||
IncrementalValuesProvider<(HierarchyInfo Hierarchy, D2D1PixelOption Options)> pixelOptionsInfo =
|
||||
IncrementalValuesProvider<(HierarchyInfo Hierarchy, D2D1PixelOptions Options)> pixelOptionsInfo =
|
||||
shaderDeclarations
|
||||
.Select(static (item, token) =>
|
||||
{
|
||||
// GetPixelOptions() info
|
||||
GetPixelOptions.GetInfo(item.Symbol, out D2D1PixelOption pixelOptions);
|
||||
GetPixelOptions.GetInfo(item.Symbol, out D2D1PixelOptions pixelOptions);
|
||||
|
||||
token.ThrowIfCancellationRequested();
|
||||
|
||||
return (item.Hierarchy, pixelOptions);
|
||||
})
|
||||
.WithComparers(HierarchyInfo.Comparer.Default, EqualityComparer<D2D1PixelOption>.Default);
|
||||
.WithComparers(HierarchyInfo.Comparer.Default, EqualityComparer<D2D1PixelOptions>.Default);
|
||||
|
||||
// Generate the GetPixelOptions() methods
|
||||
context.RegisterSourceOutput(pixelOptionsInfo, static (context, item) =>
|
||||
|
||||
@@ -16,7 +16,7 @@ public sealed class D2DPixelOptionsAttribute : Attribute
|
||||
/// 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)
|
||||
public D2DPixelOptionsAttribute(D2D1PixelOptions options)
|
||||
{
|
||||
Options = options;
|
||||
}
|
||||
@@ -24,5 +24,5 @@ public sealed class D2DPixelOptionsAttribute : Attribute
|
||||
/// <summary>
|
||||
/// Gets the options to specify for the shader.
|
||||
/// </summary>
|
||||
public D2D1PixelOption Options { get; }
|
||||
public D2D1PixelOptions Options { get; }
|
||||
}
|
||||
+9
-6
@@ -1,22 +1,25 @@
|
||||
namespace ComputeSharp.D2D1;
|
||||
using System;
|
||||
using static TerraFX.Interop.DirectX.D2D1_PIXEL_OPTIONS;
|
||||
|
||||
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).
|
||||
/// Indicates how the sampling of a D2D1 pixel shader will be restricted.
|
||||
/// </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
|
||||
[Flags]
|
||||
public enum D2D1PixelOptions
|
||||
{
|
||||
/// <summary>
|
||||
/// The pixel shader is not restricted in its sampling.
|
||||
/// </summary>
|
||||
None,
|
||||
None = (int)D2D1_PIXEL_OPTIONS_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
|
||||
TrivialSampling = (int)D2D1_PIXEL_OPTIONS_TRIVIAL_SAMPLING
|
||||
}
|
||||
@@ -85,12 +85,12 @@ public static class D2D1PixelShader
|
||||
/// </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>()
|
||||
public static D2D1PixelOptions GetPixelOptions<T>()
|
||||
where T : unmanaged, ID2D1PixelShader
|
||||
{
|
||||
Unsafe.SkipInit(out T shader);
|
||||
|
||||
return (D2D1PixelOption)shader.GetPixelOptions();
|
||||
return (D2D1PixelOptions)shader.GetPixelOptions();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -67,7 +67,7 @@ internal unsafe partial struct PixelShaderEffect
|
||||
/// <summary>
|
||||
/// The pixel options for the shader.
|
||||
/// </summary>
|
||||
private static D2D1PixelOption pixelOptions;
|
||||
private static D2D1PixelOptions pixelOptions;
|
||||
|
||||
/// <summary>
|
||||
/// The shader bytecode.
|
||||
@@ -124,7 +124,7 @@ internal unsafe partial struct PixelShaderEffect
|
||||
byte* bytecode = (byte*)RuntimeHelpers.AllocateTypeAssociatedMemory(typeof(For<T>), bytecodeSize);
|
||||
D2D1BufferPrecision bufferPrecision = D2D1PixelShader.GetOutputBufferPrecision<T>();
|
||||
D2D1ChannelDepth channelDepth = D2D1PixelShader.GetOutputBufferChannelDepth<T>();
|
||||
D2D1PixelOption pixelOptions = D2D1PixelShader.GetPixelOptions<T>();
|
||||
D2D1PixelOptions pixelOptions = D2D1PixelShader.GetPixelOptions<T>();
|
||||
|
||||
// Prepare the inputs info
|
||||
int inputCount = D2D1PixelShader.GetInputCount<T>();
|
||||
|
||||
@@ -178,7 +178,7 @@ internal unsafe partial struct PixelShaderEffect
|
||||
/// <summary>
|
||||
/// The pixel options for the shader.
|
||||
/// </summary>
|
||||
private D2D1PixelOption pixelOptions;
|
||||
private D2D1PixelOptions pixelOptions;
|
||||
|
||||
/// <summary>
|
||||
/// The shader bytecode.
|
||||
@@ -232,7 +232,7 @@ internal unsafe partial struct PixelShaderEffect
|
||||
D2D1PixelShaderInputType* inputTypes,
|
||||
int inputDescriptionCount,
|
||||
D2D1InputDescription* inputDescriptions,
|
||||
D2D1PixelOption pixelOptions,
|
||||
D2D1PixelOptions pixelOptions,
|
||||
byte* bytecode,
|
||||
int bytecodeSize,
|
||||
D2D1BufferPrecision bufferPrecision,
|
||||
|
||||
新しいイシューから参照
ユーザーをブロックする