mirror of
https://github.com/space-wizards/RobustToolbox.git
synced 2026-02-14 19:29:36 +01:00
Update to latest TerraFX, compile custom swapchain ANGLE in.
This commit is contained in:
@@ -16,7 +16,6 @@ namespace Robust.Client.Graphics.Clyde
|
||||
// Advanced GL contexts currently disabled due to lack of testing etc.
|
||||
if (OperatingSystem.IsWindows() && _cfg.GetCVar(CVars.DisplayAngle))
|
||||
{
|
||||
/*
|
||||
if (_cfg.GetCVar(CVars.DisplayAngleCustomSwapChain))
|
||||
{
|
||||
_sawmillOgl.Debug("Trying custom swap chain ANGLE.");
|
||||
@@ -31,7 +30,6 @@ namespace Robust.Client.Graphics.Clyde
|
||||
return;
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
/*
|
||||
if (_cfg.GetCVar(CVars.DisplayEgl))
|
||||
|
||||
@@ -1,6 +1,4 @@
|
||||
// Commented out because I can't be bothered to figure out trimming for TerraFX.
|
||||
/*
|
||||
using System;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Text;
|
||||
@@ -10,13 +8,18 @@ using Robust.Shared.Log;
|
||||
using Robust.Shared.Map;
|
||||
using Robust.Shared.Maths;
|
||||
using Robust.Shared.Utility;
|
||||
using TerraFX.Interop;
|
||||
using TerraFX.Interop.DirectX;
|
||||
using TerraFX.Interop.Windows;
|
||||
using static Robust.Client.Graphics.Clyde.Egl;
|
||||
using static TerraFX.Interop.D3D_DRIVER_TYPE;
|
||||
using static TerraFX.Interop.D3D_FEATURE_LEVEL;
|
||||
using static TerraFX.Interop.DXGI_FORMAT;
|
||||
using static TerraFX.Interop.DXGI_SWAP_EFFECT;
|
||||
using static TerraFX.Interop.Windows;
|
||||
using static TerraFX.Interop.DirectX.D3D_DRIVER_TYPE;
|
||||
using static TerraFX.Interop.DirectX.D3D_FEATURE_LEVEL;
|
||||
using static TerraFX.Interop.DirectX.DXGI_FORMAT;
|
||||
using static TerraFX.Interop.DirectX.DXGI_SWAP_EFFECT;
|
||||
using static TerraFX.Interop.Windows.Windows;
|
||||
using static TerraFX.Interop.DirectX.DirectX;
|
||||
using static TerraFX.Interop.DirectX.D3D11;
|
||||
using static TerraFX.Interop.DirectX.DXGI;
|
||||
using GL = OpenToolkit.Graphics.OpenGL4.GL;
|
||||
|
||||
|
||||
namespace Robust.Client.Graphics.Clyde
|
||||
@@ -77,7 +80,7 @@ namespace Robust.Client.Graphics.Clyde
|
||||
};
|
||||
_windowData[reg.Id] = data;
|
||||
|
||||
var hWnd = Clyde._windowing!.WindowGetWin32Window(reg)!.Value;
|
||||
var hWnd = (HWND) Clyde._windowing!.WindowGetWin32Window(reg)!.Value;
|
||||
|
||||
// todo: exception management.
|
||||
CreateSwapChain1(hWnd, data);
|
||||
@@ -116,8 +119,7 @@ namespace Robust.Client.Graphics.Clyde
|
||||
|
||||
fixed (ID3D11Texture2D** texPtr = &data.Backbuffer)
|
||||
{
|
||||
var iid = IID_ID3D11Texture2D;
|
||||
ThrowIfFailed("GetBuffer", data.SwapChain->GetBuffer(0, &iid, (void**) texPtr));
|
||||
ThrowIfFailed("GetBuffer", data.SwapChain->GetBuffer(0, __uuidof<ID3D11Texture2D>(), (void**) texPtr));
|
||||
}
|
||||
|
||||
var attributes = stackalloc int[]
|
||||
@@ -135,7 +137,7 @@ namespace Robust.Client.Graphics.Clyde
|
||||
attributes);
|
||||
}
|
||||
|
||||
private void CreateSwapChain1(nint hWnd, WindowData data)
|
||||
private void CreateSwapChain1(HWND hWnd, WindowData data)
|
||||
{
|
||||
var desc = new DXGI_SWAP_CHAIN_DESC
|
||||
{
|
||||
@@ -295,11 +297,9 @@ namespace Robust.Client.Graphics.Clyde
|
||||
|
||||
try
|
||||
{
|
||||
var iid = IID_IDXGIFactory1;
|
||||
|
||||
fixed (IDXGIFactory1** ptr = &_factory)
|
||||
{
|
||||
ThrowIfFailed(nameof(CreateDXGIFactory1), CreateDXGIFactory1(&iid, (void**) ptr));
|
||||
ThrowIfFailed(nameof(CreateDXGIFactory1), CreateDXGIFactory1(__uuidof<IDXGIFactory1>(), (void**) ptr));
|
||||
}
|
||||
|
||||
// Try to find the correct adapter if specified.
|
||||
@@ -336,7 +336,7 @@ namespace Robust.Client.Graphics.Clyde
|
||||
ThrowIfFailed("D3D11CreateDevice", D3D11CreateDevice(
|
||||
(IDXGIAdapter*) _adapter,
|
||||
_adapter == null ? D3D_DRIVER_TYPE_HARDWARE : D3D_DRIVER_TYPE_UNKNOWN,
|
||||
IntPtr.Zero,
|
||||
HMODULE.NULL,
|
||||
0,
|
||||
fl,
|
||||
(uint) featureLevels.Length,
|
||||
@@ -349,13 +349,11 @@ namespace Robust.Client.Graphics.Clyde
|
||||
|
||||
// Get adapter from the device.
|
||||
|
||||
iid = IID_IDXGIDevice1;
|
||||
ThrowIfFailed("QueryInterface", _device->QueryInterface(&iid, (void**) &dxgiDevice));
|
||||
ThrowIfFailed("QueryInterface", _device->QueryInterface(__uuidof<IDXGIDevice1>(), (void**) &dxgiDevice));
|
||||
|
||||
fixed (IDXGIAdapter1** ptrAdapter = &_adapter)
|
||||
{
|
||||
iid = IID_IDXGIAdapter1;
|
||||
ThrowIfFailed("GetParent", dxgiDevice->GetParent(&iid, (void**) ptrAdapter));
|
||||
ThrowIfFailed("GetParent", dxgiDevice->GetParent(__uuidof<IDXGIAdapter1>(), (void**) ptrAdapter));
|
||||
}
|
||||
|
||||
_deviceFl = _device->GetFeatureLevel();
|
||||
@@ -528,4 +526,3 @@ namespace Robust.Client.Graphics.Clyde
|
||||
}
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
@@ -22,7 +22,7 @@
|
||||
<PackageReference Include="OpenToolkit.OpenAL" Version="4.0.0-pre9.1" />
|
||||
<PackageReference Include="SpaceWizards.SharpFont" Version="1.0.1" />
|
||||
<PackageReference Include="Robust.Natives" Version="0.1.0" />
|
||||
<PackageReference Include="TerraFX.Interop.Windows" Version="10.0.20348-beta1" />
|
||||
<PackageReference Include="TerraFX.Interop.Windows" Version="10.0.20348-rc2" />
|
||||
</ItemGroup>
|
||||
<ItemGroup Condition="'$(EnableClientScripting)' == 'True'">
|
||||
<PackageReference Include="Microsoft.CodeAnalysis.CSharp.Features" Version="3.8.0" />
|
||||
|
||||
@@ -374,7 +374,7 @@ namespace Robust.Shared
|
||||
/// Should improve performance and fixes main window sRGB handling with ANGLE.
|
||||
/// </summary>
|
||||
public static readonly CVarDef<bool> DisplayAngleCustomSwapChain =
|
||||
CVarDef.Create("display.angle_custom_swap_chain", true, CVar.CLIENTONLY);
|
||||
CVarDef.Create("display.angle_custom_swap_chain", false, CVar.CLIENTONLY);
|
||||
|
||||
/// <summary>
|
||||
/// Force usage of DXGI 1.1 when using custom swap chain setup.
|
||||
|
||||
Reference in New Issue
Block a user