ValveSoftware / gamescope

SteamOS session compositing window manager
Other
3.16k stars 214 forks source link

Add support for wp_viewporter #68

Open emersion opened 4 years ago

emersion commented 4 years ago

With https://github.com/swaywm/wlroots/pull/2092 merged, gamescope can easily add support for the wp_viewporter protocol, allowing old games that expect to be able to perform modesets to work correctly.

Requires Xwayland master.

misyltoad commented 1 year ago

We just pretend modesets don't exist and scale them ourselves now.

emersion commented 1 year ago

It would still be beneficial to support the viewporter protocol for native Wayland clients.

misyltoad commented 1 year ago

Hmmm, I would imagine stuff that wants this such as Wine Wayland would just ignore it here?

Feels wrong to expose something to just really blatantly ignore it in leiu of our own scaling parameters -- but may be necessary to make some apps work down the line.

emersion commented 1 year ago

No, we need to not ignore it. We need to scale/crop the buffers.

misyltoad commented 1 year ago

I guess what a video player, etc is a very different usecase to what Wine/XWayland uses it for.

We would not want this to be used or respected for games' modesets.

emersion commented 1 year ago

The fact that Xwayland emulates modesets via viewporter is purely an Xwayland specific behavior/quirk. The Wayland protocol does not imply any kind of modeset.

misyltoad commented 1 year ago

I guess one could hide wp_viewporter from the xwayland client, but we'd also want to hide it from Wine Wayland as well if it does that. Really we need more context here.

emersion commented 1 year ago

Why hide it from anybody?

Xwayland will not do the modeset emulation when viewporter is available. It also depends on an X11 property exchange with the compositor's XWM.

misyltoad commented 1 year ago

Because we don't want to care about the 'mode' the game wants to set. We scale everything ourselves, and offer multiple scaling filters and modes (fit, stretch, fill, etc) in CLI and in the Quick Access Menu for the user to select. Really we should just scale the DMABUF we get from the game based on whatever the user's preference is, not to 'stretch the dmabuf to the screen' like every game's modeset would be.

We're not a traditional desktop compositor where this would make sense.

emersion commented 1 year ago

X11 games which perform modesets don't use viewporter, because Xwayland notices we don't support the X11 emulation properties.

Wayland native games know that they cannot perform modesets via viewporter, because that's simply not what viewporter is.

misyltoad commented 1 year ago

What properties are you referring to? All I see is checks for the wp_viewporter protocol being exposed.

Bool
xwl_screen_has_viewport_support(struct xwl_screen *xwl_screen)
{
    return wl_compositor_get_version(xwl_screen->compositor) >=
                            WL_SURFACE_DAMAGE_BUFFER_SINCE_VERSION &&
           xwl_screen->viewporter != NULL;
}

Bool
xwl_screen_has_resolution_change_emulation(struct xwl_screen *xwl_screen)
{
    /* Resolution change emulation is only supported in rootless mode and
     * it requires viewport support.
     */
    return xwl_screen->rootless && xwl_screen_has_viewport_support(xwl_screen);
}

(Also I just realised we aren't setting force_xrandr_emulation right now, only the legacy XWAYLAND_FORCE_ENABLE_EXTRA_MODES hack for SteamOS. Forgot about that now we are on newer wlroots)