From 736610e741aa5cec814d7876dd5e5c47bc5a5585 Mon Sep 17 00:00:00 2001 From: Sergio Pedri Date: Sat, 20 Jan 2024 00:39:33 +0100 Subject: [PATCH 01/20] Make ICanvasImageInterop bindings AOT safe --- .../ICanvasImageInterop.cs | 207 ++++++++++-------- .../WIN2D_GET_D2D_IMAGE_FLAGS.cs | 2 +- .../WIN2D_GET_DEVICE_ASSOCIATION_TYPE.cs | 2 +- .../Buffers/SourceReference.cs | 2 +- .../CanvasEffect.Interop.cs | 9 +- src/ComputeSharp.D2D1.WinUI/CanvasEffect.cs | 3 +- ...ixelShaderEffect{T}.ICanvasImageInterop.cs | 7 +- .../PixelShaderEffect{T}.cs | 14 +- 8 files changed, 129 insertions(+), 117 deletions(-) diff --git a/src/ComputeSharp.D2D1.WinUI/ABI.Microsoft.Graphics.Canvas/ICanvasImageInterop.cs b/src/ComputeSharp.D2D1.WinUI/ABI.Microsoft.Graphics.Canvas/ICanvasImageInterop.cs index 8cefb7c3..c094f01d 100644 --- a/src/ComputeSharp.D2D1.WinUI/ABI.Microsoft.Graphics.Canvas/ICanvasImageInterop.cs +++ b/src/ComputeSharp.D2D1.WinUI/ABI.Microsoft.Graphics.Canvas/ICanvasImageInterop.cs @@ -7,113 +7,132 @@ using WinRT.Interop; #pragma warning disable CS0649, IDE0055, IDE1006 -namespace ABI.Microsoft.Graphics.Canvas; - -/// -/// An interop Win2D interface for all images and effects that can be drawn. -/// -[NativeTypeName("class ICanvasImageInterop : IUnknown")] -[NativeInheritance("IUnknown")] -internal unsafe struct ICanvasImageInterop : IComObject +namespace ABI.Microsoft.Graphics.Canvas { - /// - static Guid* IComObject.IID + /// + /// An interop Win2D interface for all images and effects that can be drawn. + /// + [NativeTypeName("class ICanvasImageInterop : IUnknown")] + [NativeInheritance("IUnknown")] + internal unsafe struct ICanvasImageInterop : IComObject { - [MethodImpl(MethodImplOptions.AggressiveInlining)] - get + /// + public static Guid* IID { - ReadOnlySpan data = - [ - 0xF7, 0xD1, 0x42, 0xE0, - 0xAD, 0xF9, - 0x79, 0x44, - 0xA7, 0x13, - 0x67, - 0x62, - 0x7E, - 0xA3, - 0x18, - 0x63 - ]; + [MethodImpl(MethodImplOptions.AggressiveInlining)] + get + { + ReadOnlySpan data = + [ + 0xF7, 0xD1, 0x42, 0xE0, + 0xAD, 0xF9, + 0x79, 0x44, + 0xA7, 0x13, + 0x67, + 0x62, + 0x7E, + 0xA3, + 0x18, + 0x63 + ]; - return (Guid*)Unsafe.AsPointer(ref MemoryMarshal.GetReference(data)); + return (Guid*)Unsafe.AsPointer(ref MemoryMarshal.GetReference(data)); + } + } + + public void** lpVtbl; + + /// + /// Gets the device that the effect is currently realized on, if any. + /// + /// The resulting device, if available (as a marshalled ). + /// The value describing the returned instance. + /// The for the operation. + [MethodImpl(MethodImplOptions.AggressiveInlining)] + [VtblIndex(3)] + public HRESULT GetDevice(ICanvasDevice** device, WIN2D_GET_DEVICE_ASSOCIATION_TYPE* type) + { + return ((delegate* unmanaged[MemberFunction])this.lpVtbl[3])((ICanvasImageInterop*)Unsafe.AsPointer(ref this), device, type); + } + + /// + /// Gets an from an instance. + /// + /// The input canvas device (as a marshalled ). + /// + /// The device context in use. This value is is optional (but recommended), except when the + /// flag is specified. This is because + /// not all callers of have easy access to a context. It is always + /// possible to get a resource creation context from the device, but the context is only + /// actually necessary if a new effect realization needs to be created, so it is more efficient + /// to have the implementation do this lookup only if/when it turns out to be needed. + /// + /// The flags to use to get the image. + /// + /// The DPI of the target device context. This is used to determine when a D2D1DpiCompensation + /// effect needs to be inserted. Behavior of this parameter can be overridden by the flag values + /// , + /// + /// or + /// + /// + /// The DPI of a source bitmap, or zero if the image does not have a fixed DPI. A D2D1DpiCompensation effect + /// will be inserted if and are different (flags permitting). + /// + /// The resulting for the effect. + /// The for the operation. + [MethodImpl(MethodImplOptions.AggressiveInlining)] + [VtblIndex(4)] + public HRESULT GetD2DImage( + ICanvasDevice* device, + ID2D1DeviceContext* deviceContext, + WIN2D_GET_D2D_IMAGE_FLAGS flags, + float targetDpi, + float* realizeDpi, + ID2D1Image** ppImage) + { + return ((delegate* unmanaged[MemberFunction])this.lpVtbl[4])( + (ICanvasImageInterop*)Unsafe.AsPointer(ref this), + device, + deviceContext, + flags, + targetDpi, + realizeDpi, + ppImage); } } - public void** lpVtbl; - /// - /// Gets the device that the effect is currently realized on, if any. + /// The ABI methods for . /// - /// The resulting device, if available (as a marshalled ). - /// The value describing the returned instance. - /// The for the operation. - [MethodImpl(MethodImplOptions.AggressiveInlining)] - [VtblIndex(3)] - public HRESULT GetDevice(ICanvasDevice** device, WIN2D_GET_DEVICE_ASSOCIATION_TYPE* type) + [Guid("E042D1F7-F9AD-4479-A713-67627EA31863")] + internal static unsafe class ICanvasImageInteropMethods { - return ((delegate* unmanaged[MemberFunction])this.lpVtbl[3])((ICanvasImageInterop*)Unsafe.AsPointer(ref this), device, type); + /// + public static Guid IID => *ICanvasImageInterop.IID; + + /// + public static IntPtr AbiToProjectionVftablePtr => global::Microsoft.Graphics.Canvas.ICanvasImageInterop.Vftbl.AbiToProjectionVftablePtr; } +} + +namespace Microsoft.Graphics.Canvas +{ + using ABI.Microsoft.Graphics.Canvas; /// - /// Gets an from an instance. - /// - /// The input canvas device (as a marshalled ). - /// - /// The device context in use. This value is is optional (but recommended), except when the - /// flag is specified. This is because - /// not all callers of have easy access to a context. It is always - /// possible to get a resource creation context from the device, but the context is only - /// actually necessary if a new effect realization needs to be created, so it is more efficient - /// to have the implementation do this lookup only if/when it turns out to be needed. - /// - /// The flags to use to get the image. - /// - /// The DPI of the target device context. This is used to determine when a D2D1DpiCompensation - /// effect needs to be inserted. Behavior of this parameter can be overridden by the flag values - /// , - /// - /// or - /// - /// - /// The DPI of a source bitmap, or zero if the image does not have a fixed DPI. A D2D1DpiCompensation effect - /// will be inserted if and are different (flags permitting). - /// - /// The resulting for the effect. - /// The for the operation. - [MethodImpl(MethodImplOptions.AggressiveInlining)] - [VtblIndex(4)] - public HRESULT GetD2DImage( - ICanvasDevice* device, - ID2D1DeviceContext* deviceContext, - WIN2D_GET_D2D_IMAGE_FLAGS flags, - float targetDpi, - float* realizeDpi, - ID2D1Image** ppImage) - { - return ((delegate* unmanaged[MemberFunction])this.lpVtbl[4])( - (ICanvasImageInterop*)Unsafe.AsPointer(ref this), - device, - deviceContext, - flags, - targetDpi, - realizeDpi, - ppImage); - } - - /// - /// The managed implementation of . + /// The managed implementation of . /// [Guid("E042D1F7-F9AD-4479-A713-67627EA31863")] [WindowsRuntimeType] - [WindowsRuntimeHelperType(typeof(Interface))] - public interface Interface + [WindowsRuntimeHelperType(typeof(ICanvasImageInterop))] + internal unsafe interface ICanvasImageInterop { - /// + /// [return: NativeTypeName("HRESULT")] int GetDevice(ICanvasDevice** device, WIN2D_GET_DEVICE_ASSOCIATION_TYPE* type); - /// + /// [return: NativeTypeName("HRESULT")] int GetD2DImage( ICanvasDevice* device, @@ -124,7 +143,7 @@ internal unsafe struct ICanvasImageInterop : IComObject ID2D1Image** ppImage); /// - /// The vtable type for . + /// The vtable type for . /// [Guid("E042D1F7-F9AD-4479-A713-67627EA31863")] public struct Vftbl @@ -135,9 +154,9 @@ internal unsafe struct ICanvasImageInterop : IComObject public static readonly IntPtr AbiToProjectionVftablePtr = InitVtbl(); /// - /// Builds the custom method table pointer for . + /// Builds the custom method table pointer for . /// - /// The method table pointer for . + /// The method table pointer for . private static IntPtr InitVtbl() { Vftbl* lpVtbl = (Vftbl*)ComWrappersSupport.AllocateVtableMemory(typeof(Vftbl), sizeof(Vftbl)); @@ -164,14 +183,14 @@ internal unsafe struct ICanvasImageInterop : IComObject /// private delegate* unmanaged[MemberFunction] GetD2DImage; - /// + /// [UnmanagedCallersOnly(CallConvs = [typeof(CallConvMemberFunction)])] [return: NativeTypeName("HRESULT")] private static int GetDeviceFromAbi(IntPtr thisPtr, ICanvasDevice** device, WIN2D_GET_DEVICE_ASSOCIATION_TYPE* type) { try { - return ComWrappersSupport.FindObject(thisPtr).GetDevice(device, type); + return ComWrappersSupport.FindObject(thisPtr).GetDevice(device, type); } catch (Exception e) { @@ -181,7 +200,7 @@ internal unsafe struct ICanvasImageInterop : IComObject } } - /// + /// [UnmanagedCallersOnly(CallConvs = [typeof(CallConvMemberFunction)])] [return: NativeTypeName("HRESULT")] private static int GetD2DImageFromAbi( @@ -195,7 +214,7 @@ internal unsafe struct ICanvasImageInterop : IComObject { try { - return ComWrappersSupport.FindObject(thisPtr).GetD2DImage(device, deviceContext, flags, targetDpi, realizeDpi, ppImage); + return ComWrappersSupport.FindObject(thisPtr).GetD2DImage(device, deviceContext, flags, targetDpi, realizeDpi, ppImage); } catch (Exception e) { diff --git a/src/ComputeSharp.D2D1.WinUI/ABI.Microsoft.Graphics.Canvas/WIN2D_GET_D2D_IMAGE_FLAGS.cs b/src/ComputeSharp.D2D1.WinUI/ABI.Microsoft.Graphics.Canvas/WIN2D_GET_D2D_IMAGE_FLAGS.cs index 063bd8a6..0180f17b 100644 --- a/src/ComputeSharp.D2D1.WinUI/ABI.Microsoft.Graphics.Canvas/WIN2D_GET_D2D_IMAGE_FLAGS.cs +++ b/src/ComputeSharp.D2D1.WinUI/ABI.Microsoft.Graphics.Canvas/WIN2D_GET_D2D_IMAGE_FLAGS.cs @@ -3,7 +3,7 @@ using System; namespace ABI.Microsoft.Graphics.Canvas; /// -/// Options for fine-tuning the behavior of . +/// Options for fine-tuning the behavior of . /// [Flags] internal enum WIN2D_GET_D2D_IMAGE_FLAGS : uint diff --git a/src/ComputeSharp.D2D1.WinUI/ABI.Microsoft.Graphics.Canvas/WIN2D_GET_DEVICE_ASSOCIATION_TYPE.cs b/src/ComputeSharp.D2D1.WinUI/ABI.Microsoft.Graphics.Canvas/WIN2D_GET_DEVICE_ASSOCIATION_TYPE.cs index 9ce3c2e4..32452df2 100644 --- a/src/ComputeSharp.D2D1.WinUI/ABI.Microsoft.Graphics.Canvas/WIN2D_GET_DEVICE_ASSOCIATION_TYPE.cs +++ b/src/ComputeSharp.D2D1.WinUI/ABI.Microsoft.Graphics.Canvas/WIN2D_GET_DEVICE_ASSOCIATION_TYPE.cs @@ -3,7 +3,7 @@ using System; namespace ABI.Microsoft.Graphics.Canvas; /// -/// Options for fine-tuning the behavior of . +/// Options for fine-tuning the behavior of . /// [Flags] internal enum WIN2D_GET_DEVICE_ASSOCIATION_TYPE : uint diff --git a/src/ComputeSharp.D2D1.WinUI/Buffers/SourceReference.cs b/src/ComputeSharp.D2D1.WinUI/Buffers/SourceReference.cs index 28642405..a20583ca 100644 --- a/src/ComputeSharp.D2D1.WinUI/Buffers/SourceReference.cs +++ b/src/ComputeSharp.D2D1.WinUI/Buffers/SourceReference.cs @@ -41,7 +41,7 @@ namespace ComputeSharp.D2D1.WinUI.Buffers; internal unsafe struct SourceReference : IDisposable { /// - /// The produced by calling + /// The produced by calling /// on the input managed wrapper used as source for the effect (ie. ). /// private ComPtr d2D1ImageSource; diff --git a/src/ComputeSharp.D2D1.WinUI/CanvasEffect.Interop.cs b/src/ComputeSharp.D2D1.WinUI/CanvasEffect.Interop.cs index 5f4d8b0d..a539d160 100644 --- a/src/ComputeSharp.D2D1.WinUI/CanvasEffect.Interop.cs +++ b/src/ComputeSharp.D2D1.WinUI/CanvasEffect.Interop.cs @@ -7,6 +7,7 @@ using ComputeSharp.D2D1.WinUI.Helpers; using ComputeSharp.Win32; using Microsoft.Graphics.Canvas; using Windows.Foundation; +using ICanvasImageInterop = Microsoft.Graphics.Canvas.ICanvasImageInterop; using ICanvasResourceCreator = Microsoft.Graphics.Canvas.ICanvasResourceCreator; namespace ComputeSharp.D2D1.WinUI; @@ -27,9 +28,9 @@ partial class CanvasEffect } /// - unsafe int ICanvasImageInterop.Interface.GetDevice(ICanvasDevice** device, WIN2D_GET_DEVICE_ASSOCIATION_TYPE* type) + unsafe int ICanvasImageInterop.GetDevice(ICanvasDevice** device, WIN2D_GET_DEVICE_ASSOCIATION_TYPE* type) { - using ComPtr canvasImageInterop = default; + using ComPtr canvasImageInterop = default; RcwMarshaller.GetNativeInterface(GetCanvasImage(), canvasImageInterop.GetAddressOf()).Assert(); @@ -37,7 +38,7 @@ partial class CanvasEffect } /// - unsafe int ICanvasImageInterop.Interface.GetD2DImage( + unsafe int ICanvasImageInterop.GetD2DImage( ICanvasDevice* device, ID2D1DeviceContext* deviceContext, WIN2D_GET_D2D_IMAGE_FLAGS flags, @@ -45,7 +46,7 @@ partial class CanvasEffect float* realizeDpi, ID2D1Image** ppImage) { - using ComPtr canvasImageInterop = default; + using ComPtr canvasImageInterop = default; RcwMarshaller.GetNativeInterface(GetCanvasImage(), canvasImageInterop.GetAddressOf()).Assert(); diff --git a/src/ComputeSharp.D2D1.WinUI/CanvasEffect.cs b/src/ComputeSharp.D2D1.WinUI/CanvasEffect.cs index 4247f5d2..f9bd17c4 100644 --- a/src/ComputeSharp.D2D1.WinUI/CanvasEffect.cs +++ b/src/ComputeSharp.D2D1.WinUI/CanvasEffect.cs @@ -1,7 +1,6 @@ using System; using System.Collections.Generic; using System.Diagnostics.CodeAnalysis; -using ABI.Microsoft.Graphics.Canvas; using Microsoft.Graphics.Canvas; namespace ComputeSharp.D2D1.WinUI; @@ -9,7 +8,7 @@ namespace ComputeSharp.D2D1.WinUI; /// /// A base type to implement packaged and easy to use -based effects that can be used with Win2D. /// -public abstract partial class CanvasEffect : ICanvasImage, ICanvasImageInterop.Interface +public abstract partial class CanvasEffect : ICanvasImage, ICanvasImageInterop { /// /// The mapping of registered transform nodes for the current effect graph. diff --git a/src/ComputeSharp.D2D1.WinUI/PixelShaderEffect{T}.ICanvasImageInterop.cs b/src/ComputeSharp.D2D1.WinUI/PixelShaderEffect{T}.ICanvasImageInterop.cs index 0d729c98..0ac9a12c 100644 --- a/src/ComputeSharp.D2D1.WinUI/PixelShaderEffect{T}.ICanvasImageInterop.cs +++ b/src/ComputeSharp.D2D1.WinUI/PixelShaderEffect{T}.ICanvasImageInterop.cs @@ -11,6 +11,7 @@ using ComputeSharp.Win32; using Windows.Graphics.Effects; using static ABI.Microsoft.Graphics.Canvas.WIN2D_GET_D2D_IMAGE_FLAGS; using static ABI.Microsoft.Graphics.Canvas.WIN2D_GET_DEVICE_ASSOCIATION_TYPE; +using ICanvasImageInterop = Microsoft.Graphics.Canvas.ICanvasImageInterop; namespace ComputeSharp.D2D1.WinUI; @@ -18,7 +19,7 @@ namespace ComputeSharp.D2D1.WinUI; unsafe partial class PixelShaderEffect { /// - int ICanvasImageInterop.Interface.GetDevice(ICanvasDevice** device, WIN2D_GET_DEVICE_ASSOCIATION_TYPE* type) + int ICanvasImageInterop.GetDevice(ICanvasDevice** device, WIN2D_GET_DEVICE_ASSOCIATION_TYPE* type) { // Validate all input parameters if (device is null || type is null) @@ -71,7 +72,7 @@ unsafe partial class PixelShaderEffect } /// - int ICanvasImageInterop.Interface.GetD2DImage( + int ICanvasImageInterop.GetD2DImage( ICanvasDevice* device, ID2D1DeviceContext* deviceContext, WIN2D_GET_D2D_IMAGE_FLAGS flags, @@ -361,7 +362,7 @@ unsafe partial class PixelShaderEffect } else { - using ComPtr canvasImageInterop = default; + using ComPtr canvasImageInterop = default; // Convert to ICanvasImageInterop (this must always succeed, and throws if it doesn't) RcwMarshaller.GetNativeInterface(source, canvasImageInterop.GetAddressOf()).Assert(); diff --git a/src/ComputeSharp.D2D1.WinUI/PixelShaderEffect{T}.cs b/src/ComputeSharp.D2D1.WinUI/PixelShaderEffect{T}.cs index 65e2ddc5..cae06b13 100644 --- a/src/ComputeSharp.D2D1.WinUI/PixelShaderEffect{T}.cs +++ b/src/ComputeSharp.D2D1.WinUI/PixelShaderEffect{T}.cs @@ -1,4 +1,3 @@ -using System.Diagnostics.CodeAnalysis; using ABI.Microsoft.Graphics.Canvas; using ComputeSharp.D2D1.Descriptors; using ComputeSharp.D2D1.Interop; @@ -6,6 +5,7 @@ using ComputeSharp.Interop; using ComputeSharp.Win32; using Microsoft.Graphics.Canvas; using Microsoft.Graphics.Canvas.Effects; +using ICanvasImageInterop = Microsoft.Graphics.Canvas.ICanvasImageInterop; namespace ComputeSharp.D2D1.WinUI; @@ -13,7 +13,7 @@ namespace ComputeSharp.D2D1.WinUI; /// A custom implementation powered by a supplied shader type. /// /// The type of shader to use to render frames. -public sealed partial class PixelShaderEffect : IReferenceTrackedObject, ICanvasEffect, ICanvasImageInterop.Interface +public sealed partial class PixelShaderEffect : IReferenceTrackedObject, ICanvasEffect, ICanvasImageInterop where T : unmanaged, ID2D1PixelShader, ID2D1PixelShaderDescriptor { /// @@ -27,7 +27,7 @@ public sealed partial class PixelShaderEffect : IReferenceTrackedObject, ICan private readonly object lockObject = new(); /// - /// Flag to track whether a given call is recursively invoked by , to avoid graph cycles. + /// Flag to track whether a given call is recursively invoked by , to avoid graph cycles. /// private volatile int isInsideGetD2DImage; @@ -69,14 +69,6 @@ public sealed partial class PixelShaderEffect : IReferenceTrackedObject, ICan /// /// Creates a new instance. /// - // Workaround for trimming bug in custom COM/WinRT components with CsWinRT. Without manually preserving metadata for - // these types, using them will throw an InvalidCastException (see https://github.com/microsoft/CsWinRT/issues/1319). - [DynamicDependency(DynamicallyAccessedMemberTypes.All, typeof(ICanvasImageInterop.Interface))] - [DynamicDependency(DynamicallyAccessedMemberTypes.All, typeof(ICanvasImageInterop.Interface.Vftbl))] - [DynamicDependency(DynamicallyAccessedMemberTypes.All, typeof(ICanvasFactoryNative.Interface))] - [DynamicDependency(DynamicallyAccessedMemberTypes.All, typeof(ICanvasFactoryNative.Interface.Vftbl))] - [DynamicDependency(DynamicallyAccessedMemberTypes.All, typeof(ICanvasEffectFactoryNative.Interface))] - [DynamicDependency(DynamicallyAccessedMemberTypes.All, typeof(ICanvasEffectFactoryNative.Interface.Vftbl))] public PixelShaderEffect() { using ReferenceTracker.Lease _0 = ReferenceTracker.Create(this, out this.referenceTracker); From f1fc6a84101a990185acd519742562c900d6b8f0 Mon Sep 17 00:00:00 2001 From: Sergio Pedri Date: Sat, 20 Jan 2024 13:55:11 +0100 Subject: [PATCH 02/20] Make ICanvasEffectFactoryNative bindings AOT safe --- .../ICanvasEffectFactoryNative.cs | 183 ++++++++++-------- .../Helpers/ResourceManager.cs | 5 +- ...derEffect{T}.ICanvasEffectFactoryNative.cs | 5 +- 3 files changed, 107 insertions(+), 86 deletions(-) diff --git a/src/ComputeSharp.D2D1.WinUI/ABI.Microsoft.Graphics.Canvas/ICanvasEffectFactoryNative.cs b/src/ComputeSharp.D2D1.WinUI/ABI.Microsoft.Graphics.Canvas/ICanvasEffectFactoryNative.cs index 8f28b281..28d04e3f 100644 --- a/src/ComputeSharp.D2D1.WinUI/ABI.Microsoft.Graphics.Canvas/ICanvasEffectFactoryNative.cs +++ b/src/ComputeSharp.D2D1.WinUI/ABI.Microsoft.Graphics.Canvas/ICanvasEffectFactoryNative.cs @@ -8,105 +8,124 @@ using IInspectable = ComputeSharp.Win32.IInspectable; #pragma warning disable CS0649, IDE0055, IDE1006 -namespace ABI.Microsoft.Graphics.Canvas; - -/// -/// The interop Win2D interface for factories of external effects. -/// -[NativeTypeName("class ICanvasEffectFactoryNative : IUnknown")] -[NativeInheritance("IUnknown")] -internal unsafe struct ICanvasEffectFactoryNative : IComObject +namespace ABI.Microsoft.Graphics.Canvas { - /// - static Guid* IComObject.IID + /// + /// The interop Win2D interface for factories of external effects. + /// + [NativeTypeName("class ICanvasEffectFactoryNative : IUnknown")] + [NativeInheritance("IUnknown")] + internal unsafe struct ICanvasEffectFactoryNative : IComObject { - [MethodImpl(MethodImplOptions.AggressiveInlining)] - get + /// + public static Guid* IID { - ReadOnlySpan data = - [ - 0x1F, 0x1A, 0xBA, 0x29, - 0xFE, 0x1C, - 0xC3, 0x44, - 0x98, 0x4D, - 0x42, - 0x6D, - 0x61, - 0xB5, - 0x14, - 0x27 - ]; + [MethodImpl(MethodImplOptions.AggressiveInlining)] + get + { + ReadOnlySpan data = + [ + 0x1F, 0x1A, 0xBA, 0x29, + 0xFE, 0x1C, + 0xC3, 0x44, + 0x98, 0x4D, + 0x42, + 0x6D, + 0x61, + 0xB5, + 0x14, + 0x27 + ]; - return (Guid*)Unsafe.AsPointer(ref MemoryMarshal.GetReference(data)); + return (Guid*)Unsafe.AsPointer(ref MemoryMarshal.GetReference(data)); + } + } + + public void** lpVtbl; + + /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] + [VtblIndex(0)] + public HRESULT QueryInterface([NativeTypeName("const IID &")] Guid* riid, void** ppvObject) + { + return ((delegate* unmanaged[MemberFunction])this.lpVtbl[0])((ICanvasEffectFactoryNative*)Unsafe.AsPointer(ref this), riid, ppvObject); + } + + /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] + [VtblIndex(1)] + [return: NativeTypeName("ULONG")] + public uint AddRef() + { + return ((delegate* unmanaged[MemberFunction])this.lpVtbl[1])((ICanvasEffectFactoryNative*)Unsafe.AsPointer(ref this)); + } + + /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] + [VtblIndex(2)] + [return: NativeTypeName("ULONG")] + public uint Release() + { + return ((delegate* unmanaged[MemberFunction])this.lpVtbl[2])((ICanvasEffectFactoryNative*)Unsafe.AsPointer(ref this)); + } + + /// + /// Creates a new inspectable wrapper for an input D2D effect previosly registered through . + /// + /// The input canvas device. + /// The input native effect to create a wrapper for. + /// The realization DPIs for . + /// The resulting wrapper for . + /// The for the operation. + /// + /// All parameters are directly forwarded from the ones the caller passed to . The returned + /// wrapper should implement to be returned correctly from Win2D after this call. + /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] + [VtblIndex(3)] + public HRESULT CreateWrapper(ICanvasDevice* device, ID2D1Effect* resource, float dpi, IInspectable** wrapper) + { + return ((delegate* unmanaged[MemberFunction])this.lpVtbl[3])( + (ICanvasEffectFactoryNative*)Unsafe.AsPointer(ref this), + device, + resource, + dpi, + wrapper); } } - public void** lpVtbl; - - /// - [MethodImpl(MethodImplOptions.AggressiveInlining)] - [VtblIndex(0)] - public HRESULT QueryInterface([NativeTypeName("const IID &")] Guid* riid, void** ppvObject) - { - return ((delegate* unmanaged[MemberFunction])this.lpVtbl[0])((ICanvasEffectFactoryNative*)Unsafe.AsPointer(ref this), riid, ppvObject); - } - - /// - [MethodImpl(MethodImplOptions.AggressiveInlining)] - [VtblIndex(1)] - [return: NativeTypeName("ULONG")] - public uint AddRef() - { - return ((delegate* unmanaged[MemberFunction])this.lpVtbl[1])((ICanvasEffectFactoryNative*)Unsafe.AsPointer(ref this)); - } - - /// - [MethodImpl(MethodImplOptions.AggressiveInlining)] - [VtblIndex(2)] - [return: NativeTypeName("ULONG")] - public uint Release() - { - return ((delegate* unmanaged[MemberFunction])this.lpVtbl[2])((ICanvasEffectFactoryNative*)Unsafe.AsPointer(ref this)); - } - /// - /// Creates a new inspectable wrapper for an input D2D effect previosly registered through . + /// The ABI methods for . /// - /// The input canvas device. - /// The input native effect to create a wrapper for. - /// The realization DPIs for . - /// The resulting wrapper for . - /// The for the operation. - /// - /// All parameters are directly forwarded from the ones the caller passed to . The returned - /// wrapper should implement to be returned correctly from Win2D after this call. - /// - [MethodImpl(MethodImplOptions.AggressiveInlining)] - [VtblIndex(3)] - public HRESULT CreateWrapper(ICanvasDevice* device, ID2D1Effect* resource, float dpi, IInspectable** wrapper) + [Guid("E042D1F7-F9AD-4479-A713-67627EA31863")] + internal static unsafe class ICanvasEffectFactoryNativeMethods { - return ((delegate* unmanaged[MemberFunction])this.lpVtbl[3])( - (ICanvasEffectFactoryNative*)Unsafe.AsPointer(ref this), - device, - resource, - dpi, - wrapper); + /// + public static Guid IID => *ICanvasEffectFactoryNative.IID; + + /// + public static IntPtr AbiToProjectionVftablePtr => global::Microsoft.Graphics.Canvas.ICanvasEffectFactoryNative.Vftbl.AbiToProjectionVftablePtr; } +} + +namespace Microsoft.Graphics.Canvas +{ + using ABI.Microsoft.Graphics.Canvas; /// - /// The managed implementation of . + /// The managed implementation of . /// [Guid("29BA1A1F-1CFE-44C3-984D-426D61B51427")] [WindowsRuntimeType] - [WindowsRuntimeHelperType(typeof(Interface))] - public interface Interface + [WindowsRuntimeHelperType(typeof(ICanvasEffectFactoryNative))] + internal unsafe interface ICanvasEffectFactoryNative { - /// + /// [return: NativeTypeName("HRESULT")] int CreateWrapper(ICanvasDevice* device, ID2D1Effect* resource, float dpi, IInspectable** wrapper); /// - /// The vtable type for . + /// The vtable type for . /// [Guid("29BA1A1F-1CFE-44C3-984D-426D61B51427")] public struct Vftbl @@ -117,9 +136,9 @@ internal unsafe struct ICanvasEffectFactoryNative : IComObject public static readonly IntPtr AbiToProjectionVftablePtr = InitVtbl(); /// - /// Builds the custom method table pointer for . + /// Builds the custom method table pointer for . /// - /// The method table pointer for . + /// The method table pointer for . private static IntPtr InitVtbl() { Vftbl* lpVtbl = (Vftbl*)ComWrappersSupport.AllocateVtableMemory(typeof(Vftbl), sizeof(Vftbl)); @@ -140,14 +159,14 @@ internal unsafe struct ICanvasEffectFactoryNative : IComObject /// private delegate* unmanaged[MemberFunction] CreateWrapper; - /// + /// [UnmanagedCallersOnly(CallConvs = [typeof(CallConvMemberFunction)])] [return: NativeTypeName("HRESULT")] private static int CreateWrapperFromAbi(IntPtr thisPtr, ICanvasDevice* device, ID2D1Effect* resource, float dpi, IInspectable** wrapper) { try { - return ComWrappersSupport.FindObject(thisPtr).CreateWrapper(device, resource, dpi, wrapper); + return ComWrappersSupport.FindObject(thisPtr).CreateWrapper(device, resource, dpi, wrapper); } catch (Exception e) { diff --git a/src/ComputeSharp.D2D1.WinUI/Helpers/ResourceManager.cs b/src/ComputeSharp.D2D1.WinUI/Helpers/ResourceManager.cs index 6a81f448..d2701fac 100644 --- a/src/ComputeSharp.D2D1.WinUI/Helpers/ResourceManager.cs +++ b/src/ComputeSharp.D2D1.WinUI/Helpers/ResourceManager.cs @@ -9,6 +9,7 @@ using WinRT; namespace ComputeSharp.D2D1.WinUI.Helpers; using CanvasDevice = Microsoft.Graphics.Canvas.CanvasDevice; +using ICanvasEffectFactoryNative = Microsoft.Graphics.Canvas.ICanvasEffectFactoryNative; using IInspectable = Win32.IInspectable; /// @@ -86,13 +87,13 @@ internal static unsafe class ResourceManager /// /// The id of the effects to register a factory for. /// The input factory to create wrappers of native effects. - public static void RegisterEffectFactory(Guid effectId, ICanvasEffectFactoryNative.Interface factory) + public static void RegisterEffectFactory(Guid effectId, ICanvasEffectFactoryNative factory) { using ComPtr canvasFactoryNative = default; GetActivationFactory(canvasFactoryNative.GetAddressOf()); - using ComPtr canvasEffectFactoryNative = default; + using ComPtr canvasEffectFactoryNative = default; RcwMarshaller.GetNativeInterface(factory, canvasEffectFactoryNative.GetAddressOf()).Assert(); diff --git a/src/ComputeSharp.D2D1.WinUI/PixelShaderEffect{T}.ICanvasEffectFactoryNative.cs b/src/ComputeSharp.D2D1.WinUI/PixelShaderEffect{T}.ICanvasEffectFactoryNative.cs index d1b23d9a..8d11efed 100644 --- a/src/ComputeSharp.D2D1.WinUI/PixelShaderEffect{T}.ICanvasEffectFactoryNative.cs +++ b/src/ComputeSharp.D2D1.WinUI/PixelShaderEffect{T}.ICanvasEffectFactoryNative.cs @@ -5,6 +5,7 @@ using ComputeSharp.D2D1.Extensions; using ComputeSharp.D2D1.WinUI.Extensions; using ComputeSharp.D2D1.WinUI.Helpers; using ComputeSharp.Win32; +using ICanvasEffectFactoryNative = Microsoft.Graphics.Canvas.ICanvasEffectFactoryNative; namespace ComputeSharp.D2D1.WinUI; @@ -74,10 +75,10 @@ unsafe partial class PixelShaderEffect /// /// A managed implementation of for . /// - private sealed class EffectFactory : ICanvasEffectFactoryNative.Interface + private sealed class EffectFactory : ICanvasEffectFactoryNative { /// - int ICanvasEffectFactoryNative.Interface.CreateWrapper(ICanvasDevice* device, ID2D1Effect* resource, float dpi, IInspectable** wrapper) + int ICanvasEffectFactoryNative.CreateWrapper(ICanvasDevice* device, ID2D1Effect* resource, float dpi, IInspectable** wrapper) { PixelShaderEffect @this; From 8c53714c296ec83665c77fcccb17ea29ea4dc1b9 Mon Sep 17 00:00:00 2001 From: Sergio Pedri Date: Fri, 26 Jan 2024 00:32:01 +0100 Subject: [PATCH 03/20] Use ActivationFactory.Get() for ICanvasFactoryNative --- .../ICanvasFactoryNative.cs | 52 +++++++++---------- .../Helpers/ResourceManager.cs | 10 ++-- 2 files changed, 32 insertions(+), 30 deletions(-) diff --git a/src/ComputeSharp.D2D1.WinUI/ABI.Microsoft.Graphics.Canvas/ICanvasFactoryNative.cs b/src/ComputeSharp.D2D1.WinUI/ABI.Microsoft.Graphics.Canvas/ICanvasFactoryNative.cs index 1f60788a..853052f2 100644 --- a/src/ComputeSharp.D2D1.WinUI/ABI.Microsoft.Graphics.Canvas/ICanvasFactoryNative.cs +++ b/src/ComputeSharp.D2D1.WinUI/ABI.Microsoft.Graphics.Canvas/ICanvasFactoryNative.cs @@ -2,11 +2,8 @@ using System; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using ComputeSharp.Win32; -using WinRT; -using WinRT.Interop; -using IInspectable = ComputeSharp.Win32.IInspectable; -#pragma warning disable CS0649, IDE1006 +#pragma warning disable CS0649, IDE0055, IDE1006 namespace ABI.Microsoft.Graphics.Canvas; @@ -15,8 +12,32 @@ namespace ABI.Microsoft.Graphics.Canvas; /// [NativeTypeName("class ICanvasFactoryNative : public IInspectable")] [NativeInheritance("IInspectable")] -internal unsafe struct ICanvasFactoryNative +internal unsafe struct ICanvasFactoryNative : IComObject { + /// + public static Guid* IID + { + [MethodImpl(MethodImplOptions.AggressiveInlining)] + get + { + ReadOnlySpan data = + [ + 0x0D, 0x44, 0x5C, 0x69, + 0xB3, 0x04, + 0xDD, 0x4E, + 0xBF, 0xD9, + 0x63, + 0xE5, + 0x1E, + 0x9F, + 0x72, + 0x02 + ]; + + return (Guid*)Unsafe.AsPointer(ref MemoryMarshal.GetReference(data)); + } + } + public void** lpVtbl; /// @@ -144,25 +165,4 @@ internal unsafe struct ICanvasFactoryNative (ICanvasFactoryNative*)Unsafe.AsPointer(ref this), effectId); } - - /// - /// The managed interface for . - /// - [Guid("695C440D-04B3-4EDD-BFD9-63E51E9F7202")] - [WindowsRuntimeType] - [WindowsRuntimeHelperType(typeof(Interface))] - public interface Interface - { - /// - /// The vtable type for . - /// - [Guid("695C440D-04B3-4EDD-BFD9-63E51E9F7202")] - public readonly struct Vftbl - { - /// - /// Allows CsWinRT to retrieve a pointer to the projection vtable (the name is hardcoded by convention). - /// - public static readonly IntPtr AbiToProjectionVftablePtr = IUnknownVftbl.AbiToProjectionVftblPtr; - } - } } \ No newline at end of file diff --git a/src/ComputeSharp.D2D1.WinUI/Helpers/ResourceManager.cs b/src/ComputeSharp.D2D1.WinUI/Helpers/ResourceManager.cs index d2701fac..8b7a0846 100644 --- a/src/ComputeSharp.D2D1.WinUI/Helpers/ResourceManager.cs +++ b/src/ComputeSharp.D2D1.WinUI/Helpers/ResourceManager.cs @@ -107,12 +107,14 @@ internal static unsafe class ResourceManager /// A pointer to the resulting activation factory. private static void GetActivationFactory(ICanvasFactoryNative** factoryNative) { - // On WinUI 3, the types are not guaranteed to be registered for activation. Additionally, - // for concistency with other types, we just use the built-in T.As() method, which will + const string ActivatableClassId = "Microsoft.Graphics.Canvas.CanvasDevice"; + + // On WinUI 3, the types are not guaranteed to be registered for activation. Additionally, for + // concistency with other types, we just use the built-in ActivationFactory type, which will // automatically handle fallback logic to resolve types to activate if they're not registered. // For instance, this will ensure the following call will work fine in unpackaged apps. - ICanvasFactoryNative.Interface canvasDeviceActivationFactory = CanvasDevice.As(); + using IObjectReference canvasDeviceActivationFactory = ActivationFactory.Get(ActivatableClassId, *ICanvasFactoryNative.IID); - *factoryNative = (ICanvasFactoryNative*)MarshalInterface.FromManaged(canvasDeviceActivationFactory); + *factoryNative = (ICanvasFactoryNative*)canvasDeviceActivationFactory.GetRef(); } } \ No newline at end of file From 190036df9b435bf24e95ee20b8a5507a0eb009ac Mon Sep 17 00:00:00 2001 From: Sergio Pedri Date: Fri, 26 Jan 2024 00:41:09 +0100 Subject: [PATCH 04/20] Remove DynamicallyAccessedMemberTypes.Interfaces --- src/ComputeSharp.D2D1.WinUI/Helpers/RcwMarshaller.cs | 2 +- src/ComputeSharp.D2D1.WinUI/Helpers/ResourceManager.cs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/ComputeSharp.D2D1.WinUI/Helpers/RcwMarshaller.cs b/src/ComputeSharp.D2D1.WinUI/Helpers/RcwMarshaller.cs index 83588f37..aa8be751 100644 --- a/src/ComputeSharp.D2D1.WinUI/Helpers/RcwMarshaller.cs +++ b/src/ComputeSharp.D2D1.WinUI/Helpers/RcwMarshaller.cs @@ -31,7 +31,7 @@ internal static unsafe class RcwMarshaller /// The input RCW instance to unwrap. /// A pointer to the resulting native object to retrieve. /// This method should only be called with being a concrete projected type. - public static void GetNativeObject<[DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.NonPublicConstructors | DynamicallyAccessedMemberTypes.Interfaces)] T>(T managedObject, IInspectable** nativeObject) + public static void GetNativeObject<[DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.NonPublicConstructors)] T>(T managedObject, IInspectable** nativeObject) where T : class { *nativeObject = (IInspectable*)MarshalInspectable.FromManaged(managedObject); diff --git a/src/ComputeSharp.D2D1.WinUI/Helpers/ResourceManager.cs b/src/ComputeSharp.D2D1.WinUI/Helpers/ResourceManager.cs index 8b7a0846..e30cd9bf 100644 --- a/src/ComputeSharp.D2D1.WinUI/Helpers/ResourceManager.cs +++ b/src/ComputeSharp.D2D1.WinUI/Helpers/ResourceManager.cs @@ -52,7 +52,7 @@ internal static unsafe class ResourceManager /// /// The input native resource to register a wrapper for. /// The wrapper to register for . - public static void RegisterWrapper<[DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.NonPublicConstructors | DynamicallyAccessedMemberTypes.Interfaces)] T>(IUnknown* resource, T wrapper) + public static void RegisterWrapper<[DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.NonPublicConstructors)] T>(IUnknown* resource, T wrapper) where T : class { using ComPtr canvasFactoryNative = default; From 0cacfe7a2d392ff847213cdd7a3dec6690d68f0f Mon Sep 17 00:00:00 2001 From: Sergio Pedri Date: Fri, 26 Jan 2024 01:29:22 +0100 Subject: [PATCH 05/20] Also use ActivationFactory.Get() in Win2D CLI sample --- .../ICanvasFactoryNative.cs | 23 ------------------- .../Backend/Win32Application.cs | 12 ++++------ 2 files changed, 4 insertions(+), 31 deletions(-) diff --git a/samples/ComputeSharp.SwapChain.D2D1.Cli/Backend/ABI.Microsoft.Graphics.Canvas/ICanvasFactoryNative.cs b/samples/ComputeSharp.SwapChain.D2D1.Cli/Backend/ABI.Microsoft.Graphics.Canvas/ICanvasFactoryNative.cs index a137a438..49bfa283 100644 --- a/samples/ComputeSharp.SwapChain.D2D1.Cli/Backend/ABI.Microsoft.Graphics.Canvas/ICanvasFactoryNative.cs +++ b/samples/ComputeSharp.SwapChain.D2D1.Cli/Backend/ABI.Microsoft.Graphics.Canvas/ICanvasFactoryNative.cs @@ -3,8 +3,6 @@ using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using TerraFX.Interop.Windows; using TerraFX.Interop; -using WinRT; -using WinRT.Interop; #pragma warning disable CS0649, IDE0055, IDE1006 @@ -79,25 +77,4 @@ internal unsafe struct ICanvasFactoryNative : IUnknown.Interface dpi, wrapper); } - - /// - /// The managed interface for . - /// - [Guid("695C440D-04B3-4EDD-BFD9-63E51E9F7202")] - [WindowsRuntimeType] - [WindowsRuntimeHelperType(typeof(Interface))] - public interface Interface - { - /// - /// The vtable type for . - /// - [Guid("695C440D-04B3-4EDD-BFD9-63E51E9F7202")] - public readonly struct Vftbl - { - /// - /// Allows CsWinRT to retrieve a pointer to the projection vtable (the name is hardcoded by convention). - /// - public static readonly IntPtr AbiToProjectionVftablePtr = IUnknownVftbl.AbiToProjectionVftblPtr; - } - } } \ No newline at end of file diff --git a/samples/ComputeSharp.SwapChain.D2D1.Cli/Backend/Win32Application.cs b/samples/ComputeSharp.SwapChain.D2D1.Cli/Backend/Win32Application.cs index 3f3d5a79..4eef52a2 100644 --- a/samples/ComputeSharp.SwapChain.D2D1.Cli/Backend/Win32Application.cs +++ b/samples/ComputeSharp.SwapChain.D2D1.Cli/Backend/Win32Application.cs @@ -117,15 +117,11 @@ internal sealed class Win32Application using ComPtr canvasFactoryNative = default; // Get the activation factory for CanvasDevice - using (ComPtr canvasFactoryNativeUnknown = default) + using (IObjectReference canvasDeviceActivationFactory = ActivationFactory.Get( + typeName: "Microsoft.Graphics.Canvas.CanvasDevice", + iid: Windows.__uuidof())) { - ICanvasFactoryNative.Interface canvasDeviceActivationFactory = CanvasDevice.As(); - - canvasFactoryNativeUnknown.Attach((IUnknown*)MarshalInterface.FromManaged(canvasDeviceActivationFactory)); - - hresult = canvasFactoryNativeUnknown.CopyTo(canvasFactoryNative.GetAddressOf()); - - ExceptionHelpers.ThrowExceptionForHR(hresult); + canvasFactoryNative.Attach((ICanvasFactoryNative*)canvasDeviceActivationFactory.GetRef()); } // Create a Win2D wrapper for the swapchain From 242d90aec412981e3c33b9e9dde46052fc9e6f11 Mon Sep 17 00:00:00 2001 From: Sergio Pedri Date: Sat, 27 Jan 2024 23:28:58 +0100 Subject: [PATCH 06/20] Use ActivationFactory.Get() in Win2D unit tests --- .../Helpers/Win2DHelper.cs | 45 +++++-------------- 1 file changed, 11 insertions(+), 34 deletions(-) diff --git a/tests/ComputeSharp.D2D1.WinUI.Tests/Helpers/Win2DHelper.cs b/tests/ComputeSharp.D2D1.WinUI.Tests/Helpers/Win2DHelper.cs index 98f09388..e1900cbf 100644 --- a/tests/ComputeSharp.D2D1.WinUI.Tests/Helpers/Win2DHelper.cs +++ b/tests/ComputeSharp.D2D1.WinUI.Tests/Helpers/Win2DHelper.cs @@ -4,7 +4,6 @@ using Microsoft.Graphics.Canvas; using TerraFX.Interop.DirectX; using TerraFX.Interop.Windows; using WinRT; -using WinRT.Interop; namespace ComputeSharp.D2D1.WinUI.Tests.Helpers; @@ -21,20 +20,15 @@ internal static class Win2DHelper /// The resulting managed wrapper for . public static unsafe object GetOrCreate(ID2D1Image* d2D1Image, CanvasDevice? canvasDevice = null) { - using ComPtr activationFactoryUnknown = default; - - ICanvasFactoryNative activationFactory = CanvasDevice.As(); - - activationFactoryUnknown.Attach((IUnknown*)MarshalInterface.FromManaged(activationFactory)); - using ComPtr canvasFactoryNativeUnknown = default; - Guid uuidOfCanvasFactoryNativeUnknown = new("695C440D-04B3-4EDD-BFD9-63E51E9F7202"); - - //Get the ICanvasFactoryNative object - int hresult = activationFactoryUnknown.CopyTo(&uuidOfCanvasFactoryNativeUnknown, (void**)canvasFactoryNativeUnknown.GetAddressOf()); - - Marshal.ThrowExceptionForHR(hresult); + // Get the ICanvasFactoryNative object + using (IObjectReference canvasDeviceActivationFactory = ActivationFactory.Get( + typeName: "Microsoft.Graphics.Canvas.CanvasDevice", + iid: new Guid("695C440D-04B3-4EDD-BFD9-63E51E9F7202"))) + { + canvasFactoryNativeUnknown.Attach((IUnknown*)canvasDeviceActivationFactory.GetRef()); + } using ComPtr canvasDeviceUnknown = default; @@ -43,6 +37,8 @@ internal static class Win2DHelper canvasDeviceUnknown.Attach((IUnknown*)MarshalInspectable.FromManaged(canvasDevice)); } + int hresult; + using ComPtr canvasDeviceInterfaceUnknown = default; if (canvasDevice is not null) @@ -51,6 +47,8 @@ internal static class Win2DHelper // Get the ICanvasDevice object (as an IUnknown* as well) hresult = canvasDeviceUnknown.CopyTo(&uuidOfCanvasDeviceInterface, (void**)canvasDeviceInterfaceUnknown.GetAddressOf()); + + Marshal.ThrowExceptionForHR(hresult); } using ComPtr wrapperUnknown = default; @@ -115,25 +113,4 @@ internal static class Win2DHelper Marshal.ThrowExceptionForHR(hresult); } - - /// - /// The managed interface for . - /// - [Guid("695C440D-04B3-4EDD-BFD9-63E51E9F7202")] - [WindowsRuntimeType] - [WindowsRuntimeHelperType(typeof(ICanvasFactoryNative))] - public interface ICanvasFactoryNative - { - /// - /// The vtable type for . - /// - [Guid("695C440D-04B3-4EDD-BFD9-63E51E9F7202")] - public readonly struct Vftbl - { - /// - /// Allows CsWinRT to retrieve a pointer to the projection vtable (the name is hardcoded by convention). - /// - public static readonly IntPtr AbiToProjectionVftablePtr = IUnknownVftbl.AbiToProjectionVftblPtr; - } - } } \ No newline at end of file From ed088c844d813612ed82e187b8368fcc8cd5969b Mon Sep 17 00:00:00 2001 From: Sergio Pedri Date: Sat, 27 Jan 2024 23:31:38 +0100 Subject: [PATCH 07/20] Make ICanvasImageInteropMethods public --- .../ABI.Microsoft.Graphics.Canvas/ICanvasImageInterop.cs | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/ComputeSharp.D2D1.WinUI/ABI.Microsoft.Graphics.Canvas/ICanvasImageInterop.cs b/src/ComputeSharp.D2D1.WinUI/ABI.Microsoft.Graphics.Canvas/ICanvasImageInterop.cs index c094f01d..d51c3cd4 100644 --- a/src/ComputeSharp.D2D1.WinUI/ABI.Microsoft.Graphics.Canvas/ICanvasImageInterop.cs +++ b/src/ComputeSharp.D2D1.WinUI/ABI.Microsoft.Graphics.Canvas/ICanvasImageInterop.cs @@ -1,4 +1,5 @@ using System; +using System.ComponentModel; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using ComputeSharp.Win32; @@ -105,8 +106,14 @@ namespace ABI.Microsoft.Graphics.Canvas /// /// The ABI methods for . /// + /// + /// This type has public accessibility to allow the AOT generator in CsWinRT to reference + /// the and properties to make + /// marshalling of CCW types AOT-safe. It is not meant to be used directly by developers. + /// [Guid("E042D1F7-F9AD-4479-A713-67627EA31863")] - internal static unsafe class ICanvasImageInteropMethods + [EditorBrowsable(EditorBrowsableState.Never)] + public static unsafe class ICanvasImageInteropMethods { /// public static Guid IID => *ICanvasImageInterop.IID; From 9e4a416a18cba53a32b3f5d831a4cbac46164748 Mon Sep 17 00:00:00 2001 From: Sergio Pedri Date: Mon, 29 Jan 2024 20:30:30 +0100 Subject: [PATCH 08/20] Make exposed CCW types partial (eg. EffectFactory) --- .../Backend/PixelShaderEffect.cs | 4 ++-- .../PixelShaderEffect{T}.ICanvasEffectFactoryNative.cs | 8 ++++++-- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/samples/ComputeSharp.SwapChain.D2D1.Cli/Backend/PixelShaderEffect.cs b/samples/ComputeSharp.SwapChain.D2D1.Cli/Backend/PixelShaderEffect.cs index 614804c2..349880ff 100644 --- a/samples/ComputeSharp.SwapChain.D2D1.Cli/Backend/PixelShaderEffect.cs +++ b/samples/ComputeSharp.SwapChain.D2D1.Cli/Backend/PixelShaderEffect.cs @@ -8,7 +8,7 @@ namespace ComputeSharp.SwapChain.D2D1.Backend; /// /// An base effect for an animated pixel shader. /// -internal abstract class PixelShaderEffect : CanvasEffect +internal abstract partial class PixelShaderEffect : CanvasEffect { /// /// The current elapsed time. @@ -57,7 +57,7 @@ internal abstract class PixelShaderEffect : CanvasEffect /// /// The type of pixel shader to render. /// The input factory. - public sealed class For(For.Factory factory) : PixelShaderEffect + public sealed partial class For(For.Factory factory) : PixelShaderEffect where T : unmanaged, ID2D1PixelShader, ID2D1PixelShaderDescriptor { /// diff --git a/src/ComputeSharp.D2D1.WinUI/PixelShaderEffect{T}.ICanvasEffectFactoryNative.cs b/src/ComputeSharp.D2D1.WinUI/PixelShaderEffect{T}.ICanvasEffectFactoryNative.cs index 8d11efed..9fa2d101 100644 --- a/src/ComputeSharp.D2D1.WinUI/PixelShaderEffect{T}.ICanvasEffectFactoryNative.cs +++ b/src/ComputeSharp.D2D1.WinUI/PixelShaderEffect{T}.ICanvasEffectFactoryNative.cs @@ -10,7 +10,7 @@ using ICanvasEffectFactoryNative = Microsoft.Graphics.Canvas.ICanvasEffectFactor namespace ComputeSharp.D2D1.WinUI; /// -unsafe partial class PixelShaderEffect +partial class PixelShaderEffect { /// /// A manager type to handle the effect factory registration logic for . @@ -75,7 +75,11 @@ unsafe partial class PixelShaderEffect /// /// A managed implementation of for . /// - private sealed class EffectFactory : ICanvasEffectFactoryNative + /// + /// This type is partial even though there are no other explicit partial type declarations in the project, so the CsWinRT + /// generator can generate one using and the precomputed vtable entries. + /// + internal sealed unsafe partial class EffectFactory : ICanvasEffectFactoryNative { /// int ICanvasEffectFactoryNative.CreateWrapper(ICanvasDevice* device, ID2D1Effect* resource, float dpi, IInspectable** wrapper) From da8c14d920997d582040cddc0da1842103267bbf Mon Sep 17 00:00:00 2001 From: Sergio Pedri Date: Mon, 29 Jan 2024 20:31:12 +0100 Subject: [PATCH 09/20] Remove unnecessary .rd.xml file for NativeAOT --- .../ComputeSharp.SwapChain.D2D1.Cli.csproj | 5 ----- .../Properties/Default.rd.xml | 18 ------------------ 2 files changed, 23 deletions(-) delete mode 100644 samples/ComputeSharp.SwapChain.D2D1.Cli/Properties/Default.rd.xml diff --git a/samples/ComputeSharp.SwapChain.D2D1.Cli/ComputeSharp.SwapChain.D2D1.Cli.csproj b/samples/ComputeSharp.SwapChain.D2D1.Cli/ComputeSharp.SwapChain.D2D1.Cli.csproj index 03cfe048..e1f61e21 100644 --- a/samples/ComputeSharp.SwapChain.D2D1.Cli/ComputeSharp.SwapChain.D2D1.Cli.csproj +++ b/samples/ComputeSharp.SwapChain.D2D1.Cli/ComputeSharp.SwapChain.D2D1.Cli.csproj @@ -42,11 +42,6 @@ Speed - - - - - diff --git a/samples/ComputeSharp.SwapChain.D2D1.Cli/Properties/Default.rd.xml b/samples/ComputeSharp.SwapChain.D2D1.Cli/Properties/Default.rd.xml deleted file mode 100644 index 4b8aa35b..00000000 --- a/samples/ComputeSharp.SwapChain.D2D1.Cli/Properties/Default.rd.xml +++ /dev/null @@ -1,18 +0,0 @@ - - - - - - - - - - - - - - - - - - \ No newline at end of file From bcee902a87c996f45cfd2270bd10ea051c51808c Mon Sep 17 00:00:00 2001 From: Sergio Pedri Date: Mon, 5 Feb 2024 00:07:53 +0100 Subject: [PATCH 10/20] Remove unnecessary [DynamicallyAccessedMembers] --- src/ComputeSharp.D2D1.WinUI/Helpers/RcwMarshaller.cs | 3 ++- src/ComputeSharp.D2D1.WinUI/Helpers/ResourceManager.cs | 3 +-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/ComputeSharp.D2D1.WinUI/Helpers/RcwMarshaller.cs b/src/ComputeSharp.D2D1.WinUI/Helpers/RcwMarshaller.cs index aa8be751..bfef4507 100644 --- a/src/ComputeSharp.D2D1.WinUI/Helpers/RcwMarshaller.cs +++ b/src/ComputeSharp.D2D1.WinUI/Helpers/RcwMarshaller.cs @@ -31,7 +31,8 @@ internal static unsafe class RcwMarshaller /// The input RCW instance to unwrap. /// A pointer to the resulting native object to retrieve. /// This method should only be called with being a concrete projected type. - public static void GetNativeObject<[DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.NonPublicConstructors)] T>(T managedObject, IInspectable** nativeObject) + [SuppressMessage("Trimming", "IL2091", Justification = "Private reflection on constructors is only needed when using 'FromAbi' to create RCWs.")] + public static void GetNativeObject(T managedObject, IInspectable** nativeObject) where T : class { *nativeObject = (IInspectable*)MarshalInspectable.FromManaged(managedObject); diff --git a/src/ComputeSharp.D2D1.WinUI/Helpers/ResourceManager.cs b/src/ComputeSharp.D2D1.WinUI/Helpers/ResourceManager.cs index e30cd9bf..8535324b 100644 --- a/src/ComputeSharp.D2D1.WinUI/Helpers/ResourceManager.cs +++ b/src/ComputeSharp.D2D1.WinUI/Helpers/ResourceManager.cs @@ -1,5 +1,4 @@ using System; -using System.Diagnostics.CodeAnalysis; using ABI.Microsoft.Graphics.Canvas; using ComputeSharp.D2D1.Extensions; using ComputeSharp.Win32; @@ -52,7 +51,7 @@ internal static unsafe class ResourceManager /// /// The input native resource to register a wrapper for. /// The wrapper to register for . - public static void RegisterWrapper<[DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.NonPublicConstructors)] T>(IUnknown* resource, T wrapper) + public static void RegisterWrapper(IUnknown* resource, T wrapper) where T : class { using ComPtr canvasFactoryNative = default; From bac700d170e8949aa259a6ba7a45fbb6daf97461 Mon Sep 17 00:00:00 2001 From: Sergio Pedri Date: Mon, 5 Feb 2024 00:17:43 +0100 Subject: [PATCH 11/20] Fix a small typo in a comment --- .../PixelShaderEffect{T}.ReferenceTracking.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/ComputeSharp.D2D1.WinUI/PixelShaderEffect{T}.ReferenceTracking.cs b/src/ComputeSharp.D2D1.WinUI/PixelShaderEffect{T}.ReferenceTracking.cs index 0429e3d7..d709e19a 100644 --- a/src/ComputeSharp.D2D1.WinUI/PixelShaderEffect{T}.ReferenceTracking.cs +++ b/src/ComputeSharp.D2D1.WinUI/PixelShaderEffect{T}.ReferenceTracking.cs @@ -43,7 +43,7 @@ partial class PixelShaderEffect { // When the effect is disposed, we also unregister it from the resource manager cache. This // is analogous to what is done when manually unrealizing the effect (eg. when using a new - // device. Without this call, the resource manager would keep registered effects alive for + // device). Without this call, the resource manager would keep registered effects alive for // the entire process duration, even if their original wrappers are gone (ie. collected). if (this.d2D1Effect.Get() is not null) { From b8ef99868621522390acd25192414154e8afbcfa Mon Sep 17 00:00:00 2001 From: Sergio Pedri Date: Mon, 5 Feb 2024 23:17:03 +0100 Subject: [PATCH 12/20] Enable CsWinRT AOT generator, fix IIDOptimizer errors --- .../ComputeSharp.SwapChain.D2D1.Cli.csproj | 12 ++++++++++++ .../ComputeSharp.D2D1.WinUI.csproj | 13 +++++++++++++ src/ComputeSharp.WinUI/ComputeSharp.WinUI.csproj | 9 +++++++++ 3 files changed, 34 insertions(+) diff --git a/samples/ComputeSharp.SwapChain.D2D1.Cli/ComputeSharp.SwapChain.D2D1.Cli.csproj b/samples/ComputeSharp.SwapChain.D2D1.Cli/ComputeSharp.SwapChain.D2D1.Cli.csproj index e1f61e21..cdd5ec3b 100644 --- a/samples/ComputeSharp.SwapChain.D2D1.Cli/ComputeSharp.SwapChain.D2D1.Cli.csproj +++ b/samples/ComputeSharp.SwapChain.D2D1.Cli/ComputeSharp.SwapChain.D2D1.Cli.csproj @@ -12,6 +12,12 @@ + + full + $(NoWarn);IDE0065 @@ -44,6 +50,12 @@ + + + diff --git a/src/ComputeSharp.D2D1.WinUI/ComputeSharp.D2D1.WinUI.csproj b/src/ComputeSharp.D2D1.WinUI/ComputeSharp.D2D1.WinUI.csproj index 2c20eeaa..7023cd86 100644 --- a/src/ComputeSharp.D2D1.WinUI/ComputeSharp.D2D1.WinUI.csproj +++ b/src/ComputeSharp.D2D1.WinUI/ComputeSharp.D2D1.WinUI.csproj @@ -8,6 +8,13 @@ + + true + + diff --git a/src/ComputeSharp.WinUI/ComputeSharp.WinUI.csproj b/src/ComputeSharp.WinUI/ComputeSharp.WinUI.csproj index 4ebf5d63..2c38eac8 100644 --- a/src/ComputeSharp.WinUI/ComputeSharp.WinUI.csproj +++ b/src/ComputeSharp.WinUI/ComputeSharp.WinUI.csproj @@ -6,8 +6,17 @@ win-x64;win-arm64 + + + + true + + + + + From 5f7f720ffc1d390d0fdf145844d2866434ada7f8 Mon Sep 17 00:00:00 2001 From: Sergio Pedri Date: Tue, 6 Feb 2024 16:24:50 +0100 Subject: [PATCH 13/20] Enable enable AOT generator on collection types --- ...derEffect{T}.Properties.ResourceTextureManagerCollection.cs | 3 ++- .../PixelShaderEffect{T}.Properties.SourceCollection.cs | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/ComputeSharp.D2D1.WinUI/PixelShaderEffect{T}.Properties.ResourceTextureManagerCollection.cs b/src/ComputeSharp.D2D1.WinUI/PixelShaderEffect{T}.Properties.ResourceTextureManagerCollection.cs index d5355762..42ec5d12 100644 --- a/src/ComputeSharp.D2D1.WinUI/PixelShaderEffect{T}.Properties.ResourceTextureManagerCollection.cs +++ b/src/ComputeSharp.D2D1.WinUI/PixelShaderEffect{T}.Properties.ResourceTextureManagerCollection.cs @@ -18,7 +18,8 @@ partial class PixelShaderEffect /// /// Represents the collection of objects in a instance. /// - public sealed class ResourceTextureManagerCollection : IList, IReadOnlyList, IList, IFixedCountList + /// + public sealed partial class ResourceTextureManagerCollection : IList, IReadOnlyList, IList, IFixedCountList { /// /// The bitmask of valid indices for resource texture managers in the current shader type. diff --git a/src/ComputeSharp.D2D1.WinUI/PixelShaderEffect{T}.Properties.SourceCollection.cs b/src/ComputeSharp.D2D1.WinUI/PixelShaderEffect{T}.Properties.SourceCollection.cs index f071c37e..a17cd08d 100644 --- a/src/ComputeSharp.D2D1.WinUI/PixelShaderEffect{T}.Properties.SourceCollection.cs +++ b/src/ComputeSharp.D2D1.WinUI/PixelShaderEffect{T}.Properties.SourceCollection.cs @@ -16,7 +16,8 @@ partial class PixelShaderEffect /// /// Represents the collection of sources in a instance. /// - public sealed class SourceCollection : IList, IReadOnlyList, IList, IFixedCountList + /// + public sealed partial class SourceCollection : IList, IReadOnlyList, IList, IFixedCountList { /// /// The collection of valid resource texture indices for the current effect. From bf107cb93646e40096928fb1a77422965fa1a54a Mon Sep 17 00:00:00 2001 From: Sergio Pedri Date: Tue, 6 Feb 2024 16:25:38 +0100 Subject: [PATCH 14/20] Add missing accessibility modifier --- src/ComputeSharp.D2D1.WinUI/Collections/IFixedCountList{T}.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/ComputeSharp.D2D1.WinUI/Collections/IFixedCountList{T}.cs b/src/ComputeSharp.D2D1.WinUI/Collections/IFixedCountList{T}.cs index 6dcd595c..78290d63 100644 --- a/src/ComputeSharp.D2D1.WinUI/Collections/IFixedCountList{T}.cs +++ b/src/ComputeSharp.D2D1.WinUI/Collections/IFixedCountList{T}.cs @@ -7,7 +7,7 @@ namespace ComputeSharp.D2D1.WinUI.Collections; /// An interface for a list with a fixed collection. /// /// The type of elements in the list. -interface IFixedCountList +internal interface IFixedCountList { /// /// Gets the collection of valid indices for the current effect. From 73a49edf8323b512799ee2a88a5e286bc72b9ce5 Mon Sep 17 00:00:00 2001 From: Sergio Pedri Date: Sat, 11 May 2024 23:18:29 +0200 Subject: [PATCH 15/20] Remove unnecessary trim suppression --- src/ComputeSharp.D2D1.WinUI/Helpers/RcwMarshaller.cs | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/ComputeSharp.D2D1.WinUI/Helpers/RcwMarshaller.cs b/src/ComputeSharp.D2D1.WinUI/Helpers/RcwMarshaller.cs index bfef4507..9253efbd 100644 --- a/src/ComputeSharp.D2D1.WinUI/Helpers/RcwMarshaller.cs +++ b/src/ComputeSharp.D2D1.WinUI/Helpers/RcwMarshaller.cs @@ -1,5 +1,4 @@ using System; -using System.Diagnostics.CodeAnalysis; using ComputeSharp.Win32; using WinRT; using IInspectable = ComputeSharp.Win32.IInspectable; @@ -31,7 +30,6 @@ internal static unsafe class RcwMarshaller /// The input RCW instance to unwrap. /// A pointer to the resulting native object to retrieve. /// This method should only be called with being a concrete projected type. - [SuppressMessage("Trimming", "IL2091", Justification = "Private reflection on constructors is only needed when using 'FromAbi' to create RCWs.")] public static void GetNativeObject(T managedObject, IInspectable** nativeObject) where T : class { From d01bcaa1d449a5cedbee1fda37330576c208510b Mon Sep 17 00:00:00 2001 From: Sergio Pedri Date: Sat, 18 May 2024 19:17:28 +0200 Subject: [PATCH 16/20] Remove unnecessary 'partial' modifiers --- ...aderEffect{T}.Properties.ResourceTextureManagerCollection.cs | 2 +- .../PixelShaderEffect{T}.Properties.SourceCollection.cs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/ComputeSharp.D2D1.WinUI/PixelShaderEffect{T}.Properties.ResourceTextureManagerCollection.cs b/src/ComputeSharp.D2D1.WinUI/PixelShaderEffect{T}.Properties.ResourceTextureManagerCollection.cs index 42ec5d12..bb5322c8 100644 --- a/src/ComputeSharp.D2D1.WinUI/PixelShaderEffect{T}.Properties.ResourceTextureManagerCollection.cs +++ b/src/ComputeSharp.D2D1.WinUI/PixelShaderEffect{T}.Properties.ResourceTextureManagerCollection.cs @@ -19,7 +19,7 @@ partial class PixelShaderEffect /// Represents the collection of objects in a instance. /// /// - public sealed partial class ResourceTextureManagerCollection : IList, IReadOnlyList, IList, IFixedCountList + public sealed class ResourceTextureManagerCollection : IList, IReadOnlyList, IList, IFixedCountList { /// /// The bitmask of valid indices for resource texture managers in the current shader type. diff --git a/src/ComputeSharp.D2D1.WinUI/PixelShaderEffect{T}.Properties.SourceCollection.cs b/src/ComputeSharp.D2D1.WinUI/PixelShaderEffect{T}.Properties.SourceCollection.cs index a17cd08d..80d2bdf8 100644 --- a/src/ComputeSharp.D2D1.WinUI/PixelShaderEffect{T}.Properties.SourceCollection.cs +++ b/src/ComputeSharp.D2D1.WinUI/PixelShaderEffect{T}.Properties.SourceCollection.cs @@ -17,7 +17,7 @@ partial class PixelShaderEffect /// Represents the collection of sources in a instance. /// /// - public sealed partial class SourceCollection : IList, IReadOnlyList, IList, IFixedCountList + public sealed class SourceCollection : IList, IReadOnlyList, IList, IFixedCountList { /// /// The collection of valid resource texture indices for the current effect. From e5f091571f41814b1a715439d39e7a44fbbe9610 Mon Sep 17 00:00:00 2001 From: Sergio Pedri Date: Sun, 19 May 2024 11:01:47 +0200 Subject: [PATCH 17/20] Remove unnecessary [Guid] attributes --- .../ABI.Microsoft.Graphics.Canvas/ICanvasEffectFactoryNative.cs | 2 -- .../ABI.Microsoft.Graphics.Canvas/ICanvasImageInterop.cs | 2 -- 2 files changed, 4 deletions(-) diff --git a/src/ComputeSharp.D2D1.WinUI/ABI.Microsoft.Graphics.Canvas/ICanvasEffectFactoryNative.cs b/src/ComputeSharp.D2D1.WinUI/ABI.Microsoft.Graphics.Canvas/ICanvasEffectFactoryNative.cs index 28d04e3f..82fd8f56 100644 --- a/src/ComputeSharp.D2D1.WinUI/ABI.Microsoft.Graphics.Canvas/ICanvasEffectFactoryNative.cs +++ b/src/ComputeSharp.D2D1.WinUI/ABI.Microsoft.Graphics.Canvas/ICanvasEffectFactoryNative.cs @@ -97,7 +97,6 @@ namespace ABI.Microsoft.Graphics.Canvas /// /// The ABI methods for . /// - [Guid("E042D1F7-F9AD-4479-A713-67627EA31863")] internal static unsafe class ICanvasEffectFactoryNativeMethods { /// @@ -127,7 +126,6 @@ namespace Microsoft.Graphics.Canvas /// /// The vtable type for . /// - [Guid("29BA1A1F-1CFE-44C3-984D-426D61B51427")] public struct Vftbl { /// diff --git a/src/ComputeSharp.D2D1.WinUI/ABI.Microsoft.Graphics.Canvas/ICanvasImageInterop.cs b/src/ComputeSharp.D2D1.WinUI/ABI.Microsoft.Graphics.Canvas/ICanvasImageInterop.cs index d51c3cd4..a1a68d35 100644 --- a/src/ComputeSharp.D2D1.WinUI/ABI.Microsoft.Graphics.Canvas/ICanvasImageInterop.cs +++ b/src/ComputeSharp.D2D1.WinUI/ABI.Microsoft.Graphics.Canvas/ICanvasImageInterop.cs @@ -111,7 +111,6 @@ namespace ABI.Microsoft.Graphics.Canvas /// the and properties to make /// marshalling of CCW types AOT-safe. It is not meant to be used directly by developers. /// - [Guid("E042D1F7-F9AD-4479-A713-67627EA31863")] [EditorBrowsable(EditorBrowsableState.Never)] public static unsafe class ICanvasImageInteropMethods { @@ -152,7 +151,6 @@ namespace Microsoft.Graphics.Canvas /// /// The vtable type for . /// - [Guid("E042D1F7-F9AD-4479-A713-67627EA31863")] public struct Vftbl { /// From 9c0fa8dfff054b54e9fd0970110bc3dc39e03dfa Mon Sep 17 00:00:00 2001 From: Sergio Pedri Date: Thu, 13 Jun 2024 20:32:07 -0700 Subject: [PATCH 18/20] Update NuGet packages to WinAppSDK 1.6-experimental1 --- .../ComputeSharp.SwapChain.D2D1.Cli.csproj | 3 ++- .../ComputeSharp.SwapChain.WinUI.csproj | 1 + src/ComputeSharp.D2D1.WinUI/ComputeSharp.D2D1.WinUI.csproj | 5 +++-- src/ComputeSharp.WinUI/ComputeSharp.WinUI.csproj | 5 +++-- .../ComputeSharp.D2D1.WinUI.Tests.csproj | 1 + 5 files changed, 10 insertions(+), 5 deletions(-) diff --git a/samples/ComputeSharp.SwapChain.D2D1.Cli/ComputeSharp.SwapChain.D2D1.Cli.csproj b/samples/ComputeSharp.SwapChain.D2D1.Cli/ComputeSharp.SwapChain.D2D1.Cli.csproj index cdd5ec3b..76cdb79a 100644 --- a/samples/ComputeSharp.SwapChain.D2D1.Cli/ComputeSharp.SwapChain.D2D1.Cli.csproj +++ b/samples/ComputeSharp.SwapChain.D2D1.Cli/ComputeSharp.SwapChain.D2D1.Cli.csproj @@ -3,6 +3,7 @@ Exe WinExe net8.0-windows10.0.22621 + 10.0.22621.35-preview app.manifest x64;ARM64 win-x64;win-arm64 @@ -55,7 +56,7 @@ Reference CsWinRT locally for the source generators (see comments in ComputeSharp.D2D1.WinUI). Note that this is an executable and not a library, so we must drop the 'PrivateAssets' here. --> - + diff --git a/samples/ComputeSharp.SwapChain.WinUI/ComputeSharp.SwapChain.WinUI.csproj b/samples/ComputeSharp.SwapChain.WinUI/ComputeSharp.SwapChain.WinUI.csproj index 2183b354..f95ae902 100644 --- a/samples/ComputeSharp.SwapChain.WinUI/ComputeSharp.SwapChain.WinUI.csproj +++ b/samples/ComputeSharp.SwapChain.WinUI/ComputeSharp.SwapChain.WinUI.csproj @@ -3,6 +3,7 @@ WinExe net8.0-windows10.0.22621.0 10.0.17763.0 + 10.0.22621.35-preview app.manifest x64;arm64 win-x64;win-arm64 diff --git a/src/ComputeSharp.D2D1.WinUI/ComputeSharp.D2D1.WinUI.csproj b/src/ComputeSharp.D2D1.WinUI/ComputeSharp.D2D1.WinUI.csproj index 7023cd86..99900a06 100644 --- a/src/ComputeSharp.D2D1.WinUI/ComputeSharp.D2D1.WinUI.csproj +++ b/src/ComputeSharp.D2D1.WinUI/ComputeSharp.D2D1.WinUI.csproj @@ -2,6 +2,7 @@ net8.0-windows10.0.22621.0 10.0.17763.0 + 10.0.22621.35-preview x64;ARM64 win-x64;win-arm64 @@ -32,13 +33,13 @@ - + - + diff --git a/src/ComputeSharp.WinUI/ComputeSharp.WinUI.csproj b/src/ComputeSharp.WinUI/ComputeSharp.WinUI.csproj index 2c38eac8..5a49a7d6 100644 --- a/src/ComputeSharp.WinUI/ComputeSharp.WinUI.csproj +++ b/src/ComputeSharp.WinUI/ComputeSharp.WinUI.csproj @@ -2,6 +2,7 @@ net8.0-windows10.0.22621.0 10.0.17763.0 + 10.0.22621.35-preview x64;ARM64 win-x64;win-arm64 @@ -13,10 +14,10 @@ - + - + diff --git a/tests/ComputeSharp.D2D1.WinUI.Tests/ComputeSharp.D2D1.WinUI.Tests.csproj b/tests/ComputeSharp.D2D1.WinUI.Tests/ComputeSharp.D2D1.WinUI.Tests.csproj index 133ab310..31119f1e 100644 --- a/tests/ComputeSharp.D2D1.WinUI.Tests/ComputeSharp.D2D1.WinUI.Tests.csproj +++ b/tests/ComputeSharp.D2D1.WinUI.Tests/ComputeSharp.D2D1.WinUI.Tests.csproj @@ -3,6 +3,7 @@ WinExe net8.0-windows10.0.22621.0 10.0.17763.0 + 10.0.22621.35-preview app.manifest x64;ARM64 win-x64;win-arm64 From 8385445b4e39d54d2b6cc4176aca7cd296e07817 Mon Sep 17 00:00:00 2001 From: Sergio Pedri Date: Sun, 16 Jun 2024 11:24:03 -0700 Subject: [PATCH 19/20] Remove suppressions, enable CsWinRT size saving --- .../ComputeSharp.SwapChain.D2D1.Cli.csproj | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/samples/ComputeSharp.SwapChain.D2D1.Cli/ComputeSharp.SwapChain.D2D1.Cli.csproj b/samples/ComputeSharp.SwapChain.D2D1.Cli/ComputeSharp.SwapChain.D2D1.Cli.csproj index 76cdb79a..5b0fcd27 100644 --- a/samples/ComputeSharp.SwapChain.D2D1.Cli/ComputeSharp.SwapChain.D2D1.Cli.csproj +++ b/samples/ComputeSharp.SwapChain.D2D1.Cli/ComputeSharp.SwapChain.D2D1.Cli.csproj @@ -21,12 +21,16 @@ $(NoWarn);IDE0065 - - - $(NoWarn);IL2104;IL2026 - - - $(NoWarn);IL3053 + + + + + false + true + false + false + false + false From 9024d1fba691707339917a6a45718e998d62c023 Mon Sep 17 00:00:00 2001 From: Sergio Pedri Date: Fri, 28 Jun 2024 11:51:34 -0700 Subject: [PATCH 20/20] Update Win2D to 1.2.1-experimental1 --- src/ComputeSharp.D2D1.WinUI/ComputeSharp.D2D1.WinUI.csproj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/ComputeSharp.D2D1.WinUI/ComputeSharp.D2D1.WinUI.csproj b/src/ComputeSharp.D2D1.WinUI/ComputeSharp.D2D1.WinUI.csproj index 99900a06..53d69e5f 100644 --- a/src/ComputeSharp.D2D1.WinUI/ComputeSharp.D2D1.WinUI.csproj +++ b/src/ComputeSharp.D2D1.WinUI/ComputeSharp.D2D1.WinUI.csproj @@ -33,7 +33,7 @@ - +