From bdd97a750d9c9270d4f9e781507888f4984452e3 Mon Sep 17 00:00:00 2001 From: Sergio Pedri Date: Wed, 18 Oct 2023 12:57:34 +0200 Subject: [PATCH 1/5] Remove downlevel paths in HLSL primitives --- src/ComputeSharp.Core/Primitives/Bool/Bool.cs | 2 +- src/ComputeSharp.Core/Primitives/Bool/Bool2.g.cs | 4 ---- src/ComputeSharp.Core/Primitives/Bool/Bool3.g.cs | 4 ---- src/ComputeSharp.Core/Primitives/Bool/Bool4.g.cs | 4 ---- src/ComputeSharp.Core/Primitives/Double/Double2.g.cs | 4 ---- src/ComputeSharp.Core/Primitives/Double/Double3.g.cs | 4 ---- src/ComputeSharp.Core/Primitives/Double/Double4.g.cs | 4 ---- src/ComputeSharp.Core/Primitives/Float/Float2.g.cs | 4 ---- src/ComputeSharp.Core/Primitives/Float/Float3.g.cs | 4 ---- src/ComputeSharp.Core/Primitives/Float/Float4.g.cs | 4 ---- src/ComputeSharp.Core/Primitives/Int/Int2.g.cs | 4 ---- src/ComputeSharp.Core/Primitives/Int/Int3.g.cs | 4 ---- src/ComputeSharp.Core/Primitives/Int/Int4.g.cs | 4 ---- src/ComputeSharp.Core/Primitives/UInt/UInt2.g.cs | 4 ---- src/ComputeSharp.Core/Primitives/UInt/UInt3.g.cs | 4 ---- src/ComputeSharp.Core/Primitives/UInt/UInt4.g.cs | 4 ---- src/ComputeSharp.Core/Primitives/VectorType.ttinclude | 8 -------- 17 files changed, 1 insertion(+), 69 deletions(-) diff --git a/src/ComputeSharp.Core/Primitives/Bool/Bool.cs b/src/ComputeSharp.Core/Primitives/Bool/Bool.cs index d2d0490f..84136a95 100644 --- a/src/ComputeSharp.Core/Primitives/Bool/Bool.cs +++ b/src/ComputeSharp.Core/Primitives/Bool/Bool.cs @@ -48,7 +48,7 @@ public readonly struct Bool return ((bool)this).ToString(formatProvider); } -#if NET6_0_OR_GREATER +#if !SOURCE_GENERATOR /// public bool TryFormat(Span destination, out int charsWritten) { diff --git a/src/ComputeSharp.Core/Primitives/Bool/Bool2.g.cs b/src/ComputeSharp.Core/Primitives/Bool/Bool2.g.cs index 6dbee96b..c8ceac11 100644 --- a/src/ComputeSharp.Core/Primitives/Bool/Bool2.g.cs +++ b/src/ComputeSharp.Core/Primitives/Bool/Bool2.g.cs @@ -461,16 +461,12 @@ public unsafe partial struct Bool2 [UnscopedRef] public readonly ref readonly Bool4 GGGG => ref *(Bool4*)UndefinedData.Memory; -#if !SOURCE_GENERATOR - /// public override readonly string ToString() { return $"<{this.x != 0}, {this.y != 0}>"; } -#endif - /// /// Negates a value. /// diff --git a/src/ComputeSharp.Core/Primitives/Bool/Bool3.g.cs b/src/ComputeSharp.Core/Primitives/Bool/Bool3.g.cs index 9806d30f..ac3320fc 100644 --- a/src/ComputeSharp.Core/Primitives/Bool/Bool3.g.cs +++ b/src/ComputeSharp.Core/Primitives/Bool/Bool3.g.cs @@ -1727,16 +1727,12 @@ public unsafe partial struct Bool3 [UnscopedRef] public readonly ref readonly Bool4 BBBB => ref *(Bool4*)UndefinedData.Memory; -#if !SOURCE_GENERATOR - /// public override readonly string ToString() { return $"<{this.x != 0}, {this.y != 0}, {this.z != 0}>"; } -#endif - /// /// Negates a value. /// diff --git a/src/ComputeSharp.Core/Primitives/Bool/Bool4.g.cs b/src/ComputeSharp.Core/Primitives/Bool/Bool4.g.cs index de1e6bb9..3a3847d4 100644 --- a/src/ComputeSharp.Core/Primitives/Bool/Bool4.g.cs +++ b/src/ComputeSharp.Core/Primitives/Bool/Bool4.g.cs @@ -4813,16 +4813,12 @@ public unsafe partial struct Bool4 [UnscopedRef] public readonly ref readonly Bool4 AAAA => ref *(Bool4*)UndefinedData.Memory; -#if !SOURCE_GENERATOR - /// public override readonly string ToString() { return $"<{this.x != 0}, {this.y != 0}, {this.z != 0}, {this.w != 0}>"; } -#endif - /// /// Negates a value. /// diff --git a/src/ComputeSharp.Core/Primitives/Double/Double2.g.cs b/src/ComputeSharp.Core/Primitives/Double/Double2.g.cs index d1d844d6..2fcde5cc 100644 --- a/src/ComputeSharp.Core/Primitives/Double/Double2.g.cs +++ b/src/ComputeSharp.Core/Primitives/Double/Double2.g.cs @@ -463,8 +463,6 @@ public unsafe partial struct Double2 [UnscopedRef] public readonly ref readonly Double4 GGGG => ref *(Double4*)UndefinedData.Memory; -#if !SOURCE_GENERATOR - /// public override readonly string ToString() { @@ -473,8 +471,6 @@ public unsafe partial struct Double2 return $"<{this.x}{separator} {this.y}>"; } -#endif - /// /// Negates a value. /// diff --git a/src/ComputeSharp.Core/Primitives/Double/Double3.g.cs b/src/ComputeSharp.Core/Primitives/Double/Double3.g.cs index 2d626a15..75fd7e44 100644 --- a/src/ComputeSharp.Core/Primitives/Double/Double3.g.cs +++ b/src/ComputeSharp.Core/Primitives/Double/Double3.g.cs @@ -1729,8 +1729,6 @@ public unsafe partial struct Double3 [UnscopedRef] public readonly ref readonly Double4 BBBB => ref *(Double4*)UndefinedData.Memory; -#if !SOURCE_GENERATOR - /// public override readonly string ToString() { @@ -1739,8 +1737,6 @@ public unsafe partial struct Double3 return $"<{this.x}{separator} {this.y}{separator} {this.z}>"; } -#endif - /// /// Negates a value. /// diff --git a/src/ComputeSharp.Core/Primitives/Double/Double4.g.cs b/src/ComputeSharp.Core/Primitives/Double/Double4.g.cs index adfda559..a97379ee 100644 --- a/src/ComputeSharp.Core/Primitives/Double/Double4.g.cs +++ b/src/ComputeSharp.Core/Primitives/Double/Double4.g.cs @@ -4815,8 +4815,6 @@ public unsafe partial struct Double4 [UnscopedRef] public readonly ref readonly Double4 AAAA => ref *(Double4*)UndefinedData.Memory; -#if !SOURCE_GENERATOR - /// public override readonly string ToString() { @@ -4825,8 +4823,6 @@ public unsafe partial struct Double4 return $"<{this.x}{separator} {this.y}{separator} {this.z}{separator} {this.w}>"; } -#endif - /// /// Negates a value. /// diff --git a/src/ComputeSharp.Core/Primitives/Float/Float2.g.cs b/src/ComputeSharp.Core/Primitives/Float/Float2.g.cs index c1ea54b1..91717962 100644 --- a/src/ComputeSharp.Core/Primitives/Float/Float2.g.cs +++ b/src/ComputeSharp.Core/Primitives/Float/Float2.g.cs @@ -464,8 +464,6 @@ public unsafe partial struct Float2 [UnscopedRef] public readonly ref readonly Float4 GGGG => ref *(Float4*)UndefinedData.Memory; -#if !SOURCE_GENERATOR - /// public override readonly string ToString() { @@ -474,8 +472,6 @@ public unsafe partial struct Float2 return $"<{this.x}{separator} {this.y}>"; } -#endif - /// /// Negates a value. /// diff --git a/src/ComputeSharp.Core/Primitives/Float/Float3.g.cs b/src/ComputeSharp.Core/Primitives/Float/Float3.g.cs index 054f0052..57148377 100644 --- a/src/ComputeSharp.Core/Primitives/Float/Float3.g.cs +++ b/src/ComputeSharp.Core/Primitives/Float/Float3.g.cs @@ -1730,8 +1730,6 @@ public unsafe partial struct Float3 [UnscopedRef] public readonly ref readonly Float4 BBBB => ref *(Float4*)UndefinedData.Memory; -#if !SOURCE_GENERATOR - /// public override readonly string ToString() { @@ -1740,8 +1738,6 @@ public unsafe partial struct Float3 return $"<{this.x}{separator} {this.y}{separator} {this.z}>"; } -#endif - /// /// Negates a value. /// diff --git a/src/ComputeSharp.Core/Primitives/Float/Float4.g.cs b/src/ComputeSharp.Core/Primitives/Float/Float4.g.cs index b013eba6..b698a2e0 100644 --- a/src/ComputeSharp.Core/Primitives/Float/Float4.g.cs +++ b/src/ComputeSharp.Core/Primitives/Float/Float4.g.cs @@ -4816,8 +4816,6 @@ public unsafe partial struct Float4 [UnscopedRef] public readonly ref readonly Float4 AAAA => ref *(Float4*)UndefinedData.Memory; -#if !SOURCE_GENERATOR - /// public override readonly string ToString() { @@ -4826,8 +4824,6 @@ public unsafe partial struct Float4 return $"<{this.x}{separator} {this.y}{separator} {this.z}{separator} {this.w}>"; } -#endif - /// /// Negates a value. /// diff --git a/src/ComputeSharp.Core/Primitives/Int/Int2.g.cs b/src/ComputeSharp.Core/Primitives/Int/Int2.g.cs index 8418e5f8..ed18fa99 100644 --- a/src/ComputeSharp.Core/Primitives/Int/Int2.g.cs +++ b/src/ComputeSharp.Core/Primitives/Int/Int2.g.cs @@ -464,8 +464,6 @@ public unsafe partial struct Int2 [UnscopedRef] public readonly ref readonly Int4 GGGG => ref *(Int4*)UndefinedData.Memory; -#if !SOURCE_GENERATOR - /// public override readonly string ToString() { @@ -474,8 +472,6 @@ public unsafe partial struct Int2 return $"<{this.x}{separator} {this.y}>"; } -#endif - /// /// Negates a value. /// diff --git a/src/ComputeSharp.Core/Primitives/Int/Int3.g.cs b/src/ComputeSharp.Core/Primitives/Int/Int3.g.cs index fcd58d8a..c09a6c0a 100644 --- a/src/ComputeSharp.Core/Primitives/Int/Int3.g.cs +++ b/src/ComputeSharp.Core/Primitives/Int/Int3.g.cs @@ -1730,8 +1730,6 @@ public unsafe partial struct Int3 [UnscopedRef] public readonly ref readonly Int4 BBBB => ref *(Int4*)UndefinedData.Memory; -#if !SOURCE_GENERATOR - /// public override readonly string ToString() { @@ -1740,8 +1738,6 @@ public unsafe partial struct Int3 return $"<{this.x}{separator} {this.y}{separator} {this.z}>"; } -#endif - /// /// Negates a value. /// diff --git a/src/ComputeSharp.Core/Primitives/Int/Int4.g.cs b/src/ComputeSharp.Core/Primitives/Int/Int4.g.cs index b67fd279..4ffe67a3 100644 --- a/src/ComputeSharp.Core/Primitives/Int/Int4.g.cs +++ b/src/ComputeSharp.Core/Primitives/Int/Int4.g.cs @@ -4816,8 +4816,6 @@ public unsafe partial struct Int4 [UnscopedRef] public readonly ref readonly Int4 AAAA => ref *(Int4*)UndefinedData.Memory; -#if !SOURCE_GENERATOR - /// public override readonly string ToString() { @@ -4826,8 +4824,6 @@ public unsafe partial struct Int4 return $"<{this.x}{separator} {this.y}{separator} {this.z}{separator} {this.w}>"; } -#endif - /// /// Negates a value. /// diff --git a/src/ComputeSharp.Core/Primitives/UInt/UInt2.g.cs b/src/ComputeSharp.Core/Primitives/UInt/UInt2.g.cs index 7ddba2f0..d75113ff 100644 --- a/src/ComputeSharp.Core/Primitives/UInt/UInt2.g.cs +++ b/src/ComputeSharp.Core/Primitives/UInt/UInt2.g.cs @@ -463,8 +463,6 @@ public unsafe partial struct UInt2 [UnscopedRef] public readonly ref readonly UInt4 GGGG => ref *(UInt4*)UndefinedData.Memory; -#if !SOURCE_GENERATOR - /// public override readonly string ToString() { @@ -473,8 +471,6 @@ public unsafe partial struct UInt2 return $"<{this.x}{separator} {this.y}>"; } -#endif - /// /// Sums two values. /// diff --git a/src/ComputeSharp.Core/Primitives/UInt/UInt3.g.cs b/src/ComputeSharp.Core/Primitives/UInt/UInt3.g.cs index 64520fc9..7a95ab50 100644 --- a/src/ComputeSharp.Core/Primitives/UInt/UInt3.g.cs +++ b/src/ComputeSharp.Core/Primitives/UInt/UInt3.g.cs @@ -1729,8 +1729,6 @@ public unsafe partial struct UInt3 [UnscopedRef] public readonly ref readonly UInt4 BBBB => ref *(UInt4*)UndefinedData.Memory; -#if !SOURCE_GENERATOR - /// public override readonly string ToString() { @@ -1739,8 +1737,6 @@ public unsafe partial struct UInt3 return $"<{this.x}{separator} {this.y}{separator} {this.z}>"; } -#endif - /// /// Sums two values. /// diff --git a/src/ComputeSharp.Core/Primitives/UInt/UInt4.g.cs b/src/ComputeSharp.Core/Primitives/UInt/UInt4.g.cs index 56a4e76a..81a24dc4 100644 --- a/src/ComputeSharp.Core/Primitives/UInt/UInt4.g.cs +++ b/src/ComputeSharp.Core/Primitives/UInt/UInt4.g.cs @@ -4815,8 +4815,6 @@ public unsafe partial struct UInt4 [UnscopedRef] public readonly ref readonly UInt4 AAAA => ref *(UInt4*)UndefinedData.Memory; -#if !SOURCE_GENERATOR - /// public override readonly string ToString() { @@ -4825,8 +4823,6 @@ public unsafe partial struct UInt4 return $"<{this.x}{separator} {this.y}{separator} {this.z}{separator} {this.w}>"; } -#endif - /// /// Sums two values. /// diff --git a/src/ComputeSharp.Core/Primitives/VectorType.ttinclude b/src/ComputeSharp.Core/Primitives/VectorType.ttinclude index c3a3178b..0bf6f7c2 100644 --- a/src/ComputeSharp.Core/Primitives/VectorType.ttinclude +++ b/src/ComputeSharp.Core/Primitives/VectorType.ttinclude @@ -229,10 +229,6 @@ public unsafe partial struct <#=typeName#> PopIndent(); WriteLine(""); -#> -#if !SOURCE_GENERATOR - -<# if (elementTypeName == "Bool") { #> @@ -256,10 +252,6 @@ public unsafe partial struct <#=typeName#> <# } -#> - -#endif -<# // Generate the negation operator if (elementTypeName != "UInt") { From e2afabb1943d68cb489aad74b21979a24c9deb6f Mon Sep 17 00:00:00 2001 From: Sergio Pedri Date: Wed, 18 Oct 2023 13:06:16 +0200 Subject: [PATCH 2/5] Remove downlevel paths in ComputeSharp.D2D1 --- .../Exceptions/FxcCompilationException.cs | 2 +- .../Effects/PixelShaderEffect.Globals{T}.cs | 12 +- ...lShaderEffect.ID2D1DrawTransformMethods.cs | 62 --- ...ixelShaderEffect.ID2D1EffectImplMethods.cs | 44 -- .../Effects/PixelShaderEffect.Properties.cs | 62 --- .../Effects/PixelShaderEffect.Properties.g.cs | 420 ------------------ .../Effects/PixelShaderEffect.Properties.tt | 38 -- .../Interop/Effects/PixelShaderEffect.cs | 34 -- ...ManagerImpl.ID2D1ResourceTextureManager.cs | 48 -- ...mpl.ID2D1ResourceTextureManagerInternal.cs | 35 -- .../D2D1ResourceTextureManagerImpl.cs | 30 -- ...teContextImpl.ID2D1DrawInfoUpdateContex.cs | 44 -- ...tImpl.ID2D1DrawInfoUpdateContexInternal.cs | 26 -- .../D2D1DrawInfoUpdateContextImpl.cs | 30 -- ...ransformMapperImpl.ID2D1TransformMapper.cs | 59 --- ...MapperImpl.ID2D1TransformMapperInternal.cs | 26 -- .../D2D1TransformMapperImpl.cs | 30 -- .../DirectX/um/d2d1_1/ID2D1Factory1.cs | 11 +- .../d2d1effectauthor/D2D1_PROPERTY_BINDING.cs | 8 - 19 files changed, 5 insertions(+), 1016 deletions(-) diff --git a/src/ComputeSharp.D2D1/Shaders/Exceptions/FxcCompilationException.cs b/src/ComputeSharp.D2D1/Shaders/Exceptions/FxcCompilationException.cs index 39b1aa50..2d9cc834 100644 --- a/src/ComputeSharp.D2D1/Shaders/Exceptions/FxcCompilationException.cs +++ b/src/ComputeSharp.D2D1/Shaders/Exceptions/FxcCompilationException.cs @@ -23,7 +23,7 @@ public sealed class FxcCompilationException : Exception /// A formatted error message for a new instance. private static string GetExceptionMessage(string error) { -#if NET6_0_OR_GREATER +#if !SOURCE_GENERATOR ReadOnlySpan message = error.AsSpan().Trim(); #else string message = error.Trim(); diff --git a/src/ComputeSharp.D2D1/Shaders/Interop/Effects/PixelShaderEffect.Globals{T}.cs b/src/ComputeSharp.D2D1/Shaders/Interop/Effects/PixelShaderEffect.Globals{T}.cs index acfa28f2..851056b1 100644 --- a/src/ComputeSharp.D2D1/Shaders/Interop/Effects/PixelShaderEffect.Globals{T}.cs +++ b/src/ComputeSharp.D2D1/Shaders/Interop/Effects/PixelShaderEffect.Globals{T}.cs @@ -74,18 +74,10 @@ internal unsafe partial struct PixelShaderEffect /// /// Gets the factory for the current effect. /// -#if NET6_0_OR_GREATER - public delegate* unmanaged[Stdcall] Factory -#else - public void* Factory -#endif + public delegate* unmanaged Factory { [MethodImpl(MethodImplOptions.AggressiveInlining)] -#if NET6_0_OR_GREATER - get => (delegate* unmanaged[Stdcall])Marshal.GetFunctionPointerForDelegate(this.effectFactory); -#else - get => (void*)Marshal.GetFunctionPointerForDelegate(this.effectFactory); -#endif + get => (delegate* unmanaged)Marshal.GetFunctionPointerForDelegate(this.effectFactory); } } diff --git a/src/ComputeSharp.D2D1/Shaders/Interop/Effects/PixelShaderEffect.ID2D1DrawTransformMethods.cs b/src/ComputeSharp.D2D1/Shaders/Interop/Effects/PixelShaderEffect.ID2D1DrawTransformMethods.cs index 1d863751..331f4cca 100644 --- a/src/ComputeSharp.D2D1/Shaders/Interop/Effects/PixelShaderEffect.ID2D1DrawTransformMethods.cs +++ b/src/ComputeSharp.D2D1/Shaders/Interop/Effects/PixelShaderEffect.ID2D1DrawTransformMethods.cs @@ -14,68 +14,6 @@ partial struct PixelShaderEffect /// private static unsafe class ID2D1DrawTransformMethods { -#if !NET6_0_OR_GREATER - /// - [UnmanagedFunctionPointer(CallingConvention.StdCall)] - public delegate uint GetInputCountDelegate(PixelShaderEffect* @this); - - /// - [UnmanagedFunctionPointer(CallingConvention.StdCall)] - public delegate int MapOutputRectToInputRectsDelegate(PixelShaderEffect* @this, RECT* outputRect, RECT* inputRects, uint inputRectsCount); - - /// - [UnmanagedFunctionPointer(CallingConvention.StdCall)] - public delegate int MapInputRectsToOutputRectDelegate(PixelShaderEffect* @this, RECT* inputRects, RECT* inputOpaqueSubRects, uint inputRectCount, RECT* outputRect, RECT* outputOpaqueSubRect); - - /// - [UnmanagedFunctionPointer(CallingConvention.StdCall)] - public delegate int MapInvalidRectDelegate(PixelShaderEffect* @this, uint inputIndex, RECT invalidInputRect, RECT* invalidOutputRect); - - /// - [UnmanagedFunctionPointer(CallingConvention.StdCall)] - public delegate int SetDrawInfoDelegate(PixelShaderEffect* @this, ID2D1DrawInfo* drawInfo); - - /// - /// A cached instance wrapping . - /// - public static readonly QueryInterfaceDelegate QueryInterfaceWrapper = QueryInterface; - - /// - /// A cached instance wrapping . - /// - public static readonly AddRefDelegate AddRefWrapper = AddRef; - - /// - /// A cached instance wrapping . - /// - public static readonly ReleaseDelegate ReleaseWrapper = Release; - - /// - /// A cached instance wrapping . - /// - public static readonly GetInputCountDelegate GetInputCountWrapper = GetInputCount; - - /// - /// A cached instance wrapping . - /// - public static readonly MapOutputRectToInputRectsDelegate MapOutputRectToInputRectsWrapper = MapOutputRectToInputRects; - - /// - /// A cached instance wrapping . - /// - public static readonly MapInputRectsToOutputRectDelegate MapInputRectsToOutputRectWrapper = MapInputRectsToOutputRect; - - /// - /// A cached instance wrapping . - /// - public static readonly MapInvalidRectDelegate MapInvalidRectWrapper = MapInvalidRect; - - /// - /// A cached instance wrapping . - /// - public static readonly SetDrawInfoDelegate SetDrawInfoWrapper = SetDrawInfo; -#endif - /// [UnmanagedCallersOnly] public static int QueryInterface(PixelShaderEffect* @this, Guid* riid, void** ppvObject) diff --git a/src/ComputeSharp.D2D1/Shaders/Interop/Effects/PixelShaderEffect.ID2D1EffectImplMethods.cs b/src/ComputeSharp.D2D1/Shaders/Interop/Effects/PixelShaderEffect.ID2D1EffectImplMethods.cs index 6681b8e5..2eb6e2b5 100644 --- a/src/ComputeSharp.D2D1/Shaders/Interop/Effects/PixelShaderEffect.ID2D1EffectImplMethods.cs +++ b/src/ComputeSharp.D2D1/Shaders/Interop/Effects/PixelShaderEffect.ID2D1EffectImplMethods.cs @@ -17,50 +17,6 @@ internal unsafe partial struct PixelShaderEffect /// private static class ID2D1EffectImplMethods { -#if !NET6_0_OR_GREATER - /// - [UnmanagedFunctionPointer(CallingConvention.StdCall)] - public delegate int InitializeDelegate(PixelShaderEffect* @this, ID2D1EffectContext* effectContext, ID2D1TransformGraph* transformGraph); - - /// - [UnmanagedFunctionPointer(CallingConvention.StdCall)] - public delegate int PrepareForRenderDelegate(PixelShaderEffect* @this, D2D1_CHANGE_TYPE changeType); - - /// - [UnmanagedFunctionPointer(CallingConvention.StdCall)] - public delegate int SetGraphDelegate(PixelShaderEffect* @this, ID2D1TransformGraph* transformGraph); - - /// - /// A cached instance wrapping . - /// - public static readonly QueryInterfaceDelegate QueryInterfaceWrapper = QueryInterface; - - /// - /// A cached instance wrapping . - /// - public static readonly AddRefDelegate AddRefWrapper = AddRef; - - /// - /// A cached instance wrapping . - /// - public static readonly ReleaseDelegate ReleaseWrapper = Release; - - /// - /// A cached instance wrapping . - /// - public static readonly InitializeDelegate InitializeWrapper = Initialize; - - /// - /// A cached instance wrapping . - /// - public static readonly PrepareForRenderDelegate PrepareForRenderWrapper = PrepareForRender; - - /// - /// A cached instance wrapping . - /// - public static readonly SetGraphDelegate SetGraphWrapper = SetGraph; -#endif - /// [UnmanagedCallersOnly] public static int QueryInterface(PixelShaderEffect* @this, Guid* riid, void** ppvObject) diff --git a/src/ComputeSharp.D2D1/Shaders/Interop/Effects/PixelShaderEffect.Properties.cs b/src/ComputeSharp.D2D1/Shaders/Interop/Effects/PixelShaderEffect.Properties.cs index 331b4142..026c9838 100644 --- a/src/ComputeSharp.D2D1/Shaders/Interop/Effects/PixelShaderEffect.Properties.cs +++ b/src/ComputeSharp.D2D1/Shaders/Interop/Effects/PixelShaderEffect.Properties.cs @@ -11,102 +11,40 @@ namespace ComputeSharp.D2D1.Interop.Effects; /// unsafe partial struct PixelShaderEffect { -#if !NET6_0_OR_GREATER - /// - [UnmanagedFunctionPointer(CallingConvention.StdCall)] - private delegate int PropertyGetFunctionDelegate(IUnknown* effect, byte* data, uint dataSize, uint* actualSize); - - /// - [UnmanagedFunctionPointer(CallingConvention.StdCall)] - private delegate int PropertySetFunctionDelegate(IUnknown* effect, byte* data, uint dataSize); - - /// - /// A cached instance wrapping . - /// - private static readonly PropertyGetFunctionDelegate GetConstantBufferWrapper = GetConstantBufferImpl; - - /// - /// A cached instance wrapping . - /// - private static readonly PropertySetFunctionDelegate SetConstantBufferWrapper = SetConstantBufferImpl; - - /// - /// A cached instance wrapping . - /// - private static readonly PropertyGetFunctionDelegate GetTransformMapperWrapper = GetTransformMapperImpl; - - /// - /// A cached instance wrapping . - /// - private static readonly PropertySetFunctionDelegate SetTransformMapperWrapper = SetTransformMapperImpl; -#endif - /// /// Gets the get accessor for the constant buffer. /// -#if NET6_0_OR_GREATER public static delegate* unmanaged[Stdcall] GetConstantBuffer -#else - public static void* GetConstantBuffer -#endif { [MethodImpl(MethodImplOptions.AggressiveInlining)] -#if NET6_0_OR_GREATER get => &GetConstantBufferImpl; -#else - get => (void*)Marshal.GetFunctionPointerForDelegate(GetConstantBufferWrapper); -#endif } /// /// Gets the set accessor for the constant buffer. /// -#if NET6_0_OR_GREATER public static delegate* unmanaged[Stdcall] SetConstantBuffer -#else - public static void* SetConstantBuffer -#endif { [MethodImpl(MethodImplOptions.AggressiveInlining)] -#if NET6_0_OR_GREATER get => &SetConstantBufferImpl; -#else - get => (void*)Marshal.GetFunctionPointerForDelegate(SetConstantBufferWrapper); -#endif } /// /// Gets the get accessor for the transform mapper. /// -#if NET6_0_OR_GREATER public static delegate* unmanaged[Stdcall] GetTransformMapper -#else - public static void* GetTransformMapper -#endif { [MethodImpl(MethodImplOptions.AggressiveInlining)] -#if NET6_0_OR_GREATER get => &GetTransformMapperImpl; -#else - get => (void*)Marshal.GetFunctionPointerForDelegate(GetTransformMapperWrapper); -#endif } /// /// Gets the set accessor for the transform mapper. /// -#if NET6_0_OR_GREATER public static delegate* unmanaged[Stdcall] SetTransformMapper -#else - public static void* SetTransformMapper -#endif { [MethodImpl(MethodImplOptions.AggressiveInlining)] -#if NET6_0_OR_GREATER get => &SetTransformMapperImpl; -#else - get => (void*)Marshal.GetFunctionPointerForDelegate(SetTransformMapperWrapper); -#endif } /// diff --git a/src/ComputeSharp.D2D1/Shaders/Interop/Effects/PixelShaderEffect.Properties.g.cs b/src/ComputeSharp.D2D1/Shaders/Interop/Effects/PixelShaderEffect.Properties.g.cs index 6198dd5b..2f1c8cc3 100644 --- a/src/ComputeSharp.D2D1/Shaders/Interop/Effects/PixelShaderEffect.Properties.g.cs +++ b/src/ComputeSharp.D2D1/Shaders/Interop/Effects/PixelShaderEffect.Properties.g.cs @@ -1,7 +1,5 @@ using System.Runtime.CompilerServices; -#if !NET6_OR_GREATER using System.Runtime.InteropServices; -#endif using ComputeSharp.Win32; namespace ComputeSharp.D2D1.Interop.Effects; @@ -9,805 +7,387 @@ namespace ComputeSharp.D2D1.Interop.Effects; /// unsafe partial struct PixelShaderEffect { -#if !NET6_0_OR_GREATER - /// - /// A cached instance wrapping . - /// - private static readonly PropertyGetFunctionDelegate GetResourceTextureManager0Wrapper = GetResourceTextureManager0Impl; - - /// - /// A cached instance wrapping . - /// - private static readonly PropertySetFunctionDelegate SetResourceTextureManager0Wrapper = SetResourceTextureManager0Impl; - - /// - /// A cached instance wrapping . - /// - private static readonly PropertyGetFunctionDelegate GetResourceTextureManager1Wrapper = GetResourceTextureManager1Impl; - - /// - /// A cached instance wrapping . - /// - private static readonly PropertySetFunctionDelegate SetResourceTextureManager1Wrapper = SetResourceTextureManager1Impl; - - /// - /// A cached instance wrapping . - /// - private static readonly PropertyGetFunctionDelegate GetResourceTextureManager2Wrapper = GetResourceTextureManager2Impl; - - /// - /// A cached instance wrapping . - /// - private static readonly PropertySetFunctionDelegate SetResourceTextureManager2Wrapper = SetResourceTextureManager2Impl; - - /// - /// A cached instance wrapping . - /// - private static readonly PropertyGetFunctionDelegate GetResourceTextureManager3Wrapper = GetResourceTextureManager3Impl; - - /// - /// A cached instance wrapping . - /// - private static readonly PropertySetFunctionDelegate SetResourceTextureManager3Wrapper = SetResourceTextureManager3Impl; - - /// - /// A cached instance wrapping . - /// - private static readonly PropertyGetFunctionDelegate GetResourceTextureManager4Wrapper = GetResourceTextureManager4Impl; - - /// - /// A cached instance wrapping . - /// - private static readonly PropertySetFunctionDelegate SetResourceTextureManager4Wrapper = SetResourceTextureManager4Impl; - - /// - /// A cached instance wrapping . - /// - private static readonly PropertyGetFunctionDelegate GetResourceTextureManager5Wrapper = GetResourceTextureManager5Impl; - - /// - /// A cached instance wrapping . - /// - private static readonly PropertySetFunctionDelegate SetResourceTextureManager5Wrapper = SetResourceTextureManager5Impl; - - /// - /// A cached instance wrapping . - /// - private static readonly PropertyGetFunctionDelegate GetResourceTextureManager6Wrapper = GetResourceTextureManager6Impl; - - /// - /// A cached instance wrapping . - /// - private static readonly PropertySetFunctionDelegate SetResourceTextureManager6Wrapper = SetResourceTextureManager6Impl; - - /// - /// A cached instance wrapping . - /// - private static readonly PropertyGetFunctionDelegate GetResourceTextureManager7Wrapper = GetResourceTextureManager7Impl; - - /// - /// A cached instance wrapping . - /// - private static readonly PropertySetFunctionDelegate SetResourceTextureManager7Wrapper = SetResourceTextureManager7Impl; - - /// - /// A cached instance wrapping . - /// - private static readonly PropertyGetFunctionDelegate GetResourceTextureManager8Wrapper = GetResourceTextureManager8Impl; - - /// - /// A cached instance wrapping . - /// - private static readonly PropertySetFunctionDelegate SetResourceTextureManager8Wrapper = SetResourceTextureManager8Impl; - - /// - /// A cached instance wrapping . - /// - private static readonly PropertyGetFunctionDelegate GetResourceTextureManager9Wrapper = GetResourceTextureManager9Impl; - - /// - /// A cached instance wrapping . - /// - private static readonly PropertySetFunctionDelegate SetResourceTextureManager9Wrapper = SetResourceTextureManager9Impl; - - /// - /// A cached instance wrapping . - /// - private static readonly PropertyGetFunctionDelegate GetResourceTextureManager10Wrapper = GetResourceTextureManager10Impl; - - /// - /// A cached instance wrapping . - /// - private static readonly PropertySetFunctionDelegate SetResourceTextureManager10Wrapper = SetResourceTextureManager10Impl; - - /// - /// A cached instance wrapping . - /// - private static readonly PropertyGetFunctionDelegate GetResourceTextureManager11Wrapper = GetResourceTextureManager11Impl; - - /// - /// A cached instance wrapping . - /// - private static readonly PropertySetFunctionDelegate SetResourceTextureManager11Wrapper = SetResourceTextureManager11Impl; - - /// - /// A cached instance wrapping . - /// - private static readonly PropertyGetFunctionDelegate GetResourceTextureManager12Wrapper = GetResourceTextureManager12Impl; - - /// - /// A cached instance wrapping . - /// - private static readonly PropertySetFunctionDelegate SetResourceTextureManager12Wrapper = SetResourceTextureManager12Impl; - - /// - /// A cached instance wrapping . - /// - private static readonly PropertyGetFunctionDelegate GetResourceTextureManager13Wrapper = GetResourceTextureManager13Impl; - - /// - /// A cached instance wrapping . - /// - private static readonly PropertySetFunctionDelegate SetResourceTextureManager13Wrapper = SetResourceTextureManager13Impl; - - /// - /// A cached instance wrapping . - /// - private static readonly PropertyGetFunctionDelegate GetResourceTextureManager14Wrapper = GetResourceTextureManager14Impl; - - /// - /// A cached instance wrapping . - /// - private static readonly PropertySetFunctionDelegate SetResourceTextureManager14Wrapper = SetResourceTextureManager14Impl; - - /// - /// A cached instance wrapping . - /// - private static readonly PropertyGetFunctionDelegate GetResourceTextureManager15Wrapper = GetResourceTextureManager15Impl; - - /// - /// A cached instance wrapping . - /// - private static readonly PropertySetFunctionDelegate SetResourceTextureManager15Wrapper = SetResourceTextureManager15Impl; -#endif - /// /// Gets the get accessor for the resource manager at index 0. /// -#if NET6_0_OR_GREATER public static delegate* unmanaged[Stdcall] GetResourceTextureManager0 -#else - public static void* GetResourceTextureManager0 -#endif { [MethodImpl(MethodImplOptions.AggressiveInlining)] get { -#if NET6_0_OR_GREATER return &GetResourceTextureManager0Impl; -#else - return (void*)Marshal.GetFunctionPointerForDelegate(GetResourceTextureManager0Wrapper); -#endif } } /// /// Gets the set accessor for the resource manager at index 0. /// -#if NET6_0_OR_GREATER public static delegate* unmanaged[Stdcall] SetResourceTextureManager0 -#else - public static void* SetResourceTextureManager0 -#endif { [MethodImpl(MethodImplOptions.AggressiveInlining)] get { -#if NET6_0_OR_GREATER return &SetResourceTextureManager0Impl; -#else - return (void*)Marshal.GetFunctionPointerForDelegate(SetResourceTextureManager0Wrapper); -#endif } } /// /// Gets the get accessor for the resource manager at index 1. /// -#if NET6_0_OR_GREATER public static delegate* unmanaged[Stdcall] GetResourceTextureManager1 -#else - public static void* GetResourceTextureManager1 -#endif { [MethodImpl(MethodImplOptions.AggressiveInlining)] get { -#if NET6_0_OR_GREATER return &GetResourceTextureManager1Impl; -#else - return (void*)Marshal.GetFunctionPointerForDelegate(GetResourceTextureManager1Wrapper); -#endif } } /// /// Gets the set accessor for the resource manager at index 1. /// -#if NET6_0_OR_GREATER public static delegate* unmanaged[Stdcall] SetResourceTextureManager1 -#else - public static void* SetResourceTextureManager1 -#endif { [MethodImpl(MethodImplOptions.AggressiveInlining)] get { -#if NET6_0_OR_GREATER return &SetResourceTextureManager1Impl; -#else - return (void*)Marshal.GetFunctionPointerForDelegate(SetResourceTextureManager1Wrapper); -#endif } } /// /// Gets the get accessor for the resource manager at index 2. /// -#if NET6_0_OR_GREATER public static delegate* unmanaged[Stdcall] GetResourceTextureManager2 -#else - public static void* GetResourceTextureManager2 -#endif { [MethodImpl(MethodImplOptions.AggressiveInlining)] get { -#if NET6_0_OR_GREATER return &GetResourceTextureManager2Impl; -#else - return (void*)Marshal.GetFunctionPointerForDelegate(GetResourceTextureManager2Wrapper); -#endif } } /// /// Gets the set accessor for the resource manager at index 2. /// -#if NET6_0_OR_GREATER public static delegate* unmanaged[Stdcall] SetResourceTextureManager2 -#else - public static void* SetResourceTextureManager2 -#endif { [MethodImpl(MethodImplOptions.AggressiveInlining)] get { -#if NET6_0_OR_GREATER return &SetResourceTextureManager2Impl; -#else - return (void*)Marshal.GetFunctionPointerForDelegate(SetResourceTextureManager2Wrapper); -#endif } } /// /// Gets the get accessor for the resource manager at index 3. /// -#if NET6_0_OR_GREATER public static delegate* unmanaged[Stdcall] GetResourceTextureManager3 -#else - public static void* GetResourceTextureManager3 -#endif { [MethodImpl(MethodImplOptions.AggressiveInlining)] get { -#if NET6_0_OR_GREATER return &GetResourceTextureManager3Impl; -#else - return (void*)Marshal.GetFunctionPointerForDelegate(GetResourceTextureManager3Wrapper); -#endif } } /// /// Gets the set accessor for the resource manager at index 3. /// -#if NET6_0_OR_GREATER public static delegate* unmanaged[Stdcall] SetResourceTextureManager3 -#else - public static void* SetResourceTextureManager3 -#endif { [MethodImpl(MethodImplOptions.AggressiveInlining)] get { -#if NET6_0_OR_GREATER return &SetResourceTextureManager3Impl; -#else - return (void*)Marshal.GetFunctionPointerForDelegate(SetResourceTextureManager3Wrapper); -#endif } } /// /// Gets the get accessor for the resource manager at index 4. /// -#if NET6_0_OR_GREATER public static delegate* unmanaged[Stdcall] GetResourceTextureManager4 -#else - public static void* GetResourceTextureManager4 -#endif { [MethodImpl(MethodImplOptions.AggressiveInlining)] get { -#if NET6_0_OR_GREATER return &GetResourceTextureManager4Impl; -#else - return (void*)Marshal.GetFunctionPointerForDelegate(GetResourceTextureManager4Wrapper); -#endif } } /// /// Gets the set accessor for the resource manager at index 4. /// -#if NET6_0_OR_GREATER public static delegate* unmanaged[Stdcall] SetResourceTextureManager4 -#else - public static void* SetResourceTextureManager4 -#endif { [MethodImpl(MethodImplOptions.AggressiveInlining)] get { -#if NET6_0_OR_GREATER return &SetResourceTextureManager4Impl; -#else - return (void*)Marshal.GetFunctionPointerForDelegate(SetResourceTextureManager4Wrapper); -#endif } } /// /// Gets the get accessor for the resource manager at index 5. /// -#if NET6_0_OR_GREATER public static delegate* unmanaged[Stdcall] GetResourceTextureManager5 -#else - public static void* GetResourceTextureManager5 -#endif { [MethodImpl(MethodImplOptions.AggressiveInlining)] get { -#if NET6_0_OR_GREATER return &GetResourceTextureManager5Impl; -#else - return (void*)Marshal.GetFunctionPointerForDelegate(GetResourceTextureManager5Wrapper); -#endif } } /// /// Gets the set accessor for the resource manager at index 5. /// -#if NET6_0_OR_GREATER public static delegate* unmanaged[Stdcall] SetResourceTextureManager5 -#else - public static void* SetResourceTextureManager5 -#endif { [MethodImpl(MethodImplOptions.AggressiveInlining)] get { -#if NET6_0_OR_GREATER return &SetResourceTextureManager5Impl; -#else - return (void*)Marshal.GetFunctionPointerForDelegate(SetResourceTextureManager5Wrapper); -#endif } } /// /// Gets the get accessor for the resource manager at index 6. /// -#if NET6_0_OR_GREATER public static delegate* unmanaged[Stdcall] GetResourceTextureManager6 -#else - public static void* GetResourceTextureManager6 -#endif { [MethodImpl(MethodImplOptions.AggressiveInlining)] get { -#if NET6_0_OR_GREATER return &GetResourceTextureManager6Impl; -#else - return (void*)Marshal.GetFunctionPointerForDelegate(GetResourceTextureManager6Wrapper); -#endif } } /// /// Gets the set accessor for the resource manager at index 6. /// -#if NET6_0_OR_GREATER public static delegate* unmanaged[Stdcall] SetResourceTextureManager6 -#else - public static void* SetResourceTextureManager6 -#endif { [MethodImpl(MethodImplOptions.AggressiveInlining)] get { -#if NET6_0_OR_GREATER return &SetResourceTextureManager6Impl; -#else - return (void*)Marshal.GetFunctionPointerForDelegate(SetResourceTextureManager6Wrapper); -#endif } } /// /// Gets the get accessor for the resource manager at index 7. /// -#if NET6_0_OR_GREATER public static delegate* unmanaged[Stdcall] GetResourceTextureManager7 -#else - public static void* GetResourceTextureManager7 -#endif { [MethodImpl(MethodImplOptions.AggressiveInlining)] get { -#if NET6_0_OR_GREATER return &GetResourceTextureManager7Impl; -#else - return (void*)Marshal.GetFunctionPointerForDelegate(GetResourceTextureManager7Wrapper); -#endif } } /// /// Gets the set accessor for the resource manager at index 7. /// -#if NET6_0_OR_GREATER public static delegate* unmanaged[Stdcall] SetResourceTextureManager7 -#else - public static void* SetResourceTextureManager7 -#endif { [MethodImpl(MethodImplOptions.AggressiveInlining)] get { -#if NET6_0_OR_GREATER return &SetResourceTextureManager7Impl; -#else - return (void*)Marshal.GetFunctionPointerForDelegate(SetResourceTextureManager7Wrapper); -#endif } } /// /// Gets the get accessor for the resource manager at index 8. /// -#if NET6_0_OR_GREATER public static delegate* unmanaged[Stdcall] GetResourceTextureManager8 -#else - public static void* GetResourceTextureManager8 -#endif { [MethodImpl(MethodImplOptions.AggressiveInlining)] get { -#if NET6_0_OR_GREATER return &GetResourceTextureManager8Impl; -#else - return (void*)Marshal.GetFunctionPointerForDelegate(GetResourceTextureManager8Wrapper); -#endif } } /// /// Gets the set accessor for the resource manager at index 8. /// -#if NET6_0_OR_GREATER public static delegate* unmanaged[Stdcall] SetResourceTextureManager8 -#else - public static void* SetResourceTextureManager8 -#endif { [MethodImpl(MethodImplOptions.AggressiveInlining)] get { -#if NET6_0_OR_GREATER return &SetResourceTextureManager8Impl; -#else - return (void*)Marshal.GetFunctionPointerForDelegate(SetResourceTextureManager8Wrapper); -#endif } } /// /// Gets the get accessor for the resource manager at index 9. /// -#if NET6_0_OR_GREATER public static delegate* unmanaged[Stdcall] GetResourceTextureManager9 -#else - public static void* GetResourceTextureManager9 -#endif { [MethodImpl(MethodImplOptions.AggressiveInlining)] get { -#if NET6_0_OR_GREATER return &GetResourceTextureManager9Impl; -#else - return (void*)Marshal.GetFunctionPointerForDelegate(GetResourceTextureManager9Wrapper); -#endif } } /// /// Gets the set accessor for the resource manager at index 9. /// -#if NET6_0_OR_GREATER public static delegate* unmanaged[Stdcall] SetResourceTextureManager9 -#else - public static void* SetResourceTextureManager9 -#endif { [MethodImpl(MethodImplOptions.AggressiveInlining)] get { -#if NET6_0_OR_GREATER return &SetResourceTextureManager9Impl; -#else - return (void*)Marshal.GetFunctionPointerForDelegate(SetResourceTextureManager9Wrapper); -#endif } } /// /// Gets the get accessor for the resource manager at index 10. /// -#if NET6_0_OR_GREATER public static delegate* unmanaged[Stdcall] GetResourceTextureManager10 -#else - public static void* GetResourceTextureManager10 -#endif { [MethodImpl(MethodImplOptions.AggressiveInlining)] get { -#if NET6_0_OR_GREATER return &GetResourceTextureManager10Impl; -#else - return (void*)Marshal.GetFunctionPointerForDelegate(GetResourceTextureManager10Wrapper); -#endif } } /// /// Gets the set accessor for the resource manager at index 10. /// -#if NET6_0_OR_GREATER public static delegate* unmanaged[Stdcall] SetResourceTextureManager10 -#else - public static void* SetResourceTextureManager10 -#endif { [MethodImpl(MethodImplOptions.AggressiveInlining)] get { -#if NET6_0_OR_GREATER return &SetResourceTextureManager10Impl; -#else - return (void*)Marshal.GetFunctionPointerForDelegate(SetResourceTextureManager10Wrapper); -#endif } } /// /// Gets the get accessor for the resource manager at index 11. /// -#if NET6_0_OR_GREATER public static delegate* unmanaged[Stdcall] GetResourceTextureManager11 -#else - public static void* GetResourceTextureManager11 -#endif { [MethodImpl(MethodImplOptions.AggressiveInlining)] get { -#if NET6_0_OR_GREATER return &GetResourceTextureManager11Impl; -#else - return (void*)Marshal.GetFunctionPointerForDelegate(GetResourceTextureManager11Wrapper); -#endif } } /// /// Gets the set accessor for the resource manager at index 11. /// -#if NET6_0_OR_GREATER public static delegate* unmanaged[Stdcall] SetResourceTextureManager11 -#else - public static void* SetResourceTextureManager11 -#endif { [MethodImpl(MethodImplOptions.AggressiveInlining)] get { -#if NET6_0_OR_GREATER return &SetResourceTextureManager11Impl; -#else - return (void*)Marshal.GetFunctionPointerForDelegate(SetResourceTextureManager11Wrapper); -#endif } } /// /// Gets the get accessor for the resource manager at index 12. /// -#if NET6_0_OR_GREATER public static delegate* unmanaged[Stdcall] GetResourceTextureManager12 -#else - public static void* GetResourceTextureManager12 -#endif { [MethodImpl(MethodImplOptions.AggressiveInlining)] get { -#if NET6_0_OR_GREATER return &GetResourceTextureManager12Impl; -#else - return (void*)Marshal.GetFunctionPointerForDelegate(GetResourceTextureManager12Wrapper); -#endif } } /// /// Gets the set accessor for the resource manager at index 12. /// -#if NET6_0_OR_GREATER public static delegate* unmanaged[Stdcall] SetResourceTextureManager12 -#else - public static void* SetResourceTextureManager12 -#endif { [MethodImpl(MethodImplOptions.AggressiveInlining)] get { -#if NET6_0_OR_GREATER return &SetResourceTextureManager12Impl; -#else - return (void*)Marshal.GetFunctionPointerForDelegate(SetResourceTextureManager12Wrapper); -#endif } } /// /// Gets the get accessor for the resource manager at index 13. /// -#if NET6_0_OR_GREATER public static delegate* unmanaged[Stdcall] GetResourceTextureManager13 -#else - public static void* GetResourceTextureManager13 -#endif { [MethodImpl(MethodImplOptions.AggressiveInlining)] get { -#if NET6_0_OR_GREATER return &GetResourceTextureManager13Impl; -#else - return (void*)Marshal.GetFunctionPointerForDelegate(GetResourceTextureManager13Wrapper); -#endif } } /// /// Gets the set accessor for the resource manager at index 13. /// -#if NET6_0_OR_GREATER public static delegate* unmanaged[Stdcall] SetResourceTextureManager13 -#else - public static void* SetResourceTextureManager13 -#endif { [MethodImpl(MethodImplOptions.AggressiveInlining)] get { -#if NET6_0_OR_GREATER return &SetResourceTextureManager13Impl; -#else - return (void*)Marshal.GetFunctionPointerForDelegate(SetResourceTextureManager13Wrapper); -#endif } } /// /// Gets the get accessor for the resource manager at index 14. /// -#if NET6_0_OR_GREATER public static delegate* unmanaged[Stdcall] GetResourceTextureManager14 -#else - public static void* GetResourceTextureManager14 -#endif { [MethodImpl(MethodImplOptions.AggressiveInlining)] get { -#if NET6_0_OR_GREATER return &GetResourceTextureManager14Impl; -#else - return (void*)Marshal.GetFunctionPointerForDelegate(GetResourceTextureManager14Wrapper); -#endif } } /// /// Gets the set accessor for the resource manager at index 14. /// -#if NET6_0_OR_GREATER public static delegate* unmanaged[Stdcall] SetResourceTextureManager14 -#else - public static void* SetResourceTextureManager14 -#endif { [MethodImpl(MethodImplOptions.AggressiveInlining)] get { -#if NET6_0_OR_GREATER return &SetResourceTextureManager14Impl; -#else - return (void*)Marshal.GetFunctionPointerForDelegate(SetResourceTextureManager14Wrapper); -#endif } } /// /// Gets the get accessor for the resource manager at index 15. /// -#if NET6_0_OR_GREATER public static delegate* unmanaged[Stdcall] GetResourceTextureManager15 -#else - public static void* GetResourceTextureManager15 -#endif { [MethodImpl(MethodImplOptions.AggressiveInlining)] get { -#if NET6_0_OR_GREATER return &GetResourceTextureManager15Impl; -#else - return (void*)Marshal.GetFunctionPointerForDelegate(GetResourceTextureManager15Wrapper); -#endif } } /// /// Gets the set accessor for the resource manager at index 15. /// -#if NET6_0_OR_GREATER public static delegate* unmanaged[Stdcall] SetResourceTextureManager15 -#else - public static void* SetResourceTextureManager15 -#endif { [MethodImpl(MethodImplOptions.AggressiveInlining)] get { -#if NET6_0_OR_GREATER return &SetResourceTextureManager15Impl; -#else - return (void*)Marshal.GetFunctionPointerForDelegate(SetResourceTextureManager15Wrapper); -#endif } } diff --git a/src/ComputeSharp.D2D1/Shaders/Interop/Effects/PixelShaderEffect.Properties.tt b/src/ComputeSharp.D2D1/Shaders/Interop/Effects/PixelShaderEffect.Properties.tt index 9502ee6a..8f9e4325 100644 --- a/src/ComputeSharp.D2D1/Shaders/Interop/Effects/PixelShaderEffect.Properties.tt +++ b/src/ComputeSharp.D2D1/Shaders/Interop/Effects/PixelShaderEffect.Properties.tt @@ -2,9 +2,7 @@ <#@ assembly name="System.Core" #> <#@ output extension=".g.cs"#> using System.Runtime.CompilerServices; -#if !NET6_OR_GREATER using System.Runtime.InteropServices; -#endif using ComputeSharp.Win32; namespace ComputeSharp.D2D1.Interop.Effects; @@ -12,26 +10,6 @@ namespace ComputeSharp.D2D1.Interop.Effects; /// unsafe partial struct PixelShaderEffect { -#if !NET6_0_OR_GREATER -<# -for (int i = 0; i < 16; i++) -{ -#> - /// - /// A cached instance wrapping . - /// - private static readonly PropertyGetFunctionDelegate GetResourceTextureManager<#=i#>Wrapper = GetResourceTextureManager<#=i#>Impl; - - /// - /// A cached instance wrapping . - /// - private static readonly PropertySetFunctionDelegate SetResourceTextureManager<#=i#>Wrapper = SetResourceTextureManager<#=i#>Impl; -<# - if (i < 15) WriteLine(""); -} -#> -#endif - <# for (int i = 0; i < 16; i++) { @@ -39,40 +17,24 @@ for (int i = 0; i < 16; i++) /// /// Gets the get accessor for the resource manager at index <#=i#>. /// -#if NET6_0_OR_GREATER public static delegate* unmanaged[Stdcall] GetResourceTextureManager<#=i#> -#else - public static void* GetResourceTextureManager<#=i#> -#endif { [MethodImpl(MethodImplOptions.AggressiveInlining)] get { -#if NET6_0_OR_GREATER return &GetResourceTextureManager<#=i#>Impl; -#else - return (void*)Marshal.GetFunctionPointerForDelegate(GetResourceTextureManager<#=i#>Wrapper); -#endif } } /// /// Gets the set accessor for the resource manager at index <#=i#>. /// -#if NET6_0_OR_GREATER public static delegate* unmanaged[Stdcall] SetResourceTextureManager<#=i#> -#else - public static void* SetResourceTextureManager<#=i#> -#endif { [MethodImpl(MethodImplOptions.AggressiveInlining)] get { -#if NET6_0_OR_GREATER return &SetResourceTextureManager<#=i#>Impl; -#else - return (void*)Marshal.GetFunctionPointerForDelegate(SetResourceTextureManager<#=i#>Wrapper); -#endif } } diff --git a/src/ComputeSharp.D2D1/Shaders/Interop/Effects/PixelShaderEffect.cs b/src/ComputeSharp.D2D1/Shaders/Interop/Effects/PixelShaderEffect.cs index eba06e98..3c411ee8 100644 --- a/src/ComputeSharp.D2D1/Shaders/Interop/Effects/PixelShaderEffect.cs +++ b/src/ComputeSharp.D2D1/Shaders/Interop/Effects/PixelShaderEffect.cs @@ -12,20 +12,6 @@ namespace ComputeSharp.D2D1.Interop.Effects; /// internal unsafe partial struct PixelShaderEffect { -#if !NET6_0_OR_GREATER - /// - [UnmanagedFunctionPointer(CallingConvention.StdCall)] - private delegate int QueryInterfaceDelegate(PixelShaderEffect* @this, Guid* riid, void** ppvObject); - - /// - [UnmanagedFunctionPointer(CallingConvention.StdCall)] - private delegate uint AddRefDelegate(PixelShaderEffect* @this); - - /// - [UnmanagedFunctionPointer(CallingConvention.StdCall)] - private delegate uint ReleaseDelegate(PixelShaderEffect* @this); -#endif - /// /// The shared vtable pointer for instance, for . /// @@ -45,24 +31,14 @@ internal unsafe partial struct PixelShaderEffect void** lpVtbl = (void**)D2D1AssemblyAssociatedMemory.Allocate(sizeof(void*) * 14); // ID2D1EffectImpl -#if NET6_0_OR_GREATER lpVtbl[0] = (delegate* unmanaged)&ID2D1EffectImplMethods.QueryInterface; lpVtbl[1] = (delegate* unmanaged)&ID2D1EffectImplMethods.AddRef; lpVtbl[2] = (delegate* unmanaged)&ID2D1EffectImplMethods.Release; lpVtbl[3] = (delegate* unmanaged)&ID2D1EffectImplMethods.Initialize; lpVtbl[4] = (delegate* unmanaged)&ID2D1EffectImplMethods.PrepareForRender; lpVtbl[5] = (delegate* unmanaged)&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)&ID2D1DrawTransformMethods.QueryInterface; lpVtbl[6 + 1] = (delegate* unmanaged)&ID2D1DrawTransformMethods.AddRef; lpVtbl[6 + 2] = (delegate* unmanaged)&ID2D1DrawTransformMethods.Release; @@ -71,16 +47,6 @@ internal unsafe partial struct PixelShaderEffect lpVtbl[6 + 5] = (delegate* unmanaged)&ID2D1DrawTransformMethods.MapInputRectsToOutputRect; lpVtbl[6 + 6] = (delegate* unmanaged)&ID2D1DrawTransformMethods.MapInvalidRect; lpVtbl[6 + 7] = (delegate* unmanaged)&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 return lpVtbl; } diff --git a/src/ComputeSharp.D2D1/Shaders/Interop/Effects/ResourceManagers/D2D1ResourceTextureManagerImpl.ID2D1ResourceTextureManager.cs b/src/ComputeSharp.D2D1/Shaders/Interop/Effects/ResourceManagers/D2D1ResourceTextureManagerImpl.ID2D1ResourceTextureManager.cs index dd6ed705..b71c856a 100644 --- a/src/ComputeSharp.D2D1/Shaders/Interop/Effects/ResourceManagers/D2D1ResourceTextureManagerImpl.ID2D1ResourceTextureManager.cs +++ b/src/ComputeSharp.D2D1/Shaders/Interop/Effects/ResourceManagers/D2D1ResourceTextureManagerImpl.ID2D1ResourceTextureManager.cs @@ -124,54 +124,6 @@ unsafe partial struct D2D1ResourceTextureManagerImpl /// private static class ID2D1ResourceTextureManagerMethods { -#if !NET6_0_OR_GREATER - /// - [UnmanagedFunctionPointer(CallingConvention.StdCall)] - public delegate int InitializeDelegate( - D2D1ResourceTextureManagerImpl* @this, - Guid* resourceId, - D2D1_RESOURCE_TEXTURE_PROPERTIES* resourceTextureProperties, - byte* data, - uint* strides, - uint dataSize); - - /// - [UnmanagedFunctionPointer(CallingConvention.StdCall)] - public delegate int UpdateDelegate( - D2D1ResourceTextureManagerImpl* @this, - uint* minimumExtents, - uint* maximimumExtents, - uint* strides, - uint dimensions, - byte* data, - uint dataCount); - - /// - /// A cached instance wrapping . - /// - public static readonly QueryInterfaceDelegate QueryInterfaceWrapper = QueryInterface; - - /// - /// A cached instance wrapping . - /// - public static readonly AddRefDelegate AddRefWrapper = AddRef; - - /// - /// A cached instance wrapping . - /// - public static readonly ReleaseDelegate ReleaseWrapper = Release; - - /// - /// A cached instance wrapping . - /// - public static readonly InitializeDelegate InitializeWrapper = Initialize; - - /// - /// A cached instance wrapping . - /// - public static readonly UpdateDelegate UpdateWrapper = Update; -#endif - /// [UnmanagedCallersOnly] public static int QueryInterface(D2D1ResourceTextureManagerImpl* @this, Guid* riid, void** ppvObject) diff --git a/src/ComputeSharp.D2D1/Shaders/Interop/Effects/ResourceManagers/D2D1ResourceTextureManagerImpl.ID2D1ResourceTextureManagerInternal.cs b/src/ComputeSharp.D2D1/Shaders/Interop/Effects/ResourceManagers/D2D1ResourceTextureManagerImpl.ID2D1ResourceTextureManagerInternal.cs index 0255ea8a..4e31ccc5 100644 --- a/src/ComputeSharp.D2D1/Shaders/Interop/Effects/ResourceManagers/D2D1ResourceTextureManagerImpl.ID2D1ResourceTextureManagerInternal.cs +++ b/src/ComputeSharp.D2D1/Shaders/Interop/Effects/ResourceManagers/D2D1ResourceTextureManagerImpl.ID2D1ResourceTextureManagerInternal.cs @@ -13,41 +13,6 @@ partial struct D2D1ResourceTextureManagerImpl /// private static unsafe class ID2D1ResourceTextureManagerInternalMethods { -#if !NET6_0_OR_GREATER - /// - [UnmanagedFunctionPointer(CallingConvention.StdCall)] - public delegate int InitializeDelegate(D2D1ResourceTextureManagerImpl* @this, ID2D1EffectContext* effectContext, uint* dimensions); - - /// - [UnmanagedFunctionPointer(CallingConvention.StdCall)] - public delegate int GetResourceTextureDelegate(D2D1ResourceTextureManagerImpl* @this, ID2D1ResourceTexture** resourceTexture); - - /// - /// A cached instance wrapping . - /// - public static readonly QueryInterfaceDelegate QueryInterfaceWrapper = QueryInterface; - - /// - /// A cached instance wrapping . - /// - public static readonly AddRefDelegate AddRefWrapper = AddRef; - - /// - /// A cached instance wrapping . - /// - public static readonly ReleaseDelegate ReleaseWrapper = Release; - - /// - /// A cached instance wrapping . - /// - public static readonly InitializeDelegate InitializeWrapper = Initialize; - - /// - /// A cached instance wrapping . - /// - public static readonly GetResourceTextureDelegate GetResourceTextureWrapper = GetResourceTexture; -#endif - /// [UnmanagedCallersOnly] public static int QueryInterface(D2D1ResourceTextureManagerImpl* @this, Guid* riid, void** ppvObject) diff --git a/src/ComputeSharp.D2D1/Shaders/Interop/Effects/ResourceManagers/D2D1ResourceTextureManagerImpl.cs b/src/ComputeSharp.D2D1/Shaders/Interop/Effects/ResourceManagers/D2D1ResourceTextureManagerImpl.cs index 735978aa..83482269 100644 --- a/src/ComputeSharp.D2D1/Shaders/Interop/Effects/ResourceManagers/D2D1ResourceTextureManagerImpl.cs +++ b/src/ComputeSharp.D2D1/Shaders/Interop/Effects/ResourceManagers/D2D1ResourceTextureManagerImpl.cs @@ -12,20 +12,6 @@ namespace ComputeSharp.D2D1.Shaders.Interop.Effects.ResourceManagers; /// internal unsafe partial struct D2D1ResourceTextureManagerImpl { -#if !NET6_0_OR_GREATER - /// - [UnmanagedFunctionPointer(CallingConvention.StdCall)] - private delegate int QueryInterfaceDelegate(D2D1ResourceTextureManagerImpl* @this, Guid* riid, void** ppvObject); - - /// - [UnmanagedFunctionPointer(CallingConvention.StdCall)] - private delegate uint AddRefDelegate(D2D1ResourceTextureManagerImpl* @this); - - /// - [UnmanagedFunctionPointer(CallingConvention.StdCall)] - private delegate uint ReleaseDelegate(D2D1ResourceTextureManagerImpl* @this); -#endif - /// /// The shared vtable pointer for instance, for . /// @@ -45,34 +31,18 @@ internal unsafe partial struct D2D1ResourceTextureManagerImpl void** lpVtbl = (void**)D2D1AssemblyAssociatedMemory.Allocate(sizeof(void*) * 10); // ID2D1ResourceTextureManager -#if NET6_0_OR_GREATER lpVtbl[0] = (delegate* unmanaged)&ID2D1ResourceTextureManagerMethods.QueryInterface; lpVtbl[1] = (delegate* unmanaged)&ID2D1ResourceTextureManagerMethods.AddRef; lpVtbl[2] = (delegate* unmanaged)&ID2D1ResourceTextureManagerMethods.Release; lpVtbl[3] = (delegate* unmanaged)&ID2D1ResourceTextureManagerMethods.Initialize; lpVtbl[4] = (delegate* unmanaged)&ID2D1ResourceTextureManagerMethods.Update; -#else - lpVtbl[0] = (void*)Marshal.GetFunctionPointerForDelegate(ID2D1ResourceTextureManagerMethods.QueryInterfaceWrapper); - lpVtbl[1] = (void*)Marshal.GetFunctionPointerForDelegate(ID2D1ResourceTextureManagerMethods.AddRefWrapper); - lpVtbl[2] = (void*)Marshal.GetFunctionPointerForDelegate(ID2D1ResourceTextureManagerMethods.ReleaseWrapper); - lpVtbl[3] = (void*)Marshal.GetFunctionPointerForDelegate(ID2D1ResourceTextureManagerMethods.InitializeWrapper); - lpVtbl[4] = (void*)Marshal.GetFunctionPointerForDelegate(ID2D1ResourceTextureManagerMethods.UpdateWrapper); -#endif // ID2D1ResourceTextureManagerInternal -#if NET6_0_OR_GREATER lpVtbl[5 + 0] = (delegate* unmanaged)&ID2D1ResourceTextureManagerInternalMethods.QueryInterface; lpVtbl[5 + 1] = (delegate* unmanaged)&ID2D1ResourceTextureManagerInternalMethods.AddRef; lpVtbl[5 + 2] = (delegate* unmanaged)&ID2D1ResourceTextureManagerInternalMethods.Release; lpVtbl[5 + 3] = (delegate* unmanaged)&ID2D1ResourceTextureManagerInternalMethods.Initialize; lpVtbl[5 + 4] = (delegate* unmanaged)&ID2D1ResourceTextureManagerInternalMethods.GetResourceTexture; -#else - lpVtbl[5 + 0] = (void*)Marshal.GetFunctionPointerForDelegate(ID2D1ResourceTextureManagerInternalMethods.QueryInterfaceWrapper); - lpVtbl[5 + 1] = (void*)Marshal.GetFunctionPointerForDelegate(ID2D1ResourceTextureManagerInternalMethods.AddRefWrapper); - lpVtbl[5 + 2] = (void*)Marshal.GetFunctionPointerForDelegate(ID2D1ResourceTextureManagerInternalMethods.ReleaseWrapper); - lpVtbl[5 + 3] = (void*)Marshal.GetFunctionPointerForDelegate(ID2D1ResourceTextureManagerInternalMethods.InitializeWrapper); - lpVtbl[5 + 4] = (void*)Marshal.GetFunctionPointerForDelegate(ID2D1ResourceTextureManagerInternalMethods.GetResourceTextureWrapper); -#endif return lpVtbl; } diff --git a/src/ComputeSharp.D2D1/Shaders/Interop/Effects/TransformMappers/D2D1DrawInfoUpdateContextImpl.ID2D1DrawInfoUpdateContex.cs b/src/ComputeSharp.D2D1/Shaders/Interop/Effects/TransformMappers/D2D1DrawInfoUpdateContextImpl.ID2D1DrawInfoUpdateContex.cs index 49bf8974..afceb039 100644 --- a/src/ComputeSharp.D2D1/Shaders/Interop/Effects/TransformMappers/D2D1DrawInfoUpdateContextImpl.ID2D1DrawInfoUpdateContex.cs +++ b/src/ComputeSharp.D2D1/Shaders/Interop/Effects/TransformMappers/D2D1DrawInfoUpdateContextImpl.ID2D1DrawInfoUpdateContex.cs @@ -12,50 +12,6 @@ partial struct D2D1DrawInfoUpdateContextImpl /// private static unsafe class ID2D1DrawInfoUpdateContextMethods { -#if !NET6_0_OR_GREATER - /// - [UnmanagedFunctionPointer(CallingConvention.StdCall)] - public delegate int GetConstantBufferSizeDelegate(D2D1DrawInfoUpdateContextImpl* @this, uint* size); - - /// - [UnmanagedFunctionPointer(CallingConvention.StdCall)] - public delegate int GetConstantBufferDelegate(D2D1DrawInfoUpdateContextImpl* @this, byte* buffer, uint bufferCount); - - /// - [UnmanagedFunctionPointer(CallingConvention.StdCall)] - public delegate int SetConstantBufferDelegate(D2D1DrawInfoUpdateContextImpl* @this, byte* buffer, uint bufferCount); - - /// - /// A cached instance wrapping . - /// - public static readonly QueryInterfaceDelegate QueryInterfaceWrapper = QueryInterface; - - /// - /// A cached instance wrapping . - /// - public static readonly AddRefDelegate AddRefWrapper = AddRef; - - /// - /// A cached instance wrapping . - /// - public static readonly ReleaseDelegate ReleaseWrapper = Release; - - /// - /// A cached instance wrapping . - /// - public static readonly GetConstantBufferSizeDelegate GetConstantBufferSizeWrapper = GetConstantBufferSize; - - /// - /// A cached instance wrapping . - /// - public static readonly GetConstantBufferDelegate GetConstantBufferWrapper = GetConstantBuffer; - - /// - /// A cached instance wrapping . - /// - public static readonly SetConstantBufferDelegate SetConstantBufferWrapper = SetConstantBuffer; -#endif - /// [UnmanagedCallersOnly] public static int QueryInterface(D2D1DrawInfoUpdateContextImpl* @this, Guid* riid, void** ppvObject) diff --git a/src/ComputeSharp.D2D1/Shaders/Interop/Effects/TransformMappers/D2D1DrawInfoUpdateContextImpl.ID2D1DrawInfoUpdateContexInternal.cs b/src/ComputeSharp.D2D1/Shaders/Interop/Effects/TransformMappers/D2D1DrawInfoUpdateContextImpl.ID2D1DrawInfoUpdateContexInternal.cs index 13e11c6c..9063310e 100644 --- a/src/ComputeSharp.D2D1/Shaders/Interop/Effects/TransformMappers/D2D1DrawInfoUpdateContextImpl.ID2D1DrawInfoUpdateContexInternal.cs +++ b/src/ComputeSharp.D2D1/Shaders/Interop/Effects/TransformMappers/D2D1DrawInfoUpdateContextImpl.ID2D1DrawInfoUpdateContexInternal.cs @@ -20,32 +20,6 @@ unsafe partial struct D2D1DrawInfoUpdateContextImpl /// private static class ID2D1DrawInfoUpdateContextInternalMethods { -#if !NET6_0_OR_GREATER - /// - [UnmanagedFunctionPointer(CallingConvention.StdCall)] - public delegate int CloseDelegate(D2D1DrawInfoUpdateContextImpl* @this); - - /// - /// A cached instance wrapping . - /// - public static readonly QueryInterfaceDelegate QueryInterfaceWrapper = QueryInterface; - - /// - /// A cached instance wrapping . - /// - public static readonly AddRefDelegate AddRefWrapper = AddRef; - - /// - /// A cached instance wrapping . - /// - public static readonly ReleaseDelegate ReleaseWrapper = Release; - - /// - /// A cached instance wrapping . - /// - public static readonly CloseDelegate CloseWrapper = Close; -#endif - /// [UnmanagedCallersOnly] public static int QueryInterface(D2D1DrawInfoUpdateContextImpl* @this, Guid* riid, void** ppvObject) diff --git a/src/ComputeSharp.D2D1/Shaders/Interop/Effects/TransformMappers/D2D1DrawInfoUpdateContextImpl.cs b/src/ComputeSharp.D2D1/Shaders/Interop/Effects/TransformMappers/D2D1DrawInfoUpdateContextImpl.cs index 55ee583f..b9a7272a 100644 --- a/src/ComputeSharp.D2D1/Shaders/Interop/Effects/TransformMappers/D2D1DrawInfoUpdateContextImpl.cs +++ b/src/ComputeSharp.D2D1/Shaders/Interop/Effects/TransformMappers/D2D1DrawInfoUpdateContextImpl.cs @@ -12,20 +12,6 @@ namespace ComputeSharp.D2D1.Shaders.Interop.Effects.TransformMappers; /// internal unsafe partial struct D2D1DrawInfoUpdateContextImpl { -#if !NET6_0_OR_GREATER - /// - [UnmanagedFunctionPointer(CallingConvention.StdCall)] - private delegate int QueryInterfaceDelegate(D2D1DrawInfoUpdateContextImpl* @this, Guid* riid, void** ppvObject); - - /// - [UnmanagedFunctionPointer(CallingConvention.StdCall)] - private delegate uint AddRefDelegate(D2D1DrawInfoUpdateContextImpl* @this); - - /// - [UnmanagedFunctionPointer(CallingConvention.StdCall)] - private delegate uint ReleaseDelegate(D2D1DrawInfoUpdateContextImpl* @this); -#endif - /// /// The shared vtable pointer for instance, for . /// @@ -45,34 +31,18 @@ internal unsafe partial struct D2D1DrawInfoUpdateContextImpl void** lpVtbl = (void**)D2D1AssemblyAssociatedMemory.Allocate(sizeof(void*) * 10); // ID2D1ResourceTextureManager -#if NET6_0_OR_GREATER lpVtbl[0] = (delegate* unmanaged)&ID2D1DrawInfoUpdateContextMethods.QueryInterface; lpVtbl[1] = (delegate* unmanaged)&ID2D1DrawInfoUpdateContextMethods.AddRef; lpVtbl[2] = (delegate* unmanaged)&ID2D1DrawInfoUpdateContextMethods.Release; lpVtbl[3] = (delegate* unmanaged)&ID2D1DrawInfoUpdateContextMethods.GetConstantBufferSize; lpVtbl[4] = (delegate* unmanaged)&ID2D1DrawInfoUpdateContextMethods.GetConstantBuffer; lpVtbl[5] = (delegate* unmanaged)&ID2D1DrawInfoUpdateContextMethods.SetConstantBuffer; -#else - lpVtbl[0] = (void*)Marshal.GetFunctionPointerForDelegate(ID2D1DrawInfoUpdateContextMethods.QueryInterfaceWrapper); - lpVtbl[1] = (void*)Marshal.GetFunctionPointerForDelegate(ID2D1DrawInfoUpdateContextMethods.AddRefWrapper); - lpVtbl[2] = (void*)Marshal.GetFunctionPointerForDelegate(ID2D1DrawInfoUpdateContextMethods.ReleaseWrapper); - lpVtbl[3] = (void*)Marshal.GetFunctionPointerForDelegate(ID2D1DrawInfoUpdateContextMethods.GetConstantBufferSizeWrapper); - lpVtbl[4] = (void*)Marshal.GetFunctionPointerForDelegate(ID2D1DrawInfoUpdateContextMethods.GetConstantBufferWrapper); - lpVtbl[5] = (void*)Marshal.GetFunctionPointerForDelegate(ID2D1DrawInfoUpdateContextMethods.SetConstantBufferWrapper); -#endif // ID2D1ResourceTextureManagerInternal -#if NET6_0_OR_GREATER lpVtbl[6 + 0] = (delegate* unmanaged)&ID2D1DrawInfoUpdateContextInternalMethods.QueryInterface; lpVtbl[6 + 1] = (delegate* unmanaged)&ID2D1DrawInfoUpdateContextInternalMethods.AddRef; lpVtbl[6 + 2] = (delegate* unmanaged)&ID2D1DrawInfoUpdateContextInternalMethods.Release; lpVtbl[6 + 3] = (delegate* unmanaged)&ID2D1DrawInfoUpdateContextInternalMethods.Close; -#else - lpVtbl[6 + 0] = (void*)Marshal.GetFunctionPointerForDelegate(ID2D1DrawInfoUpdateContextInternalMethods.QueryInterfaceWrapper); - lpVtbl[6 + 1] = (void*)Marshal.GetFunctionPointerForDelegate(ID2D1DrawInfoUpdateContextInternalMethods.AddRefWrapper); - lpVtbl[6 + 2] = (void*)Marshal.GetFunctionPointerForDelegate(ID2D1DrawInfoUpdateContextInternalMethods.ReleaseWrapper); - lpVtbl[6 + 3] = (void*)Marshal.GetFunctionPointerForDelegate(ID2D1DrawInfoUpdateContextInternalMethods.CloseWrapper); -#endif return lpVtbl; } diff --git a/src/ComputeSharp.D2D1/Shaders/Interop/Effects/TransformMappers/D2D1TransformMapperImpl.ID2D1TransformMapper.cs b/src/ComputeSharp.D2D1/Shaders/Interop/Effects/TransformMappers/D2D1TransformMapperImpl.ID2D1TransformMapper.cs index f1c2652a..d86241e0 100644 --- a/src/ComputeSharp.D2D1/Shaders/Interop/Effects/TransformMappers/D2D1TransformMapperImpl.ID2D1TransformMapper.cs +++ b/src/ComputeSharp.D2D1/Shaders/Interop/Effects/TransformMappers/D2D1TransformMapperImpl.ID2D1TransformMapper.cs @@ -16,65 +16,6 @@ unsafe partial struct D2D1TransformMapperImpl /// private static class ID2D1TransformMapperMethods { -#if !NET6_0_OR_GREATER - /// - [UnmanagedFunctionPointer(CallingConvention.StdCall)] - public delegate int MapInputRectsToOutputRectDelegate( - D2D1TransformMapperImpl* @this, - ID2D1DrawInfoUpdateContext* d2D1DrawInfoUpdateContext, - RECT* inputRects, - RECT* inputOpaqueSubRects, - uint inputRectCount, - RECT* outputRect, - RECT* outputOpaqueSubRect); - - /// - [UnmanagedFunctionPointer(CallingConvention.StdCall)] - public delegate int MapOutputRectToInputRectsDelegate( - D2D1TransformMapperImpl* @this, - RECT* outputRect, - RECT* inputRects, - uint inputRectsCount); - - /// - [UnmanagedFunctionPointer(CallingConvention.StdCall)] - public delegate int MapInvalidRectDelegate( - D2D1TransformMapperImpl* @this, - uint inputIndex, - RECT invalidInputRect, - RECT* invalidOutputRect); - - /// - /// A cached instance wrapping . - /// - public static readonly QueryInterfaceDelegate QueryInterfaceWrapper = QueryInterface; - - /// - /// A cached instance wrapping . - /// - public static readonly AddRefDelegate AddRefWrapper = AddRef; - - /// - /// A cached instance wrapping . - /// - public static readonly ReleaseDelegate ReleaseWrapper = Release; - - /// - /// A cached instance wrapping . - /// - public static readonly MapInputRectsToOutputRectDelegate MapInputRectsToOutputRectWrapper = MapInputRectsToOutputRect; - - /// - /// A cached instance wrapping . - /// - public static readonly MapOutputRectToInputRectsDelegate MapOutputRectToInputRectsWrapper = MapOutputRectToInputRects; - - /// - /// A cached instance wrapping . - /// - public static readonly MapInvalidRectDelegate MapInvalidRectWrapper = MapInvalidRect; -#endif - /// [UnmanagedCallersOnly] public static int QueryInterface(D2D1TransformMapperImpl* @this, Guid* riid, void** ppvObject) diff --git a/src/ComputeSharp.D2D1/Shaders/Interop/Effects/TransformMappers/D2D1TransformMapperImpl.ID2D1TransformMapperInternal.cs b/src/ComputeSharp.D2D1/Shaders/Interop/Effects/TransformMappers/D2D1TransformMapperImpl.ID2D1TransformMapperInternal.cs index 8d5d355e..0eb493bb 100644 --- a/src/ComputeSharp.D2D1/Shaders/Interop/Effects/TransformMappers/D2D1TransformMapperImpl.ID2D1TransformMapperInternal.cs +++ b/src/ComputeSharp.D2D1/Shaders/Interop/Effects/TransformMappers/D2D1TransformMapperImpl.ID2D1TransformMapperInternal.cs @@ -12,32 +12,6 @@ unsafe partial struct D2D1TransformMapperImpl /// private static class ID2D1TransformMapperInternalMethods { -#if !NET6_0_OR_GREATER - /// - [UnmanagedFunctionPointer(CallingConvention.StdCall)] - public delegate int GetManagedWrapperHandleDelegate(D2D1TransformMapperImpl* @this, void** ppvHandle); - - /// - /// A cached instance wrapping . - /// - public static readonly QueryInterfaceDelegate QueryInterfaceWrapper = QueryInterface; - - /// - /// A cached instance wrapping . - /// - public static readonly AddRefDelegate AddRefWrapper = AddRef; - - /// - /// A cached instance wrapping . - /// - public static readonly ReleaseDelegate ReleaseWrapper = Release; - - /// - /// A cached instance wrapping . - /// - public static readonly GetManagedWrapperHandleDelegate GetManagedWrapperHandleWrapper = GetManagedWrapperHandle; -#endif - /// [UnmanagedCallersOnly] public static int QueryInterface(D2D1TransformMapperImpl* @this, Guid* riid, void** ppvObject) diff --git a/src/ComputeSharp.D2D1/Shaders/Interop/Effects/TransformMappers/D2D1TransformMapperImpl.cs b/src/ComputeSharp.D2D1/Shaders/Interop/Effects/TransformMappers/D2D1TransformMapperImpl.cs index e146cc65..d6177ae8 100644 --- a/src/ComputeSharp.D2D1/Shaders/Interop/Effects/TransformMappers/D2D1TransformMapperImpl.cs +++ b/src/ComputeSharp.D2D1/Shaders/Interop/Effects/TransformMappers/D2D1TransformMapperImpl.cs @@ -14,20 +14,6 @@ namespace ComputeSharp.D2D1.Shaders.Interop.Effects.TransformMappers; /// internal unsafe partial struct D2D1TransformMapperImpl { -#if !NET6_0_OR_GREATER - /// - [UnmanagedFunctionPointer(CallingConvention.StdCall)] - private delegate int QueryInterfaceDelegate(D2D1TransformMapperImpl* @this, Guid* riid, void** ppvObject); - - /// - [UnmanagedFunctionPointer(CallingConvention.StdCall)] - private delegate uint AddRefDelegate(D2D1TransformMapperImpl* @this); - - /// - [UnmanagedFunctionPointer(CallingConvention.StdCall)] - private delegate uint ReleaseDelegate(D2D1TransformMapperImpl* @this); -#endif - /// /// The shared vtable pointer for instance, for . /// @@ -47,34 +33,18 @@ internal unsafe partial struct D2D1TransformMapperImpl void** lpVtbl = (void**)D2D1AssemblyAssociatedMemory.Allocate(sizeof(void*) * 10); // ID2D1ResourceTextureManager -#if NET6_0_OR_GREATER lpVtbl[0] = (delegate* unmanaged)&ID2D1TransformMapperMethods.QueryInterface; lpVtbl[1] = (delegate* unmanaged)&ID2D1TransformMapperMethods.AddRef; lpVtbl[2] = (delegate* unmanaged)&ID2D1TransformMapperMethods.Release; lpVtbl[3] = (delegate* unmanaged)&ID2D1TransformMapperMethods.MapInputRectsToOutputRect; lpVtbl[4] = (delegate* unmanaged)&ID2D1TransformMapperMethods.MapOutputRectToInputRects; lpVtbl[5] = (delegate* unmanaged)&ID2D1TransformMapperMethods.MapInvalidRect; -#else - lpVtbl[0] = (void*)Marshal.GetFunctionPointerForDelegate(ID2D1TransformMapperMethods.QueryInterfaceWrapper); - lpVtbl[1] = (void*)Marshal.GetFunctionPointerForDelegate(ID2D1TransformMapperMethods.AddRefWrapper); - lpVtbl[2] = (void*)Marshal.GetFunctionPointerForDelegate(ID2D1TransformMapperMethods.ReleaseWrapper); - lpVtbl[3] = (void*)Marshal.GetFunctionPointerForDelegate(ID2D1TransformMapperMethods.MapInputRectsToOutputRectWrapper); - lpVtbl[4] = (void*)Marshal.GetFunctionPointerForDelegate(ID2D1TransformMapperMethods.MapOutputRectToInputRectsWrapper); - lpVtbl[5] = (void*)Marshal.GetFunctionPointerForDelegate(ID2D1TransformMapperMethods.MapInvalidRectWrapper); -#endif // ID2D1TransformMapperInternal -#if NET6_0_OR_GREATER lpVtbl[6 + 0] = (delegate* unmanaged)&ID2D1TransformMapperInternalMethods.QueryInterface; lpVtbl[6 + 1] = (delegate* unmanaged)&ID2D1TransformMapperInternalMethods.AddRef; lpVtbl[6 + 2] = (delegate* unmanaged)&ID2D1TransformMapperInternalMethods.Release; lpVtbl[6 + 3] = (delegate* unmanaged)&ID2D1TransformMapperInternalMethods.GetManagedWrapperHandle; -#else - lpVtbl[6 + 0] = (void*)Marshal.GetFunctionPointerForDelegate(ID2D1TransformMapperInternalMethods.QueryInterfaceWrapper); - lpVtbl[6 + 1] = (void*)Marshal.GetFunctionPointerForDelegate(ID2D1TransformMapperInternalMethods.AddRefWrapper); - lpVtbl[6 + 2] = (void*)Marshal.GetFunctionPointerForDelegate(ID2D1TransformMapperInternalMethods.ReleaseWrapper); - lpVtbl[6 + 3] = (void*)Marshal.GetFunctionPointerForDelegate(ID2D1TransformMapperInternalMethods.GetManagedWrapperHandleWrapper); -#endif return lpVtbl; } diff --git a/src/ComputeSharp.Win32.D2D1/DirectX/um/d2d1_1/ID2D1Factory1.cs b/src/ComputeSharp.Win32.D2D1/DirectX/um/d2d1_1/ID2D1Factory1.cs index 13eaef7a..d53395cd 100644 --- a/src/ComputeSharp.Win32.D2D1/DirectX/um/d2d1_1/ID2D1Factory1.cs +++ b/src/ComputeSharp.Win32.D2D1/DirectX/um/d2d1_1/ID2D1Factory1.cs @@ -20,15 +20,8 @@ internal unsafe partial struct ID2D1Factory1 [MethodImpl(MethodImplOptions.AggressiveInlining)] [VtblIndex(23)] -#if NET6_0_OR_GREATER - public HRESULT RegisterEffectFromString([NativeTypeName("const IID &")] Guid* classId, [NativeTypeName("PCWSTR")] ushort* propertyXml, [NativeTypeName("const D2D1_PROPERTY_BINDING *")] D2D1_PROPERTY_BINDING* bindings, [NativeTypeName("UINT32")] uint bindingsCount, [NativeTypeName("const PD2D1_EFFECT_FACTORY")] delegate* unmanaged[Stdcall] effectFactory) + public HRESULT RegisterEffectFromString([NativeTypeName("const IID &")] Guid* classId, [NativeTypeName("PCWSTR")] ushort* propertyXml, [NativeTypeName("const D2D1_PROPERTY_BINDING *")] D2D1_PROPERTY_BINDING* bindings, [NativeTypeName("UINT32")] uint bindingsCount, [NativeTypeName("const PD2D1_EFFECT_FACTORY")] delegate* unmanaged effectFactory) { - return ((delegate* unmanaged[Stdcall], int>)(lpVtbl[23]))((ID2D1Factory1*)Unsafe.AsPointer(ref this), classId, propertyXml, bindings, bindingsCount, effectFactory); + return ((delegate* unmanaged, int>)(lpVtbl[23]))((ID2D1Factory1*)Unsafe.AsPointer(ref this), classId, propertyXml, bindings, bindingsCount, effectFactory); } -#else - public HRESULT RegisterEffectFromString([NativeTypeName("const IID &")] Guid* classId, [NativeTypeName("PCWSTR")] ushort* propertyXml, [NativeTypeName("const D2D1_PROPERTY_BINDING *")] D2D1_PROPERTY_BINDING* bindings, [NativeTypeName("UINT32")] uint bindingsCount, [NativeTypeName("const PD2D1_EFFECT_FACTORY")] void* effectFactory) - { - return ((delegate* unmanaged[Stdcall])(lpVtbl[23]))((ID2D1Factory1*)Unsafe.AsPointer(ref this), classId, propertyXml, bindings, bindingsCount, effectFactory); - } -#endif } \ No newline at end of file diff --git a/src/ComputeSharp.Win32.D2D1/DirectX/um/d2d1effectauthor/D2D1_PROPERTY_BINDING.cs b/src/ComputeSharp.Win32.D2D1/DirectX/um/d2d1effectauthor/D2D1_PROPERTY_BINDING.cs index a799799c..cfb91870 100644 --- a/src/ComputeSharp.Win32.D2D1/DirectX/um/d2d1effectauthor/D2D1_PROPERTY_BINDING.cs +++ b/src/ComputeSharp.Win32.D2D1/DirectX/um/d2d1effectauthor/D2D1_PROPERTY_BINDING.cs @@ -13,16 +13,8 @@ internal unsafe partial struct D2D1_PROPERTY_BINDING public ushort* propertyName; [NativeTypeName("PD2D1_PROPERTY_SET_FUNCTION")] -#if NET6_0_OR_GREATER public delegate* unmanaged[Stdcall] setFunction; -#else - public void* setFunction; -#endif [NativeTypeName("PD2D1_PROPERTY_GET_FUNCTION")] -#if NET6_0_OR_GREATER public delegate* unmanaged[Stdcall] getFunction; -#else - public void* getFunction; -#endif } \ No newline at end of file From 23748b514ef55043744d1446cf4edf8a4ebc8c1e Mon Sep 17 00:00:00 2001 From: Sergio Pedri Date: Wed, 18 Oct 2023 13:15:53 +0200 Subject: [PATCH 3/5] Remove proxies for function pointers for methods --- .../Shaders/Interop/D2D1PixelShaderEffect.cs | 150 ++--- .../Effects/PixelShaderEffect.Properties.cs | 53 +- .../Effects/PixelShaderEffect.Properties.g.cs | 513 +++--------------- .../Effects/PixelShaderEffect.Properties.tt | 40 +- .../d2d1effectauthor/D2D1_PROPERTY_BINDING.cs | 4 +- 5 files changed, 153 insertions(+), 607 deletions(-) diff --git a/src/ComputeSharp.D2D1/Shaders/Interop/D2D1PixelShaderEffect.cs b/src/ComputeSharp.D2D1/Shaders/Interop/D2D1PixelShaderEffect.cs index 5e00d670..1edea605 100644 --- a/src/ComputeSharp.D2D1/Shaders/Interop/D2D1PixelShaderEffect.cs +++ b/src/ComputeSharp.D2D1/Shaders/Interop/D2D1PixelShaderEffect.cs @@ -148,44 +148,44 @@ public static unsafe class D2D1PixelShaderEffect d2D1PropertyBinding[D2D1PixelShaderEffectProperty.ResourceTextureManager15].propertyName = (ushort*)pResourceTextureManager15PropertyName; // Property getters - d2D1PropertyBinding[D2D1PixelShaderEffectProperty.ConstantBuffer].getFunction = PixelShaderEffect.GetConstantBuffer; - d2D1PropertyBinding[D2D1PixelShaderEffectProperty.TransformMapper].getFunction = PixelShaderEffect.GetTransformMapper; - d2D1PropertyBinding[D2D1PixelShaderEffectProperty.ResourceTextureManager0].getFunction = PixelShaderEffect.GetResourceTextureManager0; - d2D1PropertyBinding[D2D1PixelShaderEffectProperty.ResourceTextureManager1].getFunction = PixelShaderEffect.GetResourceTextureManager1; - d2D1PropertyBinding[D2D1PixelShaderEffectProperty.ResourceTextureManager2].getFunction = PixelShaderEffect.GetResourceTextureManager2; - d2D1PropertyBinding[D2D1PixelShaderEffectProperty.ResourceTextureManager3].getFunction = PixelShaderEffect.GetResourceTextureManager3; - d2D1PropertyBinding[D2D1PixelShaderEffectProperty.ResourceTextureManager4].getFunction = PixelShaderEffect.GetResourceTextureManager4; - d2D1PropertyBinding[D2D1PixelShaderEffectProperty.ResourceTextureManager5].getFunction = PixelShaderEffect.GetResourceTextureManager5; - d2D1PropertyBinding[D2D1PixelShaderEffectProperty.ResourceTextureManager6].getFunction = PixelShaderEffect.GetResourceTextureManager6; - d2D1PropertyBinding[D2D1PixelShaderEffectProperty.ResourceTextureManager7].getFunction = PixelShaderEffect.GetResourceTextureManager7; - d2D1PropertyBinding[D2D1PixelShaderEffectProperty.ResourceTextureManager8].getFunction = PixelShaderEffect.GetResourceTextureManager8; - d2D1PropertyBinding[D2D1PixelShaderEffectProperty.ResourceTextureManager9].getFunction = PixelShaderEffect.GetResourceTextureManager9; - d2D1PropertyBinding[D2D1PixelShaderEffectProperty.ResourceTextureManager10].getFunction = PixelShaderEffect.GetResourceTextureManager10; - d2D1PropertyBinding[D2D1PixelShaderEffectProperty.ResourceTextureManager11].getFunction = PixelShaderEffect.GetResourceTextureManager11; - d2D1PropertyBinding[D2D1PixelShaderEffectProperty.ResourceTextureManager12].getFunction = PixelShaderEffect.GetResourceTextureManager12; - d2D1PropertyBinding[D2D1PixelShaderEffectProperty.ResourceTextureManager13].getFunction = PixelShaderEffect.GetResourceTextureManager13; - d2D1PropertyBinding[D2D1PixelShaderEffectProperty.ResourceTextureManager14].getFunction = PixelShaderEffect.GetResourceTextureManager14; - d2D1PropertyBinding[D2D1PixelShaderEffectProperty.ResourceTextureManager15].getFunction = PixelShaderEffect.GetResourceTextureManager15; + d2D1PropertyBinding[D2D1PixelShaderEffectProperty.ConstantBuffer].getFunction = &PixelShaderEffect.GetConstantBufferImpl; + d2D1PropertyBinding[D2D1PixelShaderEffectProperty.TransformMapper].getFunction = &PixelShaderEffect.GetTransformMapperImpl; + d2D1PropertyBinding[D2D1PixelShaderEffectProperty.ResourceTextureManager0].getFunction = &PixelShaderEffect.GetResourceTextureManager0Impl; + d2D1PropertyBinding[D2D1PixelShaderEffectProperty.ResourceTextureManager1].getFunction = &PixelShaderEffect.GetResourceTextureManager1Impl; + d2D1PropertyBinding[D2D1PixelShaderEffectProperty.ResourceTextureManager2].getFunction = &PixelShaderEffect.GetResourceTextureManager2Impl; + d2D1PropertyBinding[D2D1PixelShaderEffectProperty.ResourceTextureManager3].getFunction = &PixelShaderEffect.GetResourceTextureManager3Impl; + d2D1PropertyBinding[D2D1PixelShaderEffectProperty.ResourceTextureManager4].getFunction = &PixelShaderEffect.GetResourceTextureManager4Impl; + d2D1PropertyBinding[D2D1PixelShaderEffectProperty.ResourceTextureManager5].getFunction = &PixelShaderEffect.GetResourceTextureManager5Impl; + d2D1PropertyBinding[D2D1PixelShaderEffectProperty.ResourceTextureManager6].getFunction = &PixelShaderEffect.GetResourceTextureManager6Impl; + d2D1PropertyBinding[D2D1PixelShaderEffectProperty.ResourceTextureManager7].getFunction = &PixelShaderEffect.GetResourceTextureManager7Impl; + d2D1PropertyBinding[D2D1PixelShaderEffectProperty.ResourceTextureManager8].getFunction = &PixelShaderEffect.GetResourceTextureManager8Impl; + d2D1PropertyBinding[D2D1PixelShaderEffectProperty.ResourceTextureManager9].getFunction = &PixelShaderEffect.GetResourceTextureManager9Impl; + d2D1PropertyBinding[D2D1PixelShaderEffectProperty.ResourceTextureManager10].getFunction = &PixelShaderEffect.GetResourceTextureManager10Impl; + d2D1PropertyBinding[D2D1PixelShaderEffectProperty.ResourceTextureManager11].getFunction = &PixelShaderEffect.GetResourceTextureManager11Impl; + d2D1PropertyBinding[D2D1PixelShaderEffectProperty.ResourceTextureManager12].getFunction = &PixelShaderEffect.GetResourceTextureManager12Impl; + d2D1PropertyBinding[D2D1PixelShaderEffectProperty.ResourceTextureManager13].getFunction = &PixelShaderEffect.GetResourceTextureManager13Impl; + d2D1PropertyBinding[D2D1PixelShaderEffectProperty.ResourceTextureManager14].getFunction = &PixelShaderEffect.GetResourceTextureManager14Impl; + d2D1PropertyBinding[D2D1PixelShaderEffectProperty.ResourceTextureManager15].getFunction = &PixelShaderEffect.GetResourceTextureManager15Impl; // Property setters - d2D1PropertyBinding[D2D1PixelShaderEffectProperty.ConstantBuffer].setFunction = PixelShaderEffect.SetConstantBuffer; - d2D1PropertyBinding[D2D1PixelShaderEffectProperty.TransformMapper].setFunction = PixelShaderEffect.SetTransformMapper; - d2D1PropertyBinding[D2D1PixelShaderEffectProperty.ResourceTextureManager0].setFunction = PixelShaderEffect.SetResourceTextureManager0; - d2D1PropertyBinding[D2D1PixelShaderEffectProperty.ResourceTextureManager1].setFunction = PixelShaderEffect.SetResourceTextureManager1; - d2D1PropertyBinding[D2D1PixelShaderEffectProperty.ResourceTextureManager2].setFunction = PixelShaderEffect.SetResourceTextureManager2; - d2D1PropertyBinding[D2D1PixelShaderEffectProperty.ResourceTextureManager3].setFunction = PixelShaderEffect.SetResourceTextureManager3; - d2D1PropertyBinding[D2D1PixelShaderEffectProperty.ResourceTextureManager4].setFunction = PixelShaderEffect.SetResourceTextureManager4; - d2D1PropertyBinding[D2D1PixelShaderEffectProperty.ResourceTextureManager5].setFunction = PixelShaderEffect.SetResourceTextureManager5; - d2D1PropertyBinding[D2D1PixelShaderEffectProperty.ResourceTextureManager6].setFunction = PixelShaderEffect.SetResourceTextureManager6; - d2D1PropertyBinding[D2D1PixelShaderEffectProperty.ResourceTextureManager7].setFunction = PixelShaderEffect.SetResourceTextureManager7; - d2D1PropertyBinding[D2D1PixelShaderEffectProperty.ResourceTextureManager8].setFunction = PixelShaderEffect.SetResourceTextureManager8; - d2D1PropertyBinding[D2D1PixelShaderEffectProperty.ResourceTextureManager9].setFunction = PixelShaderEffect.SetResourceTextureManager9; - d2D1PropertyBinding[D2D1PixelShaderEffectProperty.ResourceTextureManager10].setFunction = PixelShaderEffect.SetResourceTextureManager10; - d2D1PropertyBinding[D2D1PixelShaderEffectProperty.ResourceTextureManager11].setFunction = PixelShaderEffect.SetResourceTextureManager11; - d2D1PropertyBinding[D2D1PixelShaderEffectProperty.ResourceTextureManager12].setFunction = PixelShaderEffect.SetResourceTextureManager12; - d2D1PropertyBinding[D2D1PixelShaderEffectProperty.ResourceTextureManager13].setFunction = PixelShaderEffect.SetResourceTextureManager13; - d2D1PropertyBinding[D2D1PixelShaderEffectProperty.ResourceTextureManager14].setFunction = PixelShaderEffect.SetResourceTextureManager14; - d2D1PropertyBinding[D2D1PixelShaderEffectProperty.ResourceTextureManager15].setFunction = PixelShaderEffect.SetResourceTextureManager15; + d2D1PropertyBinding[D2D1PixelShaderEffectProperty.ConstantBuffer].setFunction = &PixelShaderEffect.SetConstantBufferImpl; + d2D1PropertyBinding[D2D1PixelShaderEffectProperty.TransformMapper].setFunction = &PixelShaderEffect.SetTransformMapperImpl; + d2D1PropertyBinding[D2D1PixelShaderEffectProperty.ResourceTextureManager0].setFunction = &PixelShaderEffect.SetResourceTextureManager0Impl; + d2D1PropertyBinding[D2D1PixelShaderEffectProperty.ResourceTextureManager1].setFunction = &PixelShaderEffect.SetResourceTextureManager1Impl; + d2D1PropertyBinding[D2D1PixelShaderEffectProperty.ResourceTextureManager2].setFunction = &PixelShaderEffect.SetResourceTextureManager2Impl; + d2D1PropertyBinding[D2D1PixelShaderEffectProperty.ResourceTextureManager3].setFunction = &PixelShaderEffect.SetResourceTextureManager3Impl; + d2D1PropertyBinding[D2D1PixelShaderEffectProperty.ResourceTextureManager4].setFunction = &PixelShaderEffect.SetResourceTextureManager4Impl; + d2D1PropertyBinding[D2D1PixelShaderEffectProperty.ResourceTextureManager5].setFunction = &PixelShaderEffect.SetResourceTextureManager5Impl; + d2D1PropertyBinding[D2D1PixelShaderEffectProperty.ResourceTextureManager6].setFunction = &PixelShaderEffect.SetResourceTextureManager6Impl; + d2D1PropertyBinding[D2D1PixelShaderEffectProperty.ResourceTextureManager7].setFunction = &PixelShaderEffect.SetResourceTextureManager7Impl; + d2D1PropertyBinding[D2D1PixelShaderEffectProperty.ResourceTextureManager8].setFunction = &PixelShaderEffect.SetResourceTextureManager8Impl; + d2D1PropertyBinding[D2D1PixelShaderEffectProperty.ResourceTextureManager9].setFunction = &PixelShaderEffect.SetResourceTextureManager9Impl; + d2D1PropertyBinding[D2D1PixelShaderEffectProperty.ResourceTextureManager10].setFunction = &PixelShaderEffect.SetResourceTextureManager10Impl; + d2D1PropertyBinding[D2D1PixelShaderEffectProperty.ResourceTextureManager11].setFunction = &PixelShaderEffect.SetResourceTextureManager11Impl; + d2D1PropertyBinding[D2D1PixelShaderEffectProperty.ResourceTextureManager12].setFunction = &PixelShaderEffect.SetResourceTextureManager12Impl; + d2D1PropertyBinding[D2D1PixelShaderEffectProperty.ResourceTextureManager13].setFunction = &PixelShaderEffect.SetResourceTextureManager13Impl; + d2D1PropertyBinding[D2D1PixelShaderEffectProperty.ResourceTextureManager14].setFunction = &PixelShaderEffect.SetResourceTextureManager14Impl; + d2D1PropertyBinding[D2D1PixelShaderEffectProperty.ResourceTextureManager15].setFunction = &PixelShaderEffect.SetResourceTextureManager15Impl; fixed (Guid* pGuid = &GetEffectId()) { @@ -227,9 +227,9 @@ public static unsafe class D2D1PixelShaderEffect /// The effect XML description (as null-terminated UTF8 text). /// The number of property bindings (an ). /// The property name (as null-terminated UTF8 text). - /// The property getter (a ). - /// The property setter (a ). - /// The effect factory (a ). + /// The property getter (a ). + /// The property setter (a ). + /// The effect factory (a ). /// /// The property name, getter and setter are grouped together after the number of bindings. /// @@ -275,12 +275,12 @@ public static unsafe class D2D1PixelShaderEffect writer.Write(D2D1PixelShaderEffectProperty.NumberOfAlwaysAvailableProperties + D2D1PixelShader.GetResourceTextureCount()); writer.Write("ConstantBuffer"u8); writer.Write((byte)'\0'); - writer.Write((nint)PixelShaderEffect.GetConstantBuffer); - writer.Write((nint)PixelShaderEffect.SetConstantBuffer); + writer.Write((nint)(delegate* unmanaged)&PixelShaderEffect.GetConstantBufferImpl); + writer.Write((nint)(delegate* unmanaged)&PixelShaderEffect.SetConstantBufferImpl); writer.Write("TransformMapper"u8); writer.Write((byte)'\0'); - writer.Write((nint)PixelShaderEffect.GetTransformMapper); - writer.Write((nint)PixelShaderEffect.SetTransformMapper); + writer.Write((nint)(delegate* unmanaged)&PixelShaderEffect.GetTransformMapperImpl); + writer.Write((nint)(delegate* unmanaged)&PixelShaderEffect.SetTransformMapperImpl); // Add all resource texture manager property bindings for (int i = 0; i < D2D1PixelShader.GetResourceTextureCount(); i++) @@ -290,98 +290,98 @@ public static unsafe class D2D1PixelShaderEffect case 0: writer.Write("ResourceTextureManager0"u8); writer.Write((byte)'\0'); - writer.Write((nint)PixelShaderEffect.GetResourceTextureManager0); - writer.Write((nint)PixelShaderEffect.SetResourceTextureManager0); + writer.Write((nint)(delegate* unmanaged)&PixelShaderEffect.GetResourceTextureManager0Impl); + writer.Write((nint)(delegate* unmanaged)&PixelShaderEffect.SetResourceTextureManager0Impl); break; case 1: writer.Write("ResourceTextureManager1"u8); writer.Write((byte)'\0'); - writer.Write((nint)PixelShaderEffect.GetResourceTextureManager1); - writer.Write((nint)PixelShaderEffect.SetResourceTextureManager1); + writer.Write((nint)(delegate* unmanaged)&PixelShaderEffect.GetResourceTextureManager1Impl); + writer.Write((nint)(delegate* unmanaged)&PixelShaderEffect.SetResourceTextureManager1Impl); break; case 2: writer.Write("ResourceTextureManager2"u8); writer.Write((byte)'\0'); - writer.Write((nint)PixelShaderEffect.GetResourceTextureManager2); - writer.Write((nint)PixelShaderEffect.SetResourceTextureManager2); + writer.Write((nint)(delegate* unmanaged)&PixelShaderEffect.GetResourceTextureManager2Impl); + writer.Write((nint)(delegate* unmanaged)&PixelShaderEffect.SetResourceTextureManager2Impl); break; case 3: writer.Write("ResourceTextureManager3"u8); writer.Write((byte)'\0'); - writer.Write((nint)PixelShaderEffect.GetResourceTextureManager3); - writer.Write((nint)PixelShaderEffect.SetResourceTextureManager3); + writer.Write((nint)(delegate* unmanaged)&PixelShaderEffect.GetResourceTextureManager3Impl); + writer.Write((nint)(delegate* unmanaged)&PixelShaderEffect.SetResourceTextureManager3Impl); break; case 4: writer.Write("ResourceTextureManager4"u8); writer.Write((byte)'\0'); - writer.Write((nint)PixelShaderEffect.GetResourceTextureManager4); - writer.Write((nint)PixelShaderEffect.SetResourceTextureManager4); + writer.Write((nint)(delegate* unmanaged)&PixelShaderEffect.GetResourceTextureManager4Impl); + writer.Write((nint)(delegate* unmanaged)&PixelShaderEffect.SetResourceTextureManager4Impl); break; case 5: writer.Write("ResourceTextureManager5"u8); writer.Write((byte)'\0'); - writer.Write((nint)PixelShaderEffect.GetResourceTextureManager5); - writer.Write((nint)PixelShaderEffect.SetResourceTextureManager5); + writer.Write((nint)(delegate* unmanaged)&PixelShaderEffect.GetResourceTextureManager5Impl); + writer.Write((nint)(delegate* unmanaged)&PixelShaderEffect.SetResourceTextureManager5Impl); break; case 6: writer.Write("ResourceTextureManager6"u8); writer.Write((byte)'\0'); - writer.Write((nint)PixelShaderEffect.GetResourceTextureManager6); - writer.Write((nint)PixelShaderEffect.SetResourceTextureManager6); + writer.Write((nint)(delegate* unmanaged)&PixelShaderEffect.GetResourceTextureManager6Impl); + writer.Write((nint)(delegate* unmanaged)&PixelShaderEffect.SetResourceTextureManager6Impl); break; case 7: writer.Write("ResourceTextureManager7"u8); writer.Write((byte)'\0'); - writer.Write((nint)PixelShaderEffect.GetResourceTextureManager7); - writer.Write((nint)PixelShaderEffect.SetResourceTextureManager7); + writer.Write((nint)(delegate* unmanaged)&PixelShaderEffect.GetResourceTextureManager7Impl); + writer.Write((nint)(delegate* unmanaged)&PixelShaderEffect.SetResourceTextureManager7Impl); break; case 8: writer.Write("ResourceTextureManager8"u8); writer.Write((byte)'\0'); - writer.Write((nint)PixelShaderEffect.GetResourceTextureManager8); - writer.Write((nint)PixelShaderEffect.SetResourceTextureManager8); + writer.Write((nint)(delegate* unmanaged)&PixelShaderEffect.GetResourceTextureManager8Impl); + writer.Write((nint)(delegate* unmanaged)&PixelShaderEffect.SetResourceTextureManager8Impl); break; case 9: writer.Write("ResourceTextureManager9"u8); writer.Write((byte)'\0'); - writer.Write((nint)PixelShaderEffect.GetResourceTextureManager9); - writer.Write((nint)PixelShaderEffect.SetResourceTextureManager9); + writer.Write((nint)(delegate* unmanaged)&PixelShaderEffect.GetResourceTextureManager9Impl); + writer.Write((nint)(delegate* unmanaged)&PixelShaderEffect.SetResourceTextureManager9Impl); break; case 10: writer.Write("ResourceTextureManager10"u8); writer.Write((byte)'\0'); - writer.Write((nint)PixelShaderEffect.GetResourceTextureManager10); - writer.Write((nint)PixelShaderEffect.SetResourceTextureManager10); + writer.Write((nint)(delegate* unmanaged)&PixelShaderEffect.GetResourceTextureManager10Impl); + writer.Write((nint)(delegate* unmanaged)&PixelShaderEffect.SetResourceTextureManager10Impl); break; case 11: writer.Write("ResourceTextureManager11"u8); writer.Write((byte)'\0'); - writer.Write((nint)PixelShaderEffect.GetResourceTextureManager11); - writer.Write((nint)PixelShaderEffect.SetResourceTextureManager11); + writer.Write((nint)(delegate* unmanaged)&PixelShaderEffect.GetResourceTextureManager11Impl); + writer.Write((nint)(delegate* unmanaged)&PixelShaderEffect.SetResourceTextureManager11Impl); break; case 12: writer.Write("ResourceTextureManager12"u8); writer.Write((byte)'\0'); - writer.Write((nint)PixelShaderEffect.GetResourceTextureManager12); - writer.Write((nint)PixelShaderEffect.SetResourceTextureManager12); + writer.Write((nint)(delegate* unmanaged)&PixelShaderEffect.GetResourceTextureManager12Impl); + writer.Write((nint)(delegate* unmanaged)&PixelShaderEffect.SetResourceTextureManager12Impl); break; case 13: writer.Write("ResourceTextureManager13"u8); writer.Write((byte)'\0'); - writer.Write((nint)PixelShaderEffect.GetResourceTextureManager13); - writer.Write((nint)PixelShaderEffect.SetResourceTextureManager13); + writer.Write((nint)(delegate* unmanaged)&PixelShaderEffect.GetResourceTextureManager13Impl); + writer.Write((nint)(delegate* unmanaged)&PixelShaderEffect.SetResourceTextureManager13Impl); break; case 14: writer.Write("ResourceTextureManager14"u8); writer.Write((byte)'\0'); - writer.Write((nint)PixelShaderEffect.GetResourceTextureManager14); - writer.Write((nint)PixelShaderEffect.SetResourceTextureManager14); + writer.Write((nint)(delegate* unmanaged)&PixelShaderEffect.GetResourceTextureManager14Impl); + writer.Write((nint)(delegate* unmanaged)&PixelShaderEffect.SetResourceTextureManager14Impl); break; case 15: writer.Write("ResourceTextureManager15"u8); writer.Write((byte)'\0'); - writer.Write((nint)PixelShaderEffect.GetResourceTextureManager15); - writer.Write((nint)PixelShaderEffect.SetResourceTextureManager15); + writer.Write((nint)(delegate* unmanaged)&PixelShaderEffect.GetResourceTextureManager15Impl); + writer.Write((nint)(delegate* unmanaged)&PixelShaderEffect.SetResourceTextureManager15Impl); break; } } diff --git a/src/ComputeSharp.D2D1/Shaders/Interop/Effects/PixelShaderEffect.Properties.cs b/src/ComputeSharp.D2D1/Shaders/Interop/Effects/PixelShaderEffect.Properties.cs index 026c9838..bf214d23 100644 --- a/src/ComputeSharp.D2D1/Shaders/Interop/Effects/PixelShaderEffect.Properties.cs +++ b/src/ComputeSharp.D2D1/Shaders/Interop/Effects/PixelShaderEffect.Properties.cs @@ -1,5 +1,4 @@ using System; -using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using ComputeSharp.D2D1.Extensions; using ComputeSharp.D2D1.Shaders.Interop.Effects.ResourceManagers; @@ -11,45 +10,9 @@ namespace ComputeSharp.D2D1.Interop.Effects; /// unsafe partial struct PixelShaderEffect { - /// - /// Gets the get accessor for the constant buffer. - /// - public static delegate* unmanaged[Stdcall] GetConstantBuffer - { - [MethodImpl(MethodImplOptions.AggressiveInlining)] - get => &GetConstantBufferImpl; - } - - /// - /// Gets the set accessor for the constant buffer. - /// - public static delegate* unmanaged[Stdcall] SetConstantBuffer - { - [MethodImpl(MethodImplOptions.AggressiveInlining)] - get => &SetConstantBufferImpl; - } - - /// - /// Gets the get accessor for the transform mapper. - /// - public static delegate* unmanaged[Stdcall] GetTransformMapper - { - [MethodImpl(MethodImplOptions.AggressiveInlining)] - get => &GetTransformMapperImpl; - } - - /// - /// Gets the set accessor for the transform mapper. - /// - public static delegate* unmanaged[Stdcall] SetTransformMapper - { - [MethodImpl(MethodImplOptions.AggressiveInlining)] - get => &SetTransformMapperImpl; - } - /// - [UnmanagedCallersOnly(CallConvs = new[] { typeof(CallConvStdcall) })] - private static int GetConstantBufferImpl(IUnknown* effect, byte* data, uint dataSize, uint* actualSize) + [UnmanagedCallersOnly] + public static HRESULT GetConstantBufferImpl(IUnknown* effect, byte* data, uint dataSize, uint* actualSize) { PixelShaderEffect* @this = (PixelShaderEffect*)effect; @@ -101,8 +64,8 @@ unsafe partial struct PixelShaderEffect } /// - [UnmanagedCallersOnly(CallConvs = new[] { typeof(CallConvStdcall) })] - private static int SetConstantBufferImpl(IUnknown* effect, byte* data, uint dataSize) + [UnmanagedCallersOnly] + public static HRESULT SetConstantBufferImpl(IUnknown* effect, byte* data, uint dataSize) { PixelShaderEffect* @this = (PixelShaderEffect*)effect; @@ -134,8 +97,8 @@ unsafe partial struct PixelShaderEffect } /// - [UnmanagedCallersOnly(CallConvs = new[] { typeof(CallConvStdcall) })] - private static int GetTransformMapperImpl(IUnknown* effect, byte* data, uint dataSize, uint* actualSize) + [UnmanagedCallersOnly] + public static HRESULT GetTransformMapperImpl(IUnknown* effect, byte* data, uint dataSize, uint* actualSize) { PixelShaderEffect* @this = (PixelShaderEffect*)effect; @@ -167,8 +130,8 @@ unsafe partial struct PixelShaderEffect } /// - [UnmanagedCallersOnly(CallConvs = new[] { typeof(CallConvStdcall) })] - private static int SetTransformMapperImpl(IUnknown* effect, byte* data, uint dataSize) + [UnmanagedCallersOnly] + public static HRESULT SetTransformMapperImpl(IUnknown* effect, byte* data, uint dataSize) { PixelShaderEffect* @this = (PixelShaderEffect*)effect; diff --git a/src/ComputeSharp.D2D1/Shaders/Interop/Effects/PixelShaderEffect.Properties.g.cs b/src/ComputeSharp.D2D1/Shaders/Interop/Effects/PixelShaderEffect.Properties.g.cs index 2f1c8cc3..48f5e411 100644 --- a/src/ComputeSharp.D2D1/Shaders/Interop/Effects/PixelShaderEffect.Properties.g.cs +++ b/src/ComputeSharp.D2D1/Shaders/Interop/Effects/PixelShaderEffect.Properties.g.cs @@ -1,4 +1,3 @@ -using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using ComputeSharp.Win32; @@ -7,595 +6,211 @@ namespace ComputeSharp.D2D1.Interop.Effects; /// unsafe partial struct PixelShaderEffect { - /// - /// Gets the get accessor for the resource manager at index 0. - /// - public static delegate* unmanaged[Stdcall] GetResourceTextureManager0 - { - [MethodImpl(MethodImplOptions.AggressiveInlining)] - get - { - return &GetResourceTextureManager0Impl; - } - } - - /// - /// Gets the set accessor for the resource manager at index 0. - /// - public static delegate* unmanaged[Stdcall] SetResourceTextureManager0 - { - [MethodImpl(MethodImplOptions.AggressiveInlining)] - get - { - return &SetResourceTextureManager0Impl; - } - } - - /// - /// Gets the get accessor for the resource manager at index 1. - /// - public static delegate* unmanaged[Stdcall] GetResourceTextureManager1 - { - [MethodImpl(MethodImplOptions.AggressiveInlining)] - get - { - return &GetResourceTextureManager1Impl; - } - } - - /// - /// Gets the set accessor for the resource manager at index 1. - /// - public static delegate* unmanaged[Stdcall] SetResourceTextureManager1 - { - [MethodImpl(MethodImplOptions.AggressiveInlining)] - get - { - return &SetResourceTextureManager1Impl; - } - } - - /// - /// Gets the get accessor for the resource manager at index 2. - /// - public static delegate* unmanaged[Stdcall] GetResourceTextureManager2 - { - [MethodImpl(MethodImplOptions.AggressiveInlining)] - get - { - return &GetResourceTextureManager2Impl; - } - } - - /// - /// Gets the set accessor for the resource manager at index 2. - /// - public static delegate* unmanaged[Stdcall] SetResourceTextureManager2 - { - [MethodImpl(MethodImplOptions.AggressiveInlining)] - get - { - return &SetResourceTextureManager2Impl; - } - } - - /// - /// Gets the get accessor for the resource manager at index 3. - /// - public static delegate* unmanaged[Stdcall] GetResourceTextureManager3 - { - [MethodImpl(MethodImplOptions.AggressiveInlining)] - get - { - return &GetResourceTextureManager3Impl; - } - } - - /// - /// Gets the set accessor for the resource manager at index 3. - /// - public static delegate* unmanaged[Stdcall] SetResourceTextureManager3 - { - [MethodImpl(MethodImplOptions.AggressiveInlining)] - get - { - return &SetResourceTextureManager3Impl; - } - } - - /// - /// Gets the get accessor for the resource manager at index 4. - /// - public static delegate* unmanaged[Stdcall] GetResourceTextureManager4 - { - [MethodImpl(MethodImplOptions.AggressiveInlining)] - get - { - return &GetResourceTextureManager4Impl; - } - } - - /// - /// Gets the set accessor for the resource manager at index 4. - /// - public static delegate* unmanaged[Stdcall] SetResourceTextureManager4 - { - [MethodImpl(MethodImplOptions.AggressiveInlining)] - get - { - return &SetResourceTextureManager4Impl; - } - } - - /// - /// Gets the get accessor for the resource manager at index 5. - /// - public static delegate* unmanaged[Stdcall] GetResourceTextureManager5 - { - [MethodImpl(MethodImplOptions.AggressiveInlining)] - get - { - return &GetResourceTextureManager5Impl; - } - } - - /// - /// Gets the set accessor for the resource manager at index 5. - /// - public static delegate* unmanaged[Stdcall] SetResourceTextureManager5 - { - [MethodImpl(MethodImplOptions.AggressiveInlining)] - get - { - return &SetResourceTextureManager5Impl; - } - } - - /// - /// Gets the get accessor for the resource manager at index 6. - /// - public static delegate* unmanaged[Stdcall] GetResourceTextureManager6 - { - [MethodImpl(MethodImplOptions.AggressiveInlining)] - get - { - return &GetResourceTextureManager6Impl; - } - } - - /// - /// Gets the set accessor for the resource manager at index 6. - /// - public static delegate* unmanaged[Stdcall] SetResourceTextureManager6 - { - [MethodImpl(MethodImplOptions.AggressiveInlining)] - get - { - return &SetResourceTextureManager6Impl; - } - } - - /// - /// Gets the get accessor for the resource manager at index 7. - /// - public static delegate* unmanaged[Stdcall] GetResourceTextureManager7 - { - [MethodImpl(MethodImplOptions.AggressiveInlining)] - get - { - return &GetResourceTextureManager7Impl; - } - } - - /// - /// Gets the set accessor for the resource manager at index 7. - /// - public static delegate* unmanaged[Stdcall] SetResourceTextureManager7 - { - [MethodImpl(MethodImplOptions.AggressiveInlining)] - get - { - return &SetResourceTextureManager7Impl; - } - } - - /// - /// Gets the get accessor for the resource manager at index 8. - /// - public static delegate* unmanaged[Stdcall] GetResourceTextureManager8 - { - [MethodImpl(MethodImplOptions.AggressiveInlining)] - get - { - return &GetResourceTextureManager8Impl; - } - } - - /// - /// Gets the set accessor for the resource manager at index 8. - /// - public static delegate* unmanaged[Stdcall] SetResourceTextureManager8 - { - [MethodImpl(MethodImplOptions.AggressiveInlining)] - get - { - return &SetResourceTextureManager8Impl; - } - } - - /// - /// Gets the get accessor for the resource manager at index 9. - /// - public static delegate* unmanaged[Stdcall] GetResourceTextureManager9 - { - [MethodImpl(MethodImplOptions.AggressiveInlining)] - get - { - return &GetResourceTextureManager9Impl; - } - } - - /// - /// Gets the set accessor for the resource manager at index 9. - /// - public static delegate* unmanaged[Stdcall] SetResourceTextureManager9 - { - [MethodImpl(MethodImplOptions.AggressiveInlining)] - get - { - return &SetResourceTextureManager9Impl; - } - } - - /// - /// Gets the get accessor for the resource manager at index 10. - /// - public static delegate* unmanaged[Stdcall] GetResourceTextureManager10 - { - [MethodImpl(MethodImplOptions.AggressiveInlining)] - get - { - return &GetResourceTextureManager10Impl; - } - } - - /// - /// Gets the set accessor for the resource manager at index 10. - /// - public static delegate* unmanaged[Stdcall] SetResourceTextureManager10 - { - [MethodImpl(MethodImplOptions.AggressiveInlining)] - get - { - return &SetResourceTextureManager10Impl; - } - } - - /// - /// Gets the get accessor for the resource manager at index 11. - /// - public static delegate* unmanaged[Stdcall] GetResourceTextureManager11 - { - [MethodImpl(MethodImplOptions.AggressiveInlining)] - get - { - return &GetResourceTextureManager11Impl; - } - } - - /// - /// Gets the set accessor for the resource manager at index 11. - /// - public static delegate* unmanaged[Stdcall] SetResourceTextureManager11 - { - [MethodImpl(MethodImplOptions.AggressiveInlining)] - get - { - return &SetResourceTextureManager11Impl; - } - } - - /// - /// Gets the get accessor for the resource manager at index 12. - /// - public static delegate* unmanaged[Stdcall] GetResourceTextureManager12 - { - [MethodImpl(MethodImplOptions.AggressiveInlining)] - get - { - return &GetResourceTextureManager12Impl; - } - } - - /// - /// Gets the set accessor for the resource manager at index 12. - /// - public static delegate* unmanaged[Stdcall] SetResourceTextureManager12 - { - [MethodImpl(MethodImplOptions.AggressiveInlining)] - get - { - return &SetResourceTextureManager12Impl; - } - } - - /// - /// Gets the get accessor for the resource manager at index 13. - /// - public static delegate* unmanaged[Stdcall] GetResourceTextureManager13 - { - [MethodImpl(MethodImplOptions.AggressiveInlining)] - get - { - return &GetResourceTextureManager13Impl; - } - } - - /// - /// Gets the set accessor for the resource manager at index 13. - /// - public static delegate* unmanaged[Stdcall] SetResourceTextureManager13 - { - [MethodImpl(MethodImplOptions.AggressiveInlining)] - get - { - return &SetResourceTextureManager13Impl; - } - } - - /// - /// Gets the get accessor for the resource manager at index 14. - /// - public static delegate* unmanaged[Stdcall] GetResourceTextureManager14 - { - [MethodImpl(MethodImplOptions.AggressiveInlining)] - get - { - return &GetResourceTextureManager14Impl; - } - } - - /// - /// Gets the set accessor for the resource manager at index 14. - /// - public static delegate* unmanaged[Stdcall] SetResourceTextureManager14 - { - [MethodImpl(MethodImplOptions.AggressiveInlining)] - get - { - return &SetResourceTextureManager14Impl; - } - } - - /// - /// Gets the get accessor for the resource manager at index 15. - /// - public static delegate* unmanaged[Stdcall] GetResourceTextureManager15 - { - [MethodImpl(MethodImplOptions.AggressiveInlining)] - get - { - return &GetResourceTextureManager15Impl; - } - } - - /// - /// Gets the set accessor for the resource manager at index 15. - /// - public static delegate* unmanaged[Stdcall] SetResourceTextureManager15 - { - [MethodImpl(MethodImplOptions.AggressiveInlining)] - get - { - return &SetResourceTextureManager15Impl; - } - } - /// - [UnmanagedCallersOnly(CallConvs = new[] { typeof(CallConvStdcall) })] - private static int GetResourceTextureManager0Impl(IUnknown* effect, byte* data, uint dataSize, uint* actualSize) + [UnmanagedCallersOnly] + public static HRESULT GetResourceTextureManager0Impl(IUnknown* effect, byte* data, uint dataSize, uint* actualSize) { return ((PixelShaderEffect*)effect)->GetResourceTextureManagerAtIndex(0, data, dataSize, actualSize); } /// - [UnmanagedCallersOnly(CallConvs = new[] { typeof(CallConvStdcall) })] - private static int SetResourceTextureManager0Impl(IUnknown* effect, byte* data, uint dataSize) + [UnmanagedCallersOnly] + public static HRESULT SetResourceTextureManager0Impl(IUnknown* effect, byte* data, uint dataSize) { return ((PixelShaderEffect*)effect)->SetResourceTextureManagerAtIndex(0, data, dataSize); } /// - [UnmanagedCallersOnly(CallConvs = new[] { typeof(CallConvStdcall) })] - private static int GetResourceTextureManager1Impl(IUnknown* effect, byte* data, uint dataSize, uint* actualSize) + [UnmanagedCallersOnly] + public static HRESULT GetResourceTextureManager1Impl(IUnknown* effect, byte* data, uint dataSize, uint* actualSize) { return ((PixelShaderEffect*)effect)->GetResourceTextureManagerAtIndex(1, data, dataSize, actualSize); } /// - [UnmanagedCallersOnly(CallConvs = new[] { typeof(CallConvStdcall) })] - private static int SetResourceTextureManager1Impl(IUnknown* effect, byte* data, uint dataSize) + [UnmanagedCallersOnly] + public static HRESULT SetResourceTextureManager1Impl(IUnknown* effect, byte* data, uint dataSize) { return ((PixelShaderEffect*)effect)->SetResourceTextureManagerAtIndex(1, data, dataSize); } /// - [UnmanagedCallersOnly(CallConvs = new[] { typeof(CallConvStdcall) })] - private static int GetResourceTextureManager2Impl(IUnknown* effect, byte* data, uint dataSize, uint* actualSize) + [UnmanagedCallersOnly] + public static HRESULT GetResourceTextureManager2Impl(IUnknown* effect, byte* data, uint dataSize, uint* actualSize) { return ((PixelShaderEffect*)effect)->GetResourceTextureManagerAtIndex(2, data, dataSize, actualSize); } /// - [UnmanagedCallersOnly(CallConvs = new[] { typeof(CallConvStdcall) })] - private static int SetResourceTextureManager2Impl(IUnknown* effect, byte* data, uint dataSize) + [UnmanagedCallersOnly] + public static HRESULT SetResourceTextureManager2Impl(IUnknown* effect, byte* data, uint dataSize) { return ((PixelShaderEffect*)effect)->SetResourceTextureManagerAtIndex(2, data, dataSize); } /// - [UnmanagedCallersOnly(CallConvs = new[] { typeof(CallConvStdcall) })] - private static int GetResourceTextureManager3Impl(IUnknown* effect, byte* data, uint dataSize, uint* actualSize) + [UnmanagedCallersOnly] + public static HRESULT GetResourceTextureManager3Impl(IUnknown* effect, byte* data, uint dataSize, uint* actualSize) { return ((PixelShaderEffect*)effect)->GetResourceTextureManagerAtIndex(3, data, dataSize, actualSize); } /// - [UnmanagedCallersOnly(CallConvs = new[] { typeof(CallConvStdcall) })] - private static int SetResourceTextureManager3Impl(IUnknown* effect, byte* data, uint dataSize) + [UnmanagedCallersOnly] + public static HRESULT SetResourceTextureManager3Impl(IUnknown* effect, byte* data, uint dataSize) { return ((PixelShaderEffect*)effect)->SetResourceTextureManagerAtIndex(3, data, dataSize); } /// - [UnmanagedCallersOnly(CallConvs = new[] { typeof(CallConvStdcall) })] - private static int GetResourceTextureManager4Impl(IUnknown* effect, byte* data, uint dataSize, uint* actualSize) + [UnmanagedCallersOnly] + public static HRESULT GetResourceTextureManager4Impl(IUnknown* effect, byte* data, uint dataSize, uint* actualSize) { return ((PixelShaderEffect*)effect)->GetResourceTextureManagerAtIndex(4, data, dataSize, actualSize); } /// - [UnmanagedCallersOnly(CallConvs = new[] { typeof(CallConvStdcall) })] - private static int SetResourceTextureManager4Impl(IUnknown* effect, byte* data, uint dataSize) + [UnmanagedCallersOnly] + public static HRESULT SetResourceTextureManager4Impl(IUnknown* effect, byte* data, uint dataSize) { return ((PixelShaderEffect*)effect)->SetResourceTextureManagerAtIndex(4, data, dataSize); } /// - [UnmanagedCallersOnly(CallConvs = new[] { typeof(CallConvStdcall) })] - private static int GetResourceTextureManager5Impl(IUnknown* effect, byte* data, uint dataSize, uint* actualSize) + [UnmanagedCallersOnly] + public static HRESULT GetResourceTextureManager5Impl(IUnknown* effect, byte* data, uint dataSize, uint* actualSize) { return ((PixelShaderEffect*)effect)->GetResourceTextureManagerAtIndex(5, data, dataSize, actualSize); } /// - [UnmanagedCallersOnly(CallConvs = new[] { typeof(CallConvStdcall) })] - private static int SetResourceTextureManager5Impl(IUnknown* effect, byte* data, uint dataSize) + [UnmanagedCallersOnly] + public static HRESULT SetResourceTextureManager5Impl(IUnknown* effect, byte* data, uint dataSize) { return ((PixelShaderEffect*)effect)->SetResourceTextureManagerAtIndex(5, data, dataSize); } /// - [UnmanagedCallersOnly(CallConvs = new[] { typeof(CallConvStdcall) })] - private static int GetResourceTextureManager6Impl(IUnknown* effect, byte* data, uint dataSize, uint* actualSize) + [UnmanagedCallersOnly] + public static HRESULT GetResourceTextureManager6Impl(IUnknown* effect, byte* data, uint dataSize, uint* actualSize) { return ((PixelShaderEffect*)effect)->GetResourceTextureManagerAtIndex(6, data, dataSize, actualSize); } /// - [UnmanagedCallersOnly(CallConvs = new[] { typeof(CallConvStdcall) })] - private static int SetResourceTextureManager6Impl(IUnknown* effect, byte* data, uint dataSize) + [UnmanagedCallersOnly] + public static HRESULT SetResourceTextureManager6Impl(IUnknown* effect, byte* data, uint dataSize) { return ((PixelShaderEffect*)effect)->SetResourceTextureManagerAtIndex(6, data, dataSize); } /// - [UnmanagedCallersOnly(CallConvs = new[] { typeof(CallConvStdcall) })] - private static int GetResourceTextureManager7Impl(IUnknown* effect, byte* data, uint dataSize, uint* actualSize) + [UnmanagedCallersOnly] + public static HRESULT GetResourceTextureManager7Impl(IUnknown* effect, byte* data, uint dataSize, uint* actualSize) { return ((PixelShaderEffect*)effect)->GetResourceTextureManagerAtIndex(7, data, dataSize, actualSize); } /// - [UnmanagedCallersOnly(CallConvs = new[] { typeof(CallConvStdcall) })] - private static int SetResourceTextureManager7Impl(IUnknown* effect, byte* data, uint dataSize) + [UnmanagedCallersOnly] + public static HRESULT SetResourceTextureManager7Impl(IUnknown* effect, byte* data, uint dataSize) { return ((PixelShaderEffect*)effect)->SetResourceTextureManagerAtIndex(7, data, dataSize); } /// - [UnmanagedCallersOnly(CallConvs = new[] { typeof(CallConvStdcall) })] - private static int GetResourceTextureManager8Impl(IUnknown* effect, byte* data, uint dataSize, uint* actualSize) + [UnmanagedCallersOnly] + public static HRESULT GetResourceTextureManager8Impl(IUnknown* effect, byte* data, uint dataSize, uint* actualSize) { return ((PixelShaderEffect*)effect)->GetResourceTextureManagerAtIndex(8, data, dataSize, actualSize); } /// - [UnmanagedCallersOnly(CallConvs = new[] { typeof(CallConvStdcall) })] - private static int SetResourceTextureManager8Impl(IUnknown* effect, byte* data, uint dataSize) + [UnmanagedCallersOnly] + public static HRESULT SetResourceTextureManager8Impl(IUnknown* effect, byte* data, uint dataSize) { return ((PixelShaderEffect*)effect)->SetResourceTextureManagerAtIndex(8, data, dataSize); } /// - [UnmanagedCallersOnly(CallConvs = new[] { typeof(CallConvStdcall) })] - private static int GetResourceTextureManager9Impl(IUnknown* effect, byte* data, uint dataSize, uint* actualSize) + [UnmanagedCallersOnly] + public static HRESULT GetResourceTextureManager9Impl(IUnknown* effect, byte* data, uint dataSize, uint* actualSize) { return ((PixelShaderEffect*)effect)->GetResourceTextureManagerAtIndex(9, data, dataSize, actualSize); } /// - [UnmanagedCallersOnly(CallConvs = new[] { typeof(CallConvStdcall) })] - private static int SetResourceTextureManager9Impl(IUnknown* effect, byte* data, uint dataSize) + [UnmanagedCallersOnly] + public static HRESULT SetResourceTextureManager9Impl(IUnknown* effect, byte* data, uint dataSize) { return ((PixelShaderEffect*)effect)->SetResourceTextureManagerAtIndex(9, data, dataSize); } /// - [UnmanagedCallersOnly(CallConvs = new[] { typeof(CallConvStdcall) })] - private static int GetResourceTextureManager10Impl(IUnknown* effect, byte* data, uint dataSize, uint* actualSize) + [UnmanagedCallersOnly] + public static HRESULT GetResourceTextureManager10Impl(IUnknown* effect, byte* data, uint dataSize, uint* actualSize) { return ((PixelShaderEffect*)effect)->GetResourceTextureManagerAtIndex(10, data, dataSize, actualSize); } /// - [UnmanagedCallersOnly(CallConvs = new[] { typeof(CallConvStdcall) })] - private static int SetResourceTextureManager10Impl(IUnknown* effect, byte* data, uint dataSize) + [UnmanagedCallersOnly] + public static HRESULT SetResourceTextureManager10Impl(IUnknown* effect, byte* data, uint dataSize) { return ((PixelShaderEffect*)effect)->SetResourceTextureManagerAtIndex(10, data, dataSize); } /// - [UnmanagedCallersOnly(CallConvs = new[] { typeof(CallConvStdcall) })] - private static int GetResourceTextureManager11Impl(IUnknown* effect, byte* data, uint dataSize, uint* actualSize) + [UnmanagedCallersOnly] + public static HRESULT GetResourceTextureManager11Impl(IUnknown* effect, byte* data, uint dataSize, uint* actualSize) { return ((PixelShaderEffect*)effect)->GetResourceTextureManagerAtIndex(11, data, dataSize, actualSize); } /// - [UnmanagedCallersOnly(CallConvs = new[] { typeof(CallConvStdcall) })] - private static int SetResourceTextureManager11Impl(IUnknown* effect, byte* data, uint dataSize) + [UnmanagedCallersOnly] + public static HRESULT SetResourceTextureManager11Impl(IUnknown* effect, byte* data, uint dataSize) { return ((PixelShaderEffect*)effect)->SetResourceTextureManagerAtIndex(11, data, dataSize); } /// - [UnmanagedCallersOnly(CallConvs = new[] { typeof(CallConvStdcall) })] - private static int GetResourceTextureManager12Impl(IUnknown* effect, byte* data, uint dataSize, uint* actualSize) + [UnmanagedCallersOnly] + public static HRESULT GetResourceTextureManager12Impl(IUnknown* effect, byte* data, uint dataSize, uint* actualSize) { return ((PixelShaderEffect*)effect)->GetResourceTextureManagerAtIndex(12, data, dataSize, actualSize); } /// - [UnmanagedCallersOnly(CallConvs = new[] { typeof(CallConvStdcall) })] - private static int SetResourceTextureManager12Impl(IUnknown* effect, byte* data, uint dataSize) + [UnmanagedCallersOnly] + public static HRESULT SetResourceTextureManager12Impl(IUnknown* effect, byte* data, uint dataSize) { return ((PixelShaderEffect*)effect)->SetResourceTextureManagerAtIndex(12, data, dataSize); } /// - [UnmanagedCallersOnly(CallConvs = new[] { typeof(CallConvStdcall) })] - private static int GetResourceTextureManager13Impl(IUnknown* effect, byte* data, uint dataSize, uint* actualSize) + [UnmanagedCallersOnly] + public static HRESULT GetResourceTextureManager13Impl(IUnknown* effect, byte* data, uint dataSize, uint* actualSize) { return ((PixelShaderEffect*)effect)->GetResourceTextureManagerAtIndex(13, data, dataSize, actualSize); } /// - [UnmanagedCallersOnly(CallConvs = new[] { typeof(CallConvStdcall) })] - private static int SetResourceTextureManager13Impl(IUnknown* effect, byte* data, uint dataSize) + [UnmanagedCallersOnly] + public static HRESULT SetResourceTextureManager13Impl(IUnknown* effect, byte* data, uint dataSize) { return ((PixelShaderEffect*)effect)->SetResourceTextureManagerAtIndex(13, data, dataSize); } /// - [UnmanagedCallersOnly(CallConvs = new[] { typeof(CallConvStdcall) })] - private static int GetResourceTextureManager14Impl(IUnknown* effect, byte* data, uint dataSize, uint* actualSize) + [UnmanagedCallersOnly] + public static HRESULT GetResourceTextureManager14Impl(IUnknown* effect, byte* data, uint dataSize, uint* actualSize) { return ((PixelShaderEffect*)effect)->GetResourceTextureManagerAtIndex(14, data, dataSize, actualSize); } /// - [UnmanagedCallersOnly(CallConvs = new[] { typeof(CallConvStdcall) })] - private static int SetResourceTextureManager14Impl(IUnknown* effect, byte* data, uint dataSize) + [UnmanagedCallersOnly] + public static HRESULT SetResourceTextureManager14Impl(IUnknown* effect, byte* data, uint dataSize) { return ((PixelShaderEffect*)effect)->SetResourceTextureManagerAtIndex(14, data, dataSize); } /// - [UnmanagedCallersOnly(CallConvs = new[] { typeof(CallConvStdcall) })] - private static int GetResourceTextureManager15Impl(IUnknown* effect, byte* data, uint dataSize, uint* actualSize) + [UnmanagedCallersOnly] + public static HRESULT GetResourceTextureManager15Impl(IUnknown* effect, byte* data, uint dataSize, uint* actualSize) { return ((PixelShaderEffect*)effect)->GetResourceTextureManagerAtIndex(15, data, dataSize, actualSize); } /// - [UnmanagedCallersOnly(CallConvs = new[] { typeof(CallConvStdcall) })] - private static int SetResourceTextureManager15Impl(IUnknown* effect, byte* data, uint dataSize) + [UnmanagedCallersOnly] + public static HRESULT SetResourceTextureManager15Impl(IUnknown* effect, byte* data, uint dataSize) { return ((PixelShaderEffect*)effect)->SetResourceTextureManagerAtIndex(15, data, dataSize); } diff --git a/src/ComputeSharp.D2D1/Shaders/Interop/Effects/PixelShaderEffect.Properties.tt b/src/ComputeSharp.D2D1/Shaders/Interop/Effects/PixelShaderEffect.Properties.tt index 8f9e4325..26ca5dab 100644 --- a/src/ComputeSharp.D2D1/Shaders/Interop/Effects/PixelShaderEffect.Properties.tt +++ b/src/ComputeSharp.D2D1/Shaders/Interop/Effects/PixelShaderEffect.Properties.tt @@ -1,7 +1,6 @@ <#@ template debug="false" hostspecific="false" language="C#" #> <#@ assembly name="System.Core" #> <#@ output extension=".g.cs"#> -using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using ComputeSharp.Win32; @@ -13,48 +12,17 @@ unsafe partial struct PixelShaderEffect <# for (int i = 0; i < 16; i++) { -#> - /// - /// Gets the get accessor for the resource manager at index <#=i#>. - /// - public static delegate* unmanaged[Stdcall] GetResourceTextureManager<#=i#> - { - [MethodImpl(MethodImplOptions.AggressiveInlining)] - get - { - return &GetResourceTextureManager<#=i#>Impl; - } - } - - /// - /// Gets the set accessor for the resource manager at index <#=i#>. - /// - public static delegate* unmanaged[Stdcall] SetResourceTextureManager<#=i#> - { - [MethodImpl(MethodImplOptions.AggressiveInlining)] - get - { - return &SetResourceTextureManager<#=i#>Impl; - } - } - -<# -} -#> -<# -for (int i = 0; i < 16; i++) -{ #> /// - [UnmanagedCallersOnly(CallConvs = new[] { typeof(CallConvStdcall) })] - private static int GetResourceTextureManager<#=i#>Impl(IUnknown* effect, byte* data, uint dataSize, uint* actualSize) + [UnmanagedCallersOnly] + public static HRESULT GetResourceTextureManager<#=i#>Impl(IUnknown* effect, byte* data, uint dataSize, uint* actualSize) { return ((PixelShaderEffect*)effect)->GetResourceTextureManagerAtIndex(<#=i#>, data, dataSize, actualSize); } /// - [UnmanagedCallersOnly(CallConvs = new[] { typeof(CallConvStdcall) })] - private static int SetResourceTextureManager<#=i#>Impl(IUnknown* effect, byte* data, uint dataSize) + [UnmanagedCallersOnly] + public static HRESULT SetResourceTextureManager<#=i#>Impl(IUnknown* effect, byte* data, uint dataSize) { return ((PixelShaderEffect*)effect)->SetResourceTextureManagerAtIndex(<#=i#>, data, dataSize); } diff --git a/src/ComputeSharp.Win32.D2D1/DirectX/um/d2d1effectauthor/D2D1_PROPERTY_BINDING.cs b/src/ComputeSharp.Win32.D2D1/DirectX/um/d2d1effectauthor/D2D1_PROPERTY_BINDING.cs index cfb91870..ce1c8f3a 100644 --- a/src/ComputeSharp.Win32.D2D1/DirectX/um/d2d1effectauthor/D2D1_PROPERTY_BINDING.cs +++ b/src/ComputeSharp.Win32.D2D1/DirectX/um/d2d1effectauthor/D2D1_PROPERTY_BINDING.cs @@ -13,8 +13,8 @@ internal unsafe partial struct D2D1_PROPERTY_BINDING public ushort* propertyName; [NativeTypeName("PD2D1_PROPERTY_SET_FUNCTION")] - public delegate* unmanaged[Stdcall] setFunction; + public delegate* unmanaged setFunction; [NativeTypeName("PD2D1_PROPERTY_GET_FUNCTION")] - public delegate* unmanaged[Stdcall] getFunction; + public delegate* unmanaged getFunction; } \ No newline at end of file From 813f5a18f18148bd01d6951674d6350ae0c79f37 Mon Sep 17 00:00:00 2001 From: Sergio Pedri Date: Wed, 18 Oct 2023 13:22:36 +0200 Subject: [PATCH 4/5] Remove downlevel paths in ComputeSharp --- src/ComputeSharp/Core/Imaging/Bgra32.cs | 12 +- src/ComputeSharp/Core/Imaging/R16.cs | 7 +- src/ComputeSharp/Core/Imaging/R8.cs | 7 +- src/ComputeSharp/Core/Imaging/Rg16.cs | 7 +- src/ComputeSharp/Core/Imaging/Rg32.cs | 7 +- src/ComputeSharp/Core/Imaging/Rgba32.cs | 12 +- src/ComputeSharp/Core/Imaging/Rgba64.cs | 12 +- .../Extensions/Interop/ComPtrExtensions.cs | 4 - .../IWICStreamExtensions.IBufferWriter.cs | 158 +----------------- .../Interop/IWICStreamExtensions.Stream.cs | 158 +----------------- .../Extensions/Texture1DExtensions.cs | 12 -- .../Extensions/Texture2DExtensions.cs | 12 -- .../Extensions/Texture3DExtensions.cs | 10 -- .../Graphics/GraphicsDevice.DeviceLost.cs | 11 -- .../Graphics/GraphicsDevice.Execute.cs | 31 ---- .../Helpers/DeviceHelper.IDXGIFactory6.cs | 45 ----- .../Interop/Allocation/ID3D12Allocation.cs | 7 +- .../Allocation/ID3D12MemoryAllocator.cs | 7 +- .../ID3D12MemoryAllocatorFactory.cs | 7 +- src/ComputeSharp/Graphics/Luid.cs | 7 +- src/ComputeSharp/Shaders/ComputeContext.cs | 4 - 21 files changed, 22 insertions(+), 515 deletions(-) diff --git a/src/ComputeSharp/Core/Imaging/Bgra32.cs b/src/ComputeSharp/Core/Imaging/Bgra32.cs index 1c2e6393..d73398a1 100644 --- a/src/ComputeSharp/Core/Imaging/Bgra32.cs +++ b/src/ComputeSharp/Core/Imaging/Bgra32.cs @@ -2,10 +2,8 @@ using System; using System.Numerics; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; -#if NET6_0_OR_GREATER using System.Runtime.Intrinsics; using System.Runtime.Intrinsics.X86; -#endif namespace ComputeSharp; @@ -19,10 +17,7 @@ namespace ComputeSharp; /// /// This struct is fully mutable. [StructLayout(LayoutKind.Sequential)] -public struct Bgra32 : IEquatable, IPixel -#if NET6_0_OR_GREATER - , ISpanFormattable -#endif +public struct Bgra32 : IEquatable, IPixel, ISpanFormattable { /// /// The blue component. @@ -91,7 +86,6 @@ public struct Bgra32 : IEquatable, IPixel [MethodImpl(MethodImplOptions.AggressiveInlining)] public readonly Float4 ToPixel() { -#if NET6_0_OR_GREATER if (Sse2.IsSupported) { int pack = Unsafe.As(ref Unsafe.AsRef(in this)); @@ -106,7 +100,7 @@ public struct Bgra32 : IEquatable, IPixel return vNorm.AsVector4(); } -#endif + Vector4 linear = new(this.R, this.G, this.B, this.A); Vector4 normalized = linear / byte.MaxValue; @@ -161,7 +155,6 @@ public struct Bgra32 : IEquatable, IPixel return $"{nameof(Bgra32)}({this.B}, {this.G}, {this.R}, {this.A})"; } -#if NET6_0_OR_GREATER /// public string ToString(string? format, IFormatProvider? formatProvider) { @@ -173,5 +166,4 @@ public struct Bgra32 : IEquatable, IPixel { return destination.TryWrite(provider, $"{nameof(Bgra32)}({this.B}, {this.G}, {this.R}, {this.A})", out charsWritten); } -#endif } \ No newline at end of file diff --git a/src/ComputeSharp/Core/Imaging/R16.cs b/src/ComputeSharp/Core/Imaging/R16.cs index 35b61732..f898ab70 100644 --- a/src/ComputeSharp/Core/Imaging/R16.cs +++ b/src/ComputeSharp/Core/Imaging/R16.cs @@ -11,10 +11,7 @@ namespace ComputeSharp; /// /// [StructLayout(LayoutKind.Sequential)] -public struct R16 : IEquatable, IPixel -#if NET6_0_OR_GREATER - , ISpanFormattable -#endif +public struct R16 : IEquatable, IPixel, ISpanFormattable { /// /// The red component. @@ -97,7 +94,6 @@ public struct R16 : IEquatable, IPixel return $"{nameof(R16)}({this.R})"; } -#if NET6_0_OR_GREATER /// public string ToString(string? format, IFormatProvider? formatProvider) { @@ -109,5 +105,4 @@ public struct R16 : IEquatable, IPixel { return destination.TryWrite(provider, $"{nameof(R16)}({this.R})", out charsWritten); } -#endif } \ No newline at end of file diff --git a/src/ComputeSharp/Core/Imaging/R8.cs b/src/ComputeSharp/Core/Imaging/R8.cs index d46c8315..c6f1c169 100644 --- a/src/ComputeSharp/Core/Imaging/R8.cs +++ b/src/ComputeSharp/Core/Imaging/R8.cs @@ -11,10 +11,7 @@ namespace ComputeSharp; /// /// [StructLayout(LayoutKind.Sequential)] -public struct R8 : IEquatable, IPixel -#if NET6_0_OR_GREATER - , ISpanFormattable -#endif +public struct R8 : IEquatable, IPixel, ISpanFormattable { /// /// The red component. @@ -97,7 +94,6 @@ public struct R8 : IEquatable, IPixel return $"{nameof(R8)}({this.R})"; } -#if NET6_0_OR_GREATER /// public string ToString(string? format, IFormatProvider? formatProvider) { @@ -109,5 +105,4 @@ public struct R8 : IEquatable, IPixel { return destination.TryWrite(provider, $"{nameof(R8)}({this.R})", out charsWritten); } -#endif } \ No newline at end of file diff --git a/src/ComputeSharp/Core/Imaging/Rg16.cs b/src/ComputeSharp/Core/Imaging/Rg16.cs index 1ae01ab8..19092181 100644 --- a/src/ComputeSharp/Core/Imaging/Rg16.cs +++ b/src/ComputeSharp/Core/Imaging/Rg16.cs @@ -11,10 +11,7 @@ namespace ComputeSharp; /// /// [StructLayout(LayoutKind.Sequential)] -public struct Rg16 : IEquatable, IPixel -#if NET6_0_OR_GREATER - , ISpanFormattable -#endif +public struct Rg16 : IEquatable, IPixel, ISpanFormattable { /// /// The red component. @@ -104,7 +101,6 @@ public struct Rg16 : IEquatable, IPixel return $"{nameof(Rg16)}({this.R}, {this.G})"; } -#if NET6_0_OR_GREATER /// public string ToString(string? format, IFormatProvider? formatProvider) { @@ -116,5 +112,4 @@ public struct Rg16 : IEquatable, IPixel { return destination.TryWrite(provider, $"{nameof(Rg16)}({this.R}, {this.G})", out charsWritten); } -#endif } \ No newline at end of file diff --git a/src/ComputeSharp/Core/Imaging/Rg32.cs b/src/ComputeSharp/Core/Imaging/Rg32.cs index 3262b123..45d63aee 100644 --- a/src/ComputeSharp/Core/Imaging/Rg32.cs +++ b/src/ComputeSharp/Core/Imaging/Rg32.cs @@ -11,10 +11,7 @@ namespace ComputeSharp; /// /// [StructLayout(LayoutKind.Sequential)] -public struct Rg32 : IEquatable, IPixel -#if NET6_0_OR_GREATER - , ISpanFormattable -#endif +public struct Rg32 : IEquatable, IPixel, ISpanFormattable { /// /// The red component. @@ -104,7 +101,6 @@ public struct Rg32 : IEquatable, IPixel return $"{nameof(Rg32)}({this.R}, {this.G})"; } -#if NET6_0_OR_GREATER /// public string ToString(string? format, IFormatProvider? formatProvider) { @@ -116,5 +112,4 @@ public struct Rg32 : IEquatable, IPixel { return destination.TryWrite(provider, $"{nameof(Rg32)}({this.R}, {this.G})", out charsWritten); } -#endif } \ No newline at end of file diff --git a/src/ComputeSharp/Core/Imaging/Rgba32.cs b/src/ComputeSharp/Core/Imaging/Rgba32.cs index 61fc1f32..1ac835da 100644 --- a/src/ComputeSharp/Core/Imaging/Rgba32.cs +++ b/src/ComputeSharp/Core/Imaging/Rgba32.cs @@ -2,10 +2,8 @@ using System; using System.Numerics; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; -#if NET6_0_OR_GREATER using System.Runtime.Intrinsics; using System.Runtime.Intrinsics.X86; -#endif namespace ComputeSharp; @@ -18,10 +16,7 @@ namespace ComputeSharp; /// /// This struct is fully mutable. [StructLayout(LayoutKind.Sequential)] -public struct Rgba32 : IEquatable, IPixel -#if NET6_0_OR_GREATER - , ISpanFormattable -#endif +public struct Rgba32 : IEquatable, IPixel, ISpanFormattable { /// /// The red component. @@ -90,7 +85,6 @@ public struct Rgba32 : IEquatable, IPixel [MethodImpl(MethodImplOptions.AggressiveInlining)] public readonly Float4 ToPixel() { -#if NET6_0_OR_GREATER if (Sse2.IsSupported) { int pack = Unsafe.As(ref Unsafe.AsRef(in this)); @@ -104,7 +98,7 @@ public struct Rgba32 : IEquatable, IPixel return vNorm.AsVector4(); } -#endif + Vector4 linear = new(this.R, this.G, this.B, this.A); Vector4 normalized = linear / byte.MaxValue; @@ -159,7 +153,6 @@ public struct Rgba32 : IEquatable, IPixel return $"{nameof(Rgba32)}({this.R}, {this.G}, {this.B}, {this.A})"; } -#if NET6_0_OR_GREATER /// public string ToString(string? format, IFormatProvider? formatProvider) { @@ -171,5 +164,4 @@ public struct Rgba32 : IEquatable, IPixel { return destination.TryWrite(provider, $"{nameof(Rgba32)}({this.R}, {this.G}, {this.B}, {this.A})", out charsWritten); } -#endif } \ No newline at end of file diff --git a/src/ComputeSharp/Core/Imaging/Rgba64.cs b/src/ComputeSharp/Core/Imaging/Rgba64.cs index 51f9e3a3..d65aea56 100644 --- a/src/ComputeSharp/Core/Imaging/Rgba64.cs +++ b/src/ComputeSharp/Core/Imaging/Rgba64.cs @@ -2,10 +2,8 @@ using System; using System.Numerics; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; -#if NET6_0_OR_GREATER using System.Runtime.Intrinsics; using System.Runtime.Intrinsics.X86; -#endif namespace ComputeSharp; @@ -18,10 +16,7 @@ namespace ComputeSharp; /// /// This struct is fully mutable. [StructLayout(LayoutKind.Sequential)] -public struct Rgba64 : IEquatable, IPixel -#if NET6_0_OR_GREATER - , ISpanFormattable -#endif +public struct Rgba64 : IEquatable, IPixel, ISpanFormattable { /// /// The red component. @@ -90,7 +85,6 @@ public struct Rgba64 : IEquatable, IPixel [MethodImpl(MethodImplOptions.AggressiveInlining)] public readonly Float4 ToPixel() { -#if NET6_0_OR_GREATER if (Sse2.IsSupported) { long pack = Unsafe.As(ref Unsafe.AsRef(in this)); @@ -102,7 +96,7 @@ public struct Rgba64 : IEquatable, IPixel return vNorm.AsVector4(); } -#endif + Vector4 linear = new(this.R, this.G, this.B, this.A); Vector4 normalized = linear / ushort.MaxValue; @@ -157,7 +151,6 @@ public struct Rgba64 : IEquatable, IPixel return $"{nameof(Rgba64)}({this.R}, {this.G}, {this.B}, {this.A})"; } -#if NET6_0_OR_GREATER /// public string ToString(string? format, IFormatProvider? formatProvider) { @@ -169,5 +162,4 @@ public struct Rgba64 : IEquatable, IPixel { return destination.TryWrite(provider, $"{nameof(Rgba64)}({this.R}, {this.G}, {this.B}, {this.A})", out charsWritten); } -#endif } \ No newline at end of file diff --git a/src/ComputeSharp/Graphics/Extensions/Interop/ComPtrExtensions.cs b/src/ComputeSharp/Graphics/Extensions/Interop/ComPtrExtensions.cs index cc1dd87e..33690232 100644 --- a/src/ComputeSharp/Graphics/Extensions/Interop/ComPtrExtensions.cs +++ b/src/ComputeSharp/Graphics/Extensions/Interop/ComPtrExtensions.cs @@ -16,11 +16,7 @@ internal static class ComPtrExtensions /// The moved instance. [MethodImpl(MethodImplOptions.AggressiveInlining)] public static unsafe ComPtr Move(this in ComPtr ptr) -#if NET6_0_OR_GREATER where T : unmanaged//, IUnknown.Interface -#else - where T : unmanaged -#endif { ComPtr copy = default; diff --git a/src/ComputeSharp/Graphics/Extensions/Interop/IWICStreamExtensions.IBufferWriter.cs b/src/ComputeSharp/Graphics/Extensions/Interop/IWICStreamExtensions.IBufferWriter.cs index fc4e69e7..ba509cb3 100644 --- a/src/ComputeSharp/Graphics/Extensions/Interop/IWICStreamExtensions.IBufferWriter.cs +++ b/src/ComputeSharp/Graphics/Extensions/Interop/IWICStreamExtensions.IBufferWriter.cs @@ -35,141 +35,10 @@ unsafe partial class IWICStreamExtensions /// /// A manual CCW implementation for an object wrapping an instance. /// - private unsafe partial struct IBufferWriterWrapper -#if NET6_0_OR_GREATER - //: IUnknown.Interface -#endif + private unsafe partial struct IBufferWriterWrapper //: IUnknown.Interface { -#if NET6_0_OR_GREATER ///// //static Guid* INativeGuid.NativeGuid => (Guid*)default(NotSupportedException).Throw(); -#else - /// - [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); - - /// - /// A cached instance wrapping . - /// - private static readonly QueryInterfaceDelegate QueryInterfaceWrapper = QueryInterface; - - /// - /// A cached instance wrapping . - /// - private static readonly AddRefDelegate AddRefWrapper = AddRef; - - /// - /// A cached instance wrapping . - /// - private static readonly ReleaseDelegate ReleaseWrapper = Release; - - /// - /// A cached instance wrapping . - /// - private static readonly ReadDelegate ReadWrapper = Read; - - /// - /// A cached instance wrapping . - /// - private static readonly WriteDelegate WriteWrapper = Write; - - /// - /// A cached instance wrapping . - /// - private static readonly SeekDelegate SeekWrapper = Seek; - - /// - /// A cached instance wrapping . - /// - private static readonly SetSizeDelegate SetSizeWrapper = SetSize; - - /// - /// A cached instance wrapping . - /// - private static readonly CopyToDelegate CopyToWrapper = CopyTo; - - /// - /// A cached instance wrapping . - /// - private static readonly CommitDelegate CommitWrapper = Commit; - - /// - /// A cached instance wrapping . - /// - private static readonly RevertDelegate RevertWrapper = Revert; - - /// - /// A cached instance wrapping . - /// - private static readonly LockRegionDelegate LockRegionWrapper = LockRegion; - - /// - /// A cached instance wrapping . - /// - private static readonly UnlockRegionDelegate UnlockRegionWrapper = UnlockRegion; - - /// - /// A cached instance wrapping . - /// - private static readonly StatDelegate StatWrapper = Stat; - - /// - /// A cached instance wrapping . - /// - private static readonly CloneDelegate CloneWrapper = Clone; -#endif /// /// The shared vtable pointer for instances. @@ -184,7 +53,6 @@ unsafe partial class IWICStreamExtensions { void** lpVtbl = (void**)RuntimeHelpers.AllocateTypeAssociatedMemory(typeof(IBufferWriterWrapper), sizeof(void*) * 14); -#if NET6_0_OR_GREATER lpVtbl[0] = (delegate* unmanaged)&QueryInterface; lpVtbl[1] = (delegate* unmanaged)&AddRef; lpVtbl[2] = (delegate* unmanaged)&Release; @@ -199,22 +67,6 @@ unsafe partial class IWICStreamExtensions lpVtbl[11] = (delegate* unmanaged)&UnlockRegion; lpVtbl[12] = (delegate* unmanaged)&Stat; lpVtbl[13] = (delegate* unmanaged)&Clone; -#else - lpVtbl[0] = (void*)Marshal.GetFunctionPointerForDelegate(QueryInterfaceWrapper); - lpVtbl[1] = (void*)Marshal.GetFunctionPointerForDelegate(AddRefWrapper); - lpVtbl[2] = (void*)Marshal.GetFunctionPointerForDelegate(ReleaseWrapper); - lpVtbl[3] = (void*)Marshal.GetFunctionPointerForDelegate(ReadWrapper); - lpVtbl[4] = (void*)Marshal.GetFunctionPointerForDelegate(WriteWrapper); - lpVtbl[5] = (void*)Marshal.GetFunctionPointerForDelegate(SeekWrapper); - lpVtbl[6] = (void*)Marshal.GetFunctionPointerForDelegate(SetSizeWrapper); - lpVtbl[7] = (void*)Marshal.GetFunctionPointerForDelegate(CopyToWrapper); - lpVtbl[8] = (void*)Marshal.GetFunctionPointerForDelegate(CommitWrapper); - lpVtbl[9] = (void*)Marshal.GetFunctionPointerForDelegate(RevertWrapper); - lpVtbl[10] = (void*)Marshal.GetFunctionPointerForDelegate(LockRegionWrapper); - lpVtbl[11] = (void*)Marshal.GetFunctionPointerForDelegate(UnlockRegionWrapper); - lpVtbl[12] = (void*)Marshal.GetFunctionPointerForDelegate(StatWrapper); - lpVtbl[13] = (void*)Marshal.GetFunctionPointerForDelegate(CloneWrapper); -#endif return lpVtbl; } @@ -260,25 +112,23 @@ unsafe partial class IWICStreamExtensions return Unsafe.As>(this.writerHandle.Target!); } -#if NET6_0_OR_GREATER /// - public HRESULT QueryInterface(Guid* riid, void** ppvObject) + private HRESULT QueryInterface(Guid* riid, void** ppvObject) { return ((delegate* unmanaged)this.lpVtbl[0])((IBufferWriterWrapper*)Unsafe.AsPointer(ref this), riid, ppvObject); } /// - public uint AddRef() + private uint AddRef() { return ((delegate* unmanaged)this.lpVtbl[1])((IBufferWriterWrapper*)Unsafe.AsPointer(ref this)); } /// - public uint Release() + private uint Release() { return ((delegate* unmanaged)this.lpVtbl[2])((IBufferWriterWrapper*)Unsafe.AsPointer(ref this)); } -#endif /// [UnmanagedCallersOnly] diff --git a/src/ComputeSharp/Graphics/Extensions/Interop/IWICStreamExtensions.Stream.cs b/src/ComputeSharp/Graphics/Extensions/Interop/IWICStreamExtensions.Stream.cs index 33669a79..926e6948 100644 --- a/src/ComputeSharp/Graphics/Extensions/Interop/IWICStreamExtensions.Stream.cs +++ b/src/ComputeSharp/Graphics/Extensions/Interop/IWICStreamExtensions.Stream.cs @@ -37,141 +37,10 @@ internal static unsafe partial class IWICStreamExtensions /// /// A manual CCW implementation for an object wrapping a instance. /// - private unsafe partial struct IStreamWrapper -#if NET6_0_OR_GREATER - //: IUnknown.Interface -#endif + private unsafe partial struct IStreamWrapper //: IUnknown.Interface { -#if NET6_0_OR_GREATER ///// //static Guid* INativeGuid.NativeGuid => (Guid*)default(NotSupportedException).Throw(); -#else - /// - [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); - - /// - /// A cached instance wrapping . - /// - private static readonly QueryInterfaceDelegate QueryInterfaceWrapper = QueryInterface; - - /// - /// A cached instance wrapping . - /// - private static readonly AddRefDelegate AddRefWrapper = AddRef; - - /// - /// A cached instance wrapping . - /// - private static readonly ReleaseDelegate ReleaseWrapper = Release; - - /// - /// A cached instance wrapping . - /// - private static readonly ReadDelegate ReadWrapper = Read; - - /// - /// A cached instance wrapping . - /// - private static readonly WriteDelegate WriteWrapper = Write; - - /// - /// A cached instance wrapping . - /// - private static readonly SeekDelegate SeekWrapper = Seek; - - /// - /// A cached instance wrapping . - /// - private static readonly SetSizeDelegate SetSizeWrapper = SetSize; - - /// - /// A cached instance wrapping . - /// - private static readonly CopyToDelegate CopyToWrapper = CopyTo; - - /// - /// A cached instance wrapping . - /// - private static readonly CommitDelegate CommitWrapper = Commit; - - /// - /// A cached instance wrapping . - /// - private static readonly RevertDelegate RevertWrapper = Revert; - - /// - /// A cached instance wrapping . - /// - private static readonly LockRegionDelegate LockRegionWrapper = LockRegion; - - /// - /// A cached instance wrapping . - /// - private static readonly UnlockRegionDelegate UnlockRegionWrapper = UnlockRegion; - - /// - /// A cached instance wrapping . - /// - private static readonly StatDelegate StatWrapper = Stat; - - /// - /// A cached instance wrapping . - /// - private static readonly CloneDelegate CloneWrapper = Clone; -#endif /// /// The shared vtable pointer for instances. @@ -186,7 +55,6 @@ internal static unsafe partial class IWICStreamExtensions { void** lpVtbl = (void**)RuntimeHelpers.AllocateTypeAssociatedMemory(typeof(IStreamWrapper), sizeof(void*) * 14); -#if NET6_0_OR_GREATER lpVtbl[0] = (delegate* unmanaged)&QueryInterface; lpVtbl[1] = (delegate* unmanaged)&AddRef; lpVtbl[2] = (delegate* unmanaged)&Release; @@ -201,22 +69,6 @@ internal static unsafe partial class IWICStreamExtensions lpVtbl[11] = (delegate* unmanaged)&UnlockRegion; lpVtbl[12] = (delegate* unmanaged)&Stat; lpVtbl[13] = (delegate* unmanaged)&Clone; -#else - lpVtbl[0] = (void*)Marshal.GetFunctionPointerForDelegate(QueryInterfaceWrapper); - lpVtbl[1] = (void*)Marshal.GetFunctionPointerForDelegate(AddRefWrapper); - lpVtbl[2] = (void*)Marshal.GetFunctionPointerForDelegate(ReleaseWrapper); - lpVtbl[3] = (void*)Marshal.GetFunctionPointerForDelegate(ReadWrapper); - lpVtbl[4] = (void*)Marshal.GetFunctionPointerForDelegate(WriteWrapper); - lpVtbl[5] = (void*)Marshal.GetFunctionPointerForDelegate(SeekWrapper); - lpVtbl[6] = (void*)Marshal.GetFunctionPointerForDelegate(SetSizeWrapper); - lpVtbl[7] = (void*)Marshal.GetFunctionPointerForDelegate(CopyToWrapper); - lpVtbl[8] = (void*)Marshal.GetFunctionPointerForDelegate(CommitWrapper); - lpVtbl[9] = (void*)Marshal.GetFunctionPointerForDelegate(RevertWrapper); - lpVtbl[10] = (void*)Marshal.GetFunctionPointerForDelegate(LockRegionWrapper); - lpVtbl[11] = (void*)Marshal.GetFunctionPointerForDelegate(UnlockRegionWrapper); - lpVtbl[12] = (void*)Marshal.GetFunctionPointerForDelegate(StatWrapper); - lpVtbl[13] = (void*)Marshal.GetFunctionPointerForDelegate(CloneWrapper); -#endif return lpVtbl; } @@ -262,25 +114,23 @@ internal static unsafe partial class IWICStreamExtensions return Unsafe.As(this.streamHandle.Target!); } -#if NET6_0_OR_GREATER /// - public HRESULT QueryInterface(Guid* riid, void** ppvObject) + private HRESULT QueryInterface(Guid* riid, void** ppvObject) { return ((delegate* unmanaged)this.lpVtbl[0])((IStreamWrapper*)Unsafe.AsPointer(ref this), riid, ppvObject); } /// - public uint AddRef() + private uint AddRef() { return ((delegate* unmanaged)this.lpVtbl[1])((IStreamWrapper*)Unsafe.AsPointer(ref this)); } /// - public uint Release() + private uint Release() { return ((delegate* unmanaged)this.lpVtbl[2])((IStreamWrapper*)Unsafe.AsPointer(ref this)); } -#endif /// [UnmanagedCallersOnly] diff --git a/src/ComputeSharp/Graphics/Extensions/Texture1DExtensions.cs b/src/ComputeSharp/Graphics/Extensions/Texture1DExtensions.cs index 5b054655..c2dc4378 100644 --- a/src/ComputeSharp/Graphics/Extensions/Texture1DExtensions.cs +++ b/src/ComputeSharp/Graphics/Extensions/Texture1DExtensions.cs @@ -66,7 +66,6 @@ public static class Texture1DExtensions source.CopyTo(destination.AsSpan(), 0, source.Width); } -#if NET6_0_OR_GREATER /// /// Reads the contents of the specified range from the current instance and writes them into a target array. /// @@ -82,7 +81,6 @@ public static class Texture1DExtensions source.CopyTo(destination.AsSpan(), x); } -#endif /// /// Reads the contents of the specified range from the current instance and writes them into a target array. @@ -117,7 +115,6 @@ public static class Texture1DExtensions source.CopyTo(destination.AsSpan(destinationOffset), 0, source.Width); } -#if NET6_0_OR_GREATER /// /// Reads the contents of the specified range from the current instance and writes them into a target array. /// @@ -134,7 +131,6 @@ public static class Texture1DExtensions source.CopyTo(destination.AsSpan(destinationOffset), x); } -#endif /// /// Reads the contents of the specified range from the current instance and writes them into a target array. @@ -169,7 +165,6 @@ public static class Texture1DExtensions source.CopyTo(destination, 0, source.Width); } -#if NET6_0_OR_GREATER /// /// Reads the contents of the specified range from the current instance and writes them into a target . /// @@ -186,7 +181,6 @@ public static class Texture1DExtensions source.CopyTo(destination, offsetX, width); } -#endif /// /// Reads the contents of the specified range from the current instance and writes them into a target . @@ -319,7 +313,6 @@ public static class Texture1DExtensions destination.CopyFrom(source.AsSpan(), 0, destination.Width); } -#if NET6_0_OR_GREATER /// /// Writes the contents of a given array to a specified area of the current instance. /// @@ -335,7 +328,6 @@ public static class Texture1DExtensions destination.CopyFrom(source.AsSpan(), x); } -#endif /// /// Writes the contents of a given array to a specified area of the current instance. @@ -354,7 +346,6 @@ public static class Texture1DExtensions destination.CopyFrom(source.AsSpan(), destinationOffsetX, width); } -#if NET6_0_OR_GREATER /// /// Writes the contents of a given array to a specified area of the current instance. /// @@ -371,7 +362,6 @@ public static class Texture1DExtensions destination.CopyFrom(source.AsSpan(sourceOffset), x); } -#endif /// /// Writes the contents of a given array to a specified area of the current instance. @@ -406,7 +396,6 @@ public static class Texture1DExtensions destination.CopyFrom(source, 0, destination.Width); } -#if NET6_0_OR_GREATER /// /// Writes the contents of a given to a specified area of the current instance. /// @@ -423,7 +412,6 @@ public static class Texture1DExtensions destination.CopyFrom(source, offsetX, width); } -#endif /// /// Writes the contents of a given to a specified area of the current instance. diff --git a/src/ComputeSharp/Graphics/Extensions/Texture2DExtensions.cs b/src/ComputeSharp/Graphics/Extensions/Texture2DExtensions.cs index 16f288ab..c42d7f7b 100644 --- a/src/ComputeSharp/Graphics/Extensions/Texture2DExtensions.cs +++ b/src/ComputeSharp/Graphics/Extensions/Texture2DExtensions.cs @@ -89,7 +89,6 @@ public static class Texture2DExtensions source.CopyTo(destination.AsSpan(), 0, 0, source.Width, source.Height); } -#if NET6_0_OR_GREATER /// /// Reads the contents of the specified range from the current instance and writes them into a target array. /// @@ -106,7 +105,6 @@ public static class Texture2DExtensions source.CopyTo(destination.AsSpan(), x, y); } -#endif /// /// Reads the contents of the specified range from the current instance and writes them into a target array. @@ -143,7 +141,6 @@ public static class Texture2DExtensions source.CopyTo(destination.AsSpan(destinationOffset), 0, 0, source.Width, source.Height); } -#if NET6_0_OR_GREATER /// /// Reads the contents of the specified range from the current instance and writes them into a target array. /// @@ -161,7 +158,6 @@ public static class Texture2DExtensions source.CopyTo(destination.AsSpan(destinationOffset), x, y); } -#endif /// /// Reads the contents of the specified range from the current instance and writes them into a target array. @@ -198,7 +194,6 @@ public static class Texture2DExtensions source.CopyTo(destination, 0, 0, source.Width, source.Height); } -#if NET6_0_OR_GREATER /// /// Reads the contents of the specified range from the current instance and writes them into a target . /// @@ -217,7 +212,6 @@ public static class Texture2DExtensions source.CopyTo(destination, offsetX, offsetY, width, height); } -#endif /// /// Reads the contents of the specified range from the current instance and writes them into a target . @@ -379,7 +373,6 @@ public static class Texture2DExtensions destination.CopyFrom(source.AsSpan(), 0, 0, destination.Width, destination.Height); } -#if NET6_0_OR_GREATER /// /// Writes the contents of a given array to a specified area of the current instance. /// @@ -396,7 +389,6 @@ public static class Texture2DExtensions destination.CopyFrom(source.AsSpan(), x, y); } -#endif /// /// Writes the contents of a given array to a specified area of the current instance. @@ -417,7 +409,6 @@ public static class Texture2DExtensions destination.CopyFrom(source.AsSpan(), destinationOffsetX, destinationOffsetY, width, height); } -#if NET6_0_OR_GREATER /// /// Writes the contents of a given array to a specified area of the current instance. /// @@ -435,7 +426,6 @@ public static class Texture2DExtensions destination.CopyFrom(source.AsSpan(sourceOffset), x, y); } -#endif /// /// Writes the contents of a given array to a specified area of the current instance. @@ -472,7 +462,6 @@ public static class Texture2DExtensions destination.CopyFrom(source, 0, 0, destination.Width, destination.Height); } -#if NET6_0_OR_GREATER /// /// Writes the contents of a given to a specified area of the current instance. /// @@ -491,7 +480,6 @@ public static class Texture2DExtensions destination.CopyFrom(source, offsetX, offsetY, width, height); } -#endif /// /// Writes the contents of a given to a specified area of the current instance. diff --git a/src/ComputeSharp/Graphics/Extensions/Texture3DExtensions.cs b/src/ComputeSharp/Graphics/Extensions/Texture3DExtensions.cs index e38b9859..4fcb8592 100644 --- a/src/ComputeSharp/Graphics/Extensions/Texture3DExtensions.cs +++ b/src/ComputeSharp/Graphics/Extensions/Texture3DExtensions.cs @@ -100,7 +100,6 @@ public static class Texture3DExtensions source.CopyTo(destination.AsSpan(destinationOffset), 0, 0, 0, source.Width, source.Height, source.Depth); } -#if NET6_0_OR_GREATER /// /// Reads the contents of the specified range from the current instance and writes them into a target array. /// @@ -119,7 +118,6 @@ public static class Texture3DExtensions source.CopyTo(destination.AsSpan(destinationOffset), x, y, z); } -#endif /// /// Reads the contents of the specified range from the current instance and writes them into a target array. @@ -157,7 +155,6 @@ public static class Texture3DExtensions source.CopyTo(destination, 0, 0, 0, source.Width, source.Height, source.Depth); } -#if NET6_0_OR_GREATER /// /// Reads the contents of the specified range from the current instance and writes them into a target . /// @@ -178,7 +175,6 @@ public static class Texture3DExtensions source.CopyTo(destination, offsetX, offsetY, offsetZ, width, height, depth); } -#endif /// /// Reads the contents of the specified range from the current instance and writes them into a target . @@ -357,7 +353,6 @@ public static class Texture3DExtensions destination.CopyFrom(source.AsSpan(), 0, 0, 0, destination.Width, destination.Height, destination.Depth); } -#if NET6_0_OR_GREATER /// /// Writes the contents of a given array to a specified area of the current instance. /// @@ -375,7 +370,6 @@ public static class Texture3DExtensions destination.CopyFrom(source.AsSpan(), x, y, z); } -#endif /// /// Writes the contents of a given array to a specified area of the current instance. @@ -398,7 +392,6 @@ public static class Texture3DExtensions destination.CopyFrom(source.AsSpan(), destinationOffsetX, destinationOffsetY, destinationOffsetZ, width, height, depth); } -#if NET6_0_OR_GREATER /// /// Writes the contents of a given array to a specified area of the current instance. /// @@ -417,7 +410,6 @@ public static class Texture3DExtensions destination.CopyFrom(source.AsSpan(sourceOffset), x, y, z); } -#endif /// /// Writes the contents of a given array to a specified area of the current instance. @@ -456,7 +448,6 @@ public static class Texture3DExtensions destination.CopyFrom(source, 0, 0, 0, destination.Width, destination.Height, destination.Depth); } -#if NET6_0_OR_GREATER /// /// Writes the contents of a given to a specified area of the current instance. /// @@ -477,7 +468,6 @@ public static class Texture3DExtensions destination.CopyFrom(source, offsetX, offsetY, offsetZ, width, height, depth); } -#endif /// /// Writes the contents of a given to a specified area of the current instance. diff --git a/src/ComputeSharp/Graphics/GraphicsDevice.DeviceLost.cs b/src/ComputeSharp/Graphics/GraphicsDevice.DeviceLost.cs index ae9f9c21..aec1095a 100644 --- a/src/ComputeSharp/Graphics/GraphicsDevice.DeviceLost.cs +++ b/src/ComputeSharp/Graphics/GraphicsDevice.DeviceLost.cs @@ -11,13 +11,6 @@ namespace ComputeSharp; /// unsafe partial class GraphicsDevice { -#if !NET6_0_OR_GREATER - /// - /// A cached instance wrapping . - /// - private static readonly WaitForSingleObjectCallbackDelegate WaitForSingleObjectCallbackForRegisterDeviceLostCallbackWrapper = WaitForSingleObjectCallbackForRegisterDeviceLostCallback; -#endif - /// /// Throws an if the current device has been lost. /// @@ -124,11 +117,7 @@ unsafe partial class GraphicsDevice _ = Windows.RegisterWaitForSingleObject( phNewWaitObject: &waitHandle, hObject: eventHandle, -#if NET6_0_OR_GREATER Callback: &WaitForSingleObjectCallbackForRegisterDeviceLostCallback, -#else - Callback: (void*)Marshal.GetFunctionPointerForDelegate(WaitForSingleObjectCallbackForRegisterDeviceLostCallbackWrapper), -#endif Context: (void*)GCHandle.ToIntPtr(handle), dwMilliseconds: Windows.INFINITE, dwFlags: 0); diff --git a/src/ComputeSharp/Graphics/GraphicsDevice.Execute.cs b/src/ComputeSharp/Graphics/GraphicsDevice.Execute.cs index a402805f..a92dfeea 100644 --- a/src/ComputeSharp/Graphics/GraphicsDevice.Execute.cs +++ b/src/ComputeSharp/Graphics/GraphicsDevice.Execute.cs @@ -17,21 +17,6 @@ namespace ComputeSharp; /// unsafe partial class GraphicsDevice { -#if !NET6_0_OR_GREATER - /// - /// A delegate for a callback to pass to . - /// - /// The input context. - /// Whether the wait has timed out. - [UnmanagedFunctionPointer(CallingConvention.StdCall)] - private delegate void WaitForSingleObjectCallbackDelegate(void* pContext, byte timedOut); - - /// - /// A cached instance wrapping . - /// - private static readonly WaitForSingleObjectCallbackDelegate WaitForSingleObjectCallbackForWaitForFenceAsyncWrapper = WaitForSingleObjectCallbackForWaitForFenceAsync; -#endif - /// /// Executes a given command list and waits for the operation to be completed. /// @@ -67,11 +52,7 @@ unsafe partial class GraphicsDevice d3D12CommandQueue->ExecuteCommandLists(1, d3D12CommandList); } -#if NET6_0_OR_GREATER ulong updatedFenceValue = Interlocked.Increment(ref d3D12FenceValue); -#else - ulong updatedFenceValue = (ulong)Interlocked.Increment(ref Unsafe.As(ref d3D12FenceValue)); -#endif // Signal to the target fence with the updated value. Note that incrementing the // target fence value to signal must be done after executing the command list. @@ -101,11 +82,7 @@ unsafe partial class GraphicsDevice this.d3D12ComputeCommandQueue.Get()->ExecuteCommandLists(1, d3D12CommandList); } -#if NET6_0_OR_GREATER ulong updatedFenceValue = Interlocked.Increment(ref this.nextD3D12ComputeFenceValue); -#else - ulong updatedFenceValue = (ulong)Interlocked.Increment(ref Unsafe.As(ref this.nextD3D12ComputeFenceValue)); -#endif // Signal to the target fence with the updated value. Note that incrementing the // target fence value to signal must be done after executing the command list. @@ -117,11 +94,7 @@ unsafe partial class GraphicsDevice // Return the rented command list and command allocator so that they can be reused this.computeCommandListPool.Return(commandList.DetachD3D12CommandList(), commandList.DetachD3D12CommandAllocator()); -#if NET6_0_OR_GREATER return ValueTask.CompletedTask; -#else - return new(Task.CompletedTask); -#endif } // Setup the awaitable task @@ -198,11 +171,7 @@ unsafe partial class GraphicsDevice int result = Windows.RegisterWaitForSingleObject( phNewWaitObject: &waitHandle, hObject: eventHandle, -#if NET6_0_OR_GREATER Callback: &WaitForSingleObjectCallbackForWaitForFenceAsync, -#else - Callback: (void*)Marshal.GetFunctionPointerForDelegate(WaitForSingleObjectCallbackForWaitForFenceAsyncWrapper), -#endif Context: callbackContext, dwMilliseconds: Windows.INFINITE, dwFlags: 0); diff --git a/src/ComputeSharp/Graphics/Helpers/DeviceHelper.IDXGIFactory6.cs b/src/ComputeSharp/Graphics/Helpers/DeviceHelper.IDXGIFactory6.cs index 23cf33cf..9fa7cb8e 100644 --- a/src/ComputeSharp/Graphics/Helpers/DeviceHelper.IDXGIFactory6.cs +++ b/src/ComputeSharp/Graphics/Helpers/DeviceHelper.IDXGIFactory6.cs @@ -101,44 +101,6 @@ partial class DeviceHelper /// private unsafe struct IDXGIFactory4As6Backcompat { -#if !NET6_0_OR_GREATER - /// - [UnmanagedFunctionPointer(CallingConvention.StdCall)] - private delegate uint ReleaseDelegate(IDXGIFactory4As6Backcompat* @this); - - /// - [UnmanagedFunctionPointer(CallingConvention.StdCall)] - private delegate int EnumAdaptersDelegate(IDXGIFactory4As6Backcompat* @this, uint Adapter, IDXGIAdapter** ppAdapter); - - /// - [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); - - /// - /// A cached instance wrapping . - /// - private static readonly ReleaseDelegate ReleaseWrapper = Release; - - /// - /// A cached instance wrapping . - /// - private static readonly EnumAdaptersDelegate EnumAdaptersWrapper = EnumAdapters; - - /// - /// A cached instance wrapping . - /// - private static readonly EnumWarpAdapterDelegate EnumWarpAdapterWrapper = EnumWarpAdapter; - - /// - /// A cached instance wrapping . - /// - private static readonly EnumAdapterByGpuPreferenceDelegate EnumAdapterByGpuPreferenceWrapper = EnumAdapterByGpuPreference; -#endif - /// /// The shared method table pointer for all instances. /// @@ -154,17 +116,10 @@ partial class DeviceHelper new Span(lpVtbl, 30).Clear(); -#if NET6_0_OR_GREATER lpVtbl[2] = (delegate* unmanaged)&Release; lpVtbl[7] = (delegate* unmanaged)&EnumAdapters; lpVtbl[27] = (delegate* unmanaged)&EnumWarpAdapter; lpVtbl[29] = (delegate* unmanaged)&EnumAdapterByGpuPreference; -#else - lpVtbl[2] = (void*)Marshal.GetFunctionPointerForDelegate(ReleaseWrapper); - lpVtbl[7] = (void*)Marshal.GetFunctionPointerForDelegate(EnumAdaptersWrapper); - lpVtbl[27] = (void*)Marshal.GetFunctionPointerForDelegate(EnumWarpAdapterWrapper); - lpVtbl[29] = (void*)Marshal.GetFunctionPointerForDelegate(EnumAdapterByGpuPreferenceWrapper); -#endif return lpVtbl; } diff --git a/src/ComputeSharp/Graphics/Interop/Allocation/ID3D12Allocation.cs b/src/ComputeSharp/Graphics/Interop/Allocation/ID3D12Allocation.cs index 22031a8f..ee15a951 100644 --- a/src/ComputeSharp/Graphics/Interop/Allocation/ID3D12Allocation.cs +++ b/src/ComputeSharp/Graphics/Interop/Allocation/ID3D12Allocation.cs @@ -11,10 +11,7 @@ namespace ComputeSharp.Interop.Allocation; /// An allocation wrapper for a native object. /// [Guid("D42D5782-2DE7-4539-A817-482E3AA01E2E")] -internal unsafe struct ID3D12Allocation -#if NET6_0_OR_GREATER -//: IUnknown.Interface -#endif +internal unsafe struct ID3D12Allocation //: IUnknown.Interface { /// /// Gets the for (D42D5782-2DE7-4539-A817-482E3AA01E2E). @@ -40,10 +37,8 @@ internal unsafe struct ID3D12Allocation } } -#if NET6_0_OR_GREATER ///// //static Guid* INativeGuid.NativeGuid => (Guid*)Unsafe.AsPointer(ref Unsafe.AsRef(in Guid)); -#endif /// /// The vtable for the current instance. diff --git a/src/ComputeSharp/Graphics/Interop/Allocation/ID3D12MemoryAllocator.cs b/src/ComputeSharp/Graphics/Interop/Allocation/ID3D12MemoryAllocator.cs index 61ed95ac..840732aa 100644 --- a/src/ComputeSharp/Graphics/Interop/Allocation/ID3D12MemoryAllocator.cs +++ b/src/ComputeSharp/Graphics/Interop/Allocation/ID3D12MemoryAllocator.cs @@ -11,10 +11,7 @@ namespace ComputeSharp.Interop.Allocation; /// An object that can allocate resources for a given instance. /// [Guid("2D5E55D2-9244-431F-868E-0D90AAB6E575")] -internal unsafe struct ID3D12MemoryAllocator -#if NET6_0_OR_GREATER -//: IUnknown.Interface -#endif +internal unsafe struct ID3D12MemoryAllocator //: IUnknown.Interface { /// /// Gets the for (2D5E55D2-9244-431F-868E-0D90AAB6E575). @@ -40,10 +37,8 @@ internal unsafe struct ID3D12MemoryAllocator } } -#if NET6_0_OR_GREATER ///// //static Guid* INativeGuid.NativeGuid => (Guid*)Unsafe.AsPointer(ref Unsafe.AsRef(in Guid)); -#endif /// /// The vtable for the current instance. diff --git a/src/ComputeSharp/Graphics/Interop/Allocation/ID3D12MemoryAllocatorFactory.cs b/src/ComputeSharp/Graphics/Interop/Allocation/ID3D12MemoryAllocatorFactory.cs index f87b6424..bb41a71e 100644 --- a/src/ComputeSharp/Graphics/Interop/Allocation/ID3D12MemoryAllocatorFactory.cs +++ b/src/ComputeSharp/Graphics/Interop/Allocation/ID3D12MemoryAllocatorFactory.cs @@ -11,10 +11,7 @@ namespace ComputeSharp.Interop.Allocation; /// A factory type for objects. /// [Guid("CC1E74A7-786D-40F4-8AE2-F8B7A255587E")] -internal unsafe struct ID3D12MemoryAllocatorFactory -#if NET6_0_OR_GREATER -//: IUnknown.Interface -#endif +internal unsafe struct ID3D12MemoryAllocatorFactory //: IUnknown.Interface { /// /// Gets the for (CC1E74A7-786D-40F4-8AE2-F8B7A255587E). @@ -40,10 +37,8 @@ internal unsafe struct ID3D12MemoryAllocatorFactory } } -#if NET6_0_OR_GREATER ///// //static Guid* INativeGuid.NativeGuid => (Guid*)Unsafe.AsPointer(ref Unsafe.AsRef(in Guid)); -#endif /// /// The vtable for the current instance. diff --git a/src/ComputeSharp/Graphics/Luid.cs b/src/ComputeSharp/Graphics/Luid.cs index 54290da3..4c0d369c 100644 --- a/src/ComputeSharp/Graphics/Luid.cs +++ b/src/ComputeSharp/Graphics/Luid.cs @@ -9,10 +9,7 @@ namespace ComputeSharp; /// /// A locally unique identifier for a graphics device. /// -public readonly struct Luid : IEquatable -#if NET6_0_OR_GREATER - , ISpanFormattable -#endif +public readonly struct Luid : IEquatable, ISpanFormattable { /// /// The low bits of the luid. @@ -63,7 +60,6 @@ public readonly struct Luid : IEquatable return ((((long)this.highPart) << 32) | this.lowPart).ToString(); } -#if NET6_0_OR_GREATER /// public string ToString(string? format, IFormatProvider? formatProvider) { @@ -75,7 +71,6 @@ public readonly struct Luid : IEquatable { return ((((long)this.highPart) << 32) | this.lowPart).TryFormat(destination, out charsWritten, format, provider); } -#endif /// /// Check whether two values are equal. diff --git a/src/ComputeSharp/Shaders/ComputeContext.cs b/src/ComputeSharp/Shaders/ComputeContext.cs index eb431f10..468a8995 100644 --- a/src/ComputeSharp/Shaders/ComputeContext.cs +++ b/src/ComputeSharp/Shaders/ComputeContext.cs @@ -284,11 +284,7 @@ public struct ComputeContext : IDisposable, IAsyncDisposable { device.GetReferenceTracker().DangerousRelease(); -#if NET6_0_OR_GREATER return ValueTask.CompletedTask; -#else - return new(Task.CompletedTask); -#endif } try From 40f5c7467a816e3b21548d980ab77e29414de9fe Mon Sep 17 00:00:00 2001 From: Sergio Pedri Date: Wed, 18 Oct 2023 13:24:55 +0200 Subject: [PATCH 5/5] Remove remaining downlevel conditional paths --- .../Effects/ZonePlateEffect.cs | 7 ------ tests/ComputeSharp.NuGet/Program.cs | 4 --- tests/ComputeSharp.Pix.NuGet/Program.cs | 4 --- .../Polyfills/RandomExtensions.cs | 25 ------------------- 4 files changed, 40 deletions(-) delete mode 100644 tests/ComputeSharp.Tests/Polyfills/RandomExtensions.cs diff --git a/tests/ComputeSharp.D2D1.Tests/Effects/ZonePlateEffect.cs b/tests/ComputeSharp.D2D1.Tests/Effects/ZonePlateEffect.cs index 4526d8a3..951a9073 100644 --- a/tests/ComputeSharp.D2D1.Tests/Effects/ZonePlateEffect.cs +++ b/tests/ComputeSharp.D2D1.Tests/Effects/ZonePlateEffect.cs @@ -2,13 +2,6 @@ using System; namespace ComputeSharp.D2D1.Tests.Effects; -#if !NET6_0_OR_GREATER -internal static class MathF -{ - public const float PI = (float)Math.PI; -} -#endif - [D2DInputCount(0)] [D2DRequiresScenePosition] [D2DShaderProfile(D2D1ShaderProfile.PixelShader50)] diff --git a/tests/ComputeSharp.NuGet/Program.cs b/tests/ComputeSharp.NuGet/Program.cs index c4424f36..3a8989b4 100644 --- a/tests/ComputeSharp.NuGet/Program.cs +++ b/tests/ComputeSharp.NuGet/Program.cs @@ -1,13 +1,9 @@ using System.Diagnostics; using System.Linq; -#if NET6_0_OR_GREATER using System.Runtime.Versioning; -#endif using ComputeSharp; -#if NET6_0_OR_GREATER [assembly: SupportedOSPlatform("windows6.2")] -#endif float[] array = Enumerable.Range(1, 100).Select(static i => (float)i).ToArray(); diff --git a/tests/ComputeSharp.Pix.NuGet/Program.cs b/tests/ComputeSharp.Pix.NuGet/Program.cs index 306c6d71..9bd8ef5f 100644 --- a/tests/ComputeSharp.Pix.NuGet/Program.cs +++ b/tests/ComputeSharp.Pix.NuGet/Program.cs @@ -1,13 +1,9 @@ using System.Diagnostics; using System.Linq; -#if NET6_0_OR_GREATER using System.Runtime.Versioning; -#endif using ComputeSharp; -#if NET6_0_OR_GREATER [assembly: SupportedOSPlatform("windows6.2")] -#endif float[] array = Enumerable.Range(1, 100).Select(static i => (float)i).ToArray(); diff --git a/tests/ComputeSharp.Tests/Polyfills/RandomExtensions.cs b/tests/ComputeSharp.Tests/Polyfills/RandomExtensions.cs deleted file mode 100644 index fa809217..00000000 --- a/tests/ComputeSharp.Tests/Polyfills/RandomExtensions.cs +++ /dev/null @@ -1,25 +0,0 @@ -#if !NET6_0_OR_GREATER - -namespace System; - -/// -/// A type with some helper methods for the class. -/// -internal static class RandomExtensions -{ - /// - /// Fills the elements of a specified span of bytes with random numbers. - /// - /// The target random instance. - /// The array to be filled with random numbers. - public static void NextBytes(this Random random, Span buffer) - { - byte[] array = new byte[buffer.Length]; - - random.NextBytes(array); - - array.AsSpan().CopyTo(buffer); - } -} - -#endif \ No newline at end of file