Commit graph

646 commits

Author SHA1 Message Date
Simon Ser
d187c2241e steamcompmgr: improve wait thread robustness 2021-06-09 19:16:22 +02:00
Simon Ser
24b5611478 Terminate wlserver when steamcompmgr stops
Closes: https://github.com/Plagman/gamescope/issues/167
2021-06-09 19:10:32 +02:00
Simon Ser
470756029d Stop using X11 events for vblankmanager
Instead, use a pipe. Check if the pipe is readable in the
steamcompmgr event loop.

This avoids a roundtrip through the X11 server.

Closes: https://github.com/Plagman/gamescope/issues/201
2021-06-09 18:42:38 +02:00
Simon Ser
d8dacddaea steamcompmgr: flush display after sending nudge event 2021-06-09 18:18:56 +02:00
Simon Ser
03d14fd67d Set O_CLOEXEC on stats FD 2021-06-09 17:40:52 +02:00
Simon Ser
7c3dff8d57 Log error on fork/exec failure 2021-06-09 17:39:45 +02:00
Simon Ser
df6b48776e Set O_CLOEXEC on ready FD 2021-06-09 17:38:31 +02:00
Simon Ser
8123bc4f36 steamcompmgr: split child spawning logic into separate function 2021-06-09 17:36:39 +02:00
Simon Ser
bd9590506a Split X11 event dispatching into a function 2021-06-09 17:31:15 +02:00
Simon Ser
f51a05b2dc steamcompmgr: use poll() to wait for X11 events
References: https://github.com/Plagman/gamescope/issues/201
2021-06-09 17:22:53 +02:00
Pierre-Loup A. Griffais
08f41f2046 steamcompmgr: only consider overlays for input focus
Also prctl subreaper tweaks from smcv
2021-06-07 19:10:08 -07:00
Pierre-Loup A. Griffais
e4798e27c9 steamcompmgr: protect against possible out of bounds read
It's possible no layers get drawn due to no contents.
2021-05-28 15:39:42 -07:00
Pierre-Loup A. Griffais
0396468a1d steamcompmgr: scale touch coordinates to the right window
Was erroneously using base layer size even if overlay had touch input focus.
2021-05-28 13:57:11 -07:00
Pierre-Loup A. Griffais
9a20f630ad steamcompmgr: extend input focus concept to allow mouse-only focus 2021-05-26 16:53:11 -07:00
Simon Ser
9d40b61645 wlserver: prevent list corruption on double wlserver_surface_set_wl_id 2021-05-20 17:40:20 +02:00
Simon Ser
cd4c1a4d7d Stop importing DMA-BUFs into EGL
Make renderer_texture_from_dmabuf a no-op, since we handle client
DMA-BUFs with Vulkan. We're using wlr_buffer_get_dmabuf to directly
access the client-submitted FDs.
2021-05-20 17:08:19 +02:00
Pierre-Loup A. Griffais
7adcd2fb20 steamcompmgr: publish focused Window and appID back to control process 2021-05-18 19:34:11 -07:00
Pierre-Loup A. Griffais
6dc6ff83fe steamcompmgr: support a list of GAMESCOPE_FOCUSABLE_APPS 2021-05-18 19:17:06 -07:00
Pierre-Loup A. Griffais
d053a5582e steamcompmgr fix new bug where we'd always run the focus switching code 2021-05-17 20:48:32 -07:00
Pierre-Loup A. Griffais
7e27bacc06 steamcompmgr: fix bug where we wouldn't repaint streaming video
Would just sit there if only the video underlay committed.
2021-05-17 19:42:58 -07:00
Pierre-Loup A. Griffais
d4c93c3b06 steamcompmgr: add external focus control mechanism 2021-05-17 19:42:58 -07:00
Pierre-Loup A. Griffais
f4db52a3fa steamcompmgr: move to stable_sort
It preserves original order like the old logic.
2021-05-17 19:42:58 -07:00
Pierre-Loup A. Griffais
0b92aee977 steamcompmgr: delete STEAM_UNFOCUS and isSteamPopup
now-unused test code
2021-05-17 19:42:58 -07:00
Pierre-Loup A. Griffais
a9216b398b steamcompmgr: fix appID getting stomped if reaper but no prop 2021-05-17 19:42:58 -07:00
Pierre-Loup A. Griffais
5c0e1ff4c7 steamcompmgr: publish focusable appids through root property 2021-05-17 19:42:58 -07:00
Simon Ser
fa433a3ebc Include <wayland-server-core.h> outside of extern "C"
Closes: https://github.com/Plagman/gamescope/issues/190
2021-05-17 19:21:51 +02:00
Pierre-Loup A. Griffais
756b3a6afc steamcompmgr: streaming_client is kind of like an overlay
but not really
2021-05-08 01:47:50 -07:00
Pierre-Loup A. Griffais
fe4501c633 steamcompmgr: more obscure focus fixes 2021-05-08 01:20:18 -07:00
Simon Ser
177205dca4 Block NV12 LINEAR when rotated 2021-05-07 12:21:36 +02:00
Pierre-Loup A. Griffais
9e6a6aa77d steamcompmgr: some focus regression fixes for cornercases
An overlay going away wasn't getting considered. Steam also doesn't
set the 'games running' property if Big Picture isn't running, and
we have more robust appID tracking now, so we can start to phase it out.
2021-05-06 12:57:33 -07:00
Pierre-Loup A. Griffais
7b97f6e4e8 steamcompmgr: add support for streaming_client video underlay
It'll split its YUV and RGB content into two windows. YUV one uses a
content override.
2021-05-05 23:00:40 -07:00
Pierre-Loup A. Griffais
074ee9c719 rendervulkan: remove 'fence' concept
Doesn't make sense now that we poll() the DMA-BUF fd directly. We can
do that directly from steamcompmgr. Vulkan's fence used to be an actual
fence we made up with an empty submission.
2021-05-05 18:46:19 -07:00
Pierre-Loup A. Griffais
e25f871d87 wlserver: avoid accessing mouse_focus_surface after destruction
We should also set the focus to something else that makes sense, which
means there's another bug in a higher-level layer somewhere, but at least
don't crash.
2021-05-05 16:37:51 -07:00
Simon Ser
a4f3a19480 Fix VkDescriptorPoolCreateInfo.poolSizeCount
This caused a read past the array end on anv.
2021-05-04 18:34:11 +02:00
Simon Ser
b6f5471b62 Allow toggling g_bRotated more easily
Allow just changing the default variable value to enable rotation.
2021-05-04 16:40:58 +02:00
Pierre-Loup A. Griffais
902fce73b0 steamcompmgr: flip the meaning of -x
It wasn't actually causing crashes and the memory stomp is fixed.
The option only existed for a very short time and didn't do anything
useful, so should be safe.
2021-05-02 23:51:37 -07:00
Pierre-Loup A. Griffais
580a17d462 steamcompmgr: get the appID from the process tree
In case we can't get it proactively from the app process.
2021-05-02 23:51:37 -07:00
Joshua Ashton
8afb3c3f30 Handle swapchain recreation for out of date and suboptimal 2021-05-01 16:51:00 -07:00
Joshua Ashton
e818aec744 Move to combined samplers and rewrite composite shader in GLSL
Cleans up the composite shader significantly as well as it uses
arrays of descriptors/samplers now.

This all gets unrolled as the loop is spec-constant sized.
2021-05-01 16:50:51 -07:00
Joshua Ashton
f537a40483 Use SOA instead of AOS for layers
Produces better code as the shader compiler can load
multiple layers with a single buffer_load at a time
due to the positioning and alignment.
2021-05-01 16:50:51 -07:00
Pierre-Loup A. Griffais
496b5f58d2 wlserver: downgrade wlserver_surface_set_wl_id assert to spew 2021-04-30 18:45:00 -07:00
Simon Ser
6f54b51a6c Fix cursor not using linear layout 2021-04-30 16:28:07 +02:00
Simon Ser
bf5123e19b Log errors in CVulkanTexture::BInit 2021-04-30 16:25:14 +02:00
Simon Ser
d1ff01c134 Make args const in drm_prepare 2021-04-30 16:18:29 +02:00
Pierre-Loup A. Griffais
2bb4907993 Also spew wayland display name through session pipe. 2021-04-27 21:17:36 -07:00
Simon Ser
a85c8d761c Fix planes offset/stride for multi-planar buffers
References: https://github.com/Plagman/gamescope/issues/49
2021-04-23 10:51:22 +02:00
Simon Ser
3a6895a4b8 Add more error messages 2021-04-23 10:45:17 +02:00
Simon Ser
c9b5000812 Don't query COLOR subresource layout with modifiers
According to the spec, this is invalid:

> If the tiling of the image is VK_IMAGE_TILING_DRM_FORMAT_MODIFIER_EXT, then
> the aspectMask member of pSubresource must be
> VK_IMAGE_ASPECT_MEMORY_PLANE_i_BIT_EXT

This triggers an assertion in anv.

References: https://github.com/Plagman/gamescope/issues/49
2021-04-23 10:45:17 +02:00
Simon Ser
cb0eace6d1 Use libliftoff by default
Remove the -l option. Introduce a -L option to disable libliftoff.
Don't use the same option to avoid muscle memory issues.
2021-04-22 21:55:22 +02:00
Simon Ser
a99c5f7a1c Don't set R600_DEBUG=nodcc if Vulkan supports modifiers
This can cause issues with Xwayland. Setting R600_DEBUG=nodcc
prevents Xwayland from being able to import DCC buffers coming
from Vulkan clients.

Closes: https://github.com/Plagman/gamescope/issues/185
2021-04-22 19:36:37 +02:00
Simon Ser
3b9f845dad Unify getopt string
De-duplicate its definition, so that we don't forget to update a
string when we update the other.
2021-04-21 14:38:54 +02:00
Simon Ser
910fba1008 rendervulkan: add NV12 support
This doesn't yet display correct colors, and tiling artifacts are
visible.
2021-04-20 09:13:10 +02:00
Simon Ser
5f36d1060c rendervulkan: log supported DRM formats 2021-04-20 09:13:10 +02:00
Simon Ser
b3f3f6c92d rendervulkan: log whether DRM modifiers are supported 2021-04-20 09:13:10 +02:00
Simon Ser
0aa74266c4 Relax Vulkan import plane check
Try to import multi-planar textures even if we don't have a
modifier. This is the case for e.g. DMA-BUFs coming from VA-API.
2021-04-20 09:13:10 +02:00
Simon Ser
be735e9360 Set GAMESCOPE_WAYLAND_DISPLAY
This allows gamescope-specific Wayland clients to connect to the
Wayland server, while preventing regular Wayland clients from doing
so.
2021-04-20 09:13:10 +02:00
Simon Ser
a05e5b0a39 Implement gamescope-xwayland protocol 2021-04-20 09:13:10 +02:00
Simon Ser
10816e6ed8 wlserver: adjust assertion in wlserver_surface_set_wlr
Make sure we don't overwrite an existing surf->wlr. We don't really
care about the Wayland surface ID here.
2021-04-20 09:13:10 +02:00
Simon Ser
ce0a3f7259 Rename wlserver_surface_set_id to wlserver_surface_set_wl_id
Make it clear the ID refers to a Wayland object.
2021-04-20 09:13:10 +02:00
Sefa Eyeoglu
ed44909813 Update wlroots to 0.13.0
Update usage of wlr_headless_backend_create,
wlr_renderer_get_shm_texture_formats,
wlr_texture_from_pixels and add missing include for render/egl.h.
2021-04-08 09:15:05 +02:00
Simon Ser
c834999a5f Introduce wlserver_surface 2021-04-02 08:37:53 +02:00
Simon Ser
4f24653d77 Add support for multi-planar DMA-BUF Vulkan export 2021-04-01 19:06:08 +02:00
Simon Ser
a900bef8b8 Query plane 0 layout with VK_IMAGE_ASPECT_MEMORY_PLANE_0_BIT_EXT 2021-04-01 18:17:04 +02:00
Simon Ser
ff33a3738e Query image modifier on Vulkan DMA-BUF export 2021-04-01 18:03:18 +02:00
Simon Ser
b8ab5a74ee rendervulkan: add support for legacy wl_drm buffers
There are still clients (e.g. steam) not supporting modifiers at
all.
2021-04-01 17:41:06 +02:00
Simon Ser
df18c40815 Only advertise scanout capable modifiers 2021-04-01 17:41:06 +02:00
Simon Ser
26a25b1d29 Pass list of modifiers when allocating with Vulkan
This allows us to remove the wsi_image_create_info hack when
modifiers are supported.

References: https://github.com/Plagman/gamescope/issues/51
2021-04-01 13:13:38 +02:00
Sefa Eyeoglu
774002483b fix: update liftoff log initialisation
Also: Update liftoff dependency to b08bbaa5e6331ed2
("Split liftoff_log_init into set_handler and set_priority")

The callback parameter was moved into a different method, though it is
not needed in this case as we didn't give it one before.
2021-03-31 14:25:39 +02:00
Pierre-Loup A. Griffais
7dfb55c8a8 steamcompmgr: disable XRes1.2 support by default.
Can re-enable it once an XRes release with this fix has been tagged for a bit:

https://gitlab.freedesktop.org/xorg/lib/libxres/-/merge_requests/1?commit_id=3e6bdd90c604e061c71715865eb403ffdd0dd7f0

Or users can use -x for now.
2021-03-30 18:11:27 -07:00
Pierre-Loup A. Griffais
5936baa865 steamcompmgr: make cursor hide time configurable, -C in ms 2021-03-24 20:35:33 -07:00
Simon Ser
8f9a284d32 Print error if poll fails in imageWaitThreadMain 2021-03-12 19:19:25 +01:00
Simon Ser
29d00dbc68 tracing: use {begin,end}_ctx helpers, remove unnecessary newlines 2021-03-11 11:25:34 +01:00
Simon Ser
36c8b983ee drm: fix missing flag in drmModeAddFB2WithModifiers call
That's a nice footgun right here.
2021-03-05 16:04:45 +01:00
Simon Ser
7633401874 drm: check DRM format/modifier prior to addfb2 2021-03-05 14:47:59 +01:00
Simon Ser
f89f585cdd drm: build set of scanout capable formats 2021-03-05 14:26:30 +01:00
Simon Ser
706bdf849e drm: store KMS props in a map 2021-03-05 14:18:09 +01:00
Simon Ser
47fed361cd drm: remove obscure macros 2021-03-05 11:46:59 +01:00
Simon Ser
9f07d66143 drm: whitespace fixes 2021-03-05 11:32:22 +01:00
Simon Ser
1dc98da7d1 Log when tracing is enabled 2021-03-03 16:51:58 +01:00
Simon Ser
ad06b347ee Always print error on missing DRM_CAP_ADDFB2_MODIFIERS 2021-03-03 16:07:35 +01:00
Simon Ser
0f96db3dc2 Fix is_focus_priority_greater function 2021-03-02 19:16:56 +01:00
Simon Ser
2d992653a0 drm: remove workaround for small buffers
Even if we get EINVAL, we'll just return false later on.
2021-02-25 17:21:27 +01:00
Simon Ser
c0fba1fe9f drm: remove duplicate assert 2021-02-25 17:14:18 +01:00
Simon Ser
29a23e90e1 drm: simplify rotation in drm_prepare_basic 2021-02-25 17:11:36 +01:00
Simon Ser
141f2cf374 Revert "Remove bogus ARGB8888 entry from Vulkan format list"
This reverts commit 202915271e.

We actually need this format for the cursor plane.
2021-02-25 17:11:36 +01:00
Simon Ser
79acc095b2 rendervulkan: assert DRM format is valid when exporting DMA-BUF 2021-02-24 15:07:23 +01:00
Simon Ser
49e0cc046e Move Vulkan init into main
Some Wayland server setup will need Vulkan initialized.
2021-02-22 12:37:56 +01:00
Simon Ser
202915271e Remove bogus ARGB8888 entry from Vulkan format list 2021-02-22 12:37:52 +01:00
Simon Ser
b37880c62f Add TODO about multi-planar DMA-BUFs and vkBindImageMemory 2021-02-22 12:37:46 +01:00
Simon Ser
9b63bf755e drm: initialize handles before drmModeAddFB2WithModifiers
This fixes a drmModeAddFB2WithModifiers EINVAL.
2021-02-19 17:41:33 +01:00
Simon Ser
7eb7e8ec63 Don't scale games by default
Right now scale games by default to 720p even if the screen is 1080p.
This happens when -w/-h is *not* specified.

Instead, don't scale the game by default. This means using a 720p
window when nested (shouldn't change anything), and using the screen's
resolution when embedded.
2021-02-12 22:16:34 +01:00
Simon Ser
70af2c38f0 Query window PID via XRes
References: https://github.com/Plagman/gamescope/issues/17
2021-02-12 22:16:04 +01:00
Simon Ser
0beb34b9d5 steamcompmgr: prefer to focus windows without SKIP_{TASKBAR,PAGER}
Closes: https://github.com/Plagman/gamescope/issues/87
2021-02-12 22:15:45 +01:00
Simon Ser
0275e7839d steamcompmgr: simplify focus logic
Use std::sort instead of a complicated loop.
2021-02-12 22:15:45 +01:00
Simon Ser
c26d86a794 steamcompmgr: store SKIP_TASKBAR and SKIP_PAGER hints 2021-02-12 22:15:45 +01:00
Simon Ser
bce006fd70 Fix typo in drm.cpp 2021-02-09 14:55:01 +01:00
Bas Nieuwenhuizen
d537d6ac98 Cherck all imported DMABUFS are equal.
Otherwise we need Vulkan support for the disjoint bit.
2021-02-02 23:56:32 +01:00
Bas Nieuwenhuizen
722201c5c2 Support Vulkan modifier-based imports using VK_EXT_image_drm_format_modifier
Tested with radv + radeonsi + glxgears on navi21 to work with DCC (assuming
the nodcc bit is disabled).

This is conservative and will fall back to the legacy path if the modifier
isn't supported. At the same time it also avoids the wird mesa WSI struct
if the modifier is supported.
2021-02-02 23:56:32 +01:00
Simon Ser
bb205a41b0 Add support for modifiers in drm_fbid_from_dmabuf 2021-02-01 15:59:12 +01:00
Simon Ser
c7c917e39a Read DRM_CAP_ADDFB2_MODIFIERS 2021-02-01 15:52:48 +01:00
Simon Ser
4e6204e079 Zero-initialize DRM globals
Let's make sure we don't run into uninitialized values.
2021-02-01 15:52:11 +01:00
Simon Ser
32ebfeb498 Add support for multi-planar buffers in drm_fbid_from_dmabuf 2021-02-01 15:45:30 +01:00
Simon Ser
17c74e3e6b Don't crash when KMS rejects client FB
If the client provides a DMA-BUF that cannot be scanned out, don't
crash. We should just fallback to composition instead.
2021-02-01 15:41:00 +01:00
Simon Ser
1b38faf9fd Fix double-unlock on wl_event_loop_dispatch error 2021-02-01 15:27:21 +01:00
Simon Ser
b841139327 Collect plane modifiers
This will be useful once we implement support for modifiers.
2021-02-01 15:08:01 +01:00
Simon Ser
1c80548dfc Use CLOEXEC when opening primary DRM node
Avoids leaking the FD to our clients.
2021-02-01 14:37:22 +01:00
Simon Ser
7b51575399 Check plane supports {X,A}RGB8888
Fail if it doesn't instead of leaving g_nDRMFormat uninitialized.
2021-02-01 14:29:53 +01:00
Simon Ser
598228589d Only pick primary planes in get_plane_id
If we pick another plane, g_nDRMFormat isn't populated. This isn't
a case worth supporting anyways, all drivers expose primary planes.
2021-02-01 14:27:34 +01:00
Simon Ser
9b2da80c23 Convert found_primary to bool in get_plane_id 2021-02-01 14:24:33 +01:00
Simon Ser
b8ecceb48b Fix return value of get_plane_id
The caller checks for 0, not negative values.
2021-02-01 14:22:53 +01:00
Simon Ser
0c99a3c09d Require planes to have a type property
This is guaranteed by DRM core.
2021-02-01 14:22:03 +01:00
Simon Ser
91e7ca45fc Introduce a helper to get a property value
This will be useful for other properties, like IN_FORMATS.
2021-02-01 14:18:26 +01:00
Simon Ser
7f65dedbab Fix indentation in get_plane_id 2021-02-01 12:26:50 +01:00
Simon Ser
9b780b48db Use no-op backend for output
This avoids needlessly creating buffers for an headless output we won't
use, and will allow us to more easily replace the headless backend with
a custom renderer in the future.
2021-02-01 10:24:39 +01:00
Simon Ser
c9acfb5a68 Allow SDL to run in pure Wayland mode 2021-01-29 18:33:18 +01:00
Simon Ser
078f7823ba Bail out if drmSetClientCap(ATOMIC) fails
And remove extra UNIVERSAL_PLANES cap: this is implicitly enabled
by ATOMIC.
2021-01-29 18:20:21 +01:00
Simon Ser
cf8cf60a37 Remove ALLOW_MODESET workaround
This is no longer needed as of Linux 5.10.

Closes: https://github.com/Plagman/gamescope/issues/67
2021-01-05 15:17:16 +01:00
Simon Ser
072599c037
Stop blocking SIGUSR1
wlroots doesn't use SIGUSR1 for Xwayland startup anymore, so we can
remove the per-thread signal handlers.
2020-12-16 11:52:28 +01:00
Simon Ser
fbc6bd0c08
Update wlroots and libliftoff 2020-12-16 11:52:28 +01:00
Simon Ser
131514ecb8 steamcompmgr: allocate cursor buffer on heap
This fixes a Clang failure, and ensures we don't blow up the stack on
big cursor sizes.

Closes: https://github.com/Plagman/gamescope/issues/140
2020-12-16 11:43:04 +01:00
Simon Ser
83900acb11 Create a linear buffer for cursor
The cursor plane needs to be linear on amdgpu.
2020-12-11 12:39:00 +01:00
Roman Gilg
ceeef3567d Use DRM_CAP_CURSOR_{WIDTH,HEIGTH} for cursor buffer
Hardware often has cursor plane limitations for the buffer size.

Co-authored-by: Simon Ser <contact@emersion.fr>
2020-12-11 12:39:00 +01:00
Simon Ser
85ba5c6fe9
Revert "sdlwindow: grab mouse when gaining focus"
This reverts commit 2922d96308.

Testing this again, it doesn't seem like this helps.
2020-11-20 15:55:48 +01:00
Pierre-Loup A. Griffais
c9d0b5db4c rendervulkan: fix nLayercount == k_nMaxLayers crash regression.
From spec constant work.

https://github.com/Plagman/gamescope/issues/128
2020-11-12 22:14:34 -08:00
Pierre-Loup A. Griffais
5fbd02b99c steamcompmgr: separate input focus from display focus (main layer)
Also add STEAM_INPUT_FOCUS prop interface to hijack focus for overlay layers
without having to resort to hooking games for input.
2020-11-12 21:48:08 -08:00
Simon Ser
9f64986fe3 drm: pass commit flags to libliftoff
We need to pass ALLOW_MODESET when we mean to set a mode, otherwise
libliftoff will always fail its test-only commits.
2020-11-12 20:48:15 -08:00
Simon Ser
d836e4d3ee drm: don't reset bFirstSwap on error 2020-11-12 20:48:15 -08:00
Simon Ser
89af709906 Split drm_prepare into basic/liftoff sub-functions
Instead of handling both cases in a single function, split the work of
populating the atomic request in two new functions, and keep the common
bits in drm_prepare.

Shouldn't have any functional change.
2020-11-12 20:48:15 -08:00
Simon Ser
a62740e393 Rename drm_can_avoid_composite to drm_prepare
drm_can_avoid_composite doesn't merely checks whether we can avoid
composition: it also prepares a pending atomic request. It's always
necessary to call this function before drm_atomic_commit.

Rename the function to make this clearer.
2020-11-12 20:48:15 -08:00
Simon Ser
a2e071c557
steamcompmgr: read initial NET_WM_STATE value
Before the window is mapped, the client can set the initial NET_WM_STATE
directly in the window property. After the window is mapped, the client
must use a client message and shouldn't touch the property anymore.
2020-11-10 10:13:51 +01:00
Simon Ser
ea1b5368cb
steamcompmgr: handle both props in NET_WM_STATE message 2020-11-10 10:13:51 +01:00
Simon Ser
cce9981b57
steamcompmgr: handle NET_WM_STATE_TOGGLE 2020-11-10 10:13:51 +01:00
Simon Ser
2922d96308
sdlwindow: grab mouse when gaining focus
Sometimes we hide our window and show it again after some time.
SDL_SetRelativeMouseMode doesn't seem to properly cope with this, at
least on my setup.
2020-11-09 17:54:34 +01:00
Simon Ser
cd31090733
rendervulkan: sanity check queue with vkGetPhysicalDeviceSurfaceSupportKHR
VUID-VkSwapchainCreateInfoKHR-surface-01270(ERROR / SPEC): msgNum: -1585220531 - Validation Error: [ VUID-VkSwapchainCreateInfoKHR-surface-01270 ] Object 0: handle = 0x628000040100, type = VK_OBJECT_TYPE_DEVICE; | MessageID = 0xa183744d | vkCreateSwapchainKHR(): pCreateInfo->surface is not known at this time to be supported for presentation by this device. The vkGetPhysicalDeviceSurfaceSupportKHR() must be called beforehand, and it must return VK_TRUE support with this surface for at least one queue family of this device. The Vulkan spec states: surface must be a surface that is supported by the device as determined using vkGetPhysicalDeviceSurfaceSupportKHR (https://www.khronos.org/registry/vulkan/specs/1.2-extensions/html/vkspec.html#VUID-VkSwapchainCreateInfoKHR-surface-01270)
2020-10-23 17:37:58 +02:00
Simon Ser
e1879015bd
rendervulkan: log when SDL_Vulkan_CreateSurface fails 2020-10-23 17:32:28 +02:00
Simon Ser
f6fb47ad12
Explicitly enable VK_KHR_get_physical_device_properties2
VUID-vkCreateInstance-ppEnabledExtensionNames-01388(ERROR / SPEC): msgNum: -437968512 - Validation Error: [ VUID-vkCreateInstance-ppEnabledExtensionNames-01388 ] Object 0: VK_NULL_HANDLE, type = VK_OBJECT_TYPE_INSTANCE; | MessageID = 0xe5e52180 | Missing extension required by the instance extension VK_KHR_external_memory_capabilities: VK_KHR_get_physical_device_properties2. The Vulkan spec states: All required extensions for each extension in the VkInstanceCreateInfo::ppEnabledExtensionNames list must also be present in that list (https://www.khronos.org/registry/vulkan/specs/1.2-extensions/html/vkspec.html#VUID-vkCreateInstance-ppEnabledExtensionNames-01388)
2020-10-23 17:24:53 +02:00
Simon Ser
fdc8527d01
sdlwindow: improve SDL error handling 2020-10-23 15:54:39 +02:00
Jan Beich
e8c9098187 steamcompmgr: drop unused private field after f7d815a203
In file included from ../src/steamcompmgr.cpp:74:
src/steamcompmgr.hpp:75:7: warning: private field 'm_hasPlane' is not used [-Wunused-private-field]
        bool m_hasPlane;
             ^
2020-10-22 10:23:40 +02:00
Jan Beich
0416b5fe08 steamcompmgr: add missing header
src/steamcompmgr.cpp: In function 'void statsThreadMain()':
src/steamcompmgr.cpp:357:62: error: 'O_WRONLY' was not declared in this scope
  357 |                 statsPipeFD = open( statsThreadPath.c_str(), O_WRONLY );
      |                                                              ^~~~~~~~
src/steamcompmgr.cpp:357:31: error: 'open' was not declared in this scope; did you mean 'popen'?
  357 |                 statsPipeFD = open( statsThreadPath.c_str(), O_WRONLY );
      |                               ^~~~
      |                               popen
src/steamcompmgr.cpp: In function 'void steamcompmgr_main(int, char**)':
src/steamcompmgr.cpp:2559:61: error: 'O_WRONLY' was not declared in this scope
 2559 |                                 readyPipeFD = open( optarg, O_WRONLY );
      |                                                             ^~~~~~~~
src/steamcompmgr.cpp:2559:47: error: 'open' was not declared in this scope; did you mean 'popen'?
 2559 |                                 readyPipeFD = open( optarg, O_WRONLY );
      |                                               ^~~~
      |                                               popen
2020-10-20 23:53:54 +02:00
Pierre-Loup A. Griffais
667d8afc54 wlserver: was wrong clickmode, we want 4, also fix some logic issues 2020-09-23 15:22:42 -07:00
Pierre-Loup A. Griffais
4f70525fc6 wlserver: add touch passthrough support, if clickmode == 0 2020-09-18 14:59:26 -07:00
Pierre-Loup A. Griffais
405f18b08d sdlwindow: add alternate refresh rate option when out-of-focus. 2020-09-15 14:57:11 -07:00
Pierre-Loup A. Griffais
fd7a81547a vblankmanager: obey nested refresh rate if set 2020-09-15 14:46:12 -07:00
Pierre-Loup A. Griffais
afccf2a4d1 steamcompmgr: still affect LD_PRELOAD if we strip everything from it
In cases where LD_PRELOAD only contained things we wanted to strip, we
weren't actually setting the result and stripping nothing.
2020-09-14 23:57:56 -07:00
Pierre-Loup A. Griffais
cdfe50d53b steamcompmgr: unset ENABLE_VKBASALT for subcommands
We only want gamescope's outermost swapchain to get hooked, similar as the
Steam overlay.
2020-09-14 13:13:30 -07:00
Pierre-Loup A. Griffais
0619998a49 rendervulkan: fall back to compute+graphics if compute-only can't be found
Should let people run against Intel and other non-AMD Mesa GPUs.

Also force compute+graphics if vkBasalt is enabled, as it won't support
compute-only rings. Also always composite if vkBasalt is enabled, so it
applies always in embedded.
2020-09-13 15:10:23 -07:00
Pierre-Loup A. Griffais
ebdd156df6 steamcompmgr: gracefully exit stats thread if exists. 2020-09-13 00:34:36 -07:00
Pierre-Loup A. Griffais
bff790eccb steamcompmgr: gracefully exit imageWaitThread and steamcompmgr loop. 2020-09-13 00:31:52 -07:00
Pierre-Loup A. Griffais
d7a85b00d9 sdlwindow: mimic window shown. 2020-09-13 00:19:02 -07:00
Simon Ser
0a5ecb45a9 Remove hack checking the window size
We now properly detect system tray icons, no need for this hack anymore.
2020-09-12 22:26:48 -07:00
Simon Ser
08e8b048e9 Add support for the system tray protocol
Blacklist system tray icons when deciding which window should have
focus.

Closes: https://github.com/Plagman/gamescope/issues/80
2020-09-12 22:26:48 -07:00
Joshua Ashton
9af5c3f254 Cleanup vblankmanager
Keep everything on the same timescale.
Avoid using floats here when we can just use integer maths.
Add demarcations.
Misc. cleanup.
2020-09-12 22:26:31 -07:00
Joshua Ashton
bb9d0cdf8f Use nanoseconds for vblank timing
Avoids locking on-vblank
STL's clock's accuracy can be funky also.
2020-09-12 22:26:31 -07:00
Joshua Ashton
325445a061 Add nano sleep helper functions 2020-09-12 22:26:31 -07:00
Joshua Ashton
50a508ae74 Encode vblank time in client message
Eliminates the atomic hack here
2020-09-12 22:26:31 -07:00
Joshua Ashton
d49c95569b Add get_time_in_nanos to header 2020-09-12 22:26:31 -07:00
Joshua Ashton
56442322cf Move nLayerCount and bSwapLayers to spec constants
Eliminates these comparisons being done from the constant buffer.
2020-09-02 20:43:40 -07:00
Joshua Ashton
b247f9f164 Move layer info to CompositeData_t struct
Have a nice struct for us to copy into the constant buffer
once we eliminate nLayerCount and nSwapChannels.
2020-09-02 20:43:40 -07:00
Joshua Ashton
d9920c9087 Add to-do note for frame submission time 2020-09-02 20:41:38 -07:00
Joshua Ashton
62b0a46cf3 Add demarcations to large time values
Increases readability
2020-09-02 20:41:38 -07:00
Joshua Ashton
1b8ff8a512 Base get_time_in_milliseconds off get_time_in_nanos
Avoids NTP drift and ensures time is uniformly monotonic.

No need to implement differently, this will overflow every 500-ish years.
2020-09-02 20:41:38 -07:00
Joshua Ashton
c57eb1bf28 Use MONOTONIC_RAW clock for vblank timing
``gettimeofday`` is expensive and suffers from NTP drift which means
we could miss vblank on time updates.
2020-09-02 20:41:38 -07:00
Oschowa
5954361cc3 Add an option to start in fullscreen if nested 2020-09-02 23:59:52 +02:00
Simon Ser
f268c17fb1 Setup an X IO error handler
The default erro handler calls exit(), which doesn't work well when
multiple threads are involved.

Closes: https://github.com/Plagman/gamescope/issues/46
2020-09-02 12:44:57 -07:00
Oschowa
9d6b37ee22 steamcompmgr: don't use 'd' suffix on float constant.
Fixes clang build error.
2020-09-02 11:15:02 -07:00
Oschowa
1ecb8d3b46 rendervulkan: don't mix designated and non-designated initializers 2020-09-02 11:15:02 -07:00
Pierre-Loup A. Griffais
e1d4937310 Different method of bumping priority.
Calling nice() in the very beginning ensures that Mesa worker threads in
gamescope and Xwayland can properly reduce their priority without us stomping
it later.

Move away from posix_spawn, since there's no easy way (that seems to work)
to keep priority normal for the spawned process and get the right behaviour
for gamescope and Xwayland.

The intermediate fork() lets us simplify the logic for LD_PRELOAD rewriting.
2020-09-02 11:06:30 -07:00
Simon Ser
f70308a36f
Exit with status 1 on error 2020-09-02 11:45:29 +02:00
Pierre-Loup A. Griffais
60ecb0f1f8 steamcompmgr: also set thread priorities for ourselves and Xwayland.
Avoid setting it for our children processes, by spawning them in a new
thread group and setting group-wide priority, which also conveniently
gets Xwayland.
2020-09-02 00:27:18 -07:00
Pierre-Loup A. Griffais
79d85ed532 steamcompmgr: better error handling for Vulkan device create failure.
alarm!!!
2020-09-01 23:29:49 -07:00
Pierre-Loup A. Griffais
22f20882b9 rendervulkan: use realtime priority async compute if CAP_SYS_NICE is set.
Fixes: https://github.com/Plagman/gamescope/issues/20.
2020-09-01 23:25:53 -07:00
Pierre-Loup A. Griffais
79cb130dcc sdlwindow: put all the SDL I/O code in the same spot. 2020-09-01 23:00:06 -07:00
Pierre-Loup A. Griffais
81b8e8c33c steamcompmgr: ignore vblank messages if we get them too late. 2020-09-01 22:59:44 -07:00
Pierre-Loup A. Griffais
b196cd063b steamcompmgr: show which window we're pushing commit waits for. 2020-09-01 18:03:09 -07:00
Pierre-Loup A. Griffais
8854cd8bd6 steamcompmgr: add 100ms timeout for commit wait thread.
poll() inexplicably blocks forever for some commits right now, this helps
a bit while we understand why.
2020-09-01 17:51:11 -07:00
Pierre-Loup A. Griffais
9f183ae76c drm: add gpuvis error spew when failing a legacy flip. 2020-09-01 16:16:45 -07:00
Pierre-Loup A. Griffais
11dd8014ad main: set R600_DEBUG=nodcc ourselves if we have a sub-command.
We know it's strictly better than not having it in the current state,
so might as well, if we know it'll apply to clients as well.
2020-09-01 16:01:20 -07:00
Simon Ser
aac57e7c75 Hold client buffers till KMS stops using them 2020-09-01 12:36:35 -07:00
Simon Ser
31a0713455 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-09-01 12:36:35 -07:00
Simon Ser
d88cfec0c2 Add wlr_buffer to commit queue
This lets us keep the buffers for pending commits locked.
2020-09-01 12:36:35 -07:00
Simon Ser
c2d9b23d08 Hold buffers till steamcompmgr processes them 2020-09-01 12:36:35 -07:00
Pierre-Loup A. Griffais
2a98d2b85a wlserver: use gamescope-N wayland display name.
Letting wayland use the default makes random things connect to us, which we
don't want.

Fixes https://github.com/Plagman/gamescope/issues/96.

Related to the va-api problem, but most likely not the only fix:

https://github.com/Plagman/gamescope/issues/23
2020-09-01 11:52:55 -07:00
Simon Ser
d36a11d39f
Remove whitespace at the end of rendervulkan.cpp 2020-08-31 19:23:45 +02:00
Simon Ser
9a78452a41
Read window title
Prefer _NET_WM_NAME since it's UTF-8. Fallback to WM_NAME if the client
doesn't support it.

Closes: https://github.com/Plagman/gamescope/issues/89
2020-08-31 14:59:51 +02:00
Simon Ser
5076ec1586
Fix buffer overflow when reading WM_NAME
XTextProperty doesn't guarantee the string will be null-terminated.
2020-08-31 14:33:25 +02:00
Simon Ser
6eb108d3bc
Extract client message event handling in function
No logic changes, just shuffling code around.
2020-08-31 13:53:41 +02:00
Simon Ser
0a1bf2e81f
Extract PropertyNotify event handling in function
No logic changes, just shuffling code around for better readability.
2020-08-31 13:48:21 +02:00
Simon Ser
3096c1e9cf
Fix alloc-dealloc-mismatch in vecNewEnviron
==2654441==ERROR: AddressSanitizer: alloc-dealloc-mismatch (operator new [] vs operator delete) on 0x6020000c0330
        #0 0x7f264e95e009 in operator delete(void*, unsigned long) /build/gcc/src/gcc/libsanitizer/asan/asan_new_delete.cpp:172
        #1 0x5645ddfcef1e in steamcompmgr_main(int, char**) ../src/steamcompmgr.cpp:2602
    Running Steam on arch rolling 64-bit
        #2 0x5645de0020e6 in steamCompMgrThreadRun() ../src/main.cpp:126
        #3 0x5645de001a2f in void std::__invoke_impl<void, void (*)()>(std::__invoke_other, void (*&&)()) /usr/include/c++/10.2.0/bits/invoke.h:60
        #4 0x5645de001899 in std::__invoke_result<void (*)()>::type std::__invoke<void (*)()>(void (*&&)()) /usr/include/c++/10.2.0/bits/invoke.h:95
        #5 0x5645de001757 in void std:🧵:_Invoker<std::tuple<void (*)()> >::_M_invoke<0ul>(std::_Index_tuple<0ul>) /usr/include/c++/10.2.0/thread:264
        #6 0x5645de00161a in std:🧵:_Invoker<std::tuple<void (*)()> >::operator()() /usr/include/c++/10.2.0/thread:271
        #7 0x5645de000d98 in std:🧵:_State_impl<std:🧵:_Invoker<std::tuple<void (*)()> > >::_M_run() /usr/include/c++/10.2.0/thread:215
    STEAM_RUNTIME is enabled automatically
        #8 0x7f264e143c23 in execute_native_thread_routine /build/gcc/src/gcc/libstdc++-v3/src/c++11/thread.cc:80
        #9 0x7f264d58b3e8 in start_thread (/usr/lib/libpthread.so.0+0x93e8)
        #10 0x7f264d4b9292 in __GI___clone (/usr/lib/libc.so.6+0x100292)

Fixes: 4a5cd5d2bd ("steamcompmgr: disable Steam overlay for sub-command")
2020-08-31 12:18:47 +02:00
Pierre-Loup A. Griffais
6dd7f60540 Switch commit waiting over to polling the DMA-BUF fd.
Remove the implicit sync Vulkan fence hack, it took us 0.2ms of GPU time
to prepare the 1x1 copy to wait on.
2020-08-30 13:26:46 -07:00
Pierre-Loup A. Griffais
165946fad9 rendervulkan: fix typo and some easy validation errors.
Needs more correctness around layout transitions still.
2020-08-29 21:44:47 -07:00
Pierre-Loup A. Griffais
df38bea747 Implement screenshot support.
Mostly in rendervulkan. Super+S or SIGUSR2.
2020-08-29 21:33:14 -07:00
Pierre-Loup A. Griffais
4a5cd5d2bd steamcompmgr: disable Steam overlay for sub-command
If running through Steam, we want the overlay hooked into gamescope and
not the underlying game, or we'll get double overlay, and one with wrong
scaling.

This strips any token containing gameoverlayrenderer.so from LD_PRELOAD.
2020-08-28 18:16:13 -07:00
Pierre-Loup A. Griffais
669183c1e2 wlserver: fix use-after-free in surface destroy path.
The new-ish code to listen for destroy on surfaces on the wlserver side
installs a dynamic listener. We need to remove it from the list before
freeing it, or wayland will try to do it when the signal gets destroyed,
which involves updating the link member in the freed memory.

Some xcb protocol allocations would often get allocated there in that
short time window and get scribbled on.

https://github.com/Plagman/gamescope/issues/7

Ironic. 064d132c could save others from use-after-free, but not itself.
2020-08-28 00:49:04 -07:00
Pierre-Loup A. Griffais
74f831f290 steamcompmgr: fix valgrind warning in size hints code. 2020-08-28 00:40:05 -07:00
Pierre-Loup A. Griffais
7fedd8251b steamcompmgr: zero-initialize some cursor stuff that used to be global. 2020-08-28 00:39:54 -07:00
Simon Ser
d3f3acde74 steamcompmgr: check message_type in NET_WM_STATE handler 2020-08-26 11:50:26 +02:00
Simon Ser
c6d7ef0be2 steamcompmgr: set WM_STATE
Closes: https://github.com/Plagman/gamescope/issues/79
Closes: https://github.com/Plagman/gamescope/issues/42
2020-08-26 11:50:26 +02:00
Simon Ser
535fa8c7e5 steamcompmgr: add _NET_WM_STATE to supported atoms 2020-08-26 11:50:26 +02:00
Simon Ser
9889d4f521 steamcompmgr: set _NET_WM_STATE_FOCUSED 2020-08-26 11:50:26 +02:00
Simon Ser
3b9f8a6d85
Rename NET_WM_STATE_* Atom globals
Give them a less misleading name, because WM_STATE is a separate thing.
2020-08-12 12:04:45 +02:00
Simon Ser
aa853dbb76
steamcompmgr: use initializer for supported atoms
Makes it less error-prone to add atoms to the list.
2020-08-12 11:41:07 +02:00
Pierre-Loup A. Griffais
695fc4eb17 steamcompmgr: flip opacity default and ignore transparent windows for focus
Origin has a bunch of sub-windows that are fully translucent until remapped.
2020-08-04 18:25:39 -07:00
Pierre-Loup A. Griffais
272699656f steamcompmgr: also allow override redirect windows out-of-game
Only if there's no alternative. Useful for Steam updater screen.
2020-08-04 18:25:39 -07:00
Pierre-Loup A. Griffais
a24b3ba008 steamcompmgr: add focus debug optional spew 2020-08-04 18:25:39 -07:00
Simon Ser
d7132a2397
Remove unused CVulkanTexture::m_DMA 2020-07-30 13:38:05 +02:00
Simon Ser
dd4d035808
Fix DMA-BUF leak in CVulkanTexture with bFlippable
We were storing the DMA-BUF in a CVulkanTexture field, without using it
after BInit, and without cleaning it up on destroy.
2020-07-30 13:34:59 +02:00
Pierre-Loup A. Griffais
69bcb1b339 Revert "Hold buffers till steamcompmgr processes them"
This reverts commit 98e263c37d.
2020-07-24 15:01:33 -07:00
Pierre-Loup A. Griffais
da81b37d07 Revert "Add wlr_buffer to commit queue"
This reverts commit 789f009a53.
2020-07-24 15:01:32 -07:00
Pierre-Loup A. Griffais
0757f2676b Revert "Copy commit queue in check_new_wayland_res"
This reverts commit 9c9a8093ee.
2020-07-24 15:01:31 -07:00
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
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
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
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
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
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
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
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
c147de2134 Fix alloc-dealloc-mismatch for win objects
win objects are allocated with `new`, so they need to be de-allocated
with `delete` instead of `free`.

    ==589398==ERROR: AddressSanitizer: alloc-dealloc-mismatch (operator new vs free) on 0x61200017f140
    (EE) failed to read Wayland events: Broken pipe
    X connection to :1 broken (explicit kill or server shutdown).
        #0 0x7f5468ae4720 in __interceptor_free /build/gcc/src/gcc/libsanitizer/asan/asan_malloc_linux.cc:122
        #1 0x559820f5c9a0 in finish_destroy_win ../src/steamcompmgr.cpp:1743
        #2 0x559820f5ca6d in destroy_win ../src/steamcompmgr.cpp:1759
        #3 0x559820f6163e in steamcompmgr_main ../src/steamcompmgr.cpp:2288
        #4 0x559820f8e977 in steamCompMgrThreadRun() ../src/main.cpp:121
        #5 0x559820f8e3e9 in void std::__invoke_impl<void, void (*)()>(std::__invoke_other, void (*&&)()) /usr/include/c++/9.3.0/bits/invoke.h:60
        #6 0x559820f8e24f in std::__invoke_result<void (*)()>::type std::__invoke<void (*)()>(void (*&&)()) /usr/include/c++/9.3.0/bits/invoke.h:95
        #7 0x559820f8e0b3 in void std:🧵:_Invoker<std::tuple<void (*)()> >::_M_invoke<0ul>(std::_Index_tuple<0ul>) /usr/include/c++/9.3.0/thread:244
        #8 0x559820f8dfae in std:🧵:_Invoker<std::tuple<void (*)()> >::operator()() /usr/include/c++/9.3.0/thread:251
        #9 0x559820f8d7ba in std:🧵:_State_impl<std:🧵:_Invoker<std::tuple<void (*)()> > >::_M_run() /usr/include/c++/9.3.0/thread:195
        #10 0x7f5468006b23 in execute_native_thread_routine /build/gcc/src/gcc/libstdc++-v3/src/c++11/thread.cc:80
        #11 0x7f546745346e in start_thread (/usr/lib/libpthread.so.0+0x946e)
        #12 0x7f54673833d2 in clone (/usr/lib/libc.so.6+0xff3d2)

    0x61200017f140 is located 0 bytes inside of 296-byte region [0x61200017f140,0x61200017f268)
    allocated by thread T40 here:
        #0 0x7f5468ae6968 in operator new(unsigned long) /build/gcc/src/gcc/libsanitizer/asan/asan_new_delete.cc:104
        #1 0x559820f595fe in add_win ../src/steamcompmgr.cpp:1548
        #2 0x559820f614e8 in steamcompmgr_main ../src/steamcompmgr.cpp:2278
        #3 0x559820f8e977 in steamCompMgrThreadRun() ../src/main.cpp:121
        #4 0x559820f8e3e9 in void std::__invoke_impl<void, void (*)()>(std::__invoke_other, void (*&&)()) /usr/include/c++/9.3.0/bits/invoke.h:60
        #5 0x559820f8e24f in std::__invoke_result<void (*)()>::type std::__invoke<void (*)()>(void (*&&)()) /usr/include/c++/9.3.0/bits/invoke.h:95
        #6 0x559820f8e0b3 in void std:🧵:_Invoker<std::tuple<void (*)()> >::_M_invoke<0ul>(std::_Index_tuple<0ul>) /usr/include/c++/9.3.0/thread:244
        #7 0x559820f8dfae in std:🧵:_Invoker<std::tuple<void (*)()> >::operator()() /usr/include/c++/9.3.0/thread:251
        #8 0x559820f8d7ba in std:🧵:_State_impl<std:🧵:_Invoker<std::tuple<void (*)()> > >::_M_run() /usr/include/c++/9.3.0/thread:195
        #9 0x7f5468006b23 in execute_native_thread_routine /build/gcc/src/gcc/libstdc++-v3/src/c++11/thread.cc:80

    Thread T40 created by T0 here:
        #0 0x7f5468a0e377 in __interceptor_pthread_create /build/gcc/src/gcc/libsanitizer/asan/asan_interceptors.cc:208
        #1 0x7f5468006df9 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 0x7f5468006df9 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 0x559820f8ea10 in startSteamCompMgr ../src/main.cpp:126
        #4 0x559820f95cfb in xwayland_ready ../src/wlserver.c:119
        #5 0x5598210de191 in wlr_signal_emit_safe ../subprojects/wlroots/util/signal.c:29
        #6 0x559820ff596b in xserver_handle_ready ../subprojects/wlroots/xwayland/xwayland.c:251
        #7 0x7f5468744434  (/usr/lib/libwayland-server.so.0+0xa434)
        #8 0x7ffc9796869f  ([stack]+0x1f69f)
2020-05-08 22:12:13 +02:00
Simon Ser
7733ffb769 Fix crash on touch up 2020-05-08 22:11:38 +02:00