Repository navigation
[xess xmx] Don't hide Intel GPUs when XeSS is provided by Proton #5992
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
29a44cd
72976ef
4030a36
30f723f
b9491a9
903dcaf
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,5 +1,6 @@ | ||
| #include "dxgi_options.h" | ||
|
|
||
| #include <cstring> | ||
| #include <unordered_map> | ||
|
|
||
| namespace dxvk { | ||
|
|
@@ -39,20 +40,37 @@ namespace dxvk { | |
| return id; | ||
| } | ||
|
|
||
| /** | ||
| * \brief Whether old XeSS versions need the Intel vendor ID hidden | ||
| */ | ||
| enum class XessVendorWa : uint32_t { | ||
| Unknown, ///< No XeSS loaded yet | ||
| NotNeeded, ///< Wine builtin XeSS or a fixed XeSS version | ||
| Needed, ///< XeSS version that fails on the Intel path | ||
| }; | ||
|
|
||
| /* Some XeSS versions crash on Proton for Intel due to missing Intel | ||
| * interfaces. Avoid crash by pretending to be non-Intel if the libxess.dll | ||
| * module is loaded by an application. */ | ||
| static bool isXessVendorWaNeeded() { | ||
| * interfaces. Avoid the crash by pretending to be non-Intel once such | ||
| * a libxess.dll module is loaded by the application. Applications may | ||
| * load XeSS late, e.g. the Unreal Engine plugin loads it only after the | ||
| * D3D12 device is created, so this can't be decided up front. */ | ||
| static XessVendorWa getXessVendorWa() { | ||
| #ifdef _WIN32 | ||
| HMODULE libxess = nullptr; | ||
|
|
||
| // Use Ex variant here to keep the library loaded while we use the handle | ||
| if (!GetModuleHandleExA(0u, "libxess", &libxess) | ||
| && !GetModuleHandleExA(0u, "libxess_dx11", &libxess)) | ||
| return false; | ||
| return XessVendorWa::Unknown; | ||
|
|
||
| if (!libxess) | ||
| return false; | ||
| return XessVendorWa::Unknown; | ||
|
|
||
| // Wine builtin XeSS (e.g. Proton forwarding to a native libxess.so) | ||
| // doesn't use the Intel path that needs the workaround. | ||
| static const char builtinSignature[] = "Wine builtin DLL"; | ||
| bool isBuiltin = !std::memcmp(reinterpret_cast<const char*>(libxess) + 0x40, | ||
| builtinSignature, sizeof(builtinSignature)); | ||
|
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Isn't there a more robust way to detect this (e.g. some export that's only available in the built-in dll or something)? This hack looks like the kind of thing that's just going to blow up either on Windows or at some point in the future, and when it does then the only real option is to remove the code. |
||
|
|
||
| // For some reason it seems to be impossible to just query | ||
| // the length, need to pre-allocate for the worst case | ||
|
|
@@ -63,56 +81,57 @@ namespace dxvk { | |
| // on the actual file from now on | ||
| FreeLibrary(libxess); | ||
|
|
||
| if (isBuiltin) | ||
| return XessVendorWa::NotNeeded; | ||
|
|
||
| if (!nameLen) { | ||
| Logger::warn("DXGI: Failed to get file name for XeSS module"); | ||
| return true; | ||
| return XessVendorWa::Needed; | ||
| } | ||
|
|
||
| // Query version info blob size... | ||
| auto fiSize = GetFileVersionInfoSizeA(fileName.data(), nullptr); | ||
|
|
||
| if (!fiSize) { | ||
| Logger::warn("DXGI: Failed to get XeSS version info size"); | ||
| return true; | ||
| return XessVendorWa::Needed; | ||
| } | ||
|
|
||
| // Retrieve actual version info blob | ||
| std::vector<char> fiData(fiSize); | ||
|
|
||
| if (!GetFileVersionInfoA(fileName.data(), 0u, fiSize, fiData.data())) { | ||
| Logger::warn("DXGI: Failed to get XeSS version info"); | ||
| return true; | ||
| return XessVendorWa::Needed; | ||
| } | ||
|
|
||
| void* fiBlock = nullptr; | ||
| UINT fiBlockSize = 0u; | ||
|
|
||
| if (!VerQueryValueA(fiData.data(), "\\", &fiBlock, &fiBlockSize)) { | ||
| Logger::warn("DXGI: Failed to get XeSS version info block"); | ||
| return true; | ||
| return XessVendorWa::Needed; | ||
| } | ||
|
|
||
| auto fiBlockTyped = reinterpret_cast<const VS_FIXEDFILEINFO*>(fiBlock); | ||
|
|
||
| if (!fiBlockTyped || fiBlockSize < sizeof(*fiBlockTyped)) { | ||
| Logger::warn("DXGI: Invalid XeSS version info block"); | ||
| return true; | ||
| return XessVendorWa::Needed; | ||
| } | ||
|
|
||
| const uint32_t major = fiBlockTyped->dwProductVersionMS >> 16; | ||
| const uint32_t minor = fiBlockTyped->dwProductVersionMS & 0xffffu; | ||
| const uint32_t patch = fiBlockTyped->dwProductVersionLS >> 16; | ||
| const uint32_t build = fiBlockTyped->dwProductVersionLS & 0xffffu; | ||
|
|
||
| // Some early 2.0 builds are still affected, keep the workaround enabled | ||
| // until at least 2.0.2.68. | ||
| const bool isKnownGood = isVersionAtLeast( | ||
| major, minor, patch, build, | ||
| bool isKnownGood = isVersionAtLeast( | ||
| fiBlockTyped->dwProductVersionMS >> 16, | ||
| fiBlockTyped->dwProductVersionMS & 0xffffu, | ||
| fiBlockTyped->dwProductVersionLS >> 16, | ||
| fiBlockTyped->dwProductVersionLS & 0xffffu, | ||
| 2u, 0u, 2u, 68u); | ||
|
|
||
| return !isKnownGood; | ||
| return isKnownGood ? XessVendorWa::NotNeeded : XessVendorWa::Needed; | ||
| #else | ||
| return false; | ||
| return XessVendorWa::NotNeeded; | ||
| #endif | ||
| } | ||
|
|
||
|
|
@@ -121,6 +140,35 @@ namespace dxvk { | |
| } | ||
|
|
||
|
|
||
| bool DxgiOptions::shouldHideIntelGpu() const { | ||
| if (this->hideIntelGpu) | ||
| return true; | ||
|
|
||
| // XeSS is loaded once per process, so the decision is shared by all | ||
| // DXGI factories. Keep checking until XeSS is loaded, then stick with | ||
| // the decision so the reported vendor doesn't change again. | ||
| static std::atomic<XessVendorWa> s_xessVendorWa = { XessVendorWa::Unknown }; | ||
|
|
||
| XessVendorWa wa = s_xessVendorWa.load(); | ||
| if (wa == XessVendorWa::Unknown) { | ||
| wa = getXessVendorWa(); | ||
|
|
||
| if (wa != XessVendorWa::Unknown) { | ||
| XessVendorWa expected = XessVendorWa::Unknown; | ||
|
|
||
| if (s_xessVendorWa.compare_exchange_strong(expected, wa)) { | ||
| if (wa == XessVendorWa::Needed) | ||
| Logger::info("DXGI: Detected XeSS usage, hiding Intel GPU Vendor"); | ||
| } else { | ||
| wa = expected; | ||
| } | ||
| } | ||
| } | ||
|
|
||
| return wa == XessVendorWa::Needed; | ||
| } | ||
|
|
||
|
|
||
| static bool isHDRDisallowed(bool enableUe4Workarounds) { | ||
| #ifdef _WIN32 | ||
| // Unreal Engine 4 titles use AGS/NVAPI to try and enable | ||
|
|
@@ -187,11 +235,6 @@ namespace dxvk { | |
| this->hideAmdGpu = config.getOption<Tristate>("dxgi.hideAmdGpu", Tristate::Auto) == Tristate::True; | ||
| this->hideIntelGpu = config.getOption<Tristate>("dxgi.hideIntelGpu", Tristate::Auto) == Tristate::True; | ||
|
|
||
| if (isXessVendorWaNeeded()) { | ||
| Logger::info(str::format("XeSS: hiding Intel GPU Vendor ID")); | ||
| this->hideIntelGpu = true; | ||
| } | ||
|
|
||
| this->enableHDR = config.getOption<bool>("dxgi.enableHDR", env::getEnvVar("DXVK_HDR") == "1"); | ||
|
|
||
| bool enableUe4Workarounds = config.getOption<bool>("dxgi.enableUe4Workarounds", false); | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.