From 224b41109e729d932b4d1ab06b6e52a272740a7a Mon Sep 17 00:00:00 2001 From: Sergio Pedri Date: Thu, 23 Nov 2023 17:31:48 +0100 Subject: [PATCH] Adopt IComObject.IID in ComputeSharp.WinUI --- .../DirectX/shared/dxgi/IDXGISwapChain.cs | 29 ++++++++++++++++++- .../DirectX/shared/dxgi1_2/DXGIOutput1.cs | 29 ++++++++++++++++++- .../DirectX/shared/dxgi1_4/IDXGISwapChain3.cs | 29 ++++++++++++++++++- 3 files changed, 84 insertions(+), 3 deletions(-) diff --git a/src/ComputeSharp.Win32.D3D12/DirectX/shared/dxgi/IDXGISwapChain.cs b/src/ComputeSharp.Win32.D3D12/DirectX/shared/dxgi/IDXGISwapChain.cs index 953f1e38..c24fd39e 100644 --- a/src/ComputeSharp.Win32.D3D12/DirectX/shared/dxgi/IDXGISwapChain.cs +++ b/src/ComputeSharp.Win32.D3D12/DirectX/shared/dxgi/IDXGISwapChain.cs @@ -7,13 +7,40 @@ using System; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; +#pragma warning disable IDE0055 + namespace ComputeSharp.Win32; [Guid("310D36A0-D2E7-4C0A-AA04-6A9D23B8886A")] [NativeTypeName("struct IDXGISwapChain : IDXGIDeviceSubObject")] [NativeInheritance("IDXGIDeviceSubObject")] -internal unsafe partial struct IDXGISwapChain +internal unsafe partial struct IDXGISwapChain : IComObject { + /// + static Guid* IComObject.IID + { + [MethodImpl(MethodImplOptions.AggressiveInlining)] + get + { + ReadOnlySpan data = + [ + 0xA0, 0x36, 0x0D, 0x31, + 0xE7, 0xD2, + 0x0A, 0x4C, + 0xAA, + 0x04, + 0x6A, + 0x9D, + 0x23, + 0xB8, + 0x88, + 0x6A + ]; + + return (Guid*)Unsafe.AsPointer(ref MemoryMarshal.GetReference(data)); + } + } + public void** lpVtbl; [MethodImpl(MethodImplOptions.AggressiveInlining)] diff --git a/src/ComputeSharp.Win32.D3D12/DirectX/shared/dxgi1_2/DXGIOutput1.cs b/src/ComputeSharp.Win32.D3D12/DirectX/shared/dxgi1_2/DXGIOutput1.cs index 0dd44e7c..fecbd2ee 100644 --- a/src/ComputeSharp.Win32.D3D12/DirectX/shared/dxgi1_2/DXGIOutput1.cs +++ b/src/ComputeSharp.Win32.D3D12/DirectX/shared/dxgi1_2/DXGIOutput1.cs @@ -7,13 +7,40 @@ using System; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; +#pragma warning disable IDE0055 + namespace ComputeSharp.Win32; [Guid("00CDDEA8-939B-4B83-A340-A685226666CC")] [NativeTypeName("struct IDXGIOutput1 : IDXGIOutput")] [NativeInheritance("IDXGIOutput")] -internal unsafe partial struct IDXGIOutput1 +internal unsafe partial struct IDXGIOutput1 : IComObject { + /// + static Guid* IComObject.IID + { + [MethodImpl(MethodImplOptions.AggressiveInlining)] + get + { + ReadOnlySpan data = + [ + 0xA8, 0xDE, 0xCD, 0x00, + 0x9B, 0x93, + 0x83, 0x4B, + 0xA3, + 0x40, + 0xA6, + 0x85, + 0x22, + 0x66, + 0x66, + 0xCC + ]; + + return (Guid*)Unsafe.AsPointer(ref MemoryMarshal.GetReference(data)); + } + } + public void** lpVtbl; [MethodImpl(MethodImplOptions.AggressiveInlining)] diff --git a/src/ComputeSharp.Win32.D3D12/DirectX/shared/dxgi1_4/IDXGISwapChain3.cs b/src/ComputeSharp.Win32.D3D12/DirectX/shared/dxgi1_4/IDXGISwapChain3.cs index 4084deb8..36f5717f 100644 --- a/src/ComputeSharp.Win32.D3D12/DirectX/shared/dxgi1_4/IDXGISwapChain3.cs +++ b/src/ComputeSharp.Win32.D3D12/DirectX/shared/dxgi1_4/IDXGISwapChain3.cs @@ -8,14 +8,41 @@ using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Runtime.Versioning; +#pragma warning disable IDE0055 + namespace ComputeSharp.Win32; [SupportedOSPlatform("windows10.0")] [Guid("94D99BDB-F1F8-4AB0-B236-7DA0170EDAB1")] [NativeTypeName("struct IDXGISwapChain3 : IDXGISwapChain2")] [NativeInheritance("IDXGISwapChain2")] -internal unsafe partial struct IDXGISwapChain3 +internal unsafe partial struct IDXGISwapChain3 : IComObject { + /// + static Guid* IComObject.IID + { + [MethodImpl(MethodImplOptions.AggressiveInlining)] + get + { + ReadOnlySpan data = + [ + 0xDB, 0x9B, 0xD9, 0x94, + 0xF8, 0xF1, + 0xB0, 0x4A, + 0xB2, + 0x36, + 0x7D, + 0xA0, + 0x17, + 0x0E, + 0xDA, + 0xB1 + ]; + + return (Guid*)Unsafe.AsPointer(ref MemoryMarshal.GetReference(data)); + } + } + public void** lpVtbl; [MethodImpl(MethodImplOptions.AggressiveInlining)]