Gamescope swapchain
This is a private Gamescope protocol. Regular Wayland clients must not use it.
gamescope_swapchain_factory_v2
destroy()
create_swapchain(surface: object<wl_surface>, callback: new_id<gamescope_swapchain>)
Argument | Type | Description |
|---|---|---|
| surface | object<wl_surface> | target surface |
| callback | new_id<gamescope_swapchain> | new swapchain object |
This constructor only enables the original past_present_timing, refresh_cycle and retired events, regardless of the bound version. Clients must use create_swapchain_with_timing to opt into newer events.
create_swapchain_with_timing(surface: object<wl_surface>, callback: new_id<gamescope_swapchain>)
Argument | Type | Description |
|---|---|---|
| surface | object<wl_surface> | target surface |
| callback | new_id<gamescope_swapchain> | new swapchain object |
Creates a swapchain that also receives present_timing and timing_properties. Binding version 2 alone does not enable these events, since older clients may bind the advertised version without understanding them. The initial properties arrive once the compositor knows the surface's timing.
gamescope_swapchain
destroy()
override_window_content(gamescope_xwayland_server_id: uint, x11_window: uint)
Argument | Type | Description |
|---|---|---|
| gamescope_xwayland_server_id | uint | gamescope xwayland server ID |
| x11_window | uint | X11 window ID |
Xwayland creates a wl_surface for each X11 window. It sends a WL_SURFACE_ID client message to indicate the mapping between the X11 windows and the wl_surface objects.
This request overrides this mapping for a given X11 window, allowing an X11 client to submit buffers via the Wayland protocol. The override only affects buffer submission. Everything else (e.g. input events) still uses Xwayland's WL_SURFACE_ID.
x11_server is gotten by the GAMESCOPE_XWAYLAND_SERVER_ID property on the root window of the associated server.
swapchain_feedback(image_count: uint, vk_format: uint, vk_colorspace: uint, vk_composite_alpha: uint, vk_pre_transform: uint, vk_clipped: uint, vk_engine_name: string)
Argument | Type | Description |
|---|---|---|
| image_count | uint | image count of swapchain |
| vk_format | uint | VkFormat of swapchain |
| vk_colorspace | uint | VkColorSpaceKHR of swapchain |
| vk_composite_alpha | uint | VkCompositeAlphaFlagBitsKHR of swapchain |
| vk_pre_transform | uint | VkSurfaceTransformFlagBitsKHR of swapchain |
| vk_clipped | uint | clipped (VkBool32) of swapchain |
| vk_engine_name | string | Engine name |
Provide swapchain feedback to the compositor.
This is what the useless tearing protocol should have been. Absolutely not enough information in the final protocol to do what we want for SteamOS -- which is have the Allow Tearing toggle apply to *both* Mailbox + Immediate and NOT fifo, essentially acting as an override for tearing on/off for games. The upstream protocol is very useless for our usecase here.
Provides image count ahead of time instead of needing to try and calculate it from an initial stall if we are doing low latency.
Provides colorspace info for us to do HDR for both HDR10 PQ and scRGB. The upstream HDR efforts seem to have no interest in supporting scRGB but we *need* that so /shrug We can do it here now! Yipee!
Swapchain feedback solves so many problems! :D
set_present_mode(vk_present_mode: uint)
Argument | Type | Description |
|---|---|---|
| vk_present_mode | uint | VkPresentModeKHR |
set_hdr_metadata(display_primary_red_x: uint, display_primary_red_y: uint, display_primary_green_x: uint, display_primary_green_y: uint, display_primary_blue_x: uint, display_primary_blue_y: uint, white_point_x: uint, white_point_y: uint, max_display_mastering_luminance: uint, min_display_mastering_luminance: uint, max_cll: uint, max_fall: uint)
Argument | Type | Description |
|---|---|---|
| display_primary_red_x | uint | red primary x coordinate |
| display_primary_red_y | uint | red primary y coordinate |
| display_primary_green_x | uint | green primary x coordinate |
| display_primary_green_y | uint | green primary y coordinate |
| display_primary_blue_x | uint | blue primary x coordinate |
| display_primary_blue_y | uint | blue primary y coordinate |
| white_point_x | uint | white point x coordinate |
| white_point_y | uint | white point y coordinate |
| max_display_mastering_luminance | uint | max display mastering luminance |
| min_display_mastering_luminance | uint | min display mastering luminance |
| max_cll | uint | max content light level |
| max_fall | uint | max frame average light level |
Forward HDR metadata from Vulkan to the compositor.
HDR Metadata Infoframe as per CTA 861.G spec. This is expected to match exactly with the spec.
display_primary_*: Color Primaries of the Data. Specifies X and Y coordinates. These are coded as unsigned 16-bit values in units of 0.00002, where 0x0000 represents zero and 0xC350 represents 1.0000.
white_point_*: White Point of Colorspace Data. Specifies X and Y coordinates. These are coded as unsigned 16-bit values in units of 0.00002, where 0x0000 represents zero and 0xC350 represents 1.0000.
max_display_mastering_luminance: Max Mastering Display Luminance. This value is coded as an unsigned 16-bit value in units of 1 cd/m2, where 0x0001 represents 1 cd/m2 and 0xFFFF represents 65535 cd/m2.
max_display_mastering_luminance: Min Mastering Display Luminance. This value is coded as an unsigned 16-bit value in units of 0.0001 cd/m2, where 0x0001 represents 0.0001 cd/m2 and 0xFFFF represents 6.5535 cd/m2.
max_cll: Max Content Light Level. This value is coded as an unsigned 16-bit value in units of 1 cd/m2, where 0x0001 represents 1 cd/m2 and 0xFFFF represents 65535 cd/m2.
max_fall: Max Frame Average Light Level. This value is coded as an unsigned 16-bit value in units of 1 cd/m2, where 0x0001 represents 1 cd/m2 and 0xFFFF represents 65535 cd/m2.
set_present_time(present_id: uint, desired_present_time_hi: uint, desired_present_time_lo: uint)
Argument | Type | Description |
|---|---|---|
| present_id | uint | application provided presentation id |
| desired_present_time_hi | uint | high part of the desired presentation time for this commit. Uses CLOCK_MONOTONIC. 0 = present as soon as possible. |
| desired_present_time_lo | uint | low part of the desired presentation time for this commit. Uses CLOCK_MONOTONIC. 0 = present as soon as possible. |
Sets the display timing of the next commit.
This gets reset to 0s in the compositor's state after a commit.
set_present_timing(serial_hi: uint, serial_lo: uint, target_hi: uint, target_lo: uint, flags: uint<gamescope_swapchain.present_timing_flags>)
Argument | Type | Description |
|---|---|---|
| serial_hi | uint | high part of the client timing serial |
| serial_lo | uint | low part of the client timing serial |
| target_hi | uint | high part of target time or relative duration in nanoseconds |
| target_lo | uint | low part of target time or relative duration in nanoseconds |
| flags | uint<gamescope_swapchain.present_timing_flags> | presentation timing flags |
Only swapchains created with create_swapchain_with_timing accept this request. Other swapchains ignore it, including zero-serial requests. Registers a client-local serial for one timing report. Target uses CLOCK_MONOTONIC nanoseconds, or a duration with the relative flag. Zero requests presentation as soon as possible, as does a relative target before this swapchain has latched a frame. Unknown flag bits are ignored. The request applies to the next commit that carries buffer content, including one that recommits the current buffer. Replacing an armed serial reports the old serial as dropped. A zero serial clears any armed request and is never reported.
past_present_timing(present_id: uint, desired_present_time_hi: uint, desired_present_time_lo: uint, actual_present_time_hi: uint, actual_present_time_lo: uint, earliest_present_time_hi: uint, earliest_present_time_lo: uint, present_margin_hi: uint, present_margin_lo: uint)
Argument | Type | Description |
|---|---|---|
| present_id | uint | application provided presentation id |
| desired_present_time_hi | uint | high part of the desired presentation time for the commit. (from the app) |
| desired_present_time_lo | uint | low part of the desired presentation time for the commit. (from the app) |
| actual_present_time_hi | uint | high part of the actual present time for this commit. |
| actual_present_time_lo | uint | low part of the actual present time for this commit. |
| earliest_present_time_hi | uint | high part of the refresh time that Gamescope thought this commit was done by. |
| earliest_present_time_lo | uint | low part of the refresh time that Gamescope thought this commit was done by. |
| present_margin_hi | uint | high part of the difference between earliest present time and the earliest latch time |
| present_margin_lo | uint | low part of the difference between earliest present time and the earliest latch time |
Gives information on the past presentation timing
refresh_cycle(refresh_cycle_hi: uint, refresh_cycle_lo: uint)
Argument | Type | Description |
|---|---|---|
| refresh_cycle_hi | uint | high part of the refresh cycle in nanos |
| refresh_cycle_lo | uint | low part of the refresh cycle in nanos |
Gives information on the refresh cycle for this swapchain
present_timing(serial_hi: uint, serial_lo: uint, queue_end_hi: uint, queue_end_lo: uint, dequeued_hi: uint, dequeued_lo: uint, pixel_out_hi: uint, pixel_out_lo: uint)
Argument | Type | Description |
|---|---|---|
| serial_hi | uint | high part of the client timing serial |
| serial_lo | uint | low part of the client timing serial |
| queue_end_hi | uint | high part of queue completion time in nanoseconds |
| queue_end_lo | uint | low part of queue completion time in nanoseconds |
| dequeued_hi | uint | high part of latch time in nanoseconds |
| dequeued_lo | uint | low part of latch time in nanoseconds |
| pixel_out_hi | uint | high part of predicted scanout time in nanoseconds |
| pixel_out_lo | uint | low part of predicted scanout time in nanoseconds |
Only sent to swapchains created with create_swapchain_with_timing. Sent once per serial when presented or dropped, unless this object is destroyed first. All timestamps use CLOCK_MONOTONIC nanoseconds. Zero means unavailable, and a dropped commit has all timestamps zero. Pixel out is the compositor's predicted scanout.
timing_properties(refresh_duration_hi: uint, refresh_duration_lo: uint, refresh_interval_hi: uint, refresh_interval_lo: uint)
Argument | Type | Description |
|---|---|---|
| refresh_duration_hi | uint | high part of effective refresh duration in nanoseconds |
| refresh_duration_lo | uint | low part of effective refresh duration in nanoseconds |
| refresh_interval_hi | uint | high part of base refresh interval in nanoseconds |
| refresh_interval_lo | uint | low part of base refresh interval in nanoseconds |
Only sent to swapchains created with create_swapchain_with_timing. Duration is the effective cycle including the frame limiter, the same value refresh_cycle carries. Interval is the panel cycle on fixed refresh, or UINT64_MAX for variable refresh. Sent once the compositor knows the window's timing and whenever the values change. Until then both values are unknown to the client.
present_timing_flags { relative, nearest_refresh_cycle }
Argument | Value | Description |
|---|---|---|
| relative | 1 | target is a duration after this swapchain's previous expected scanout |
| nearest_refresh_cycle | 2 | allow presentation less than half an effective refresh cycle early |
Compositor Support
| gamescope_swapchain_factory_v2 | ↓ | ||
| Compositors | |||
| Cage | 0.3.0 | x | |
| COSMIC | 1.11.0 | x | |
| flakewm | 3.0.5 | x | |
| GameScope | 3.17.0 | 2 | |
| Hyprland | 0.57.2 | x | |
| Jay | 1.14.0 | x | |
| KWin | 6.7 | x | |
| Labwc | 0.20.2 | x | |
| Louvre | 2.14.1 | x | |
| Mango | 0.16.3 | x | |
| Mir | 2.26 | x | |
| Muffin | 6.7.4 | x | |
| Mutter | 51 | x | |
| niri | 26.04 | x | |
| phoc | 0.55 | x | |
| Pila | 0.5.1 | x | |
| Qtile | 0.37.1 | x | |
| river | 0.5.0 | x | |
| Sway | 1.11 | x | |
| Treeland | 0.8.0 | x | |
| Wayfire | 0.9.0 | x | |
| Weston | 15.0.1 | x | |
Copyright
Copyright © 2023 Joshua Ashton for Valve Software
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.