Commit graph

536 commits

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