From 2c47e7d1da257490b3d3559cb445f7f3be1b45e1 Mon Sep 17 00:00:00 2001 From: Lightczx <1686188646@qq.com> Date: Fri, 31 May 2024 14:43:38 +0800 Subject: [PATCH] IDXGIFactory6 --- .../Win32/{D3d11_Temp.cs => D3d11.cs} | 0 src/Snap.Hutao/Snap.Hutao/Win32/Dxgi.cs | 18 +++++++- .../Graphics/Dxgi/Common/DXGI_ALPHA_MODE.cs | 12 ++++++ .../Win32/Graphics/Dxgi/DXGI_ADAPTER_DESC.cs | 2 +- .../Win32/Graphics/Dxgi/DXGI_ADAPTER_DESC1.cs | 20 +++++++++ .../Win32/Graphics/Dxgi/DXGI_FEATURE.cs | 9 ++++ .../Graphics/Dxgi/DXGI_GPU_PREFERENCE.cs | 11 +++++ .../Graphics/Dxgi/DXGI_PRESENT_PARAMETERS.cs | 15 +++++++ .../Win32/Graphics/Dxgi/DXGI_RGBA.cs | 13 ++++++ .../Win32/Graphics/Dxgi/DXGI_SCALING.cs | 11 +++++ .../Graphics/Dxgi/DXGI_SWAP_CHAIN_DESC.cs | 19 +++++++++ .../Graphics/Dxgi/DXGI_SWAP_CHAIN_DESC1.cs | 22 ++++++++++ .../Graphics/Dxgi/DXGI_SWAP_CHAIN_FLAG.cs | 21 ++++++++++ .../Dxgi/DXGI_SWAP_CHAIN_FULLSCREEN_DESC.cs | 15 +++++++ .../Win32/Graphics/Dxgi/DXGI_SWAP_EFFECT.cs | 12 ++++++ .../Win32/Graphics/Dxgi/IDXGIAdapter1.cs | 28 +++++++++++++ .../Win32/Graphics/Dxgi/IDXGIFactory.cs | 33 +++++++++++++++ .../Win32/Graphics/Dxgi/IDXGIFactory1.cs | 31 ++++++++++++++ .../Win32/Graphics/Dxgi/IDXGIFactory2.cs | 41 +++++++++++++++++++ .../Win32/Graphics/Dxgi/IDXGIFactory3.cs | 29 +++++++++++++ .../Win32/Graphics/Dxgi/IDXGIFactory4.cs | 29 +++++++++++++ .../Win32/Graphics/Dxgi/IDXGIFactory5.cs | 28 +++++++++++++ .../Win32/Graphics/Dxgi/IDXGIFactory6.cs | 28 +++++++++++++ .../Win32/Graphics/Dxgi/IDXGISwapChain.cs | 38 +++++++++++++++++ .../Win32/Graphics/Dxgi/IDXGISwapChain1.cs | 39 ++++++++++++++++++ 25 files changed, 521 insertions(+), 3 deletions(-) rename src/Snap.Hutao/Snap.Hutao/Win32/{D3d11_Temp.cs => D3d11.cs} (100%) create mode 100644 src/Snap.Hutao/Snap.Hutao/Win32/Graphics/Dxgi/Common/DXGI_ALPHA_MODE.cs create mode 100644 src/Snap.Hutao/Snap.Hutao/Win32/Graphics/Dxgi/DXGI_ADAPTER_DESC1.cs create mode 100644 src/Snap.Hutao/Snap.Hutao/Win32/Graphics/Dxgi/DXGI_FEATURE.cs create mode 100644 src/Snap.Hutao/Snap.Hutao/Win32/Graphics/Dxgi/DXGI_GPU_PREFERENCE.cs create mode 100644 src/Snap.Hutao/Snap.Hutao/Win32/Graphics/Dxgi/DXGI_PRESENT_PARAMETERS.cs create mode 100644 src/Snap.Hutao/Snap.Hutao/Win32/Graphics/Dxgi/DXGI_RGBA.cs create mode 100644 src/Snap.Hutao/Snap.Hutao/Win32/Graphics/Dxgi/DXGI_SCALING.cs create mode 100644 src/Snap.Hutao/Snap.Hutao/Win32/Graphics/Dxgi/DXGI_SWAP_CHAIN_DESC.cs create mode 100644 src/Snap.Hutao/Snap.Hutao/Win32/Graphics/Dxgi/DXGI_SWAP_CHAIN_DESC1.cs create mode 100644 src/Snap.Hutao/Snap.Hutao/Win32/Graphics/Dxgi/DXGI_SWAP_CHAIN_FLAG.cs create mode 100644 src/Snap.Hutao/Snap.Hutao/Win32/Graphics/Dxgi/DXGI_SWAP_CHAIN_FULLSCREEN_DESC.cs create mode 100644 src/Snap.Hutao/Snap.Hutao/Win32/Graphics/Dxgi/DXGI_SWAP_EFFECT.cs create mode 100644 src/Snap.Hutao/Snap.Hutao/Win32/Graphics/Dxgi/IDXGIAdapter1.cs create mode 100644 src/Snap.Hutao/Snap.Hutao/Win32/Graphics/Dxgi/IDXGIFactory.cs create mode 100644 src/Snap.Hutao/Snap.Hutao/Win32/Graphics/Dxgi/IDXGIFactory1.cs create mode 100644 src/Snap.Hutao/Snap.Hutao/Win32/Graphics/Dxgi/IDXGIFactory2.cs create mode 100644 src/Snap.Hutao/Snap.Hutao/Win32/Graphics/Dxgi/IDXGIFactory3.cs create mode 100644 src/Snap.Hutao/Snap.Hutao/Win32/Graphics/Dxgi/IDXGIFactory4.cs create mode 100644 src/Snap.Hutao/Snap.Hutao/Win32/Graphics/Dxgi/IDXGIFactory5.cs create mode 100644 src/Snap.Hutao/Snap.Hutao/Win32/Graphics/Dxgi/IDXGIFactory6.cs create mode 100644 src/Snap.Hutao/Snap.Hutao/Win32/Graphics/Dxgi/IDXGISwapChain.cs create mode 100644 src/Snap.Hutao/Snap.Hutao/Win32/Graphics/Dxgi/IDXGISwapChain1.cs diff --git a/src/Snap.Hutao/Snap.Hutao/Win32/D3d11_Temp.cs b/src/Snap.Hutao/Snap.Hutao/Win32/D3d11.cs similarity index 100% rename from src/Snap.Hutao/Snap.Hutao/Win32/D3d11_Temp.cs rename to src/Snap.Hutao/Snap.Hutao/Win32/D3d11.cs diff --git a/src/Snap.Hutao/Snap.Hutao/Win32/Dxgi.cs b/src/Snap.Hutao/Snap.Hutao/Win32/Dxgi.cs index 2ddfc7c5..28ef5aab 100644 --- a/src/Snap.Hutao/Snap.Hutao/Win32/Dxgi.cs +++ b/src/Snap.Hutao/Snap.Hutao/Win32/Dxgi.cs @@ -7,9 +7,23 @@ using System.Runtime.Versioning; namespace Snap.Hutao.Win32; +[SuppressMessage("", "SA1313")] +[SuppressMessage("", "SYSLIB1054")] internal static class Dxgi { - [DllImport("dxgi.dll", ExactSpelling = true, PreserveSig = false)] + [DllImport("dxgi.dll", CallingConvention = CallingConvention.Winapi, ExactSpelling = true)] [SupportedOSPlatform("windows8.1")] - public unsafe static extern HRESULT CreateDXGIFactory2([In] uint Flags, [In][Const] Guid* riid, [Out][ComOutPtr] void** ppFactory); + public static unsafe extern HRESULT CreateDXGIFactory2(uint Flags, Guid* riid, void** ppFactory); + + public static unsafe HRESULT CreateDXGIFactory2(uint Flags, ref readonly Guid iid, out T* pFactory) + where T : unmanaged + { + fixed (Guid* riid = &iid) + { + fixed (T** ppFactory = &pFactory) + { + return CreateDXGIFactory2(Flags, riid, (void**)ppFactory); + } + } + } } \ No newline at end of file diff --git a/src/Snap.Hutao/Snap.Hutao/Win32/Graphics/Dxgi/Common/DXGI_ALPHA_MODE.cs b/src/Snap.Hutao/Snap.Hutao/Win32/Graphics/Dxgi/Common/DXGI_ALPHA_MODE.cs new file mode 100644 index 00000000..7be1ab31 --- /dev/null +++ b/src/Snap.Hutao/Snap.Hutao/Win32/Graphics/Dxgi/Common/DXGI_ALPHA_MODE.cs @@ -0,0 +1,12 @@ +// Copyright (c) DGP Studio. All rights reserved. +// Licensed under the MIT license. + +namespace Snap.Hutao.Win32.Graphics.Dxgi.Common; + +internal enum DXGI_ALPHA_MODE +{ + DXGI_ALPHA_MODE_UNSPECIFIED = 0, + DXGI_ALPHA_MODE_PREMULTIPLIED = 1, + DXGI_ALPHA_MODE_STRAIGHT = 2, + DXGI_ALPHA_MODE_IGNORE = 3, +} \ No newline at end of file diff --git a/src/Snap.Hutao/Snap.Hutao/Win32/Graphics/Dxgi/DXGI_ADAPTER_DESC.cs b/src/Snap.Hutao/Snap.Hutao/Win32/Graphics/Dxgi/DXGI_ADAPTER_DESC.cs index 7cb3a87e..98f51612 100644 --- a/src/Snap.Hutao/Snap.Hutao/Win32/Graphics/Dxgi/DXGI_ADAPTER_DESC.cs +++ b/src/Snap.Hutao/Snap.Hutao/Win32/Graphics/Dxgi/DXGI_ADAPTER_DESC.cs @@ -16,4 +16,4 @@ internal struct DXGI_ADAPTER_DESC public nuint DedicatedSystemMemory; public nuint SharedSystemMemory; public LUID AdapterLuid; -} +} \ No newline at end of file diff --git a/src/Snap.Hutao/Snap.Hutao/Win32/Graphics/Dxgi/DXGI_ADAPTER_DESC1.cs b/src/Snap.Hutao/Snap.Hutao/Win32/Graphics/Dxgi/DXGI_ADAPTER_DESC1.cs new file mode 100644 index 00000000..36190b58 --- /dev/null +++ b/src/Snap.Hutao/Snap.Hutao/Win32/Graphics/Dxgi/DXGI_ADAPTER_DESC1.cs @@ -0,0 +1,20 @@ +// Copyright (c) DGP Studio. All rights reserved. +// Licensed under the MIT license. + +using Snap.Hutao.Win32.Foundation; + +namespace Snap.Hutao.Win32.Graphics.Dxgi; + +internal struct DXGI_ADAPTER_DESC1 +{ + public unsafe fixed char Description[128]; + public uint VendorId; + public uint DeviceId; + public uint SubSysId; + public uint Revision; + public UIntPtr DedicatedVideoMemory; + public UIntPtr DedicatedSystemMemory; + public UIntPtr SharedSystemMemory; + public LUID AdapterLuid; + public uint Flags; +} \ No newline at end of file diff --git a/src/Snap.Hutao/Snap.Hutao/Win32/Graphics/Dxgi/DXGI_FEATURE.cs b/src/Snap.Hutao/Snap.Hutao/Win32/Graphics/Dxgi/DXGI_FEATURE.cs new file mode 100644 index 00000000..367107a2 --- /dev/null +++ b/src/Snap.Hutao/Snap.Hutao/Win32/Graphics/Dxgi/DXGI_FEATURE.cs @@ -0,0 +1,9 @@ +// Copyright (c) DGP Studio. All rights reserved. +// Licensed under the MIT license. + +namespace Snap.Hutao.Win32.Graphics.Dxgi; + +internal enum DXGI_FEATURE +{ + DXGI_FEATURE_PRESENT_ALLOW_TEARING = 0, +} \ No newline at end of file diff --git a/src/Snap.Hutao/Snap.Hutao/Win32/Graphics/Dxgi/DXGI_GPU_PREFERENCE.cs b/src/Snap.Hutao/Snap.Hutao/Win32/Graphics/Dxgi/DXGI_GPU_PREFERENCE.cs new file mode 100644 index 00000000..d7837350 --- /dev/null +++ b/src/Snap.Hutao/Snap.Hutao/Win32/Graphics/Dxgi/DXGI_GPU_PREFERENCE.cs @@ -0,0 +1,11 @@ +// Copyright (c) DGP Studio. All rights reserved. +// Licensed under the MIT license. + +namespace Snap.Hutao.Win32.Graphics.Dxgi; + +internal enum DXGI_GPU_PREFERENCE +{ + DXGI_GPU_PREFERENCE_UNSPECIFIED = 0, + DXGI_GPU_PREFERENCE_MINIMUM_POWER = 1, + DXGI_GPU_PREFERENCE_HIGH_PERFORMANCE = 2, +} \ No newline at end of file diff --git a/src/Snap.Hutao/Snap.Hutao/Win32/Graphics/Dxgi/DXGI_PRESENT_PARAMETERS.cs b/src/Snap.Hutao/Snap.Hutao/Win32/Graphics/Dxgi/DXGI_PRESENT_PARAMETERS.cs new file mode 100644 index 00000000..d52e17aa --- /dev/null +++ b/src/Snap.Hutao/Snap.Hutao/Win32/Graphics/Dxgi/DXGI_PRESENT_PARAMETERS.cs @@ -0,0 +1,15 @@ +// Copyright (c) DGP Studio. All rights reserved. +// Licensed under the MIT license. + +using Snap.Hutao.Win32.Foundation; + +namespace Snap.Hutao.Win32.Graphics.Dxgi; + +[SuppressMessage("", "SA1307")] +internal struct DXGI_PRESENT_PARAMETERS +{ + public uint DirtyRectsCount; + public unsafe RECT* pDirtyRects; + public unsafe RECT* pScrollRect; + public unsafe POINT* pScrollOffset; +} \ No newline at end of file diff --git a/src/Snap.Hutao/Snap.Hutao/Win32/Graphics/Dxgi/DXGI_RGBA.cs b/src/Snap.Hutao/Snap.Hutao/Win32/Graphics/Dxgi/DXGI_RGBA.cs new file mode 100644 index 00000000..192d943b --- /dev/null +++ b/src/Snap.Hutao/Snap.Hutao/Win32/Graphics/Dxgi/DXGI_RGBA.cs @@ -0,0 +1,13 @@ +// Copyright (c) DGP Studio. All rights reserved. +// Licensed under the MIT license. + +namespace Snap.Hutao.Win32.Graphics.Dxgi; + +[SuppressMessage("", "SA1307")] +internal struct DXGI_RGBA +{ + public float r; + public float g; + public float b; + public float a; +} \ No newline at end of file diff --git a/src/Snap.Hutao/Snap.Hutao/Win32/Graphics/Dxgi/DXGI_SCALING.cs b/src/Snap.Hutao/Snap.Hutao/Win32/Graphics/Dxgi/DXGI_SCALING.cs new file mode 100644 index 00000000..ece81623 --- /dev/null +++ b/src/Snap.Hutao/Snap.Hutao/Win32/Graphics/Dxgi/DXGI_SCALING.cs @@ -0,0 +1,11 @@ +// Copyright (c) DGP Studio. All rights reserved. +// Licensed under the MIT license. + +namespace Snap.Hutao.Win32.Graphics.Dxgi; + +internal enum DXGI_SCALING +{ + DXGI_SCALING_STRETCH = 0, + DXGI_SCALING_NONE = 1, + DXGI_SCALING_ASPECT_RATIO_STRETCH = 2, +} \ No newline at end of file diff --git a/src/Snap.Hutao/Snap.Hutao/Win32/Graphics/Dxgi/DXGI_SWAP_CHAIN_DESC.cs b/src/Snap.Hutao/Snap.Hutao/Win32/Graphics/Dxgi/DXGI_SWAP_CHAIN_DESC.cs new file mode 100644 index 00000000..0d380ecd --- /dev/null +++ b/src/Snap.Hutao/Snap.Hutao/Win32/Graphics/Dxgi/DXGI_SWAP_CHAIN_DESC.cs @@ -0,0 +1,19 @@ +// Copyright (c) DGP Studio. All rights reserved. +// Licensed under the MIT license. + +using Snap.Hutao.Win32.Foundation; +using Snap.Hutao.Win32.Graphics.Dxgi.Common; + +namespace Snap.Hutao.Win32.Graphics.Dxgi; + +internal struct DXGI_SWAP_CHAIN_DESC +{ + public DXGI_MODE_DESC BufferDesc; + public DXGI_SAMPLE_DESC SampleDesc; + public DXGI_USAGE BufferUsage; + public uint BufferCount; + public HWND OutputWindow; + public BOOL Windowed; + public DXGI_SWAP_EFFECT SwapEffect; + public uint Flags; +} \ No newline at end of file diff --git a/src/Snap.Hutao/Snap.Hutao/Win32/Graphics/Dxgi/DXGI_SWAP_CHAIN_DESC1.cs b/src/Snap.Hutao/Snap.Hutao/Win32/Graphics/Dxgi/DXGI_SWAP_CHAIN_DESC1.cs new file mode 100644 index 00000000..2f4b7f77 --- /dev/null +++ b/src/Snap.Hutao/Snap.Hutao/Win32/Graphics/Dxgi/DXGI_SWAP_CHAIN_DESC1.cs @@ -0,0 +1,22 @@ +// Copyright (c) DGP Studio. All rights reserved. +// Licensed under the MIT license. + +using Snap.Hutao.Win32.Foundation; +using Snap.Hutao.Win32.Graphics.Dxgi.Common; + +namespace Snap.Hutao.Win32.Graphics.Dxgi; + +internal struct DXGI_SWAP_CHAIN_DESC1 +{ + public uint Width; + public uint Height; + public DXGI_FORMAT Format; + public BOOL Stereo; + public DXGI_SAMPLE_DESC SampleDesc; + public DXGI_USAGE BufferUsage; + public uint BufferCount; + public DXGI_SCALING Scaling; + public DXGI_SWAP_EFFECT SwapEffect; + public DXGI_ALPHA_MODE AlphaMode; + public DXGI_SWAP_CHAIN_FLAG Flags; +} \ No newline at end of file diff --git a/src/Snap.Hutao/Snap.Hutao/Win32/Graphics/Dxgi/DXGI_SWAP_CHAIN_FLAG.cs b/src/Snap.Hutao/Snap.Hutao/Win32/Graphics/Dxgi/DXGI_SWAP_CHAIN_FLAG.cs new file mode 100644 index 00000000..cb9e4a99 --- /dev/null +++ b/src/Snap.Hutao/Snap.Hutao/Win32/Graphics/Dxgi/DXGI_SWAP_CHAIN_FLAG.cs @@ -0,0 +1,21 @@ +// Copyright (c) DGP Studio. All rights reserved. +// Licensed under the MIT license. + +namespace Snap.Hutao.Win32.Graphics.Dxgi; + +internal enum DXGI_SWAP_CHAIN_FLAG : uint +{ + DXGI_SWAP_CHAIN_FLAG_NONPREROTATED = 0x1, + DXGI_SWAP_CHAIN_FLAG_ALLOW_MODE_SWITCH = 0x2, + DXGI_SWAP_CHAIN_FLAG_GDI_COMPATIBLE = 0x4, + DXGI_SWAP_CHAIN_FLAG_RESTRICTED_CONTENT = 0x8, + DXGI_SWAP_CHAIN_FLAG_RESTRICT_SHARED_RESOURCE_DRIVER = 0x10, + DXGI_SWAP_CHAIN_FLAG_DISPLAY_ONLY = 0x20, + DXGI_SWAP_CHAIN_FLAG_FRAME_LATENCY_WAITABLE_OBJECT = 0x40, + DXGI_SWAP_CHAIN_FLAG_FOREGROUND_LAYER = 0x80, + DXGI_SWAP_CHAIN_FLAG_FULLSCREEN_VIDEO = 0x100, + DXGI_SWAP_CHAIN_FLAG_YUV_VIDEO = 0x200, + DXGI_SWAP_CHAIN_FLAG_HW_PROTECTED = 0x400, + DXGI_SWAP_CHAIN_FLAG_ALLOW_TEARING = 0x800, + DXGI_SWAP_CHAIN_FLAG_RESTRICTED_TO_ALL_HOLOGRAPHIC_DISPLAYS = 0x1000, +} \ No newline at end of file diff --git a/src/Snap.Hutao/Snap.Hutao/Win32/Graphics/Dxgi/DXGI_SWAP_CHAIN_FULLSCREEN_DESC.cs b/src/Snap.Hutao/Snap.Hutao/Win32/Graphics/Dxgi/DXGI_SWAP_CHAIN_FULLSCREEN_DESC.cs new file mode 100644 index 00000000..c31c0891 --- /dev/null +++ b/src/Snap.Hutao/Snap.Hutao/Win32/Graphics/Dxgi/DXGI_SWAP_CHAIN_FULLSCREEN_DESC.cs @@ -0,0 +1,15 @@ +// Copyright (c) DGP Studio. All rights reserved. +// Licensed under the MIT license. + +using Snap.Hutao.Win32.Foundation; +using Snap.Hutao.Win32.Graphics.Dxgi.Common; + +namespace Snap.Hutao.Win32.Graphics.Dxgi; + +internal struct DXGI_SWAP_CHAIN_FULLSCREEN_DESC +{ + public DXGI_RATIONAL RefreshRate; + public DXGI_MODE_SCANLINE_ORDER ScanlineOrdering; + public DXGI_MODE_SCALING Scaling; + public BOOL Windowed; +} \ No newline at end of file diff --git a/src/Snap.Hutao/Snap.Hutao/Win32/Graphics/Dxgi/DXGI_SWAP_EFFECT.cs b/src/Snap.Hutao/Snap.Hutao/Win32/Graphics/Dxgi/DXGI_SWAP_EFFECT.cs new file mode 100644 index 00000000..a4ff9619 --- /dev/null +++ b/src/Snap.Hutao/Snap.Hutao/Win32/Graphics/Dxgi/DXGI_SWAP_EFFECT.cs @@ -0,0 +1,12 @@ +// Copyright (c) DGP Studio. All rights reserved. +// Licensed under the MIT license. + +namespace Snap.Hutao.Win32.Graphics.Dxgi; + +internal enum DXGI_SWAP_EFFECT +{ + DXGI_SWAP_EFFECT_DISCARD = 0, + DXGI_SWAP_EFFECT_SEQUENTIAL = 1, + DXGI_SWAP_EFFECT_FLIP_SEQUENTIAL = 3, + DXGI_SWAP_EFFECT_FLIP_DISCARD = 4, +} \ No newline at end of file diff --git a/src/Snap.Hutao/Snap.Hutao/Win32/Graphics/Dxgi/IDXGIAdapter1.cs b/src/Snap.Hutao/Snap.Hutao/Win32/Graphics/Dxgi/IDXGIAdapter1.cs new file mode 100644 index 00000000..07b26127 --- /dev/null +++ b/src/Snap.Hutao/Snap.Hutao/Win32/Graphics/Dxgi/IDXGIAdapter1.cs @@ -0,0 +1,28 @@ +// Copyright (c) DGP Studio. All rights reserved. +// Licensed under the MIT license. + +using Snap.Hutao.Win32.Foundation; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +namespace Snap.Hutao.Win32.Graphics.Dxgi; + +internal unsafe readonly struct IDXGIAdapter1 +{ + public readonly Vftbl* ThisPtr; + + internal static ref readonly Guid IID + { + get + { + ReadOnlySpan data = [0x61, 0x8F, 0x03, 0x29, 0x39, 0x38, 0x26, 0x46, 0x91, 0xFD, 0x08, 0x68, 0x79, 0x01, 0x1A, 0x05]; + return ref Unsafe.As(ref MemoryMarshal.GetReference(data)); + } + } + + internal readonly struct Vftbl + { + internal readonly IDXGIAdapter.Vftbl IDXGIAdapterVftbl; + internal readonly delegate* unmanaged[Stdcall] GetDesc1; + } +} \ No newline at end of file diff --git a/src/Snap.Hutao/Snap.Hutao/Win32/Graphics/Dxgi/IDXGIFactory.cs b/src/Snap.Hutao/Snap.Hutao/Win32/Graphics/Dxgi/IDXGIFactory.cs new file mode 100644 index 00000000..76f26370 --- /dev/null +++ b/src/Snap.Hutao/Snap.Hutao/Win32/Graphics/Dxgi/IDXGIFactory.cs @@ -0,0 +1,33 @@ +// Copyright (c) DGP Studio. All rights reserved. +// Licensed under the MIT license. + +using Snap.Hutao.Win32.Foundation; +using Snap.Hutao.Win32.System.Com; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +namespace Snap.Hutao.Win32.Graphics.Dxgi; + +internal unsafe readonly struct IDXGIFactory +{ + public readonly Vftbl* ThisPtr; + + internal static ref readonly Guid IID + { + get + { + ReadOnlySpan data = [0xEC, 0x66, 0x71, 0x7B, 0xC7, 0x21, 0xAE, 0x44, 0xB2, 0x1A, 0xC9, 0xAE, 0x32, 0x1A, 0xE3, 0x69]; + return ref Unsafe.As(ref MemoryMarshal.GetReference(data)); + } + } + + internal readonly struct Vftbl + { + internal readonly IDXGIObject.Vftbl IDXGIObjectVftbl; + internal readonly delegate* unmanaged[Stdcall] EnumAdapters; + internal readonly delegate* unmanaged[Stdcall] MakeWindowAssociation; + internal readonly delegate* unmanaged[Stdcall] GetWindowAssociation; + internal readonly delegate* unmanaged[Stdcall] CreateSwapChain; + internal readonly delegate* unmanaged[Stdcall] CreateSoftwareAdapter; + } +} \ No newline at end of file diff --git a/src/Snap.Hutao/Snap.Hutao/Win32/Graphics/Dxgi/IDXGIFactory1.cs b/src/Snap.Hutao/Snap.Hutao/Win32/Graphics/Dxgi/IDXGIFactory1.cs new file mode 100644 index 00000000..20eb3a60 --- /dev/null +++ b/src/Snap.Hutao/Snap.Hutao/Win32/Graphics/Dxgi/IDXGIFactory1.cs @@ -0,0 +1,31 @@ +// Copyright (c) DGP Studio. All rights reserved. +// Licensed under the MIT license. + +using Snap.Hutao.Win32.Foundation; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; +using System.Runtime.Versioning; + +namespace Snap.Hutao.Win32.Graphics.Dxgi; + +[SupportedOSPlatform("windows6.1")] +internal unsafe readonly struct IDXGIFactory1 +{ + public readonly Vftbl* ThisPtr; + + internal static ref readonly Guid IID + { + get + { + ReadOnlySpan data = [0x78, 0xAE, 0x0A, 0x77, 0x6F, 0xF2, 0xBA, 0x4D, 0xA8, 0x29, 0x25, 0x3C, 0x83, 0xD1, 0xB3, 0x87]; + return ref Unsafe.As(ref MemoryMarshal.GetReference(data)); + } + } + + internal readonly struct Vftbl + { + internal readonly IDXGIFactory.Vftbl IDXGIFactoryVftbl; + internal readonly delegate* unmanaged[Stdcall] EnumAdapters1; + internal readonly delegate* unmanaged[Stdcall] IsCurrent; + } +} \ No newline at end of file diff --git a/src/Snap.Hutao/Snap.Hutao/Win32/Graphics/Dxgi/IDXGIFactory2.cs b/src/Snap.Hutao/Snap.Hutao/Win32/Graphics/Dxgi/IDXGIFactory2.cs new file mode 100644 index 00000000..bfda0fd2 --- /dev/null +++ b/src/Snap.Hutao/Snap.Hutao/Win32/Graphics/Dxgi/IDXGIFactory2.cs @@ -0,0 +1,41 @@ +// Copyright (c) DGP Studio. All rights reserved. +// Licensed under the MIT license. + +using Snap.Hutao.Win32.Foundation; +using Snap.Hutao.Win32.System.Com; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; +using System.Runtime.Versioning; + +namespace Snap.Hutao.Win32.Graphics.Dxgi; + +[SupportedOSPlatform("windows8.0")] +internal unsafe readonly struct IDXGIFactory2 +{ + public readonly Vftbl* ThisPtr; + + internal static ref readonly Guid IID + { + get + { + ReadOnlySpan data = [0x1C, 0x3A, 0xC8, 0x50, 0x72, 0xE0, 0x48, 0x4C, 0x87, 0xB0, 0x36, 0x30, 0xFA, 0x36, 0xA6, 0xD0]; + return ref Unsafe.As(ref MemoryMarshal.GetReference(data)); + } + } + + internal readonly struct Vftbl + { + internal readonly IDXGIFactory1.Vftbl IDXGIFactory1Vftbl; + internal readonly delegate* unmanaged[Stdcall] IsWindowedStereoEnabled; + internal readonly delegate* unmanaged[Stdcall] CreateSwapChainForHwnd; + internal readonly delegate* unmanaged[Stdcall] CreateSwapChainForCoreWindow; + internal readonly delegate* unmanaged[Stdcall] GetSharedResourceAdapterLuid; + internal readonly delegate* unmanaged[Stdcall] RegisterStereoStatusWindow; + internal readonly delegate* unmanaged[Stdcall] RegisterStereoStatusEvent; + internal readonly delegate* unmanaged[Stdcall] UnregisterStereoStatus; + internal readonly delegate* unmanaged[Stdcall] RegisterOcclusionStatusWindow; + internal readonly delegate* unmanaged[Stdcall] RegisterOcclusionStatusEvent; + internal readonly delegate* unmanaged[Stdcall] UnregisterOcclusionStatus; + internal readonly delegate* unmanaged[Stdcall] CreateSwapChainForComposition; + } +} \ No newline at end of file diff --git a/src/Snap.Hutao/Snap.Hutao/Win32/Graphics/Dxgi/IDXGIFactory3.cs b/src/Snap.Hutao/Snap.Hutao/Win32/Graphics/Dxgi/IDXGIFactory3.cs new file mode 100644 index 00000000..ab45029f --- /dev/null +++ b/src/Snap.Hutao/Snap.Hutao/Win32/Graphics/Dxgi/IDXGIFactory3.cs @@ -0,0 +1,29 @@ +// Copyright (c) DGP Studio. All rights reserved. +// Licensed under the MIT license. + +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; +using System.Runtime.Versioning; + +namespace Snap.Hutao.Win32.Graphics.Dxgi; + +[SupportedOSPlatform("windows8.1")] +internal unsafe readonly struct IDXGIFactory3 +{ + public readonly Vftbl* ThisPtr; + + internal static ref readonly Guid IID + { + get + { + ReadOnlySpan data = [0x23, 0x38, 0x48, 0x25, 0x46, 0xCD, 0x7D, 0x4C, 0x86, 0xCA, 0x47, 0xAA, 0x95, 0xB8, 0x37, 0xBD]; + return ref Unsafe.As(ref MemoryMarshal.GetReference(data)); + } + } + + internal readonly struct Vftbl + { + internal readonly IDXGIFactory2.Vftbl IDXGIFactory2Vftbl; + internal readonly delegate* unmanaged[Stdcall] GetCreationFlags; + } +} \ No newline at end of file diff --git a/src/Snap.Hutao/Snap.Hutao/Win32/Graphics/Dxgi/IDXGIFactory4.cs b/src/Snap.Hutao/Snap.Hutao/Win32/Graphics/Dxgi/IDXGIFactory4.cs new file mode 100644 index 00000000..b11cafa3 --- /dev/null +++ b/src/Snap.Hutao/Snap.Hutao/Win32/Graphics/Dxgi/IDXGIFactory4.cs @@ -0,0 +1,29 @@ +// Copyright (c) DGP Studio. All rights reserved. +// Licensed under the MIT license. + +using Snap.Hutao.Win32.Foundation; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +namespace Snap.Hutao.Win32.Graphics.Dxgi; + +internal unsafe readonly struct IDXGIFactory4 +{ + public readonly Vftbl* ThisPtr; + + internal static ref readonly Guid IID + { + get + { + ReadOnlySpan data = [0x02, 0xEA, 0xC6, 0x1B, 0x36, 0xEF, 0x4F, 0x46, 0xBF, 0x0C, 0x21, 0xCA, 0x39, 0xE5, 0x16, 0x8A]; + return ref Unsafe.As(ref MemoryMarshal.GetReference(data)); + } + } + + internal readonly struct Vftbl + { + internal readonly IDXGIFactory3.Vftbl IDXGIFactory3Vftbl; + internal readonly delegate* unmanaged[Stdcall] EnumAdapterByLuid; + internal readonly delegate* unmanaged[Stdcall] EnumWarpAdapter; + } +} diff --git a/src/Snap.Hutao/Snap.Hutao/Win32/Graphics/Dxgi/IDXGIFactory5.cs b/src/Snap.Hutao/Snap.Hutao/Win32/Graphics/Dxgi/IDXGIFactory5.cs new file mode 100644 index 00000000..072a4cba --- /dev/null +++ b/src/Snap.Hutao/Snap.Hutao/Win32/Graphics/Dxgi/IDXGIFactory5.cs @@ -0,0 +1,28 @@ +// Copyright (c) DGP Studio. All rights reserved. +// Licensed under the MIT license. + +using Snap.Hutao.Win32.Foundation; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +namespace Snap.Hutao.Win32.Graphics.Dxgi; + +internal unsafe readonly struct IDXGIFactory5 +{ + public readonly Vftbl* ThisPtr; + + internal static ref readonly Guid IID + { + get + { + ReadOnlySpan data = [0xF5, 0xE1, 0x32, 0x76, 0x65, 0xEE, 0xCA, 0x4D, 0x87, 0xFD, 0x84, 0xCD, 0x75, 0xF8, 0x83, 0x8D]; + return ref Unsafe.As(ref MemoryMarshal.GetReference(data)); + } + } + + internal readonly struct Vftbl + { + internal readonly IDXGIFactory4.Vftbl IDXGIFactory4Vftbl; + internal readonly delegate* unmanaged[Stdcall] CheckFeatureSupport; + } +} \ No newline at end of file diff --git a/src/Snap.Hutao/Snap.Hutao/Win32/Graphics/Dxgi/IDXGIFactory6.cs b/src/Snap.Hutao/Snap.Hutao/Win32/Graphics/Dxgi/IDXGIFactory6.cs new file mode 100644 index 00000000..e304f50a --- /dev/null +++ b/src/Snap.Hutao/Snap.Hutao/Win32/Graphics/Dxgi/IDXGIFactory6.cs @@ -0,0 +1,28 @@ +// Copyright (c) DGP Studio. All rights reserved. +// Licensed under the MIT license. + +using Snap.Hutao.Win32.Foundation; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +namespace Snap.Hutao.Win32.Graphics.Dxgi; + +internal unsafe readonly struct IDXGIFactory6 +{ + public readonly Vftbl* ThisPtr; + + internal static ref readonly Guid IID + { + get + { + ReadOnlySpan data = [0x4F, 0x69, 0xB6, 0xC1, 0x09, 0xFF, 0xA9, 0x44, 0xB0, 0x3C, 0x77, 0x90, 0x0A, 0x0A, 0x1D, 0x17]; + return ref Unsafe.As(ref MemoryMarshal.GetReference(data)); + } + } + + internal readonly struct Vftbl + { + internal readonly IDXGIFactory5.Vftbl IDXGIFactory5Vftbl; + internal readonly delegate* unmanaged[Stdcall] EnumAdapterByGpuPreference; + } +} \ No newline at end of file diff --git a/src/Snap.Hutao/Snap.Hutao/Win32/Graphics/Dxgi/IDXGISwapChain.cs b/src/Snap.Hutao/Snap.Hutao/Win32/Graphics/Dxgi/IDXGISwapChain.cs new file mode 100644 index 00000000..be912cf8 --- /dev/null +++ b/src/Snap.Hutao/Snap.Hutao/Win32/Graphics/Dxgi/IDXGISwapChain.cs @@ -0,0 +1,38 @@ +// Copyright (c) DGP Studio. All rights reserved. +// Licensed under the MIT license. + +using Snap.Hutao.Win32.Foundation; +using Snap.Hutao.Win32.Graphics.Dxgi.Common; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +namespace Snap.Hutao.Win32.Graphics.Dxgi; + +internal unsafe readonly struct IDXGISwapChain +{ + public readonly Vftbl* ThisPtr; + + internal static ref readonly Guid IID + { + get + { + ReadOnlySpan data = [0xA0, 0x36, 0x0D, 0x31, 0xE7, 0xD2, 0x0A, 0x4C, 0xAA, 0x04, 0x6A, 0x9D, 0x23, 0xB8, 0x88, 0x6A]; + return ref Unsafe.As(ref MemoryMarshal.GetReference(data)); + } + } + + internal readonly struct Vftbl + { + internal readonly IDXGIDeviceSubObject.Vftbl IDXGIDeviceSubObjectVftbl; + internal readonly delegate* unmanaged[Stdcall] Present; + internal readonly delegate* unmanaged[Stdcall] GetBuffer; + internal readonly delegate* unmanaged[Stdcall] SetFullscreenState; + internal readonly delegate* unmanaged[Stdcall] GetFullscreenState; + internal readonly delegate* unmanaged[Stdcall] GetDesc; + internal readonly delegate* unmanaged[Stdcall] ResizeBuffers; + internal readonly delegate* unmanaged[Stdcall] ResizeTarget; + internal readonly delegate* unmanaged[Stdcall] GetContainingOutput; + internal readonly delegate* unmanaged[Stdcall] GetFrameStatistics; + internal readonly delegate* unmanaged[Stdcall] GetLastPresentCount; + } +} \ No newline at end of file diff --git a/src/Snap.Hutao/Snap.Hutao/Win32/Graphics/Dxgi/IDXGISwapChain1.cs b/src/Snap.Hutao/Snap.Hutao/Win32/Graphics/Dxgi/IDXGISwapChain1.cs new file mode 100644 index 00000000..ee876916 --- /dev/null +++ b/src/Snap.Hutao/Snap.Hutao/Win32/Graphics/Dxgi/IDXGISwapChain1.cs @@ -0,0 +1,39 @@ +// Copyright (c) DGP Studio. All rights reserved. +// Licensed under the MIT license. + +using Snap.Hutao.Win32.Foundation; +using Snap.Hutao.Win32.Graphics.Dxgi.Common; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +namespace Snap.Hutao.Win32.Graphics.Dxgi; + +internal unsafe readonly struct IDXGISwapChain1 +{ + public readonly Vftbl* ThisPtr; + + internal static ref readonly Guid IID + { + get + { + ReadOnlySpan data = [0xF7, 0x45, 0x0A, 0x79, 0x42, 0x0D, 0x76, 0x48, 0x98, 0x3A, 0x0A, 0x55, 0xCF, 0xE6, 0xF4, 0xAA]; + return ref Unsafe.As(ref MemoryMarshal.GetReference(data)); + } + } + + internal readonly struct Vftbl + { + internal readonly IDXGISwapChain.Vftbl IDXGISwapChainVftbl; + internal readonly delegate* unmanaged[Stdcall] GetDesc1; + internal readonly delegate* unmanaged[Stdcall] GetFullscreenDesc; + internal readonly delegate* unmanaged[Stdcall] GetHwnd; + internal readonly delegate* unmanaged[Stdcall] GetCoreWindow; + internal readonly delegate* unmanaged[Stdcall] Present1; + internal readonly delegate* unmanaged[Stdcall] IsTemporaryMonoSupported; + internal readonly delegate* unmanaged[Stdcall] GetRestrictToOutput; + internal readonly delegate* unmanaged[Stdcall] SetBackgroundColor; + internal readonly delegate* unmanaged[Stdcall] GetBackgroundColor; + internal readonly delegate* unmanaged[Stdcall] SetRotation; + internal readonly delegate* unmanaged[Stdcall] GetRotation; + } +} \ No newline at end of file