Commit graph

424 commits

Author SHA1 Message Date
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