Compare commits

...
11 Commits
Author SHA1 Message Date
The412Banner fb1d6955f0 test: pin the published gamescope p18 (same archive as the QA build) 2026-10-28 04:42:12 +00:00
The412Banner 4745517101 fix(steam): skip only Steam's own driver-query run in compatdata/0
Review of #1708: matching the file name alone also caught
getcompatpath for that path and a game that happens to use the name.
The wrappers now skip only "run …/d3ddriverquery64.exe" (or the 32-bit
name) with STEAM_COMPAT_DATA_PATH in compatdata/0, which is how the
client calls it; every other verb and prefix goes on to Proton.

(cherry picked from commit c5e8ad0f80)
2026-10-28 04:42:12 +00:00
The412Banner 58c262a32e Merge perf/render-on-commit (callback-paced clients, idle recheck) into test/perf-round2 2026-10-28 04:42:11 +00:00
The412Banner bfe5941ce9 fix(compositor): keep callback-paced clients at one frame per refresh
Review of #1707: a client that draws its next frame only after the
frame callback of the last one sends no new frame while the tick holds
one back, so it got one frame every two refreshes. Once a held frame is
still waiting at the next tick, the tick now draws every frame for a
second before holding one again; such a client loses at most one
refresh per second, while gamescope, which commits without waiting,
keeps drawing on arrival.

The queued draw also checks again that drawing on arrival is still on,
so a frame queued just before streaming, frame generation or paced
output switched on is left for the tick.
2026-10-28 04:40:24 +00:00
The412Banner 93bed6e931 fix(steam): answer Steam's D3D driver query without starting Wine
At every start, Steam's shader pre-caching runs d3ddriverquery64.exe
through each Proton tool (DroidDeck-Proton and the ARM64 Proton) in
compatdata/0. Here the query has never succeeded (948 of 948 runs in
the client's shader log failed, mostly exit code 1), and each run
started Wine in that prefix, where the two Protons upgraded it back and
forth (11.0-100 <-> GE-Proton11-11) with the 32-bit wine.inf install.
When that overlapped a game's start, AIO ran 25-30 % slower for its
first 5-7 seconds.

Both Proton wrappers now exit 1 for the query before doing anything
else, so Steam gets the same failure without Wine. Other launches are
unchanged.

(cherry picked from commit 0d8dbe4360)
2026-10-28 02:48:47 +00:00
The412Banner c6a31be049 Merge perf/render-on-commit (tick leaves young frames for the next arrival) into test/perf-round2 2026-10-28 02:21:34 +00:00
The412Banner 1c245df6b6 fix(compositor): keep drawing frames on arrival at one frame per refresh
On the device, render-on-commit drew only 4-12 % of frames on arrival
while a game ran uncapped: gamescope delivers about one frame per
refresh, so once the tick drew a frame, the next one arrived in the same
refresh, was held back by the once-per-refresh limit and was drawn by
the next tick, which held back the one after it. Waits stayed at ~2 ms.

The tick now leaves a frame younger than one refresh for the next
arrival to draw, unless the tick itself changed the window, effects or
headset pose. A frame no other frame follows is drawn at the tick after.
2026-10-28 02:21:27 +00:00
The412Banner 6c6c68413f test: pin the gamescope QA build with 0123 and 0124 2026-10-28 01:02:53 +00:00
The412Banner d00e0b2763 test: render-on-commit + gamescope 0124 together 2026-10-28 01:02:52 +00:00
The412Banner f7cebee7ee perf(gamescope): handle a finished frame at import (0124) with upstream fence fixes (0123)
0123 backports upstream 0efe47c and 666c52b by Matthew Schwartz (commit
completion list lifetime, no Rc to a dying commit). 0124 polls a new
commit's fence at import; a finished frame is marked done at once and
handled in the same steamcompmgr pass instead of a second wake through
the image waiter. commit_ready_check (default on) turns it off.
2026-10-28 00:50:21 +00:00
The412Banner 8e7044af4c perf(compositor): draw a new frame when it arrives
A new game frame waited for the next screen tick before the compositor
drew it: 1.9-3.5 ms on average at 144 Hz, measured with the pacing
counters. With frames going straight back to the game (no compositor
limit), the compositor now draws as soon as the clients' requests are
handled, at most once per refresh: a second frame in the same refresh
still waits for the tick, and presentation times stay on the tick.

Paced output (glasses), streaming and frame generation keep drawing on
the tick. The hidden pref renderOnCommit (default on) turns it off. The
pacing log line counts the scenes drawn on arrival.
2026-10-28 00:46:16 +00:00
12 changed files with 616 additions and 15 deletions

No files matched your search

+49 -7
View File
@@ -263,9 +263,14 @@ static struct wl_event_source *g_render_idle, *g_frame_timer;
static int g_dirty;
static int64_t g_dirty_since_ns;
volatile int g_render_on_commit = 1;
static int64_t g_rendered_tick_ns;
static int g_tick_held;
static int64_t g_hold_missed_ns;
#define HOLD_RETRY_NS 1000000000LL
#define PACE_BUFFERS 32
static struct {
unsigned ticks, ticks_late_2ms, renders, null_attaches, reattaches, presented, replaced, undrawn, distinct;
unsigned ticks, ticks_late_2ms, renders, commit_renders, null_attaches, reattaches, presented, replaced, undrawn, distinct;
int64_t tick_late_ns, tick_late_max_ns, wait_ns, wait_max_ns;
const void *buffers[PACE_BUFFERS];
uint64_t game_frames_seen;
@@ -327,6 +332,7 @@ static struct {
} g_perf;
static void schedule_render(void);
static void on_commit_idle(void *data);
static int64_t now_ns(void) {
struct timespec ts; clock_gettime(CLOCK_MONOTONIC, &ts);
@@ -2132,6 +2138,8 @@ static void render_scene(void) {
g_dirty_since_ns = 0;
}
g_dirty = 0;
g_rendered_tick_ns = g_tick_vsync_ns;
g_tick_held = 0;
g_hud_fresh = 0;
g_hdr_unimported = NULL;
wl_list_for_each(s, &g_surfaces, link) s->drawn = 0;
@@ -2296,11 +2304,25 @@ static int on_fallback_timer(void *data) {
return 0;
}
/* A new frame is drawn when it arrives instead of at the next screen tick, at most once per refresh,
while frames go straight back to the game (no compositor limit), without streaming or frame generation. */
static int commit_renders_on(void) {
return g_render_on_commit && g_release_unpaced && !atomic_load(&g_stream_on) && !vkp_framegen_active();
}
static int render_on_commit(void) {
return commit_renders_on() && !g_render_idle && g_rendered_tick_ns != g_tick_vsync_ns;
}
static void schedule_render(void) {
if (!g_dirty && !g_dirty_since_ns) g_dirty_since_ns = now_ns();
g_dirty = 1;
if (!g_display) return;
if (g_last_vsync_ns && now_ns() - g_last_vsync_ns < 100000000LL) return;
if (g_last_vsync_ns && now_ns() - g_last_vsync_ns < 100000000LL) {
if (render_on_commit())
g_render_idle = wl_event_loop_add_idle(wl_display_get_event_loop(g_display), on_commit_idle, NULL);
return;
}
if (g_fallback_armed) return;
if (!g_fallback_timer)
g_fallback_timer = wl_event_loop_add_timer(wl_display_get_event_loop(g_display),
@@ -2314,6 +2336,13 @@ static int scene_waits_for_game(int64_t now) {
return g_hud_surface && !g_hud_fresh && now - g_hud_last_ns < 100000000LL && vkp_framegen_active();
}
static void on_commit_idle(void *data) {
g_render_idle = NULL;
if (!g_dirty || !commit_renders_on() || g_rendered_tick_ns == g_tick_vsync_ns || scene_waits_for_game(now_ns())) return;
g_pace.commit_renders++;
render_scene();
}
static void on_vsync(int64_t frame_time_ns) {
int64_t now = now_ns();
g_perf.ticks++;
@@ -2330,9 +2359,22 @@ static void on_vsync(int64_t frame_time_ns) {
}
g_last_vsync_ns = now;
g_tick_vsync_ns = frame_time_ns;
if (vkp_apply_window_request()) g_dirty = 1;
if (vkp_effects_sync()) g_dirty = 1;
if (vkp_cardboard_pose_changed()) g_dirty = 1;
int tick_change = 0;
if (vkp_apply_window_request()) tick_change = 1;
if (vkp_effects_sync()) tick_change = 1;
if (vkp_cardboard_pose_changed()) tick_change = 1;
if (tick_change) g_dirty = 1;
/* A frame that arrived after this refresh was already drawn is left for the next arrival to draw;
drawing it here would block that arrival too and keep every frame waiting for the tick. A client
that draws again only after its frame callback sends no such arrival: once a held frame is still
waiting at the next tick, the tick draws every frame for a second before holding one again. */
if (g_tick_held && g_dirty) g_hold_missed_ns = now;
g_tick_held = 0;
if (!tick_change && commit_renders_on() && g_dirty_since_ns && now - g_dirty_since_ns < g_refresh_ns &&
now - g_hold_missed_ns >= HOLD_RETRY_NS) {
g_tick_held = 1;
return;
}
if (g_dirty && !scene_waits_for_game(now)) render_scene();
}
@@ -3440,13 +3482,13 @@ static int on_stats_timer(void *data) {
if (g_pace.ticks || g_pace.renders || game || g_pace.reattaches || g_pace.null_attaches || g_pace.distinct ||
g_pace.presented || g_pace.replaced || g_pace.undrawn) {
droiddeck_log("pacing", "last 10 s: tick reaches compositor %.2f/%.2f ms late (%u ticks, %u over 2 ms) | "
"new frame waits %.2f/%.2f ms to be drawn (%u scenes) | %llu game frames, %u re-attached after an "
"new frame waits %.2f/%.2f ms to be drawn (%u scenes, %u on arrival) | %llu game frames, %u re-attached after an "
"empty attach, %u empty attaches, %u distinct buffers | feedback %u shown, %u replaced before drawing, "
"%u not drawn",
g_pace.ticks ? (double)g_pace.tick_late_ns / 1e6 / g_pace.ticks : 0.0, (double)g_pace.tick_late_max_ns / 1e6,
g_pace.ticks, g_pace.ticks_late_2ms,
g_pace.renders ? (double)g_pace.wait_ns / 1e6 / g_pace.renders : 0.0, (double)g_pace.wait_max_ns / 1e6,
g_pace.renders, (unsigned long long)game, g_pace.reattaches, g_pace.null_attaches, g_pace.distinct,
g_pace.renders, g_pace.commit_renders, (unsigned long long)game, g_pace.reattaches, g_pace.null_attaches, g_pace.distinct,
g_pace.presented, g_pace.replaced, g_pace.undrawn);
}
{
@@ -36,6 +36,7 @@ extern void droiddeck_wayland_output_resized(void);
extern void droiddeck_wayland_set_output_refresh_rate(int mhz);
extern volatile int g_fps_limit;
extern volatile int g_release_unpaced;
extern volatile int g_render_on_commit;
extern volatile int g_hide_shell;
extern volatile int g_zero_copy;
extern volatile unsigned g_zero_copy_last;
@@ -587,6 +588,12 @@ Java_com_droiddeck_launcher_wayland_WaylandCompositor_nativeSetLookName(JNIEnv *
free(s);
}
JNIEXPORT void JNICALL
Java_com_droiddeck_launcher_wayland_WaylandCompositor_nativeSetRenderOnCommit(JNIEnv *env, jclass clazz, jboolean on) {
g_render_on_commit = on ? 1 : 0;
__android_log_print(ANDROID_LOG_INFO, TAG, "render on commit %s", on ? "on" : "off");
}
JNIEXPORT void JNICALL
Java_com_droiddeck_launcher_wayland_WaylandCompositor_nativeSetFpsLimit(JNIEnv *env, jclass clazz, jint fps) {
g_fps_limit = fps > 0 ? fps : 0;
@@ -603,6 +603,7 @@ object SessionPrefs {
fun mangoapp(context: Context): Boolean = prefs(context).getBoolean("mangoapp", true)
fun vsyncThread(context: Context): Boolean = prefs(context).getBoolean("vsyncThread", true)
fun renderOnCommit(context: Context): Boolean = prefs(context).getBoolean("renderOnCommit", true)
fun setMangoapp(context: Context, on: Boolean) { prefs(context).edit().putBoolean("mangoapp", on).apply() }
fun zinkLazy(context: Context): Boolean = prefs(context).getBoolean("zinkLazy", true)
@@ -53,6 +53,7 @@ object CompositorHost {
fpsLimit: Int,
): Boolean {
ownVsyncThread = SessionPrefs.vsyncThread(context)
WaylandCompositor.nativeSetRenderOnCommit(SessionPrefs.renderOnCommit(context))
pace(refreshHz, fpsLimit)
if (!SessionState.running) WaylandCompositor.nativeSetOutputSize(outputWidth, outputHeight)
if (started) {
@@ -284,6 +284,8 @@ public final class WaylandCompositor {
public static native void nativeSetFpsLimit(int fps);
public static native void nativeSetRenderOnCommit(boolean on);
public static native void nativeSetGpuTurbo(boolean on);
public static native int nativeRaisePriority(int tid, int nice);
+18
View File
@@ -181,3 +181,21 @@ The nested Wayland backend's input thread reads the host display, but steamcompm
does not watch that file descriptor, so buffer releases and presentation feedback
queued by that read could wait up to one refresh for steamcompmgr's next poll. The
input thread now wakes steamcompmgr after each read.
## 0123 commit: fence lifetime fixes from upstream
Backport of upstream commits 0efe47c and 666c52b by Matthew Schwartz (ValveSoftware/gamescope).
Pending commits share ownership of their completion list with the Xwayland context, so a late
fence signal can no longer append to a list freed with the context; and a commit being destroyed
no longer hands the image waiter a new reference to itself. Both touch the code 0124 changes.
## 0124 commit: mark a finished frame done at import
Every game frame took two passes of steamcompmgr's loop: the import duplicated the buffer's
fence and handed the commit to the image waiter (epoll add), then the waiter thread saw the fence
signalled, removed and closed it and woke steamcompmgr again to handle the finished commit.
`update_wayland_res` now polls the fence without waiting first. A frame that is already finished
is marked done at once - no duplicate fence, no epoll add or delete, no waiter wake - and the main
loop handles it in the same pass, after the import (FIFO commits still wait for a vblank). The
`commit_ready_check` convar (default on, `gamescopectl commit_ready_check 0`) turns it off; the
`xwm` log counts fences ready at import and waited for, every 10 s.
@@ -0,0 +1,157 @@
diff --git a/src/commit.cpp b/src/commit.cpp
index c9d0001..f2e0f0c 100644
--- a/src/commit.cpp
+++ b/src/commit.cpp
@@ -105,14 +105,15 @@ bool commit_t::CloseFenceInternal()
if ( m_nCommitFence < 0 )
return false;
- // Will automatically remove from epoll!
- g_ImageWaiter.RemoveWaitable( this );
+ // Do not recreate an Rc after deletion has started.
+ if ( HasLiveReferences() )
+ g_ImageWaiter.RemoveWaitable( this );
close( m_nCommitFence );
m_nCommitFence = -1;
return true;
}
-void commit_t::SetFence( int nFence, bool bMangoNudge, uint32_t uMangoMsgType, CommitDoneList_t *pDoneCommits )
+void commit_t::SetFence( int nFence, bool bMangoNudge, uint32_t uMangoMsgType, const std::shared_ptr<CommitDoneList_t> &pDoneCommits )
{
std::unique_lock lock( m_WaitableCommitStateMutex );
CloseFenceInternal();
diff --git a/src/commit.h b/src/commit.h
index 20f881d..8603a9a 100644
--- a/src/commit.h
+++ b/src/commit.h
@@ -1,6 +1,7 @@
#include "steamcompmgr_shared.hpp"
#include "Utils/NonCopyable.h"
+#include <memory>
#include <optional>
#include "main.hpp"
#include "rendervulkan.hpp"
@@ -34,7 +35,7 @@ struct commit_t final : public gamescope::RcObject, public gamescope::IWaitable,
// Returns true if we had a fence that was closed.
bool CloseFenceInternal();
- void SetFence( int nFence, bool bMangoNudge, uint32_t uMangoMsgType, CommitDoneList_t *pDoneCommits );
+ void SetFence( int nFence, bool bMangoNudge, uint32_t uMangoMsgType, const std::shared_ptr<CommitDoneList_t> &pDoneCommits );
bool ShouldPreemptivelyUpscale( GamescopeUpscaleFilter eFilter, GamescopeUpscaleScaler eScaler );
@@ -81,5 +82,5 @@ struct commit_t final : public gamescope::RcObject, public gamescope::IWaitable,
bool m_bMangoNudge = false;
// Typed mangoapp stream to nudge, 0 for none, never the legacy type.
uint32_t m_uMangoMsgType = 0;
- CommitDoneList_t *m_pDoneCommits = nullptr; // I hate this
-};
\ No newline at end of file
+ std::shared_ptr<CommitDoneList_t> m_pDoneCommits; // I hate this
+};
diff --git a/src/steamcompmgr.cpp b/src/steamcompmgr.cpp
index 5fb9086..22aa907 100644
--- a/src/steamcompmgr.cpp
+++ b/src/steamcompmgr.cpp
@@ -932,7 +932,7 @@ constexpr const T& clamp( const T& x, const T& min, const T& max )
extern bool g_bForceRelativeMouse;
-CommitDoneList_t g_steamcompmgr_xdg_done_commits;
+std::shared_ptr<CommitDoneList_t> g_steamcompmgr_xdg_done_commits = std::make_shared<CommitDoneList_t>();
static std::mutex s_KeysToCloseMutex;
@@ -8073,7 +8073,7 @@ bool handle_done_commit( steamcompmgr_win_t *w, xwayland_ctx_t *ctx, uint64_t co
// TODO: Merge these two functions.
void handle_done_commits_xwayland( xwayland_ctx_t *ctx, bool vblank, uint64_t vblank_idx )
{
- std::lock_guard<std::mutex> lock( ctx->doneCommits.listCommitsDoneLock );
+ std::lock_guard<std::mutex> lock( ctx->doneCommits->listCommitsDoneLock );
uint64_t next_refresh_time = g_SteamCompMgrVBlankTime.schedule.ulTargetVBlank;
@@ -8090,7 +8090,7 @@ void handle_done_commits_xwayland( xwayland_ctx_t *ctx, bool vblank, uint64_t vb
uint64_t now = get_time_in_nanos();
// very fast loop yes
- for ( auto& entry : ctx->doneCommits.listCommitsDone )
+ for ( auto& entry : ctx->doneCommits->listCommitsDone )
{
steamcompmgr_win_t *entry_win = nullptr;
for ( steamcompmgr_win_t *w = ctx->list; w; w = w->xwayland().next )
@@ -8130,12 +8130,12 @@ void handle_done_commits_xwayland( xwayland_ctx_t *ctx, bool vblank, uint64_t vb
}
}
- ctx->doneCommits.listCommitsDone.swap( commits_before_their_time );
+ ctx->doneCommits->listCommitsDone.swap( commits_before_their_time );
}
void handle_done_commits_xdg( bool vblank, uint64_t vblank_idx )
{
- std::lock_guard<std::mutex> lock( g_steamcompmgr_xdg_done_commits.listCommitsDoneLock );
+ std::lock_guard<std::mutex> lock( g_steamcompmgr_xdg_done_commits->listCommitsDoneLock );
uint64_t next_refresh_time = g_SteamCompMgrVBlankTime.schedule.ulTargetVBlank;
@@ -8152,7 +8152,7 @@ void handle_done_commits_xdg( bool vblank, uint64_t vblank_idx )
uint64_t now = get_time_in_nanos();
// very fast loop yes
- for ( auto& entry : g_steamcompmgr_xdg_done_commits.listCommitsDone )
+ for ( auto& entry : g_steamcompmgr_xdg_done_commits->listCommitsDone )
{
steamcompmgr_win_t *entry_win = nullptr;
for (const auto& xdg_win : g_steamcompmgr_xdg_wins)
@@ -8192,7 +8192,7 @@ void handle_done_commits_xdg( bool vblank, uint64_t vblank_idx )
}
}
- g_steamcompmgr_xdg_done_commits.listCommitsDone.swap( commits_before_their_time );
+ g_steamcompmgr_xdg_done_commits->listCommitsDone.swap( commits_before_their_time );
}
gamescope::ConVar<bool> cv_mangoapp_use_output_timing{ "mangoapp_use_output_timing", true };
@@ -8359,7 +8359,7 @@ static TempUpscaleImage_t *GetTempUpscaleImage( global_focus_t *pFocus, uint32_t
gamescope::ConVar<bool> cv_surface_update_force_only_current_surface( "surface_update_force_only_current_surface", false, "Force updates to apply only to the current surface, ignoring commits for other surfaces." );
-void update_wayland_res(CommitDoneList_t *doneCommits, steamcompmgr_win_t *w, ResListEntry_t& reslistentry)
+void update_wayland_res(const std::shared_ptr<CommitDoneList_t> &doneCommits, steamcompmgr_win_t *w, ResListEntry_t& reslistentry)
{
struct wlr_buffer *buf = reslistentry.buf;
@@ -8632,7 +8632,7 @@ void check_new_xwayland_res(xwayland_ctx_t *ctx)
for ( uint32_t i = 0; i < tmp_queue.size(); i++ )
{
steamcompmgr_win_t *w = find_win( ctx, tmp_queue[ i ].surf );
- update_wayland_res( &ctx->doneCommits, w, tmp_queue[ i ]);
+ update_wayland_res( ctx->doneCommits, w, tmp_queue[ i ]);
}
}
@@ -8645,7 +8645,7 @@ void check_new_xdg_res()
{
if ( xdg_win->xdg().surface.main_surface == tmp_queue[ i ].surf )
{
- update_wayland_res( &g_steamcompmgr_xdg_done_commits, xdg_win.get(), tmp_queue[ i ] );
+ update_wayland_res( g_steamcompmgr_xdg_done_commits, xdg_win.get(), tmp_queue[ i ] );
break;
}
}
diff --git a/src/xwayland_ctx.hpp b/src/xwayland_ctx.hpp
index 81910a1..3a75650 100644
--- a/src/xwayland_ctx.hpp
+++ b/src/xwayland_ctx.hpp
@@ -92,7 +92,7 @@ struct xwayland_ctx_t final : public gamescope::IWaitable
std::unique_ptr<MouseCursor> cursor;
- CommitDoneList_t doneCommits;
+ std::shared_ptr<CommitDoneList_t> doneCommits = std::make_shared<CommitDoneList_t>();
double accum_x = 0.0;
double accum_y = 0.0;
@@ -0,0 +1,103 @@
diff --git a/src/steamcompmgr.cpp b/src/steamcompmgr.cpp
index 22aa907..0aef598 100644
--- a/src/steamcompmgr.cpp
+++ b/src/steamcompmgr.cpp
@@ -8359,6 +8359,33 @@ static TempUpscaleImage_t *GetTempUpscaleImage( global_focus_t *pFocus, uint32_t
gamescope::ConVar<bool> cv_surface_update_force_only_current_surface( "surface_update_force_only_current_surface", false, "Force updates to apply only to the current surface, ignoring commits for other surfaces." );
+gamescope::ConVar<bool> cv_commit_ready_check( "commit_ready_check", true, "Check a new commit's fence at import; a finished frame is marked done in the same pass instead of through the image waiter." );
+
+// Set when update_wayland_res marks a commit done itself, so the main loop handles it in the same pass.
+static bool s_bXwaylandCommitsDoneAtImport = false;
+static bool s_bXdgCommitsDoneAtImport = false;
+
+static bool commit_fence_ready_now( int nFd )
+{
+ struct pollfd pfd = { .fd = nFd, .events = POLLIN, .revents = 0 };
+ return poll( &pfd, 1, 0 ) == 1 && ( pfd.revents & POLLIN );
+}
+
+static void note_commit_fence( bool bReadyAtImport )
+{
+ static uint64_t s_ulReady = 0, s_ulWaited = 0, s_ulLastLog = 0;
+ ( bReadyAtImport ? s_ulReady : s_ulWaited )++;
+ uint64_t now = get_time_in_nanos();
+ if ( !s_ulLastLog )
+ s_ulLastLog = now;
+ if ( now - s_ulLastLog >= 10'000'000'000ul )
+ {
+ xwm_log.infof( "commit fences, last 10 s: %lu ready at import, %lu waited for", s_ulReady, s_ulWaited );
+ s_ulReady = s_ulWaited = 0;
+ s_ulLastLog = now;
+ }
+}
+
void update_wayland_res(const std::shared_ptr<CommitDoneList_t> &doneCommits, steamcompmgr_win_t *w, ResListEntry_t& reslistentry)
{
struct wlr_buffer *buf = reslistentry.buf;
@@ -8602,7 +8629,11 @@ void update_wayland_res(const std::shared_ptr<CommitDoneList_t> &doneCommits, st
struct wlr_dmabuf_attributes dmabuf = {0};
if ( wlr_buffer_get_dmabuf( buf, &dmabuf ) )
{
- fence = dup( dmabuf.fd[0] );
+ // A finished buffer needs no fence of its own.
+ if ( cv_commit_ready_check && commit_fence_ready_now( dmabuf.fd[0] ) )
+ bKnownReady = true;
+ else
+ fence = dup( dmabuf.fd[0] );
}
else
{
@@ -8610,11 +8641,22 @@ void update_wayland_res(const std::shared_ptr<CommitDoneList_t> &doneCommits, st
}
}
+ if ( cv_commit_ready_check )
+ {
+ if ( !bKnownReady && fence >= 0 && commit_fence_ready_now( fence ) )
+ bKnownReady = true;
+ note_commit_fence( bKnownReady );
+ }
+
gpuvis_trace_printf( "pushing wait for commit %lu win %lx", newCommit->commitID, w->type == steamcompmgr_win_type_t::XWAYLAND ? w->xwayland().id : 0 );
{
newCommit->SetFence( fence, mango_nudge, uMangoMsgType, doneCommits );
if ( bKnownReady )
+ {
newCommit->Signal();
+ if ( cv_commit_ready_check )
+ ( w->type == steamcompmgr_win_type_t::XWAYLAND ? s_bXwaylandCommitsDoneAtImport : s_bXdgCommitsDoneAtImport ) = true;
+ }
else
g_ImageWaiter.AddWaitable( newCommit.get() );
}
@@ -9400,6 +9442,13 @@ void steamcompmgr_check_xdg(bool vblank, uint64_t vblank_idx)
}
check_new_xdg_res();
+
+ // Commits marked done at import: handle them now rather than on the next wake. FIFO commits still wait for a vblank.
+ if ( s_bXdgCommitsDoneAtImport )
+ {
+ s_bXdgCommitsDoneAtImport = false;
+ handle_done_commits_xdg( false, vblank_idx );
+ }
}
void update_edid_prop()
@@ -10512,6 +10561,14 @@ steamcompmgr_main(int argc, char **argv)
gamescope_xwayland_server_t *server = NULL;
for (size_t i = 0; (server = wlserver_get_xwayland_server(i)); i++)
check_new_xwayland_res(server->ctx.get());
+
+ // Commits marked done at import: handle them now rather than on the next wake. FIFO commits still wait for a vblank.
+ if ( s_bXwaylandCommitsDoneAtImport )
+ {
+ s_bXwaylandCommitsDoneAtImport = false;
+ for (size_t i = 0; (server = wlserver_get_xwayland_server(i)); i++)
+ handle_done_commits_xwayland(server->ctx.get(), false, vblank_idx);
+ }
}
+2 -2
View File
@@ -1,3 +1,3 @@
GAMESCOPE_REPO=Droid-Deck/DroidDeck-Components
GAMESCOPE_TAG=gamescope-3.16.29-p17
GAMESCOPE_SHA256=18e2b65407c5775301abdbc9f0db7df6b0e653923afcebdaa0f1ea3b9d5d5bb4
GAMESCOPE_TAG=gamescope-3.16.29-p18
GAMESCOPE_SHA256=a79d8acc5628973c807a43524638c20e7d5c101a4fc3bcb8b5068631e6f6fe55
@@ -276,6 +276,18 @@ bl_vacdiag() {
}
"""
# Steam's shader pre-caching runs its D3D driver query through every Proton tool at each start, as
# "run <client>/bin/d3ddriverquery64.exe" in compatdata/0. Here it has never succeeded (exit 1 every time), and each
# run started Wine in compatdata/0, where the two Protons upgrade the prefix back and forth for many seconds while the
# game starts. Steam gets the same failure without starting Wine; other verbs and prefixes are left alone.
BL_DRIVER_QUERY_SKIP = """
case "$verb:${1##*/}:${STEAM_COMPAT_DATA_PATH%/}" in
run:d3ddriverquery64.exe:*/compatdata/0 | run:d3ddriverquery.exe:*/compatdata/0)
echo "droiddeck-proton: Steam's D3D driver query is not run (it fails here and would start Wine in compatdata/0)" >&2
exit 1 ;;
esac
"""
BL_DIRECTAUDIO_SETUP = """
bl_is_steam_installscript_target() {
local target=${1:-}
@@ -408,7 +420,7 @@ LAUNCHER_TEMPLATE = LAUNCHER_SH
def launcher_sh(sources=SOURCES):
return (LAUNCHER_TEMPLATE % " ".join('"%s"' % n for n in sources)).replace(
"verb=$1; shift", "verb=$1; shift\n" + BL_DESKTOP_GPU_SETUP + BL_DIRECTAUDIO_SETUP + BL_GAME_CPUS_SETUP + BL_IDTECH3_SETUP
"verb=$1; shift", "verb=$1; shift\n" + BL_DRIVER_QUERY_SKIP + BL_DESKTOP_GPU_SETUP + BL_DIRECTAUDIO_SETUP + BL_GAME_CPUS_SETUP + BL_IDTECH3_SETUP
+ BL_VACDIAG_SETUP + BL_COMPONENTS_SETUP + BL_LIBPATH_SETUP + BL_STORE_SETUP, 1)
@@ -455,6 +467,15 @@ bl_store_launch "$@"
BL_STORE_ARGS=("$@")
bl_run ${BL_TASKSET:-} /usr/local/bin/droiddeck-game-env "$BL_STORE_PROTON" "$verb" "$@" "${BL_EXTRA_ARGS[@]}"
"""
def extra_wrapper_sh(entry_point):
return (EXTRA_WRAPPER_SH % entry_point).replace(
'here=$(dirname "$0")',
'here=$(dirname "$0")\n' + BL_DRIVER_QUERY_SKIP + BL_DESKTOP_GPU_SETUP + BL_DIRECTAUDIO_SETUP + BL_GAME_CPUS_SETUP
+ BL_IDTECH3_SETUP + BL_VACDIAG_SETUP + BL_COMPONENTS_SETUP + BL_LIBPATH_SETUP + BL_STORE_SETUP, 1)
EXTRA_COMPAT_TOOL_VDF = """"compatibilitytools"
{
"compat_tools"
@@ -678,11 +699,7 @@ def adopt_extras(tools):
name = first_key(compat_vdf, ["compatibilitytools", "compat_tools"]) or entry
wrapper = os.path.join(tool_dir, EXTRA_WRAPPER)
try:
body = (EXTRA_WRAPPER_SH % entry_point).replace(
'here=$(dirname "$0")',
'here=$(dirname "$0")\n' + BL_DESKTOP_GPU_SETUP + BL_DIRECTAUDIO_SETUP + BL_GAME_CPUS_SETUP + BL_IDTECH3_SETUP
+ BL_VACDIAG_SETUP + BL_COMPONENTS_SETUP + BL_LIBPATH_SETUP + BL_STORE_SETUP, 1)
write_changed(wrapper, body, 0o755)
write_changed(wrapper, extra_wrapper_sh(entry_point), 0o755)
write_changed(manifest, EXTRA_MANIFEST_VDF)
write_changed(compat_vdf, EXTRA_COMPAT_TOOL_VDF % (name, display_name(entry)))
legacy_wrapper = os.path.join(tool_dir, LEGACY_EXTRA_WRAPPER)
+30
View File
@@ -856,6 +856,36 @@ class GameEnvironmentTest(unittest.TestCase):
subprocess.run(["bash", "-n"], input=script, text=True, check=True)
self.assertIn('bl_run ${BL_TASKSET:-} /usr/local/bin/droiddeck-game-env', script)
def test_both_proton_wrappers_answer_steams_driver_query_without_wine(self):
scripts = (COMPAT["launcher_sh"](), COMPAT["extra_wrapper_sh"]("proton"))
query = "/root/.local/share/Steam/steamrtarm64/../bin/d3ddriverquery64.exe"
probe = "/root/.local/share/Steam/steamapps/compatdata/0"
for script in scripts:
subprocess.run(["bash", "-n"], input=script, text=True, check=True)
self.assertLess(script.index('case "$verb:${1##*/}:'), script.index("bl_components "))
for args, prefix in (([query, "-d3d12"], probe), ([query], probe + "/"),
([query.replace("64.exe", ".exe")], probe)):
result = subprocess.run(["bash", "-s", "run"] + args, input=script, text=True, capture_output=True,
env={"PATH": os.defpath, "HOME": "/nonexistent", "STEAM_COMPAT_DATA_PATH": prefix},
timeout=10)
self.assertEqual(result.returncode, 1, result.stderr)
self.assertEqual(result.stdout, "")
self.assertIn("D3D driver query is not run", result.stderr)
skip = COMPAT["BL_DRIVER_QUERY_SKIP"]
for verb, args, prefix in (
("getcompatpath", [query], probe),
("run", [query], "/root/.local/share/Steam/steamapps/compatdata/2276548447"),
("run", [query], None),
("waitforexitandrun", ["/games/AIO/AIO-Graphics-Test-64bit.exe", "--cube", "dx11"], probe),
("run", ["/games/Tool/tool.exe", query], probe),
("run", ["/games/d3ddriverquery64.exe.bak"], probe)):
env = {"PATH": os.defpath}
if prefix is not None:
env["STEAM_COMPAT_DATA_PATH"] = prefix
out = subprocess.run(["bash", "-c", "verb=" + verb + "\n" + skip + "echo continued", "_"] + args,
env=env, capture_output=True, text=True, check=True).stdout
self.assertEqual(out, "continued\n", (verb, args, prefix))
def test_wrappers_preload_the_session_library_before_the_input_shim(self):
overlay = "/root/.local/share/Steam/ubuntu12_64/gameoverlayrenderer.so"
with tempfile.TemporaryDirectory() as tmp:
+223
View File
@@ -0,0 +1,223 @@
import os
from pathlib import Path
import shutil
import subprocess
import sys
import tempfile
import unittest
from test_output_refresh import SOURCE, extract_function
PREAMBLE = r'''
#include <assert.h>
#include <stdatomic.h>
#include <stdint.h>
#include <stdio.h>
struct wl_event_source { int armed; };
static struct wl_event_source idle_source, timer_source;
static void (*idle_func)(void *);
static int idles_added, timers_armed, renders, window_requests, effects_changes, pose_changes;
static int64_t clock_ns;
static int g_display_storage;
static void *g_display = &g_display_storage;
static struct wl_event_source *g_render_idle, *g_fallback_timer;
static int g_fallback_armed, g_dirty, g_hud_fresh, framegen;
static void *g_hud_surface;
static int64_t g_dirty_since_ns, g_last_vsync_ns, g_tick_vsync_ns, g_hud_last_ns, g_rendered_tick_ns;
static int g_tick_held;
static int64_t g_hold_missed_ns;
#define HOLD_RETRY_NS 1000000000LL
static int64_t g_refresh_ns = 16666667;
volatile int g_render_on_commit = 1;
volatile int g_release_unpaced = 1;
static atomic_int g_stream_on;
static struct { unsigned ticks, ticks_late_2ms, commit_renders; int64_t tick_late_ns, tick_late_max_ns; } g_pace;
static struct { unsigned ticks; } g_perf;
static int64_t now_ns(void) { return clock_ns; }
static void *wl_display_get_event_loop(void *display) { return display; }
static struct wl_event_source *wl_event_loop_add_idle(void *loop, void (*func)(void *), void *data) {
idles_added++; idle_func = func; return &idle_source;
}
static struct wl_event_source *wl_event_loop_add_timer(void *loop, int (*func)(void *), void *data) { return &timer_source; }
static int wl_event_source_timer_update(struct wl_event_source *source, int ms) { timers_armed++; return 0; }
static int vkp_framegen_active(void) { return framegen; }
static int vkp_apply_window_request(void) { return window_requests; }
static int vkp_effects_sync(void) { return effects_changes; }
static int vkp_cardboard_pose_changed(void) { return pose_changes; }
static void render_scene(void) { renders++; g_dirty = 0; g_dirty_since_ns = 0; g_rendered_tick_ns = g_tick_vsync_ns; g_tick_held = 0; }
static int on_fallback_timer(void *data) { return 0; }
static void on_commit_idle(void *data);
'''
CHECKS = r'''
static void run_idle(void) {
void (*func)(void *) = idle_func;
idle_func = NULL;
if (func) func(NULL);
}
static void tick(int64_t t) { clock_ns = t; on_vsync(t); }
static void arrive(int64_t after_ns) { clock_ns += after_ns; schedule_render(); }
int main(void) {
const int64_t refresh = 6944444, ms = 1000000;
int64_t t = 1000000000LL;
int r0;
unsigned c0;
g_refresh_ns = refresh;
tick(t);
assert(renders == 0);
/* a new frame is drawn when it arrives */
arrive(2 * ms);
assert(idles_added == 1 && renders == 0);
run_idle();
assert(renders == 1 && g_pace.commit_renders == 1 && g_render_idle == NULL);
/* a second frame in the same refresh is left for the next arrival, which is drawn when it arrives */
arrive(1 * ms);
assert(idles_added == 1);
tick(t += refresh);
assert(renders == 1 && g_tick_held == 1);
arrive(2 * ms);
assert(idles_added == 2);
run_idle();
assert(renders == 2 && g_pace.commit_renders == 2 && g_tick_held == 0);
/* a frame no other frame follows is drawn at the tick after next */
arrive(1 * ms);
tick(t += refresh);
assert(renders == 2);
tick(t += refresh);
assert(renders == 3 && g_pace.commit_renders == 2);
/* after that, the tick draws every frame for a second, then holds one again */
arrive(1 * ms);
tick(t += refresh);
assert(renders == 4 && g_tick_held == 0);
t += HOLD_RETRY_NS;
tick(t);
arrive(1 * ms);
run_idle();
arrive(1 * ms);
tick(t += refresh);
assert(renders == 5 && g_tick_held == 1);
arrive(2 * ms);
run_idle();
assert(renders == 6 && g_pace.commit_renders == 4);
/* one frame per refresh, starting right after a tick draw, settles on drawing every frame when it arrives */
window_requests = 1;
tick(t += refresh);
window_requests = 0;
arrive(2 * ms);
r0 = renders; c0 = g_pace.commit_renders;
for (int i = 0; i < 10; i++) {
tick(t += refresh);
arrive(2 * ms);
run_idle();
}
assert(renders - r0 == 10 && g_pace.commit_renders - c0 == 10);
/* a client that draws again only after its frame callback (sent when the scene is drawn) keeps one frame
per refresh: two held frames in 200 refreshes, about 1.4 s */
r0 = renders; c0 = g_pace.commit_renders;
{
int seen = renders - 1;
for (int i = 0; i < 200; i++) {
if (renders != seen) { seen = renders; arrive(1 * ms); run_idle(); }
tick(t += refresh);
}
}
assert(renders - r0 == 198 && g_pace.commit_renders == c0);
/* a window, effect or headset change at the tick draws the waiting frame now */
t += HOLD_RETRY_NS;
tick(t);
arrive(1 * ms);
run_idle();
r0 = renders;
arrive(1 * ms);
window_requests = 1;
tick(t += refresh);
window_requests = 0;
assert(renders - r0 == 1 && g_tick_held == 0);
/* a draw queued before the tick still draws the frame once */
tick(t += refresh);
r0 = renders; c0 = g_pace.commit_renders;
arrive(1 * ms);
tick(t += refresh);
assert(renders == r0);
run_idle();
assert(renders - r0 == 1 && g_pace.commit_renders - c0 == 1);
tick(t += refresh);
assert(renders - r0 == 1);
/* streaming switched on after the draw was queued leaves the frame for the tick */
tick(t += refresh);
r0 = renders; c0 = g_pace.commit_renders;
arrive(1 * ms);
atomic_store(&g_stream_on, 1);
run_idle();
assert(renders == r0);
tick(t += refresh);
atomic_store(&g_stream_on, 0);
assert(renders - r0 == 1 && g_pace.commit_renders == c0);
/* paced output, frame generation, the switch off and streaming keep drawing on the tick */
const int idles = idles_added;
r0 = renders;
for (int c = 0; c < 4; c++) {
tick(t += refresh);
if (c == 0) g_release_unpaced = 0;
if (c == 1) framegen = 1;
if (c == 2) g_render_on_commit = 0;
if (c == 3) atomic_store(&g_stream_on, 1);
arrive(1 * ms);
assert(idles_added == idles);
tick(t += refresh);
g_release_unpaced = 1; framegen = 0; g_render_on_commit = 1; atomic_store(&g_stream_on, 0);
assert(renders - r0 == c + 1);
}
/* without screen ticks the fallback timer still draws */
clock_ns += 200000000LL;
schedule_render();
assert(idles_added == idles && g_fallback_armed == 1 && timers_armed == 1);
puts("PASS");
return 0;
}
'''
@unittest.skipUnless(sys.platform.startswith('linux'), 'needs a Linux host compiler')
class RenderOnCommitTest(unittest.TestCase):
def test_a_new_frame_is_drawn_on_arrival_at_most_once_per_refresh(self):
compiler = shutil.which(os.environ.get('CC', 'cc'))
if compiler is None:
self.skipTest('A host C compiler is required')
source = SOURCE.read_text()
render = extract_function(source, 'render_scene')
self.assertIn('g_rendered_tick_ns = g_tick_vsync_ns;', render)
self.assertIn('g_tick_held = 0;', render)
functions = ('commit_renders_on', 'render_on_commit', 'schedule_render', 'scene_waits_for_game', 'on_commit_idle', 'on_vsync')
harness = PREAMBLE + '\n'.join(extract_function(source, name) for name in functions) + CHECKS
with tempfile.TemporaryDirectory(prefix='droiddeck-render-on-commit-') as folder:
path = Path(folder)
(path / 'commit.c').write_text(harness)
binary = path / 'commit-test'
build = subprocess.run([compiler, '-std=c11', '-Wall', '-Wextra', '-Werror',
'-Wno-unused-parameter', '-Wno-unused-function', '-O2',
str(path / 'commit.c'), '-o', str(binary)], capture_output=True, text=True)
self.assertEqual(0, build.returncode, build.stderr)
result = subprocess.run([str(binary)], capture_output=True, text=True, timeout=10)
self.assertEqual(0, result.returncode, result.stderr)
self.assertEqual('PASS', result.stdout.strip())
if __name__ == '__main__':
unittest.main()