Skip to content

Commit

Permalink
merge rootfs
Browse files Browse the repository at this point in the history
  • Loading branch information
honjow committed Jan 18, 2024
1 parent d0799e8 commit 8d9566d
Show file tree
Hide file tree
Showing 31 changed files with 605 additions and 45 deletions.
340 changes: 340 additions & 0 deletions pkgs/xorg-xwayland/0001-xwayland-Implement-tearing-protocol.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,340 @@
From 168be90a4daa8a3bc9f7e5f787782d07b3dc8a68 Mon Sep 17 00:00:00 2001
From: Joshua Ashton <[email protected]>
Date: Wed, 24 Aug 2022 23:16:24 +0000
Subject: [PATCH] xwayland: Implement tearing protocol

Use gamescope tearing protocol instead

Renamed to not clash
---
hw/xwayland/meson.build | 2 +-
.../gamescope-tearing-control-unstable-v1.xml | 142 ++++++++++++++++++
hw/xwayland/xwayland-present.c | 18 +--
hw/xwayland/xwayland-screen.c | 7 +-
hw/xwayland/xwayland-screen.h | 2 +-
hw/xwayland/xwayland-window.c | 21 +--
hw/xwayland/xwayland-window.h | 2 +-
7 files changed, 169 insertions(+), 25 deletions(-)
create mode 100644 hw/xwayland/protocols/unstable/tearing-control/gamescope-tearing-control-unstable-v1.xml

diff --git a/hw/xwayland/meson.build b/hw/xwayland/meson.build
index 54529b64e..8955072a0 100644
--- a/hw/xwayland/meson.build
+++ b/hw/xwayland/meson.build
@@ -48,7 +48,7 @@ xdg_shell_xml = join_paths(protodir, 'stable', 'xdg-shell', 'xdg-shell.xml')
drm_lease_xml = join_paths(protodir, 'staging', 'drm-lease', 'drm-lease-v1.xml')
shortcuts_inhibit_xml = join_paths(protodir, 'unstable', 'keyboard-shortcuts-inhibit', 'keyboard-shortcuts-inhibit-unstable-v1.xml')
xwayland_shell_xml = join_paths(protodir, 'staging', 'xwayland-shell', 'xwayland-shell-v1.xml')
-tearing_xml = join_paths(protodir, 'staging', 'tearing-control', 'tearing-control-v1.xml')
+tearing_xml = join_paths('protocols', 'unstable', 'tearing-control', 'gamescope-tearing-control-unstable-v1.xml')

client_header = generator(scanner,
output : '@[email protected]',
diff --git a/hw/xwayland/protocols/unstable/tearing-control/gamescope-tearing-control-unstable-v1.xml b/hw/xwayland/protocols/unstable/tearing-control/gamescope-tearing-control-unstable-v1.xml
new file mode 100644
index 000000000..3c7cfb09e
--- /dev/null
+++ b/hw/xwayland/protocols/unstable/tearing-control/gamescope-tearing-control-unstable-v1.xml
@@ -0,0 +1,142 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<protocol name="gamescope_tearing_control_unstable_v1">
+
+ <copyright>
+ Copyright © 2021 Xaver Hugl
+
+ Permission is hereby granted, free of charge, to any person obtaining a
+ copy of this software and associated documentation files (the "Software"),
+ to deal in the Software without restriction, including without limitation
+ the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ and/or sell copies of the Software, and to permit persons to whom the
+ Software is furnished to do so, subject to the following conditions:
+
+ The above copyright notice and this permission notice (including the next
+ paragraph) shall be included in all copies or substantial portions of the
+ Software.
+
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ DEALINGS IN THE SOFTWARE.
+ </copyright>
+
+ <interface name="gamescope_tearing_control_v1" version="1">
+ <description summary="protocol for tearing control">
+ This global is a factory interface, allowing clients to request
+ the compositor to use asynchronous page flips on a per-surface basis.
+
+ Graphics APIs, like EGL or Vulkan, that manage the buffer queue and
+ commits of a wl_surface themselves, are likely to be using this
+ extension internally. If a client is using such an API for a
+ wl_surface, it should not directly use this extension on that surface,
+ to avoid raising a tearing_control_exists protocol error.
+
+ Warning! The protocol described in this file is experimental and
+ backward incompatible changes may be made. Backward compatible changes
+ may be added together with the corresponding interface version bump.
+ Backward incompatible changes are done by bumping the version number in
+ the protocol and interface names and resetting the interface version.
+ Once the protocol is to be declared stable, the 'z' prefix and the
+ version number in the protocol and interface names are removed and the
+ interface version number is reset.
+ </description>
+
+ <request name="destroy" type="destructor">
+ <description summary="destroy tearing control factory object">
+ Destroy this tearing control factory object. Other objects, including
+ gamescope_surface_tearing_control_v1 objects created by this factory,
+ shall not be affected by this request.
+ </description>
+ </request>
+
+ <enum name="error">
+ <entry name="tearing_control_exists" value="0"
+ summary="the surface already has a tearing object associated"/>
+ </enum>
+
+ <request name="get_tearing_control">
+ <description summary="extend surface interface for tearing control">
+ Instantiate an interface extension for the given wl_surface to
+ request asynchronous page flips for presentation.
+
+ If the given wl_surface already has a gamescope_surface_tearing_control_v1
+ object associated, the tearing_control_exists protocol error is raised.
+ </description>
+
+ <arg name="id" type="new_id"
+ interface="gamescope_surface_tearing_control_v1"
+ summary="the new surface tearing interface id"/>
+ <arg name="surface" type="object" interface="wl_surface"
+ summary="the surface"/>
+ </request>
+ </interface>
+
+ <interface name="gamescope_surface_tearing_control_v1" version="1">
+ <description summary="per-surface tearing control request">
+ An additional interface to a wl_surface object, which allows the client
+ to hint to the compositor if and when it should use asynchronous page
+ flips for presentation.
+ </description>
+
+ <enum name="presentation_hint">
+ <description summary="presentation hint values">
+ This enum provides information for if and when submitted frames from
+ the client may be presented with tearing. The possible values are:
+
+ VSYNC:
+ Presentation should be synchronized to the vertical retrace by the
+ display hardware so that tearing doesn't happen.
+
+ VSYNC_RELAXED:
+ Presentation should be synchronized to the vertical retrace by the
+ display hardware so that tearing doesn't happen as long as the client
+ submits new frame fast enough. If a frame is late for presentation,
+ that is, if more than one vertical retrace has occurred since the last
+ commit then the compositor should use asynchronous page flips to
+ immediately present the frame. This may cause visible tearing.
+ The compositor is encouraged to send requested frame callbacks as soon
+ as possible after such a late commit to make sure clients have as much
+ time as possible to render their next frame.
+
+ ASYNC:
+ Presentation should not be synchronized to the vertical retrace,
+ committed frames are meant to be immediately presented with asynchronous
+ page flips with as little delay as possible. Tearing will be visible.
+ The compositor is encouraged to send requested frame callbacks as soon
+ as possible after every commit.
+ </description>
+ <entry name="vsync" value="0"
+ summary="tearing-free presentation"/>
+ <entry name="vsync_relaxed" value="1"
+ summary="async pageflips on missed presentation deadline"/>
+ <entry name="async" value="2"
+ summary="async pageflips for all frames"/>
+ </enum>
+
+ <request name="set_presentation_hint">
+ <description summary="set presentation hint">
+ Set the presentation hint for the associated wl_surface. See
+ presentation_hint for the description. This state is double-buffered
+ and is applied on the next wl_surface.commit.
+
+ The compositor is free to dynamically respect or ignore this hint based
+ on various conditions, including GPU capabilities and surface window
+ state.
+ </description>
+ <arg name="hint" type="uint" enum="presentation_hint"/>
+ </request>
+
+ <request name="destroy" type="destructor">
+ <description summary="destroy synchronization object">
+ Destroy this surface tearing object and remove the presentation hint.
+ The change will be applied on the next wl_surface.commit.
+ </description>
+ </request>
+ </interface>
+
+</protocol>
+
diff --git a/hw/xwayland/xwayland-present.c b/hw/xwayland/xwayland-present.c
index 941be06da..5406d13d2 100644
--- a/hw/xwayland/xwayland-present.c
+++ b/hw/xwayland/xwayland-present.c
@@ -34,7 +34,8 @@
#include "xwayland-pixmap.h"
#include "glamor.h"

-#include "tearing-control-v1-client-protocol.h"
+#include "gamescope-tearing-control-unstable-v1-client-protocol.h"
+

#define XWL_PRESENT_CAPS PresentCapabilityAsync | PresentCapabilityAsyncMayTear

@@ -797,15 +798,14 @@ xwl_present_flip(present_vblank_ptr vblank, RegionPtr damage)
damage_box->x2 - damage_box->x1,
damage_box->y2 - damage_box->y1);

- if (xwl_window->tearing_control) {
- uint32_t hint;
- if (event->async_may_tear)
- hint = WP_TEARING_CONTROL_V1_PRESENTATION_HINT_ASYNC;
- else
- hint = WP_TEARING_CONTROL_V1_PRESENTATION_HINT_VSYNC;

- wp_tearing_control_v1_set_presentation_hint(xwl_window->tearing_control, hint);
- }
+ // Josh: No support for VSync relaxed, this is something that should
+ // be determined by a user setting in gamescope.
+ if (xwl_window->tearing_control)
+ gamescope_surface_tearing_control_v1_set_presentation_hint(xwl_window->tearing_control,
+ event->async_may_tear
+ ? GAMESCOPE_SURFACE_TEARING_CONTROL_V1_PRESENTATION_HINT_ASYNC
+ : GAMESCOPE_SURFACE_TEARING_CONTROL_V1_PRESENTATION_HINT_VSYNC);

wl_surface_commit(xwl_window->surface);

diff --git a/hw/xwayland/xwayland-screen.c b/hw/xwayland/xwayland-screen.c
index cc14e0771..2dafb8688 100644
--- a/hw/xwayland/xwayland-screen.c
+++ b/hw/xwayland/xwayland-screen.c
@@ -63,7 +63,7 @@
#include "viewporter-client-protocol.h"
#include "xdg-shell-client-protocol.h"
#include "xwayland-shell-v1-client-protocol.h"
-#include "tearing-control-v1-client-protocol.h"
+#include "gamescope-tearing-control-unstable-v1-client-protocol.h"

static DevPrivateKeyRec xwl_screen_private_key;
static DevPrivateKeyRec xwl_client_private_key;
@@ -462,9 +462,8 @@ registry_global(void *data, struct wl_registry *registry, uint32_t id,
xwl_screen->xwayland_shell =
wl_registry_bind(registry, id, &xwayland_shell_v1_interface, 1);
}
- else if (strcmp(interface, "wp_tearing_control_manager_v1") == 0) {
- xwl_screen->tearing_control_manager =
- wl_registry_bind(registry, id, &wp_tearing_control_manager_v1_interface, 1);
+ else if (strcmp(interface, "gamescope_tearing_control_v1") == 0) {
+ xwl_screen->tearing_control = wl_registry_bind(registry, id, &gamescope_tearing_control_v1_interface, 1);
}
#ifdef XWL_HAS_GLAMOR
else if (xwl_screen->glamor) {
diff --git a/hw/xwayland/xwayland-screen.h b/hw/xwayland/xwayland-screen.h
index bd66dd681..e840512ff 100644
--- a/hw/xwayland/xwayland-screen.h
+++ b/hw/xwayland/xwayland-screen.h
@@ -110,13 +110,13 @@ struct xwl_screen {
struct zxdg_output_manager_v1 *xdg_output_manager;
struct wp_viewporter *viewporter;
struct xwayland_shell_v1 *xwayland_shell;
- struct wp_tearing_control_manager_v1 *tearing_control_manager;
struct xorg_list drm_lease_devices;
struct xorg_list queued_drm_lease_devices;
struct xorg_list drm_leases;
struct xwl_output *fixed_output;
struct xorg_list pending_wl_surface_destroy;
uint64_t surface_association_serial;
+ struct gamescope_tearing_control_v1 *tearing_control;
uint32_t serial;

#define XWL_FORMAT_ARGB8888 (1 << 0)
diff --git a/hw/xwayland/xwayland-window.c b/hw/xwayland/xwayland-window.c
index 4978f37c7..efa03c357 100644
--- a/hw/xwayland/xwayland-window.c
+++ b/hw/xwayland/xwayland-window.c
@@ -46,10 +46,10 @@
#include "xwayland-shm.h"

#include "linux-dmabuf-unstable-v1-client-protocol.h"
-#include "tearing-control-v1-client-protocol.h"
#include "viewporter-client-protocol.h"
#include "xdg-shell-client-protocol.h"
#include "xwayland-shell-v1-client-protocol.h"
+#include "gamescope-tearing-control-unstable-v1-client-protocol.h"

#define DELAYED_WL_SURFACE_DESTROY 1000 /* ms */

@@ -926,6 +926,12 @@ ensure_surface_for_window(WindowPtr window)
xwl_screen->xwayland_shell, xwl_window->surface);
}

+ if (xwl_screen->tearing_control) {
+ xwl_window->tearing_control =
+ gamescope_tearing_control_v1_get_tearing_control(xwl_screen->tearing_control, xwl_window->surface);
+ }
+
+
if (!xwl_screen->rootless && !xwl_create_root_surface(xwl_window))
goto err;

@@ -967,11 +973,6 @@ ensure_surface_for_window(WindowPtr window)
xwl_window_check_resolution_change_emulation(xwl_window);
}

- if (xwl_screen->tearing_control_manager) {
- xwl_window->tearing_control = wp_tearing_control_manager_v1_get_tearing_control(
- xwl_screen->tearing_control_manager, xwl_window->surface);
- }
-
return TRUE;

err:
@@ -1175,6 +1176,11 @@ xwl_unrealize_window(WindowPtr window)
if (xwl_window_has_viewport_enabled(xwl_window))
xwl_window_disable_viewport(xwl_window);

+ if (xwl_window->tearing_control) {
+ gamescope_surface_tearing_control_v1_destroy(xwl_window->tearing_control);
+ xwl_window->tearing_control = NULL;
+ }
+
xwl_dmabuf_feedback_destroy(&xwl_window->feedback);

#ifdef GLAMOR_HAS_GBM
@@ -1182,9 +1188,6 @@ xwl_unrealize_window(WindowPtr window)
xwl_present_for_each_frame_callback(xwl_window, xwl_present_unrealize_window);
#endif

- if (xwl_window->tearing_control)
- wp_tearing_control_v1_destroy(xwl_window->tearing_control);
-
release_wl_surface_for_window(xwl_window);
xorg_list_del(&xwl_window->link_damage);
xorg_list_del(&xwl_window->link_window);
diff --git a/hw/xwayland/xwayland-window.h b/hw/xwayland/xwayland-window.h
index 7fbb2a623..a0c58bff1 100644
--- a/hw/xwayland/xwayland-window.h
+++ b/hw/xwayland/xwayland-window.h
@@ -121,7 +121,7 @@ struct xwl_window {
struct xwl_dmabuf_feedback feedback;
/* If TRUE, the window buffer format supports scanout with implicit modifier */
Bool has_implicit_scanout_support;
- struct wp_tearing_control_v1 *tearing_control;
+ struct gamescope_surface_tearing_control_v1 *tearing_control;
};

struct xwl_window *xwl_window_get(WindowPtr window);
--
2.43.0

Loading

0 comments on commit 8d9566d

Please sign in to comment.