From cbde677e0c523eda3e716f805af2294285a495ca Mon Sep 17 00:00:00 2001 From: phantoslayer21 <156617979+phantoslayer21@users.noreply.github.com> Date: Fri, 13 Nov 2026 22:18:40 -0500 Subject: [PATCH] Model L as a model choice: registry row (sr_model=L, model=L), front-end WG_MODEL_L, model lookup and refusals - registry: sr_model value L and the model row (runtime option model=L, build flag WRONGGPU_MODEL_L); regenerated header, ini text and REGISTRY.md. The append-only baseline of the tests (tests/data/registry.prev.json) is release 0.6.0's registry: Model L's entry 0x...03 is appended after the released M and K entries; a model put before a released one is refused. - front end: CMake option WG_MODEL_L (default OFF, src/model_l.h). With it: the entry WrongGPU Model L, sr_model=L / model=L passed to the runtime, the model lookup looks for \L\model.wgcm, and a create with Model L chosen and no converted Model L is refused with the reason (the runtime is not asked; AMD takes over as for any failed create). Without it: model=L (wronggpu.ini runtime_options, WG_RUNTIME_OPTIONS) and sr_model=L are refused by name in the log and Model M runs. - tests: the front-end unit tests also built with Model L (test_frontend_model_l); new tests for both builds; the registry tests for the third entry. Refs #89 Signed-off-by: phantoslayer21 <156617979+phantoslayer21@users.noreply.github.com> --- clean/fsr/CMakeLists.txt | 63 ++++-- clean/fsr/src/config.cpp | 46 ++++- clean/fsr/src/config.h | 11 ++ clean/fsr/src/frontend.cpp | 76 ++++++-- clean/fsr/src/frontend.h | 7 +- clean/fsr/src/fsr30_hook.cpp | 3 + clean/fsr/src/model_l.h | 13 ++ clean/fsr/src/overlay.cpp | 10 +- clean/fsr/src/provider_label.h | 4 + clean/fsr/src/status.h | 1 + clean/fsr/tests/test_frontend.cpp | 191 +++++++++++++++++-- clean/wgshared/EXTENDING.md | 12 +- clean/wgshared/REGISTRY.md | 6 +- clean/wgshared/include/wg_registry_gen.h | 14 +- clean/wgshared/include/wg_registry_ini_gen.h | 6 +- clean/wgshared/ini/wronggpu.default.ini | 4 +- clean/wgshared/registry/registry.json | 5 +- clean/wgshared/tests/data/registry.prev.json | 14 +- clean/wgshared/tests/test_dummy_extension.py | 2 +- clean/wgshared/tests/test_gen_registry.py | 22 ++- 20 files changed, 419 insertions(+), 91 deletions(-) create mode 100644 clean/fsr/src/model_l.h diff --git a/clean/fsr/CMakeLists.txt b/clean/fsr/CMakeLists.txt index 96234cad..c9ad07d3 100644 --- a/clean/fsr/CMakeLists.txt +++ b/clean/fsr/CMakeLists.txt @@ -33,6 +33,17 @@ if(WG_MODEL_K) else() add_compile_definitions(WRONGGPU_MODEL_K=0) endif() +# Model L in the front end (#89; src/model_l.h): its entry "WrongGPU Model L" in the hosted version list, its id, +# sr_model=L / model=L passed to the runtime (which needs WG_MODEL_L too), the model lookup's \L\model.wgcm, its +# names in the overlay and the provider label. OFF (the default while Model L is not released): none of that; model=L +# from wronggpu.ini or WG_RUNTIME_OPTIONS is refused with one log line and Model M runs. Set on wg_fsr_core (and so on +# everything that links it), so that the tests below can also build a front end with Model L. +option(WG_MODEL_L "Offer Model L (hosted list entry, model=L); OFF = no Model L" OFF) +if(WG_MODEL_L) + set(WG_MODEL_L_VALUE 1) +else() + set(WG_MODEL_L_VALUE 0) +endif() enable_testing() # clean/wgshared: the registry, the shared settings block and wg_settings_io.h (with their own tests). @@ -41,13 +52,14 @@ add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/../wgshared ${CMAKE_BINARY_DIR}/wgs # folder, spec 65.6): not built unless asked for. Its header-only unit tests still run. option(WG_BUILD_ASI "Build the retired OptiScaler menu-patching plugin WrongGPU.asi" OFF) add_executable(test_provider_label tests/test_provider_label.cpp) +target_compile_definitions(test_provider_label PRIVATE WRONGGPU_MODEL_L=${WG_MODEL_L_VALUE}) if(MSVC) set_property(TARGET test_provider_label PROPERTY MSVC_RUNTIME_LIBRARY "MultiThreaded$<$:Debug>") endif() add_test(NAME fsr_provider_label_unit COMMAND test_provider_label) # Front-end logic without Windows or D3D12 (routing, forwarding, parameter mapping, log text, settings). -add_library(wg_fsr_core STATIC +set(WG_FSR_CORE_SOURCES src/amd_compare.cpp src/amd_provider.cpp src/async_create.cpp @@ -57,22 +69,26 @@ add_library(wg_fsr_core STATIC src/fsr30_hook.cpp src/fsr30_map.cpp src/param_map.cpp) -target_include_directories(wg_fsr_core SYSTEM PUBLIC ${FFX_SDK_DIR}) -target_include_directories(wg_fsr_core PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/include) -target_link_libraries(wg_fsr_core PUBLIC wg_shared_headers) -set_target_properties(wg_fsr_core PROPERTIES POSITION_INDEPENDENT_CODE ON) - -if(MSVC) - target_compile_options(wg_fsr_core PRIVATE /Zi) - target_compile_options(wg_fsr_core PUBLIC /W4 $<$:/permissive-> /utf-8 /wd4100) - target_compile_definitions(wg_fsr_core PUBLIC _CRT_SECURE_NO_WARNINGS NOMINMAX) -else() - target_compile_options(wg_fsr_core PUBLIC -Wall -Wextra) -endif() -if(MINGW) - # Struct-returning COM methods (GetDesc, GetCPUDescriptorHandleForHeapStart) need the MSVC calling convention. - target_compile_definitions(wg_fsr_core PUBLIC WIDL_EXPLICIT_AGGREGATE_RETURNS) -endif() +function(wg_fsr_core_library name model_l) + add_library(${name} STATIC ${WG_FSR_CORE_SOURCES}) + target_include_directories(${name} SYSTEM PUBLIC ${FFX_SDK_DIR}) + target_include_directories(${name} PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/include) + target_link_libraries(${name} PUBLIC wg_shared_headers) + target_compile_definitions(${name} PUBLIC WRONGGPU_MODEL_L=${model_l}) + set_target_properties(${name} PROPERTIES POSITION_INDEPENDENT_CODE ON) + if(MSVC) + target_compile_options(${name} PRIVATE /Zi) + target_compile_options(${name} PUBLIC /W4 $<$:/permissive-> /utf-8 /wd4100) + target_compile_definitions(${name} PUBLIC _CRT_SECURE_NO_WARNINGS NOMINMAX) + else() + target_compile_options(${name} PUBLIC -Wall -Wextra) + endif() + if(MINGW) + # Struct-returning COM methods (GetDesc, GetCPUDescriptorHandleForHeapStart) need the MSVC calling convention. + target_compile_definitions(${name} PUBLIC WIDL_EXPLICIT_AGGREGATE_RETURNS) + endif() +endfunction() +wg_fsr_core_library(wg_fsr_core ${WG_MODEL_L_VALUE}) # Host unit tests (any platform). add_executable(test_amd_provider tests/test_amd_provider.cpp) @@ -84,6 +100,13 @@ add_test(NAME fsr_frontend_unit COMMAND test_frontend) add_executable(test_fsr30 tests/test_fsr30.cpp) target_link_libraries(test_fsr30 PRIVATE wg_fsr_core) add_test(NAME fsr30_hook_unit COMMAND test_fsr30) +# A build without Model L (the default) also tests a front end with it: the same tests, Model L built in. +if(NOT WG_MODEL_L) + wg_fsr_core_library(wg_fsr_core_model_l 1) + add_executable(test_frontend_model_l tests/test_frontend.cpp) + target_link_libraries(test_frontend_model_l PRIVATE wg_fsr_core_model_l) + add_test(NAME fsr_frontend_model_l_unit COMMAND test_frontend_model_l) +endif() # 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. @@ -107,9 +130,15 @@ if(WIN32) else() set(CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreaded$<$:Debug>") set_property(TARGET wg_fsr_core test_frontend test_fsr30 PROPERTY MSVC_RUNTIME_LIBRARY "MultiThreaded$<$:Debug>") + if(TARGET test_frontend_model_l) + set_property(TARGET wg_fsr_core_model_l test_frontend_model_l PROPERTY MSVC_RUNTIME_LIBRARY "MultiThreaded$<$:Debug>") + endif() endif() if(MINGW) target_link_options(test_frontend PRIVATE ${WG_STATIC_RUNTIME}) + if(TARGET test_frontend_model_l) + target_link_options(test_frontend_model_l PRIVATE ${WG_STATIC_RUNTIME}) + endif() target_link_options(test_fsr30 PRIVATE ${WG_STATIC_RUNTIME}) target_link_options(test_asi_thunk PRIVATE ${WG_STATIC_RUNTIME}) target_link_options(test_asi_scan PRIVATE ${WG_STATIC_RUNTIME}) diff --git a/clean/fsr/src/config.cpp b/clean/fsr/src/config.cpp index 4eba3f92..7574bdbe 100644 --- a/clean/fsr/src/config.cpp +++ b/clean/fsr/src/config.cpp @@ -20,6 +20,7 @@ bool ModelBuiltIn(int32_t srModel) { if (srModel < 0 || srModel >= WG_SR_MODEL_COUNT) return false; // Models with a build flag (registry models[].build_flag): the one place of the front end that knows them. if (std::strcmp(kWgModelRows[srModel].name, "K") == 0) return WRONGGPU_MODEL_K != 0; + if (std::strcmp(kWgModelRows[srModel].name, "L") == 0) return WRONGGPU_MODEL_L != 0; return true; } @@ -181,7 +182,10 @@ const char* RuntimeProviderName(const std::string& runtimeOptions, const char* e return name; } -std::string WithoutModelK(const std::string& options, bool* removed) { +std::string WithoutModelK(const std::string& options, bool* removed) { return WithoutModel(options, 'K', removed); } + +std::string WithoutModel(const std::string& options, char model, bool* removed) { + const char upper = char(std::toupper((unsigned char)model)), lower = char(std::tolower((unsigned char)model)); std::string kept; bool any = false; for (size_t a = 0; a < options.size();) { @@ -190,7 +194,8 @@ std::string WithoutModelK(const std::string& options, bool* removed) { const std::string item = options.substr(a, b - a); const size_t equal = item.find('='); const std::string value = equal == std::string::npos ? "" : Trim(item.substr(equal + 1)); - if (equal != std::string::npos && Trim(item.substr(0, equal)) == "model" && (value == "K" || value == "k")) { + if (equal != std::string::npos && Trim(item.substr(0, equal)) == "model" && value.size() == 1 && + (value[0] == upper || value[0] == lower)) { any = true; } else { if (!kept.empty()) kept += options[a - 1]; // the separator in front of the item @@ -202,13 +207,14 @@ std::string WithoutModelK(const std::string& options, bool* removed) { return any ? kept : options; } -#if !WRONGGPU_MODEL_K -std::string IgnoreModelK(Config& config) { - bool ini = false, env = false; - config.runtimeOptions = WithoutModelK(config.runtimeOptions, &ini); +#if !WRONGGPU_MODEL_K || !WRONGGPU_MODEL_L +// model= dropped from the ini's runtime options and from WG_RUNTIME_OPTIONS (also the process environment); +// *ini / *env: where it was. +static void DropModelOption(Config& config, char model, bool* ini, bool* env) { + config.runtimeOptions = WithoutModel(config.runtimeOptions, model, ini); if (const char* value = std::getenv("WG_RUNTIME_OPTIONS")) { - const std::string kept = WithoutModelK(value, &env); - if (env) { + const std::string kept = WithoutModel(value, model, env); + if (*env) { #ifdef _WIN32 _putenv_s("WG_RUNTIME_OPTIONS", kept.c_str()); // also the process environment; empty: removed #else @@ -217,6 +223,24 @@ std::string IgnoreModelK(Config& config) { #endif } } +} +#endif + +#if !WRONGGPU_MODEL_L +std::string IgnoreModelL(Config& config) { + bool ini = false, env = false; + DropModelOption(config, 'L', &ini, &env); + if (!ini && !env) return std::string(); + return std::string("note: model=L (") + (ini ? "runtime_options in wronggpu.ini" : "") + (ini && env ? " and " : "") + + (env ? "WG_RUNTIME_OPTIONS" : "") + ") is refused: Model L is not part of this build of the front end " + "(CMake WG_MODEL_L); Model M is used"; +} +#endif + +#if !WRONGGPU_MODEL_K +std::string IgnoreModelK(Config& config) { + bool ini = false, env = false; + DropModelOption(config, 'K', &ini, &env); if (!ini && !env) return std::string(); return std::string("note: model=K (") + (ini ? "runtime_options in wronggpu.ini" : "") + (ini && env ? " and " : "") + (env ? "WG_RUNTIME_OPTIONS" : "") + ") is ignored: Model K is not part of this build; Model M is used"; @@ -394,8 +418,12 @@ std::string OptionValue(const std::string& options, const char* key, bool* found } ModelChoice ChooseModelDir(const std::vector& places, bool modelK, const std::function& exists) { + return ChooseModelDir(places, modelK ? 'K' : 'M', exists); +} + +ModelChoice ChooseModelDir(const std::vector& places, char model, const std::function& exists) { ModelChoice c; - const char* leaf = modelK ? "\\K\\model.wgcm" : "\\model.wgcm"; + const char* leaf = model == 'K' ? "\\K\\model.wgcm" : model == 'L' ? "\\L\\model.wgcm" : "\\model.wgcm"; for (size_t i = 0; i < places.size(); ++i) { const ModelPlace& p = places[i]; if (p.dir.empty()) continue; diff --git a/clean/fsr/src/config.h b/clean/fsr/src/config.h index 52b1e237..68ed13b7 100644 --- a/clean/fsr/src/config.h +++ b/clean/fsr/src/config.h @@ -8,6 +8,7 @@ #include #include "model_k.h" +#include "model_l.h" #include "wg_registry_gen.h" // clean/wgshared: options, version-list entries, models (plain C, no Windows headers) namespace wgfsr { @@ -131,6 +132,13 @@ std::string NormalizeOptions(const std::string& text); // The options (items separated by ';' or ',') without their model=K items; *removed: whether there was one. For // builds without Model K (model_k.h), which drop the item before the runtime reads it. std::string WithoutModelK(const std::string& options, bool* removed); +// The same for any model letter (model=, either case): WithoutModelK is WithoutModel(options, 'K', removed). +std::string WithoutModel(const std::string& options, char model, bool* removed); +#if !WRONGGPU_MODEL_L +// A build without Model L (model_l.h, CMake WG_MODEL_L=OFF): drops model=L from config.runtimeOptions and from +// WG_RUNTIME_OPTIONS as IgnoreModelK does, so that Model M runs. Returns the one line for the log, or "". +std::string IgnoreModelL(Config& config); +#endif #if !WRONGGPU_MODEL_K // A build without Model K: drops model=K from config.runtimeOptions (wronggpu.ini) and from WG_RUNTIME_OPTIONS in the // process environment, so that Model M runs (the runtime library refuses the option, and it reads the environment as @@ -159,6 +167,9 @@ struct ModelChoice { }; // The first place (in order) whose model file exists; a runtime-default place ends the search without a probe. ModelChoice ChooseModelDir(const std::vector& places, bool modelK, const std::function& exists); +// The same for a model by its letter: M looks for \model.wgcm, K and L for \K\model.wgcm and +// \L\model.wgcm (the folders the launcher converts them into and the runtime reads under model_dir). +ModelChoice ChooseModelDir(const std::vector& places, char model, const std::function& exists); // Original process-specific synchronization default. Returns true when an option was added; explicit user // choices and other games/backends are preserved. No image/model settings are changed. diff --git a/clean/fsr/src/frontend.cpp b/clean/fsr/src/frontend.cpp index e15a1147..bd0780e7 100644 --- a/clean/fsr/src/frontend.cpp +++ b/clean/fsr/src/frontend.cpp @@ -156,14 +156,17 @@ bool LogPoint(uint64_t n) { // 1, 2, 3, 10, 100, 1000, ... return n == 1; } -bool OwnModelK(const std::string& options) { +// The options (and WG_RUNTIME_OPTIONS) run the registry model `id` ("K", "L"), when this build offers it. +bool OwnModel(const std::string& options, const char* id) { const char* name = RuntimeProviderName(options, std::getenv("WG_RUNTIME_OPTIONS")); - const WgEntryDef* k = nullptr; + const WgEntryDef* e = nullptr; for (int m = 0; m < WG_SR_MODEL_COUNT; ++m) - if (std::strcmp(kWgModelRows[m].name, "K") == 0) k = SrEntryOfModel(m); - return k && std::strcmp(name, EntryProviderName(*k)) == 0; + if (std::strcmp(kWgModelRows[m].name, id) == 0) e = SrEntryOfModel(m); + return e && std::strcmp(name, EntryProviderName(*e)) == 0; } +bool OwnModelK(const std::string& options) { return OwnModel(options, "K"); } + // A frame whose sizes do not fit its textures (a resolution change of the game: the stated render size is the old one, // the textures are the new ones, or the reverse) made usable for the stand-in: the regions are cut to the textures. // False when the stand-in cannot upscale it either (no command list, color or output). @@ -242,14 +245,15 @@ ffxReturnCode_t CreateAmdWithoutPrivateVersion(const OriginalApi& api, ffxContex } // namespace -#if WRONGGPU_MODEL_K -FrontEnd::FrontEnd(Platform platform, Config config) : platform_(std::move(platform)), config_(std::move(config)), providerName_(RuntimeProviderName(config_.runtimeOptions, std::getenv("WG_RUNTIME_OPTIONS"))) {} -#else FrontEnd::FrontEnd(Platform platform, Config config) : platform_(std::move(platform)), config_(std::move(config)) { +#if !WRONGGPU_MODEL_K if (const std::string note = IgnoreModelK(config_); !note.empty()) Log(note); // (config.h; one log line) +#endif +#if !WRONGGPU_MODEL_L + if (const std::string note = IgnoreModelL(config_); !note.empty()) Log(note); // (config.h; one log line) +#endif providerName_ = RuntimeProviderName(config_.runtimeOptions, std::getenv("WG_RUNTIME_OPTIONS")); } -#endif FrontEnd::~FrontEnd() { // Contexts the game never destroyed: the process is ending; GPU objects are left to the runtime. @@ -665,7 +669,7 @@ ffxReturnCode_t FrontEnd::CreateUpscale(ffxContext* context, ffxCreateContextDes return FFX_API_RETURN_ERROR_RUNTIME_ERROR; } } - ApplyModelDir(*u, tag); + const std::string refusal = ApplyModelDir(*u, tag); info.options = u->options.c_str(); info.log = &UpscalerLog; info.log_user = u; @@ -675,7 +679,7 @@ ffxReturnCode_t FrontEnd::CreateUpscale(ffxContext* context, ffxCreateContextDes // Custom slot: the same upscaler with the same options failed earlier in this session: no new attempt. std::string remembered; uint64_t repeats = 0; - if (config_.customSlot) { + if (config_.customSlot && refusal.empty()) { std::lock_guard lock(mutex_); auto it = failedCreates_.find(FailureKey(backend, *u)); if (it != failedCreates_.end()) { @@ -683,7 +687,17 @@ ffxReturnCode_t FrontEnd::CreateUpscale(ffxContext* context, ffxCreateContextDes repeats = ++it->second.repeats; } } - if (!remembered.empty()) { + if (!refusal.empty()) { + // Nothing is created (ApplyModelDir: Model L without its file): the held lines go out, then the reason. + if (t_held) { + std::vector lines = std::move(t_held->lines); + t_held->lines.clear(); + t_held = nullptr; + for (const std::string& l : lines) Log(l); + } + why = refusal; + u->failReason = refusal; + } else if (!remembered.empty()) { if (t_held) { // only the summary below, now and then (LogPoint); between those, nothing t_held->lines.clear(); t_held->drop = !LogPoint(repeats); @@ -701,11 +715,12 @@ ffxReturnCode_t FrontEnd::CreateUpscale(ffxContext* context, ffxCreateContextDes t_held = nullptr; for (const std::string& l : lines) Log(l); } - if (remembered.empty()) Log(tag + " WrongGPU upscaler \"" + backend->name + "\" create: " + DescribeCreateInfo(info)); + const bool attempt = remembered.empty() && refusal.empty(); + if (attempt) Log(tag + " WrongGPU upscaler \"" + backend->name + "\" create: " + DescribeCreateInfo(info)); double parkedMs = 0; - UpscaleContext* warm = remembered.empty() ? TakeParked(backend, *u, tag, &parkedMs) : nullptr; - if (remembered.empty()) parkGuard.settled = true; - if (!remembered.empty()) { + UpscaleContext* warm = attempt ? TakeParked(backend, *u, tag, &parkedMs) : nullptr; + if (attempt) parkGuard.settled = true; + if (!attempt) { // (nothing created: `why` says so; the fallback below decides) } else if (warm) { // The parked context object stays the upscaler's (its log callback and options point into it): it becomes @@ -1007,12 +1022,14 @@ std::string FrontEnd::FailureKey(const WgUpscalerBackend* backend, const Upscale std::to_string(u.create.maxUpscaleSize.height) + "|" + std::to_string(u.create.flags); } -void FrontEnd::ApplyModelDir(UpscaleContext& u, const std::string& tag) { +std::string FrontEnd::ApplyModelDir(UpscaleContext& u, const std::string& tag) { bool inOptions = false, inEnv = false; OptionValue(u.options, "model_dir", &inOptions); const char* env = std::getenv("WG_RUNTIME_OPTIONS"); if (env) OptionValue(env, "model_dir", &inEnv); const bool k = OwnModelK(u.options); + const bool l = !k && OwnModel(u.options, "L"); + std::string refusal; // Model L chosen and no converted Model L anywhere: the create is refused (the caller) bool kDir = false; if (k) { bool a = false, b = false; @@ -1025,23 +1042,29 @@ void FrontEnd::ApplyModelDir(UpscaleContext& u, const std::string& tag) { line = std::string("model: ") + (kDir ? "model_k_dir" : "model_dir") + " from " + (inEnv ? "WG_RUNTIME_OPTIONS" : "runtime_options") + " decides (the front end's model lookup is not used)"; } else { - if (!platform_.modelPlaces) return; - const ModelChoice c = ChooseModelDir(platform_.modelPlaces(), k, platform_.fileExists); + if (!platform_.modelPlaces) return std::string(); + const ModelChoice c = ChooseModelDir(platform_.modelPlaces(), k ? 'K' : l ? 'L' : 'M', platform_.fileExists); u.options += c.option; - const char* model = k ? "Model K" : "Model M"; + const char* model = k ? "Model K" : l ? "Model L" : "Model M"; if (!c.option.empty()) line = std::string("model: ") + model + " from " + c.file + " (passed to the runtime as model_dir); looked at: " + c.searched; else if (c.index >= 0) line = std::string("model: ") + model + " is not in the game's folders; the runtime looks in its own default place; looked at: " + c.searched; else line = std::string("model: no converted ") + model + " found; looked at: " + c.searched; + // Model L has no fallback model file: without its own file the runtime cannot start it, so the create is + // refused here with the reason (and what writes the file), not left to fail inside the runtime. + if (l && c.index < 0) + refusal = "Model L is chosen but no converted Model L was found (" + c.searched + + "); WrongGPU.exe model convert --preset=L writes it"; } { std::lock_guard lock(mutex_); - if (modelLogged_.count(line)) return; + if (modelLogged_.count(line)) return refusal; modelLogged_[line] = true; } Log(tag + " " + line); + return refusal; } void FrontEnd::Fail(UpscaleContext& u, const std::string& why, uint64_t call, bool error) { @@ -1296,6 +1319,19 @@ bool FrontEnd::ConfiguredModel(int32_t* model, std::string* described) { bool isDefault = true; std::string text; const int32_t value = platform_.menu.get(WG_OPT_SR_MODEL, &text, &isDefault); +#if !WRONGGPU_MODEL_L + if (!isDefault && value == WG_SR_MODEL_L) { // a model this build lacks: refused by name, once (Model M runs) + const std::string line = "note: " + text + " is refused: Model L is not part of this build of the front end " + "(CMake WG_MODEL_L); Model M is used"; + bool first = false; + { + std::lock_guard lock(mutex_); + first = !modelLogged_.count(line); + modelLogged_[line] = true; + } + if (first) Log(line); + } +#endif if (isDefault || !SrEntryOfModel(value)) return false; *model = value; if (described) *described = text; diff --git a/clean/fsr/src/frontend.h b/clean/fsr/src/frontend.h index 5a946ab6..e33a9b74 100644 --- a/clean/fsr/src/frontend.h +++ b/clean/fsr/src/frontend.h @@ -107,6 +107,7 @@ constexpr uint32_t kBadFrameRun = 30; // value index + 1), which keep these two; test_frontend checks they equal kWgEntries[0] and [1]. constexpr uint64_t kWrongGpuProviderVersionId = 0x5747000000000001ull; // "WG", interface 1 constexpr uint64_t kWrongGpuKProviderVersionId = 0x5747000000000002ull; // same interface, Model K +constexpr uint64_t kWrongGpuLProviderVersionId = 0x5747000000000003ull; // same interface, Model L (#89) constexpr const char* kWrongGpuVersionName = "WrongGPU Model M"; // Any of WrongGPU's own listed entries (config.h, OwnEntryOfId: SR models and RR modes from the registry). @@ -132,6 +133,9 @@ constexpr const char* kWrongGpuListedNameM = "WrongGPU Model M##" WRONGGPU_LISTE #if WRONGGPU_MODEL_K // (model_k.h; without it the Model K id above is not WrongGPU's: an unknown override) constexpr const char* kWrongGpuListedNameK = "WrongGPU Model K##" WRONGGPU_LISTED_API_LEVEL; #endif +#if WRONGGPU_MODEL_L // (model_l.h; without it the Model L id above is not WrongGPU's: an unknown override) +constexpr const char* kWrongGpuListedNameL = "WrongGPU Model L##" WRONGGPU_LISTED_API_LEVEL; +#endif class FrontEnd { public: @@ -208,7 +212,8 @@ class FrontEnd { bool ActivateSplit(UpscaleContext& u, const WgUpscalerBackend* backend, const std::string& tag); // The model folder for `u`'s options (Platform::modelPlaces): appends ";model_dir=" when the model is found // in a place before the runtime's own default; nothing when runtime_options / WG_RUNTIME_OPTIONS name model_dir. - void ApplyModelDir(UpscaleContext& u, const std::string& tag); + // The model lookup (model_dir for the runtime). Returns why the create is refused (Model L without its file), or "". + std::string ApplyModelDir(UpscaleContext& u, const std::string& tag); // Custom slot (Config::customSlot): a create of the same upscaler with the same options failed earlier in this // session. Key: backend name + options. Guarded by mutex_. std::string FailureKey(const WgUpscalerBackend* backend, const UpscaleContext& u) const; diff --git a/clean/fsr/src/fsr30_hook.cpp b/clean/fsr/src/fsr30_hook.cpp index 9b625031..e6d70306 100644 --- a/clean/fsr/src/fsr30_hook.cpp +++ b/clean/fsr/src/fsr30_hook.cpp @@ -60,6 +60,9 @@ Hook::Hook(Platform platform, Config config, std::string tag) #if !WRONGGPU_MODEL_K // (config.h: model=K is dropped with one log line, Model M runs) if (const std::string note = IgnoreModelK(config_); !note.empty()) Log(note); #endif +#if !WRONGGPU_MODEL_L // (config.h: model=L is refused with one log line, Model M runs) + if (const std::string note = IgnoreModelL(config_); !note.empty()) Log(note); +#endif } Hook::~Hook() { // contexts the game never destroyed: the process is ending diff --git a/clean/fsr/src/model_l.h b/clean/fsr/src/model_l.h new file mode 100644 index 00000000..67158ab2 --- /dev/null +++ b/clean/fsr/src/model_l.h @@ -0,0 +1,13 @@ +// SPDX-License-Identifier: MIT +// Model L in this build of the front end (#89): CMake option WG_MODEL_L (default OFF) defines WRONGGPU_MODEL_L as 1 or +// 0. 1: the entry "WrongGPU Model L" in the hosted version list, its id, sr_model=L and model=L reach the runtime as its +// create option (the runtime must be built with Model L, WG_MODEL_L), the model lookup looks for \L\model.wgcm, +// and the overlay and the provider label name Model L. 0 (today's releases): none of that; model=L from wronggpu.ini or +// WG_RUNTIME_OPTIONS is dropped with one log line that says so (IgnoreModelL) and Model M runs; the Model L id is an +// unknown override like any other. Sources built without the definition get no Model L (unlike Model K: Model L is not +// in a release yet). +#pragma once + +#ifndef WRONGGPU_MODEL_L +#define WRONGGPU_MODEL_L 0 +#endif diff --git a/clean/fsr/src/overlay.cpp b/clean/fsr/src/overlay.cpp index b44f4150..39ae6ab7 100644 --- a/clean/fsr/src/overlay.cpp +++ b/clean/fsr/src/overlay.cpp @@ -1068,9 +1068,12 @@ UINT Layout(Renderer& r, Quad* quads, const View& v, bool panel, const Frames& f if (!panel) { // badge const float padX = 12 * s, h = float(bold.height) + 10 * s, dot = 8 * s; #if WRONGGPU_MODEL_K - const std::wstring modelName = v.upscaler.find("Model K") != std::string::npos ? L"Model K" : L"Model M"; + std::wstring modelName = v.upscaler.find("Model K") != std::string::npos ? L"Model K" : L"Model M"; #else - const std::wstring modelName = L"Model M"; + std::wstring modelName = L"Model M"; +#endif +#if WRONGGPU_MODEL_L + if (v.upscaler.find("Model L") != std::string::npos) modelName = L"Model L"; #endif std::wstring name = v.state == 1 ? (network ? modelName : L"active") : v.state == 2 ? L"stand-in" : v.state == 3 ? amdName : v.state == 4 ? L"unavailable" : amdName.empty() ? L"off \u00B7 AMD FSR" : L"off \u00B7 " + amdName; @@ -1116,6 +1119,9 @@ UINT Layout(Renderer& r, Quad* quads, const View& v, bool panel, const Frames& f if (v.state >= 0) { rows.push_back({L"Upscaler", v.state == 0 ? (amdName.empty() ? std::wstring(L"AMD FSR") : amdName) + L" (WrongGPU off)" : v.state == 4 ? L"Unavailable (frame failed)" : v.state == 3 ? amdName +#if WRONGGPU_MODEL_L + : network && v.upscaler.find("Model L") != std::string::npos ? L"Model L \u00B7 neural network" +#endif #if WRONGGPU_MODEL_K : network ? (v.upscaler.find("Model K") != std::string::npos ? L"Model K \u00B7 neural network" : L"Model M \u00B7 neural network") #else diff --git a/clean/fsr/src/provider_label.h b/clean/fsr/src/provider_label.h index 6323f2de..bc6d35fb 100644 --- a/clean/fsr/src/provider_label.h +++ b/clean/fsr/src/provider_label.h @@ -15,6 +15,10 @@ class ProviderLabel { #if WRONGGPU_MODEL_K if (s.upscaler.find("Model K") != std::string::npos) label = "WrongGPU Model K"; else +#endif +#if WRONGGPU_MODEL_L + if (s.upscaler.find("Model L") != std::string::npos) label = "WrongGPU Model L"; + else #endif if (s.upscaler.find("Model M") != std::string::npos) label = "WrongGPU Model M"; else label = "WrongGPU"; diff --git a/clean/fsr/src/status.h b/clean/fsr/src/status.h index 5bc0cfcb..06d9a697 100644 --- a/clean/fsr/src/status.h +++ b/clean/fsr/src/status.h @@ -7,6 +7,7 @@ #include #include "model_k.h" +#include "model_l.h" namespace wgfsr { diff --git a/clean/fsr/tests/test_frontend.cpp b/clean/fsr/tests/test_frontend.cpp index 14fabbb7..c2ff9000 100644 --- a/clean/fsr/tests/test_frontend.cpp +++ b/clean/fsr/tests/test_frontend.cpp @@ -1839,8 +1839,12 @@ static void TestHostedLookupReentry() { } static void TestRuntimeProviderName() { -#if WRONGGPU_MODEL_K +#if WRONGGPU_MODEL_K && WRONGGPU_MODEL_L + for (const char* model : {"M", "K", "L"}) { +#elif WRONGGPU_MODEL_K for (const char* model : {"M", "K"}) { +#elif WRONGGPU_MODEL_L // (the configured model=K is dropped, TestWithoutModelK) + for (const char* model : {"M", "L"}) { #else // (the configured model=K is dropped, TestWithoutModelK; the host's choice of Model M is all there is) for (const char* model : {"M"}) { #endif @@ -1849,10 +1853,11 @@ static void TestRuntimeProviderName() { Config c; c.hosted = true; // Deliberately configure the opposite default: the in-game choice must win. - c.runtimeOptions = std::string("model=") + (model[0] == 'K' ? "M" : "K"); + c.runtimeOptions = std::string("model=") + (model[0] == 'M' ? "K" : "M"); auto f = MakeFrontEnd(c); UpscaleCreate create(FFX_UPSCALE_ENABLE_HIGH_DYNAMIC_RANGE, true); - create.version.versionId = model[0] == 'K' ? kWrongGpuKProviderVersionId : kWrongGpuProviderVersionId; + create.version.versionId = model[0] == 'K' ? kWrongGpuKProviderVersionId + : model[0] == 'L' ? kWrongGpuLProviderVersionId : kWrongGpuProviderVersionId; ffxContext ctx = nullptr; CHECK(f->CreateContext(&ctx, &create.upscale.header, kMemCb) == FFX_API_RETURN_OK); auto frame = MakeDispatch(); @@ -1892,10 +1897,14 @@ static void TestRuntimeProviderName() { query.versionIds = ids; query.versionNames = names; CHECK(frontend.Query(nullptr, &query.header) == FFX_API_RETURN_OK); - // Model M alone: the list holds only the SR models (RR modes have their own box since 10-31) and this build has no - // Model K (OwnEntry(1) is null here; the test read it and crashed in a build without Model K). - CHECK(count == 1 && ids[0] == kWrongGpuProviderVersionId && std::strcmp(names[0], kWrongGpuListedNameM) == 0); - CHECK(OwnEntryCount() == 1 && OwnEntry(1) == nullptr); + // Model M alone (and Model L after it when built in): the list holds only the SR models (RR modes have their own + // box since 10-31) and this build has no Model K (OwnEntry(n) is null past the end; the test read it and crashed in + // a build without Model K). + CHECK(count == 1 + WRONGGPU_MODEL_L && ids[0] == kWrongGpuProviderVersionId && std::strcmp(names[0], kWrongGpuListedNameM) == 0); +#if WRONGGPU_MODEL_L + CHECK(ids[1] == kWrongGpuLProviderVersionId && std::strcmp(names[1], kWrongGpuListedNameL) == 0); +#endif + CHECK(OwnEntryCount() == 1 + WRONGGPU_MODEL_L && OwnEntry(1 + WRONGGPU_MODEL_L) == nullptr); #else CHECK(std::strcmp(RuntimeProviderName("model=K;network=fused", nullptr), "WrongGPU Model K") == 0); CHECK(std::strcmp(RuntimeProviderName("model = k", nullptr), "WrongGPU Model K") == 0); @@ -2199,7 +2208,7 @@ static void TestHostVersionHandling() { list.versionNames = names; CHECK(fe->Query(nullptr, &list.header) == FFX_API_RETURN_OK && count == kOwn + 2); CHECK(ids[0] == 0x5747000000000001ull && ids[kOwn] == g_versionIds[0] && ids[kOwn + 1] == g_versionIds[1]); - CHECK(kOwn == 1 || ids[1] == 0x5747000000000002ull); + CHECK(kOwn == 1 || ids[1] == (WRONGGPU_MODEL_K ? 0x5747000000000002ull : 0x5747000000000003ull)); CHECK(std::strcmp(names[kOwn], "3.1.5") == 0 && std::strcmp(names[kOwn + 1], "2.3.4") == 0); for (int i = 0; i < kOwn; ++i) { HostVersion selected; @@ -2214,8 +2223,11 @@ static void TestHostVersionHandling() { } CHECK(std::strcmp(names[0], "WrongGPU Model M##3.1.0") == 0); CHECK(WRONGGPU_MODEL_K == 0 || std::strcmp(names[1], "WrongGPU Model K##3.1.0") == 0); + CHECK(WRONGGPU_MODEL_L == 0 || std::strcmp(names[kOwn - 1], "WrongGPU Model L##3.1.0") == 0); // The selection still works by id, and a context's own provider name stays the label alone (the last SR model). - const uint64_t lastModel = WRONGGPU_MODEL_K ? kWrongGpuKProviderVersionId : kWrongGpuProviderVersionId; + const uint64_t lastModel = WRONGGPU_MODEL_L ? kWrongGpuLProviderVersionId + : WRONGGPU_MODEL_K ? kWrongGpuKProviderVersionId : kWrongGpuProviderVersionId; + const char* const lastName = WRONGGPU_MODEL_L ? "WrongGPU Model L" : WRONGGPU_MODEL_K ? "WrongGPU Model K" : "WrongGPU Model M"; UpscaleCreate own(FFX_UPSCALE_ENABLE_HIGH_DYNAMIC_RANGE, /*withOverride=*/true); own.version.versionId = lastModel; ffxContext ctx = nullptr; @@ -2223,7 +2235,7 @@ static void TestHostVersionHandling() { ffxQueryGetProviderVersion provider{}; provider.header.type = FFX_API_QUERY_DESC_TYPE_GET_PROVIDER_VERSION; CHECK(fe->Query(&ctx, &provider.header) == FFX_API_RETURN_OK && provider.versionId == lastModel && provider.versionName && - std::strcmp(provider.versionName, WRONGGPU_MODEL_K ? "WrongGPU Model K" : "WrongGPU Model M") == 0); + std::strcmp(provider.versionName, lastName) == 0); CHECK(fe->DestroyContext(&ctx, kMemCb) == FFX_API_RETURN_OK); g_hostedFrontEnd = nullptr; @@ -2497,7 +2509,7 @@ static void TestRegistryEntries() { CHECK(kWgEntries[1].id == kWrongGpuKProviderVersionId && std::strcmp(kWgEntries[1].label, kWrongGpuListedNameK) == 0); #endif CHECK(WG_ENTRY_COUNT == WG_SR_MODEL_COUNT); // no RR entries - CHECK(kOwn == WG_ENTRY_COUNT - (WRONGGPU_MODEL_K ? 0 : 1)); + CHECK(kOwn == WG_ENTRY_COUNT - (WRONGGPU_MODEL_K ? 0 : 1) - (WRONGGPU_MODEL_L ? 0 : 1)); CHECK(std::strcmp(EntryProviderName(kWgEntries[0]), "WrongGPU Model M") == 0); for (int i = 0; i < kOwn; ++i) { const WgEntryDef* e = OwnEntry(i); @@ -3153,6 +3165,157 @@ static void TestModelLookup() { CHECK(std::string(DefaultFsrSectionText()).find("model_dir =") != std::string::npos); } +// Model L in the model lookup (model_l.h): \L\model.wgcm, never Model M's or Model K's file; WithoutModel for L. +// The same in every build. +static void TestModelLookupL() { + const std::vector places = {{"G:\\game\\WrongGPU\\model", "the game's data folder", false}}; + auto has = [](std::vector files) { + return [files](const std::string& f) { return std::find(files.begin(), files.end(), f) != files.end(); }; + }; + ModelChoice m = ChooseModelDir(places, 'L', has({"G:\\game\\WrongGPU\\model\\L\\model.wgcm"})); + CHECK(m.index == 0 && m.option == ";model_dir=G:\\game\\WrongGPU\\model" && m.file == "G:\\game\\WrongGPU\\model\\L\\model.wgcm"); + m = ChooseModelDir(places, 'L', has({"G:\\game\\WrongGPU\\model\\model.wgcm", "G:\\game\\WrongGPU\\model\\K\\model.wgcm"})); + CHECK(m.index == -1 && m.option.empty() && m.searched.find("L\\model.wgcm (the game's data folder: not there)") != std::string::npos); + CHECK(ChooseModelDir(places, 'M', has({"G:\\game\\WrongGPU\\model\\model.wgcm"})).index == 0); + CHECK(ChooseModelDir(places, 'K', has({"G:\\game\\WrongGPU\\model\\K\\model.wgcm"})).index == 0); + bool removed = false; + CHECK(WithoutModel("a=1;model=l;b=2", 'L', &removed) == "a=1;b=2" && removed); + CHECK(WithoutModel("model=K; model = L ", 'L', &removed) == "model=K" && removed); + CHECK(WithoutModel("model=LL;model=M", 'L', &removed) == "model=LL;model=M" && !removed); + CHECK(WithoutModelK("model=L;model=k", &removed) == "model=L" && removed); +} + +#if WRONGGPU_MODEL_L +// A build with Model L (CMake WG_MODEL_L=ON): model=L names Model L; the model lookup passes its folder when +// \L\model.wgcm is there; without it the create is refused with the reason (what writes the file), the runtime +// is not asked, and AMD's upscaler takes over (fallback_to_amd, the default). +static void TestModelL() { + CHECK(std::strcmp(RuntimeProviderName("model=L", nullptr), "WrongGPU Model L") == 0); + CHECK(std::strcmp(RuntimeProviderName("model=M", "model=l"), "WrongGPU Model L") == 0); + CHECK(std::strcmp(RuntimeProviderName("model=L", "model=M"), "WrongGPU Model M") == 0); + CHECK(ModelBuiltIn(WG_SR_MODEL_L) && SrEntryOfModel(WG_SR_MODEL_L) && + SrEntryOfModel(WG_SR_MODEL_L)->id == kWrongGpuLProviderVersionId); + const std::vector places = {{"G:\\game\\WrongGPU\\model", "the game's data folder", false}}; + auto create = [&](const std::vector& files, size_t* amdAdded, int* runtimeCreates) { + Reset(); + g_resources[kOutput] = {dxgi::R16G16B16A16_FLOAT, 2560, 1440}; + g_modelOn = true; + g_modelPlaces = places; + g_modelFiles = files; + Config c; + c.runtimeOptions = "model=L"; + c.contextParkMs = 0; + auto f = MakeFrontEnd(c); + const size_t amd = g_amd.size(); + const int creates = g_createCalls; + UpscaleCreate u(FFX_UPSCALE_ENABLE_HIGH_DYNAMIC_RANGE); + ffxContext ctx = nullptr; + CHECK(f->CreateContext(&ctx, &u.upscale.header, kMemCb) == FFX_API_RETURN_OK && ctx); + *amdAdded = g_amd.size() - amd; + *runtimeCreates = g_createCalls - creates; + CHECK(f->DestroyContext(&ctx, kMemCb) == FFX_API_RETURN_OK); + }; + size_t amd = 0; + int creates = 0; + // only Model M's and Model K's files: refused, nothing created by the runtime + create({"G:\\game\\WrongGPU\\model\\model.wgcm", "G:\\game\\WrongGPU\\model\\K\\model.wgcm"}, &amd, &creates); + CHECK(creates == 0 && amd >= 1); + CHECK(CountLog("Model L is chosen but no converted Model L was found") >= 1); + CHECK(CountLog("WrongGPU.exe model convert --preset=L writes it") >= 1); + CHECK(CountLog("model: no converted Model L found") == 1); + // its file: passed to the runtime as model_dir with model=L + create({"G:\\game\\WrongGPU\\model\\L\\model.wgcm"}, &amd, &creates); + CHECK(creates == 1 && amd == 0); + CHECK(g_createOptions.find("model=L") != std::string::npos); + CHECK(g_createOptions.find(";model_dir=G:\\game\\WrongGPU\\model") != std::string::npos); + CHECK(CountLog("model: Model L from G:\\game\\WrongGPU\\model\\L\\model.wgcm (passed to the runtime as model_dir)") == 1); + CHECK(CountLog("Model L is chosen but") == 0); + // sr_model=L in the shared settings (wronggpu.ini [wronggpu]): Model L's runtime option, named Model L + Reset(); + g_resources[kOutput] = {dxgi::R16G16B16A16_FLOAT, 2560, 1440}; + g_menuOn = true; + g_menuValues[WG_OPT_SR_MODEL] = WG_SR_MODEL_L; + { + auto f = MakeFrontEnd(Config()); + UpscaleCreate u(FFX_UPSCALE_ENABLE_HIGH_DYNAMIC_RANGE); + ffxContext ctx = nullptr; + CHECK(f->CreateContext(&ctx, &u.upscale.header, kMemCb) == FFX_API_RETURN_OK && ctx); + CHECK(g_createOptions.find("model=L") != std::string::npos); + CHECK(CountLog("settings: sr_model=L (ini)") == 1); + ffxQueryGetProviderVersion q{}; + q.header.type = FFX_API_QUERY_DESC_TYPE_GET_PROVIDER_VERSION; + CHECK(f->Query(&ctx, &q.header) == FFX_API_RETURN_OK && q.versionName && std::strcmp(q.versionName, "WrongGPU Model L") == 0); + CHECK(q.versionId == kWrongGpuLProviderVersionId); + CHECK(f->DestroyContext(&ctx, kMemCb) == FFX_API_RETURN_OK); + } +} +#else +static void SetRuntimeOptionsEnv(const char* value) { +#ifdef _WIN32 + _putenv_s("WG_RUNTIME_OPTIONS", value); +#else + if (*value) setenv("WG_RUNTIME_OPTIONS", value, 1); + else unsetenv("WG_RUNTIME_OPTIONS"); +#endif +} + +// A build without Model L (the default): model=L from wronggpu.ini or the environment is refused with one log line +// that says why, and Model M runs; the Model L id is not WrongGPU's. +static void TestWithoutModelL() { + const char* const kNote = "is refused: Model L is not part of this build of the front end (CMake WG_MODEL_L); Model M is used"; + CHECK(std::strcmp(RuntimeProviderName("model=L", nullptr), "WrongGPU") == 0); + CHECK(!ModelBuiltIn(WG_SR_MODEL_L) && SrEntryOfModel(WG_SR_MODEL_L) == nullptr); + CHECK(!IsWrongGpuProvider(kWrongGpuLProviderVersionId)); + auto runs = [&](FrontEnd& f) { + ffxContext ctx = nullptr; + UpscaleCreate u(FFX_UPSCALE_ENABLE_HIGH_DYNAMIC_RANGE); + CHECK(f.CreateContext(&ctx, &u.upscale.header, kMemCb) == FFX_API_RETURN_OK && ctx); + const std::string options = g_createInfo.options ? g_createInfo.options : ""; + CHECK(options.find("model=L") == std::string::npos && options.find("model=l") == std::string::npos); + ffxQueryGetProviderVersion q{}; + q.header.type = FFX_API_QUERY_DESC_TYPE_GET_PROVIDER_VERSION; + CHECK(f.Query(&ctx, &q.header) == FFX_API_RETURN_OK && q.versionName && std::strcmp(q.versionName, "WrongGPU Model M") == 0); + CHECK(f.DestroyContext(&ctx, kMemCb) == FFX_API_RETURN_OK); + }; + const char* saved = std::getenv("WG_RUNTIME_OPTIONS"); + const std::string savedValue = saved ? saved : ""; + SetRuntimeOptionsEnv(""); + { // wronggpu.ini: runtime_options = ...;model=L + Reset(); + g_resources[kOutput] = {dxgi::R16G16B16A16_FLOAT, 2560, 1440}; + std::string warnings; + Config c = ParseConfig("runtime_options = timing_log=1;model=L\n", &warnings); + CHECK(warnings.empty() && c.runtimeOptions == "timing_log=1;model=L"); + auto f = MakeFrontEnd(c); + CHECK(CountLog(kNote) == 1 && CountLog("note: model=L (runtime_options in wronggpu.ini)") == 1); + runs(*f); + CHECK(CountLog(kNote) == 1); + } + { // the environment: dropped from the process environment before the runtime library reads it + Reset(); + g_resources[kOutput] = {dxgi::R16G16B16A16_FLOAT, 2560, 1440}; + SetRuntimeOptionsEnv("timing_log=1;model=L"); + auto f = MakeFrontEnd(Config()); + const char* now = std::getenv("WG_RUNTIME_OPTIONS"); + CHECK(now && std::strcmp(now, "timing_log=1") == 0); + CHECK(CountLog(kNote) == 1 && CountLog("note: model=L (WG_RUNTIME_OPTIONS)") == 1); + runs(*f); + } + SetRuntimeOptionsEnv(""); + { // sr_model=L in the shared settings (wronggpu.ini [wronggpu]): refused by name once, Model M runs + Reset(); + g_resources[kOutput] = {dxgi::R16G16B16A16_FLOAT, 2560, 1440}; + g_menuOn = true; + g_menuValues[WG_OPT_SR_MODEL] = WG_SR_MODEL_L; + auto f = MakeFrontEnd(Config()); + runs(*f); + runs(*f); + CHECK(CountLog((std::string("note: sr_model=L (ini) ") + kNote).c_str()) == 1); + } + SetRuntimeOptionsEnv(savedValue.c_str()); +} +#endif + int main() { TestCustomSlotFailedCreate(); TestCustomSlotFailureKeyHasSize(); @@ -3163,6 +3326,12 @@ int main() { TestCustomSlotDestroyPath(); TestHooksAfterCreate(); TestModelLookup(); + TestModelLookupL(); +#if WRONGGPU_MODEL_L + TestModelL(); +#else + TestWithoutModelL(); +#endif TestRegistryEntries(); TestUnsupportedFrames(); TestSplitBlocked(); diff --git a/clean/wgshared/EXTENDING.md b/clean/wgshared/EXTENDING.md index 2771aa46..f77b2cc3 100644 --- a/clean/wgshared/EXTENDING.md +++ b/clean/wgshared/EXTENDING.md @@ -47,12 +47,16 @@ A mode is a choice of kernel variants, one word per variant group (`head`, `inpu front end may be built without it) and append `"L"` to `options[id 0].values`. 2. The SR runtime must accept `model=L` (the front end passes `runtime_option` in the create options); the model's kernels live with the runtime. -3. Regenerate: `WG_SR_MODEL_L 2`, `kWgModelRows[2] = {"L", "model=L"}`, the entry `3.1.5 WrongGPU (Model L)` with id - `0x5747000000000003`. The SR entries come before the RR entries because entries are ordered by option id, so the - index of every RR entry in the host's list moves by one; that is why the host is given ids, not indexes, and why +3. Regenerate: `WG_SR_MODEL_L 2`, `kWgModelRows[2] = {"L", "model=L"}`, the entry `WrongGPU Model L##3.1.0` with id + `0x5747000000000003`. The version list holds only the SR models (the RR modes left it for their own box), so a new + model is appended after the released ones; the append-only check (`--previous`, the tests' `registry.prev.json`, + release 0.6.0's registry) refuses a model put before a released one. The host is given ids, not indexes, and OptiScaler.ini's `UpscalerIndex` is read against the list of the running build. 4. Front end: nothing, unless the model has a build flag; then one line in `ModelBuiltIn` (`clean/fsr/src/config.cpp`), - the single place that maps a model to its CMake option (Model K: `WG_MODEL_K`). + the single place that maps a model to its CMake option (Model K: `WG_MODEL_K`, `src/model_k.h`; Model L: + `WG_MODEL_L`, `src/model_l.h`, default OFF). A build without the model refuses `model=` and `sr_model=` by + name in its log and runs Model M. A model with its own model folder (K, L) also needs its letter in + `ChooseModelDir` (`\\model.wgcm`). ## 3. Add a game-interface version (example: 2.15) diff --git a/clean/wgshared/REGISTRY.md b/clean/wgshared/REGISTRY.md index 28a02987..e0f3cb60 100644 --- a/clean/wgshared/REGISTRY.md +++ b/clean/wgshared/REGISTRY.md @@ -1,14 +1,14 @@ # WrongGPU registry (generated) Generated by `clean/wgshared/tools/gen_registry.py` from `clean/wgshared/registry/registry.json`; do not edit. -Registry hash `0x9EC9B4F5` (FNV-1a-32). API level prefix of the version-list names: `3.1.0`. +Registry hash `0x9F5E68A9` (FNV-1a-32). API level prefix of the version-list names: `3.1.0`. How to add a mode, a model, a game-interface family or an API adapter: `EXTENDING.md`. ## Options (shared-block slots) | slot | key | type | values | default | readers | live / latch | env | contract | opt-in | what | |---|---|---|---|---|---|---|---|---|---|---| -| 0 | `sr_model` | choice | M \| K | M | sr-frontend, sr-runtime | latched / sr-create | WG_RUNTIME_MODEL | - | - | super-resolution model | +| 0 | `sr_model` | choice | M \| K \| L | M | sr-frontend, sr-runtime | latched / sr-create | WG_RUNTIME_MODEL | - | - | super-resolution model | | 1 | `rr_mode` | choice | exact \| accurate \| fast | accurate | rr-plugin, rr-runtime | live / next-frame | WG_RR_MODE | - | - | ray-reconstruction mode | | 2 | `rr_enabled` | onoff | 0 \| 1 | 1 | rr-plugin | latched / rr-create | - | yes | - | WrongGPU RR on/off (60.9 key 0) | | 3 | `rr_specular_motion_from_v` | onoff | 0 \| 1 | 0 | rr-plugin | live / next-frame | - | yes | yes | 62.4 / 52.7.1 SV = V (opt-in) | @@ -39,6 +39,7 @@ How to add a mode, a model, a game-interface family or an API adapter: `EXTENDIN |---|---|---|---|---| | 0 | `0x5747000000000001` | WrongGPU Model M##3.1.0 | WrongGPU M | `sr_model=M` | | 1 | `0x5747000000000002` | WrongGPU Model K##3.1.0 | WrongGPU K | `sr_model=K` | +| 2 | `0x5747000000000003` | WrongGPU Model L##3.1.0 | WrongGPU L | `sr_model=L` | ## SR models @@ -46,6 +47,7 @@ How to add a mode, a model, a game-interface family or an API adapter: `EXTENDIN |---|---|---|---| | M | `model=M` | clean/kernels (Model M) | - | | K | `model=K` | clean/k | WRONGGPU_MODEL_K | +| L | `model=L` | clean/l | WRONGGPU_MODEL_L | ## RR modes (kernel-variant words) diff --git a/clean/wgshared/include/wg_registry_gen.h b/clean/wgshared/include/wg_registry_gen.h index 2ba18a71..c228a4e0 100644 --- a/clean/wgshared/include/wg_registry_gen.h +++ b/clean/wgshared/include/wg_registry_gen.h @@ -13,7 +13,7 @@ extern "C" { #endif #define WG_REGISTRY_SCHEMA "wronggpu.registry.v1" -#define WG_REGISTRY_HASH 0x9EC9B4F5u +#define WG_REGISTRY_HASH 0x9F5E68A9u #define WG_API_LEVEL_PREFIX "3.1.0" /* ---- option slots (shared block index) ---- */ @@ -51,7 +51,8 @@ extern "C" { /* ---- choice values ---- */ #define WG_SR_MODEL_M 0 #define WG_SR_MODEL_K 1 -#define WG_SR_MODEL_COUNT 2 +#define WG_SR_MODEL_L 2 +#define WG_SR_MODEL_COUNT 3 #define WG_RR_MODE_EXACT 0 #define WG_RR_MODE_ACCURATE 1 @@ -79,12 +80,12 @@ typedef struct WgOptionDef { const char* doc; } WgOptionDef; -static const char* const kWgSrModelNames[WG_SR_MODEL_COUNT] = {"M", "K"}; +static const char* const kWgSrModelNames[WG_SR_MODEL_COUNT] = {"M", "K", "L"}; static const char* const kWgRrModeNames[WG_RR_MODE_COUNT] = {"exact", "accurate", "fast"}; static const char* const kWgEntrySourceNames[WG_ENTRY_SOURCE_COUNT] = {"versions", "folders"}; static const WgOptionDef kWgOptions[WG_OPT_COUNT] = { - {0, "sr_model", WG_KIND_CHOICE, WG_SR_MODEL_M, 0, 1, WG_READER_SR_FRONTEND | WG_READER_SR_RUNTIME, 0, WG_LATCH_SR_CREATE, 0, 0, "wronggpu", "WG_RUNTIME_MODEL", kWgSrModelNames, "super-resolution model"}, + {0, "sr_model", WG_KIND_CHOICE, WG_SR_MODEL_M, 0, 2, WG_READER_SR_FRONTEND | WG_READER_SR_RUNTIME, 0, WG_LATCH_SR_CREATE, 0, 0, "wronggpu", "WG_RUNTIME_MODEL", kWgSrModelNames, "super-resolution model"}, {1, "rr_mode", WG_KIND_CHOICE, WG_RR_MODE_ACCURATE, 0, 2, WG_READER_RR_PLUGIN | WG_READER_RR_RUNTIME, 1, WG_LATCH_NEXT_FRAME, 0, 0, "wronggpu", "WG_RR_MODE", kWgRrModeNames, "ray-reconstruction mode"}, {2, "rr_enabled", WG_KIND_ONOFF, 1, 0, 1, WG_READER_RR_PLUGIN, 0, WG_LATCH_RR_CREATE, 1, 0, "wronggpu", "", 0, "WrongGPU RR on/off (60.9 key 0)"}, {3, "rr_specular_motion_from_v", WG_KIND_ONOFF, 0, 0, 1, WG_READER_RR_PLUGIN, 1, WG_LATCH_NEXT_FRAME, 1, 1, "wronggpu", "", 0, "62.4 / 52.7.1 SV = V (opt-in)"}, @@ -118,10 +119,11 @@ static const WgTextOptionDef kWgTextOptions[WG_TEXT_OPT_COUNT] = { /* ---- version-list entries (what OptiScaler shows under the WrongGPU folder), in list order ---- */ typedef struct WgEntryDef { uint64_t id; uint32_t slot; int32_t value; const char* label; const char* folder_label; } WgEntryDef; #define WG_ENTRY_ID_BASE 0x5747000000000000ull -#define WG_ENTRY_COUNT 2 +#define WG_ENTRY_COUNT 3 static const WgEntryDef kWgEntries[WG_ENTRY_COUNT] = { {0x5747000000000001ull, WG_OPT_SR_MODEL, WG_SR_MODEL_M, "WrongGPU Model M##" WG_API_LEVEL_PREFIX, "WrongGPU M"}, {0x5747000000000002ull, WG_OPT_SR_MODEL, WG_SR_MODEL_K, "WrongGPU Model K##" WG_API_LEVEL_PREFIX, "WrongGPU K"}, + {0x5747000000000003ull, WG_OPT_SR_MODEL, WG_SR_MODEL_L, "WrongGPU Model L##" WG_API_LEVEL_PREFIX, "WrongGPU L"}, }; /* ---- RR modes: kernel-variant words per group (the runtime maps words to its variant bits) ---- */ @@ -145,7 +147,7 @@ static const WgModeRow kWgModeRows[WG_RR_MODE_COUNT] = { /* ---- SR models ---- */ typedef struct WgModelRow { const char* name; const char* runtime_option; } WgModelRow; -static const WgModelRow kWgModelRows[WG_SR_MODEL_COUNT] = {{"M", "model=M"}, {"K", "model=K"}}; +static const WgModelRow kWgModelRows[WG_SR_MODEL_COUNT] = {{"M", "model=M"}, {"K", "model=K"}, {"L", "model=L"}}; #ifdef __cplusplus } diff --git a/clean/wgshared/include/wg_registry_ini_gen.h b/clean/wgshared/include/wg_registry_ini_gen.h index 90008ae6..5b2e99f5 100644 --- a/clean/wgshared/include/wg_registry_ini_gen.h +++ b/clean/wgshared/include/wg_registry_ini_gen.h @@ -5,7 +5,7 @@ #ifndef WG_REGISTRY_INI_GEN_H #define WG_REGISTRY_INI_GEN_H -#define WG_REGISTRY_INI_HASH 0x9EC9B4F5u +#define WG_REGISTRY_INI_HASH 0x9F5E68A9u static const char kWgDefaultIniText[] = "# WrongGPU settings: the one settings file of every WrongGPU DLL (\\WrongGPU\\wronggpu.ini).\r\n" "# Delete this file to restore the defaults. The [wronggpu] section is generated from WrongGPU's registry\r\n" @@ -13,8 +13,8 @@ static const char kWgDefaultIniText[] = "# menu is written back here, so the next start without OptiScaler keeps it. A process environment variable\r\n" "# named on a key's comment overrides the key for that process.\r\n" "[wronggpu]\r\n" - "# sr_model: super-resolution model. Values: M | K. Default: M. Read by: sr-frontend, sr-runtime; applied at the next\r\n" - "# SR create. Environment: WG_RUNTIME_MODEL.\r\n" + "# sr_model: super-resolution model. Values: M | K | L. Default: M. Read by: sr-frontend, sr-runtime; applied at the\r\n" + "# next SR create. Environment: WG_RUNTIME_MODEL.\r\n" "sr_model = M\r\n" "# rr_mode: ray-reconstruction mode. Values: exact | accurate | fast. Default: accurate. Read by: rr-plugin,\r\n" "# rr-runtime; applied at the next frame. Environment: WG_RR_MODE.\r\n" diff --git a/clean/wgshared/ini/wronggpu.default.ini b/clean/wgshared/ini/wronggpu.default.ini index 75889fa4..c9383085 100644 --- a/clean/wgshared/ini/wronggpu.default.ini +++ b/clean/wgshared/ini/wronggpu.default.ini @@ -4,8 +4,8 @@ # menu is written back here, so the next start without OptiScaler keeps it. A process environment variable # named on a key's comment overrides the key for that process. [wronggpu] -# sr_model: super-resolution model. Values: M | K. Default: M. Read by: sr-frontend, sr-runtime; applied at the next -# SR create. Environment: WG_RUNTIME_MODEL. +# sr_model: super-resolution model. Values: M | K | L. Default: M. Read by: sr-frontend, sr-runtime; applied at the +# next SR create. Environment: WG_RUNTIME_MODEL. sr_model = M # rr_mode: ray-reconstruction mode. Values: exact | accurate | fast. Default: accurate. Read by: rr-plugin, # rr-runtime; applied at the next frame. Environment: WG_RR_MODE. diff --git a/clean/wgshared/registry/registry.json b/clean/wgshared/registry/registry.json index a3bbec58..0124a638 100644 --- a/clean/wgshared/registry/registry.json +++ b/clean/wgshared/registry/registry.json @@ -11,7 +11,7 @@ {"id": "rr", "label": "WrongGPU RR", "kind": "ray-reconstruction", "choice_option": "rr_mode"} ], "options": [ - {"id": 0, "key": "sr_model", "type": "choice", "values": ["M", "K"], "default": "M", + {"id": 0, "key": "sr_model", "type": "choice", "values": ["M", "K", "L"], "default": "M", "readers": ["sr-frontend", "sr-runtime"], "live": false, "latch": "sr-create", "ini_section": "wronggpu", "env": "WG_RUNTIME_MODEL", "menu": {"list": "versions", "label": "WrongGPU Model {value}", "folder_label": "WrongGPU {value}"}, "values_from": "models", "doc": "super-resolution model"}, @@ -54,7 +54,8 @@ ], "models": [ {"id": "M", "option": "sr_model", "runtime_option": "model=M", "kernels": "clean/kernels (Model M)"}, - {"id": "K", "option": "sr_model", "runtime_option": "model=K", "kernels": "clean/k", "build_flag": "WRONGGPU_MODEL_K"} + {"id": "K", "option": "sr_model", "runtime_option": "model=K", "kernels": "clean/k", "build_flag": "WRONGGPU_MODEL_K"}, + {"id": "L", "option": "sr_model", "runtime_option": "model=L", "kernels": "clean/l", "build_flag": "WRONGGPU_MODEL_L"} ], "variants": [ {"group": "head", "words": ["exact", "relaxed"]}, diff --git a/clean/wgshared/tests/data/registry.prev.json b/clean/wgshared/tests/data/registry.prev.json index c7df7507..a3bbec58 100644 --- a/clean/wgshared/tests/data/registry.prev.json +++ b/clean/wgshared/tests/data/registry.prev.json @@ -17,7 +17,7 @@ "values_from": "models", "doc": "super-resolution model"}, {"id": 1, "key": "rr_mode", "type": "choice", "values": ["exact", "accurate", "fast"], "default": "accurate", "readers": ["rr-plugin", "rr-runtime"], "live": true, "latch": "next-frame", "ini_section": "wronggpu", "env": "WG_RR_MODE", - "menu": {"list": "versions", "label": "WrongGPU RR {value}", "folder_label": "WrongGPU RR {value}"}, + "menu": {"list": "panel", "label": "{value}"}, "values_from": "modes", "doc": "ray-reconstruction mode"}, {"id": 2, "key": "rr_enabled", "type": "onoff", "default": 1, "readers": ["rr-plugin"], "live": false, "latch": "rr-create", "ini_section": "wronggpu", "contract": true, "doc": "WrongGPU RR on/off (60.9 key 0)"}, @@ -35,12 +35,18 @@ "latch": "start", "ini_section": "wronggpu", "doc": "hook a game-interface family whose layouts are not confirmed"}, {"id": 9, "key": "entry_source", "type": "choice", "values": ["versions", "folders"], "default": "versions", "readers": ["sr-frontend"], "live": false, "latch": "start", "ini_section": "wronggpu", - "doc": "how the host offers the choices: one version list, or one folder per choice"} + "doc": "how the host offers the choices: one version list, or one folder per choice"}, + {"id": 10, "key": "rr_exact_allowed", "type": "onoff", "default": 0, "readers": ["rr-plugin"], "live": false, + "latch": "start", "ini_section": "wronggpu", + "doc": "exact RR mode offered in the menu panel (turned on in the launcher; without it rr_mode=exact runs accurate)"}, + {"id": 11, "key": "rr_hit_distance_filter", "type": "onoff", "default": 0, "readers": ["rr-plugin"], "live": true, + "latch": "next-frame", "ini_section": "wronggpu", "contract": true, "opt_in": true, + "doc": "52.7.2 deviation (opt-in): the specular hit distance is the median of its 1x4 pixel run (lone missed-ray outliers make reflection speckles in motion)"} ], "text_options": [ {"key": "rr_model", "default": "", "readers": ["rr-plugin", "rr-runtime"], "env": "WG_RR_MODEL", "doc": "path of the RR model file"}, {"key": "sr_runtime_dll", "default": "wronggpu_runtime.dll", "readers": ["sr-frontend"], "doc": "SR runtime library in the data folder"}, - {"key": "rr_runtime_dll", "default": "wronggpu_rr_runtime.dll", "readers": ["rr-plugin"], "doc": "RR runtime library in the data folder"}, + {"key": "rr_runtime_dll", "default": "wronggpu_runtime.dll", "readers": ["rr-plugin"], "doc": "RR runtime library (since 0.6.0 part of wronggpu_runtime.dll, Model M and RR in one DLL)"}, {"key": "diag_env_1", "default": "", "readers": ["rr-plugin"], "doc": "WG_RR_= handed to the RR runtime (diagnostics)"}, {"key": "diag_env_2", "default": "", "readers": ["rr-plugin"], "doc": ""}, {"key": "diag_env_3", "default": "", "readers": ["rr-plugin"], "doc": ""}, @@ -59,7 +65,7 @@ ], "modes": [ {"id": "exact", "option": "rr_mode", "head": "exact", "input": "exact", "body": "exact", "output": "default", "resolve": "exact"}, - {"id": "accurate", "option": "rr_mode", "head": "exact", "input": "exact", "body": "relaxed", "output": "default", "resolve": "exact"}, + {"id": "accurate", "option": "rr_mode", "head": "relaxed", "input": "exact", "body": "relaxed", "output": "default", "resolve": "exact"}, {"id": "fast", "option": "rr_mode", "head": "relaxed", "input": "lite", "body": "relaxed", "output": "fast", "resolve": "hw"} ], "gi_layouts": ["A10-2.7", "A10-2.14"], diff --git a/clean/wgshared/tests/test_dummy_extension.py b/clean/wgshared/tests/test_dummy_extension.py index 060fab4c..f471e6b9 100644 --- a/clean/wgshared/tests/test_dummy_extension.py +++ b/clean/wgshared/tests/test_dummy_extension.py @@ -58,7 +58,7 @@ def main(): check("#define WG_RR_MODE_DUMMY 3" in h, "WG_RR_MODE_DUMMY = 3") check("#define WG_RR_MODE_COUNT 4" in h, "WG_RR_MODE_COUNT 4") check('kWgRrModeNames[WG_RR_MODE_COUNT] = {"exact", "accurate", "fast", "dummy"};' in h, "mode names") - check("#define WG_ENTRY_COUNT 2" in h, "still the two SR entries") + check("#define WG_ENTRY_COUNT 3" in h, "still the three SR entries") check("0x5747000000000104" not in h and "WrongGPU RR dummy" not in h, "no version-list entry for the new mode") rows = re.findall(r'^ \{"(\w+)",\s+(.*)\},$', h, re.M) words = {name: re.sub(r"\s+", " ", rest) for name, rest in rows} diff --git a/clean/wgshared/tests/test_gen_registry.py b/clean/wgshared/tests/test_gen_registry.py index 1d7be71a..18372ccf 100644 --- a/clean/wgshared/tests/test_gen_registry.py +++ b/clean/wgshared/tests/test_gen_registry.py @@ -6,7 +6,8 @@ - the committed outputs equal a fresh generation; - the generated header reproduces the initial i15 interface header (tests/data/wg_registry_gen.initial.h) exactly, except the header comment and WG_REGISTRY_HASH; -- ids are append-only against the previous registry (tests/data/registry.prev.json), entry ids ...0001/...0002 kept; +- ids are append-only against the previous registry (tests/data/registry.prev.json: release 0.6.0's), entry ids + ...0001/...0002 kept and Model L's ...0003 only appended after them; - every refusal rule fires (id gap, duplicate id, renumbering, removed / reordered values, changed entry label or API prefix, a first label without the API prefix, a 4.x prefix, an unknown variant word, overlapping families, an unknown layout, test rows into the committed folder); @@ -91,7 +92,7 @@ def main(): "every slot id and SR entry of the initial i15 header kept") check("0x5747000000000101ull" not in outs["header"], "no RR entry in the version list") for needle in ["#define WG_OPT_SR_MODEL 0", "#define WG_OPT_ENTRY_SOURCE 9", "#define WG_OPT_RR_EXACT_ALLOWED 10", - "#define WG_OPT_RR_HIT_DISTANCE_FILTER 11", "#define WG_OPT_COUNT 12", "#define WG_ENTRY_COUNT 2", + "#define WG_OPT_RR_HIT_DISTANCE_FILTER 11", "#define WG_OPT_COUNT 12", "#define WG_ENTRY_COUNT 3", "#define WG_RR_MODE_EXACT 0", "#define WG_RR_MODE_ACCURATE 1", "#define WG_RR_MODE_FAST 2", "static const uint32_t kWgContractSlots[WG_CONTRACT_COUNT] = {2, 3, 4, 5, 6, 11};", '#define WG_API_LEVEL_PREFIX "3.1.0"', @@ -107,11 +108,13 @@ def main(): # 4. entries entries = gen.entries_of(merged) - # only the SR models: the RR modes are a box of their own in the RR plugin's menu tab (menu list "panel") - check([e["id"] for e in entries] == [0x5747000000000001, 0x5747000000000002], "entry ids") + # only the SR models: the RR modes are a box of their own in the RR plugin's menu tab (menu list "panel"); Model L + # (#89) appended after M and K (a front end offers it only when built with it: clean/fsr WG_MODEL_L) + check([e["id"] for e in entries] == [0x5747000000000001, 0x5747000000000002, 0x5747000000000003], "entry ids") check(entries[0]["label"] == "WrongGPU Model M##3.1.0" and entries[1]["label"] == "WrongGPU Model K##3.1.0", - "the two entries keep today's names") - check([e["folder_label"] for e in entries] == ["WrongGPU M", "WrongGPU K"], "folder labels") + "the two released entries keep their names") + check(entries[2]["label"] == "WrongGPU Model L##3.1.0", "Model L's entry") + check([e["folder_label"] for e in entries] == ["WrongGPU M", "WrongGPU K", "WrongGPU L"], "folder labels") check(merged["options"][1]["menu"]["list"] == "panel", "rr_mode is offered in the panel, not the version list") # 5. refusals @@ -133,7 +136,12 @@ def main(): check(refused(r, prev, expect="changed or moved"), "refuses entries that change place (models gone from the front)") r = copy.deepcopy(reg); r["options"][1]["menu"]["list"] = "sidebar" check(refused(r, expect="not one of versions, panel"), "refuses an unknown menu list") - check(not gen.append_only_errors(load(prev), reg), "the RR entries may leave the end of the list (models keep 0 and 1)") + check(not gen.append_only_errors(load(prev), reg), "Model L appended after the released entries (M and K keep 0 and 1)") + r = copy.deepcopy(reg); r["options"][0]["values"] = ["M", "L", "K"]; r["models"] = [r["models"][0], r["models"][2], + r["models"][1]] + check(refused(r, prev, expect="changed or moved"), "refuses a new model put before a released one") + r = copy.deepcopy(reg); r["options"][0]["values"] = ["M", "K"]; r["models"] = r["models"][:2] + check(not gen.append_only_errors(load(prev), r), "the last entry may leave the end of the list") r = copy.deepcopy(reg); r["api_level_prefix"] = "v3" check(refused(r, expect="not an a.b.c version"), "refuses an API prefix that is not a version") r = copy.deepcopy(reg); r["api_level_prefix"] = "4.0.0"