ASI add-on for existing OptiScaler installs
Add an optional D4R_INSTALL_MODE=asi release (d4r-<version>-asi.zip) holding only d4r.asi and a companion d4r/ folder, to drop into an existing OptiScaler plugin directory. - Shim: export InitializeASI. It identifies OptiScaler by its PE export name to find the active INI, then launches d4r-setup.exe out of process (no GPU or network work under the loader lock). The .asi build loads its runtime and config from the companion d4r/ folder. - tools/d4r_asi_setup.cpp: native helper. It waits for the game to exit, installs the D3D12 wrapper and the private d4r12core.dll beside the EXE, and merges the NGX route into the loader's INI (including GE-Proton's prefix-local INI) with backups. Unchanged launches do nothing. It skips Proton helpers and background utilities and runs setup for one plugin install at a time. - scripts/private_d3d12_core.py: points vkd3d's d3d12.dll forwarder at d4r12core.dll without moving code addresses. - install.sh runs from inside the ASI's d4r/ as well as the proxy release root. d4r-check.sh checks ASI installs (loader, plugin path, LoadAsiPlugins, HookOriginalNvngxOnly, Wine drive paths). - Packaging, build script, docs, ASI_README.txt and tests.
This commit is contained in:
1 parent
85175e0b27
commit
d5c8be25c8
16 files changed
+1091
-39
No files matched your search
@@ -0,0 +1,66 @@
|
||||
// CPU-only smoke probe for the ASI loader contract. No NGX/CUDA/GPU initialization.
|
||||
#include <windows.h>
|
||||
#include <cstdio>
|
||||
#include <cstdlib>
|
||||
#include <string>
|
||||
|
||||
int wmain(int argc, wchar_t** argv)
|
||||
{
|
||||
if (argc != 3 && argc != 4)
|
||||
return 2; // ASI absolute path, expected runtime directory
|
||||
SetErrorMode(SEM_FAILCRITICALERRORS | SEM_NOGPFAULTERRORBOX);
|
||||
HMODULE optiscaler = nullptr;
|
||||
if (argc == 4)
|
||||
{
|
||||
optiscaler = LoadLibraryW(argv[3]);
|
||||
if (!optiscaler || !GetModuleHandleW(argv[1]) ||
|
||||
GetEnvironmentVariableW(L"D4R_NVCUDA_BRIDGE", nullptr, 0) == 0)
|
||||
{
|
||||
std::fprintf(stderr, "OptiScaler did not initialize the ASI: %lu\n", GetLastError());
|
||||
return 8;
|
||||
}
|
||||
}
|
||||
HMODULE plugin = LoadLibraryW(argv[1]);
|
||||
if (!plugin)
|
||||
{
|
||||
std::fprintf(stderr, "LoadLibrary failed: %lu\n", GetLastError());
|
||||
return 3;
|
||||
}
|
||||
for (const char* name : {"InitializeASI", "NVSDK_NGX_D3D12_Init", "NVSDK_NGX_VULKAN_Init",
|
||||
"NVSDK_NGX_D3D12_CreateFeature", "NVSDK_NGX_VULKAN_CreateFeature"})
|
||||
if (!GetProcAddress(plugin, name))
|
||||
{
|
||||
std::fprintf(stderr, "Missing export: %s\n", name);
|
||||
return 4;
|
||||
}
|
||||
auto initialize = reinterpret_cast<void (*)()>(GetProcAddress(plugin, "InitializeASI"));
|
||||
initialize();
|
||||
initialize(); // ASI initialization is idempotent.
|
||||
struct Expected { const wchar_t* name; const wchar_t* suffix; };
|
||||
for (const auto& expected : {Expected{L"D4R_NGX_FEATURE_DIR", L""},
|
||||
Expected{L"D4R_NVCUDA_BRIDGE", L"\\nvcuda.dll"},
|
||||
Expected{L"D4R_NGX_CORE", L"\\ngx\\_nvngx.dll"},
|
||||
Expected{L"D4R_SHIM_LOG", L"\\d4r_nvngx.log"}})
|
||||
{
|
||||
wchar_t value[MAX_PATH] = {};
|
||||
GetEnvironmentVariableW(expected.name, value, MAX_PATH);
|
||||
if (std::wstring(value) != std::wstring(argv[2]) + expected.suffix)
|
||||
{
|
||||
std::fwprintf(stderr, L"Wrong %ls: %ls\n", expected.name, value);
|
||||
return 5;
|
||||
}
|
||||
}
|
||||
HMODULE backend = LoadLibraryW(argv[1]);
|
||||
if (backend != plugin)
|
||||
return 6;
|
||||
if (GetModuleHandleA("nvcuda.dll") || GetModuleHandleA("_nvngx.dll"))
|
||||
return 7; // The ASI loader must not trigger GPU initialization.
|
||||
char delay[16] = {};
|
||||
if (GetEnvironmentVariableA("D4R_ASI_PROBE_PAUSE_MS", delay, sizeof(delay)))
|
||||
Sleep(static_cast<DWORD>(std::strtoul(delay, nullptr, 10)));
|
||||
FreeLibrary(backend);
|
||||
FreeLibrary(plugin);
|
||||
if (optiscaler) FreeLibrary(optiscaler);
|
||||
std::puts("ASI loader contract passed; backend reused, runtime located, GPU initialization deferred");
|
||||
return 0;
|
||||
}
|
||||
Reference in new issue
Block a user