Skip to content

protocols: Add fifo-v1 and commit-timing-v1#11703

Closed
vaxerski wants to merge 1 commit into
hyprwm:mainfrom
vaxerski:fifo-ct
Closed

protocols: Add fifo-v1 and commit-timing-v1#11703
vaxerski wants to merge 1 commit into
hyprwm:mainfrom
vaxerski:fifo-ct

Conversation

@vaxerski
Copy link
Copy Markdown
Member

Fixes #11386

Needs some testing, I didn't test this because I dont know what apps use it.

If anyone has a test app, do lmk.

@Justsnoopy30 @fxzzi

@vaxerski
Copy link
Copy Markdown
Member Author

Also @ikalco @gulafaran I touched your surface commit things. Might wanna verify I didn't exactly fuk something up

@vaxerski
Copy link
Copy Markdown
Member Author

@fufexan wp bump needed tooooo.... idk which version, fifo and ct

@fxzzi
Copy link
Copy Markdown
Contributor

fxzzi commented Sep 14, 2025

Games using SDL3 (SDL2 as well, not sure?) should be taking advantage of these two protos. As indicated, SDL should automatically pick Wayland as its default backend now that these are available to it. CS2 will still default to XWL for now as they've manually added an env var to their launch script to use x11 SDL backend.

Comment thread src/protocols/Fifo.hpp
@vaxerski
Copy link
Copy Markdown
Member Author

I tried PPSSPP with wayland backend and it didnt bind to either fifo or ct

@fufexan
Copy link
Copy Markdown
Member

fufexan commented Sep 14, 2025

@fufexan wp bump needed tooooo.... idk which version, fifo and ct

not needed, they've been available since 1.38. We have 1.45.

@vaxerski
Copy link
Copy Markdown
Member Author

vaxerski commented Sep 14, 2025

why is ci failing then huh

oh I forgor mesonnn

Comment thread src/protocols/Fifo.cpp Outdated
Comment thread src/protocols/CommitTiming.cpp
Comment thread src/protocols/Fifo.cpp Outdated
@vaxerski
Copy link
Copy Markdown
Member Author

@ikalco check now

@fxzzi
Copy link
Copy Markdown
Contributor

fxzzi commented Sep 15, 2025

hyprlandCrashReport105723.txt

crash to tty when trying to launch CS2 with SDL_VIDEO_DRIVER=wayland, nvidia
wleave (gtk4, GSK_RENDERER default vulkan) also crashing to tty

@vaxerski
Copy link
Copy Markdown
Member Author

oops fixer

@fxzzi
Copy link
Copy Markdown
Contributor

fxzzi commented Sep 15, 2025

PXL_20250915_193818758.TS-scaled.mp4

cs2 now launches, though lots of flickering is present as shown by above video (sorry for shitty camera angle)

explicit sync does seem to be in use as indicated by WAYLAND_DEBUG logs

image
[ 915462.444] {Default Queue} wl_registry#2.global(56, "wp_fifo_manager_v1", 1)
[ 915462.445] {Default Queue} wl_registry#2.global(57, "wp_commit_timing_manager_v1", 1)

also present in logs, does this mean it's attempting to use them?

@Zebra2711
Copy link
Copy Markdown
Contributor

If anyone has a test app, do lmk.

mpv has implemented fifo-v1 (mpv-player/mpv@39b53dd)

@vaxerski
Copy link
Copy Markdown
Member Author

also present in logs, does this mean it's attempting to use them?

No, it has to be bind.

@vaxerski
Copy link
Copy Markdown
Member Author

check flicker now

@vaxerski
Copy link
Copy Markdown
Member Author

@Zebra2711 I can't get mpv to bind to fifo. mpv ./file.mp4 --gpu-api=vulkan

@fxzzi
Copy link
Copy Markdown
Contributor

fxzzi commented Sep 16, 2025

check flicker now

naw, still cooked. The flicker looks exactly like the flicker from pre-explicit-sync days. Discord flickering, steam flickering, cs2 flickering, etc etc, in the same ways they used to.

@Zebra2711
Copy link
Copy Markdown
Contributor

Zebra2711 commented Sep 16, 2025

@Zebra2711 I can't get mpv to bind to fifo. mpv ./file.mp4 --gpu-api=vulkan

mpv can use fifo, but it seems like something is wrong here line 130-L147. Log failed when run with mpv log.txt

@vaxerski
Copy link
Copy Markdown
Member Author

how are you launching it to get it to use fifo?

@Zebra2711
Copy link
Copy Markdown
Contributor

how are you launching it to get it to use fifo?

i run with mpv --gpu-api=vulkan file.mp4 but mpv cannot open with this patch and fifo appeared in the log

...
[2975156.711] wl_callback#79.done(2344)
[2975156.715]  -> zwp_linux_dmabuf_v1#86.get_surface_feedback(new id zwp_linux_dmabuf_feedback_v1#79, wl_surface#7)
[2975156.717]  -> wl_display#1.sync(new id wl_callback#87)
[2975156.783] {Display Queue} wl_display#1.delete_id(76)
[2975156.787] {Display Queue} wl_display#1.delete_id(81)
[2975156.789] {Display Queue} wl_display#1.delete_id(83)
[2975156.791] {Display Queue} wl_display#1.delete_id(87)
[2975156.793] discarded wl_drm#85.device("/dev/dri/renderD128")
[2975156.796] discarded wl_drm#85.capabilities(1)
[2975156.798] discarded wl_drm#85.format(1211384385)
[2975156.800] discarded wl_drm#85.format(1211384408)
[2975156.802] discarded wl_drm#85.format(942948929)
[2975156.804] discarded wl_drm#85.format(942948952)
[2975156.806] discarded wl_drm#85.format(808669761)
[2975156.808] discarded wl_drm#85.format(808669784)
[2975156.810] discarded wl_drm#85.format(808665665)
[2975156.812] discarded wl_drm#85.format(875713089)
[2975156.814] discarded wl_drm#85.format(875708993)
[2975156.816] discarded wl_drm#85.format(875713112)
[2975156.818] discarded wl_drm#85.format(875709016)
[2975156.820] discarded wl_drm#85.format(892424769)
...
[2975185.181] {Default Queue}  -> xdg_toplevel#34.set_title("No file - mpv")
[2975185.201] {Default Queue}  -> wp_content_type_v1#37.set_content_type(0)
[2975186.448]  -> frog_color_managed_surface#52.set_known_container_color_volume(0)
[2975186.458]  -> frog_color_managed_surface#52.set_known_transfer_function(0)
[2975186.461]  -> frog_color_managed_surface#52.set_hdr_metadata(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0)
[2975186.474]  -> wp_presentation#80.feedback(wl_surface#7, new id wp_presentation_feedback#92)
[2975186.869]  -> wl_surface#7.attach(wl_buffer#83, 0, 0)
[2975186.876]  -> wl_surface#7.damage_buffer(0, 0, 2147483647, 2147483647)
[2975186.879]  -> wp_fifo_v1#82.set_barrier()
[2975186.881]  -> wp_fifo_v1#82.wait_barrier()
[2975186.883]  -> wl_surface#7.commit()
[2975186.885]  -> wp_fifo_v1#82.wait_barrier()
[2975186.887]  -> wl_surface#7.commit()
[2975187.022] {Default Queue}  -> wl_pointer#10.set_cursor(0, nil, 0, 0)
[2975187.414]  -> wp_presentation#80.feedback(wl_surface#7, new id wp_presentation_feedback#93)
[2975187.807]  -> wl_surface#7.attach(wl_buffer#76, 0, 0)
[2975187.813]  -> wl_surface#7.damage_buffer(0, 0, 2147483647, 2147483647)
[2975187.816]  -> wp_fifo_v1#82.set_barrier()
[2975187.818]  -> wp_fifo_v1#82.wait_barrier()
[2975187.820]  -> wl_surface#7.commit()
[2975187.822]  -> wp_fifo_v1#82.wait_barrier()
[2975187.824]  -> wl_surface#7.commit()
[2975200.712]  -> wp_presentation#80.feedback(wl_surface#7, new id wp_presentation_feedback#94)
[2975201.205]  -> wl_surface#7.attach(wl_buffer#89, 0, 0)
[2975201.213]  -> wl_surface#7.damage_buffer(0, 0, 2147483647, 2147483647)
[2975201.217]  -> wp_fifo_v1#82.set_barrier()
[2975201.228]  -> wp_fifo_v1#82.wait_barrier()
[2975201.231]  -> wl_surface#7.commit()
[2975201.234]  -> wp_fifo_v1#82.wait_barrier()
[2975201.238]  -> wl_surface#7.commit()
[2975209.328]  -> wp_presentation#80.feedback(wl_surface#7, new id wp_presentation_feedback#95)
[2975209.820]  -> wl_surface#7.attach(wl_buffer#91, 0, 0)
[2975209.828]  -> wl_surface#7.damage_buffer(0, 0, 2147483647, 2147483647)
[2975209.831]  -> wp_fifo_v1#82.set_barrier()
[2975209.833]  -> wp_fifo_v1#82.wait_barrier()
[2975209.835]  -> wl_surface#7.commit()
[2975209.837]  -> wp_fifo_v1#82.wait_barrier()
[2975209.839]  -> wl_surface#7.commit()

@vaxerski
Copy link
Copy Markdown
Member Author

it doesnt bind for me :(

Comment thread src/protocols/CommitTiming.cpp
Comment thread src/protocols/core/Compositor.cpp Outdated
Comment on lines +260 to +276
void CWLSurfaceResource::lockState() {
m_stateLocks++;
}

void CWLSurfaceResource::unlockState(std::optional<size_t> seq) {
RASSERT(!!m_stateLocks, "Tried to unlock an unlocked wl_surface state");
m_stateLocks--;

if (m_stateLocks)
return;

while (!m_pendingStates.empty() && (!seq || m_pendingStates.front()->seq <= *seq)) {
commitState(*m_pendingStates.front());
m_pendingStates.pop();
}
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be in SSurfaceState

currently we can skip a frame/buffer:

  1. we get commit1 with buffer1, locks = 1
  2. we get commit2 with buffer2, locks = 2
  3. buffer1 is readable, locks = 1 .... this should've applied commit1
  4. buffer2 is readable, locks = 0 .... this applies commit1 followed by commit2
  5. commit1 buffer was never applied and scanned out, so a frame is skipped

I wrote this before you added the seq mechanism, but I still think this applies cause buffer unlock isn't the only thing locking/unlocking every queued surface state

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

right... I'll rethink this tomorrow.

Copy link
Copy Markdown
Member Author

@vaxerski vaxerski Sep 18, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ikalco what about having a queue with fences?

Say we have a queue with states:
A B C D

commit comes, we insert a fence on the buffer F1

A B C D F1

more commits come:

A B C D F1 E

fifo and a new buffer is used, F2 for dma and F3 for fifo:

A B C D F1 E G F2 F3

when F1 signals, all commits before it get applied:

E G F2 F3

Now the only problem is that for E and G, as far as I understand, both F2 and F3 need to signal. This is fine though and easy code-wise.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah I think that can work
just make sure that commits without constraints are applied immediately

Comment thread src/protocols/Fifo.hpp
Comment on lines +29 to +33
SState m_current, m_pending;

struct {
CHyprSignalListener surfacePrecommit;
} m_listeners;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this should be in SSurfaceState, cause this bypasses the m_pendingStates queue

also as a clarifying note, surface commit's aren't really "double buffered"
the first "buffer" is m_pending, and then the second "buffer" is actually that m_pending is added into the m_pendingStates queue until it can be applied depending on constraints (buffer readability, commit timing timeout, fifo_barrier is unset, more stuff?)

Comment thread src/protocols/Fifo.cpp
Comment on lines +148 to +151
// Signal all surfaces
// TODO: should we wait for the correct monitor(s)?

fifo->presented();
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the monitor probably would matter because fifo proto guarantees that a surface buffer will be active for at least one refresh cycle, which depends on each monitors refresh rate

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what if its on two?

Copy link
Copy Markdown
Contributor

@ikalco ikalco Sep 16, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what if its on two?

?

it should only unlock for the corresponding monitor (PHLMONITOR m), otherwise when refresh cycles are desynced bad stuff happens (mon1 has 60hz, mon2 144hz)

@vaxerski
Copy link
Copy Markdown
Member Author

@ikalco check now, I've done locks per-state, should be better

@Zebra2711
Copy link
Copy Markdown
Contributor

mpv is able to open now, but it immediately closes when playing a video

WAYLAND_DEBUG=1 mpv --player-operation-mode=pseudo-gui
[2552434.075]  -> wl_surface#7.commit()
[2552437.929] {Display Queue} wl_display#1.delete_id(64)
[2552438.317] {Display Queue} wl_display#1.delete_id(43)
[2552438.326] {Default Queue} wl_callback#43.done(8494166)
[2552438.329] {Default Queue}  -> wl_surface#7.frame(new id wl_callback#43)
[2552438.869] wl_buffer#78.release()
[2552438.871] wl_buffer#62.release()
[2552438.872] wl_buffer#74.release()
[2552440.100] wp_presentation_feedback#64.sync_output(wl_output#29)
[2552440.111] wp_presentation_feedback#64.presented(0, 8492, 166950046, 6944299, 0, 1222610, 7)
[2552440.122]  -> wp_presentation#59.feedback(wl_surface#7, new id wp_presentation_feedback#64)
[2552440.124]  -> wp_commit_timer_v1#65.set_timestamp(0, 8495, 319201537)
[2552440.714]  -> wl_surface#7.attach(wl_buffer#62, 0, 0)
[2552440.718]  -> wl_surface#7.damage_buffer(0, 0, 2147483647, 2147483647)
[2552440.720]  -> wp_fifo_v1#63.set_barrier()
[2552440.736]  -> wp_fifo_v1#63.wait_barrier()
[2552440.738]  -> wl_surface#7.commit()
[2552440.739]  -> wp_fifo_v1#63.wait_barrier()
[2552440.740]  -> wl_surface#7.commit()
[2552444.875] {Display Queue} wl_display#1.delete_id(64)
[2552447.284] wp_presentation_feedback#64.sync_output(wl_output#29)
[2552447.293] wp_presentation_feedback#64.presented(0, 8494, 173895014, 6944299, 0, 1222611, 7)
[2552447.307]  -> wp_presentation#59.feedback(wl_surface#7, new id wp_presentation_feedback#64)
[2552447.310]  -> wp_commit_timer_v1#65.set_timestamp(0, 8495, 326148648)
[2552447.915]  -> wl_surface#7.attach(wl_buffer#74, 0, 0)
[2552447.917]  -> wl_surface#7.damage_buffer(0, 0, 2147483647, 2147483647)
[2552447.919]  -> wp_fifo_v1#63.set_barrier()
[2552447.921]  -> wp_fifo_v1#63.wait_barrier()
[2552447.922]  -> wl_surface#7.commit()
[2552447.924]  -> wp_fifo_v1#63.wait_barrier()
[2552447.926]  -> wl_surface#7.commit()
[2552447.976] {Display Queue} wl_display#1.error(wp_commit_timer_v1#65, 1, "Timestamp is already set")
wp_commit_timer_v1#65: error 1: Timestamp is already set
[2552683.804] {Default Queue}  -> ext_data_control_device_v1#3.destroy()
[2552683.818] {Default Queue}  -> ext_data_control_manager_v1#5.destroy()

full log log.txt

@vaxerski
Copy link
Copy Markdown
Member Author

check now @fxzzi

@fxzzi
Copy link
Copy Markdown
Contributor

fxzzi commented Sep 23, 2025

check now @fxzzi

rip, still bugged

@vaxerski
Copy link
Copy Markdown
Member Author

well I dunno then, and it's really annoying to dev without being able to test or debug

@Kommynct
Copy link
Copy Markdown

Let him remote innnn, dooo ittt

@vaxerski
Copy link
Copy Markdown
Member Author

I tried the weston fifo test and it seems to have passed? idk how to test this really mpv doesn't fucking want to use fifo

@Zebra2711
Copy link
Copy Markdown
Contributor

I tried the weston fifo test and it seems to have passed? idk how to test this really mpv doesn't fucking want to use fifo

I built mpv with the flag -Degl-wayland=enabled, so it could be.. :)

@vaxerski
Copy link
Copy Markdown
Member Author

ok I'll try that

@vaxerski
Copy link
Copy Markdown
Member Author

still no

@Honkazel
Copy link
Copy Markdown
Contributor

--vo=gpu-next --gpu-api=vulkan?

@g3r
Copy link
Copy Markdown

g3r commented Oct 11, 2025

I tried it and still hangs. When I run with WAYLAND_DEBUG=1 This are the last lines:

[3940647.595] {Display Queue} wl_display#1.delete_id(79)
[3940658.162] wp_presentation_feedback#79.sync_output(wl_output#28)
[3940658.204] wp_presentation_feedback#79.presented(0, 90, 816962108, 16666666, 0, 0, 7)
[3940658.236]  -> wp_presentation#55.feedback(wl_surface#7, new id wp_presentation_feedback#79)
[3940658.262]  -> wp_commit_timer_v1#62.set_timestamp(0, 90, 833128774)
[3940658.279]  -> wp_linux_drm_syncobj_surface_v1#64.set_acquire_point(wp_linux_drm_syncobj_timeline_v1#72, 0, 3)
[3940658.299]  -> wp_linux_drm_syncobj_surface_v1#64.set_release_point(wp_linux_drm_syncobj_timeline_v1#72, 0, 4)
[3940658.432]  -> wl_surface#7.attach(wl_buffer#71, 0, 0)
[3940658.457]  -> wl_surface#7.damage_buffer(0, 0, 2147483647, 2147483647)
[3940658.475]  -> wp_fifo_v1#60.set_barrier()
[3940658.486]  -> wp_fifo_v1#60.wait_barrier()
[3940658.503]  -> wl_surface#7.commit()
[3940658.516]  -> wp_fifo_v1#60.wait_barrier()
[3940658.530]  -> wl_surface#7.commit()
[3940682.620] {Display Queue} wl_display#1.delete_id(79)
^C

My mpv is the default 0.40.0 (manjaro package) with default settings. Nvidia 960.

@Honkazel
Copy link
Copy Markdown
Contributor

mpv-fifo.log
I'll also attach my log file
I don't like discarded wl_buffer#ID.release lines and lines after that, but maybe that's not the reason

@vaxerski
Copy link
Copy Markdown
Member Author

--vo=gpu-next --gpu-api=vulkan?

yup. Nothing makes it use fifo. AMD, fwiw.

@s0mebodyhelpme
Copy link
Copy Markdown

Shot in the dark here but what about:
gpu-context = waylandvk

@vaxerski
Copy link
Copy Markdown
Member Author

nope

@s0mebodyhelpme
Copy link
Copy Markdown

s0mebodyhelpme commented Oct 13, 2025

Damn. Maybe you have the following option from the manual set or, more likely, it defaults to yes behavior for this option and does not work because the protocol isn't detected by mpv when running it?

--wayland-internal-vsync=<no|auto|yes>

Controls whether to use mpv's internal vsync for Wayland-base video outputs (default: auto). This is mainly useful for benchmarking wayland VOs when combined with video-sync=display-desync, --audio=no, and --untimed=yes. The special auto value will disable the internal vsync if the compositor supports the fifo protocol and version 2 of the presentation time protocol when using --gpu-api=vulkan. In any other situation, it is exactly the same as yes.

If the latter, try setting --wayland-interval-sync=no or something. Might force it to use your implementation of the wayland protocol? Again another shot in the dark, but it seems like it defaults to yes behavior if the protocol is not detected in wayland.

@vaxerski
Copy link
Copy Markdown
Member Author

I tried that too, I think I tried fucking everything at this point. I can see fifo v1 in WAYLAND_DEBUG so it is exported.

@AntoSkate
Copy link
Copy Markdown

Maybe vkcube --wsi wayland --present_mode 2 works? If it doesn't you should try with mesa-git or something ig

@Honkazel
Copy link
Copy Markdown
Contributor

fifo-v1 already in mesa from 24.3, lol

@vaxerski
Copy link
Copy Markdown
Member Author

nope, doesnt bind fifo

@UjinT34
Copy link
Copy Markdown
Contributor

UjinT34 commented Oct 15, 2025

nope, doesnt bind fifo

vkcube doesn't bind? binds for me on nvidia... hangs immediately
fifo.log

@AntoSkate
Copy link
Copy Markdown

AntoSkate commented Oct 15, 2025

fifo-v1 already in mesa from 24.3, lol

Yeah I just meant recompiling locally cause maybe it's just a packaging issue or something like that

@UjinT34
Copy link
Copy Markdown
Contributor

UjinT34 commented Oct 15, 2025

It keeps going for some time with CFifoResource::presented with barrierSet=true, surfaceLocked=true and m_locks=1 and a bunch of surfacePrecommit per CFifoResource::presented. Then for some reason m_locks goes up to 3 and it keeps spamming CFifoResource::presented with barrierSet=false, surfaceLocked=false and a falsy m_current.lock && m_current.lock->m_lock. Some race condition?

@vaxerski
Copy link
Copy Markdown
Member Author

tom is working on his own cuz I cant for the life of me test this #12052

@gulafaran
Copy link
Copy Markdown
Contributor

think i got fifo working, mpv, vkcube seems happy. anyone knows what i can test commit-timing-v1 with?

@AntoSkate
Copy link
Copy Markdown

think i got fifo working, mpv, vkcube seems happy. anyone knows what i can test commit-timing-v1 with?

vulkan fifo is implemented using both protocols in mesa (https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/26150) so mpv and vkcube should be ok to test it too ig

@Gliczy
Copy link
Copy Markdown
Contributor

Gliczy commented Oct 16, 2025

think i got fifo working, mpv, vkcube seems happy. anyone knows what i can test commit-timing-v1 with?

vulkan fifo is implemented using both protocols in mesa (https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/26150) so mpv and vkcube should be ok to test it too ig

It was later relaxed to be able to use FIFO without commit-timing in https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/32556.

@gulafaran
Copy link
Copy Markdown
Contributor

ok feel free to test #12052 , im not sure i got all the protocol things correct but vkcube,cs2,mpv seems happy now. and it kinda changed all sorts of buffer commit/release things so it might just end up regressing vrr or other things.

@vaxerski vaxerski closed this Oct 27, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Implement fifo v1