Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
8d51620
R1: non-RDNA-4 adapters use the front end's upscaler; GPU identity fr…
phantoslayer21 Nov 15, 2026
de91e17
R1: identity by the driver's PCI ids only, fail closed; no HIP route …
phantoslayer21 Nov 15, 2026
9584e52
R1: hip_switch is ignored for every model (one line); no move to HIP …
phantoslayer21 Nov 15, 2026
13f1b28
R1: Quality 5/9 fall back to the default filter on D3D12; launcher sh…
phantoslayer21 Nov 15, 2026
ec0d3b6
R1: launcher HIP-only tests, interop matrix case for the create refus…
phantoslayer21 Nov 15, 2026
dd381b0
H2 matrix: format-agnostic readback, narrower HIP-line check, hip_swi…
phantoslayer21 Nov 15, 2026
8124836
Matrix comments: reword the mode names for the leak scan
phantoslayer21 Nov 15, 2026
713b86f
H2 matrix driver: Model M and L with converted model files (read only)
phantoslayer21 Nov 15, 2026
442fcd8
R1: no in-game route to HIP; refused frames and creates always go to …
phantoslayer21 Nov 15, 2026
516e3a9
H2 matrix: a leg with executor=hip and capture_dir in the options
phantoslayer21 Nov 15, 2026
2263902
R1: the package never holds developer diagnostics; create worker owns…
phantoslayer21 Nov 15, 2026
9ccadf9
Comments: neutral wording for review findings
phantoslayer21 Nov 15, 2026
50e809d
R1: the package gate rests on the build, not on marker bytes; retry f…
phantoslayer21 Nov 15, 2026
3ba977b
CI: the package gate runs on the real runtime library; selector pin
phantoslayer21 Nov 15, 2026
9076349
Tests: the hard rule (no release choice is HIP); build.py writes the …
phantoslayer21 Nov 15, 2026
9c91f7a
The create worker's device hold: owner first, retain after (no leak i…
phantoslayer21 Nov 15, 2026
bce4a4e
Test: the allocation failure injection is thread-local
phantoslayer21 Nov 15, 2026
23dda8b
Test: the allocation-order check uses a callable whose copy throws; u…
phantoslayer21 Nov 15, 2026
f75acd6
Test: the hold's order is observed without an exception (the CI confi…
phantoslayer21 Nov 15, 2026
00aa1e1
The hold's owner callable is a named class: a lambda capturing a thro…
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
19 changes: 19 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,25 @@ jobs:
cmake -S clean/installer -B out/launcher-models -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=ON -DWRONGGPU_MODEL_K=ON -DWRONGGPU_MODEL_L=ON -DWRONGGPU_DIRECT_ROUTE=OFF
cmake --build out/launcher-models --target wg-core-tests launcher-core-tests coexist-core-tests convert-ignore-tests model-choice-tests model-choice-k-tests model-choice-k-only-tests
ctest --test-dir out/launcher-models --output-on-failure -R "^(wg-core|launcher-core|coexist-core|convert-ignore|model-choice|model-choice-k|model-choice-k-only|source-size|wording)$"
- name: Payload packager and package check refuse a developer runtime (R1)
# The packager (clean/installer/tools/make_payload.py) runs clean/tests/check_no_dev_diagnostics.py on every runtime
# library it embeds and refuses the payload for dev-diagnostics=1 or a missing marker; tools/release runs the same
# check on the final package. Here the real packager is run on runtime files carrying each marker, and the check on
# packages (zip, launcher executable): what is tested are the bytes that would ship, not source strings.
run: |
$PSNativeCommandUseErrorActionPreference = $true
python -m unittest clean.tests.test_dev_diagnostics_off -v
- name: Package gate on the real runtime library (R1)
# The runtime library is built from this tree (clean/runner/build.py --runtime-only --no-embed: the C++ runtime without
# the GPU code objects) in the release configuration the package gets, and as a developer build; the gate's functions
# then check THOSE libraries: the release one passes the real packager (marker, no developer-diagnostic code text,
# build manifest with its SHA-256); the developer one, the same with a forged marker, a stripped and a changed
# library are refused.
run: |
$PSNativeCommandUseErrorActionPreference = $true
$clang = (Get-Command clang++ -ErrorAction SilentlyContinue).Source
if (-not $clang) { $clang = "C:\Program Files\LLVM\bin\clang++.exe" }
python tools/ci/check_release_runtime.py --out out/runtime-gate --cxx $clang

rr-plugin:
name: "CPU: Ray Reconstruction plugin"
Expand Down
3 changes: 2 additions & 1 deletion clean/dx12/tests/native_probe_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
#include <string>

#include "../../runtime/device_d3d12.h"
#include "../../runtime/rdna4_win.h"
#include "../../runtime/rdna4.h"

int main(int argc, char** argv) {
Expand Down Expand Up @@ -45,7 +46,7 @@ int main(int argc, char** argv) {
DXGI_ADAPTER_DESC1 desc{};
char n[256] = {};
if (SUCCEEDED(a->GetDesc1(&desc))) WideCharToMultiByte(CP_UTF8, 0, desc.Description, -1, n, sizeof n - 1, nullptr, nullptr);
if (wgrt::rdna4_adapter(desc.VendorId, (desc.Flags & DXGI_ADAPTER_FLAG_SOFTWARE) != 0, n)) {
if (wgrt::rdna4_identity(wgrt::read_adapter_identity(desc.AdapterLuid))) { // the driver's ids (rdna4_win.h)
adapter = a;
name = n;
break;
Expand Down
20 changes: 16 additions & 4 deletions clean/fsr/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -266,10 +266,22 @@ OptiScaler folder ships `amd_fidelityfx_upscaler_dx12.dll`; OptiScaler.ini `[Lib
otherwise it is refused with one line and the context gets AMD's FSR (else the stand-in). WrongGPU's queue is never
made on another device (`test_wrapped_list` case F). The front end writes its log to disk right after an upscaler's
`about to ...` line (HIP start-up, the shared-memory import) and before the first split's submission.
- **Frames the upscaler does not take:** `WG_ERROR_UNSUPPORTED` from the upscaler's dispatch (the network runtime with
`hip_switch=off`, its default since 2026-11-04: frames above the render size checked at create) hands the context to
AMD's FSR at once;
without AMD's FSR the stand-in upscales such frames.
- **Frames the upscaler does not take:** `WG_ERROR_UNSUPPORTED` from the upscaler's dispatch (the network runtime's
D3D12 executor: frames above the render size checked at create) hands the context to AMD's FSR at once; without
AMD's FSR the stand-in upscales such frames. No model moves to the HIP executor in a game; the old option
`hip_switch=on` is ignored with one log line.
- **Creates the runtime refuses:** a create the runtime answers `WG_ERROR_UNSUPPORTED` (an adapter that is not an RX 9000-series
card, a build without its Direct3D 12 kernel set, a Direct3D 12 executor that cannot take the context) is a hard
incompatibility, not a runtime failure: the context goes to AMD's FSR whatever `fallback_to_amd` says (`fallback_to_amd = 0`
governs runtime failures only). With no AMD provider the answer is `NO_PROVIDER`, explicitly: the game gets no context from
WrongGPU and no silent substitute (OptiScaler's custom slot hands the game back to its host). A create that does not finish
in `create_giveup_ms` (default 30000; only when nothing could upscale meanwhile: `fallback_to_amd = 0`, or a custom slot
without an AMD DLL of its own) is refused, logged, and the context goes to AMD's FSR for now (the late result takes over, as
for a create that outlasts `create_wait_ms`); the game's thread does not wait for ever.
- **Developer diagnostics are not in a game:** `executor=hip` and `capture_dir` are ignored in a release build of the runtime
(one log line: `ignored: diagnostic key, release build`); the context stays on Direct3D 12. They work in a developer build
only (`clean/runner/build.py --dev-diagnostics`, `WG_DEV_DIAGNOSTICS`), which no release or package is; the library says which
kind it is (`wg-build dev-diagnostics=0|1`, `clean/tests/check_no_dev_diagnostics.py`).
- **Model location:** the front end looks for the converted model (`model.wgcm`, Model K in `K\`) in `[fsr] model_dir`
of `wronggpu.ini` (relative: from the data folder), then `<game exe folder>\WrongGPU\model`, and passes the first
folder that has it to the runtime as `model_dir=`; otherwise the runtime's own default (`%LOCALAPPDATA%\WrongGPU\model`,
Expand Down
28 changes: 25 additions & 3 deletions clean/fsr/src/async_create.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,33 @@

namespace wgfsr {

std::shared_ptr<PendingCreate> PendingCreate::Start(const WgUpscalerBackend* backend, const WgCreateInfo& info) {
auto p = std::make_shared<PendingCreate>();
namespace {
PendingCreate::Launcher g_launcher = nullptr;
}

void PendingCreate::SetLauncherForTest(Launcher launcher) { g_launcher = launcher; }

std::shared_ptr<PendingCreate> PendingCreate::Start(const WgUpscalerBackend* backend, const WgCreateInfo& info,
ScopedRelease hold) {
auto p = std::make_shared<PendingCreate>(); // (if this throws, `hold` is released as the argument goes away)
p->backend_ = backend;
p->info_ = info;
p->release_ = std::move(hold);
p->start_ = std::chrono::steady_clock::now();
std::thread([p] { p->Run(p); }).detach();
try {
std::function<void()> work = [p] { p->Run(p); };
if (g_launcher) g_launcher(work);
else std::thread(work).detach();
} catch (...) { // the worker could not be started: the create did not run and failed; the hold is given back now
{
std::lock_guard<std::mutex> lock(p->mutex_);
p->result_ = WG_ERROR_DEVICE;
p->end_ = std::chrono::steady_clock::now();
p->done_ = true;
}
p->cv_.notify_all();
p->release_.Release();
}
return p;
}

Expand All @@ -29,6 +50,7 @@ void PendingCreate::Run(std::shared_ptr<PendingCreate> self) {
}
cv_.notify_all();
if (cleanup) cleanup(r == WG_OK ? upscaler : nullptr); // the context went away while the create ran
release_.Release(); // the last step: nothing of this worker touches the game's device after it
}

bool PendingCreate::Wait(uint32_t ms) {
Expand Down
65 changes: 63 additions & 2 deletions clean/fsr/src/async_create.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,71 @@

namespace wgfsr {

// Owns one thing to give back (the create worker's COM reference on the game's device, taken by the front end before the
// worker starts): released exactly once, by Release() or, if nobody did, when the owner goes away. So the reference is
// given back when the worker finishes, when the worker could not be started at all (Start), and when anything between taking
// the reference and starting the worker throws. Move-only.
class ScopedRelease {
public:
ScopedRelease() = default;
explicit ScopedRelease(std::function<void()> release) : release_(std::move(release)) {}
ScopedRelease(ScopedRelease&& o) noexcept : release_(std::move(o.release_)) { o.release_ = nullptr; }
ScopedRelease& operator=(ScopedRelease&& o) noexcept {
if (this != &o) {
Release();
release_ = std::move(o.release_);
o.release_ = nullptr;
}
return *this;
}
ScopedRelease(const ScopedRelease&) = delete;
ScopedRelease& operator=(const ScopedRelease&) = delete;
~ScopedRelease() { Release(); }
void Release() {
std::function<void()> f = std::move(release_);
release_ = nullptr;
if (f) f();
}
explicit operator bool() const { return static_cast<bool>(release_); }

private:
std::function<void()> release_;
};

// Takes the create worker's hold on the game's device: the owner is built FIRST (its callable is the only allocation), the
// reference is retained AFTER it, and the owner is returned by a noexcept move: nothing that can throw lies between the
// retain and the owner, so a throwing allocation never leaks the reference (it throws before anything was retained).
// The owner's callable is a named class, not a lambda that captures `release` by copy: with MSVC's /Zc:lambda (on whenever
// /permissive- is, as in the CI builds) a lambda whose capture copy throws terminates the process instead of unwinding (a
// defect in the closure's unwind state; reproduced with a callable whose copy throws, and std::bad_alloc from copying a large
// callable is the same case), while the same copy inside a class constructor unwinds normally.
struct DeviceRelease {
std::function<void(void*)> release;
void* device;
DeviceRelease(const std::function<void(void*)>& r, void* d) : release(r), device(d) {}
void operator()() const { release(device); }
};

inline ScopedRelease AcquireHold(void* device, const std::function<void(void*)>& retain, const std::function<void(void*)>& release) {
ScopedRelease hold{std::function<void()>(DeviceRelease(release, device))};
retain(device);
return hold;
}

class PendingCreate {
public:
// Starts backend->create(info) on a new thread. `info` and what it points to (options, log user) must stay valid
// until the create finished, or until the cleanup given to Abandon ran.
static std::shared_ptr<PendingCreate> Start(const WgUpscalerBackend* backend, const WgCreateInfo& info);
// until the create finished, or until the cleanup given to Abandon ran. `hold`: released by the worker as its last step,
// also after a timeout and after the context went away; released at once when the worker cannot be started (the create
// then counts as failed: WG_ERROR_DEVICE, no exception reaches the game's thread) or when anything before it throws (the
// front end takes a COM reference on the game's D3D12 device before the worker starts and gives it back through this, so a
// late worker never meets a released device and a worker that never ran never leaks it).
static std::shared_ptr<PendingCreate> Start(const WgUpscalerBackend* backend, const WgCreateInfo& info,
ScopedRelease hold = {});
// Tests: how the worker thread is launched (default: a detached std::thread). A launcher that throws is a worker that
// could not be started. Null restores the default.
using Launcher = void (*)(std::function<void()> work);
static void SetLauncherForTest(Launcher launcher);

// Waits up to `ms` milliseconds (UINT32_MAX: until it finishes); true when the create has finished.
bool Wait(uint32_t ms);
Expand Down Expand Up @@ -49,6 +109,7 @@ class PendingCreate {
WgResult result_ = WG_ERROR_DEVICE;
WgUpscaler* upscaler_ = nullptr;
std::function<void(WgUpscaler*)> cleanup_; // set by Abandon while the create runs
ScopedRelease release_; // the worker's last step (Start's hold)
double reported_ = 0; // highest threshold PassedThreshold answered true for
std::chrono::steady_clock::time_point start_, end_;
};
Expand Down
7 changes: 6 additions & 1 deletion clean/fsr/src/config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -335,6 +335,10 @@ Config ParseConfig(const std::string& text, std::string* warnings) {
float f = 0;
ok = ParseFloat(value, f) && f >= 0.0f && f <= 600000.0f;
if (ok) c.createWaitMs = static_cast<uint32_t>(f);
} else if (key == "create_giveup_ms") {
float f = 0;
ok = ParseFloat(value, f) && f >= 1.0f && f <= 600000.0f;
if (ok) c.createGiveUpMs = static_cast<uint32_t>(f);
} else if (key == "context_park_ms") {
float f = 0;
ok = ParseFloat(value, f) && f >= 0.0f && f <= 60000.0f;
Expand Down Expand Up @@ -512,7 +516,8 @@ std::string Config::Describe() const {
// Paths (runtime_dll, runtime_options) can be long: no fixed-size buffer for them.
return std::string("upscaler=") + up + " runtime_dll=" + runtimeDll + (modelDir.empty() ? "" : " model_dir=" + modelDir) +
" fallback_to_amd=" + (fallbackToAmd ? "1" : "0") +
" create_wait_ms=" + std::to_string(createWaitMs) + " context_park_ms=" + std::to_string(contextParkMs) + " " +
" create_wait_ms=" + std::to_string(createWaitMs) + " create_giveup_ms=" + std::to_string(createGiveUpMs) +
" context_park_ms=" + std::to_string(contextParkMs) + " " +
BackendOptions() + buffer;
}

Expand Down
4 changes: 4 additions & 0 deletions clean/fsr/src/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,10 @@ struct Config {
// How long a game thread waits for the upscaler's create (async_create.h); after that AMD's FSR upscales until the
// create finishes (with fallbackToAmd; without it the game thread waits until the create finishes).
uint32_t createWaitMs = 3000;
// The longest a game thread waits for the upscaler's create when AMD's FSR cannot upscale meanwhile (fallback_to_amd = 0,
// or a custom slot without an AMD DLL of its own). After that the create is refused, logged, and the context goes to
// the front end's upscaler (a create that hangs must not hang the game). create_giveup_ms.
uint32_t createGiveUpMs = 30000;
// A destroyed upscaler context keeps its upscaler warm ("parked") for this long; a context created with the same
// device, sizes, flags, options and model within that time takes it over instead of creating one (games that
// re-create their upscaler at every step of a dynamic resolution). One parked upscaler at most; 0: never.
Expand Down
2 changes: 2 additions & 0 deletions clean/fsr/src/dll_fsr3.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,8 @@ Hook& H() {
p.logBytes = [] { return wronggpu::Log::Get().Bytes(); };
p.resourceInfo = &D3D12ResourceInfo;
p.deviceFromCommandList = &DeviceFromCommandList;
p.retainDevice = &RetainDevice;
p.releaseDevice = &ReleaseDevice;
AddSplitServices(p, config);
// How many upscaler dispatches WrongGPU's ffx_fsr3upscaler_x64.dll has seen on this thread (0 if not ours).
p.upscalerSeenOnThread = [] {
Expand Down
2 changes: 2 additions & 0 deletions clean/fsr/src/dll_fsr3upscaler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,8 @@ Hook& H() {
p.logBytes = [] { return wronggpu::Log::Get().Bytes(); };
p.resourceInfo = &D3D12ResourceInfo;
p.deviceFromCommandList = &DeviceFromCommandList;
p.retainDevice = &RetainDevice;
p.releaseDevice = &ReleaseDevice;
AddSplitServices(p, config);
g_hook = new Hook(p, config, "");
LoadOriginal();
Expand Down
2 changes: 2 additions & 0 deletions clean/fsr/src/dllmain.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,8 @@ FrontEnd& Get() {
p.logBytes = [] { return L().Bytes(); };
p.resourceInfo = &D3D12ResourceInfo;
p.timer = &StartTimer;
p.retainDevice = &RetainDevice;
p.releaseDevice = &ReleaseDevice;
p.deviceLost = [](void* device) {
return device && static_cast<ID3D12Device*>(device)->GetDeviceRemovedReason() != S_OK;
};
Expand Down
Loading
Loading