mirror of
https://github.com/valentderah/totk-pc-recomp.git
synced 2026-11-22 13:05:57 +00:00
Load the NGX core through the platform layer, so vk_dlaa.c has no Win32 calls
tools/check_platform.py failed on vk_dlaa.c: it read the NGX core's folder from the registry, loaded it with LoadLibraryA and GetProcAddress and named the executable's folder with GetModuleFileNameW. platform.h gets plat_ngx_core_path (the registry folder plus _nvngx.dll on Windows, libnvidia-ngx.so.1 on Linux), plat_exe_dir_wide (the folder as NGX's wchar_t string; the UTF-8 to UTF-32 conversion moves from vk_dlaa.c to linux.c) and plat_lib_error, and the core loads through plat_lib_open and plat_lib_sym on both hosts. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
da86c39121
commit
cc4df7d140
4 files changed
+73
-54
No files matched your search
@@ -1456,6 +1456,41 @@ int plat_open_folder(const char *path) {
|
||||
void *plat_lib_open(const char *name) { return dlopen(name, RTLD_NOW | RTLD_LOCAL); }
|
||||
void *plat_lib_sym(void *lib, const char *name) { return lib ? dlsym(lib, name) : NULL; }
|
||||
|
||||
void plat_lib_error(char *out, size_t cap) {
|
||||
const char *e = dlerror();
|
||||
snprintf(out, cap, "%s", e ? e : "unknown error");
|
||||
}
|
||||
|
||||
int plat_ngx_core_path(char *out, size_t cap) { return snprintf(out, cap, "libnvidia-ngx.so.1") < (int)cap; }
|
||||
|
||||
// UTF-8 to UTF-32 wchar_t, without the C library's locale (the runtime never sets one, so mbstowcs would stop at the
|
||||
// first non-ASCII byte). Returns 0 on malformed input or when out has no room.
|
||||
static int utf8_to_wide(const char *in, wchar_t *out, size_t cap) {
|
||||
const unsigned char *u = (const unsigned char *)in;
|
||||
size_t n = 0;
|
||||
while (*u) {
|
||||
unsigned c = *u++, more = c < 0x80 ? 0 : c >= 0xF0 ? 3 : c >= 0xE0 ? 2 : c >= 0xC0 ? 1 : 4;
|
||||
if (more == 4) return 0;
|
||||
if (more) c &= 0x3F >> more;
|
||||
for (unsigned k = 0; k < more; k++, u++) {
|
||||
if ((*u & 0xC0) != 0x80) return 0;
|
||||
c = c << 6 | (*u & 0x3F);
|
||||
}
|
||||
if (n + 1 >= cap) return 0;
|
||||
out[n++] = (wchar_t)c;
|
||||
}
|
||||
out[n] = 0;
|
||||
return 1;
|
||||
}
|
||||
|
||||
int plat_exe_dir_wide(wchar_t *out, size_t cap) {
|
||||
char dir[PLAT_PATH_MAX];
|
||||
char *cut = plat_exe_path(dir, sizeof dir) ? plat_last_sep(dir) : NULL;
|
||||
if (!cut) return 0;
|
||||
cut[1] = 0;
|
||||
return utf8_to_wide(dir, out, cap);
|
||||
}
|
||||
|
||||
// ---- machine load: /proc/stat and /proc/self/stat for the CPU, hwmon for the temperature, the amdgpu sysfs files of
|
||||
// the render device for the GPU.
|
||||
|
||||
|
||||
Reference in new issue
Block a user