// DroidDeck glue for the upscaler layer: environment lookup and logging. // // Every setting is read as DROIDDECK_UPSCALE_ first and WINLATOR_FSR4_ 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 #include 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 #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 #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