Added LSFG/Import/License Checking (#96)

* feat(lsfg): take Lossless Scaling from Steam by itself, import it once owned, rebuild on update

- Lossless.kt owns the DLL and its shader cache. The copy the Steam
  client installs (runtime library or the card's) is taken by itself
  and taken again when the client updates it (size/mtime stamp). The
  DLL is copied in and built into a cache named after its SHA-256, so
  a new DLL hands the compositor a new path; a build that fails keeps
  the working cache. Builds are serialized.
- The Steam session asks the signed-in client once per session whether
  the account owns app 993090 until the answer is yes, then records it
  and the app stops asking (BL_LOSSLESS_OWNED). Once owned, the frame
  generation menu offers "Import Lossless.dll…", on the main screen and
  in the session drawer; an import stays until Steam's copy changes.
- The compositor restarts the LSFG engine when its cache path changes,
  and a new engine selection clears an earlier start failure, so an
  updated DLL or a retry no longer needs the app restarted.
- The HUD says when LSFG is waiting on Lossless Scaling instead of
  "starting"; frame generation strings are resources.
- Removed LsfgNative's unused DLL variant and cache-match calls.

* Find Lossless.dll in added Games libraries too

* LSFG: 120, 90 and 60 fps targets alongside 2x-4x

The pacer's target-rate mode picks 0-3 generations per game frame. While it
is warm the input ring and shared chain follow every frame, so frames that
generate nothing don't leave the next one without history.

* Credit LSFG: Camille LaVey / Eden, ported to WinNative and DroidDeck by @maxjivi05

* LSFG: aim 0.1 fps under the target so output never passes the refresh rate
This commit is contained in:
MaxsTechReview authored and GitHub committed 2026-09-30 16:40:46 -04:00
1 parent 38c9b733b5
commit 6c5d6cda73
51 files changed
+676 -353

No files matched your search

@@ -0,0 +1,42 @@
package com.droiddeck.launcher.gpu
import android.content.Context
import org.junit.Assert.assertEquals
import org.junit.Before
import org.junit.Test
import org.junit.runner.RunWith
import org.robolectric.RobolectricTestRunner
import org.robolectric.RuntimeEnvironment
import org.robolectric.annotation.Config
@RunWith(RobolectricTestRunner::class)
@Config(sdk = [28], manifest = Config.NONE)
class FrameGenTest {
private lateinit var context: Context
@Before fun setUp() {
context = RuntimeEnvironment.getApplication()
context.getSharedPreferences("frame_gen", Context.MODE_PRIVATE).edit().clear().commit()
}
@Test fun offUntilPicked() {
assertEquals(FrameGen.Mode.OFF, FrameGen.mode(context))
}
@Test fun adaptiveTargetIsKept() {
FrameGen.set(context, FrameGen.Mode(FrameGen.ENGINE_LSFG, target = 90))
assertEquals(FrameGen.Mode(FrameGen.ENGINE_LSFG, target = 90), FrameGen.mode(context))
}
@Test fun fixedMultiplierReplacesATarget() {
FrameGen.set(context, FrameGen.Mode(FrameGen.ENGINE_LSFG, target = 120))
FrameGen.set(context, FrameGen.Mode(FrameGen.ENGINE_LSFG, 3))
assertEquals(FrameGen.Mode(FrameGen.ENGINE_LSFG, 3), FrameGen.mode(context))
}
@Test fun onlyLsfgIsAdaptive() {
context.getSharedPreferences("frame_gen", Context.MODE_PRIVATE).edit()
.putString("engine", FrameGen.ENGINE_WINFG).putInt("multiplier", 4).putInt("target", 60).commit()
assertEquals(FrameGen.Mode(FrameGen.ENGINE_WINFG, 4), FrameGen.mode(context))
}
}
@@ -0,0 +1,48 @@
package com.droiddeck.launcher.gpu
import android.content.Context
import com.droiddeck.launcher.runtime.LinuxRuntime
import org.junit.Assert.assertEquals
import org.junit.Assert.assertFalse
import org.junit.Assert.assertNull
import org.junit.Assert.assertTrue
import org.junit.Before
import org.junit.Test
import org.junit.runner.RunWith
import org.robolectric.RobolectricTestRunner
import org.robolectric.RuntimeEnvironment
import org.robolectric.annotation.Config
import java.io.File
@RunWith(RobolectricTestRunner::class)
@Config(sdk = [28], manifest = Config.NONE)
class LosslessTest {
private lateinit var context: Context
private lateinit var flag: File
@Before fun setUp() {
context = RuntimeEnvironment.getApplication()
context.getSharedPreferences("lossless", Context.MODE_PRIVATE).edit().clear().commit()
flag = File(LinuxRuntime.rootDir(context), "root/.config/droiddeck/lossless-owned")
flag.delete()
}
@Test fun nothingIsOwnedOrReadyUntilTheSessionSaysSo() {
assertEquals(Lossless.State.NONE, Lossless.state(context))
assertNull(Lossless.cacheFile(context))
}
@Test fun theSessionsOwnershipFlagIsRememberedForGood() {
flag.parentFile!!.mkdirs()
flag.writeText("")
assertTrue(Lossless.owned(context))
flag.delete()
assertTrue(Lossless.owned(context))
}
@Test fun importIsRefusedWithoutOwnership() {
val dll = File(context.cacheDir, "Lossless.dll").apply { writeText("not a dll") }
assertFalse(Lossless.owned(context))
assertEquals(Lossless.ImportResult.NOT_OWNED, Lossless.import(context, dll))
}
}