Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
1c3f17f
OptiScaler plugin path: honour the launcher's model choice (Model L, K)
phantoslayer21 Nov 14, 2026
dcc16a6
Merge remote-tracking branch 'origin/main' into fix/asi-honours-launc…
phantoslayer21 Nov 14, 2026
005f8f8
Merge remote-tracking branch 'origin/main' into fix/asi-honours-launc…
phantoslayer21 Nov 14, 2026
acde5c1
Model K launcher test: K then M also writes model_chosen
phantoslayer21 Nov 14, 2026
4b1c4b2
Model choice precedence: review fixes (re-apply, ties, OptiScaler's F…
phantoslayer21 Nov 15, 2026
b398cb5
Model choice: one seq record per game instead of three clocks
phantoslayer21 Nov 15, 2026
c8edbcc
Merge remote-tracking branch 'origin/main' into fix/asi-honours-launc…
phantoslayer21 Nov 15, 2026
3d9c045
Model choice: choices are events, one cross-process lock per game
phantoslayer21 Nov 15, 2026
dc1da70
Merge remote-tracking branch 'origin/main' into fix/asi-honours-launc…
phantoslayer21 Nov 15, 2026
1112b93
Shared: the per-game state folder, its lock and atomic writes (wg_sta…
phantoslayer21 Nov 15, 2026
27e86aa
Shared: the loaded marker (LoadedMarker, IsGameUsingWrongGPU) in wg_s…
phantoslayer21 Nov 15, 2026
fc6cb43
Model choice: the shared state lock, no queued choices, one apply lock
phantoslayer21 Nov 15, 2026
309464f
Merge branch 'shared/wg-state' of https://github.com/phantoslayer21/w…
phantoslayer21 Nov 15, 2026
8d048d7
Model choice: register as loaded before any state is read (wg_state.h)
phantoslayer21 Nov 15, 2026
36d8440
Model choice record: the header says who writes it (the launcher's Ap…
phantoslayer21 Nov 15, 2026
55054e6
Merge branch 'shared/wg-state' (wg_state.h re-check fixes) into fix/a…
phantoslayer21 Nov 15, 2026
4d7fa3a
Model choice record: wg_state.h's WriteResult (its words in the reason)
phantoslayer21 Nov 15, 2026
2ad053b
Model choice: the game side registers nothing (the loaded marker is d…
phantoslayer21 Nov 15, 2026
b0be8b4
Merge branch 'shared/wg-state' (game in use through exclusive binary …
phantoslayer21 Nov 15, 2026
b0645d8
Model choice: compare with the running model, record route always, Ap…
phantoslayer21 Nov 15, 2026
d0ee941
Merge remote-tracking branch 'origin/main' (#226 wg_state.h) into fix…
phantoslayer21 Nov 15, 2026
9a2788a
CI: check OptiScaler WrongGPU edition's copy of wg_model_entries.h
phantoslayer21 Nov 15, 2026
60c5002
Merge main (#243, #224, #225) into fix/asi-honours-launcher-model
phantoslayer21 Nov 15, 2026
62dc5df
Model choice: the player's files stay the player's; a partial apply s…
phantoslayer21 Nov 15, 2026
fbb7049
Merge main (#249) into fix/asi-honours-launcher-model
phantoslayer21 Nov 15, 2026
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
2 changes: 2 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ jobs:
python-version: "3.12"
- name: Line endings
run: python tools/ci/check_line_endings.py
- name: Vendored model entry order (OptiScaler WrongGPU edition)
run: python tools/ci/check_vendored_model_entries.py
- name: Licence (REUSE)
run: |
$PSNativeCommandUseErrorActionPreference = $true
Expand Down
14 changes: 12 additions & 2 deletions clean/fsr/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,15 @@ add_test(NAME fsr30_hook_${WG_OTHER_K_NAME}_unit COMMAND test_fsr30_${WG_OTHER_K
# WrongGPU OptiScaler ASI plugin: thunk logic (any OS) and the offline anchor scan of an OptiScaler binary
# (any OS; skips when WRONGGPU_OPTISCALER_BIN is not set). Header-only resolver/thunk, no extra libraries.
add_executable(test_asi_thunk tests/test_asi_thunk.cpp)
target_compile_definitions(test_asi_thunk PRIVATE WRONGGPU_MODEL_L=${WG_MODEL_L_VALUE})
add_test(NAME fsr_asi_thunk_unit COMMAND test_asi_thunk)
# The plugin's menu and saved choice with Model L (and Model K), whatever this build's switches: the 0.6.5 shape.
add_executable(test_asi_thunk_kl tests/test_asi_thunk.cpp)
target_compile_definitions(test_asi_thunk_kl PRIVATE WRONGGPU_MODEL_K_OVERRIDE=1 WRONGGPU_MODEL_L=1)
add_test(NAME fsr_asi_thunk_kl_unit COMMAND test_asi_thunk_kl)
# The game's model choice record (src/model_choice_record.h) on real files in the temporary folder.
add_executable(test_model_choice_record tests/test_model_choice_record.cpp)
add_test(NAME fsr_model_choice_record_unit COMMAND test_model_choice_record)
add_executable(test_asi_patch tests/test_asi_patch.cpp)
add_test(NAME fsr_asi_patch_unit COMMAND test_asi_patch)
add_executable(test_asi_lifetime tests/test_asi_lifetime.cpp)
Expand All @@ -141,7 +149,7 @@ add_executable(test_asi_scan tests/test_asi_scan.cpp)
add_test(NAME fsr_asi_scan_unit COMMAND test_asi_scan)
set_tests_properties(fsr_asi_scan_unit PROPERTIES SKIP_RETURN_CODE 77)
if(MSVC)
set_property(TARGET test_asi_thunk test_asi_scan test_asi_patch test_asi_lifetime PROPERTY MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CONFIG:Debug>:Debug>")
set_property(TARGET test_asi_thunk test_asi_thunk_kl test_model_choice_record test_asi_scan test_asi_patch test_asi_lifetime PROPERTY MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CONFIG:Debug>:Debug>")
endif()

if(WIN32)
Expand All @@ -166,6 +174,8 @@ if(WIN32)
target_link_options(test_fsr30_${WG_OTHER_K_NAME} PRIVATE ${WG_STATIC_RUNTIME})
target_link_options(test_fsr30 PRIVATE ${WG_STATIC_RUNTIME})
target_link_options(test_asi_thunk PRIVATE ${WG_STATIC_RUNTIME})
target_link_options(test_asi_thunk_kl PRIVATE ${WG_STATIC_RUNTIME})
target_link_options(test_model_choice_record PRIVATE ${WG_STATIC_RUNTIME})
target_link_options(test_asi_scan PRIVATE ${WG_STATIC_RUNTIME})
target_link_options(test_asi_patch PRIVATE ${WG_STATIC_RUNTIME})
target_link_options(test_asi_lifetime PRIVATE ${WG_STATIC_RUNTIME})
Expand Down Expand Up @@ -280,7 +290,7 @@ if(WIN32)
set_target_properties(wronggpu_asi PROPERTIES PREFIX "" OUTPUT_NAME WrongGPU SUFFIX ".asi"
MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CONFIG:Debug>:Debug>")
target_include_directories(wronggpu_asi PRIVATE src)
target_compile_definitions(wronggpu_asi PRIVATE _CRT_SECURE_NO_WARNINGS NOMINMAX)
target_compile_definitions(wronggpu_asi PRIVATE _CRT_SECURE_NO_WARNINGS NOMINMAX WRONGGPU_MODEL_L=${WG_MODEL_L_VALUE})
if(MSVC)
target_compile_options(wronggpu_asi PRIVATE /W4 /wd4100 /Zi)
target_link_options(wronggpu_asi PRIVATE /DEBUG:FULL /INCREMENTAL:NO)
Expand Down
22 changes: 21 additions & 1 deletion clean/fsr/asi/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,25 @@ What the front end does with the plugin's entry (`src/frontend.cpp`, `TestAsiPlu
whatever the FFX box names; "FSR 3.X(/4)" runs AMD: the AMD version the FFX box names, else AMD's newest listed version.
The FFX box's list is the same with and without the plugin (WrongGPU first).

Which model runs (0.6.5, `src/model_choice_record.h`, `TestAsiChoiceRecord`, `tests/test_model_choice_record.cpp`): the
plugin's entry says WrongGPU or AMD; which WrongGPU model is the game's **model choice record**, `model-choice.ini` in the
game's WrongGPU state folder (`wronggpu-setup`, beside `settings.ini`; `clean/wgshared/include/wg_state.h`). It holds
`model=`, `seq=` and `source=` (launcher, ffx or plugin) and is written only for a choice the player made, each time with
the record's seq + 1, so the highest seq is the most recent choice: by the launcher when the player applies a model (Apply,
or `set <game> model=`; always, also the same model again; then OptiScaler's `UpscalerIndex` is set to that model's entry,
for display); by the front end when the WrongGPU edition of OptiScaler reports that the player selected one of WrongGPU's
entries (`WrongGpuHostSelectedV1`, `include/wronggpu_host_event.h`); and by this plugin when the player clicks one of its
model entries. The index OptiScaler stores is never a choice, and wronggpu.ini's model item is the install's default, which
only seeds the record of a game that has none (read under the lock). Every read and write holds the game's state lock (one
named mutex per game folder, from its volume and file identity, shared with every WrongGPU program); writes are atomic.
A click that cannot be saved in time changes nothing: its entry says "not saved, try again" and nothing is kept for later.
When the record cannot be read, is corrupt or busy at a create, the front end runs the last choice it read this session,
else wronggpu.ini's model item, else Model M. Without a record (no launcher state folder) the launcher's Model K / L item
decides, else the plugin's saved entry, else Model M. The front end logs the model and which
choice decided and tells the plugin which model runs (`WrongGpuAsiShowModelV1`), so the menu marks that entry. Model L's
own entry ("WrongGPU Model L") is in the menu of a build with `WG_MODEL_L`; a model the front end was built without runs
as Model M, with a note in the log.

## How it works

1. OptiScaler loads the plugin and calls its exported `InitializeASI()`. `opti_module.h` finds OptiScaler's module
Expand All @@ -41,7 +60,8 @@ The FFX box's list is the same with and without the plugin (WrongGPU first).
none of OptiScaler's data.
4. WrongGPU's front end (`amd_fidelityfx_dx12.dll`) finds the plugin by module and asks it (`WrongGpuAsiQuery`,
`asi_abi.h`) which model is selected. The FFX list always starts with WrongGPU entries followed by AMD entries;
when hooked, the front end creates Model M / Model K / AMD according to the plugin selection.
when hooked, the front end creates Model M / K / L or AMD from the plugin's selection weighed against the launcher's
model choice (the model choice record; see "Which model runs" above).

If a required anchor is missing or ambiguous, or a stub cannot be placed, nothing is patched and the plugin reports
"not hooked". Call sites are prepared and revalidated before publication. A failed write rolls back sites whose
Expand Down
19 changes: 16 additions & 3 deletions clean/fsr/asi/asi_abi.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
// entry the player selected in OptiScaler's menu. The front end finds the plugin by module (GetModuleHandle of the
// plugin file name) and resolves this one export by name, so load order does not matter and neither DLL links the
// other. Defined once, shared by the plugin (which exports it) and the front-end bridge (which calls it).
#include <stddef.h>
#include <stdint.h>

#define WRONGGPU_ASI_MODULE L"WrongGPU.asi"
Expand All @@ -12,8 +13,9 @@

// Query result. `hooked` is 1 after the prepared menu call-patch transaction commits; it does not promise
// complete menu adaptation. The FFX list still contains WrongGPU and AMD entries. Zero means inactive: the
// front end then behaves as if no plugin were present. `model` is 0 (OptiScaler's own FSR 3.X / AMD), 'M' or 'K'.
// Returns the ABI version (>= 1), or 0 on error. Signature: int WrongGpuAsiQuery(int* hooked, char* model).
// front end then behaves as if no plugin were present. `model` is 0 (OptiScaler's own FSR 3.X / AMD), 'M' or 'K'
// (a saved Model L reads as 'M' here, for an older front end; which WrongGPU model runs is the model choice
// record's, src/model_choice_record.h). Returns the ABI version (>= 1), or 0 on error. Signature: int WrongGpuAsiQuery(int* hooked, char* model).
typedef int (*PfnWrongGpuAsiQuery)(int* hooked, char* model);

// Additive WrongGPU-owned diagnostic API; this is NOT a host plugin or RR frame ABI.
Expand Down Expand Up @@ -56,7 +58,7 @@ typedef int (*PfnWrongGpuAsiQuery)(int* hooked, char* model);
// Before any host write, the plugin pins its own module until process termination. Pin failure
// leaves host call sites untouched. Query-only loads do not pin. Neither query promises host
// lifetime, executing-thread atomicity, or safe live unhook/unload.
// Selection is 0 (AMD), 'M', or 'K'; it is NOT evidence of the effective rendering backend.
// Selection is 0 (AMD), 'M', 'K' or 'L' (the saved choice); it is NOT evidence of the effective rendering backend.
// Fields are independent observations during initialization/selection changes, not a transactional snapshot.
// rr_ready is always zero in this implementation; rr_blockers is a bitmask of the reasons above.
typedef struct WrongGpuAsiStatusV1 {
Expand All @@ -75,3 +77,14 @@ typedef struct WrongGpuAsiStatusV1 {
} WrongGpuAsiStatusV1;

typedef int (*PfnWrongGpuAsiQueryStatusV1)(WrongGpuAsiStatusV1* status, uint32_t caller_size);

// The front end tells the plugin where the game's model choice record is (wronggpu-setup\model-choice.ini next to
// its wronggpu.ini; src/model_choice_record.h). A click on one of the plugin's model entries is written there (seq + 1,
// source=plugin). Without this call the plugin uses wronggpu-setup\model-choice.ini in its own data folder.
#define WRONGGPU_ASI_SET_CHOICE_RECORD "WrongGpuAsiSetChoiceRecordV1"
typedef void (*PfnWrongGpuAsiSetChoiceRecordV1)(const wchar_t* path);

// The front end reports which model it runs (0 AMD, 'M', 'K', 'L'), so the plugin's menu marks that entry; 1 returns
// to marking the saved choice. Display only: nothing is saved.
#define WRONGGPU_ASI_SHOW_MODEL "WrongGpuAsiShowModelV1"
typedef void (*PfnWrongGpuAsiShowModelV1)(char model);
Loading
Loading