Skip to content

Conversation

vaxerski
Copy link
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
Member Author

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

@vaxerski
Copy link
Member Author

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

@fxzzi
Copy link
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.

@vaxerski
Copy link
Member Author

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

@fufexan
Copy link
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
Member Author

vaxerski commented Sep 14, 2025

why is ci failing then huh

oh I forgor mesonnn

@vaxerski
Copy link
Member Author

@ikalco check now

@fxzzi
Copy link
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
Member Author

oops fixer

@fxzzi
Copy link
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
Contributor

If anyone has a test app, do lmk.

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

@vaxerski
Copy link
Member Author

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

No, it has to be bind.

@vaxerski
Copy link
Member Author

check flicker now

@vaxerski
Copy link
Member Author

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

@fxzzi
Copy link
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
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
Member Author

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

@Zebra2711
Copy link
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
Member Author

it doesnt bind for me :(

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
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
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
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
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 on lines +29 to +33
SState m_current, m_pending;

struct {
CHyprSignalListener surfacePrecommit;
} m_listeners;
Copy link
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 on lines +148 to +151
// Signal all surfaces
// TODO: should we wait for the correct monitor(s)?

fifo->presented();
Copy link
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
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
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
Member Author

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

@Zebra2711
Copy link
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
Member Author

ew

@vaxerski
Copy link
Member Author

now?

@Zebra2711
Copy link
Contributor

now?

now it just freezes :)

log.txt

@vaxerski
Copy link
Member Author

stellar

@vaxerski
Copy link
Member Author

this should help

@Zebra2711
Copy link
Contributor

it plays a few frames and then freezes again

log.txt

@vaxerski
Copy link
Member Author

@ikalco any idea? I still can't test

@vaxerski
Copy link
Member Author

check now @fxzzi

@fxzzi
Copy link
Contributor

fxzzi commented Sep 23, 2025

check now @fxzzi

rip, still bugged

@vaxerski
Copy link
Member Author

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

@Kommynct
Copy link

Let him remote innnn, dooo ittt

@M-UnityDev
Copy link

M-UnityDev commented Oct 2, 2025

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

image

I noticed that Godot gives a warning about this protocol when launching the game so maybe you can use a wayland native build of my tech demo to test how your protocol implementation works

(there is also an auto generated sh script that will output debug info to the terminal)

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
7 participants