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
15 changes: 13 additions & 2 deletions clean/installer/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,17 @@ set(WRONGGPU_MAP_K "${CMAKE_CURRENT_SOURCE_DIR}/../../data/preset-K.v1.map.json"
# team's synthetic preset-F map, so its tests never need a real RR file.
set(WRONGGPU_RR_DIR "" CACHE PATH "Folder with the RR plugin (plugins/WrongGPU-RR.asi) and the RR runtime (wronggpu_rr_runtime.dll)")
set(WRONGGPU_MAP_F "" CACHE FILEPATH "RR converter map (preset F); empty: data/preset-F.v1.map.json (test builds: the synthetic rr-f-synth/synth-r0 map)")
# Model L (#89): its converter map, embedded for "model convert --preset=L" (the model's folder: <model>\L). Default: the
# shipped map (data/preset-L.v1.map.json, the spec side's revision v1.1). Tests of the conversion itself give a map of
# its exact layout with their own digests (tests/run_model_l_tests.py --write-test-map); empty: a build without Model L.
set(WRONGGPU_MAP_L "${CMAKE_CURRENT_SOURCE_DIR}/../../data/preset-L.v1.map.json" CACHE FILEPATH "Model L converter map (preset L); empty: none")
if(WRONGGPU_MAP_L AND EXISTS "${WRONGGPU_MAP_L}")
set(MAP_L_ARGS --map-l ${WRONGGPU_MAP_L})
set(MAP_L_FILE ${WRONGGPU_MAP_L})
else()
set(MAP_L_ARGS)
set(MAP_L_FILE)
endif()
option(WRONGGPU_PRESET_K "Preset K in the installer (second model choice, /PRESET=K, its converter map); OFF = Model M only" ON)
if(WRONGGPU_PRESET_K)
set(PRESET_K_MAP_ARGS --map-k ${WRONGGPU_MAP_K})
Expand Down Expand Up @@ -143,8 +154,8 @@ add_custom_command(
COMMAND ${Python3_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/tools/make_payload.py
--payload ${WRONGGPU_PAYLOAD_DIR} --map ${WRONGGPU_MAP} ${PRESET_K_MAP_ARGS} --version ${WRONGGPU_VERSION}
--build-id=${WRONGGPU_BUILD_ID} --payload-name=${WRONGGPU_PAYLOAD_NAME}
${DIRECT_ROUTE_PAYLOAD_ARGS} ${RR_PAYLOAD_ARGS} ${MAP_F_ARGS} ${MANIFEST_ARGS} --out ${GEN}
DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/tools/make_payload.py ${MANIFEST} ${WRONGGPU_MAP} ${PRESET_K_MAP_FILE} ${MAP_F_FILE} ${WRONGGPU_PAYLOAD_FILES} ${WRONGGPU_RR_FILES}
${DIRECT_ROUTE_PAYLOAD_ARGS} ${RR_PAYLOAD_ARGS} ${MAP_F_ARGS} ${MAP_L_ARGS} ${MANIFEST_ARGS} --out ${GEN}
DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/tools/make_payload.py ${MANIFEST} ${WRONGGPU_MAP} ${PRESET_K_MAP_FILE} ${MAP_F_FILE} ${MAP_L_FILE} ${WRONGGPU_PAYLOAD_FILES} ${WRONGGPU_RR_FILES}
COMMENT "Embedding the payload and the converter map")

# WrongGPU-Restore.exe: the per-game restorer (uninstall.exe in each game's wronggpu-setup folder): wg_core without the
Expand Down
16 changes: 15 additions & 1 deletion clean/installer/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -318,7 +318,8 @@ ctest `source-size`.
the window itself never runs elevated.
- **Command line** (a verb as the first argument; `src/app/cli.cpp`): `scan`, `status [game]`, `install`, `repair`,
`update`, `uninstall`, `rollback`, `adopt [game | --all]`, `set <game> key=value ...`, `set --global key=value`,
`get <game> [key]`, `get --global`, `collect <game> [--zip=<file>]`, `hipcheck`, `model status|convert`,
`get <game> [key]`, `get --global`, `collect <game> [--zip=<file>]`, `hipcheck`, `model status|convert [--preset=M|L]`
("Model L by name" below),
`rr-data status|convert [--dll=<RR model file>]` (both converts also take `--ignore=`, `--ignore-list=` and `--library=`:
"Ignore lists" below),
`self-install [--dir=] [--startmenu=<folder>|-]`, `self-uninstall [--keep-games]`, `play <game>`, `update-check`,
Expand Down Expand Up @@ -372,6 +373,19 @@ keep the games, which then get their own entries back); its data (`launcher.ini`
`%LOCALAPPDATA%\WrongGPU\model` in both modes (the runtime reads it there). `managed-games.txt` in that folder lists
the managed games, so an uninstaller keeps the model while another game uses it.

**Model L by name** (#89; `src/wg_core/context.h` `SelectPreset`): `model status --preset=L` and
`model convert --preset=L [--model=<nvngx_dlss.dll>]` use Model L's converter map and model folder. The launcher embeds the
map (CMake `WRONGGPU_MAP_L`, default `data/preset-L.v1.map.json`, the spec side's revision v1.1; empty: a build without
Model L) and loads it as preset L, so a map that names another preset is "converter data damaged". The model goes to
`%LOCALAPPDATA%\WrongGPU\model\L\model.wgcm` with its own `model-source.txt`, the folder where the runtime looks for
`model=L`. Model M's files are never touched by it. A file without Model L's data is refused: "Model L can't be prepared:
no DLSS model file with Model L's data was found.", followed by the converter's reason for the file the player chose
(exit 5). An unknown name, or Model L in a build without its map, is a bad command line (exit 10). The JSON result names
the model (`preset`) and the converter map in use (`model.map_sha256`). Without `--preset` nothing changes. The window's
model choice and the runtime settings for Model L are not part of this step. `tests/run_model_l_tests.py` checks it
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`).

**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
15 changes: 13 additions & 2 deletions clean/installer/src/app/cli.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@
// fingerprint <file> ... what a DLL is (version resource, exports, text; never its name)
// collect <game> [--out=<zip>] logs into a zip
// hipcheck the HIP runtime check alone
// model status | model convert [--model=<dll>]
// model status | model convert [--model=<dll>] [--preset=M|L]: the model by name (its converter map and folder; K too in
// a build with Preset K)
// 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
Expand Down Expand Up @@ -886,6 +887,13 @@ 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];
// --preset=<name>: the model by its name (M, L; K in a build with Preset K). Its converter map, model folder and
// messages; without it, the launcher's model as before.
if (a.opt.count(L"preset") || a.has(L"preset")) { // --preset=<name>; a bare --preset (no name) is refused
wstring why;
if (!SelectPreset(g.ctx, a.get(L"preset"), why)) { o.j.S("error", why); Print(why); return EXIT_USAGE; }
}
o.j.S("preset", wstring(1, SelectedPreset(g.ctx)));
if (sub == L"convert") {
if (!ConvertIgnoreArgs(a, o)) return o.code;
OpLogBegin();
Expand All @@ -911,7 +919,10 @@ int Verb(const wstring& verb, const Args& a, Output& o) {
wstring why;
wgc::ModelFileInfo info{};
const bool valid = ExistingModelValid(g.ctx, &why, &info);
o.j.Key("model").Obj().S("file", ModelFile(g.ctx)).B("valid", valid).S("source", ReadModelSource(g.ctx)).S("why", why).End();
// map_sha256: the converter map of the selected model (embedded; the file it was built from has the same SHA-256)
const wstring mapSha = g.ctx.map.map ? FromUtf8(wgc::to_hex(g.ctx.map.map->file_sha256)) : wstring();
o.j.Key("model").Obj().S("file", ModelFile(g.ctx)).B("valid", valid).S("source", ReadModelSource(g.ctx)).S("why", why)
.S("map_sha256", mapSha).S("map_error", g.ctx.mapError).End();
Print(wstring(L"model data: ") + (valid ? L"ready (" + ModelFile(g.ctx) + L")" : L"not ready" + (why.empty() ? wstring() : L" (" + why + L")")));
return valid || sub == L"status" ? EXIT_OK : EXIT_NO_MODEL;
}
Expand Down
2 changes: 1 addition & 1 deletion clean/installer/src/app/payload_embed.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,6 @@ const wg::EmbeddedData& EmbeddedPayload() {
#endif
kLogoResourceId, SETUP_VERSION, SETUP_BUILD_ID, SETUP_PAYLOAD_NAME,
kRrPayload, kRrPayloadCount, kFMapResourceId, kFMapSha256, // Ray Reconstruction (rr.h)
kRrInterfaceFile};
kRrInterfaceFile, kLMapResourceId, kLMapSha256}; // Model L's converter map
return data;
}
42 changes: 37 additions & 5 deletions clean/installer/src/wg_core/context.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
// WrongGPU launcher core: the Context, the log file, the model data folder and the embedded converter map. Written for
// this project.
#include "context.h"
#include <cwctype>
#include "payload.h"

namespace wg {
Expand Down Expand Up @@ -47,12 +48,39 @@ wstring ModelBaseDir() { return Join(AppDataPath(), L"model"); }
#if WRONGGPU_PRESET_K
int MapResourceId(Context& ctx, bool k) { return k ? ctx.data->kMapId : ctx.data->mapId; }
const wchar_t* MapSha256(Context& ctx, bool k) { return k ? ctx.data->kMapSha256 : ctx.data->mapSha256; }
wstring ModelDir(Context& ctx) { return ctx.presetK ? Join(ModelBaseDir(), L"K") : ModelBaseDir(); }
wstring ModelDir(Context& ctx) { return ctx.presetL ? Join(ModelBaseDir(), L"L") : ctx.presetK ? Join(ModelBaseDir(), L"K") : ModelBaseDir(); }
#else
int MapResourceId(Context& ctx, bool) { return ctx.data->mapId; }
const wchar_t* MapSha256(Context& ctx, bool) { return ctx.data->mapSha256; }
wstring ModelDir(Context&) { return ModelBaseDir(); }
wstring ModelDir(Context& ctx) { return ctx.presetL ? Join(ModelBaseDir(), L"L") : ModelBaseDir(); }
#endif
wchar_t SelectedPreset(const Context& ctx) { return ctx.presetL ? L'L' : ctx.presetK ? L'K' : L'M'; }
bool SelectPreset(Context& ctx, const wstring& name, wstring& error) {
const wchar_t c = name.size() == 1 ? static_cast<wchar_t>(towupper(name[0])) : L'\0';
#if WRONGGPU_PRESET_K
const wstring known = L"M, L or K";
const bool isK = c == L'K';
#else
const wstring known = L"M or L";
const bool isK = false;
#endif
if (c != L'M' && c != L'L' && !isK) {
error = L"Unknown model \"" + name + L"\" (the models of this build: " + known + L").";
return false;
}
if (c == L'L' && (!ctx.data || !ctx.data->lMapId)) {
error = L"This build of WrongGPU has no converter data for Model L.";
return false;
}
if (c == SelectedPreset(ctx)) return true;
ctx.presetL = c == L'L';
#if WRONGGPU_PRESET_K
ctx.presetK = c == L'K';
#endif
ctx.map = wgc::LoadedMap(); // the other model's map is loaded on first use (LoadEmbeddedMap)
ctx.mapError.clear();
return true;
}
wstring ModelFile(Context& ctx) { return Join(ModelDir(ctx), FromUtf8(wgc::kModelFileName)); }
wstring ModelSourceFile(Context& ctx) { return Join(ModelDir(ctx), L"model-source.txt"); }

Expand All @@ -62,11 +90,15 @@ bool LoadEmbeddedMap(Context& ctx) {
static std::mutex loading;
std::lock_guard<std::mutex> lock(loading);
if (ctx.map.map) return true;
// Model L: its own map, loaded as preset L (the converter refuses a map that names another preset: "converter data
// damaged"). Models M and K: as before (the map's own preset).
const bool l = ctx.presetL;
if (l && !ctx.data->lMapId) { ctx.mapError = L"this build has no converter data for Model L"; return false; }
DWORD sz = 0;
const void* d = ResourceData(MapResourceId(ctx, ctx.presetK), sz);
if (!d || Sha256Bytes(d, sz) != MapSha256(ctx, ctx.presetK)) { ctx.mapError = L"the converter data is missing or damaged"; return false; }
const void* d = ResourceData(l ? ctx.data->lMapId : MapResourceId(ctx, ctx.presetK), sz);
if (!d || Sha256Bytes(d, sz) != (l ? ctx.data->lMapSha256 : MapSha256(ctx, ctx.presetK))) { ctx.mapError = L"the converter data is missing or damaged"; return false; }
const wgc::Result r = wgc::load_map_bytes(string(static_cast<const char*>(d), sz), ctx.map,
[&ctx](const string& s) { LogLine(ctx, L"converter: " + FromUtf8(s)); });
[&ctx](const string& s) { LogLine(ctx, L"converter: " + FromUtf8(s)); }, l ? "L" : "");
if (r.code != wgc::kOk) { ctx.mapError = FromUtf8(r.message); return false; }
return true;
}
Expand Down
13 changes: 13 additions & 0 deletions clean/installer/src/wg_core/context.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,10 @@ struct EmbeddedData {
// the file name of the game interface the RR plugin hooks (the RR folder's interposer.json; empty: none given): which
// build of the plugin a game gets follows its version (rr.h, RrPluginFor)
const wchar_t* rrInterface = L"";
// Model L (#89): its converter map (data/preset-L.v1.map.json, revision v1.1; CMake WRONGGPU_MAP_L). lMapId 0: not in
// this build.
int lMapId = 0;
const wchar_t* lMapSha256 = L"";
const PayloadFile* begin() const { return files; }
const PayloadFile* end() const { return files + count; }
};
Expand Down Expand Up @@ -70,6 +74,9 @@ struct Context {
#else
static constexpr bool presetK = false; // CMake WRONGGPU_PRESET_K=OFF: Model M only
#endif
// Model L (#89): the converter map and model folder (<model>\L, the runtime's folder for model=L) are Model L's.
// Chosen by name (SelectPreset); it takes precedence over presetK.
bool presetL = false;
// The converter map of the selected preset, loaded and validated once (spec 08 section 5; LoadEmbeddedMap).
wgc::LoadedMap map;
wstring mapError;
Expand Down Expand Up @@ -110,6 +117,12 @@ wstring DefaultLogPath();
wstring ModelBaseDir();
int MapResourceId(Context& ctx, bool k);
const wchar_t* MapSha256(Context& ctx, bool k);
// The selected model's name: L'L' (presetL), L'K' (presetK) or L'M'.
wchar_t SelectedPreset(const Context& ctx);
// Selects a model by its name (M, L, and K in a build with Preset K; either case) for the converter map, the model folder
// and the conversion. A different model than before drops the loaded map. False: `error` says why (an unknown name, or a
// model whose converter data this build does not have); nothing changes.
bool SelectPreset(Context& ctx, const wstring& name, wstring& error);
wstring ModelDir(Context& ctx);
wstring ModelFile(Context& ctx);
wstring ModelSourceFile(Context& ctx);
Expand Down
13 changes: 13 additions & 0 deletions clean/installer/src/wg_core/model.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,19 @@ ModelState FindModel(Context& ctx, const GameTarget* t, const wstring& userDll,
LogLine(ctx, L"model: every DLSS model file found is on an ignore list; nothing converted");
return m;
}
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;
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; }
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) +
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);
return m;
}
m.error = L"No DLSS model file that WrongGPU can use was found. WrongGPU needs the DLSS model file (nvngx_dlss.dll) of "
L"version 310.5 or newer, which comes with many recent games and apps. Install or update such a game, or choose its "
L"nvngx_dlss.dll yourself. The file stays where it is: only the model data is read, on this PC." +
Expand Down
23 changes: 23 additions & 0 deletions clean/installer/tests/launcher_core_tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,29 @@ int main() {
require(!HasConverterData(rc, false) && !HasConverterData(rc, true) && HasConverterData(lc, false), "the converter data: uninstall.exe none, WrongGPU.exe its map");
RemoveTree(cl);
}
// ---- Model L (#89): the model by name (model convert/status --preset=); its converter map and model folder --------
{
static const EmbeddedData withL{nullptr, 0, 900, L"00", 0, L"", 0, L"0.7.0", L"0.7.0", L"0.7.0", nullptr, 0, 0, L"", L"", 903, L"00"};
static const EmbeddedData noL{nullptr, 0, 900, L"00", 0, L"", 0, L"0.7.0"};
Context lc, nc;
lc.data = &withL;
nc.data = &noL;
wstring err;
require(SelectedPreset(lc) == L'M' && ModelDir(lc) == ModelBaseDir(), "Model M by default: the model folder itself");
lc.mapError = L"an earlier load";
require(SelectPreset(lc, L"l", err) && lc.presetL && SelectedPreset(lc) == L'L' && ModelDir(lc) == Join(ModelBaseDir(), L"L") &&
ModelFile(lc) == Join(Join(ModelBaseDir(), L"L"), L"model.wgcm") && lc.mapError.empty(),
"--preset=l: Model L, its folder <model>\\L (the runtime's folder for model=L); the earlier map state is dropped");
require(SelectPreset(lc, L"L", err) && lc.presetL, "the same model again: nothing changes");
require(SelectPreset(lc, L"M", err) && !lc.presetL && SelectedPreset(lc) == L'M' && ModelDir(lc) == ModelBaseDir(), "back to Model M: the model folder itself");
require(!SelectPreset(lc, L"Q", err) && err.rfind(L"Unknown model \"Q\"", 0) == 0 && SelectedPreset(lc) == L'M', "an unknown name is refused; nothing changes");
require(!SelectPreset(lc, L"ML", err) && !SelectPreset(lc, L"", err) && SelectedPreset(lc) == L'M', "a model name is one letter");
require(!SelectPreset(nc, L"L", err) && err == L"This build of WrongGPU has no converter data for Model L." && !nc.presetL && ModelDir(nc) == ModelBaseDir(),
"a build without Model L's map refuses L by name; nothing changes");
#if !WRONGGPU_PRESET_K
require(!SelectPreset(lc, L"K", err) && err.find(L"M or L") != wstring::npos, "K is not a model of a build without Preset K");
#endif
}
// ---- validation -----------------------------------------------------------------------------------------
string n; wstring why;
const SettingDef* exec = FindSetting("executor");
Expand Down
Loading
Loading