mirror of
https://github.com/Droid-Deck/DroidDeck.git
synced 2026-12-06 21:15:43 +00:00
Layer and bridges updated from Winlator-NeuralScale 71c140d9 (michaelisomer-cyber, GPL-3.0): - full FSR 4.1 on the NPU (S8 graph, U8 fallback), compiled on the device per HTP arch - ghosting fix: blank far depth when a game sends none, binding 11 bound with 62 - FSR 4.1.2 Lite S8/U8 zero-copy graphs - Snapdragon GSR 2 on the GPU (new engine sgsr2_gpu) - D3D11 DLSS through DXVK's interop (nvngx D3D11 entry points) Left out on purpose: upstream's root-only performance/thermal manager, GPU clock floor and bypass charging. Kept from DroidDeck: NPU detection by the app (DROIDDECK_UPSCALE_NPU, any HTP generation incl. the phone's own QNN libraries) instead of upstream's SoC list, DD env names and log tags, Intel XeSS 3 (runtime still fetched from a0ab6b0f, upstream dropped it in cb3ae04e). FSR 4.0 on the NPU is gone upstream; the engine id becomes fsr4_1_full_npu and saved fsr4_0_npu choices map to it. The full-FSR-4-on-Turnip guard is now opt-in (DROIDDECK_UPSCALE_FULL_OFF_ON_TURNIP=1), since upstream's binding-11 fix targets that black frame. Data files re-pinned to 71c140d9 (81 core + 8 NPU, sha256 checked).
102 lines
3.3 KiB
Plaintext
102 lines
3.3 KiB
Plaintext
#version 450
|
|
// Winlator Ludashi Native GPU FSR 3.1 Pass 3: Official AMD RCAS Sharpening
|
|
// Runs at full native output resolution (ow x oh) in perceptual mu-law space so HDR games
|
|
// sharpen cleanly without ringing or haloing around bright highlights.
|
|
layout(local_size_x = 8, local_size_y = 8) in;
|
|
|
|
layout(set = 0, binding = 0) uniform sampler2D u_in_img;
|
|
layout(set = 0, binding = 1, rgba16f) writeonly uniform image2D u_out_img;
|
|
layout(set = 0, binding = 2) uniform sampler2D u_exposure;
|
|
|
|
layout(push_constant) uniform PC {
|
|
vec2 u_jitter;
|
|
vec2 u_mv_scale;
|
|
vec2 u_jitter_cancel;
|
|
float u_expo;
|
|
float u_sharp;
|
|
uint rw;
|
|
uint rh;
|
|
uint ow;
|
|
uint oh;
|
|
uint flags;
|
|
uint col_base;
|
|
uint dep_base;
|
|
uint mv_base;
|
|
uint react_base;
|
|
uint pad0;
|
|
} pc;
|
|
|
|
const float FSR_RCAS_LIMIT = 0.25 - 1.0 / 16.0;
|
|
|
|
float getExposure() {
|
|
float e = pc.u_expo;
|
|
if ((pc.flags & 32u) != 0u) {
|
|
float te = texelFetch(u_exposure, ivec2(0), 0).r;
|
|
if (!isnan(te) && !isinf(te) && te > 1e-4 && te < 1e4) e *= te;
|
|
}
|
|
return clamp(e, 1e-4, 1e4);
|
|
}
|
|
|
|
vec3 toMuLaw(vec3 c, float e) {
|
|
c = max(c, vec3(0.0)) * e;
|
|
return max(vec3(0.1174) * log(vec3(1.0) + 150.0 * c), vec3(0.0));
|
|
}
|
|
|
|
vec3 fromMuLaw(vec3 m, float e) {
|
|
return max((exp(8.51788 * m) - 1.0) / 150.0, vec3(0.0)) / max(e, 1e-6);
|
|
}
|
|
|
|
vec3 fetchMu(ivec2 p, ivec2 lim, float e) {
|
|
return toMuLaw(texelFetch(u_in_img, clamp(p, ivec2(0), lim), 0).rgb, e);
|
|
}
|
|
|
|
void main() {
|
|
ivec2 sp = ivec2(gl_GlobalInvocationID.xy);
|
|
if (sp.x >= int(pc.ow) || sp.y >= int(pc.oh)) return;
|
|
ivec2 lim = ivec2(int(pc.ow) - 1, int(pc.oh) - 1);
|
|
|
|
float sharp = clamp(pc.u_sharp, 0.0, 1.0);
|
|
if (sharp < 0.01) {
|
|
imageStore(u_out_img, sp, vec4(clamp(texelFetch(u_in_img, sp, 0).rgb, vec3(0.0), vec3(64000.0)), 1.0));
|
|
return;
|
|
}
|
|
|
|
float eff_expo = getExposure();
|
|
vec3 b = fetchMu(sp + ivec2(0, -1), lim, eff_expo);
|
|
vec3 d = fetchMu(sp + ivec2(-1, 0), lim, eff_expo);
|
|
vec3 e = fetchMu(sp, lim, eff_expo);
|
|
vec3 f = fetchMu(sp + ivec2(1, 0), lim, eff_expo);
|
|
vec3 h = fetchMu(sp + ivec2(0, 1), lim, eff_expo);
|
|
|
|
float bL = b.b * 0.5 + (b.r * 0.5 + b.g);
|
|
float dL = d.b * 0.5 + (d.r * 0.5 + d.g);
|
|
float eL = e.b * 0.5 + (e.r * 0.5 + e.g);
|
|
float fL = f.b * 0.5 + (f.r * 0.5 + f.g);
|
|
float hL = h.b * 0.5 + (h.r * 0.5 + h.g);
|
|
|
|
float nz = 0.25 * (bL + dL + fL + hL) - eL;
|
|
float lmin = min(min(bL, min(dL, eL)), min(fL, hL));
|
|
float lmax = max(max(bL, max(dL, eL)), max(fL, hL));
|
|
nz = clamp(abs(nz) / max(lmax - lmin, 1e-6), 0.0, 1.0);
|
|
nz = -0.5 * nz + 1.0;
|
|
|
|
vec3 mn4 = min(min(b, min(d, f)), h);
|
|
vec3 mx4 = max(max(b, max(d, f)), h);
|
|
|
|
float lll = clamp(eL / max(min(min(bL, dL), min(fL, hL)), 1e-6), 0.0, 1.0);
|
|
vec3 hitMin = mn4 / max(4.0 * mx4, vec3(1e-6)) * lll;
|
|
vec3 den4 = 4.0 * mn4 - 4.0;
|
|
vec3 strip = step(abs(den4), vec3(1e-6));
|
|
vec3 hitMax = (1.0 - mx4) / (den4 - strip * vec3(1e-6));
|
|
hitMax = mix(hitMax, vec3(-1e9), strip);
|
|
vec3 lobe3 = max(-hitMin, hitMax);
|
|
float lobe = max(-FSR_RCAS_LIMIT, min(max(max(lobe3.r, lobe3.g), lobe3.b), 0.0));
|
|
|
|
lobe *= exp2(2.0 * sharp - 2.0);
|
|
lobe *= nz;
|
|
|
|
vec3 pix = (lobe * (b + d + h + f) + e) / (4.0 * lobe + 1.0);
|
|
vec3 fc = clamp(fromMuLaw(pix, eff_expo), vec3(0.0), vec3(64000.0));
|
|
imageStore(u_out_img, sp, vec4(fc, 1.0));
|
|
}
|