Add .NET Standard 2.0 support back
このコミットが含まれているのは:
1 親
61b51c706b
コミット
a8525592fd
6ファイル変更
+191
-10
検索条件に一致するファイルはありません
@@ -109,6 +109,7 @@ Global
|
||||
src\ComputeSharp.NetStandard\ComputeSharp.NetStandard.projitems*{314eb353-e7e3-4146-8111-685cc83ec1de}*SharedItemsImports = 5
|
||||
src\TerraFX.Interop.Windows\TerraFX.Interop.Windows.projitems*{314eb353-e7e3-4146-8111-685cc83ec1de}*SharedItemsImports = 5
|
||||
src\ComputeSharp.Core.NetStandard\ComputeSharp.Core.NetStandard.projitems*{3acacf03-6b20-40ba-b8ec-11ac1624d2c9}*SharedItemsImports = 13
|
||||
src\ComputeSharp.D2D1Interop.NetStandard\ComputeSharp.D2D1Interop.NetStandard.projitems*{4d7d9ba8-a821-4b1c-9ee2-cbcf5849906e}*SharedItemsImports = 5
|
||||
src\TerraFX.Interop.Windows.D2D1Interop\TerraFX.Interop.Windows.D2D1Interop.projitems*{4d7d9ba8-a821-4b1c-9ee2-cbcf5849906e}*SharedItemsImports = 5
|
||||
src\TerraFX.Interop.Windows\TerraFX.Interop.Windows.projitems*{514ff00e-bbf0-4d55-a47c-eeeb6208adce}*SharedItemsImports = 13
|
||||
src\ComputeSharp.SourceGeneration\ComputeSharp.SourceGeneration.projitems*{51d5a422-d3a5-4c4d-8a6d-a048940bf279}*SharedItemsImports = 13
|
||||
|
||||
@@ -1,9 +1,8 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
<PropertyGroup>
|
||||
<TargetFrameworks>net6.0</TargetFrameworks>
|
||||
<TargetFrameworks>netstandard2.0;net6.0</TargetFrameworks>
|
||||
<OutputPath>bin\Release</OutputPath>
|
||||
<DocumentationFile>ComputeSharp.D2D1Interop.xml</DocumentationFile>
|
||||
<Platforms>AnyCPU;x64;ARM64</Platforms>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<None Remove="Shaders\Translation\Headers\d2d1effecthelpers.hlsli" />
|
||||
|
||||
@@ -1,7 +1,10 @@
|
||||
using System;
|
||||
#if !NET6_0_OR_GREATER
|
||||
using System.Runtime.InteropServices;
|
||||
#endif
|
||||
using System.Text;
|
||||
using ComputeSharp.D2D1Interop.Extensions;
|
||||
using ComputeSharp.D2D1Interop.Tests.Helpers;
|
||||
using ComputeSharp.D2D1Interop.Interop.Effects;
|
||||
using TerraFX.Interop.DirectX;
|
||||
using TerraFX.Interop.Windows;
|
||||
|
||||
@@ -56,12 +59,20 @@ unsafe partial class D2D1InteropServices
|
||||
d2D1PropertyBinding.propertyName = (ushort*)pPropertyName;
|
||||
d2D1PropertyBinding.getFunction =
|
||||
(delegate* unmanaged[Stdcall]<IUnknown*, byte*, uint, uint*, HRESULT>)
|
||||
(delegate* unmanaged[Stdcall]<IUnknown*, byte*, uint, uint*, int>)
|
||||
#if NET6_0_OR_GREATER
|
||||
(delegate* unmanaged<IUnknown*, byte*, uint, uint*, int>)
|
||||
&PixelShaderEffect.GetConstantBuffer;
|
||||
#else
|
||||
(void*)Marshal.GetFunctionPointerForDelegate(PixelShaderEffect.GetConstantBufferWrapper);
|
||||
#endif
|
||||
d2D1PropertyBinding.setFunction =
|
||||
(delegate* unmanaged[Stdcall]<IUnknown*, byte*, uint, HRESULT>)
|
||||
(delegate* unmanaged[Stdcall]<IUnknown*, byte*, uint, int>)
|
||||
#if NET6_0_OR_GREATER
|
||||
(delegate* unmanaged<IUnknown*, byte*, uint, int>)
|
||||
&PixelShaderEffect.SetConstantBuffer;
|
||||
#else
|
||||
(void*)Marshal.GetFunctionPointerForDelegate(PixelShaderEffect.SetConstantBufferWrapper);
|
||||
#endif
|
||||
|
||||
Guid shaderId = typeof(T).GUID;
|
||||
|
||||
|
||||
+66
-1
@@ -2,8 +2,11 @@
|
||||
using System.Runtime.InteropServices;
|
||||
using TerraFX.Interop.DirectX;
|
||||
using TerraFX.Interop.Windows;
|
||||
#if !NET6_0_OR_GREATER
|
||||
using UnmanagedCallersOnlyAttribute = ComputeSharp.NetStandard.System.Runtime.InteropServices.UnmanagedCallersOnlyAttribute;
|
||||
#endif
|
||||
|
||||
namespace ComputeSharp.D2D1Interop.Tests.Helpers;
|
||||
namespace ComputeSharp.D2D1Interop.Interop.Effects;
|
||||
|
||||
/// <inheritdoc/>
|
||||
partial struct PixelShaderEffect
|
||||
@@ -13,6 +16,68 @@ partial struct PixelShaderEffect
|
||||
/// </summary>
|
||||
private unsafe static class ID2D1DrawTransformMethods
|
||||
{
|
||||
#if !NET6_0_OR_GREATER
|
||||
/// <inheritdoc cref="GetInputCount"/>
|
||||
[UnmanagedFunctionPointer(CallingConvention.StdCall)]
|
||||
public delegate uint GetInputCountDelegate(PixelShaderEffect* @this);
|
||||
|
||||
/// <inheritdoc cref="MapOutputRectToInputRects"/>
|
||||
[UnmanagedFunctionPointer(CallingConvention.StdCall)]
|
||||
public delegate int MapOutputRectToInputRectsDelegate(PixelShaderEffect* @this, RECT* outputRect, RECT* inputRects, uint inputRectsCount);
|
||||
|
||||
/// <inheritdoc cref="MapInputRectsToOutputRect"/>
|
||||
[UnmanagedFunctionPointer(CallingConvention.StdCall)]
|
||||
public delegate int MapInputRectsToOutputRectDelegate(PixelShaderEffect* @this, RECT* inputRects, RECT* inputOpaqueSubRects, uint inputRectCount, RECT* outputRect, RECT* outputOpaqueSubRect);
|
||||
|
||||
/// <inheritdoc cref="MapInvalidRect"/>
|
||||
[UnmanagedFunctionPointer(CallingConvention.StdCall)]
|
||||
public delegate int MapInvalidRectDelegate(PixelShaderEffect* @this, uint inputIndex, RECT invalidInputRect, RECT* invalidOutputRect);
|
||||
|
||||
/// <inheritdoc cref="SetDrawInfo"/>
|
||||
[UnmanagedFunctionPointer(CallingConvention.StdCall)]
|
||||
public delegate int SetDrawInfoDelegate(PixelShaderEffect* @this, ID2D1DrawInfo* drawInfo);
|
||||
|
||||
/// <summary>
|
||||
/// A cached <see cref="QueryInterfaceDelegate"/> instance wrapping <see cref="QueryInterface"/>.
|
||||
/// </summary>
|
||||
public static readonly QueryInterfaceDelegate QueryInterfaceWrapper = QueryInterface;
|
||||
|
||||
/// <summary>
|
||||
/// A cached <see cref="AddRefDelegate"/> instance wrapping <see cref="AddRef"/>.
|
||||
/// </summary>
|
||||
public static readonly AddRefDelegate AddRefWrapper = AddRef;
|
||||
|
||||
/// <summary>
|
||||
/// A cached <see cref="ReleaseDelegate"/> instance wrapping <see cref="Release"/>.
|
||||
/// </summary>
|
||||
public static readonly ReleaseDelegate ReleaseWrapper = Release;
|
||||
|
||||
/// <summary>
|
||||
/// A cached <see cref="GetInputCountDelegate"/> instance wrapping <see cref="GetInputCount"/>.
|
||||
/// </summary>
|
||||
public static readonly GetInputCountDelegate GetInputCountWrapper = GetInputCount;
|
||||
|
||||
/// <summary>
|
||||
/// A cached <see cref="MapOutputRectToInputRectsDelegate"/> instance wrapping <see cref="MapOutputRectToInputRects"/>.
|
||||
/// </summary>
|
||||
public static readonly MapOutputRectToInputRectsDelegate MapOutputRectToInputRectsWrapper = MapOutputRectToInputRects;
|
||||
|
||||
/// <summary>
|
||||
/// A cached <see cref="MapInputRectsToOutputRectDelegate"/> instance wrapping <see cref="MapInputRectsToOutputRect"/>.
|
||||
/// </summary>
|
||||
public static readonly MapInputRectsToOutputRectDelegate MapInputRectsToOutputRectWrapper = MapInputRectsToOutputRect;
|
||||
|
||||
/// <summary>
|
||||
/// A cached <see cref="MapInvalidRectDelegate"/> instance wrapping <see cref="MapInvalidRect"/>.
|
||||
/// </summary>
|
||||
public static readonly MapInvalidRectDelegate MapInvalidRectWrapper = MapInvalidRect;
|
||||
|
||||
/// <summary>
|
||||
/// A cached <see cref="SetDrawInfoDelegate"/> instance wrapping <see cref="SetDrawInfo"/>.
|
||||
/// </summary>
|
||||
public static readonly SetDrawInfoDelegate SetDrawInfoWrapper = SetDrawInfo;
|
||||
#endif
|
||||
|
||||
/// <inheritdoc cref="ID2D1DrawTransform.QueryInterface"/>
|
||||
[UnmanagedCallersOnly]
|
||||
public static int QueryInterface(PixelShaderEffect* @this, Guid* riid, void** ppvObject)
|
||||
|
||||
+48
-1
@@ -2,8 +2,11 @@
|
||||
using System.Runtime.InteropServices;
|
||||
using TerraFX.Interop.DirectX;
|
||||
using TerraFX.Interop.Windows;
|
||||
#if !NET6_0_OR_GREATER
|
||||
using UnmanagedCallersOnlyAttribute = ComputeSharp.NetStandard.System.Runtime.InteropServices.UnmanagedCallersOnlyAttribute;
|
||||
#endif
|
||||
|
||||
namespace ComputeSharp.D2D1Interop.Tests.Helpers;
|
||||
namespace ComputeSharp.D2D1Interop.Interop.Effects;
|
||||
|
||||
/// <summary>
|
||||
/// A simple <see cref="ID2D1EffectImpl"/> and <see cref="ID2D1DrawTransform"/> implementation for a given pixel shader.
|
||||
@@ -15,6 +18,50 @@ internal unsafe partial struct PixelShaderEffect
|
||||
/// </summary>
|
||||
private static class ID2D1EffectImplMethods
|
||||
{
|
||||
#if !NET6_0_OR_GREATER
|
||||
/// <inheritdoc cref="Initialize"/>
|
||||
[UnmanagedFunctionPointer(CallingConvention.StdCall)]
|
||||
public delegate int InitializeDelegate(PixelShaderEffect* @this, ID2D1EffectContext* effectContext, ID2D1TransformGraph* transformGraph);
|
||||
|
||||
/// <inheritdoc cref="PrepareForRender"/>
|
||||
[UnmanagedFunctionPointer(CallingConvention.StdCall)]
|
||||
public delegate int PrepareForRenderDelegate(PixelShaderEffect* @this, D2D1_CHANGE_TYPE changeType);
|
||||
|
||||
/// <inheritdoc cref="SetGraph"/>
|
||||
[UnmanagedFunctionPointer(CallingConvention.StdCall)]
|
||||
public delegate int SetGraphDelegate(PixelShaderEffect* @this, ID2D1TransformGraph* transformGraph);
|
||||
|
||||
/// <summary>
|
||||
/// A cached <see cref="QueryInterfaceDelegate"/> instance wrapping <see cref="QueryInterface"/>.
|
||||
/// </summary>
|
||||
public static readonly QueryInterfaceDelegate QueryInterfaceWrapper = QueryInterface;
|
||||
|
||||
/// <summary>
|
||||
/// A cached <see cref="AddRefDelegate"/> instance wrapping <see cref="AddRef"/>.
|
||||
/// </summary>
|
||||
public static readonly AddRefDelegate AddRefWrapper = AddRef;
|
||||
|
||||
/// <summary>
|
||||
/// A cached <see cref="ReleaseDelegate"/> instance wrapping <see cref="Release"/>.
|
||||
/// </summary>
|
||||
public static readonly ReleaseDelegate ReleaseWrapper = Release;
|
||||
|
||||
/// <summary>
|
||||
/// A cached <see cref="InitializeDelegate"/> instance wrapping <see cref="Initialize"/>.
|
||||
/// </summary>
|
||||
public static readonly InitializeDelegate InitializeWrapper = Initialize;
|
||||
|
||||
/// <summary>
|
||||
/// A cached <see cref="PrepareForRenderDelegate"/> instance wrapping <see cref="PrepareForRender"/>.
|
||||
/// </summary>
|
||||
public static readonly PrepareForRenderDelegate PrepareForRenderWrapper = PrepareForRender;
|
||||
|
||||
/// <summary>
|
||||
/// A cached <see cref="SetGraphDelegate"/> instance wrapping <see cref="SetGraph"/>.
|
||||
/// </summary>
|
||||
public static readonly SetGraphDelegate SetGraphWrapper = SetGraph;
|
||||
#endif
|
||||
|
||||
/// <inheritdoc cref="ID2D1EffectImpl.QueryInterface"/>
|
||||
[UnmanagedCallersOnly]
|
||||
public static int QueryInterface(PixelShaderEffect* @this, Guid* riid, void** ppvObject)
|
||||
|
||||
@@ -4,8 +4,14 @@ using System.Runtime.InteropServices;
|
||||
using System.Threading;
|
||||
using TerraFX.Interop.DirectX;
|
||||
using TerraFX.Interop.Windows;
|
||||
#if NET6_0_OR_GREATER
|
||||
using RuntimeHelpers = System.Runtime.CompilerServices.RuntimeHelpers;
|
||||
#else
|
||||
using RuntimeHelpers = ComputeSharp.D2D1Interop.NetStandard.System.Runtime.CompilerServices.RuntimeHelpers;
|
||||
using UnmanagedCallersOnlyAttribute = ComputeSharp.NetStandard.System.Runtime.InteropServices.UnmanagedCallersOnlyAttribute;
|
||||
#endif
|
||||
|
||||
namespace ComputeSharp.D2D1Interop.Tests.Helpers;
|
||||
namespace ComputeSharp.D2D1Interop.Interop.Effects;
|
||||
|
||||
/// <summary>
|
||||
/// A simple <see cref="ID2D1EffectImpl"/> and <see cref="ID2D1DrawTransform"/> implementation for a given pixel shader.
|
||||
@@ -20,6 +26,38 @@ internal unsafe partial struct PixelShaderEffect
|
||||
[UnmanagedFunctionPointer(CallingConvention.StdCall)]
|
||||
private delegate int FactoryDelegate(IUnknown** effectImpl);
|
||||
|
||||
#if !NET6_0_OR_GREATER
|
||||
/// <inheritdoc cref="QueryInterface"/>
|
||||
[UnmanagedFunctionPointer(CallingConvention.StdCall)]
|
||||
private delegate int QueryInterfaceDelegate(PixelShaderEffect* @this, Guid* riid, void** ppvObject);
|
||||
|
||||
/// <inheritdoc cref="AddRef"/>
|
||||
[UnmanagedFunctionPointer(CallingConvention.StdCall)]
|
||||
private delegate uint AddRefDelegate(PixelShaderEffect* @this);
|
||||
|
||||
/// <inheritdoc cref="Release"/>
|
||||
[UnmanagedFunctionPointer(CallingConvention.StdCall)]
|
||||
private delegate uint ReleaseDelegate(PixelShaderEffect* @this);
|
||||
|
||||
/// <inheritdoc cref="GetConstantBuffer"/>
|
||||
[UnmanagedFunctionPointer(CallingConvention.StdCall)]
|
||||
public delegate int GetConstantBufferDelegate(IUnknown* effect, byte* data, uint dataSize, uint* actualSize);
|
||||
|
||||
/// <inheritdoc cref="SetConstantBuffer"/>
|
||||
[UnmanagedFunctionPointer(CallingConvention.StdCall)]
|
||||
public delegate int SetConstantBufferDelegate(IUnknown* effect, byte* data, uint dataSize);
|
||||
|
||||
/// <summary>
|
||||
/// A cached <see cref="GetConstantBufferDelegate"/> instance wrapping <see cref="GetConstantBuffer"/>.
|
||||
/// </summary>
|
||||
public static readonly GetConstantBufferDelegate GetConstantBufferWrapper = GetConstantBuffer;
|
||||
|
||||
/// <summary>
|
||||
/// A cached <see cref="SetConstantBufferDelegate"/> instance wrapping <see cref="SetConstantBuffer"/>.
|
||||
/// </summary>
|
||||
public static readonly SetConstantBufferDelegate SetConstantBufferWrapper = SetConstantBuffer;
|
||||
#endif
|
||||
|
||||
/// <summary>
|
||||
/// A generic pixel shader implementation.
|
||||
/// </summary>
|
||||
@@ -108,14 +146,24 @@ internal unsafe partial struct PixelShaderEffect
|
||||
void** lpVtbl = (void**)RuntimeHelpers.AllocateTypeAssociatedMemory(typeof(PixelShaderEffect), sizeof(void*) * 14);
|
||||
|
||||
// ID2D1EffectImpl
|
||||
#if NET6_0_OR_GREATER
|
||||
lpVtbl[0] = (delegate* unmanaged<PixelShaderEffect*, Guid*, void**, int>)&ID2D1EffectImplMethods.QueryInterface;
|
||||
lpVtbl[1] = (delegate* unmanaged<PixelShaderEffect*, uint>)&ID2D1EffectImplMethods.AddRef;
|
||||
lpVtbl[2] = (delegate* unmanaged<PixelShaderEffect*, uint>)&ID2D1EffectImplMethods.Release;
|
||||
lpVtbl[3] = (delegate* unmanaged<PixelShaderEffect*, ID2D1EffectContext*, ID2D1TransformGraph*, int>)&ID2D1EffectImplMethods.Initialize;
|
||||
lpVtbl[4] = (delegate* unmanaged<PixelShaderEffect*, D2D1_CHANGE_TYPE, int>)&ID2D1EffectImplMethods.PrepareForRender;
|
||||
lpVtbl[5] = (delegate* unmanaged<PixelShaderEffect*, ID2D1TransformGraph*, int>)&ID2D1EffectImplMethods.SetGraph;
|
||||
#else
|
||||
lpVtbl[0] = (void*)Marshal.GetFunctionPointerForDelegate(ID2D1EffectImplMethods.QueryInterfaceWrapper);
|
||||
lpVtbl[1] = (void*)Marshal.GetFunctionPointerForDelegate(ID2D1EffectImplMethods.AddRefWrapper);
|
||||
lpVtbl[2] = (void*)Marshal.GetFunctionPointerForDelegate(ID2D1EffectImplMethods.ReleaseWrapper);
|
||||
lpVtbl[3] = (void*)Marshal.GetFunctionPointerForDelegate(ID2D1EffectImplMethods.InitializeWrapper);
|
||||
lpVtbl[4] = (void*)Marshal.GetFunctionPointerForDelegate(ID2D1EffectImplMethods.PrepareForRenderWrapper);
|
||||
lpVtbl[5] = (void*)Marshal.GetFunctionPointerForDelegate(ID2D1EffectImplMethods.SetGraphWrapper);
|
||||
#endif
|
||||
|
||||
// ID2D1DrawTransform
|
||||
#if NET6_0_OR_GREATER
|
||||
lpVtbl[6 + 0] = (delegate* unmanaged<PixelShaderEffect*, Guid*, void**, int>)&ID2D1DrawTransformMethods.QueryInterface;
|
||||
lpVtbl[6 + 1] = (delegate* unmanaged<PixelShaderEffect*, uint>)&ID2D1DrawTransformMethods.AddRef;
|
||||
lpVtbl[6 + 2] = (delegate* unmanaged<PixelShaderEffect*, uint>)&ID2D1DrawTransformMethods.Release;
|
||||
@@ -124,6 +172,16 @@ internal unsafe partial struct PixelShaderEffect
|
||||
lpVtbl[6 + 5] = (delegate* unmanaged<PixelShaderEffect*, RECT*, RECT*, uint, RECT*, RECT*, int>)&ID2D1DrawTransformMethods.MapInputRectsToOutputRect;
|
||||
lpVtbl[6 + 6] = (delegate* unmanaged<PixelShaderEffect*, uint, RECT, RECT*, int>)&ID2D1DrawTransformMethods.MapInvalidRect;
|
||||
lpVtbl[6 + 7] = (delegate* unmanaged<PixelShaderEffect*, ID2D1DrawInfo*, int>)&ID2D1DrawTransformMethods.SetDrawInfo;
|
||||
#else
|
||||
lpVtbl[6 + 0] = (void*)Marshal.GetFunctionPointerForDelegate(ID2D1DrawTransformMethods.QueryInterfaceWrapper);
|
||||
lpVtbl[6 + 1] = (void*)Marshal.GetFunctionPointerForDelegate(ID2D1DrawTransformMethods.AddRefWrapper);
|
||||
lpVtbl[6 + 2] = (void*)Marshal.GetFunctionPointerForDelegate(ID2D1DrawTransformMethods.ReleaseWrapper);
|
||||
lpVtbl[6 + 3] = (void*)Marshal.GetFunctionPointerForDelegate(ID2D1DrawTransformMethods.GetInputCountWrapper);
|
||||
lpVtbl[6 + 4] = (void*)Marshal.GetFunctionPointerForDelegate(ID2D1DrawTransformMethods.MapOutputRectToInputRectsWrapper);
|
||||
lpVtbl[6 + 5] = (void*)Marshal.GetFunctionPointerForDelegate(ID2D1DrawTransformMethods.MapInputRectsToOutputRectWrapper);
|
||||
lpVtbl[6 + 6] = (void*)Marshal.GetFunctionPointerForDelegate(ID2D1DrawTransformMethods.MapInvalidRectWrapper);
|
||||
lpVtbl[6 + 7] = (void*)Marshal.GetFunctionPointerForDelegate(ID2D1DrawTransformMethods.SetDrawInfoWrapper);
|
||||
#endif
|
||||
|
||||
VtblForID2D1EffectImpl = lpVtbl;
|
||||
VtblForID2D1DrawTransform = &lpVtbl[6];
|
||||
@@ -213,7 +271,7 @@ internal unsafe partial struct PixelShaderEffect
|
||||
}
|
||||
|
||||
/// <inheritdoc cref="D2D1_PROPERTY_BINDING.getFunction"/>
|
||||
[UnmanagedCallersOnly(CallConvs = new[] { typeof(CallConvStdcall) })]
|
||||
[UnmanagedCallersOnly]
|
||||
public static int GetConstantBuffer(IUnknown* effect, byte* data, uint dataSize, uint* actualSize)
|
||||
{
|
||||
PixelShaderEffect* @this = (PixelShaderEffect*)effect;
|
||||
@@ -235,7 +293,7 @@ internal unsafe partial struct PixelShaderEffect
|
||||
}
|
||||
|
||||
/// <inheritdoc cref="D2D1_PROPERTY_BINDING.getFunction"/>
|
||||
[UnmanagedCallersOnly(CallConvs = new[] { typeof(CallConvStdcall) })]
|
||||
[UnmanagedCallersOnly]
|
||||
public static int SetConstantBuffer(IUnknown* effect, byte* data, uint dataSize)
|
||||
{
|
||||
PixelShaderEffect* @this = (PixelShaderEffect*)effect;
|
||||
|
||||
新しいイシューから参照
ユーザーをブロックする