Add APIs to get other metadata, update effect XML

このコミットが含まれているのは:
Sergio Pedri committed 2023-09-27 15:03:06 +02:00
1 親 e5daf558ec
コミット 308eab5fbc
1ファイル変更
+70 -7
+70 -7
ファイルの表示
@@ -34,7 +34,7 @@ public static unsafe class D2D1PixelShaderEffect
/// <summary>
/// Gets the effect display name of the D2D effect using this shader, if available.
/// </summary>
/// <typeparam name="T">The type of D2D1 pixel shader to get the effect id for.</typeparam>
/// <typeparam name="T">The type of D2D1 pixel shader to get the effect display name for.</typeparam>
/// <returns>The effect display name of the D2D effect using <typeparamref name="T"/> shaders, if available.</returns>
public static string? GetEffectDisplayName<T>()
where T : unmanaged, ID2D1PixelShader
@@ -44,6 +44,45 @@ public static unsafe class D2D1PixelShaderEffect
return shader.EffectDisplayName;
}
/// <summary>
/// Gets the effect description of the D2D effect using this shader, if available.
/// </summary>
/// <typeparam name="T">The type of D2D1 pixel shader to get the effect description for.</typeparam>
/// <returns>The effect description of the D2D effect using <typeparamref name="T"/> shaders, if available.</returns>
public static string? GetEffectDescription<T>()
where T : unmanaged, ID2D1PixelShader
{
Unsafe.SkipInit(out T shader);
return shader.EffectDescription;
}
/// <summary>
/// Gets the effect category of the D2D effect using this shader, if available.
/// </summary>
/// <typeparam name="T">The type of D2D1 pixel shader to get the effect category for.</typeparam>
/// <returns>The effect category of the D2D effect using <typeparamref name="T"/> shaders, if available.</returns>
public static string? GetEffectCategory<T>()
where T : unmanaged, ID2D1PixelShader
{
Unsafe.SkipInit(out T shader);
return shader.EffectCategory;
}
/// <summary>
/// Gets the effect author of the D2D effect using this shader, if available.
/// </summary>
/// <typeparam name="T">The type of D2D1 pixel shader to get the effect author for.</typeparam>
/// <returns>The effect author of the D2D effect using <typeparamref name="T"/> shaders, if available.</returns>
public static string? GetEffectAuthor<T>()
where T : unmanaged, ID2D1PixelShader
{
Unsafe.SkipInit(out T shader);
return shader.EffectAuthor;
}
/// <summary>
/// Registers an effect from an input D2D1 pixel shader, by calling <c>ID2D1Factory1::RegisterEffectFromString</c>.
/// </summary>
@@ -74,9 +113,21 @@ public static unsafe class D2D1PixelShaderEffect
writer.WriteRaw(GetEffectDisplayName<T>().AsSpan());
writer.WriteRaw("""
'/>
<Property name='Author' type='string' value='ComputeSharp.D2D1'/>
<Property name='Category' type='string' value='Stylize'/>
<Property name='Description' type='string' value='A custom D2D1 effect using a pixel shader'/>
<Property name='Description' type='string' value='
""");
writer.WriteRaw(GetEffectDescription<T>().AsSpan());
writer.WriteRaw("""
'/>
<Property name='Category' type='string' value='
""");
writer.WriteRaw(GetEffectCategory<T>().AsSpan());
writer.WriteRaw("""
'/>
<Property name='Author' type='string' value='
""");
writer.WriteRaw(GetEffectAuthor<T>().AsSpan());
writer.WriteRaw("""
'/>
<Inputs>
""");
@@ -314,9 +365,21 @@ public static unsafe class D2D1PixelShaderEffect
writer.WriteAsUtf8(GetEffectDisplayName<T>() ?? "");
writer.WriteRaw("""
'/>
<Property name='Author' type='string' value='ComputeSharp.D2D1'/>
<Property name='Category' type='string' value='Stylize'/>
<Property name='Description' type='string' value='A custom D2D1 effect using a pixel shader'/>
<Property name='Description' type='string' value='
"""u8);
writer.WriteAsUtf8(GetEffectDescription<T>() ?? "");
writer.WriteRaw("""
'/>
<Property name='Category' type='string' value='
"""u8);
writer.WriteAsUtf8(GetEffectCategory<T>() ?? "");
writer.WriteRaw("""
'/>
<Property name='Author' type='string' value='
"""u8);
writer.WriteAsUtf8(GetEffectAuthor<T>() ?? "");
writer.WriteRaw("""
'/>
<Inputs>
"""u8);