From 05a0145887db8a72e28d4a397c251512c3eb1f94 Mon Sep 17 00:00:00 2001 From: Sergio Pedri Date: Fri, 4 Feb 2022 01:18:41 +0100 Subject: [PATCH] Add missing [UnmanagedFunctionPointer] delegate attributes --- .../Interop/IWICStreamExtensions.IBufferWriter.cs | 14 ++++++++++++++ .../Interop/IWICStreamExtensions.Stream.cs | 14 ++++++++++++++ .../Graphics/GraphicsDevice.Execute.cs | 1 + .../Graphics/Helpers/DeviceHelper.IDXGIFactory6.cs | 3 +++ 4 files changed, 32 insertions(+) diff --git a/src/ComputeSharp/Graphics/Extensions/Interop/IWICStreamExtensions.IBufferWriter.cs b/src/ComputeSharp/Graphics/Extensions/Interop/IWICStreamExtensions.IBufferWriter.cs index 71945a6c..ee8772d1 100644 --- a/src/ComputeSharp/Graphics/Extensions/Interop/IWICStreamExtensions.IBufferWriter.cs +++ b/src/ComputeSharp/Graphics/Extensions/Interop/IWICStreamExtensions.IBufferWriter.cs @@ -48,45 +48,59 @@ internal static unsafe partial class IWICStreamExtensions { #if !NET6_0_OR_GREATER /// + [UnmanagedFunctionPointer(CallingConvention.StdCall)] private delegate int QueryInterfaceDelegate(IBufferWriterWrapper* @this, Guid* riid, void** ppvObject); /// + [UnmanagedFunctionPointer(CallingConvention.StdCall)] private delegate uint AddRefDelegate(IBufferWriterWrapper* @this); /// + [UnmanagedFunctionPointer(CallingConvention.StdCall)] private delegate uint ReleaseDelegate(IBufferWriterWrapper* @this); /// + [UnmanagedFunctionPointer(CallingConvention.StdCall)] private delegate HRESULT ReadDelegate(IBufferWriterWrapper* @this, void* pv, uint cb, uint* pcbRead); /// + [UnmanagedFunctionPointer(CallingConvention.StdCall)] private delegate HRESULT WriteDelegate(IBufferWriterWrapper* @this, void* pv, uint cb, uint* pcbWritten); /// + [UnmanagedFunctionPointer(CallingConvention.StdCall)] private delegate HRESULT SeekDelegate(IBufferWriterWrapper* @this, LARGE_INTEGER dlibMove, uint dwOrigin, ULARGE_INTEGER* plibNewPosition); /// + [UnmanagedFunctionPointer(CallingConvention.StdCall)] private delegate HRESULT SetSizeDelegate(IBufferWriterWrapper* @this, ULARGE_INTEGER libNewSize); /// + [UnmanagedFunctionPointer(CallingConvention.StdCall)] private delegate HRESULT CopyToDelegate(IBufferWriterWrapper* @this, IStream* pstm, ULARGE_INTEGER cb, ULARGE_INTEGER* pcbRead, ULARGE_INTEGER* pcbWritten); /// + [UnmanagedFunctionPointer(CallingConvention.StdCall)] private delegate HRESULT CommitDelegate(IBufferWriterWrapper* @this, uint grfCommitFlags); /// + [UnmanagedFunctionPointer(CallingConvention.StdCall)] private delegate HRESULT RevertDelegate(IBufferWriterWrapper* @this); /// + [UnmanagedFunctionPointer(CallingConvention.StdCall)] private delegate HRESULT LockRegionDelegate(IBufferWriterWrapper* @this, ULARGE_INTEGER libOffset, ULARGE_INTEGER cb, uint dwLockType); /// + [UnmanagedFunctionPointer(CallingConvention.StdCall)] private delegate HRESULT UnlockRegionDelegate(IBufferWriterWrapper* @this, ULARGE_INTEGER libOffset, ULARGE_INTEGER cb, uint dwLockType); /// + [UnmanagedFunctionPointer(CallingConvention.StdCall)] private delegate HRESULT StatDelegate(IBufferWriterWrapper* @this, STATSTG* pstatstg, uint grfStatFlag); /// + [UnmanagedFunctionPointer(CallingConvention.StdCall)] private delegate HRESULT CloneDelegate(IBufferWriterWrapper* @this, IStream** ppstm); /// diff --git a/src/ComputeSharp/Graphics/Extensions/Interop/IWICStreamExtensions.Stream.cs b/src/ComputeSharp/Graphics/Extensions/Interop/IWICStreamExtensions.Stream.cs index 36a07e75..dc664ea7 100644 --- a/src/ComputeSharp/Graphics/Extensions/Interop/IWICStreamExtensions.Stream.cs +++ b/src/ComputeSharp/Graphics/Extensions/Interop/IWICStreamExtensions.Stream.cs @@ -51,45 +51,59 @@ internal static unsafe partial class IWICStreamExtensions { #if !NET6_0_OR_GREATER /// + [UnmanagedFunctionPointer(CallingConvention.StdCall)] private delegate int QueryInterfaceDelegate(IStreamWrapper* @this, Guid* riid, void** ppvObject); /// + [UnmanagedFunctionPointer(CallingConvention.StdCall)] private delegate uint AddRefDelegate(IStreamWrapper* @this); /// + [UnmanagedFunctionPointer(CallingConvention.StdCall)] private delegate uint ReleaseDelegate(IStreamWrapper* @this); /// + [UnmanagedFunctionPointer(CallingConvention.StdCall)] private delegate HRESULT ReadDelegate(IStreamWrapper* @this, void* pv, uint cb, uint* pcbRead); /// + [UnmanagedFunctionPointer(CallingConvention.StdCall)] private delegate HRESULT WriteDelegate(IStreamWrapper* @this, void* pv, uint cb, uint* pcbWritten); /// + [UnmanagedFunctionPointer(CallingConvention.StdCall)] private delegate HRESULT SeekDelegate(IStreamWrapper* @this, LARGE_INTEGER dlibMove, uint dwOrigin, ULARGE_INTEGER* plibNewPosition); /// + [UnmanagedFunctionPointer(CallingConvention.StdCall)] private delegate HRESULT SetSizeDelegate(IStreamWrapper* @this, ULARGE_INTEGER libNewSize); /// + [UnmanagedFunctionPointer(CallingConvention.StdCall)] private delegate HRESULT CopyToDelegate(IStreamWrapper* @this, IStream* pstm, ULARGE_INTEGER cb, ULARGE_INTEGER* pcbRead, ULARGE_INTEGER* pcbWritten); /// + [UnmanagedFunctionPointer(CallingConvention.StdCall)] private delegate HRESULT CommitDelegate(IStreamWrapper* @this, uint grfCommitFlags); /// + [UnmanagedFunctionPointer(CallingConvention.StdCall)] private delegate HRESULT RevertDelegate(IStreamWrapper* @this); /// + [UnmanagedFunctionPointer(CallingConvention.StdCall)] private delegate HRESULT LockRegionDelegate(IStreamWrapper* @this, ULARGE_INTEGER libOffset, ULARGE_INTEGER cb, uint dwLockType); /// + [UnmanagedFunctionPointer(CallingConvention.StdCall)] private delegate HRESULT UnlockRegionDelegate(IStreamWrapper* @this, ULARGE_INTEGER libOffset, ULARGE_INTEGER cb, uint dwLockType); /// + [UnmanagedFunctionPointer(CallingConvention.StdCall)] private delegate HRESULT StatDelegate(IStreamWrapper* @this, STATSTG* pstatstg, uint grfStatFlag); /// + [UnmanagedFunctionPointer(CallingConvention.StdCall)] private delegate HRESULT CloneDelegate(IStreamWrapper* @this, IStream** ppstm); /// diff --git a/src/ComputeSharp/Graphics/GraphicsDevice.Execute.cs b/src/ComputeSharp/Graphics/GraphicsDevice.Execute.cs index 33c07124..6d2a3ac5 100644 --- a/src/ComputeSharp/Graphics/GraphicsDevice.Execute.cs +++ b/src/ComputeSharp/Graphics/GraphicsDevice.Execute.cs @@ -27,6 +27,7 @@ unsafe partial class GraphicsDevice /// /// The input context. /// Whether the wait has timed out. + [UnmanagedFunctionPointer(CallingConvention.StdCall)] private delegate void WaitForSingleObjectCallbackDelegate(void* pContext, byte timedOut); /// diff --git a/src/ComputeSharp/Graphics/Helpers/DeviceHelper.IDXGIFactory6.cs b/src/ComputeSharp/Graphics/Helpers/DeviceHelper.IDXGIFactory6.cs index ebeab8c7..ce5158bf 100644 --- a/src/ComputeSharp/Graphics/Helpers/DeviceHelper.IDXGIFactory6.cs +++ b/src/ComputeSharp/Graphics/Helpers/DeviceHelper.IDXGIFactory6.cs @@ -101,12 +101,15 @@ internal static partial class DeviceHelper { #if !NET6_0_OR_GREATER /// + [UnmanagedFunctionPointer(CallingConvention.StdCall)] private delegate uint ReleaseDelegate(IDXGIFactory4As6Backcompat* @this); /// + [UnmanagedFunctionPointer(CallingConvention.StdCall)] private delegate int EnumWarpAdapterDelegate(IDXGIFactory4As6Backcompat* @this, Guid* riid, void** ppvAdapter); /// + [UnmanagedFunctionPointer(CallingConvention.StdCall)] private delegate int EnumAdapterByGpuPreferenceDelegate(IDXGIFactory4As6Backcompat* @this, uint Adapter, DXGI_GPU_PREFERENCE GpuPreference, Guid* riid, void** ppvAdapter); ///