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 @@ -115,8 +115,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 convert-ignore-tests
ctest --test-dir out/launcher-tests --output-on-failure -R "^(wg-core|launcher-core|coexist-core|convert-ignore|source-size|wording)$"
cmake --build out/launcher-tests --target wg-core-tests launcher-core-tests coexist-core-tests convert-ignore-tests model-choice-tests
ctest --test-dir out/launcher-tests --output-on-failure -R "^(wg-core|launcher-core|coexist-core|convert-ignore|model-choice|source-size|wording)$"

rr-plugin:
name: "CPU: Ray Reconstruction plugin"
Expand Down
20 changes: 18 additions & 2 deletions clean/installer/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,13 @@ else()
set(PRESET_K_MAP_FILE)
set(PRESET_K_DEFINITION WRONGGPU_PRESET_K=0)
endif()
# The Model L choice in the launcher (src/wizard_policy.h): ON only for a release whose front end and runtime run Model L.
option(WRONGGPU_MODEL_L "The Model L choice in the launcher (model=L, the OptiScaler entry); OFF = no model setting" OFF)
if(WRONGGPU_MODEL_L)
set(MODEL_L_DEFINITION WRONGGPU_MODEL_L=1)
else()
set(MODEL_L_DEFINITION WRONGGPU_MODEL_L=0)
endif()
option(WRONGGPU_DIRECT_ROUTE "The direct FSR route in the installer (the wizard's advanced choice, /DIRECTFSR, a silent install without /OPTISCALER=); OFF = OptiScaler is required" ON)
if(WRONGGPU_DIRECT_ROUTE)
set(DIRECT_ROUTE_PAYLOAD_ARGS)
Expand Down Expand Up @@ -119,6 +126,8 @@ add_library(wg_core STATIC
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})
# (private: model-choice-tests compiles profile.cpp with the Model L choice on, against this library)
target_compile_definitions(wg_core PRIVATE ${MODEL_L_DEFINITION})
if(WRONGGPU_TESTING)
target_compile_definitions(wg_core PUBLIC WRONGGPU_TESTING)
endif()
Expand Down Expand Up @@ -184,7 +193,7 @@ add_executable(WrongGPU WIN32 src/app/main.cpp src/app/wizard.cpp src/app/cli.cp
add_dependencies(WrongGPU WrongGPU-Restore)
if(WRONGGPU_TESTING)
add_executable(wizard-policy-tests tests/wizard_policy_tests.cpp)
target_compile_definitions(wizard-policy-tests PRIVATE ${PRESET_K_DEFINITION} ${DIRECT_ROUTE_DEFINITION})
target_compile_definitions(wizard-policy-tests PRIVATE ${PRESET_K_DEFINITION} ${DIRECT_ROUTE_DEFINITION} ${MODEL_L_DEFINITION})
endif()
# wg_core's unit tests (strings and paths, install record, wronggpu.ini keys, the log file; no game, payload or GPU).
add_executable(wg-core-tests tests/wg_core_tests.cpp)
Expand All @@ -193,6 +202,7 @@ target_link_libraries(wg-core-tests PRIVATE wg_core)
# job files, the update reply, the game environment; no game, payload or GPU).
add_executable(launcher-core-tests tests/launcher_core_tests.cpp)
target_link_libraries(launcher-core-tests PRIVATE wg_core)
target_compile_definitions(launcher-core-tests PRIVATE ${MODEL_L_DEFINITION})
# The coexistence tests (M2): fingerprints on synthetic bytes, the proxy picker, byte-exact OptiScaler.ini edits and the
# inikey journal, the OptiScaler tab's key rules, the record's inikey and coexist lines, the log warnings.
add_executable(coexist-core-tests tests/coexist_tests.cpp)
Expand All @@ -209,14 +219,20 @@ add_test(NAME source-size COMMAND ${Python3_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_D
# 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)
# The Model L choice (profile.cpp with WRONGGPU_MODEL_L on, whatever this build's switch): the model setting, wronggpu.ini's
# model item and OptiScaler's UpscalerIndex. Its own copy of profile.cpp comes first; the rest is wg_core.
add_executable(model-choice-tests tests/model_choice_tests.cpp src/wg_core/profile.cpp)
target_compile_definitions(model-choice-tests PRIVATE WRONGGPU_MODEL_L=1)
target_link_libraries(model-choice-tests PRIVATE wg_core)
add_test(NAME launcher-core COMMAND launcher-core-tests)
add_test(NAME model-choice COMMAND model-choice-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()
target_include_directories(WrongGPU PRIVATE ${GEN})
target_compile_definitions(WrongGPU PRIVATE ${PRESET_K_DEFINITION} ${DIRECT_ROUTE_DEFINITION})
target_compile_definitions(WrongGPU PRIVATE ${PRESET_K_DEFINITION} ${DIRECT_ROUTE_DEFINITION} ${MODEL_L_DEFINITION})
target_link_libraries(WrongGPU PRIVATE wg_ui wg_core wgc_core comctl32 shell32 ole32 oleaut32 uuid advapi32 user32 gdi32 gdiplus dwmapi uxtheme d2d1 d3d11 dxgi dwrite windowscodecs uiautomationcore)
if(MSVC)
target_compile_options(WrongGPU PRIVATE /Zi)
Expand Down
21 changes: 21 additions & 0 deletions clean/installer/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -386,6 +386,27 @@ model choice and the runtime settings for Model L are not part of this step. `te
end to end: once with a build of the shipped map, and once with a build of a test map in its exact layout
(`--write-test-map`).

**The model choice** (#89; CMake `WRONGGPU_MODEL_L`, default `OFF`, on only in a release whose front end and runtime run
Model L; `src/wizard_policy.h`). With it off there is no model setting anywhere (profile, `get`, the window), and
`set <game> model=L` is refused by name (exit 10). With it on, `set <game> model=L|M` (profile key `model`, values `m`, `l`):
- **L** is accepted only while Model L's data on this PC (`model\L\model.wgcm`) passes its check against Model L's converter
data. Otherwise: "Model L can't be chosen. Model L's data on this PC is not ready (...). Convert it first: ..." (exit 5,
nothing changed). It writes wronggpu.ini's `runtime_options`: every model item out, `model=L` last (the last model item
wins). It also writes OptiScaler.ini's `UpscalerIndex`, so OptiScaler starts with Model L's entry: `[WrongGPU]` in
OptiScaler 10's slot, else `[FSR]`. The index is 1, or 2 in a build with Preset K (after Model M and Model K in the
front end's list). Both writes go through the settings apply, so the install record's hashes follow them, as for every
settings write.
- **M** is the default and changes nothing. Model L's items become `model=M` again, and an `UpscalerIndex` naming Model
L's entry goes back to 0. Anything else (the installer's `model=M`, another entry the player chose in OptiScaler's
menu) stays as it is. profile.ini has a `model` line only for L.
- A game saved on L whose Model L data is gone (removed, or not converted before an install, repair or update) is not
refused. Its files say Model M with a warning saying how to convert the data, and the profile keeps L.
- The window has no model control yet. The choice is made with `set` (or a `profile.model=` line of an elevated job).

Tested by `model-choice` (ctest: profile.cpp built with the choice on) and `tests/run_model_l_tests.py --launcher-choice`
(a build with the choice on: refusal, both files, record hashes, back to M byte for byte, repair without the data,
uninstall), and with it off by `launcher-core` and the same script's build without the choice.

**Ignore lists** (`src/wg_core/convert_ignore.*`): WrongGPU converts only the vendor DLL files that came with the player's
own games, never a copy that another program's installer placed in a game. Such an installer registers the files it placed
in a list the launcher always reads, and the player does nothing. Every search for a file to convert (the model and the Ray
Expand Down
22 changes: 20 additions & 2 deletions clean/installer/src/wg_core/launcher.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@

#include "gamerules.h"
#include "json_writer.h"
#include "model.h"
#include "optiscaler.h"
#include "payload.h"
#include "pe.h"
Expand Down Expand Up @@ -754,22 +755,34 @@ void ApplyProfile(Context& ctx, const wstring& dir, const Profile& p, std::vecto
if (!LoadRecord(RecordPath(dir), m) || m.legacy) Fail(L"WrongGPU is not installed in " + dir + L".", EXIT_NOT_INSTALLED);
InferOwners(ctx, m);
bool recordChanged = m.format < 2;
// Model L saved while its data on this PC is not ready (removed since, or an install of a game set to L before the data
// was converted): the game's files say Model M until it is; the profile keeps the player's choice
Profile q = p;
if (p.get("model") == "l") {
wstring why;
if (!ModelFileReady(ctx, L'L', &why)) {
q.v["model"] = "m";
const wstring w = ModelLNotReady(why) + L" Until then the game starts on Model M.";
notes.push_back(w);
if (warnings) warnings->push_back(w);
}
}
auto renderFile = [&](const wchar_t* name, bool opti) {
const wstring path = Join(dir, name);
string in;
const bool had = ReadAll(path, in);
if (opti && !had) return; // OptiScaler.ini: only an existing file (ours) is changed
string out; wstring why;
if (opti) {
RenderOptiIni(p, in, out, &notes);
RenderOptiIni(q, in, out, &notes);
bool wrote = false;
out = RenderGameOptiKeys(p, m.exe, out, m.inikeys, notes, &wrote);
if (wrote)
for (auto& n : kGameNotices) if (IEq(BaseName(m.exe), n.exe)) notes.push_back(n.notice);
JournalChanges(m.inikeys, name, in, out);
recordChanged = recordChanged || out != in;
}
else if (!RenderWronggpuIni(p, in, out, &why)) Fail(L"Settings not applied: " + why, EXIT_USAGE);
else if (!RenderWronggpuIni(q, in, out, &why)) Fail(L"Settings not applied: " + why, EXIT_USAGE);
if (out == in && (had || out.empty())) return; // unchanged, or nothing to write into a missing file
WriteFileAtomic(path, out.data(), out.size());
const wstring h = Sha256Bytes(out.data(), out.size());
Expand Down Expand Up @@ -1107,6 +1120,11 @@ OpResult RunOp(Context& ctx, const OpRequest& r, Ui& ui) {
res.message = L"Engine.ini setting applied; it takes effect the next time the game starts";
break;
}
// Model L chosen now (it was not the game's model before): only with its data on this PC; nothing changes otherwise
if (!r.optiOnly && r.hasProfile && r.profile.get("model") == "l" && GameProfile(r.dir).get("model") != "l") {
wstring why;
if (!ModelFileReady(ctx, L'L', &why)) Fail(L"Model L can't be chosen. " + ModelLNotReady(why) + L" Nothing was changed.", EXIT_NO_MODEL);
}
if (!r.optiOnly) ApplyProfile(ctx, r.dir, r.hasProfile ? r.profile : GameProfile(r.dir), res.notes, &res.warnings);
ApplyOptiTab(ctx, r.dir, r, res.notes);
res.message = L"Settings applied; they take effect the next time the game starts";
Expand Down
17 changes: 14 additions & 3 deletions clean/installer/src/wg_core/model.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,17 @@ bool ExistingModelValid(Context& ctx, wstring* why, wgc::ModelFileInfo* info) {
if (why) *why = FromUtf8(w);
return ok;
}
// One model's file on this PC checked against that model's own converter data, whatever model ctx has selected (it is
// selected again afterwards). False: `why` says what is missing or wrong.
bool ModelFileReady(Context& ctx, wchar_t preset, wstring* why) {
const wchar_t was = SelectedPreset(ctx);
if (was == preset) return ExistingModelValid(ctx, why);
wstring err;
if (!SelectPreset(ctx, wstring(1, preset), err)) { if (why) *why = err; return false; }
const bool ok = ExistingModelValid(ctx, why);
SelectPreset(ctx, wstring(1, was), err);
return ok;
}
// True when a valid model file may lack a group of this map (preset M, map version 4: the output-filter weights).
bool MapHasOptionalGroup(const wgc::Map& map) {
for (auto& st : map.stages) if (st.optional()) return true;
Expand Down Expand Up @@ -210,11 +221,11 @@ ModelState FindModel(Context& ctx, const GameTarget* t, const wstring& userDll,
const wstring skippedText = skipped ? L" " + std::to_wstring(skipped) + L" file(s) on an ignore list were not tried. " + IgnoredExample(ctx, m.ignored) : wstring();
if (ctx.presetL) { // Model L: said by name, with the converter's reason for the file the player chose
const wstring picked = userDll.empty() ? wstring() : FullPath(userDll);
wstring why;
wstring pickedWhy;
for (auto& r : m.rejections)
if (!picked.empty() && r.size() > picked.size() + 2 && IEq(r.substr(0, picked.size() + 2), picked + L": ")) { why = r.substr(picked.size() + 2); break; }
if (!picked.empty() && r.size() > picked.size() + 2 && IEq(r.substr(0, picked.size() + 2), picked + L": ")) { pickedWhy = r.substr(picked.size() + 2); break; }
m.error = L"Model L can't be prepared: no DLSS model file with Model L's data was found." +
(why.empty() ? wstring() : L" The file you chose (" + picked + L"): " + why) +
(pickedWhy.empty() ? wstring() : L" The file you chose (" + picked + L"): " + pickedWhy) +
L" Model L is converted from the DLSS model file (nvngx_dlss.dll) of version 310.5 or newer. The file stays where it is: "
L"only the model data is read, on this PC." + skippedText + (m.chosenSkipped.empty() ? wstring() : L" " + m.chosenSkipped);
LogLine(ctx, L"model: " + m.error);
Expand Down
7 changes: 7 additions & 0 deletions clean/installer/src/wg_core/model.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,13 @@ struct ModelCandidate { wstring path, origin; };

wstring ReadModelSource(Context& ctx);
bool ExistingModelValid(Context& ctx, wstring* why = nullptr, wgc::ModelFileInfo* info = nullptr);
// One model's file (L'M', L'L', ...) checked against that model's converter data, whatever model ctx has selected.
bool ModelFileReady(Context& ctx, wchar_t preset, wstring* why = nullptr);
// The player's lines for Model L chosen while its data on this PC is not ready (`why`: ModelFileReady's reason).
inline wstring ModelLNotReady(const wstring& why) {
return L"Model L's data on this PC is not ready (" + why + L"). Convert it first: WrongGPU.exe model convert --preset=L "
L"(optionally --model=<the nvngx_dlss.dll of one of your games, version 310.5 or newer>).";
}
bool MapHasOptionalGroup(const wgc::Map& map);
wstring FilterText(Context& ctx, bool present);
std::vector<ModelCandidate> ModelCandidates(const GameTarget* t, const wstring& userDll, const std::vector<StoreGame>& libraries);
Expand Down
Loading
Loading