Commit graph

275 commits

Author SHA1 Message Date
Pierre-Loup A. Griffais
fb2fd1127a Revert "Hold client buffers till KMS stops using them"
This reverts commit c9e11ebdbf.
2020-07-24 15:01:28 -07:00
Pierre-Loup A. Griffais
a39fddf909
Update README.md 2020-07-23 14:06:54 -07:00
Simon Ser
77722293f3 Don't use VK_STRUCTURE_TYPE_WSI_IMAGE_CREATE_INFO_MESA for imported DMA-BUFs
We don't know whether clients create scanout-able DMA-BUFs.
2020-07-23 22:41:56 +02:00
Simon Ser
c9e11ebdbf Hold client buffers till KMS stops using them 2020-07-23 22:26:06 +02:00
Simon Ser
9c9a8093ee Copy commit queue in check_new_wayland_res
This will allow us to call wlr_buffer_lock/unlock in import_commit without
causing a deadlock.
2020-07-23 22:26:06 +02:00
Simon Ser
789f009a53 Add wlr_buffer to commit queue
This lets us keep the buffers for pending commits locked.
2020-07-23 22:26:06 +02:00
Simon Ser
98e263c37d Hold buffers till steamcompmgr processes them 2020-07-23 22:26:06 +02:00
Simon Ser
b7505b23cf Get DMA-BUF from wlr_buffer if possible
wlr_texture_to_dmabuf involves issuing EGL commands to get a DMA-BUF out
of an EGLImage.

When the client submits a DMA-BUF via the linux-dmabuf protocol, there's
no need to go through EGL. We can directly import the client's DMA-BUF
into Vulkan.

The old code is still retained as a fallback in case the client uses
wl_drm (old Xwayland) or wl_shm. Removing it would involve creating a
Vulkan-based wlr_renderer.

References: https://github.com/Plagman/gamescope/issues/16
2020-07-23 22:14:17 +02:00
Simon Ser
4ddb892d4f
wlserver: listen for new_input on the multi backend
The multi backend aggregates all input devices. No need to have a
different listener for headless and libinput.
2020-07-23 13:52:07 +02:00
Simon Ser
7785ed9cdb
Upgrade to wlroots 0.11.0 2020-07-23 13:37:33 +02:00
Pierre-Loup A. Griffais
064d132c93 wlserver: Fix use-after-free of wlr_surface in steamcompmgr. 2020-07-03 15:05:00 -07:00
Pierre-Loup A. Griffais
2e7f86f80c steamcompmgr: Only raise new windows if they want to be.
Leaves embed tray icon windows to take care of.
2020-07-03 14:27:57 -07:00
Pierre-Loup A. Griffais
6d65808e0a steamcompmgr: implement _NET_ACTIVE_WINDOW.
Doesn't actually seem to be used for the newly-mapped Origin setup
window, so hacks have to stay in for the time being until that's
understood.
2020-07-03 14:01:08 -07:00
Pierre-Loup A. Griffais
d95d4bf796 steamcompmgr: focus tweaks/hacks when out of game.
Avoid override redirect windows.

Raise new windows, don't focus tiny windows. If we only raised windows
that want to be activated, we probably wouldn't need the hack to filter
out small windows. TBD.
2020-07-03 13:00:09 -07:00
Pierre-Loup A. Griffais
575171360b wlserver: properly handle touch for scaled windows.
Gets scale from steamcompmgr in an extremely safe and elegant way.
2020-07-02 17:40:31 -07:00
Pierre-Loup A. Griffais
76b7d58a74 Show cursor always, not just in-game.
Will do a cosmetic pass later but unblock using Steam windows that use
OS cursor for now.
2020-06-29 13:46:36 -07:00
Simon Ser
4524ac3cbb
Fix alloc-dealloc-mismatch in add_win
ASan trace:

    ==14537==ERROR: AddressSanitizer: alloc-dealloc-mismatch (operator new vs free) on 0x6120002290c0
    DispatchAsyncEvent backlog, failed to dispatch all this frame. Queue depth: 1685 (1687 input number was)
        #0 0x7f44ebe590e9 in __interceptor_free /build/gcc/src/gcc/libsanitizer/asan/asan_malloc_linux.cpp:123
        #1 0x555b4b76b66f in add_win ../src/steamcompmgr.cpp:1550
        #2 0x555b4b7735d4 in steamcompmgr_main(int, char**) ../src/steamcompmgr.cpp:2278
        #3 0x555b4b79fca5 in steamCompMgrThreadRun() ../src/main.cpp:124
        #4 0x555b4b79f5ee in void std::__invoke_impl<void, void (*)()>(std::__invoke_other, void (*&&)()) /usr/include/c++/10.1.0/bits/invoke.h:60
        #5 0x555b4b79f467 in std::__invoke_result<void (*)()>::type std::__invoke<void (*)()>(void (*&&)()) /usr/include/c++/10.1.0/bits/invoke.h:95
        #6 0x555b4b79f34b in void std:🧵:_Invoker<std::tuple<void (*)()> >::_M_invoke<0ul>(std::_Index_tuple<0ul>) /usr/include/c++/10.1.0/thread:264
        #7 0x555b4b79f28e in std:🧵:_Invoker<std::tuple<void (*)()> >::operator()() /usr/include/c++/10.1.0/thread:271
        #8 0x555b4b79ebb2 in std:🧵:_State_impl<std:🧵:_Invoker<std::tuple<void (*)()> > >::_M_run() /usr/include/c++/10.1.0/thread:215
        #9 0x7f44eb664b73 in execute_native_thread_routine /build/gcc/src/gcc/libstdc++-v3/src/c++11/thread.cc:80
        #10 0x7f44eaaad421 in start_thread (/usr/lib/libpthread.so.0+0x9421)
        #11 0x7f44ea9dcbf2 in __GI___clone (/usr/lib/libc.so.6+0xffbf2)

    0x6120002290c0 is located 0 bytes inside of 304-byte region [0x6120002290c0,0x6120002291f0)
    allocated by thread T18 here:
        #0 0x7f44ebe5af41 in operator new(unsigned long) /build/gcc/src/gcc/libsanitizer/asan/asan_new_delete.cpp:99
        #1 0x555b4b76b2ae in add_win ../src/steamcompmgr.cpp:1533
        #2 0x555b4b7735d4 in steamcompmgr_main(int, char**) ../src/steamcompmgr.cpp:2278
        #3 0x555b4b79fca5 in steamCompMgrThreadRun() ../src/main.cpp:124
        #4 0x555b4b79f5ee in void std::__invoke_impl<void, void (*)()>(std::__invoke_other, void (*&&)()) /usr/include/c++/10.1.0/bits/invoke.h:60
        #5 0x555b4b79f467 in std::__invoke_result<void (*)()>::type std::__invoke<void (*)()>(void (*&&)()) /usr/include/c++/10.1.0/bits/invoke.h:95
        #6 0x555b4b79f34b in void std:🧵:_Invoker<std::tuple<void (*)()> >::_M_invoke<0ul>(std::_Index_tuple<0ul>) /usr/include/c++/10.1.0/thread:264
        #7 0x555b4b79f28e in std:🧵:_Invoker<std::tuple<void (*)()> >::operator()() /usr/include/c++/10.1.0/thread:271
        #8 0x555b4b79ebb2 in std:🧵:_State_impl<std:🧵:_Invoker<std::tuple<void (*)()> > >::_M_run() /usr/include/c++/10.1.0/thread:215
        #9 0x7f44eb664b73 in execute_native_thread_routine /build/gcc/src/gcc/libstdc++-v3/src/c++11/thread.cc:80

    Thread T18 created by T0 here:
    DispatchAsyncEvent backlog, failed to dispatch all this frame. Queue depth: 669 (1699 input number was)
        #0 0x7f44ebdff1c7 in __interceptor_pthread_create /build/gcc/src/gcc/libsanitizer/asan/asan_interceptors.cpp:214
        #1 0x7f44eb664e49 in __gthread_create /build/gcc/src/gcc-build/x86_64-pc-linux-gnu/libstdc++-v3/include/x86_64-pc-linux-gnu/bits/gthr-default.h:663
        #2 0x7f44eb664e49 in std:🧵:_M_start_thread(std::unique_ptr<std:🧵:_State, std::default_delete<std:🧵:_State> >, void (*)()) /build/gcc/src/gcc/libstdc++-v3/src/c++11/thread.cc:135
        #3 0x555b4b79fd3e in startSteamCompMgr() ../src/main.cpp:129
        #4 0x555b4b7a725e in xwayland_ready ../src/wlserver.cpp:114
        #5 0x555b4b8dea6a in wlr_signal_emit_safe ../subprojects/wlroots/util/signal.c:29
        #6 0x555b4b8e2263 in xserver_handle_ready ../subprojects/wlroots/xwayland/server.c:234
        #7 0x7f44ebb5f434  (/usr/lib/libwayland-server.so.0+0xa434)
2020-06-18 19:03:28 +02:00
Simon Ser
5228f37089
Fix EINVAL when using direct scan-out without libliftoff
When directly scanning out game buffers, we need to make sure the game
buffer is suitable for scanout. If that's not the case, we need to
fallback to composition.

The fallback path was implemented, but we never checked whether scan-out
is possible in drm_can_avoid_composite. Perform an atomic test-only
commit to fix this.
2020-06-18 18:01:32 +02:00
Simon Ser
bae255ee1a
Get rid of C_SIDE
wlroots headers can mostly be included with extern "C" blocks. Two
exceptions are the use of `static` for array args and `class` as a
struct field. These can be #define'ed to avoid C++ build errors.

This allows the whole project to be built as a single C++ codebase,
without having to maintain hybrid header files.
2020-06-11 12:44:36 +02:00
Pierre-Loup A. Griffais
453caf7672 steamcompmgr: don't focus overlay windows, they're just there to be composited 2020-06-02 16:07:15 -07:00
Pierre-Loup A. Griffais
44023e25d0 steamcompmgr: (mostly) obey stacking order when out of game 2020-06-01 17:37:59 -07:00
Simon Ser
d41c865661
Fix error handling in drm_can_avoid_composite
-1 is a truthy value.
2020-05-26 17:15:27 +02:00
Simon Ser
cb540e3fc7
Fix error handling in add_connector_property 2020-05-26 17:00:27 +02:00
Simon Ser
af983d2b75
Print DRM logs to stderr instead of stdout
stdout isn't flushed on each newline when redirected to a file. stderr
is always line-buffered. This prevents missing logs and badly
interleaved logs.
2020-05-26 16:58:47 +02:00
Simon Ser
cdef160f14
Simplify fbids_queued handling in page_flip_handler 2020-05-26 16:50:18 +02:00
Simon Ser
9802890c93
Fix spurious assertions in page_flip_handler
This commit fixes two issues.

A first issue is that fbids_in_req was previously populated
drm_can_avoid_composite and read from in page_flip_handler. As a
result, calling drm_can_avoid_composite then page_flip_handler would
prevent drm_atomic_commit from referencing the right FBs
(page_flip_handler runs in a separate thread and clears fbids_in_req).

To fix this, add a new fbids_queued vector filled by drm_atomic_commit.
Make page_flip_handler read from this new vector instead of
fbids_in_req. As a bonus, this fixes a data race since fbids_queued is
now protected by flip_lock.

The second issue is that drm_can_avoid_composite assumes all layers made
it into a hw plane when liftoff_output_apply succeeds. That's not the
case because libliftoff supports mixed hw plane + composition (where
some layers make it into a hw plane and the others get composited).

To fix this, make drm_can_avoid_composite fail if some but not all
layers make it into a hw plane. In the future, we'll want to support the
mixed mode too.

Closes: https://github.com/Plagman/gamescope/issues/65
References: https://github.com/Plagman/gamescope/issues/41
2020-05-26 16:29:50 +02:00
Simon Ser
bcc7cf3b55
Fix memory leak in drm_can_avoid_composite
We were creating a new DRM blob each page-flip and never destroying it.
Instead, create the mode blob once on startup.
2020-05-26 10:57:57 +02:00
Simon Ser
384e777069
Update libliftoff
Upstream has new features, incl. support for the alpha property.
2020-05-26 09:12:59 +02:00
Simon Ser
9353ba11d3
Add error handling when no physical device is found
References: https://github.com/Plagman/gamescope/issues/49
2020-05-22 12:47:57 +02:00
Simon Ser
5ab3129d8e Switch to upstream wlroots 2020-05-19 22:21:45 +02:00
Simon Ser
a69017d08d Use upstream wlr_xwayland_server
Use wlr_xwayland_server, which allows enough customization for us.

References: https://github.com/swaywm/wlroots/pull/2175
Closes: https://github.com/Plagman/gamescope/issues/15
2020-05-19 22:21:45 +02:00
Simon Ser
5bab7f6d85
Update wlroots 2020-05-19 15:03:36 +02:00
Simon Ser
2062141c49
Introduce drm_free_fb
This function takes care of calling drmModeRmFB. In the future it'll
also take care of releasing the client buffer when using direct
scan-out.
2020-05-19 14:25:59 +02:00
Simon Ser
0ee8d451e4
Replace map_fbid_inflightflips pair with a struct
This makes it explicit what "first" and "second" are. This also allows
to add more fields.
2020-05-19 14:05:52 +02:00
Simon Ser
02b233429f
Add error handling to drm_fbid_from_dmabuf 2020-05-19 10:52:51 +02:00
Simon Ser
d70df758a8
Remove dead code in xwayland_surface_role_commit
The FDs are guaranteed to be set if wlr_texture_to_dmabuf doesn't return
an error.
2020-05-15 15:26:48 +02:00
Simon Ser
48b429e7b1
Add n_planes == 1 assert in drm_fbid_from_dmabuf
This code assumes a single planes. Let's add a safe-guard so that we
don't forget this function when adding support for multiple planes.
2020-05-15 15:26:47 +02:00
Simon Ser
b305b7f123
Dup FD in CVulkanTexture::BInit
This saves us the wlr_dmabuf_attributes juggle and makes it easier to
understand the FDs ownership and lifetime.
2020-05-15 15:26:47 +02:00
Simon Ser
db876af1c4
Use wlr_dmabuf_attributes_finish instead of close
This ensures we don't leak any FD.
2020-05-15 14:48:07 +02:00
Simon Ser
8c2b9849ec
Update wlroots fork 2020-05-15 10:33:45 +02:00
Simon Ser
51259bba1c
Silence -Wunused-parameter for C code too 2020-05-15 10:20:59 +02:00
Simon Ser
b84750e775
Enable more warnings
Makes it easier to spot mistakes.
2020-05-15 10:03:55 +02:00
Pierre-Loup A. Griffais
09bc171666 Revert "steamcompmgr: attempt to get rid of damage_sequence"
This reverts commit de16a27674.
2020-05-13 13:52:02 -07:00
Rajdeep Nanua
810972b074 Correct integer scaling example in README 2020-05-13 01:37:31 +02:00
Simon Ser
c0bdf361d5
Don't set WAYLAND_DISPLAY
We don't actually support Wayland clients (yet). Xwayland doesn't use
WAYLAND_DISPLAY, the compositor creates a special Wayland socket instead.
2020-05-12 15:55:01 +02:00
Simon Ser
1e82803574
Improve initOutput error handling
Bail out on DRM error.
2020-05-12 15:07:52 +02:00
Simon Ser
dced8a88da
Switch VT on Ctrl+Alt+F<n>
Only works when switching to fbcon for now. We need to stop
page-flipping when the DRM FD is paused to support switching to another
compositor.

References: https://github.com/Plagman/gamescope/issues/6
2020-05-12 11:19:21 +02:00
Simon Ser
16d74b8e15
Fix segfault when system doesn't support Vulkan 2020-05-12 10:14:57 +02:00
Simon Ser
fc72bda2cf Build libliftoff as a static library 2020-05-08 22:17:07 +02:00
Simon Ser
267036754c Build wlroots as a static subproject 2020-05-08 22:17:07 +02:00