mirror of
https://github.com/Droid-Deck/DroidDeck.git
synced 2026-12-05 12:35:42 +00:00
Port of the NeuralScale layer (previous commit) for DroidDeck: - Layer VK_LAYER_DROIDDECK_upscale, library libVkLayer_droiddeck_upscale.so, implicit manifest template (DROIDDECK_UPSCALE=1 / DROIDDECK_UPSCALE_DISABLE=1). - Settings read as DROIDDECK_UPSCALE_<KEY>, then WINLATOR_FSR4_<KEY>. - No hardcoded com.winlator.cmod data dir; without a dir frames get the blit fallback. - Compiled NPU graph caches go to <dir>/<htp arch>/ (v79/v81 from HTP_ARCH, the SoC properties or the mapped QNN stub) instead of <dir>/v81/. - The arch stub is loaded from the QNN library search list first, so NATIVELIB_DIR is enough without LD_LIBRARY_PATH. - driverID/driverName are only rewritten with GPU_SPOOF word "1"; SPOOF_DLSS=1 alone reports RTX vendor/device IDs. - APK build via app/src/main/cpp/CMakeLists.txt; glibc build for the PRoot guest (build-glibc.sh, DD_UPSCALE_NO_ANDROID: QNN stubs, stderr log) in the runtime recipe, installed to usr/local/lib/droiddeck-upscale-layer/. - -Bsymbolic so the exported vkGetInstanceProcAddr is not interposed by a libvulkan in the global scope. - Pack scripts take their paths as arguments. Seam protocol, buffer sizes, magic values and backend IDs are unchanged.
57 lines
1.7 KiB
C
57 lines
1.7 KiB
C
// DroidDeck glue for the upscaler layer: environment lookup and logging.
|
|
//
|
|
// Every setting is read as DROIDDECK_UPSCALE_<KEY> first and WINLATOR_FSR4_<KEY> second, so
|
|
// launchers written for the upstream layer keep working. Empty values count as unset.
|
|
//
|
|
// Android builds log to logcat. DD_UPSCALE_NO_ANDROID builds (glibc, PRoot guest) log to stderr.
|
|
#pragma once
|
|
|
|
#include <stdio.h>
|
|
#include <stdlib.h>
|
|
|
|
static inline const char *dd_upscale_env(const char *key) {
|
|
char name[96];
|
|
snprintf(name, sizeof name, "DROIDDECK_UPSCALE_%s", key);
|
|
const char *v = getenv(name);
|
|
if (v && *v) return v;
|
|
snprintf(name, sizeof name, "WINLATOR_FSR4_%s", key);
|
|
v = getenv(name);
|
|
return (v && *v) ? v : NULL;
|
|
}
|
|
|
|
// Data dir with the SPIR-V passes, weights and QNN files. NULL when no launcher set one.
|
|
static inline const char *dd_upscale_dir(void) {
|
|
const char *dir = dd_upscale_env("DIR");
|
|
if (!dir) {
|
|
dir = getenv("DM_FSR4_DIR");
|
|
if (dir && !*dir) dir = NULL;
|
|
}
|
|
return dir;
|
|
}
|
|
|
|
#ifdef DD_UPSCALE_NO_ANDROID
|
|
#include <stdarg.h>
|
|
|
|
#define DD_LOG_INFO 4
|
|
#define DD_LOG_WARN 5
|
|
#define DD_LOG_ERROR 6
|
|
|
|
__attribute__((format(printf, 3, 4)))
|
|
static inline int dd_upscale_log(int prio, const char *tag, const char *fmt, ...) {
|
|
char msg[1024];
|
|
va_list ap;
|
|
va_start(ap, fmt);
|
|
vsnprintf(msg, sizeof msg, fmt, ap);
|
|
va_end(ap);
|
|
const char lvl = prio >= DD_LOG_ERROR ? 'E' : (prio == DD_LOG_WARN ? 'W' : 'I');
|
|
return fprintf(stderr, "%c/%s: %s\n", lvl, tag, msg);
|
|
}
|
|
#else
|
|
#include <android/log.h>
|
|
|
|
#define DD_LOG_INFO ANDROID_LOG_INFO
|
|
#define DD_LOG_WARN ANDROID_LOG_WARN
|
|
#define DD_LOG_ERROR ANDROID_LOG_ERROR
|
|
#define dd_upscale_log __android_log_print
|
|
#endif
|