Add D2D1PixelShaderEffect.GetEffectId<T>() API

このコミットが含まれているのは:
Sergio Pedri committed 2023-09-27 14:04:04 +02:00
1 親 321430b6da
コミット 4066899e44
2ファイル変更
+20 -5

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

+19 -4
ファイルの表示
@@ -18,6 +18,19 @@ namespace ComputeSharp.D2D1.Interop;
/// </summary>
public static unsafe class D2D1PixelShaderEffect
{
/// <summary>
/// Gets the effect id of the D2D effect using this shader.
/// </summary>
/// <typeparam name="T">The type of D2D1 pixel shader to get the effect id for.</typeparam>
/// <returns>The effect id of the D2D effect using <typeparamref name="T"/> shaders.</returns>
public static ref readonly Guid GetEffectId<T>()
where T : unmanaged, ID2D1PixelShader
{
Unsafe.SkipInit(out T shader);
return ref shader.EffectId;
}
/// <summary>
/// Registers an effect from an input D2D1 pixel shader, by calling <c>ID2D1Factory1::RegisterEffectFromString</c>.
/// </summary>
@@ -26,7 +39,10 @@ public static unsafe class D2D1PixelShaderEffect
/// <param name="effectId">The <see cref="Guid"/> of the registered effect, which can be used to call <c>ID2D1DeviceContext::CreateEffect</c>.</param>
/// <exception cref="ArgumentNullException">Thrown if <paramref name="d2D1Factory1"/> is <see langword="null"/>.</exception>
/// <exception cref="InvalidOperationException">Thrown if an effect is registered multiple times with different properties.</exception>
/// <remarks>For more info, see <see href="https://docs.microsoft.com/windows/win32/api/d2d1_1/nf-d2d1_1-id2d1factory1-registereffectfromstring"/>.</remarks>
/// <remarks>
/// <para>The returned <paramref name="effectId"/> value is the same as that returned by <see cref="GetEffectId{T}"/>.</para>
/// <para>For more info, see <see href="https://docs.microsoft.com/windows/win32/api/d2d1_1/nf-d2d1_1-id2d1factory1-registereffectfromstring"/>.</para>
/// </remarks>
public static void RegisterForD2D1Factory1<T>(void* d2D1Factory1, out Guid effectId)
where T : unmanaged, ID2D1PixelShader
{
@@ -261,9 +277,8 @@ public static unsafe class D2D1PixelShaderEffect
/// To make the deserialization easier, the <see cref="D2D1EffectRegistrationData"/> type can be used to read and validate the returned blob.
/// The leading blob id will determine what subtype should be used to deserialize the blob (eg. <see cref="D2D1EffectRegistrationData.V1"/>).
/// </para>
/// <para>
/// For more info, see <see href="https://docs.microsoft.com/windows/win32/api/d2d1_1/nf-d2d1_1-id2d1factory1-registereffectfromstring"/>.
/// </para>
/// <para>The returned <paramref name="effectId"/> value is the same as that returned by <see cref="GetEffectId{T}"/>.</para>
/// <para>For more info, see <see href="https://docs.microsoft.com/windows/win32/api/d2d1_1/nf-d2d1_1-id2d1factory1-registereffectfromstring"/>.</para>
/// </remarks>
public static ReadOnlyMemory<byte> GetRegistrationBlob<T>(out Guid effectId)
where T : unmanaged, ID2D1PixelShader
+1 -1
ファイルの表示
@@ -165,7 +165,7 @@ internal unsafe partial struct PixelShaderEffect
private static For<T> CreateInstance()
{
// Load all shader properties
Guid shaderId = typeof(T).GUID;
Guid shaderId = D2D1PixelShaderEffect.GetEffectId<T>();
int constantBufferSize = D2D1PixelShader.GetConstantBufferSize<T>();
D2D1BufferPrecision bufferPrecision = D2D1PixelShader.GetOutputBufferPrecision<T>();
D2D1ChannelDepth channelDepth = D2D1PixelShader.GetOutputBufferChannelDepth<T>();