Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,8 @@ jobs:
run: |
$PSNativeCommandUseErrorActionPreference = $true
cmake -S clean/installer -B out/launcher-tests -G Ninja -DCMAKE_BUILD_TYPE=Release -DCMAKE_POLICY_DEFAULT_CMP0091=NEW -DCMAKE_MSVC_RUNTIME_LIBRARY=MultiThreaded -DWRONGGPU_PAYLOAD_DIR="$PWD/out/no-payload" -DWRONGGPU_TESTING=OFF -DWRONGGPU_PRESET_K=OFF -DWRONGGPU_DIRECT_ROUTE=OFF
cmake --build out/launcher-tests --target wg-core-tests launcher-core-tests coexist-core-tests
ctest --test-dir out/launcher-tests --output-on-failure -R "^(wg-core|launcher-core|coexist-core|source-size|wording)$"
cmake --build out/launcher-tests --target wg-core-tests launcher-core-tests coexist-core-tests convert-ignore-tests
ctest --test-dir out/launcher-tests --output-on-failure -R "^(wg-core|launcher-core|coexist-core|convert-ignore|source-size|wording)$"
- name: Ray Reconstruction plugin (build and CPU tests)
run: |
$PSNativeCommandUseErrorActionPreference = $true
Expand Down
8 changes: 7 additions & 1 deletion clean/installer/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ add_library(wg_core STATIC
src/wg_core/model.cpp src/wg_core/checks.cpp src/wg_core/install.cpp src/wg_core/logs.cpp
src/wg_core/profile.cpp src/wg_core/logtail.cpp src/wg_core/launcher.cpp
src/wg_core/fingerprint.cpp src/wg_core/optikeys.cpp src/wg_core/leftovers.cpp src/wg_core/rr.cpp src/wg_core/rrprep.cpp src/wg_core/gamerules.cpp
src/wg_core/rrconfig.cpp)
src/wg_core/rrconfig.cpp src/wg_core/convert_ignore.cpp)
target_include_directories(wg_core PUBLIC src)
target_compile_definitions(wg_core PUBLIC ${PRESET_K_DEFINITION} ${DIRECT_ROUTE_DEFINITION})
if(WRONGGPU_TESTING)
Expand Down Expand Up @@ -188,13 +188,19 @@ add_executable(coexist-core-tests tests/coexist_tests.cpp)
target_link_libraries(coexist-core-tests PRIVATE wg_core)
# real front-end log excerpts (trimmed, paths replaced) for the Last run parser (UI review r3 #2)
target_compile_definitions(coexist-core-tests PRIVATE WG_TEST_LOGS="${CMAKE_CURRENT_SOURCE_DIR}/tests/logs")
# The converter search's ignore lists (src/wg_core/convert_ignore.h): the list format, bad lines, path and hash matching
# (case, slashes, '.' and '..', hard link, junction, symbolic link where the account may make one), the well-known lists,
# and an empty list keeping every candidate set as it was (synthetic files in the temp folder).
add_executable(convert-ignore-tests tests/convert_ignore_tests.cpp)
target_link_libraries(convert-ignore-tests PRIVATE wg_core)
enable_testing()
add_test(NAME source-size COMMAND ${Python3_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/tools/check_source_size.py)
# The launcher's words never claim the same output as the original ("bit for bit", "identical", "(native)": rr-notes.md)
add_test(NAME wording COMMAND ${Python3_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/tools/check_wording.py)
add_test(NAME wg-core COMMAND wg-core-tests)
add_test(NAME launcher-core COMMAND launcher-core-tests)
add_test(NAME coexist-core COMMAND coexist-core-tests)
add_test(NAME convert-ignore COMMAND convert-ignore-tests)
if(WRONGGPU_TESTING)
add_test(NAME wizard-policy COMMAND wizard-policy-tests)
endif()
Expand Down
148 changes: 148 additions & 0 deletions clean/installer/README.md

Large diffs are not rendered by default.

136 changes: 123 additions & 13 deletions clean/installer/src/app/cli.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@
// hipcheck the HIP runtime check alone
// model status | model convert [--model=<dll>]
// rr-data status | rr-data convert [--dll=<RR model file>] the Ray Reconstruction data (shared by the RR games)
// both converts: --ignore=<path> | --ignore=<path> sha256=<hex> (both must match) |
// --ignore=sha256=<hex> (every identical copy), --ignore-list=<file> (repeatable; added
// to the well-known ignore lists, wg_core/convert_ignore.h), --library=<folder> (its sub-folders
// searched as games, this run only)
// rr-recheck <game> [--run] what the window's start does: RR's kernels prepared again after a driver / runtime change
// self-install [--dir=<folder>] [--startmenu=<folder>|-] the launcher for this user (one Apps & features entry)
// self-uninstall [--keep-games] [--startmenu=<folder>] (no window; Apps & features runs "uninstall-launcher", the window's)
Expand Down Expand Up @@ -60,6 +64,7 @@ const int kRestorerResourceId = 960; // WrongGPU-Restore.exe, embedded by CMake
void LauncherInit(const wstring& logOverride, bool worker, bool window) {
gl.paths = ResolvePaths(SelfPath(), gl.dataOverride);
gl.global = LoadGlobal(gl.paths);
g.ctx.ownDataDir = gl.paths.dataDir; // its ignore-files.txt is a well-known list too (convert_ignore.h)
g.ctx.hipOptional = true;
g.ctx.hostedLayout = !kDirectRoute;
g.ctx.perGameEntry = !LauncherInstalled();
Expand Down Expand Up @@ -346,6 +351,8 @@ struct Args {
std::map<wstring, wstring> opt; // --name=value (and --name value for the path options)
std::set<wstring> flags; // --name
std::vector<wstring> libraries; // --library=<folder> (repeatable)
std::vector<wstring> ignores; // --ignore=<path, or sha256=<hex>> (repeatable; convert_ignore.h)
std::vector<wstring> ignoreLists; // --ignore-list=<file> (repeatable)
bool has(const wchar_t* f) const { return flags.count(f) > 0; }
wstring get(const wchar_t* k) const { auto it = opt.find(k); return it == opt.end() ? wstring() : it->second; }
};
Expand Down Expand Up @@ -489,7 +496,74 @@ static void RrConfigAfterInstall(const Args& a, const wstring& dir, OpResult& re
Print(RrConfigNotice(*rg) + L"\n\nFix it for me: " + set + L"\nDo it yourself: the steps below (rr_config_fix=off stops this question).\n\n" + steps);
}

// model convert / rr-data convert: the store libraries (unless --noscan) and the sub-folders of each --library=<folder> (one
// game each, as `scan` reads them; this run only).
static std::vector<StoreGame> ConvertLibraries(const Args& a, bool noScan) {
std::vector<StoreGame> libs = noScan ? std::vector<StoreGame>{} : ScanLibraries();
for (auto& lib : a.libraries)
for (auto& sub : ListDirs(FullPath(lib))) libs.push_back({BaseName(sub), sub, L"", L"Folder"});
return libs;
}
// --ignore-list=<file> and --ignore=<entry> of model convert / rr-data convert (convert_ignore.h), added to the well-known
// lists. A list file that can't be read, or an --ignore= that is not understood, stops the command before anything is
// converted (a file meant to be skipped is never converted because of a typo); a bad line inside a list is skipped with a warning.
static bool ConvertIgnoreArgs(const Args& a, Output& o) {
g.ctx.ignoreListFiles.clear();
g.ctx.ignoreListBytes.clear();
g.ctx.ignoreEntries.clear();
auto refuse = [&o](const wstring& msg) { o.code = EXIT_USAGE; o.j.S("error", msg); Print(msg); return false; };
// a bare --ignore / --ignore-list (no "=", or nothing after it): never takes the next argument as its value
if (a.has(L"ignore")) return refuse(L"--ignore needs its entry after an equals sign: --ignore=<full path> or --ignore=sha256=<hex>; nothing was converted");
if (a.has(L"ignore-list")) return refuse(L"--ignore-list needs its file: --ignore-list=<file>; nothing was converted");
for (auto& f : a.ignoreLists) {
// read once, with the lists' own bounded reader (the size is checked before anything is read); the search parses
// these bytes (LoadConvertIgnore), it does not read the file again
const wstring full = FullPath(f);
string bytes;
wstring why;
if (!ReadIgnoreListBytes(full, bytes, why)) return refuse(L"--ignore-list=" + f + L": the file can't be read (" + full + L": " + why + L"); nothing was converted");
g.ctx.ignoreListFiles.push_back(full);
g.ctx.ignoreListBytes.push_back(std::move(bytes));
}
for (auto& s : a.ignores) {
IgnoreEntry e;
wstring why;
// a hash alone (--ignore=sha256=<hex>) is the player's own choice here; it matches every copy of that file with the same bytes
if (!ParseIgnoreLine(s, e, why, nullptr, true) || e.text.empty())
return refuse(L"--ignore=" + s + L": " + (why.empty() ? wstring(L"no path or sha256=<hex>") : why) + L"; nothing was converted");
g.ctx.ignoreEntries.push_back(s);
}
return true;
}
// --ignore and --ignore-list are read by model convert and rr-data convert / prepare only: on any other verb they would be
// accepted and do nothing, so the player thinks a file is protected. Exit 10 and a message instead.
static bool IgnoreArgsMisplaced(const wstring& verb, const Args& a, Output& o) {
if (a.ignores.empty() && a.ignoreLists.empty() && !a.has(L"ignore") && !a.has(L"ignore-list")) return false;
const wstring sub = a.pos.empty() ? L"status" : a.pos[0];
bool applies = (verb == L"model" && sub == L"convert") || (verb == L"rr-data" && sub == L"convert");
#ifdef WRONGGPU_TESTING
applies = applies || (verb == L"rr-data" && sub == L"prepare");
#endif
if (applies) return false;
const wstring msg = L"--ignore and --ignore-list apply only to \"model convert\" and \"rr-data convert\" (the well-known ignore lists are read by every conversion, "
L"also an install's); \"" + verb + (a.pos.empty() ? wstring() : L" " + a.pos[0]) + L"\" would ignore them, so it was not run";
o.code = EXIT_USAGE;
o.j.S("error", msg);
Print(msg);
return true;
}
// The files the ignore lists left out, with the reason, and the lists' warnings: in the result and on the console.
static void IgnoreJson(Output& o, const IgnoreReport& r) {
o.j.Key("skipped").Arr();
for (auto& s : r.skipped) { o.j.Str(s); Print(L" skipped: " + s); }
o.j.End();
o.j.Key("ignore_warnings").Arr();
for (auto& w : r.warnings) { o.j.Str(w); Print(L" ignore list warning: " + w); }
o.j.End();
}

int Verb(const wstring& verb, const Args& a, Output& o) {
if (IgnoreArgsMisplaced(verb, a, o)) return o.code;
const bool noScan = a.has(L"noscan");
GlobalSettings& gs = gl.global;
GlobalSettings scan = gs; // --library=<folder>: scanned this time only, never saved
Expand Down Expand Up @@ -813,15 +887,24 @@ int Verb(const wstring& verb, const Args& a, Output& o) {
if (verb == L"model") {
const wstring sub = a.pos.empty() ? L"status" : a.pos[0];
if (sub == L"convert") {
if (!ConvertIgnoreArgs(a, o)) return o.code;
OpLogBegin();
const std::vector<StoreGame> libs = noScan ? std::vector<StoreGame>{} : ScanLibraries();
const std::vector<StoreGame> libs = ConvertLibraries(a, noScan);
ModelState m = FindModel(g.ctx, nullptr, a.get(L"model").empty() ? wstring() : FullPath(a.get(L"model")), libs);
IgnoreJson(o, m.ignored);
int code = EXIT_OK;
std::vector<wstring> notes = m.notes; // the player's lines (a chosen file on a list, a model kept unchecked, ...)
if (m.ok()) {
Ui ui; ui.step = [](int, int, const wstring&) {}; ui.log = [](const wstring& s) { LogLine(g.ctx, s); };
try { const ModelResult r = WriteModel(g.ctx, m, ui); o.j.S("outcome", r.outcome); Print(L"model: " + r.outcome); }
try { const ModelResult r = WriteModel(g.ctx, m, ui); notes = r.notes; o.j.S("outcome", r.outcome); Print(L"model: " + r.outcome); }
catch (const SetupError& e) { o.j.S("error", e.msg); Print(e.msg); code = e.code; }
} else { o.j.S("error", m.error); Print(L"model: " + m.error); code = m.damaged ? EXIT_DAMAGED : EXIT_NO_MODEL; }
} else {
o.j.S("error", m.error); Print(L"model: " + m.error);
code = m.damaged ? EXIT_DAMAGED : m.code ? m.code : EXIT_NO_MODEL; // 10: an ignore list can't be read
}
o.j.Key("notes").Arr();
for (auto& n : notes) { o.j.Str(n); Print(L" " + n); }
o.j.End();
OpLogEnd();
if (code) return code;
}
Expand Down Expand Up @@ -890,17 +973,38 @@ int Verb(const wstring& verb, const Args& a, Output& o) {
if (verb == L"rr-data") { // Ray Reconstruction data (rr.h): status, or "convert" [--dll=<RR model file>]
const wstring sub = a.pos.empty() ? L"status" : a.pos[0];
if (sub == L"convert") {
if (!ConvertIgnoreArgs(a, o)) return o.code;
OpLogBegin();
const std::vector<StoreGame> libs = noScan ? std::vector<StoreGame>{} : ScanLibraries();
const std::vector<StoreGame> libs = ConvertLibraries(a, noScan);
wstring why;
std::vector<RrSettingsFailure> notWritten;
std::vector<wstring> warnings;
const bool ok = ConvertRrData(g.ctx, a.get(L"dll").empty() ? wstring() : FullPath(a.get(L"dll")), libs, &why, &notWritten);
IgnoreReport ignored;
const bool ok = ConvertRrData(g.ctx, a.get(L"dll").empty() ? wstring() : FullPath(a.get(L"dll")), libs, &why, &notWritten, &ignored);
if (ok) SyncRrSettings(nullptr, L"", warnings, &notWritten);
OpLogEnd();
if (!ok) { o.j.S("error", why); Print(L"Ray Reconstruction data: " + why); return EXIT_NO_MODEL; }
IgnoreJson(o, ignored);
if (!ok) { o.j.S("error", why); Print(L"Ray Reconstruction data: " + why); return ignored.unreadable.empty() ? EXIT_NO_MODEL : EXIT_USAGE; }
o.j.Key("warnings").Arr(); for (auto& w : warnings) { o.j.Str(w); Print(L" warning: " + w); } o.j.End();
}
#ifdef WRONGGPU_TESTING
// tests: what an install does with the RR data (FindRrData without `fresh`: the data on this PC reused when the ignore
// lists allow it, else converted again from --library= games), without a game or a device
if (sub == L"prepare") {
if (!ConvertIgnoreArgs(a, o)) return o.code;
const RrDataState st = FindRrData(g.ctx, nullptr, L"", ConvertLibraries(a, noScan), false);
wstring why;
const bool ok = st.ok && WriteRrData(g.ctx, st, &why);
IgnoreJson(o, st.ignored);
o.j.B("reused", st.reused).Key("notes").Arr();
for (auto& n : st.notes) { o.j.Str(n); Print(L" " + n); }
o.j.End();
if (!ok) {
o.j.S("error", why.empty() ? st.error : why); Print(L"Ray Reconstruction data: " + (why.empty() ? st.error : why));
return st.ignored.unreadable.empty() ? EXIT_NO_MODEL : EXIT_USAGE;
}
}
#endif
wstring why;
const bool valid = RrDataValid(g.ctx, &why);
o.j.Key("rr_data").Obj().S("file", RrDataFile()).B("valid", valid).S("source", RrDataSource()).S("why", why).B("payload", RrPayloadAvailable(g.ctx)).End();
Expand Down Expand Up @@ -948,10 +1052,11 @@ int Verb(const wstring& verb, const Args& a, Output& o) {
}
if (verb == L"remove-data") { // a portable copy's Settings > Remove data... without the window (RemoveSharedData)
const SharedDataLook look = LookAtSharedData(g.ctx);
wstring why;
if (!RemoveSharedData(g.ctx, &why)) { o.j.S("error", why); Print(why); return EXIT_REFUSED; }
o.j.B("removed", look.there);
wstring why, kept;
if (!RemoveSharedData(g.ctx, &why, &kept)) { o.j.S("error", why); Print(why); return EXIT_REFUSED; }
o.j.B("removed", look.there).S("kept", kept);
Print(look.there ? L"WrongGPU's data is removed from this PC." : L"There is no WrongGPU data to remove.");
if (!kept.empty()) Print(kept); // the ignore list stays (convert_ignore.h)
return EXIT_OK;
}
if (verb == L"play") {
Expand Down Expand Up @@ -1021,12 +1126,17 @@ int RunCli(int argc, wchar_t** argv) {
if (s.rfind(L"--", 0) == 0) {
const size_t eq = s.find(L'=');
const wstring name = Lower(s.substr(2, eq == wstring::npos ? wstring::npos : eq - 2));
auto put = [&a, &name](const wstring& v) {
if (name == L"library") a.libraries.push_back(v);
else if (name == L"ignore") a.ignores.push_back(v);
else if (name == L"ignore-list") a.ignoreLists.push_back(v);
else a.opt[name] = v;
};
if (eq != wstring::npos) {
const wstring v = s.substr(eq + 1);
if (name == L"library") a.libraries.push_back(v); else a.opt[name] = v;
put(s.substr(eq + 1));
} else if ((name == L"out" || name == L"job" || name == L"result" || name == L"batch" || name == L"data" || name == L"log" || name == L"dir" || name == L"opti" ||
name == L"model" || name == L"library" || name == L"startmenu") && i + 1 < argc) {
if (name == L"library") a.libraries.push_back(argv[++i]); else a.opt[name] = argv[++i];
name == L"model" || name == L"library" || name == L"startmenu") && i + 1 < argc) { // (--ignore and --ignore-list need their "=")
put(argv[++i]);
} else a.flags.insert(name);
} else a.pos.push_back(s);
}
Expand Down
11 changes: 9 additions & 2 deletions clean/installer/src/app/ui_words.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -757,13 +757,20 @@ void RemoveDataAsked() {
if (look->anyGame) { Inform(L"Your games still use WrongGPU's data\n\nUninstall WrongGPU from each game first, then remove the data.", 1); return; }
if (!Confirm(RemoveDataText(look->modelData, look->rrData), 0, L"Remove data", L"Cancel", true)) return;
auto why = std::make_shared<wstring>();
auto kept = std::make_shared<wstring>();
auto ok = std::make_shared<bool>(false);
if (!WaitForRead(L"", L"Removing…", T_NONE, [why, ok] { *ok = RemoveSharedData(g.ctx, why.get()); })) return;
if (!WaitForRead(L"", L"Removing…", T_NONE, [why, kept, ok] { *ok = RemoveSharedData(g.ctx, why.get(), kept.get()); })) return;
if (!*ok) {
InformDetails(L"WrongGPU's data couldn't be removed.\n\nA file in it may be in use. Close what uses it, then try again. Nothing was removed.", kIconError, *why);
return;
}
ShowToast(L"WrongGPU's data is removed. You can delete this portable copy once you close it.", 1);
// the ignore list stays (convert_ignore.h): said once in the toast; kept elsewhere than in place (another program's new
// list was there, or it could not be put back): where it is, in full
if (!kept->empty() && !StartsWithI(*kept, kKeptIgnoreListText))
Inform(L"WrongGPU's data is removed, but your ignore list was not put back as it was\n\n" + *kept, 1);
else
ShowToast(kept->empty() ? L"WrongGPU's data is removed. You can delete this portable copy once you close it."
: L"WrongGPU's data is removed; kept ignore-files.txt (your/integrators' ignore list). You can delete this portable copy once you close it.", 1);
StartHealth(false); // the model and RR data are gone: the status line and Settings follow
Invalidate();
}
Expand Down
Loading
Loading