mirror of
https://github.com/hedge-dev/UnleashedRecomp.git
synced 2025-04-28 21:37:58 +03:00
Try creating the D3D12 device again if redirection to Vulkan fails. (#1504)
Some checks failed
validate-internal / build (push) Failing after 7s
Some checks failed
validate-internal / build (push) Failing after 7s
This commit is contained in:
parent
8370312454
commit
21be4e17fb
1 changed files with 43 additions and 25 deletions
|
@ -1679,10 +1679,16 @@ bool Video::CreateHostDevice(const char *sdlVideoDriver, bool graphicsApiRetry)
|
||||||
std::vector<RenderInterfaceFunction *> interfaceFunctions;
|
std::vector<RenderInterfaceFunction *> interfaceFunctions;
|
||||||
|
|
||||||
#ifdef UNLEASHED_RECOMP_D3D12
|
#ifdef UNLEASHED_RECOMP_D3D12
|
||||||
|
bool allowVulkanRedirection = true;
|
||||||
|
|
||||||
if (graphicsApiRetry)
|
if (graphicsApiRetry)
|
||||||
{
|
{
|
||||||
// If we are attempting to create again after a reboot due to a crash, swap the order.
|
// If we are attempting to create again after a reboot due to a crash, swap the order.
|
||||||
g_vulkan = !g_vulkan;
|
g_vulkan = !g_vulkan;
|
||||||
|
|
||||||
|
// Don't allow redirection to Vulkan if we are retrying after a crash,
|
||||||
|
// so the user can at least boot the game with D3D12 if Vulkan fails to work.
|
||||||
|
allowVulkanRedirection = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
interfaceFunctions.push_back(g_vulkan ? CreateVulkanInterfaceWrapper : CreateD3D12Interface);
|
interfaceFunctions.push_back(g_vulkan ? CreateVulkanInterfaceWrapper : CreateD3D12Interface);
|
||||||
|
@ -1691,8 +1697,10 @@ bool Video::CreateHostDevice(const char *sdlVideoDriver, bool graphicsApiRetry)
|
||||||
interfaceFunctions.push_back(CreateVulkanInterfaceWrapper);
|
interfaceFunctions.push_back(CreateVulkanInterfaceWrapper);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
for (RenderInterfaceFunction *interfaceFunction : interfaceFunctions)
|
for (size_t i = 0; i < interfaceFunctions.size(); i++)
|
||||||
{
|
{
|
||||||
|
RenderInterfaceFunction* interfaceFunction = interfaceFunctions[i];
|
||||||
|
|
||||||
#ifdef UNLEASHED_RECOMP_D3D12
|
#ifdef UNLEASHED_RECOMP_D3D12
|
||||||
// Wrap the device creation in __try/__except to survive from driver crashes.
|
// Wrap the device creation in __try/__except to survive from driver crashes.
|
||||||
__try
|
__try
|
||||||
|
@ -1711,6 +1719,8 @@ bool Video::CreateHostDevice(const char *sdlVideoDriver, bool graphicsApiRetry)
|
||||||
|
|
||||||
#ifdef UNLEASHED_RECOMP_D3D12
|
#ifdef UNLEASHED_RECOMP_D3D12
|
||||||
if (interfaceFunction == CreateD3D12Interface)
|
if (interfaceFunction == CreateD3D12Interface)
|
||||||
|
{
|
||||||
|
if (allowVulkanRedirection)
|
||||||
{
|
{
|
||||||
bool redirectToVulkan = false;
|
bool redirectToVulkan = false;
|
||||||
|
|
||||||
|
@ -1731,14 +1741,22 @@ bool Video::CreateHostDevice(const char *sdlVideoDriver, bool graphicsApiRetry)
|
||||||
redirectToVulkan = true;
|
redirectToVulkan = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Allow redirection to Vulkan only if we are not retrying after a crash,
|
if (redirectToVulkan)
|
||||||
// so the user can at least boot the game with D3D12 if Vulkan fails to work.
|
|
||||||
if (!graphicsApiRetry && redirectToVulkan)
|
|
||||||
{
|
{
|
||||||
g_device.reset();
|
g_device.reset();
|
||||||
g_interface.reset();
|
g_interface.reset();
|
||||||
|
|
||||||
|
// In case Vulkan fails to initialize, we will try D3D12 again afterwards,
|
||||||
|
// just to get the game to boot. This only really happens in very old Intel GPU drivers.
|
||||||
|
if (!g_vulkan)
|
||||||
|
{
|
||||||
|
interfaceFunctions.push_back(CreateD3D12Interface);
|
||||||
|
allowVulkanRedirection = false;
|
||||||
|
}
|
||||||
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Hardware resolve seems to be completely bugged on Intel D3D12 drivers.
|
// Hardware resolve seems to be completely bugged on Intel D3D12 drivers.
|
||||||
g_hardwareResolve = (deviceDescription.vendor != RenderDeviceVendor::INTEL);
|
g_hardwareResolve = (deviceDescription.vendor != RenderDeviceVendor::INTEL);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue