mirror of
https://github.com/Droid-Deck/DroidDeck.git
synced 2026-11-25 07:46:01 +00:00
feat(display): black frame insertion on 100 Hz and faster screens (#2653)
* feat(display): black frame insertion on 100 Hz and faster screens * feat(display): black frame insertion lives in Screen effects * test(compositor): cover black frame insertion in the render-on-commit harness * fix(display): keep HDR and pacing intact around black frame insertion * fix(display): gate black frame insertion on the panel's refresh, not the tick rate BFI checked the 100 Hz minimum against g_refresh_ns, an average of the time between handled vsync ticks. BFI presents on every tick, so under load the ticks run late, the average fell to 95-100 Hz on a 120 Hz panel, and BFI switched off and on again many times a second (3793 times in one session on a Retroid Pocket Duo). That showed as uneven flicker. Use the display mode's refresh (g_output_refresh_mhz) instead, which only changes when the mode does. * fix(display): offer black frame insertion for the bottom screen and while it is on * fix(display): capture a picture, not a black refresh, while black frame insertion strobes * fix(display): hold black frame insertion off until the last capture ends * fix(display): keep the game composed while a capture holds black frame insertion * test(display): a picture hold presents only pictures while black frame insertion runs
This commit is contained in:
1 parent
f65e7a3d43
commit
758e7983fa
46 files changed
+343
-29
No files matched your search
@@ -53,6 +53,8 @@ object CompositorHost {
|
||||
WaylandCompositor.nativeSetClockControl(java.io.File(context.filesDir, "${com.droiddeck.launcher.runtime.LinuxRuntime.DIR}/tmp/.bl-clock").path)
|
||||
ownVsyncThread = SessionPrefs.vsyncThread(context)
|
||||
WaylandCompositor.nativeSetRenderOnCommit(SessionPrefs.renderOnCommit(context))
|
||||
blackFrameInsertion = SessionPrefs.blackFrameInsertion(context)
|
||||
WaylandCompositor.nativeSetBlackFrameInsertion(blackFrameInsertion)
|
||||
pace(refreshHz, fpsLimit)
|
||||
if (!SessionState.running) WaylandCompositor.nativeSetOutputSize(outputWidth, outputHeight)
|
||||
if (started) {
|
||||
@@ -72,9 +74,12 @@ object CompositorHost {
|
||||
return true
|
||||
}
|
||||
|
||||
private var blackFrameInsertion = false
|
||||
private var pictureHolds = 0
|
||||
|
||||
private fun pace(refreshHz: Float, fpsLimit: Int) {
|
||||
WaylandCompositor.nativeSetFpsLimit(fpsLimit)
|
||||
WaylandCompositor.nativeSetLayerFrameRate(if (fpsLimit > 0) fpsLimit.toFloat() else refreshHz)
|
||||
WaylandCompositor.nativeSetLayerFrameRate(if (fpsLimit > 0 && !blackFrameInsertion) fpsLimit.toFloat() else refreshHz)
|
||||
WaylandCompositor.nativeSetOutputRefreshRate(refreshHz)
|
||||
SessionState.refreshHz = refreshHz
|
||||
}
|
||||
@@ -84,6 +89,27 @@ object CompositorHost {
|
||||
if (started) pace(refreshHz, fpsLimit)
|
||||
}
|
||||
|
||||
@Synchronized
|
||||
fun setBlackFrameInsertion(on: Boolean, refreshHz: Float, fpsLimit: Int) {
|
||||
blackFrameInsertion = on
|
||||
WaylandCompositor.nativeSetBlackFrameInsertion(on)
|
||||
if (started) pace(refreshHz, fpsLimit)
|
||||
}
|
||||
|
||||
/** Presents only pictures until the matching release; false when nothing is strobing. */
|
||||
@Synchronized
|
||||
fun holdPicture(): Boolean {
|
||||
if (!started || !blackFrameInsertion) return false
|
||||
if (pictureHolds++ == 0) WaylandCompositor.nativeSetPictureHold(true)
|
||||
return true
|
||||
}
|
||||
|
||||
@Synchronized
|
||||
fun releasePicture() {
|
||||
if (pictureHolds == 0) return
|
||||
if (--pictureHolds == 0) WaylandCompositor.nativeSetPictureHold(false)
|
||||
}
|
||||
|
||||
@Synchronized
|
||||
fun resize(surface: Surface, rearm: () -> Unit) {
|
||||
if (!started) return
|
||||
|
||||
@@ -321,6 +321,10 @@ public final class WaylandCompositor {
|
||||
|
||||
public static native void nativeSetFpsLimit(int fps);
|
||||
|
||||
public static native void nativeSetBlackFrameInsertion(boolean on);
|
||||
|
||||
public static native void nativeSetPictureHold(boolean on);
|
||||
|
||||
public static native void nativeSetRenderOnCommit(boolean on);
|
||||
|
||||
public static native void nativeSetGpuTurbo(boolean on);
|
||||
|
||||
Reference in new issue
Block a user