The FSR 4.1.1 full path (descriptor buffers) runs on Turnip but writes a black frame (Elite, Adreno 830: 5 screenshots, no lit pixel, while the status said ok). FSR 4.1.2 Lite, on classic descriptors, works there, so the full path now declines on VK_DRIVER_ID_MESA_TURNIP and the pipeline's own fallback runs Lite, with reason full_black_on_turnip_lite_used in the status. DROIDDECK_UPSCALE_FULL_ON_TURNIP=1 runs it anyway.
VK_LAYER_DROIDDECK_upscale
A Vulkan layer that runs the upscaler calls of Windows games (FSR 4 / FSR 3 / FSR 2 through
FidelityFX, DLSS through NGX, XeSS) on the device: on the Adreno GPU, or on the Snapdragon
Hexagon NPU through Qualcomm QNN. The Windows side is a set of bridge DLLs
(amd_fidelityfx_*.dll, nvngx.dll, libxess.dll, ...). They talk to this layer through two
Vulkan buffers with magic sizes and a vkCmdUpdateBuffer doorbell (fsr4_seam_proto.h). That
protocol, its buffer sizes, magic values and backend IDs are unchanged from upstream, so the
upstream bridge DLLs work against this layer.
Layer name VK_LAYER_DROIDDECK_upscale, library libVkLayer_droiddeck_upscale.so, implicit layer.
The manifest template VK_LAYER_DROIDDECK_upscale.json turns it on with DROIDDECK_UPSCALE=1 and
off with DROIDDECK_UPSCALE_DISABLE=1.
Origin, credits, licence
GPL-3.0, like DroidDeck. Ported from app/src/main/cpp/fsr4npu/ of
michaelisomer-cyber/Winlator-NeuralScale
at commit a0ab6b0f770e1a6786b4e68def46b4edb8baafd0 (GPL-3.0). That project is a fork of
StevenMXZ/Winlator-Ludashi. The first commit
that adds this folder holds the upstream files unchanged; the DroidDeck changes are in the
commits after it.
Work this code builds on, as credited upstream:
- AMD FidelityFX SDK (FSR 3.1, FSR 4.0.2, FSR 4.1.x): GPUOpen FidelityFX-SDK
- Intel XeSS 3.0 SDK: intel/xess
- FSR 4 Vulkan DP4a reference pipelines: dvj5411/fsr4vk, zrprod9-cmyk/vela, puzzled-pancake/fsr4-hexagon
- RDR2 DLSS-gate byte patterns: OptiPatcher from optiscaler/OptiScaler
- QNN HTP runtime handling adapted from BananaNative's SM8850 runtime (per the upstream source comments)
- Qualcomm QNN / QAIRT HTP runtime (Qualcomm AI Engine Direct SDK);
fsr4_qnn.his a clean-room declaration of the C ABI subset, no Qualcomm headers are used
Files
| File | What |
|---|---|
fsr4_layer.c |
Loader interface, device/extension/feature injection, GPU/DLSS spoof, seam mailbox + doorbell, ctrl and status files |
fsr4_pipeline.c/.h |
Backend dispatch and fallbacks, FSR 4.1.1 Full NPU (external pack) path |
fsr4_builtin.c/.h |
FSR 4.0.2 INT8 on the NPU (graph compiled on the device from fsr4_v07_i8.wpack) |
fsr412_lite.c/.h |
FSR 4.1.2 Lite INT8, GPU DP4a or NPU |
fsr411_full_gpu.c/.h |
FSR 4.1.1 Full INT8 on the GPU |
fsr3_gpu.c/.h |
FSR 3.1 on the GPU, also the fallback for every other backend |
fsr4_qnn.c/.h |
QNN/FastRPC/AHardwareBuffer runtime; stubs only in glibc builds |
fsr4_seam_proto.h |
Shared protocol with the Windows bridge DLLs (do not change) |
fsr_gpu_timer.h |
GPU timestamp helper for the status file |
dd_upscale_compat.h |
DroidDeck env lookup and logging (logcat, or stderr in glibc builds) |
shaders/*.comp |
GLSL source of fsr3_*.spv, fsr4_builtin_*.spv, fsr412_lite/lite_npu_{pack,unpack}.spv |
scripts/pack_*.py |
Build fsr4_v07_i8.wpack and fsr412_lite/fsr412_lite_i8.wpack from the AMD weights |
CMakeLists.txt |
APK build (bionic), added from app/src/main/cpp/CMakeLists.txt |
build-glibc.sh |
PRoot guest build (glibc), called by tools/components/recipes/runtime.sh |
Builds
- APK (bionic, arm64-v8a, minSdk 26): Gradle's NDK build makes
libVkLayer_droiddeck_upscale.sothroughadd_subdirectory(../../../../tools/upscale/layer upscale_layer). Linksandroid log dl m,-Wl,-z,max-page-size=16384 -Wl,-Bsymbolic. The manifest's relativelibrary_pathis meant to be rewritten to the absolute path by the app. - PRoot guest (glibc):
tools/upscale/layer/build-glibc.sh OUT(CC, defaultaarch64-linux-gnu-gcc; Vulkan headers fromVK_INCLUDEor the NDK). Built with-DDD_UPSCALE_NO_ANDROID: no AHardwareBuffer, FastRPC, QNN or liblog (logs go to stderr). Every NPU init fails withnpu_unavailableand the backends take their GPU fallbacks.OUTgets the library and a manifest withlibrary_path/usr/local/lib/droiddeck-upscale-layer/libVkLayer_droiddeck_upscale.so(override withDD_UPSCALE_GUEST_LIB). The runtime recipe installs both intoapp/src/main/assets/linuxfs/usr/local/lib/droiddeck-upscale-layer/. -Bsymbolicis needed in both builds: the layer exportsvkGetInstanceProcAddr, and alibvulkanalready in the global symbol scope would otherwise win the lookup (the loader then fails withFailed to find 'vkCreateInstance').
Environment
Each key is read as DROIDDECK_UPSCALE_<KEY> first, then WINLATOR_FSR4_<KEY>
(dd_upscale_compat.h). Empty values count as unset.
| Key | Read at | Meaning |
|---|---|---|
DIR (then DM_FSR4_DIR) |
fsr4_pipeline.c:566, :826 |
Data dir (layout below). Unset: no backend can load its files, frames get a plain blit. No built-in fallback path |
POWER |
fsr4_pipeline.c:575, :830 |
HTP power vote: burst, turbo (default), balanced/nom, low |
BACKEND, then ENGINE |
fsr4_layer.c:458 |
Start backend (names under ctrl file). Unset: fsr4_0_npu |
NPU_SYNC |
fsr4_layer.c:462 |
1 = GPU waits for the NPU each frame. Anything else = async (default). sync/true also mean sync |
SHARPNESS |
fsr4_layer.c:464 |
RCAS 0.0-1.0, default 0.55 |
PRESET |
fsr4_pipeline.c:1239 |
ultraperf or performance forces the preset; else from the game's quality mode / ratio |
CTRL_FILE |
fsr4_layer.c:472 |
Live control file, format below |
STATUS_FILE |
fsr4_layer.c:526 |
Live status file, format below |
NATIVELIB_DIR |
fsr4_qnn.c:311 |
Folder with the Qualcomm host libraries (see NPU setup) |
HTP_ARCH |
fsr4_qnn.c:237 |
Optional override of the HTP arch (v79, v81) used for the cache folder |
SPOOF_DLSS |
fsr4_layer.c:557, :583 |
1 = expose VK_NVX_binary_import / VK_NVX_image_view_handle (stub functions) and report an RTX 2060 vendorID/deviceID/name |
GPU_SPOOF |
fsr4_layer.c:570 |
Words split by , + ; or blanks: rtx / rdna4 pick the reported GPU; 1 also rewrites driverID/driverName/driverInfo; off/none/0 keep the real GPU even with SPOOF_DLSS=1 |
VRAM_OVERRIDE |
fsr4_layer.c:757 |
1 = report VRAM_MB as the size of every device-local heap (and its budget). Off otherwise |
VRAM_MB (then WRAPPER_VMEM_MAX_SIZE) |
fsr4_layer.c:759 |
Heap size in MB for VRAM_OVERRIDE=1, 512-65536 |
RDR2_PATCH |
fsr4_layer.c:235 |
1 = patch RDR2.exe's DLSS vendor checks in memory. Off otherwise (Arxan crashes after loading with it) |
LOG |
fsr4_qnn.c:145, fsr4_pipeline.c:443 |
2 = verbose QNN log and every NPU dispatch logged |
JX, JY, MX, MY |
fsr4_pipeline.c:1387-1390 |
Debug: jitter and motion-vector scale multipliers for the external FSR 4.1.1 NPU pack, default 1 |
Not prefixed: ADSP_LIBRARY_PATH (read and, if <DIR>/adsp is missing from it, prepended by the
layer, fsr4_qnn.c:262), LD_LIBRARY_PATH (searched for QNN libraries, fsr4_qnn.c:303).
Upstream's WINLATOR_FSR4_DISABLE_LAYER only lived in its manifest; the C code never read it.
Here the loader switch is DROIDDECK_UPSCALE_DISABLE=1.
Spoof examples: SPOOF_DLSS=1 gives RTX 2060 IDs with the real driverID; add GPU_SPOOF=1 for
VK_DRIVER_ID_NVIDIA_PROPRIETARY too. GPU_SPOOF=rdna4 gives Radeon RX 9070 XT IDs,
GPU_SPOOF=rdna4,1 adds the AMD driverID. Upstream rewrote the driverID whenever GPU_SPOOF was
rtx or rdna4; here that needs the 1 word.
Ctrl file (read)
read_live_ctrl, fsr4_layer.c:454-505. Re-read at most every 200 ms, when a doorbell arrives
and at vkCreateDevice. One key=value per line; keys missing from the file keep their last value
(first the env values):
enabled=1 # 0, off..., false... = bypass (plain blit); anything else = on
backend=fsr4_1_lite_gpu
engine=fsr4_1_lite_gpu # same as backend=, upstream writes both
npu_sync=async # 1, sync..., true... = sync; anything else = async
sharpness=0.55 # clamped to 0..1
Backend names, matched by prefix (parse_backend_str, fsr4_layer.c:421): fsr3/gpu = FSR 3.1
GPU (0), xess/xess3 = XeSS 3 DP4a (1), fsr4_0_npu/fsr4_npu/fsr4/npu = FSR 4.0.2 NPU (2),
fsr4_1_lite_npu/412_lite_npu (3), fsr4_1_full_npu/412_full_npu (4),
fsr4_1_lite_gpu/412_lite_gpu (5), fsr4_1_full_gpu/412_full_gpu (6); anything else = 5.
If the first line has none of these keys, it is a bare flag: containing 0, off or false turns
the upscaler off, anything else on.
Status file (written)
write_live_status, fsr4_layer.c:507-553. Written to <STATUS_FILE>.tmp, then renamed over
STATUS_FILE. At most every 250 ms unless enabled/backend/sync/NPU use/quality/render width
changed; always at vkCreateDevice. Exactly these lines in this order:
layer=1
driver=<real GPU name>
ahb=<pending|gpu_only|zc|staging|zc_avail|staging_avail|zc_pending|zc_failed>
npu_state=<standby|ready|compiling|failed|cached|ready_to_compile|no_pack|fsr3_gpu|xess3_dp4a|fsr412_lite_gpu|fsr411_full_gpu|...>
rdr2_patch=<none|partial|ok>
engine=<fsr3|fsr4>
backend=<fsr3_gpu|xess3_gpu|fsr4_0_npu|fsr4_1_lite_npu|fsr4_1_full_npu|fsr4_1_lite_gpu|fsr4_1_full_gpu>
backend_tag=<what really ran, e.g. FSR4.1-Lite-GPU (NPU fallback)>
npu_sync=<sync|async>
sharpness=<%.2f>
enabled=<0|1>
active=<0|1>
npu=<0|1>
api=<None|FSR 4 (Vulkan)|FSR 4 (DX12)|DLSS (Vulkan)|DLSS (DX12)|XeSS (Vulkan)|XeSS (DX12)|FSR 3 (...)|FSR 2 (...)>
quality=<Native AA (DLAA)|Ultra Quality|Quality|Balanced|Performance|Ultra Performance|Auto>
render=<w>x<h>
output=<w>x<h>
preset=<perf|ultraperf>
gpu_us=<u32>
htp_us=<u32>
dispatches=<u64>
reason=<ok|standby|bypass_off|ok_fsr3_gpu|missing_fsr3_shaders|npu_unavailable|...>
ts_ms=<CLOCK_REALTIME ms>
Data dir (DROIDDECK_UPSCALE_DIR)
Same tree as upstream's app/src/main/assets/fsr4/. None of it is in this repo; it is installed at
run time. Paths the layer opens, relative to the dir:
| Path | Used by | Built here? |
|---|---|---|
fsr3_prepare.spv, fsr3_accumulate.spv, fsr3_rcas.spv |
FSR 3.1 GPU (fsr3_gpu.c:343, :385) |
Source in shaders/. Upstream's files look like glslc -O --target-env=vulkan1.1 output (Shaderc, SPIR-V 1.3); a local build of that is close in size, not byte-identical. Not built by the layer builds |
fsr4_builtin_pre.spv, fsr4_builtin_post_a.spv, fsr4_builtin_post_b.spv |
FSR 4.0.2 NPU (fsr4_builtin.c:560, :609) |
Source in shaders/ |
fsr4_v07_i8.wpack |
FSR 4.0.2 NPU graph (fsr4_qnn.c:1583) |
scripts/pack_fsr4_weights.py, needs fsr4-hexagon and AMD weights |
fsr412_lite/0000.spv ... 0010.spv, 0013.spv, weights.bin |
FSR 4.1.2 Lite (fsr412_lite.c:410, :688) |
No: precompiled AMD FidelityFX SDK passes (per upstream) |
fsr412_lite/lite_npu_pack.spv, lite_npu_unpack.spv |
Lite NPU (fsr412_lite.c:618) |
Source in shaders/ |
fsr412_lite/fsr412_lite_i8.wpack |
Lite NPU graph (fsr412_lite.c:456) |
scripts/pack_fsr412_lite_weights.py, needs vela + weights.bin |
fsr411_full/{quality,performance}/pass-00.spv ... pass-27.spv, initializers.bin |
FSR 4.1.1 Full GPU (fsr411_full_gpu.c:328, :346) |
No: precompiled AMD FidelityFX SDK passes (per upstream) |
adsp/libQnnHtpV79Skel.so, adsp/libQnnHtpV81Skel.so |
NPU side, loaded by FastRPC through ADSP_LIBRARY_PATH; also probed for the arch (fsr4_qnn.c:224) |
No: Qualcomm QNN |
<arch>/fsr4_v07_i8_cache.bin, <arch>/fsr412_lite_i8_cache.bin |
Compiled NPU graphs, written by the layer on first use | Made on the device |
1080/{performance,ultraperf}/pass-00.spv, pass-01-npu.spv, pass-28.spv, initializers.bin, v81/nf4_k1h.bin, v81/nf4up_k1h.bin |
Optional external FSR 4.1.1 Full NPU pack (fsr4_pipeline.c:460-478, fsr4_qnn.c:1018); v81 only |
No |
jni/arm64-v8a/<lib>, <lib> |
First two places searched for QNN host libraries | No |
<arch> is v79 or v81: HTP_ARCH if set, else the SoC (ro.soc.model /
ro.vendor.qti.soc_model starting with SM8750 = v79, SM8850 = v81, or ro.vendor.qti.soc_name /
ro.board.platform sun = v79, canoe = v81), else the libQnnHtpV<NN>Stub.so mapped in the
process, else the only skel present in adsp/, else htp (fsr4_qnn.c:176-250). Upstream always
used v81/.
NPU setup (Android build only)
- Host libraries:
libQnnSystem.so,libQnnHtp.so,libQnnHtpV79Stub.so,libQnnHtpV81Stub.so,libQnnHtpPrepare.so(on-device graph compile). Searched in this order (fsr4_qnn.c:303):<DIR>/jni/arm64-v8a/,<DIR>/,<NATIVELIB_DIR>/, eachLD_LIBRARY_PATHentry, then the bare name (Androidsphalnamespace first, then the default one). libQnnHtp.soopens the arch stub by name itself. The layer loadslibQnnHtpV<arch>Stub.so(both stubs when the arch is unknown) from the same search list first (fsr4_qnn.c:364), soNATIVELIB_DIRalone is enough;LD_LIBRARY_PATHdoes not have to name the folder.ADSP_LIBRARY_PATHmust list<DIR>/adsp(the skels),;-separated, e.g.<DIR>/adsp;/vendor/dsp/cdsp;/vendor/lib/rfsa/adsp;/system/lib/rfsa/adsp. The layer prepends<DIR>/adspitself when it is missing.libcdsprpc.socomes from the vendor partition.
DroidDeck changes from upstream
- Layer name, library name, log tags, manifest (implicit,
DROIDDECK_UPSCALE/DROIDDECK_UPSCALE_DISABLE). DROIDDECK_UPSCALE_<KEY>env withWINLATOR_FSR4_<KEY>fallback.- No hardcoded
/data/user/0/com.winlator.cmod/files/fsr4fallback; no data dir means GPU blit. - Compiled NPU graph caches in
<DIR>/<arch>/instead of<DIR>/v81/. - driverID/driverName/driverInfo rewrite only with
GPU_SPOOFword1;SPOOF_DLSS=1alone reports RTX vendor/device IDs. - Arch stub preloaded from the library search list (
NATIVELIB_DIRworks withoutLD_LIBRARY_PATH). - glibc build (
DD_UPSCALE_NO_ANDROID) with QNN stubs and stderr logging. -Bsymboliclink flag; pack scripts take their paths as arguments instead of the author's Windows paths.