From 952c66fe2a761449660c088eda2a530c484f4e12 Mon Sep 17 00:00:00 2001 From: Philip Rebohle Date: Mon, 14 Aug 2023 19:44:07 +0200 Subject: [PATCH] [dxgi] Add options to hide Intel or AMD GPUs. --- dxvk.conf | 21 +++++++++++++++++++-- src/dxgi/dxgi_adapter.cpp | 34 +++++++++++++++++++++++++++------- src/dxgi/dxgi_options.cpp | 6 ++++++ src/dxgi/dxgi_options.h | 7 ++++++- 4 files changed, 58 insertions(+), 10 deletions(-) diff --git a/dxvk.conf b/dxvk.conf index 3e474d89..198188f6 100644 --- a/dxvk.conf +++ b/dxvk.conf @@ -61,14 +61,31 @@ # d3d9.customDeviceDesc = "" -# Report Nvidia GPUs as AMD GPUs by default. This is enabled by default -# to work around issues with NVAPI, but may cause issues in some games. +# Report Nvidia GPUs as AMD GPUs. Unless NVAPI support is explicitly +# enabled through proton, this is done by default in order to work +# around crashes or low performance with Nvidia-speciic code paths +# in games, especially Unreal Engine. # # Supported values: Auto, True, False # dxgi.hideNvidiaGpu = Auto +# Report AMD GPUs as Nvidia GPUs. This is only done for games that are +# known to have issues with AMDAGS or other AMD-specific code paths. +# +# Supported values: Auto, True, False + +# dxgi.hideAmdGpu = Auto + + +# Report Intel GPUs as AMD GPUs. This is only done for games that are +# known to have issues with Intel-specific libraries such as XESS. +# +# Supported values: Auto, True, False + +# dxgi.hideIntelGpu = Auto + # Override maximum amount of device memory and shared system memory # reported to the application. This may fix texture streaming issues diff --git a/src/dxgi/dxgi_adapter.cpp b/src/dxgi/dxgi_adapter.cpp index fc1c14f4..b7c1b716 100644 --- a/src/dxgi/dxgi_adapter.cpp +++ b/src/dxgi/dxgi_adapter.cpp @@ -283,13 +283,33 @@ namespace dxvk { std::string description = options->customDeviceDesc.empty() ? std::string(deviceProp.deviceName) : options->customDeviceDesc; - - // XXX nvapi workaround for a lot of Unreal Engine 4 games - if (options->customVendorId < 0 && options->customDeviceId < 0 - && options->hideNvidiaGpu && deviceProp.vendorID == uint16_t(DxvkGpuVendor::Nvidia)) { - Logger::info("DXGI: NvAPI workaround enabled, reporting AMD GPU"); - deviceProp.vendorID = uint16_t(DxvkGpuVendor::Amd); - deviceProp.deviceID = 0x67df; /* RX 480 */ + + if (options->customVendorId < 0) { + uint16_t fallbackVendor = 0xdead; + uint16_t fallbackDevice = 0xbeef; + + if (!options->hideAmdGpu) { + // AMD RX 6700XT + fallbackVendor = uint16_t(DxvkGpuVendor::Amd); + fallbackDevice = 0x73df; + } else if (!options->hideNvidiaGpu) { + // Nvidia RTX 3060 + fallbackVendor = uint16_t(DxvkGpuVendor::Nvidia); + fallbackDevice = 0x2487; + } + + bool hideGpu = (deviceProp.vendorID == uint16_t(DxvkGpuVendor::Nvidia) && options->hideNvidiaGpu) + || (deviceProp.vendorID == uint16_t(DxvkGpuVendor::Amd) && options->hideAmdGpu) + || (deviceProp.vendorID == uint16_t(DxvkGpuVendor::Intel) && options->hideIntelGpu); + + if (hideGpu) { + deviceProp.vendorID = fallbackVendor; + + if (options->customDeviceId < 0) + deviceProp.deviceID = fallbackDevice; + + Logger::info(str::format("DXGI: Hiding actual GPU, reporting vendor ID 0x", std::hex, deviceProp.vendorID, ", device ID ", deviceProp.deviceID)); + } } // Convert device name diff --git a/src/dxgi/dxgi_options.cpp b/src/dxgi/dxgi_options.cpp index ee498a00..522a47e6 100644 --- a/src/dxgi/dxgi_options.cpp +++ b/src/dxgi/dxgi_options.cpp @@ -85,6 +85,12 @@ namespace dxvk { applyTristate(this->hideNvidiaGpu, hideNvidiaGpuOption); + // Expose AMD and Intel GPU by default, unless a config override is active. + // Implement as a tristate so that we have the option to introduce similar + // logic to Nvidia later, if necessary. + this->hideAmdGpu = config.getOption("dxgi.hideAmdGpu", Tristate::Auto) == Tristate::True; + this->hideIntelGpu = config.getOption("dxgi.hideIntelGpu", Tristate::Auto) == Tristate::True; + this->enableHDR = config.getOption("dxgi.enableHDR", env::getEnvVar("DXVK_HDR") == "1"); if (this->enableHDR && isHDRDisallowed()) { Logger::info("HDR was configured to be enabled, but has been force disabled as a UE4 DX11 game was detected."); diff --git a/src/dxgi/dxgi_options.h b/src/dxgi/dxgi_options.h index 751c7f5d..326c0b50 100644 --- a/src/dxgi/dxgi_options.h +++ b/src/dxgi/dxgi_options.h @@ -34,9 +34,14 @@ namespace dxvk { bool emulateUMA; /// Reports Nvidia GPUs as a different vendor (usually AMD) - /// in order to work around potential issues with NVAPI. bool hideNvidiaGpu; + /// Reports AMD GPUs as a different vendor (usually Nvidia) + bool hideAmdGpu; + + /// Reports Intel GPUs as a different vendor (usually AMD) + bool hideIntelGpu; + /// Enable HDR bool enableHDR; };