Code refactoring, always use DXGIFactory6 as entry point

このコミットが含まれているのは:
Sergio Pedri committed 2022-06-19 02:57:58 +02:00
1 親 878f6da329
コミット 639bcb75e1
3ファイル変更
+28 -17

検索条件に一致するファイルはありません

+3 -3
ファイルの表示
@@ -483,13 +483,13 @@ internal sealed unsafe partial class SwapChainManager<TOwner> : NativeObject
/// <inheritdoc/>
private unsafe partial void OnGetDynamicResolutionManager(out DynamicResolutionManager resolutionManager)
{
using ComPtr<IDXGIFactory4> dxgiFactory4 = default;
using ComPtr<IDXGIFactory6> dxgiFactory6 = default;
DeviceHelper.CreateDXGIFactory4(dxgiFactory4.GetAddressOf());
DeviceHelper.CreateDXGIFactory6(dxgiFactory6.GetAddressOf());
using ComPtr<IDXGIAdapter> dxgiAdapter = default;
dxgiFactory4.Get()->EnumAdapters(0, dxgiAdapter.GetAddressOf()).Assert();
dxgiFactory6.Get()->EnumAdapters(0, dxgiAdapter.GetAddressOf()).Assert();
int targetFramerate = dxgiAdapter.Get()->GetCompositionRefreshRate(DXGI_FORMAT.DXGI_FORMAT_R8G8B8A8_UNORM);
+18 -14
ファイルの表示
@@ -27,20 +27,6 @@ internal static partial class DeviceHelper
Configuration.IsDebugOutputEnabled ? (uint)DXGI.DXGI_CREATE_FACTORY_DEBUG : 0;
#endif
/// <summary>
/// Creates a new <see cref="IDXGIFactory4"/> instance to be used to enumerate devices.
/// </summary>
/// <param name="dxgiFactory4">The resulting <see cref="IDXGIFactory4"/> instance.</param>
internal static unsafe void CreateDXGIFactory4(IDXGIFactory4** dxgiFactory4)
{
if (Configuration.IsDebugOutputEnabled)
{
EnableDebugMode();
}
DirectX.CreateDXGIFactory2(IDXGIFactoryCreationFlags, Windows.__uuidof<IDXGIFactory4>(), (void**)dxgiFactory4).Assert();
}
/// <summary>
/// Creates a new <see cref="IDXGIFactory6"/> instance to be used to enumerate devices.
/// </summary>
@@ -104,6 +90,10 @@ internal static partial class DeviceHelper
[UnmanagedFunctionPointer(CallingConvention.StdCall)]
private delegate uint ReleaseDelegate(IDXGIFactory4As6Backcompat* @this);
/// <inheritdoc cref="EnumAdapters"/>
[UnmanagedFunctionPointer(CallingConvention.StdCall)]
private delegate int EnumAdaptersDelegate(IDXGIFactory4As6Backcompat* @this, uint Adapter, IDXGIAdapter** ppAdapter);
/// <inheritdoc cref="EnumWarpAdapter"/>
[UnmanagedFunctionPointer(CallingConvention.StdCall)]
private delegate int EnumWarpAdapterDelegate(IDXGIFactory4As6Backcompat* @this, Guid* riid, void** ppvAdapter);
@@ -117,6 +107,11 @@ internal static partial class DeviceHelper
/// </summary>
private static readonly ReleaseDelegate ReleaseWrapper = Release;
/// <summary>
/// A cached <see cref="EnumAdaptersDelegate"/> instance wrapping <see cref="EnumAdapters"/>.
/// </summary>
private static readonly EnumAdaptersDelegate EnumAdaptersWrapper = EnumAdapters;
/// <summary>
/// A cached <see cref="EnumWarpAdapterDelegate"/> instance wrapping <see cref="EnumWarpAdapter"/>.
/// </summary>
@@ -145,10 +140,12 @@ internal static partial class DeviceHelper
#if NET6_0_OR_GREATER
lpVtbl[2] = (delegate* unmanaged<IDXGIFactory4As6Backcompat*, uint>)&Release;
lpVtbl[7] = (delegate* unmanaged<IDXGIFactory4As6Backcompat*, uint, IDXGIAdapter**, int>)&EnumAdapters;
lpVtbl[27] = (delegate* unmanaged<IDXGIFactory4As6Backcompat*, Guid*, void**, int>)&EnumWarpAdapter;
lpVtbl[29] = (delegate* unmanaged<IDXGIFactory4As6Backcompat*, uint, DXGI_GPU_PREFERENCE, Guid*, void**, int>)&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
@@ -194,6 +191,13 @@ internal static partial class DeviceHelper
return 0;
}
/// <inheritdoc cref="IDXGIFactory6.EnumAdapters(uint, IDXGIAdapter**)"/>
[UnmanagedCallersOnly]
public static int EnumAdapters(IDXGIFactory4As6Backcompat* @this, uint Adapter, IDXGIAdapter** ppAdapter)
{
return @this->dxgiFactory4->EnumAdapters(Adapter, ppAdapter);
}
/// <inheritdoc cref="IDXGIFactory6.EnumWarpAdapter(Guid*, void**)"/>
[UnmanagedCallersOnly]
public static int EnumWarpAdapter(IDXGIFactory4As6Backcompat* @this, Guid* riid, void** ppvAdapter)
+7
ファイルの表示
@@ -42,6 +42,13 @@ namespace TerraFX.Interop.DirectX
return ((delegate* unmanaged[Stdcall]<IDXGIFactory6*, uint>)(lpVtbl[2]))((IDXGIFactory6*)Unsafe.AsPointer(ref this));
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
[VtblIndex(7)]
public HRESULT EnumAdapters(uint Adapter, IDXGIAdapter** ppAdapter)
{
return ((delegate* unmanaged[Stdcall]<IDXGIFactory6*, uint, IDXGIAdapter**, int>)(lpVtbl[7]))((IDXGIFactory6*)Unsafe.AsPointer(ref this), Adapter, ppAdapter);
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
[VtblIndex(24)]
public HRESULT CreateSwapChainForComposition(IUnknown* pDevice, [NativeTypeName("const DXGI_SWAP_CHAIN_DESC1 *")] DXGI_SWAP_CHAIN_DESC1* pDesc, IDXGIOutput* pRestrictToOutput, IDXGISwapChain1** ppSwapChain)