Add D2D1PixelShader.GetInputDescriptions API

このコミットが含まれているのは:
Sergio Pedri committed 2022-05-08 18:40:26 +02:00
1 親 3b760f02d4
コミット 7a5386a55e
8ファイル変更
+68 -13

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

+18 -1
ファイルの表示
@@ -1,8 +1,8 @@
using System;
using System.Runtime.CompilerServices;
using ComputeSharp.D2D1.Helpers;
using ComputeSharp.D2D1.Shaders.Dispatching;
using ComputeSharp.D2D1.Shaders.Interop.Buffers;
using ComputeSharp.D2D1.Shaders.Loaders;
using TerraFX.Interop.DirectX;
using TerraFX.Interop.Windows;
@@ -113,6 +113,23 @@ public static class D2D1PixelShader
return (D2D1PixelShaderInputType)shader.GetInputType((uint)index);
}
/// <summary>
/// Gets the available input descriptions for a D2D1 pixel shader.
/// </summary>
/// <typeparam name="T">The type of D2D1 pixel shader to get the input descriptions for.</typeparam>
/// <returns>A <see cref="ReadOnlyMemory{T}"/> with the available input descriptions for the shader.</returns>
public static ReadOnlyMemory<D2D1InputDescription> GetInputDescriptions<T>()
where T : unmanaged, ID2D1PixelShader
{
D2D1ByteArrayInputDescriptionsLoader inputDescriptionsLoader = default;
Unsafe.SkipInit(out T shader);
shader.LoadInputDescriptions(ref inputDescriptionsLoader);
return inputDescriptionsLoader.GetResultingInputDescriptions();
}
/// <summary>
/// Gets the buffer precision for the output buffer of a D2D1 pixel shader.
/// </summary>
+1 -1
ファイルの表示
@@ -8,8 +8,8 @@ using System.Text;
using ComputeSharp.D2D1.Extensions;
using ComputeSharp.D2D1.Helpers;
using ComputeSharp.D2D1.Interop.Effects;
using ComputeSharp.D2D1.Shaders.Dispatching;
using ComputeSharp.D2D1.Shaders.Interop.Buffers;
using ComputeSharp.D2D1.Shaders.Loaders;
using TerraFX.Interop.DirectX;
using TerraFX.Interop.Windows;
+1 -1
ファイルの表示
@@ -2,7 +2,7 @@
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using ComputeSharp.D2D1.Extensions;
using ComputeSharp.D2D1.Shaders.Dispatching;
using ComputeSharp.D2D1.Shaders.Loaders;
using TerraFX.Interop.DirectX;
using TerraFX.Interop.Windows;
@@ -6,7 +6,7 @@ using TerraFX.Interop.DirectX;
#pragma warning disable CS0618
namespace ComputeSharp.D2D1.Shaders.Dispatching;
namespace ComputeSharp.D2D1.Shaders.Loaders;
/// <summary>
/// A data loader for D2D1 pixel shaders dispatched via <see cref="ID2D1DrawInfo"/>.
@@ -14,7 +14,7 @@ namespace ComputeSharp.D2D1.Shaders.Dispatching;
internal struct D2D1ByteArrayDispatchDataLoader : ID2D1DispatchDataLoader
{
/// <summary>
/// The <see cref="ID2D1DrawInfo"/> object in use.
/// The resulting array with the constant buffer to use.
/// </summary>
private byte[]? data;
@@ -29,7 +29,7 @@ internal struct D2D1ByteArrayDispatchDataLoader : ID2D1DispatchDataLoader
}
/// <inheritdoc/>
public void LoadConstantBuffer(ReadOnlySpan<uint> data)
void ID2D1DispatchDataLoader.LoadConstantBuffer(ReadOnlySpan<uint> data)
{
this.data = MemoryMarshal.AsBytes(data).ToArray();
}
+37
ファイルの表示
@@ -0,0 +1,37 @@
using System;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using ComputeSharp.D2D1.__Internals;
using ComputeSharp.D2D1.Interop;
using TerraFX.Interop.DirectX;
#pragma warning disable CS0618
namespace ComputeSharp.D2D1.Shaders.Loaders;
/// <summary>
/// An input descriptions loader for D2D1 pixel shaders.
/// </summary>
internal struct D2D1ByteArrayInputDescriptionsLoader : ID2D1InputDescriptionsLoader
{
/// <summary>
/// The <see cref="ID2D1DrawInfo"/> object in use.
/// </summary>
private D2D1InputDescription[]? inputDescriptions;
/// <summary>
/// Gets the resulting input descriptions.
/// </summary>
/// <remarks>A <see cref="D2D1InputDescription"/> array with the available input descriptions.</remarks>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public D2D1InputDescription[] GetResultingInputDescriptions()
{
return this.inputDescriptions!;
}
/// <inheritdoc/>
void ID2D1InputDescriptionsLoader.LoadInputDescriptions(ReadOnlySpan<byte> data)
{
this.inputDescriptions = MemoryMarshal.Cast<byte, D2D1InputDescription>(data).ToArray();
}
}
@@ -6,7 +6,7 @@ using TerraFX.Interop.DirectX;
#pragma warning disable CS0618
namespace ComputeSharp.D2D1.Shaders.Dispatching;
namespace ComputeSharp.D2D1.Shaders.Loaders;
/// <summary>
/// A data loader for D2D1 pixel shaders dispatched via <see cref="ID2D1DrawInfo"/>.
@@ -29,7 +29,7 @@ internal readonly unsafe struct D2D1DrawInfoDispatchDataLoader : ID2D1DispatchDa
}
/// <inheritdoc/>
public void LoadConstantBuffer(ReadOnlySpan<uint> data)
void ID2D1DispatchDataLoader.LoadConstantBuffer(ReadOnlySpan<uint> data)
{
this.d2D1DrawInfo->SetPixelShaderConstantBuffer(
buffer: (byte*)Unsafe.AsPointer(ref MemoryMarshal.GetReference(data)),
@@ -7,7 +7,7 @@ using TerraFX.Interop.DirectX;
#pragma warning disable CS0618
namespace ComputeSharp.D2D1.Shaders.Dispatching;
namespace ComputeSharp.D2D1.Shaders.Loaders;
/// <summary>
/// A data loader for D2D1 pixel shaders dispatched via <see cref="ID2D1Effect"/>.
@@ -30,7 +30,7 @@ internal readonly unsafe struct D2D1EffectDispatchDataLoader : ID2D1DispatchData
}
/// <inheritdoc/>
public void LoadConstantBuffer(ReadOnlySpan<uint> data)
void ID2D1DispatchDataLoader.LoadConstantBuffer(ReadOnlySpan<uint> data)
{
if (data.IsEmpty)
{
@@ -9,7 +9,7 @@ using TerraFX.Interop.Windows;
#pragma warning disable CS0618
namespace ComputeSharp.D2D1.Shaders.Dispatching;
namespace ComputeSharp.D2D1.Shaders.Loaders;
/// <summary>
/// A bytecode loader for D2D1 shaders.
@@ -46,7 +46,8 @@ internal unsafe struct D2D1ShaderBytecodeLoader : ID2D1BytecodeLoader
}
/// <inheritdoc/>
public unsafe void LoadDynamicBytecode(IntPtr handle)
[MethodImpl(MethodImplOptions.AggressiveInlining)]
unsafe void ID2D1BytecodeLoader.LoadDynamicBytecode(IntPtr handle)
{
if (this.embeddedBytecodePtr is not null ||
this.d3DBlob.Get() is not null)
@@ -64,7 +65,7 @@ internal unsafe struct D2D1ShaderBytecodeLoader : ID2D1BytecodeLoader
/// <inheritdoc/>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public void LoadEmbeddedBytecode(ReadOnlySpan<byte> bytecode)
void ID2D1BytecodeLoader.LoadEmbeddedBytecode(ReadOnlySpan<byte> bytecode)
{
if (this.embeddedBytecodePtr is not null ||
this.d3DBlob.Get() is not null)