diff --git a/clean/installer/CMakeLists.txt b/clean/installer/CMakeLists.txt index bca556bb..92c9003f 100644 --- a/clean/installer/CMakeLists.txt +++ b/clean/installer/CMakeLists.txt @@ -11,6 +11,12 @@ # payload folder are not built in (src/setup_route.h). cmake_minimum_required(VERSION 3.16) project(wronggpu_installer LANGUAGES CXX RC) +# MinGW's headers set _WIN32_WINNT to Windows 7 as soon as a standard header comes first (context.h includes +# before base.h), which hides the Windows 8+ declarations the core uses (FILE_ID_INFO in convert_ignore.cpp): +# the whole build gets base.h's Windows 10 instead. MSVC's headers leave it unset. +if(MINGW) + add_compile_definitions(_WIN32_WINNT=0x0A00 WINVER=0x0A00) +endif() set(CMAKE_CXX_STANDARD 17) set(CMAKE_CXX_STANDARD_REQUIRED ON) diff --git a/clean/installer/README.md b/clean/installer/README.md index be0c3882..7f62bb3f 100644 --- a/clean/installer/README.md +++ b/clean/installer/README.md @@ -190,7 +190,10 @@ With the defaults nothing of this section changes the installer. conversion runs in memory during the checks and is written at install time to `%LOCALAPPDATA%\WrongGPU\model\model.wgcm` with `model-source.txt` (which file, its version, where it was found, `filter` = whether that file had the weights, and a `not-used` line for each file that converts too but was passed - over). The DLSS file is never copied or modified. + over). The DLSS file is never copied or modified. Under Wine (Linux), where Proton runs each game in a prefix of its + own, the game's settings name this folder and the Ray Reconstruction data file by their `Z:` paths, which relies on + `Z:` mapping the Linux root in the game's prefix (Wine's default). A path that can't be made a `Z:` path is written + as it is, logged, and reported in the install result. - **A model file that is already on the PC.** A `model.wgcm` whose stage digests match the embedded map is valid. It is reused without searching when it has the group `filter` and was written with the map this installer carries. A valid model M file without the group (written before the group existed, or from a DLSS file whose filter was diff --git a/clean/installer/src/app/ui_game.cpp b/clean/installer/src/app/ui_game.cpp index 469ef579..786b7a35 100644 --- a/clean/installer/src/app/ui_game.cpp +++ b/clean/installer/src/app/ui_game.cpp @@ -1648,10 +1648,14 @@ static float RrSection(Gfx& gx, float x, float y, float w) { if (Rec() && on) { wstring why; const bool working = BusyHere() && v.busyVerb == L"Preparing Ray Reconstruction\u2026"; - const GameRule* gr = GameRuleFor(e.exe); const wstring bg = working ? L"" : RrBackgroundWords(e.exe); // 0.6.0 polish: prepared again after a driver update - if (gr && gr->rrKernelsInGame) // the game prepares them at its own first start (gamerules.h: its driver cache is its own) - yy += DotRow(gx, x, yy, w, false, L"Prepared by the game at its first start (about a minute after a graphics driver update)", pal.greyDot, pal.text); + // the game prepares them at its own first start (gamerules.h: its driver cache is its own; under Wine every game, + // rrprep.h): no Prepare button, which would do nothing there + if (RrKernelsInGame(e.exe)) + yy += DotRow(gx, x, yy, w, false, + UnderWine() ? L"Prepared by the game at its first start (under Proton its shader caches are its own)" + : L"Prepared by the game at its first start (about a minute after a graphics driver update)", + pal.greyDot, pal.text); else if (!bg.empty()) yy += NeedRow(gx, x, yy, w, false, bg, L"Not ready until it is done. Prepare does it now instead.", pal.greyDot, pal.text, ID_G_RRPREP, L"Prepare", B_PLAIN, !Locked(), L"Prepare Ray Reconstruction", false); diff --git a/clean/installer/src/wg_core/checks.cpp b/clean/installer/src/wg_core/checks.cpp index 7c9fcfa2..bdcf8ceb 100644 --- a/clean/installer/src/wg_core/checks.cpp +++ b/clean/installer/src/wg_core/checks.cpp @@ -28,6 +28,57 @@ WinInfo WindowsInfo() { } bool IsRdna4Name(const wstring& name) { return Contains(name, L"RX 90") || Contains(name, L"PRO R97") || Contains(name, L"PRO R96"); } +// Under Wine, Wine's own DXGI can name an RDNA 4 card after an old Radeon ("ATI Radeon HD 5600 Series"); the PCI ids of +// Linux's DRM devices (/sys/class/drm/cardN/device, reached through Z:) are the card's own. The RDNA 4 ids are the RR +// runtime's list (clean/rr_f/runtime/src/rr_runtime.cpp rdna4_device_id). +// sysfs reports 4096 bytes for files that hold a few (ReadAll's size check fails on them): read to the end of the file. +static bool ReadSysfs(const wstring& path, string& out) { + HANDLE h = CreateFileW(path.c_str(), GENERIC_READ, FILE_SHARE_READ | FILE_SHARE_WRITE, nullptr, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, nullptr); + if (h == INVALID_HANDLE_VALUE) return false; + char b[64]; + DWORD got = 0; + out.clear(); + while (out.size() < 256 && ReadFile(h, b, sizeof b, &got, nullptr) && got) out.append(b, got); + CloseHandle(h); + return !out.empty(); +} +// Every DRM card the folder lists (card0, card1, ...; not the connectors such as card1-DP-1), in number order. +static std::vector> DrmCards(const wstring& drmRoot) { + std::vector> cards; + WIN32_FIND_DATAW fd; + HANDLE f = FindFirstFileW((drmRoot + L"\\card*").c_str(), &fd); + if (f == INVALID_HANDLE_VALUE) return cards; + do { + const wstring n = fd.cFileName; + if (n.size() <= 4 || n.size() > 12 || n.find_first_not_of(L"0123456789", 4) != wstring::npos) continue; + cards.push_back({std::wcstoul(n.c_str() + 4, nullptr, 10), Join(drmRoot, n)}); + } while (FindNextFileW(f, &fd)); + FindClose(f); + std::sort(cards.begin(), cards.end()); + return cards; +} +static bool HexId(const string& text, unsigned long& id) { + const char* s = text.c_str(); + char* end = nullptr; + id = strtoul(s, &end, 16); + while (end && (*end == '\n' || *end == '\r' || *end == ' ')) ++end; + return end && end != s && *end == '\0'; +} +wstring LinuxRdna4Name(const wstring& drmRoot) { + for (const auto& card : DrmCards(drmRoot)) { + string vendor, device; + unsigned long v = 0, d = 0; + if (!ReadSysfs(Join(card.second, L"device\\vendor"), vendor) || !ReadSysfs(Join(card.second, L"device\\device"), device) || + !HexId(vendor, v) || !HexId(device, d)) + continue; + if (v == 0x1002 && (d == 0x7550 || d == 0x7551 || d == 0x7590 || d == 0x7591)) { + wchar_t b[160]; + swprintf(b, 160, L"AMD Radeon RDNA 4 (PCI 1002:%04lX, found in Linux's device list; not confirmed as the adapter the game uses)", d); + return b; + } + } + return L""; +} GpuInfo DetectGpu() { GpuInfo best; HMODULE dxgi = LoadSystemDll(L"dxgi.dll"); @@ -56,6 +107,11 @@ GpuInfo DetectGpu() { if (!best.amd || (rdna4 && !best.rdna4)) { best.amd = true; best.rdna4 = rdna4; best.name = name; best.driver = driver; } } f->Release(); + if (!best.rdna4 && UnderWine()) { + const wstring linuxName = LinuxRdna4Name(); + // the driver version of the DXGI adapter is not this card's: left unknown rather than carried over + if (!linuxName.empty()) { best.amd = true; best.rdna4 = true; best.name = linuxName; best.driver.clear(); } + } return best; } diff --git a/clean/installer/src/wg_core/checks.h b/clean/installer/src/wg_core/checks.h index b60d94f3..82a377cf 100644 --- a/clean/installer/src/wg_core/checks.h +++ b/clean/installer/src/wg_core/checks.h @@ -28,6 +28,10 @@ struct SystemInfo { WinInfo win; GpuInfo gpu; HipInfo hip; }; WinInfo WindowsInfo(); bool IsRdna4Name(const wstring& name); +// Under Wine: the name DetectGpu gives an RDNA 4 card from Linux's PCI ids when Wine's DXGI names it otherwise; empty +// when Linux reports no RDNA 4 card (or outside Wine, where Z:\sys does not exist). drmRoot: the folder holding card0, +// card1, ... (Linux's /sys/class/drm; tests point it at a made-up folder). Every card is looked at, in number order. +wstring LinuxRdna4Name(const wstring& drmRoot = L"Z:\\sys\\class\\drm"); GpuInfo DetectGpu(); bool VersionLess(const wstring& a, const wstring& b); std::vector HipCandidates(); diff --git a/clean/installer/src/wg_core/coexist.cpp b/clean/installer/src/wg_core/coexist.cpp index 1500f9f1..f6d70183 100644 --- a/clean/installer/src/wg_core/coexist.cpp +++ b/clean/installer/src/wg_core/coexist.cpp @@ -319,10 +319,15 @@ CoexistReport AssessCoexistence(Context& ctx, const wstring& exe, const wstring& } } - // DXVK / vkd3d-proton: native D3D12 is required + // DXVK / vkd3d-proton: native D3D12 is required on Windows. Under Wine (Proton on Linux) vkd3d-proton is the D3D12 a + // game runs on, and a copy of it next to the game (a newer build than the Proton's own) is how a player gets one. for (Tool t : {Tool::Dxvk, Tool::Vkd3d}) { const auto f = filesOf(t); - if (!f.empty()) + if (!f.empty() && t == Tool::Vkd3d && UnderWine()) + add(t, Decision::Inform, wstring(ToolName(t)) + L" as " + f[0], f, fpOf(t)->evidence, + L"Under Wine (Proton) vkd3d-proton is the game's Direct3D 12. Left alone; Model M needs a vkd3d-proton whose " + L"dxil-spirv has pull request #362 (AMD's matrix instructions as WrongGPU uses them)."); + else if (!f.empty()) add(t, Decision::Refuse, wstring(ToolName(t)) + L" as " + f[0], f, fpOf(t)->evidence, L"WrongGPU needs Windows' own Direct3D 12; " + wstring(ToolName(t)) + L" translates the game's graphics to Vulkan. Not installed.", EXIT_REFUSED); } diff --git a/clean/installer/src/wg_core/install.cpp b/clean/installer/src/wg_core/install.cpp index 1036d0fd..618fdb73 100644 --- a/clean/installer/src/wg_core/install.cpp +++ b/clean/installer/src/wg_core/install.cpp @@ -169,6 +169,21 @@ wstring GameAmdFfxDll(Context& ctx, const wstring& dir, const wstring& exeDir) { // ------------------------------------------------------------------------------------------------ // Install engine // ------------------------------------------------------------------------------------------------ +// Under Wine: a model path for the game's own Proton prefix (PathForGamePrefix). When it can't be made a Z: path (Wine's +// wine_get_unix_file_name missing, or no part of the path resolvable), the launcher-prefix path is written as it is and +// the game will most likely not find the model: logged, and a line in the install result. +static wstring ModelPathForGame(Context& ctx, Ui& ui, std::vector& warnings, const wstring& path) { + const wstring z = PathForGamePrefix(path); + if (UnderWine() && !path.empty() && !StartsWithI(z, L"Z:\\")) { + const wstring w = L"The model path could not be made reachable from the game's own Proton prefix, so the game may " + L"not find the model: " + z + L" (a Z: path is needed; Z: maps the Linux root in every prefix)."; + LogLine(ctx, w); + ui.log(w); + warnings.push_back(w); + } + return z; +} + std::vector DoInstall(Context& ctx, const GameTarget& target, const ModelState& model, const Consent& consent, Ui& ui, const HipInfo& hip) { std::vector warnings; const wstring dir = target.dir; @@ -336,6 +351,12 @@ std::vector DoInstall(Context& ctx, const GameTarget& target, const Mod selectedOptions = OnlyModelM(selectedOptions); #endif selectedIni = IniSet(selectedIni, "fsr", "runtime_options", selectedOptions); + // Under Wine the game runs in a prefix of its own (Proton), where this launcher's %LOCALAPPDATA% does not exist: the + // model folder is named by its Z: path, which that prefix reaches too. A model_dir the player set stays. + string playerModelDir, playerModelDirSection; + IniGetFrontEnd(selectedIni, "model_dir", &playerModelDir, &playerModelDirSection); + if (UnderWine() && playerModelDir.empty()) + selectedIni = IniSet(selectedIni, "fsr", "model_dir", ToUtf8(ModelPathForGame(ctx, ui, warnings, ModelBaseDir()))); const wstring selectedIniSrc = Join(OptiTempDir(ctx), L"WrongGPU.selected.ini"); WriteFileAtomic(selectedIniSrc, selectedIni.data(), selectedIni.size()); optiFiles.push_back({L"wronggpu.ini", selectedIniSrc}); @@ -485,7 +506,7 @@ std::vector DoInstall(Context& ctx, const GameTarget& target, const Mod WriteFileAtomic(src, d, sz); optiFiles.push_back({IsRrPayloadPlugin(f.rel) ? Join(Parent(pluginRel), kRrPluginName) : wstring(f.rel), src}); } - const string rini = RrIniText(RrDataFile()); + const string rini = RrIniText(ModelPathForGame(ctx, ui, warnings, RrDataFile())); // Z: under Wine, as model_dir above const wstring rsrc = Join(tmp, kRrIni); WriteFileAtomic(rsrc, rini.data(), rini.size()); optiFiles.push_back({kRrIni, rsrc}); diff --git a/clean/installer/src/wg_core/rrprep.cpp b/clean/installer/src/wg_core/rrprep.cpp index ed9c1330..a0a833cf 100644 --- a/clean/installer/src/wg_core/rrprep.cpp +++ b/clean/installer/src/wg_core/rrprep.cpp @@ -122,6 +122,10 @@ wstring RrRuntimeSha(Context& ctx) { int RrPassesFor(const string& mode) { return mode.empty() || mode == "accurate" ? 1 : 2; } bool RrKernelsInGame(const wstring& exe) { + // Under Wine (Proton) a game's compiled kernels are kept by vkd3d-proton in the game folder (vkd3d-proton.cache, its + // working folder) and by Mesa in Steam's folder for the game, both under the game's own Proton: a helper in the + // launcher's prefix fills neither (measured 2026-11-13, Cyberpunk 2077 under GE-Proton 11-11). + if (UnderWine()) return true; const GameRule* r = GameRuleFor(exe); return r && r->rrKernelsInGame; } @@ -140,7 +144,8 @@ const wchar_t* RrPrepStateName(RrPrepState s) { RrPrepState RrPrepStateOf(Context& ctx, const wstring& dataDir, const wstring& exe, int passes, wstring* why) { if (RrKernelsInGame(exe)) { - if (why) *why = L"the game prepares them at its first start (its graphics driver cache is its own)"; + if (why) *why = UnderWine() ? L"the game prepares them at its first start (under Proton its shader caches are its own)" + : L"the game prepares them at its first start (its graphics driver cache is its own)"; return RrPrepState::InGame; } const wstring name = BaseName(exe), driver = RrDriverVersion(), sha = RrRuntimeSha(ctx); @@ -162,6 +167,12 @@ bool RrPrepared(Context& ctx, const wstring& dataDir, const wstring& exe, int pa int PrepareRr(Context& ctx, const wstring& dataDir, const wstring& exe, const wstring& runtimeDll, int passes, const std::function& progress, wstring* why) { if (RrKernelsInGame(exe)) { + if (UnderWine()) { + if (why) *why = L"the game prepares them at its first start (under Proton its shader caches are its own)"; + LogLine(ctx, L"Ray Reconstruction: " + BaseName(exe) + L" prepares its kernels at its first start (under Proton the game's shader caches are vkd3d-proton's " + L"file in the game folder and Steam's folder for the game, which the launcher's helper can't fill); nothing prepared ahead"); + return 4; + } if (why) *why = L"the game prepares them at its first start (its graphics driver cache is its own)"; LogLine(ctx, L"Ray Reconstruction: " + BaseName(exe) + L" prepares its kernels at its first start (the graphics driver keeps the game's shader cache under the game's own " L"application name, which the launcher's helper can't reach); nothing prepared ahead"); diff --git a/clean/installer/src/wg_core/rrprep.h b/clean/installer/src/wg_core/rrprep.h index db8c71d8..03ae8b02 100644 --- a/clean/installer/src/wg_core/rrprep.h +++ b/clean/installer/src/wg_core/rrprep.h @@ -49,7 +49,8 @@ RrPrepState RrPrepStateOf(Context& ctx, const wstring& dataDir, const wstring& e const wchar_t* RrPrepStateName(RrPrepState s); // "ready", "not-prepared", "driver-changed", ... (JSON, logs) // What the launcher's start prepares again in the background: prepared before, and the driver or the runtime changed. inline bool RrStaleAfterUpdate(RrPrepState s) { return s == RrPrepState::DriverChanged || s == RrPrepState::RuntimeChanged; } -// gamerules.h: the game prepares RR's kernels at its own first start (the launcher's helper can't reach its cache) +// gamerules.h, or any game under Wine (Proton): the game prepares RR's kernels at its own first start (the launcher's helper +// can't reach its cache) bool RrKernelsInGame(const wstring& exe); // The helper run: the launcher's own program copied as rr-prepare\run\, started with --rr-prepare // , its progress read line by line (progress answers false: cancel). 0 prepared (recorded), 1 diff --git a/clean/installer/src/wg_core/util.cpp b/clean/installer/src/wg_core/util.cpp index 02f80268..0a20f887 100644 --- a/clean/installer/src/wg_core/util.cpp +++ b/clean/installer/src/wg_core/util.cpp @@ -245,6 +245,29 @@ wstring EnvVar(const wchar_t* name) { } // System DLLs this exe uses only sometimes are loaded from System32 only, never from the download folder. HMODULE LoadSystemDll(const wchar_t* name) { return LoadLibraryExW(name, nullptr, LOAD_LIBRARY_SEARCH_SYSTEM32); } +bool UnderWine() { return GetProcAddress(GetModuleHandleW(L"ntdll.dll"), "wine_get_version") != nullptr; } +wstring PathForGamePrefix(const wstring& path) { + if (path.empty() || !UnderWine()) return path; + // Wine's kernel32: the Unix name of a DOS path, allocated on the process heap (UTF-8). It fails when more than the last + // part is missing (the RR data's F\ folder before its first conversion), so the deepest folder that exists is converted + // and the missing rest appended. + using UnixNameFn = char*(CDECL*)(const wchar_t*); + auto unixName = reinterpret_cast(reinterpret_cast(GetProcAddress(GetModuleHandleW(L"kernel32.dll"), "wine_get_unix_file_name"))); + if (!unixName) return path; + wstring head = path, tail; + char* u = nullptr; + while (!(u = unixName(head.c_str()))) { + const size_t cut = head.find_last_of(L"\\/"); + if (cut == wstring::npos || cut < 3) return path; + tail = head.substr(cut) + tail; + head.resize(cut); + } + wstring z = L"Z:" + FromUtf8(u) + tail; + HeapFree(GetProcessHeap(), 0, u); + for (wchar_t& c : z) + if (c == L'/') c = L'\\'; + return z; +} wstring SelfPath() { wchar_t b[MAX_PATH * 2]; DWORD n = GetModuleFileNameW(nullptr, b, (DWORD)std::size(b)); return wstring(b, n); } } // namespace wg diff --git a/clean/installer/src/wg_core/util.h b/clean/installer/src/wg_core/util.h index 41a4838c..e773f157 100644 --- a/clean/installer/src/wg_core/util.h +++ b/clean/installer/src/wg_core/util.h @@ -65,5 +65,10 @@ wstring Sha256File(const wstring& path); wstring NowStamp(bool forFileName); wstring EnvVar(const wchar_t* name); HMODULE LoadSystemDll(const wchar_t* name); +// The launcher under Wine (Linux): Wine's ntdll exports wine_get_version. +bool UnderWine(); +// A path for a game in another Wine prefix (Proton gives every game its own): under Wine the Z: path of the same file +// (Z: maps the Linux root in every prefix, C: does not), otherwise the path unchanged. +wstring PathForGamePrefix(const wstring& path); wstring SelfPath(); } // namespace wg diff --git a/clean/installer/tests/coexist_tests.cpp b/clean/installer/tests/coexist_tests.cpp index e72dc682..7eec29a5 100644 --- a/clean/installer/tests/coexist_tests.cpp +++ b/clean/installer/tests/coexist_tests.cpp @@ -695,6 +695,21 @@ int main() { for (auto& w : all.warnings) { xessWarn |= w.kind == L"xess-no-depth"; plug |= w.kind == L"plugin-not-hooked"; } require(all.found && xessWarn && plug && all.plugin == L"not-hooked", "ReadLastRun: XeSS without depth (OptiScaler.log), the plugin's log in its own folder"); + // ---- vkd3d-proton next to the game: refused on Windows, a note under Wine (where it is the game's D3D12) ---------- + { + const wstring vg = Join(dir, L"vkd3d game"); + Put(Join(vg, L"Game.exe"), "synthetic game exe"); + Put(Join(vg, L"d3d12.dll"), "MZ synthetic vkd3d-proton d3d12"); + Context vctx; + const CoexistReport vr = AssessCoexistence(vctx, Join(vg, L"Game.exe"), L"", nullptr); + const Finding* vf = nullptr; + for (auto& f : vr.findings) if (f.tool == Tool::Vkd3d) vf = &f; + if (UnderWine()) + require(vf && vf->decision == Decision::Inform && !vr.refusal(), "vkd3d-proton next to the game under Wine: a note, not refused"); + else + require(vf && vf->decision == Decision::Refuse && vr.refusal() == vf, "vkd3d-proton next to the game on Windows: refused"); + } + RemoveTree(dir); std::printf("coexist-core: %d checks passed\n", checks); return 0; diff --git a/clean/installer/tests/wg_core_tests.cpp b/clean/installer/tests/wg_core_tests.cpp index fbd0d2cf..dc16690f 100644 --- a/clean/installer/tests/wg_core_tests.cpp +++ b/clean/installer/tests/wg_core_tests.cpp @@ -12,6 +12,7 @@ #include "wg_core/gamerules.h" #include "wg_core/model.h" #include "wg_core/record.h" +#include "wg_core/rrprep.h" #include "wg_core/settings.h" using namespace wg; @@ -155,6 +156,21 @@ int main() { require(refused, "Target refuses a path outside the folder"); } + // RR's kernels under Wine: the game prepares them at its first start (its shader caches are under its own Proton); + // no helper runs. On Windows a game without a rule is prepared by the launcher. + { + Context rctx; + rctx.logFile = Join(dir, L"rr-prep.log"); + const wstring game = Join(dir, L"No Rule Game\\NoRuleGame.exe"); + wstring why; + if (UnderWine()) { + require(RrKernelsInGame(game) && RrPrepStateOf(rctx, dir, game, 1, &why) == RrPrepState::InGame && Contains(why, L"Proton"), + "RR kernels under Wine: prepared by the game at its first start"); + require(PrepareRr(rctx, dir, game, Join(dir, L"no-runtime.dll"), 1, nullptr, &why) == 4, "PrepareRr under Wine: no helper run (4)"); + } else { + require(!RrKernelsInGame(game), "RR kernels on Windows: a game without a rule is prepared by the launcher"); + } + } // anti-cheat: the game's top folder and the markers it owns (a sibling game's or a library's markers do not count) { const wstring lib = Join(dir, L"OpenNR Library"), steam = Join(dir, L"SteamLib"); @@ -189,6 +205,48 @@ int main() { "ShortenMiddle keeps the drive and the marker"); } + // Linux's device list from a made-up folder (any host): every card in number order, connectors skipped, junk and + // missing files ignored, the reported name says the card was not confirmed as the game's adapter + { + const wstring drm = Join(dir, L"drm-fixture"); + auto card = [&](const wstring& name, const char* vendor, const char* device) { + EnsureDir(Join(drm, name + L"\\device")); + if (vendor) WriteFileAtomic(Join(drm, name + L"\\device\\vendor"), vendor, strlen(vendor)); + if (device) WriteFileAtomic(Join(drm, name + L"\\device\\device"), device, strlen(device)); + }; + card(L"card0", "0x1002\n", "0x15bf\n"); // an integrated Radeon, not RDNA 4 + card(L"card1", "0x10de\n", "0x7550\n"); // another vendor with an RDNA 4 device id + card(L"card2", "zz\n", "0x7550\n"); // a vendor that is not a number + card(L"card3", "0x1002\n", nullptr); // the device file missing + card(L"card4-DP-1", "0x1002\n", "0x7550\n"); // a connector, not a card + require(LinuxRdna4Name(drm).empty(), "LinuxRdna4Name: none among an iGPU, another vendor, junk, a missing file, a connector"); + require(LinuxRdna4Name(Join(dir, L"no-such-drm")).empty(), "LinuxRdna4Name: a missing device list"); + card(L"card20", "0x1002\n", "0x7590\n"); // past the first 16 cards + const wstring past16 = LinuxRdna4Name(drm); + require(Contains(past16, L"7590") && Contains(past16, L"not confirmed"), "LinuxRdna4Name: a card numbered 20, reported as not confirmed"); + card(L"card17", "0x1002\n", "0x7550 \n"); // two RDNA 4 cards: the lower number first + require(Contains(LinuxRdna4Name(drm), L"7550"), "LinuxRdna4Name: cards in number order"); + } + // under Wine an RDNA 4 card that Linux reports is found even when Wine's own DXGI names an old Radeon + if (UnderWine()) { + auto sysfs = [](const wstring& p) { // the C runtime reads to the end of file (sysfs reports 4096 bytes) + string s; + if (FILE* f = _wfopen(p.c_str(), L"rb")) { char b[64]; size_t n; while ((n = fread(b, 1, sizeof b, f)) > 0) s.append(b, n); fclose(f); } + return s; + }; + bool linuxRdna4 = false; + for (int i = 0; i < 16 && !linuxRdna4; ++i) { + const wstring dev = L"Z:\\sys\\class\\drm\\card" + std::to_wstring(i) + L"\\device\\"; + const unsigned long v = strtoul(sysfs(dev + L"vendor").c_str(), nullptr, 16), id = strtoul(sysfs(dev + L"device").c_str(), nullptr, 16); + linuxRdna4 = v == 0x1002 && (id == 0x7550 || id == 0x7551 || id == 0x7590 || id == 0x7591); + } + const wstring fromLinux = LinuxRdna4Name(); + const GpuInfo gpu = DetectGpu(); + std::wcout << L"under Wine: Linux reports RDNA 4: " << linuxRdna4 << L"; LinuxRdna4Name: \"" << fromLinux << L"\"; DetectGpu: " << gpu.name << L" (rdna4 " << gpu.rdna4 << L")\n"; + require(fromLinux.empty() != linuxRdna4, "LinuxRdna4Name: the RDNA 4 card Linux reports, and only then"); + if (linuxRdna4) require(gpu.amd && gpu.rdna4, "DetectGpu under Wine: the RDNA 4 card Linux reports"); + } + // a store's launch exe is a hint only: a launcher stub (REDprelauncher.exe) gives way to the exe discovery { auto file = [](const wstring& p) { EnsureDir(Parent(p)); WriteFileAtomic(p, "MZ", 2); }; @@ -248,6 +306,29 @@ int main() { require(ResolveGameExe(Join(q, L"Game\\QuarryNine.exe")) == Join(q, L"Game\\QuarryNine.exe"), "an exe without a game of its name below it stays"); } + // paths for a game in another Wine prefix (Proton): the Z: name of the same file; unchanged outside Wine + { + const wstring f = Join(dir, L"prefix-path.txt"); + WriteFileAtomic(f, "same file", 9); + const wstring g = PathForGamePrefix(f); + string back; + if (UnderWine()) + require(StartsWithI(g, L"Z:\\") && ReadAll(g, back) && back == "same file", "PathForGamePrefix under Wine: a Z: path to the same file"); + else + require(g == f, "PathForGamePrefix outside Wine: the path unchanged"); + // two folders that do not exist yet (the RR data's F\ before its first conversion): still the Z: path, the tail kept + const wstring deepTail = L"\\no-such-dir\\F\\model.wgcm", deep = PathForGamePrefix(dir + deepTail); + if (UnderWine()) + require(StartsWithI(deep, L"Z:\\") && deep.size() > deepTail.size() && deep.compare(deep.size() - deepTail.size(), deepTail.size(), deepTail) == 0, + "PathForGamePrefix under Wine: a Z: path for missing folders too"); + require(PathForGamePrefix(L"").empty(), "PathForGamePrefix of an empty path"); + // a drive the prefix doesn't map: no Z: path can be made, the path comes back as it is (the install then + // reports it, install.cpp ModelPathForGame) + if (UnderWine()) { + const wstring unmapped = L"Q:\\wg-no-such-drive\\model"; + require(PathForGamePrefix(unmapped) == unmapped, "PathForGamePrefix under Wine: an unmapped drive comes back unchanged"); + } + } // the Context's log file Context ctx; ctx.logFile = Join(dir, L"setup.log");