Update code to use new COM interface binding ttypes

このコミットが含まれているのは:
Sergio Pedri committed 2022-08-15 15:01:17 +02:00
1 親 7f80a7270f
コミット d02f8f3a9f
6ファイル変更
+47 -116

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

+36 -32
ファイルの表示
@@ -81,17 +81,21 @@ public static unsafe class D2D1ResourceTextureManager
}
/// <summary>
///
/// Initializes a given <c>ID2D1ResourceTextureManager</c> instance.
/// </summary>
/// <param name="resourceTextureManager"></param>
/// <param name="resourceId"></param>
/// <param name="extents"></param>
/// <param name="bufferPrecision"></param>
/// <param name="channelDepth"></param>
/// <param name="filter"></param>
/// <param name="extendModes"></param>
/// <param name="data"></param>
/// <param name="strides"></param>
/// <param name="resourceTextureManager">A pointer to the <c>ID2D1ResourceTextureManager</c> instance to use.</param>
/// <param name="resourceId">The resource id for the resource to create.</param>
/// <param name="extents">The extents of the resource to create.</param>
/// <param name="bufferPrecision">The buffer precision for the resource to create.</param>
/// <param name="channelDepth">The channel depth for the resource to create.</param>
/// <param name="filter">The filter for the resource to create.</param>
/// <param name="extendModes">The extend modes for the resource to create.</param>
/// <param name="data">The data to load in the resource to create.</param>
/// <param name="strides">The strides for the data supplied for the resource to create.</param>
/// <remarks>
/// Depending on internal state, <paramref name="resourceTextureManager"/> might immediately create the resource
/// texture, or it might buffer the data internally and then create the resource texture at a later time.
/// </remarks>
public static void Initialize(
void* resourceTextureManager,
Guid resourceId,
@@ -118,25 +122,25 @@ public static unsafe class D2D1ResourceTextureManager
d2D1ResourceTextureProperties.filter = (D2D1_FILTER)filter;
d2D1ResourceTextureProperties.extendModes = (D2D1_EXTEND_MODE*)pExtendModes;
_ = ((delegate* unmanaged[Stdcall]<void*, Guid*, D2D1_RESOURCE_TEXTURE_PROPERTIES*, byte*, uint*, uint, int>)(*(void***)resourceTextureManager)[3])(
resourceTextureManager,
&resourceId,
&d2D1ResourceTextureProperties,
pData,
pStrides,
(uint)data.Length);
// TODO: validate
_ = ((ID2D1ResourceTextureManager*)resourceTextureManager)->Initialize(
resourceId: &resourceId,
resourceTextureProperties: &d2D1ResourceTextureProperties,
data: pData,
strides: pStrides,
dataSize: (uint)data.Length);
}
}
/// <summary>
///
/// Updates the data in a given <c>ID2D1ResourceTextureManager</c> instance.
/// </summary>
/// <param name="resourceTextureManager"></param>
/// <param name="minimumExtents"></param>
/// <param name="maximumExtents"></param>
/// <param name="strides"></param>
/// <param name="dimensions"></param>
/// <param name="data"></param>
/// <param name="resourceTextureManager">A pointer to the <c>ID2D1ResourceTextureManager</c> instance to use.</param>
/// <param name="minimumExtents">The "left" extent of the updates if specified (if empty, the entire texture is updated).</param>
/// <param name="maximumExtents">The "right" extent of the updates if specified (if empty, the entire texture is updated).</param>
/// <param name="strides">The stride to advance through the input data, according to dimension.</param>
/// <param name="dimensions">The number of dimensions in the resource texture. This must match the number used to load the texture.</param>
/// <param name="data">The data to be placed into the resource texture.</param>
public static void Update(
void* resourceTextureManager,
ReadOnlySpan<uint> minimumExtents,
@@ -152,14 +156,14 @@ public static unsafe class D2D1ResourceTextureManager
fixed (uint* pStrides = strides)
fixed (byte* pData = data)
{
_ = ((delegate* unmanaged[Stdcall]<void*, uint*, uint*, uint*, uint, byte*, uint, int>)(*(void***)resourceTextureManager)[4])(
resourceTextureManager,
pMinimumExtents,
pMaximumExtents,
pStrides,
dimensions,
pData,
(uint)data.Length);
// TODO: validate
_ = ((ID2D1ResourceTextureManager*)resourceTextureManager)->Update(
minimumExtents: pMinimumExtents,
maximumExtents: pMaximumExtents,
strides: pStrides,
dimensions: dimensions,
data: pData,
dataCount: (uint)data.Length);
}
}
}
@@ -4,6 +4,8 @@ using System.Runtime.InteropServices;
using TerraFX.Interop.DirectX;
using TerraFX.Interop.Windows;
#pragma warning disable CS0649
namespace ComputeSharp.D2D1.Shaders.Interop.Effects.ResourceManagers;
/// <summary>
@@ -4,6 +4,8 @@ using System.Runtime.InteropServices;
using TerraFX.Interop.DirectX;
using TerraFX.Interop.Windows;
#pragma warning disable CS0649
namespace ComputeSharp.D2D1.Shaders.Interop.Effects.ResourceManagers;
/// <summary>
@@ -14,7 +16,7 @@ internal unsafe struct ID2D1ResourceTextureManagerInternal
/// <summary>
/// Gets the <see cref="System.Guid"/> for <c>ID2D1ResourceTextureManagerInternal</c> (<c>5CBB1024-8EA1-4689-81BF-8AD190B5EF5D</c>).
/// </summary>
private static ref readonly Guid Guid
public static ref readonly Guid Guid
{
get
{
@@ -85,17 +85,7 @@ partial struct ResourceTextureManager
return @this->Release();
}
/// <summary>
/// Creates or finds the given resource texture, depending on whether a resource id is specified.
/// It also optionally initializes the texture with the specified data.
/// </summary>
/// <param name="this">The current <c>ID2D1ResourceTextureManager</c> instance.</param>
/// <param name="resourceId">An optional pointer to the unique id that identifies the resource texture.</param>
/// <param name="resourceTextureProperties">The properties used to create the resource texture.</param>
/// <param name="data">The optional data to be loaded into the resource texture.</param>
/// <param name="strides">An optional pointer to the stride to advance through the resource texture, according to dimension.</param>
/// <param name="dataSize">The size, in bytes, of the data.</param>
/// <returns>An <see cref="HRESULT"/> for the operation.</returns>
/// <inheritdoc cref="ID2D1ResourceTextureManager.Initialize"/>
[UnmanagedCallersOnly]
public static int Initialize(
ResourceTextureManager* @this,
@@ -175,17 +165,7 @@ partial struct ResourceTextureManager
return 0;
}
/// <summary>
/// Updates the specific resource texture inside the specific range or box using the supplied data.
/// </summary>
/// <param name="this">The current <c>ID2D1ResourceTextureManager</c> instance.</param>
/// <param name="minimumExtents">The "left" extent of the updates if specified. If <see langword="null"/>, the entire texture is updated.</param>
/// <param name="maximumExtents">The "right" extent of the updates if specified. If <see langword="null"/>, the entire texture is updated.</param>
/// <param name="strides">The stride to advance through the input data, according to dimension.</param>
/// <param name="dimensions">The number of dimensions in the resource texture. This must match the number used to load the texture.</param>
/// <param name="data">The data to be placed into the resource texture.</param>
/// <param name="dataCount">The size of the data buffer to be used to update the resource texture.</param>
/// <returns>An <see cref="HRESULT"/> for the operation.</returns>
/// <inheritdoc cref="ID2D1ResourceTextureManager.Update"/>
[UnmanagedCallersOnly]
public static int Update(
ResourceTextureManager* @this,
@@ -78,12 +78,7 @@ partial struct ResourceTextureManager
return @this->Release();
}
/// <summary>
/// Sets the <see cref="ID2D1EffectContext"/> for the current <c>ID2D1ResourceTextureManagerInternal</c> instance.
/// </summary>
/// <param name="this">The current <c>ID2D1ResourceTextureManagerInternal</c> instance.</param>
/// <param name="effectContext">The input <see cref="ID2D1EffectContext"/> for the manager.</param>
/// <returns>An <see cref="HRESULT"/> for the operation.</returns>
/// <inheritdoc cref="ID2D1ResourceTextureManagerInternal.SetEffectContext"/>
[UnmanagedCallersOnly]
public static int SetEffectContext(ResourceTextureManager* @this, ID2D1EffectContext* effectContext)
{
@@ -110,12 +105,7 @@ partial struct ResourceTextureManager
return S.S_FALSE;
}
/// <summary>
/// Gets the <see cref="ID2D1ResourceTexture"/> instance held by the manager.
/// </summary>
/// <param name="this">The current <c>ID2D1ResourceTextureManagerInternal</c> instance.</param>
/// <param name="resourceTexture">The resulting <see cref="ID2D1ResourceTexture"/> instance.</param>
/// <returns>An <see cref="HRESULT"/> for the operation.</returns>
/// <inheritdoc cref="ID2D1ResourceTextureManagerInternal.GetResourceTexture"/>
[UnmanagedCallersOnly]
public static int GetResourceTexture(ResourceTextureManager* @this, ID2D1ResourceTexture** resourceTexture)
{
+2 -49
ファイルの表示
@@ -17,53 +17,6 @@ namespace ComputeSharp.D2D1.Shaders.Interop.Effects.ResourceManagers;
/// </summary>
internal unsafe partial struct ResourceTextureManager
{
/// <summary>
/// Gets the <see cref="Guid"/> for <c>ID2D1ResourceTextureManager</c> (<c>3C4FC7E4-A419-46CA-B5F6-66EB4FF18D64</c>).
/// </summary>
private static ref readonly Guid IID_ID2D1ResourceTextureManager
{
get
{
ReadOnlySpan<byte> data = new byte[] {
0x3C, 0x4F, 0xC7, 0xE4, 0xA4,
0x19, 0x46,
0xCA, 0xB5,
0xF6, 0x66,
0xEB,
0x4F,
0xF1,
0x8D,
0x64
};
return ref Unsafe.As<byte, Guid>(ref MemoryMarshal.GetReference(data));
}
}
/// <summary>
/// Gets the <see cref="Guid"/> for <c>ID2D1ResourceTextureManagerInternal</c> (<c>5CBB1024-8EA1-4689-81BF-8AD190B5EF5D</c>).
/// </summary>
private static ref readonly Guid IID_ID2D1ResourceTextureManagerInternal
{
get
{
ReadOnlySpan<byte> data = new byte[] {
0x5C, 0xBB, 0x10, 0x24,
0x8E, 0xA1,
0x46, 0x89,
0x81, 0xBF,
0x8A,
0xD1,
0x90,
0xB5,
0xEF,
0x5D
};
return ref Unsafe.As<byte, Guid>(ref MemoryMarshal.GetReference(data));
}
}
/// <inheritdoc cref="QueryInterface"/>
[UnmanagedFunctionPointer(CallingConvention.StdCall)]
private delegate int QueryInterfaceDelegate(ResourceTextureManager* @this, Guid* riid, void** ppvObject);
@@ -231,7 +184,7 @@ internal unsafe partial struct ResourceTextureManager
// ID2D1ResourceTextureManager
if (riid->Equals(Windows.__uuidof<IUnknown>()) ||
riid->Equals(IID_ID2D1ResourceTextureManager))
riid->Equals(ID2D1ResourceTextureManager.Guid))
{
_ = Interlocked.Increment(ref this.referenceCount);
@@ -241,7 +194,7 @@ internal unsafe partial struct ResourceTextureManager
}
// ID2D1ResourceTextureManagerInternal
if (riid->Equals(IID_ID2D1ResourceTextureManagerInternal))
if (riid->Equals(ID2D1ResourceTextureManagerInternal.Guid))
{
_ = Interlocked.Increment(ref this.referenceCount);