Skip to content

OptiScaler plugin path honours the launcher's model choice (Model L, K) - #213

Merged
phantoslayer21 merged 25 commits into
mainfrom
fix/asi-honours-launcher-model
Nov 16, 2026
Merged

phantoslayer21 merged 25 commits into
mainfrom
fix/asi-honours-launcher-model

Conversation

@phantoslayer21

@phantoslayer21 phantoslayer21 commented Nov 14, 2026 •

Copy link
Copy Markdown
Owner

The bug

On a hosted OptiScaler install (OptiScaler before 10, FidelityFX route) with WrongGPU's menu plugin WrongGPU.asi hooked, the launcher's Model L choice was ignored:

  • The launcher wrote model=L into wronggpu.ini and set OptiScaler's [FSR] UpscalerIndex to Model L's entry.
  • The plugin's saved state could only be M, K or AMD, and defaulted to M.
  • With the plugin hooked, the front end took the plugin's model unconditionally.

So the game ran Model M (or a remembered Model K), with no refusal and no warning.

The design: one model choice record per game

model-choice.ini lives in the game's WrongGPU state folder (wronggpu-setup, beside #224's settings.ini):

model=<M|K|L>
seq=<1..18446744073709551615>
source=<launcher|ffx|plugin>

It decides which WrongGPU model runs, on every route. The highest seq is the most recent choice.

It is written only for a choice the player made:

  • The launcher, when the player applies a model: the launcher window's Apply (with a model shown, also unchanged) or set <game> model=. It is written every time, also for the same model again, so an explicit launcher choice wins over a newer choice made in the game. A change of another setting never touches it. A game without a record gets one from the launcher's profile. If the launcher's own last choice can't run (the model's data isn't ready), it records Model M until the data is ready.
  • OptiScaler's list: the WrongGPU edition of OptiScaler calls WrongGpuHostSelectedV1(versionId) in the front-end DLL when the player selects an entry (clean/fsr/include/wronggpu_host_event.h; the fork change is Version box: tell the upscaler's DLL which version the player selected OptiScaler#2). The result is:
    • 1: the selected model is not the one the active upscaler runs, so the host recreates it, and the selected model runs. This covers a re-selection of the entry already shown, and a record changed underneath (a launcher Apply while the game is open);
    • 0: the selected model already runs;
    • negative: not saved (no state folder, the lock not free in time, the write failed), or refused (the end of seq, or a record that is not a valid record, which is never replaced). Nothing changes, and the host says "not saved, try again".
  • The menu plugin, when the player clicks one of its model entries.

Never a choice:

  • The index OptiScaler stores, on any route (the hooked route, the custom slot, the direct route), with or without a state folder.
  • wronggpu.ini's model item. That is the install's default: no WrongGPU program writes it after the install, and it only seeds the record of a game that has none.

One lock. Every read and write holds the game's state lock from clean/wgshared/include/wg_state.h (#226): a named mutex taken from the game folder's volume and file identity, so every path alias of one folder is one lock. #213 has no lock code of its own.

  • The launcher's apply holds that lock across Launcher: the RR plugin's own rr_mode save keeps WrongGPU\wronggpu.ini WrongGPU's #224's settings.ini, the record and OptiScaler.ini's UpscalerIndex, in that order (settings are validated first, so invalid settings change nothing). It does not rewrite wronggpu.ini. The index is set to the model's entry whatever it was (AMD's version, another value, or a missing key, which is created). It is for display only, so a crash between the record and the index is harmless.
  • When OptiScaler.ini is missing or can't be read, the record is still written and the launcher says "OptiScaler's list couldn't be updated; the model choice is saved".
  • The upgrade migration reads wronggpu.ini's model item (the file as it is on disk) while it holds the lock. A launcher apply is therefore wholly before or wholly after it.

Game in use. The game side registers nothing. Whether a game is using WrongGPU is decided by the launcher's own uninstall, repair and update checks (#224/#226).

Nothing is queued. A plugin click or a host selection that can't be saved in time changes nothing: the plugin's entry reads "not saved, try again" and the running model stays. Writes are retried up to 3 times within the call only.

When the record can't be used at a create (no state folder, the folder can't be checked, unreadable, corrupt, or the lock not free in time), the order is:

  1. the last choice this session read or wrote;
  2. else wronggpu.ini's model item;
  3. else Model M.

The host's stored entry is never used. A create never writes over a corrupt or unreadable record, and neither does a choice: it is refused with one log line, the file keeps its bytes (the player's to fix or delete), and the model that runs stays.

Writes change the record in place through #224's state-file updater (wgstate::UpdateStateFile, the settings.ini updater made usable for any file of the state folder): the file is held from the read to the replace, only the three key lines change, and the player's comments, other lines and line ends stay. The stamp for model-choice.ini and the install's id is put back only when the file was WrongGPU's and unedited (or new). A record the player edited or made stays unstamped, the player's, and the launcher's uninstall keeps it. Underneath it is the same atomic replace: a temporary file in the same folder, flushed, then MoveFileExW(REPLACE_EXISTING | WRITE_THROUGH), every step checked.

Parsing is strict: exactly the three keys, seq a checked uint64. At the end of seq a choice is refused and logged as an error.

Entry order. One definition, clean/wgshared/include/wg_model_entries.h, sets the order: Model M, then K, then L, as each build lists them.

  • The launcher writes UpscalerIndex from it.
  • TestModelEntryOrder fails if the front end's version list disagrees with it.
  • The fork holds a byte-identical copy (OptiScaler/include/wronggpu/wg_model_entries.h) with static asserts and a test, and logs a list in another order. tools/ci/check_vendored_model_entries.py (in the "Licence and line endings" job) fails when this header no longer has its pinned SHA-256 or the fork's copy at the pinned fork commit differs from it.

Plugin. The plugin learns Model L (WG_MODEL_L), and the front end tells it which model runs, so the menu marks that entry.

sr_model never chooses the model on this route. The front end still writes sr_model (the overlay's value, persisted to wronggpu.ini) at each create, as before; it always mirrors the model that runs, and the record route never reads it. When the record names a model this build lacks, a create runs Model M, never the persisted sr_model (before this, a create no entry named fell back to sr_model there, which an earlier session could have left on another model).

In-game callables. No lambda in the front end or the plugin captures an object whose copy can throw: wronggpu.ini's reader, the model places, AMD's DLL and the comparison DLL are named classes (dllmain.cpp, win_util.h). The other in-game modules' cases are listed in #247.

wronggpu-asi.ini (the menu plugin's file): when an explicit model choice brings OptiScaler's list back from AMD to WrongGPU, only its selection line changes; every other byte stays. A file whose bytes were WrongGPU's (the install record's hash) stays WrongGPU's under its new hash; the player's stays the player's.

A partial apply (a later write fails after earlier ones were made) says exactly what was applied and what was not, for example "Settings applied in part. Applied: the upscaler settings (...); the model choice (Model L). Not applied: the Ray Reconstruction settings (...)", and the install record keeps the hashes of the files WrongGPU changed. There is no rollback; each piece is whole on its own.

Current with main (#224, #225): the launcher's settings go to settings.ini through #224's state keys, inside the apply's lock hold.

Tested

All test processes ran with TMP, APPDATA, LOCALAPPDATA and ProgramData redirected to scratch folders.

  • Record (fsr_model_choice_record_unit, real files and real processes): 144 checks.

    • An install with an id: every write carries a valid stamp for model-choice.ini and that id (not for another id or name), the record still parses and the next choice keeps it stamped; without an id, no stamp.
    • The player's files: a stamped record the player added a comment to keeps the comment and is written unstamped from then on; a player-made record (LF line ends, comments, another key order) keeps every other byte and stays unstamped; a corrupt record (overflow, a key missing, unknown key, a NUL, oversized) is refused and keeps its bytes.
    • Strict format; each source winning in turn; corrupt and overflowing records; the end of seq.
    • The upgrade migration, and failures that change nothing (no queue).
    • Four writer processes plus a reader: final seq 600, never back.
    • An abandoned lock is taken over.
    • Migration under the lock against an apply in another process, both when that process dies between wronggpu.ini and the record and when it finishes.
    • A directory junction and the \\?\ form of one folder are one lock across processes.
  • Front end (TestAsiChoiceRecord, real files):

    • the upgrade from wronggpu.ini as it is on disk;
    • the stored index is never a choice;
    • an event returns 1 and that model runs;
    • running Model K, the record changed to M underneath (a launcher apply), the player selects the M entry already shown: 1, the upscaler is recreated and Model M runs;
    • a re-selection of the same entry after a plugin choice returns 1, and once more returns 0;
    • no state folder: a create runs wronggpu.ini's item (or M), never the entry; an event returns "not saved";
    • each source in turn; AMD; the custom slot; the direct route;
    • lock timeout → "not saved", nothing changes, a create meanwhile runs the session's choice;
    • a failed write → "not saved";
    • unreadable and corrupt records use wronggpu.ini's item, never the entry; a selection over a corrupt record is refused (-2), the file keeps its bytes, the model that runs stays; once the player fixes it, the next selection is saved;
    • the end of seq;
    • TestModelEntryOrder;
    • the record names a model this build lacks while sr_model names the build's other model: Model M runs (builds with exactly one of K and L).
  • Plugin menu: a click whose save fails changes nothing and says "not saved, try again" (or "full" when refused); the AMD entry never writes. WithSelection changes only the selection line (comments, a later selection line, line ends and a last line without one stay).

  • Shared state (wgshared_state): passes.

  • Suites:

    Shape Result
    Front end, CI shape 20/20
    Front end, 0.6.5 shape 19/19
    Shared 5/5
    Launcher CPU 9/9
  • Launcher end-to-end (WRONGGPU_TESTING builds, mock payload):

    • Model L suite, 29/29:
      • set model=L leaves wronggpu.ini byte for byte as installed; the record and index follow;
      • an explicit set model=L with an unchanged profile wins over a newer plugin choice;
      • the launcher window's Apply (GuiApplyRequest, the request its button makes, run by set ... --gui-apply) with the unchanged model wins over a newer choice made in OptiScaler's list;
      • a launcher change of another setting leaves the plugin's choice alone;
      • the index is set from AMD's value and from a missing key;
      • OptiScaler.ini missing: the record is written, the message names it;
      • the player's wronggpu-asi.ini on AMD (comments, selection=amd): an explicit model choice changes only its selection line, every other byte and its ownership in the install record stay;
      • an apply stopped between the record and OptiScaler.ini (test hook) leaves a harmless stale index;
      • the upgrade migration in a second process against the real launcher apply holding the lock: the launcher records L (seq 1), the migration waits and writes nothing;
      • a repair without the model's data records Model M;
      • uninstall leaves the game folder byte for byte as before.
    • Model K suite, 21/21.
    • Main suite, non-RR groups (with Launcher: the RR plugin's own rr_mode save keeps WrongGPU\wronggpu.ini WrongGPU's #224's state group): 257 passed, 8 failed. Unchanged main fails the same 8 in the same run on this machine: the local-build size check (Launcher: coexist with other OptiScaler setups #47), three edition_download checks and four keyboard/focus checks of the launcher window.
    • Main suite, RR group: a partial apply (the RR write failure injected after the upscaler settings were saved): refused, the message lists the upscaler settings as applied and the RR settings as not applied, the RR settings unchanged; the same apply without the fault succeeds. The group's other results match unchanged main on this machine (it stops at the RR data preparation, which needs files this machine doesn't have).
  • Vendored copy check: passes; a changed byte in the header and a fork commit without the copy both fail it.

  • Negative controls. Each mutation was applied, the tests run, and the source restored:

    • the event comparing with the previous record instead of the running model: 1 front-end failure (the running-model case);
    • no state folder: the host's entry choosing the model: 24 front-end failures;
    • an event without a state folder reporting "recorded": 1 front-end failure;
    • the migration taking no lock, against the real launcher apply: 5 record failures and the end-to-end race check;
    • the launcher window's Apply not an explicit choice: the end-to-end Apply check;
    • a corrupt record treated as missing (a choice replaces it): the front end's corrupt-record case fails;
    • the launcher rewriting wronggpu-asi.ini whole: the Model L player's-file check fails;
    • a partial apply saying "Settings not applied": the suite's partial-apply check fails.

Not tested yet

  • The fork-to-front-end event, in game, and the game run (the launcher picks L → l_* kernels, the same for K, a selection in OptiScaler's list switches the model). Both follow after merge, on the candidate build.

Not guaranteed

  • On OptiScaler builds without the fork change (the player's own OptiScaler before 10), a selection in OptiScaler's list is not a model choice; the launcher and the plugin's menu entries are.
  • WrongGpuHostSelectedV1 is an in-process export with no caller check. Code in the game's process could call it, just as it could write the record itself.
  • A missing OptiScaler.ini is not created by the launcher.

With WrongGPU.asi hooked in OptiScaler's menu, the plugin's saved entry
could only be M, K or AMD, defaulted to M, and always decided the model:
a launcher choice of Model L (model=L in wronggpu.ini, L's UpscalerIndex)
ran Model M (or a remembered K) with no warning.

- The plugin learns Model L (its menu entry, wronggpu-asi.ini
  selection=wronggpu-l) and records when the player clicked
  (chosen=<seconds since 1970 UTC>). New exports: WrongGpuAsiQueryChoiceV1
  (model, explicit or default, time) and WrongGpuAsiShowModelV1 (the front
  end tells the menu which model runs). The old query reports L as M.
- The launcher writes model_chosen=<seconds> into wronggpu.ini whenever
  it changes the model item of runtime_options (any model letter).
- The front end decides with model_precedence.h: the launcher's choice
  wins over the plugin's default entry and the reverse; two explicit
  different choices: the more recent wins (equal or missing times: the
  plugin's), with one "model choice conflict:" line naming both.
- Model L without its file keeps the existing refusal (AMD's FSR
  upscales); a model the front end lacks runs as Model M, with a note.

Tests: front end (precedence cases, L file missing, negative control),
plugin thunk/selection file/exports, launcher model_chosen.

Signed-off-by: phantoslayer21 <156617979+phantoslayer21@users.noreply.github.com>
…her-model

Signed-off-by: phantoslayer21 <156617979+phantoslayer21@users.noreply.github.com>
@phantoslayer21
phantoslayer21 marked this pull request as ready for review November 14, 2026 23:19
@phantoslayer21
phantoslayer21 marked this pull request as draft November 14, 2026 23:19
…her-model

Signed-off-by: phantoslayer21 <156617979+phantoslayer21@users.noreply.github.com>
The launcher now stamps every model change (model_chosen, profile.h), so
the K-then-M rendering compares the file without that line and checks the
line is there.

Signed-off-by: phantoslayer21 <156617979+phantoslayer21@users.noreply.github.com>
@phantoslayer21
phantoslayer21 marked this pull request as ready for review November 14, 2026 23:31
…FX box)

Review of #213 (three items):

1. An explicit launcher apply of a model restamps it as the newest choice,
   also the same model again and Model M: `set <game> model=<m>` passes
   modelChosen to ApplyProfile and RenderWronggpuIni, which writes
   model_chosen even when the model item is unchanged (Model M then
   becomes the last model item). Another setting applied is still not a
   model choice.
2. Stamps are Windows FILETIME units (100 ns since 1601 UTC) on all
   sides (launcher, plugin, front end). An exact tie goes to the launcher
   (then OptiScaler's FFX box, then the plugin menu); an untimed explicit
   choice ranks as the oldest and the log says so. Clock rollback is
   documented as a known limit.
3. With the plugin hooked, the WrongGPU entry picked in OptiScaler's FFX
   upscaler box is a third choice: the front end saves the entry it saw
   (wronggpu-ffx-choice.ini next to wronggpu.ini), stamps the time when it
   changes, and DecideModel weighs launcher, FFX box and plugin menu by
   the same most-recent rule, with one conflict line naming each. An AMD
   version in the box is still not a model choice. No OptiScaler change.

Tests: the three-source table in every order, ties, untimed sources,
the re-apply sequence for L, K and M (front end and launcher), the FFX
box through hosted creates across two sessions; the Model K / Model L
launcher end-to-end tests expect the new model_chosen line. Negative
controls: each fix reverted makes its tests fail.

Signed-off-by: phantoslayer21 <156617979+phantoslayer21@users.noreply.github.com>
Review of #213 (second round): the three-clock design lost or fabricated
choices in OptiScaler's FFX box, could be locked out by a clock set back,
wrote its files in place and parsed timestamps without overflow checks.
Replaced as the architect decided:

- One record per game, wronggpu-setup\model-choice.ini next to
  wronggpu.ini (the launcher's state folder; an uninstall removes it by
  name, a reinstall keeps it with the game's settings): model, seq,
  source (launcher|ffx|plugin) and ffx (the WrongGPU entry the writer knew
  OptiScaler's list to name). The highest seq is the most recent choice;
  no clock anywhere.
- Writers: the launcher when it applies a model (explicit `set ...
  model=`, or a changed model item; it sets OptiScaler's entry with it
  and writes ffx = that entry), the front end when OptiScaler's FFX box
  names an entry the record does not know (also at the first create
  without a record), the menu plugin on a click on one of its model
  entries (keeping the record's ffx). The launcher's own index rewrite is
  never taken for a choice in the game.
- Atomic writes: a temporary file in the same folder, flushed, renamed
  over the record through its handle with POSIX semantics (MoveFileExW
  REPLACE_EXISTING | WRITE_THROUGH as the fallback), checked, retried;
  a reader never sees part of a record, a stale temporary file is never
  read.
- Strict parsing: exactly the four keys once, seq a checked uint64
  (overflow refused), model in M/K/L; anything else is corrupt, logged and
  treated as no record. An unreadable record is never written over.
- Without a record: the launcher's K/L item, else the plugin's saved
  entry, else Model M. The plugin's AMD entry still means AMD; a launcher
  model choice selects WrongGPU there again.
- Removed: model_chosen, chosen= stamps, wronggpu-ffx-choice.ini,
  WrongGpuAsiQueryChoiceV1; the plugin gets WrongGpuAsiSetChoiceRecordV1.

Tests on real files: strict format and overflow, seq order, the FFX rule,
each source winning in turn, the launcher's index rewrite, the first
create, a stale temporary file, corrupt and locked records, a reader
racing 400 replacements; Model K / L launcher end-to-end tests check the
record. Negative controls for the FFX rule, the overflow check, the
unreadable rule and the atomic write.

Signed-off-by: phantoslayer21 <156617979+phantoslayer21@users.noreply.github.com>
…her-model

Signed-off-by: phantoslayer21 <156617979+phantoslayer21@users.noreply.github.com>
Review of #213 (third round): concurrent writers could lose a choice or
move seq back, an upgrade could take its model from OptiScaler's stored
index, the launcher's index and record were separate steps, re-selecting
the same entry in OptiScaler's list was invisible, the index was not
always set, and the preferred rename ignored its flush result. Reworked
as the architect decided:

- The record has three keys: model, seq, source. The ffx key is gone; a
  record with it reads as corrupt.
- A choice made in OptiScaler's list is an event: the WrongGPU edition of
  OptiScaler calls WrongGpuHostSelectedV1(versionId) in the front-end DLL
  (include/wronggpu_host_event.h) before it recreates the upscaler. The
  index OptiScaler passes at a create is never taken for a choice, on the
  hooked route and on the custom slot; the slot's ini poll leaves model
  entries alone while there is a record.
- Every read-modify-write runs under one named mutex per game
  (Local\WrongGPU-choice-<hash of the record's path>), taken by the
  launcher, the front end and the menu plugin. An abandoned lock is taken
  over.
- Writes: a temporary file, written and flushed (both checked), then
  MoveFileExW(REPLACE_EXISTING | WRITE_THROUGH), checked; up to 3 tries.
- The launcher writes the record first, then sets OptiScaler's
  UpscalerIndex to the model's entry whatever it was (AMD's version,
  another value, or no key: created), both under the lock. The index is
  display only, so a crash between the two is harmless.
- Upgrade: a game without a record gets one from wronggpu.ini's model
  item (else Model M), seq 1, source=launcher. The old stamp files are
  ignored.
- A choice that cannot be written now runs for the session and is tried
  again (dropped when a newer choice was recorded meanwhile): the front
  end's host events at each create, the plugin's clicks at each create
  and once a second while its menu is drawn; the plugin's entry says
  "not saved yet, retrying" and the front end asks it
  (WrongGpuAsiPendingChoiceV1). At the end of the sequence numbers a
  choice is refused and logged as an error.

Tests on real files and real processes (TMP, APPDATA, LOCALAPPDATA and
ProgramData redirected): four writer processes and a reader racing the
record (no lost update, seq never back), a lock holder that dies, the
upgrade migration, each source winning in turn, re-selecting the same
entry after a plugin choice, corrupt and overflowing records, the end of
seq, a failed write with its retry and a superseded retry, the custom
slot ignoring its stored index, the plugin's not-saved label, and in the
launcher end-to-end suites: the index set from AMD's value and from a
missing key, and an apply stopped between the record and OptiScaler.ini.
Negative controls: no lock, the stored index taken as the choice, a retry
ignoring newer choices, no end-of-seq check, migration from the index,
the launcher not setting the index.

Signed-off-by: phantoslayer21 <156617979+phantoslayer21@users.noreply.github.com>
…her-model

Signed-off-by: phantoslayer21 <156617979+phantoslayer21@users.noreply.github.com>
…te.h)

One header-only module for every WrongGPU program that changes per-game state after the
install (the launcher, the front end and its menu plugin, the RR plugin):

- the ONE state folder <game folder>\wronggpu-setup (settings.ini: settings chosen in the
  launcher or a WrongGPU menu in the game, over wronggpu.ini's install defaults;
  model-choice.ini: the model choice record);
- StateLock: a named mutex per game folder, named from the folder's file identity
  (volume serial + file index, so every spelling of the path gives the same name), open to
  every integrity level, bounded wait, abandoned = taken;
- WriteAtomic: temporary file in the same folder (created only where nothing is), flushed,
  MoveFileExW(REPLACE_EXISTING | WRITE_THROUGH), the temporary file deleted on any failure;
- settings.ini in a strict key=value format (corrupt = no keys); SetSettings is the locked
  read-modify-write (an unreadable file is never overwritten, the folder never created).

test_wg_state (ctest wgshared_state): the format, real-file writes and cleanup, the lock
name for several spellings, four child processes doing 50 locked increments each of one
counter (200 at the end), a busy lock (bounded wait, nothing written) and a holder that
dies (abandoned, taken).

Refs #219

Signed-off-by: phantoslayer21 <156617979+phantoslayer21@users.noreply.github.com>
…tate.h

A WrongGPU module loaded in the game keeps a named mutex Local\WrongGPU-loaded-<volume
serial>-<file index> open (never owned) for the game folder; the object exists exactly while
some process has it open, and the OS closes every handle of a process that ends or crashes, so
a dead game leaves no stale marker. IsGameUsingWrongGPU(gameDir) only opens it (never creates).
StateLock and the marker share CreateSharedMutex and NameFor.

Tests: a marker in this process (any spelling of the folder), another folder, a missing
folder, a child process holding it, and that child killed (TerminateProcess): not in use.

Refs #219

Signed-off-by: phantoslayer21 <156617979+phantoslayer21@users.noreply.github.com>
Review of #213 (fourth round), cut down as decided:

- The record lives in the game's WrongGPU state folder and uses
  wg_state.h (#226): its state lock (named from the game folder's volume
  and file identity, so every path alias is one lock) and its atomic
  write, retried up to 3 times in the call. #213 has no lock code of its
  own.
- No queued choices. A plugin click or a host selection that cannot be
  saved in time changes nothing: the plugin's entry says "not saved, try
  again", the host event returns "not saved"; the running model stays.
- When the record cannot be read, is corrupt or busy at a create: the
  last choice read this session, else wronggpu.ini's model item, else
  Model M. Never the host's stored entry.
- The launcher's Apply with a model shown is an explicit choice: the
  record is always written (also the same model again) and the index
  set. The launcher holds the state lock across wronggpu.ini, the record
  and OptiScaler.ini; the model is no longer written into wronggpu.ini.
  A game without a record gets one from the profile; the launcher's own
  last choice follows the model's data being ready.
- The upgrade migration reads wronggpu.ini's model item while it holds
  the lock (the file as it is on disk now).
- The host event returns 1 when the model that runs changes (also for a
  re-selection of the same entry), 0 when nothing changes, negative when
  not saved. No session-only choices.
- One shared definition of the entry order (wgshared
  wg_model_entries.h) for the launcher's UpscalerIndex, checked against
  the front end's version list.
- The front end and the menu plugin keep WrongGPU's loaded marker open
  while loaded (wg_state.h), for the launcher's refusal to uninstall,
  repair or update a game in use.
- The record decides on the direct route too.

Tests: two real processes for the migration against a launcher apply
(one dying between wronggpu.ini and the record), a junction and the \\?\
form of one folder as one lock across processes, lock timeout and failed
writes changing nothing, a re-selection of the same entry returning 1,
an explicit launcher choice of an unchanged model winning over a newer
plugin choice, a launcher change of another setting leaving it, the
entry order. Negative controls for the migration read, the fallback, the
event result, the plugin's failed save and the launcher's explicit
choice.

Signed-off-by: phantoslayer21 <156617979+phantoslayer21@users.noreply.github.com>
…ronggpu into fix/asi-honours-launcher-model

Signed-off-by: phantoslayer21 <156617979+phantoslayer21@users.noreply.github.com>

# Conflicts:
#	clean/wgshared/include/wg_state.h
#	clean/wgshared/tests/test_wg_state.cpp
The front end and the menu plugin follow wg_state.h's loaded protocol
(#226): each registers under the game's state lock before it reads or
writes any state (LoadedRegistration), keeping its loaded marker open
while loaded. When the registration fails (an uninstall, repair or update
holds the lock), the record is neither read nor written that session:
the front end runs wronggpu.ini's model item (else Model M) and a host
selection returns "not saved"; a plugin click is not saved.

Test: a front end that could not register reads and writes nothing and
runs wronggpu.ini's item.

Signed-off-by: phantoslayer21 <156617979+phantoslayer21@users.noreply.github.com>
…ply and set, always)

Signed-off-by: phantoslayer21 <156617979+phantoslayer21@users.noreply.github.com>
Signed-off-by: phantoslayer21 <156617979+phantoslayer21@users.noreply.github.com>
…ropped)

Design change from the wg_state.h re-check: whether a game is using
WrongGPU is decided by the launcher opening WrongGPU's binaries in the
game folder exclusively, so the front end and the menu plugin no longer
register as loaded or hold a marker. The record keeps wg_state.h's state
lock and atomic write.

The record test's reader reports a read another program briefly refused
(a virus scanner looking at the new file) instead of failing on it; a
corrupt record or seq going back still fails, and every reader and
writer failure is printed.

Signed-off-by: phantoslayer21 <156617979+phantoslayer21@users.noreply.github.com>
…handles) into fix/asi-honours-launcher-model
@phantoslayer21
phantoslayer21 marked this pull request as ready for review November 15, 2026 03:10
@phantoslayer21
phantoslayer21 marked this pull request as draft November 15, 2026 03:15
…ply leaves wronggpu.ini

Review of #213 (fifth round):

- The host event compares the selection with the model the active
  context runs, not with the earlier record: it returns 1 whenever the
  selection differs from what runs (also when a launcher Apply changed
  the record while the game is open), so the host recreates.
- The front end always takes the model choice route. Without the state
  folder (wronggpu-setup), or when it cannot be checked: the session's
  last choice, else wronggpu.ini's model item, else Model M. The host's
  stored entry and the plugin's saved entry never choose the model; the
  legacy host-entry route is removed. An event that cannot be saved
  returns "not saved".
- Apply does not rewrite wronggpu.ini at all (the settings it applied
  there move to wronggpu-setup\settings.ini with #224). A missing or
  unreadable OptiScaler.ini: the record is still written and the player
  is told "OptiScaler's list couldn't be updated; the model choice is
  saved".
- The launcher window's Apply builds its request in GuiApplyRequest
  (core); `set ... --gui-apply` runs that same request in test builds.

Tests: running K, the launcher records M, the player selects the shown M:
1 and M runs; no state folder: wronggpu.ini's item on the hooked route
and the custom slot, never the entry, and a selection is not saved; the
launcher's Apply of an unchanged model wins over a newer choice made in
OptiScaler's list; OptiScaler.ini missing; the upgrade migration (the
record tool in its own process) against the REAL launcher apply holding
the lock (test hook). The earlier tests that relied on an entry choosing
the model now expect the model choice route's model.

Signed-off-by: phantoslayer21 <156617979+phantoslayer21@users.noreply.github.com>
tools/ci/check_vendored_model_entries.py fails when
clean/wgshared/include/wg_model_entries.h no longer has its pinned SHA-256,
or when the fork's copy (OptiScaler/include/wronggpu/wg_model_entries.h at
the pinned fork commit, fetched from GitHub) is not byte-identical to it.
The version box stores the player's entry as a position in WrongGPU's
version list, so the two copies must never differ. Run in the "Licence and
line endings" job.

Signed-off-by: phantoslayer21 <156617979+phantoslayer21@users.noreply.github.com>
Conflicts:
- launcher.cpp ApplyProfile: one state-lock hold covers #224's settings
  (validated first, then settings.ini through the state keys), the model
  choice record, OptiScaler.ini's entry and #224's RR state, in that
  order. WriteLauncherModelChoice / GuiApplyRequest sit next to #224's
  FrontEndStateKeys / WithFrontEndState.
- record.cpp: #224's version (model-choice.ini is WrongGPU's by its
  stamp, not by its name).

Follow-ups for main's changes:
- The model choice record is written with wgstate::WriteStamped (#224's
  stamp for model-choice.ini and the install's id), so an uninstall knows
  it as WrongGPU's; a test covers the stamp, a parse of a stamped record
  and a write without an install id.
- A create no entry names, whose record names a model this build lacks,
  runs Model M, never the persisted sr_model (which an earlier session
  may have left on another model); test case (16).
- wronggpu.ini's reader for the upgrade migration is a named callable
  class, not a lambda capturing the path by copy.
- run_model_k_tests: since #224 the uninstall also removes the seeded,
  unchanged wronggpu-asi.ini, so the game folder is byte for byte as
  before.

Signed-off-by: phantoslayer21 <156617979+phantoslayer21@users.noreply.github.com>
@phantoslayer21
phantoslayer21 marked this pull request as ready for review November 15, 2026 22:43
…ays what was applied

- model-choice.ini is written in place through #224's state-file updater
  (wg_state.h UpdateStateFile, the settings.ini updater generalised for
  any state file of the folder): only the record's three key lines
  change; comments, other lines and line ends stay; the stamp is put
  back only when the file was WrongGPU's and unedited (or new), so an
  edited or player-made record stays unstamped and the uninstall keeps
  it. A record that is not a valid record is never replaced: the choice
  is refused with one log line (the front end returns "refused", the
  plugin's entry says so, the launcher warns) and the model that runs
  stays. Tests: edited, player-made, corrupt.
- wronggpu-asi.ini: the launcher's Apply changes only its selection line
  (wgasi::WithSelection) and keeps every other byte; a file whose bytes
  were WrongGPU's (the install record's hash) stays WrongGPU's under its
  new hash, the player's stays the player's. Tests: unit, and the Model L
  suite with a player's file (comments, selection=amd).
- dllmain.cpp / win_util.h: the callables that keep a string of the
  configuration (model places, AMD's DLL, the comparison DLL) are named
  classes, not lambdas capturing the string by copy.
- A partial apply: when the RR write fails after other settings were
  written, the message lists exactly what was applied and what was not
  (no "settings not applied" after some were), and the install record
  keeps the hashes of the files WrongGPU changed. Test: the launcher
  suite's RR group with the write failure injected
  (WRONGGPU_TEST_FAIL_RR_STATE, testing builds only).

Signed-off-by: phantoslayer21 <156617979+phantoslayer21@users.noreply.github.com>
Signed-off-by: phantoslayer21 <156617979+phantoslayer21@users.noreply.github.com>
@phantoslayer21
phantoslayer21 merged commit 174b4af into main Nov 16, 2026
10 checks passed
@phantoslayer21
phantoslayer21 deleted the fix/asi-honours-launcher-model branch November 16, 2026 00:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant