Skip to content

add global gamescope microcompositor support#14871

Draft
aderumier wants to merge 1 commit into
batocera-linux:masterfrom
aderumier:gamescope
Draft

add global gamescope microcompositor support#14871
aderumier wants to merge 1 commit into
batocera-linux:masterfrom
aderumier:gamescope

Conversation

@aderumier

Copy link
Copy Markdown
Contributor

This is a continuation of this work:

#13690

Gamescope is a microcompositor allowing to any emulator or process is a wayland surfarce,
with upscaling|downscaling support with fsr or other modern techniques.

It's also add support for HDR for games supporting it. (mostly modern windows games).

For wine, it's really usefull, as currently, wine is using xrandr to switch the monitor resolution to the native game resolution with an automatic frequency (even if videomode is at batocer size defined, it'll can change it), and sometime it choose a bad unsupported frequency or resolution, and user can have a black screen or game not rendered full screen. (some 4k tvs have shit EDID).

This is also allowing some only 1080p games to run on steamdeck in 720p. (Most of the modern arcade games have fixed internal resolution, and are not able to downscale)
or allow to run 16:9 in 4:3 arcade cabinet monitor

Gamescope is compatible with AMD (Mesa 20.3+), Intel (Mesa 21.2+) , Nvidia proprietary driver (515.43.04+). So no legacy driver for nvidia, as it need gbm support.

I have tested myself and some friend with : nvidia rtx2070, nvidia quadro, amd rx 6600, Nvidia Quadro P1000, amd ryzen7 apu, steamdeck

@Redemp

Redemp commented Nov 28, 2025

Copy link
Copy Markdown
Contributor

Thanks @aderumier

I just wanted to say a proper thank you for

  • Reaching out to me on Discord and all the discussions we had in DMs.
  • Picking up my original Gamescope PR for Wine-only support (GameScope support for Wine #13690) and using it as a base.
  • Building on top of that work and turning it into this new global Gamescope feature for all emulators in Batocera.
  • All the testing and refinement you’ve done to get it to this point.

I really appreciate the collaboration and the fact that you didn’t just redo everything from scratch but iterated on the original idea and pushed it much further. It’s great to see Gamescope becoming a proper first-class, global feature in Batocera.

/Rion

@dmanlfc

dmanlfc commented Nov 28, 2025

Copy link
Copy Markdown
Collaborator

@aderumier good job, please mark it as draft until finished

a few of points:

  1. wayland should be optional as gamescope should run on xorg without wayland (afaik)
  2. therefore make the dependencies based on the support for the board they're built against
  • we don't want unnecessary packages enabled for an ecosystem which will affect other package builds
  1. please aim for .mk files to ideally stay with in the hash length for the package
  2. tidy the config.in as well as you don't need to select all packages if they're optional
  3. squash your commits :-)

@aderumier

Copy link
Copy Markdown
Contributor Author

@aderumier good job, please mark it as draft until finished

a few of points:

  1. wayland should be optional as gamescope should run on xorg without wayland (afaik)
  2. therefore make the dependencies based on the support for the board they're built against
  • we don't want unnecessary packages enabled for an ecosystem which will affect other package builds
  1. please aim for .mk files to ideally stay with in the hash length for the package
  2. tidy the config.in as well as you don't need to select all packages if they're optional
  3. squash your commits :-)

I have only tested on xorg with xwayland, at minimum it need libwayland-client && libwaylab-server

gamescope is using wlroots internally and run only on pure wayland or xwayland(wit xorg)

I'm pretty noob with buildroot, so sorry, I'll try to reduce dependencies at minimum again. (I had already tried to reduce it)

(the depend in .mk are ok , but i'm not sure in Config.in )

BR2_PACKAGE_WAYLAND_PROTOCOLS && BR2_PACKAGE_XWAYLAND are needed at minimum, I'm not sure about BR2_PACKAGE_WAYLAND

I'll do test again.

@aderumier

Copy link
Copy Markdown
Contributor Author

to be more precise, gamescope is opening a new wayland session over current Xorg with only the game running in this session fullscreen. And the game inside gamescope, can run with Xwayland or native wayland if it support it).

@crcerror

Copy link
Copy Markdown
Contributor

@aderumier You can use TortoiseGit if you are working on windows ... I've made a small writeup here https://wiki.batocera.org/github-tortoisegit
Also squasing and rebasing can be done on the fly here .... (did not documented so far but ask in discord)
Good job @aderumier and thankx @Redemp

@dmanlfc

dmanlfc commented Nov 28, 2025

Copy link
Copy Markdown
Collaborator

@aderumier i think you're confused. xwayland is for backward compatibility with wayland compositors. are you suggesting xorg -> gamescope -> wayland -> xwayland?
if wayland is truly needed then this opens up a can or worms for the xorg only x86_64 build.
are you sure you just don't need wlroots with possibly wayland protocols?

i will look at their source code...

@dmanlfc

dmanlfc commented Nov 28, 2025

Copy link
Copy Markdown
Collaborator

ok we have a problem, it does look like wayland is needed.
this will break the build and set the wrong expectations for older nvidia card users.
we can accept it for the newer zen3 images but not the x86_64 one.

@Redemp

Redemp commented Nov 28, 2025

Copy link
Copy Markdown
Contributor

ok we have a problem, it does look like wayland is needed. this will break the build and set the wrong expectations for older nvidia card users. we can accept it for the newer zen3 images but not the x86_64 one.

I have no issues running this on my R9 380X..

What do you mean by not the x86_64

I specifically developed this without issue using my older AMD RX 380X cards in the older pull request..

@dmanlfc

dmanlfc commented Nov 29, 2025

Copy link
Copy Markdown
Collaborator

Read what I wrote. Older NVIDIA cards don't support Wayland. You can't add it to a broad OS image such as x86_64 without causing confusion not to mention the graphics stack ugliness.

@dmanlfc

dmanlfc commented Nov 29, 2025

Copy link
Copy Markdown
Collaborator

ok built it, yes it needs xwayland as a dependency.

like this @aderumier

################################################################################
#
# gamescope
#
################################################################################

GAMESCOPE_VERSION = 3.16.17
GAMESCOPE_SITE = https://github.com/ValveSoftware/gamescope
GAMESCOPE_SITE_METHOD = git
GAMESCOPE_GIT_SUBMODULES=YES

GAMESCOPE_DEPENDENCIES += hwdata libdisplay-info libdecor luajit seatd
GAMESCOPE_DEPENDENCIES += vulkan-headers vulkan-loader wayland wayland-protocols 
GAMESCOPE_DEPENDENCIES += xlib_libX11 xlib_libXmu xlib_libXres xwayland

GAMESCOPE_CONF_OPTS = --wrap-mode=default
GAMESCOPE_CONF_OPTS += -Dbenchmark=disabled
GAMESCOPE_CONF_OPTS += -Denable_openvr_support=false
GAMESCOPE_CONF_OPTS += -Dinput_emulation=disabled

ifeq ($(BR2_PACKAGE_LIBAVIF),y)
GAMESCOPE_DEPENDENCIES += libavif
GAMESCOPE_CONF_OPTS += -Davif_screenshots=enabled
else
GAMESCOPE_CONF_OPTS += -Davif_screenshots=disabled
endif

ifeq ($(BR2_PACKAGE_LIBDRM),y)
GAMESCOPE_DEPENDENCIES += libdrm
GAMESCOPE_CONF_OPTS += -Ddrm_backend=enabled
else
GAMESCOPE_CONF_OPTS += -Ddrm_backend=disabled
endif

ifeq ($(BR2_PACKAGE_PIPEWIRE),y)
GAMESCOPE_DEPENDENCIES += pipewire
GAMESCOPE_CONF_OPTS += -Dpipewire=enabled
else
GAMESCOPE_CONF_OPTS += -Dpipewire=disabled
endif

ifeq ($(BR2_PACKAGE_SDL2),y)
GAMESCOPE_DEPENDENCIES += sdl2
GAMESCOPE_CONF_OPTS += -Dsdl2_backend=enabled
else
GAMESCOPE_CONF_OPTS += -Dsdl2_backend=disabled
endif

define GAMESCOPE_INSTALL_TARGET_CMDS
	mkdir -p $(TARGET_DIR)/usr/bin
	$(INSTALL) -D $(@D)/build/src/gamescope $(TARGET_DIR)/usr/bin/gamescope
	$(INSTALL) -D $(@D)/build/src/gamescopereaper $(TARGET_DIR)/usr/bin/gamescopereaper
	$(INSTALL) -D $(@D)/build/src/gamescopestream $(TARGET_DIR)/usr/bin/gamescopestream
	$(INSTALL) -D $(@D)/build/src/gamescopectl $(TARGET_DIR)/usr/bin/gamescopectl
endef

$(eval $(meson-package))

and...

config BR2_PACKAGE_GAMESCOPE
    bool "gamescope"
    select BR2_PACKAGE_HWDATA
    select BR2_PACKAGE_LIBDECOR
    select BR2_PACKAGE_LIBDISPLAY_INFO
    select BR2_PACKAGE_LIBX11
    select BR2_PACKAGE_LIBXCB
    select BR2_PACKAGE_LIBXRES
    select BR2_PACKAGE_LUAJIT    if !BR2_PACKAGE_LUA
    select BR2_PACKAGE_SEATD
    select BR2_PACKAGE_SEATD_DAEMON
    select BR2_PACKAGE_VULKAN_HEADERS
    select BR2_PACKAGE_VULKAN_LOADER
    select BR2_PACKAGE_WAYLAND
    select BR2_PACKAGE_WAYLAND_PROTOCOLS
    select BR2_PACKAGE_WLROOTS
    select BR2_PACKAGE_WLROOTS_X11
    select BR2_PACKAGE_XLIB_LIBXMU
    select BR2_PACKAGE_XWAYLAND
    help
      SteamOS session compositing window manager

      https://github.com/Plagman/gamescope

@Redemp

Redemp commented Nov 29, 2025

Copy link
Copy Markdown
Contributor

Read what I wrote. Older NVIDIA cards don't support Wayland. You can't add it to a broad OS image such as x86_64 without causing confusion not to mention the graphics stack ugliness.

My idea was instead to tap into this new function introduced in v42 by @bryanforbes

#13679

With this we could just display a message to the user if gamescope is unsupported by the dGPU/APU

@dmanlfc

dmanlfc commented Nov 29, 2025

Copy link
Copy Markdown
Collaborator

easier said than done unfortunately.
until such time i still think xorg -> gamescope -> wayland -> xwayland (and it's probably more complicated than that) is plain stupid. not to mention messy.
running wayland -> gamescope and occasionally when you need it for compatibility wayland -> gamescope -> xwayland is much nicer.
hence bringing it into zen3 which is wayland by design is a much better starting point.

@aderumier

Copy link
Copy Markdown
Contributor Author

gamescope itself is building 3 libs statically with specific version: (wlroots=0.18 ,vkroots ,libliftoff 0.5)

(fallback for theses 3 lib ares forced in gamescope meson as wlroots versions are not abi retrocompatible,and for example last sway already use 0.19)

so ithe depends are more like this to be complete:

GAMESCOPE_DEPENDENCIES = sdl2 glm stb libdrm pipewire libdecor luajit libavif wayland wayland-protocols xwayland hwdata #gamescope

GAMESCOPE_DEPENDENCIES += host-pkgconf host-wayland hwdata libdisplay-info libinput libegl libgles libgbm pixman seatd udev #wlroots
GAMESCOPE_DEPENDENCIES += xlib_libXres xlib_libXmu xlib_libXcomposite xlib_libXdamage xlib_libXcursor xlib_libXrender xlib_libXrender xlib_libXext xlib_libXfixes xlib_libXxf86vm xlib_libXtst libxcb xcb-util-wm #vkroots

@dmanlfc

dmanlfc commented Nov 29, 2025

Copy link
Copy Markdown
Collaborator

sorry this is incorrect. glm stb get built by meson.
sdl2 libdrm & pipewire are optional features as should be treated as such.
host-pkgconf is not needed it's default in buildroot.
host-wayland is just not needed also.

other dependencies are automatically pulled in by others already defined.

if you build it as i wrote it, it should work.

@aderumier

aderumier commented Nov 29, 2025

Copy link
Copy Markdown
Contributor Author

easier said than done unfortunately. until such time i still think xorg -> gamescope -> wayland -> xwayland (and it's probably more complicated than that) is plain stupid. not to mention messy. running wayland -> gamescope and occasionally when you need it for compatibility wayland -> gamescope -> xwayland is much nicer. hence bringing it into zen3 which is wayland by design is a much better starting point.

no, it's more

-->xorg session--->gamescope  -> xwayland---> X11 game
                               -> wayland  native game

They are not "wayland" server, wayland is a lib, and the "server" is the compositor : gamescope, sway, ...

without xorg, you could used gamescope nested behind sway, or directly gamescope in standalone, managing the whole sessions

nested

-->sway--->gamescope nested -> xwayland---> X11 game
                            -> wayland  native game

standalone

-->gamescope session -> xwayland---> X11 game
                      -> wayland  native game

(I think that steamdeck steamos use standalone model)

@aderumier

aderumier commented Nov 29, 2025

Copy link
Copy Markdown
Contributor Author

easier said than done unfortunately. until such time i still think xorg -> gamescope -> wayland -> xwayland (and it's probably more complicated than that) is plain stupid. not to mention messy. running wayland -> gamescope and occasionally when you need it for compatibility wayland -> gamescope -> xwayland is much nicer. hence bringing it into zen3 which is wayland by design is a much better starting point.

but, how can you use wayland currently with non zen3 cpu ? (intel cpu with radeon for example)

could it better to make generic x86 xorg or wayland image ? instead only enable wayland for specific cpu > zen3 ?

or install both xorg,wayland by default in x86 images, and allow to switch between them.

@Redemp

Redemp commented Nov 29, 2025

Copy link
Copy Markdown
Contributor

easier said than done unfortunately. until such time i still think xorg -> gamescope -> wayland -> xwayland (and it's probably more complicated than that) is plain stupid. not to mention messy. running wayland -> gamescope and occasionally when you need it for compatibility wayland -> gamescope -> xwayland is much nicer. hence bringing it into zen3 which is wayland by design is a much better starting point.

I just want to clarify a couple of points from the X11 vs Wayland angle, especially since I originally did the Wine-only Gamescope PR and have spent a lot of time testing this on the current x86_64 image.

xorg -> gamescope -> wayland -> xwayland … is plain stupid. not to mention messy.

Architecturally, Gamescope is always a Wayland compositor, but on an Xorg session it is not actually that many layers in practice. What we really have is:

  • host Xorg session
  • Gamescope running as a nested compositor on top of Xorg (fullscreen window)
  • inside Gamescope: Xwayland (for X11 games) or native Wayland clients

This is a very common setup today. Gamescope is explicitly designed to run either

  • as a nested micro-compositor on top of an existing desktop, or
  • as a full DRM/KMS session without a normal desktop underneath it.

Arch based setups like ChimeraOS, and distros such as Nobara and Bazzite, all ship variations of this model. Some use a dedicated "Gamescope session" that logs you directly into Gamescope on KMS, and the same tooling can also run nested from a regular X11 or Wayland desktop. In all of those cases the core idea is the same: Gamescope is a small compositor that can sit on top of an existing session and still talk directly to DRM for flips and scaling when the driver stack allows it.

On the current generic x86_64 Batocera image I already run Gamescope this way on an AMD R9 380X (amdgpu, Mesa) without real issues:

  • no extra tearing compared to straight Xorg when page flips are working
  • latency impact in line with adding a single fullscreen compositor
  • internal resolution tricks and scaling behaving as intended

For modern flat panels on supported AMD / Intel / NVIDIA GPUs this nested path is what actually unlocks most of the useful Gamescope workflows: resolution spoofing to force specific internal resolutions and aspect ratios (for example 4:3 on a 16:9 screen), upscaling from sub-native resolutions, using AMD FidelityFX Super Resolution or NVIDIA Image Scaling, applying ReShade, and enforcing clean frame rate limits with stable fullscreen behavior. Under the hood, the timing and resolution stack that makes this possible (including SwitchRes for downscaling, custom low resolution modes and non-standard refresh rates, whether the target is a flat panel or a CRT) is still built entirely around Xorg and direct xrandr/DRM mode programming. Wayland compositors today do not expose the same low level mode control that these tools rely on, so a Wayland first base would effectively drop that whole class of workflows. If Gamescope ends up available only on a future Zen3 Wayland image, all of these existing use cases on the generic x86_64 build lose access to something that is already working today, both for modern displays and for CRT/downscaling setups.

I completely understand the concern about older NVIDIA cards and the different driver paths. But that is really a runtime support problem, not a reason to avoid shipping Gamescope for x86_64 entirely:

  • Older NVIDIA with legacy drivers simply cannot run Gamescope reliably. That is fine.
  • Modern AMD / Intel and newer NVIDIA with GBM-capable drivers can run it, even when the main session is Xorg.

This is where the new capability detection work from @bryanforbes in #13679 becomes very useful. Instead of making a hard build time decision, we can:

  1. Add a simple "supports_gamescope" capability that checks vendor, driver and minimal Vulkan or GBM support.
  2. If the GPU does not qualify, hide the Gamescope options or show a clear message such as:

    "Gamescope is not available on this GPU or driver (requires modern AMD/Intel, or NVIDIA with GBM-capable drivers)."

  3. Keep Gamescope compiled for the generic x86_64 image so that supported GPUs (like my R9 380X and other common AMD/Intel hardware) can actually use it.

That way:

  • Older NVIDIA users on x86_64 do not get broken expectations or confusing menu entries.
  • We do not need two different feature sets between "Zen3 only" and "everyone else" for a feature that already works on many existing machines.
  • Users on the generic image with supported AMD / Intel / NVIDIA hardware, whether they are on modern flat panels or CRTs, keep access to what Gamescope already gives us today: consistent frame pacing, good scaling from sub-native resolutions, optional frame rate limiting, better fullscreen handling, and improved behavior for odd refresh rates and awkward game modes.

I would really hate to see it excluded from the generic image when it is already proven to work there for a large chunk of AMD/Intel and Nvidia users.

To be clear, this is also why I do not think it makes sense to restrict Gamescope only to a future Wayland based, AMD handled build. With everything above in mind, that would be an unnecessarily narrow target for a feature that already works today on the generic x86_64 image:

  • It would exclude all users perfectly capable AMD/NVIDIA/Intel setups that can already run Gamescope on Xorg without issues.
  • It would effectively remove existing, tested use cases from current users, just to make the feature available in a smaller, future subset of hardware and configurations.

@dmanlfc

dmanlfc commented Nov 29, 2025

Copy link
Copy Markdown
Collaborator

@Redemp all the OS's you mentioned run Wayland by default and are forks of or provide an OS similar to SteamOS from which gamescope was designed for.
I don't know how many times you wish me to say this but bringing in a bunch of dependencies for wayland will have a knock-on effect for other packages in the x86_64 build ecosystem. effectively building support for wayland into said packages also. this may have a negative impact and I will be the one who would need to tidy it up.
I have no doubt this works in your testing but I have to think of the bigger picture and also support. Could we raise a support case for gamescope on xorg? these are the things i need to consider.
since your driver identification is not added to this PR all I can say is that this would be an ideal approach before committing to x86_64. until such time we can bring this PR into zen3 which is more controlled & then expand from there.

the PR is still incomplete and should be marked as draft until things are tidied up.

but for now select BR2_PACKAGE_GAMESCOPE if BR2_PACKAGE_BATOCERA_TARGET_ZEN3

in future we can do select BR2_PACKAGE_GAMESCOPE if BR2_PACKAGE_BATOCERA_XWAYLAND && BR2_PACKAGE_BATOCERA_WAYLAND && BR2_PACKAGE_BATOCERA_VULKAN to possibly test higher-end arm boards too but that's up to Valve... SteamDeck 2? :-)

@aderumier

Copy link
Copy Markdown
Contributor Author

to detect for driver support, I think we can use eglinfo to detect gbm support

nvidia

#DISPLAY=:0.0 eglinfo
...
GBM platform:
EGL API version: 1.5
EGL vendor string: NVIDIA
EGL version string: 1.5
EGL client APIs: OpenGL_ES OpenGL
EGL extensions string:
    EGL_ANDROID_native_fence_sync, EGL_EXT_buffer_age, EGL_EXT_client_sync, 
    EGL_EXT_create_context_robustness, EGL_EXT_image_dma_buf_import, 
    EGL_EXT_image_dma_buf_import_modifiers, EGL_EXT_output_base, 
    EGL_EXT_output_drm, EGL_EXT_protected_content, 
    EGL_EXT_stream_acquire_mode, EGL_EXT_stream_consumer_egloutput, 
    EGL_EXT_sync_reuse, EGL_IMG_context_priority, EGL_KHR_config_attribs, 
    EGL_KHR_context_flush_control, EGL_KHR_create_context, 
    EGL_KHR_create_context_no_error, EGL_KHR_fence_sync, 
    EGL_KHR_get_all_proc_addresses, EGL_KHR_gl_colorspace, 
    EGL_KHR_gl_renderbuffer_image, EGL_KHR_gl_texture_2D_image, 
    EGL_KHR_gl_texture_3D_image, EGL_KHR_gl_texture_cubemap_image, 
    EGL_KHR_image, EGL_KHR_image_base, EGL_KHR_no_config_context, 
    EGL_KHR_partial_update, EGL_KHR_reusable_sync, EGL_KHR_stream, 
    EGL_KHR_stream_attrib, EGL_KHR_stream_consumer_gltexture, 
    EGL_KHR_stream_cross_process_fd, EGL_KHR_stream_fifo, 
    EGL_KHR_stream_producer_eglsurface, EGL_KHR_surfaceless_context, 
    EGL_KHR_swap_buffers_with_damage, EGL_KHR_wait_sync, 
    EGL_MESA_image_dma_buf_export, EGL_NV_nvrm_fence_sync, 
    EGL_NV_output_drm_flip_event, EGL_NV_quadruple_buffer, 
    EGL_NV_robustness_video_memory_purge, EGL_NV_stream_attrib, 
    EGL_NV_stream_consumer_eglimage, EGL_NV_stream_consumer_gltexture_yuv, 
    EGL_NV_stream_cross_display, EGL_NV_stream_cross_object, 
    EGL_NV_stream_cross_process, EGL_NV_stream_cross_system, 
    EGL_NV_stream_dma, EGL_NV_stream_fifo_next, 
    EGL_NV_stream_fifo_synchronous, EGL_NV_stream_flush, 
    EGL_NV_stream_metadata, EGL_NV_stream_origin, EGL_NV_stream_remote, 
    EGL_NV_stream_reset, EGL_NV_stream_socket, EGL_NV_stream_socket_inet, 
    EGL_NV_stream_socket_unix, EGL_NV_stream_sync, EGL_NV_system_time, 
    EGL_NV_triple_buffer, EGL_WL_bind_wayland_display, 
    EGL_WL_wayland_eglstream

amd

EGL API version: 1.5
EGL vendor string: Mesa Project
EGL version string: 1.5
EGL client APIs: OpenGL OpenGL_ES 
EGL driver name: radeonsi
EGL extensions string:
    EGL_ANDROID_blob_cache, EGL_ANDROID_native_fence_sync, EGL_EXT_buffer_age, 
    EGL_EXT_config_select_group, EGL_EXT_create_context_robustness, 
    EGL_EXT_image_dma_buf_import, EGL_EXT_image_dma_buf_import_modifiers, 
    EGL_EXT_pixel_format_float, EGL_EXT_protected_surface, 
    EGL_EXT_query_reset_notification_strategy, EGL_EXT_surface_compression, 
    EGL_IMG_context_priority, EGL_KHR_cl_event2, EGL_KHR_config_attribs, 
    EGL_KHR_context_flush_control, EGL_KHR_create_context, 
    EGL_KHR_create_context_no_error, EGL_KHR_fence_sync, 
    EGL_KHR_get_all_proc_addresses, EGL_KHR_gl_colorspace, 
    EGL_KHR_gl_renderbuffer_image, EGL_KHR_gl_texture_2D_image, 
    EGL_KHR_gl_texture_3D_image, EGL_KHR_gl_texture_cubemap_image, 
    EGL_KHR_image, EGL_KHR_image_base, EGL_KHR_image_pixmap, 
    EGL_KHR_no_config_context, EGL_KHR_reusable_sync, 
    EGL_KHR_surfaceless_context, EGL_KHR_wait_sync, 
    EGL_MESA_configless_context, EGL_MESA_drm_image, EGL_MESA_gl_interop, 
    EGL_MESA_image_dma_buf_export, EGL_MESA_query_driver, 
    EGL_MESA_x11_native_visual_id

grep on "EGL_WL_wayland_eglstream" should be enough (or maybe EGL_KHR_platform_wayland)

BTW, at least on v42, the nvidia driver deployment is missing a symlink on gbm

ln -s /usr/lib/libnvidia-allocator.so /usr/lib/gbm/nvidia-drm_gbm.so

without it, gbm is not loaded and gamescope can't work.

@aderumier

Copy link
Copy Markdown
Contributor Author
BR2_PACKAGE_BATOCERA_WAYLAND && BR2_PACKAGE_BATOCERA_VULKAN` to possibly test higher-end arm boards too but that's up to Valve... SteamDeck 2? :-)

technically, they are already doing it in their new vr headset running on snapdragon.
But running windows x86 games through an arm emulator... ^_^

Note that they are plenty of usecase for gamescope outside handled devices

  • a lot of arcade cabinets with 4:3 screen can't run modern (windows based) arcade games,

  • some 4k tv with bad edid are doing shit with wine . wine is using xrandr api to switch monitor resolution && frequency to game native resolution, even if you have fixed it in ES videomode and for old games with 640x480 , 800x600 this is breaking display (blackscreen, not fully displayed games,...) of theses monitor.

@Redemp

Redemp commented Nov 29, 2025

Copy link
Copy Markdown
Contributor

@Redemp all the OS's you mentioned run Wayland by default and are forks of or provide an OS similar to SteamOS from which gamescope was designed for. I don't know how many times you wish me to say this but bringing in a bunch of dependencies for wayland will have a knock-on effect for other packages in the x86_64 build ecosystem. effectively building support for wayland into said packages also. this may have a negative impact and I will be the one who would need to tidy it up. I have no doubt this works in your testing but I have to think of the bigger picture and also support. Could we raise a support case for gamescope on xorg? these are the things i need to consider. since your driver identification is not added to this PR all I can say is that this would be an ideal approach before committing to x86_64. until such time we can bring this PR into zen3 which is more controlled & then expand from there.

the PR is still incomplete and should be marked as draft until things are tidied up.

but for now select BR2_PACKAGE_GAMESCOPE if BR2_PACKAGE_BATOCERA_TARGET_ZEN3

in future we can do select BR2_PACKAGE_GAMESCOPE if BR2_PACKAGE_BATOCERA_XWAYLAND && BR2_PACKAGE_BATOCERA_WAYLAND && BR2_PACKAGE_BATOCERA_VULKAN to possibly test higher-end arm boards too but that's up to Valve... SteamDeck 2? :-)

I did read what you wrote, and I completely understand the worry about older NVIDIA cards and not wanting to mislead those users.

My point is that this does not have to mean "no Gamescope at all" on the generic x86_64 image.

We already ship a lot of features that are not universally supported on every GPU or board:

  • Vulkan backends inside emulators
  • DXVK for Wine
  • Demanding Vulcan shader presets
  • Various threaded / async video options

On unsupported hardware if a user forces them anyway the renderer fails and they are simply dropped back to EmulationStation. Nothing is permanently broken, and users quickly learn "this option does not work on my card".

Gamescope on x86_64 behaves in the same way in practice:

  • On my R9 380X (amdgpu, Mesa) it runs fine as a nested compositor on Xorg.
  • If you try it on a GPU or driver that does not meet the requirements, Gamescope fails and ES comes back.

The problem you are describing ("wrong expectations for older NVIDIA") is a runtime capability problem, not a reason to exclude Gamescope from the generic image entirely.

To be clear, this is also why I do not think it makes sense to restrict Gamescope only to a future Wayland based, AMD handled build. That would be an unnecessarily narrow target for a feature that already works today on the generic x86_64 image:

  • It would exclude a lot of perfectly capable AMD and NVIDIA setups that can already run Gamescope on Xorg without issues.

I hope this does not come across the wrong way, but from my perspective it currently feels a bit like the "Little Red Hen" story: a lot of work has already gone into getting Gamescope working reliably on the generic x86_64 build, exactly so existing users on modern displays and CRT setups can benefit from it. Restricting it only to a future Wayland based AMD image would be like baking the bread, but then telling most of the people who helped grow the wheat that they cannot have a slice.

My only real ask is that we do not throw away a working, tested path for the generic image when a capability based approach can keep expectations sane for unsupported GPUs and still let all the hardware that already can run Gamescope actually use it.

@Tonhum

Tonhum commented Nov 30, 2025

Copy link
Copy Markdown

I'm very happy this is being worked on and hope it gets merged, having more control over adjusting resolutions is always good, especially for us with less than conventional displays.

@digitech2308

Copy link
Copy Markdown

Man im so excited about this, want to thank all the ones that are involved for the hard work, valious time and dedication. Me and my friends sometime play games that only works at fixed resolutions and this would be god send on all kinds of displays, i have a hd crt and this would be a option that i dont have anywhere else, heck im going to send a message to RetroRGB and MarcoRetro they both have YT channels related to gaming and im sure they would be very interested in the progress of gamescope.

@ZFEbHVUE

Copy link
Copy Markdown

I agree with the previous comments, because having an option to control resolutions is a significant advantage for Wine and other emulators.

Comment thread package/batocera/core/batocera-configgen/configgen/configgen/utils/gamescope.py Outdated
Comment thread package/batocera/core/batocera-configgen/configgen/configgen/utils/gamescope.py Outdated
Comment thread package/batocera/core/batocera-configgen/configgen/configgen/utils/gamescope.py Outdated
Comment thread package/batocera/core/batocera-configgen/configgen/configgen/utils/gamescope.py Outdated
Comment thread package/batocera/core/batocera-configgen/configgen/configgen/utils/gamescope.py Outdated
])

# Retrieve nested refresh rate.
# Default 60 if undefined

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we provide the default? If gamescope decides to change their default, our default will change unless we use one here.

@aderumier aderumier Nov 30, 2025

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For now, I would like really to keep "auto" = default from gamescope without forcing param, as after looking at the code, it's a little bit more complex :

int g_nNestedRefresh = 0;
g_nNestedRefresh = gamescope::ConvertHztomHz( parse_integer( optarg, "nested-refresh" ) );
g_nOutputRefresh = g_nNestedRefresh;
   if ( g_nOutputRefresh == 0 )
   	g_nOutputRefresh = ConvertHztomHz( 60 );  

nested refresh is initialized to 0 , not 60.

Output refresh inherit from nested refresh if nested refresh is defined, if not it's forced to 60hz . I'll update the comment for now.

@kl4ng3r

kl4ng3r commented Nov 30, 2025

Copy link
Copy Markdown

Want to add my +1 support for this initiative. Batocera would make a great OS for handheld systems. A lot o them use portrait native displays ... which means their image is rotated by 90 degrees by default and in driver you have to rotate the screen. This breaks compatibility with a lot of Wine games, both old and new. Also having the ability to lock in a particular refresh rate like 40 fps / hz would be another godsend for users of x86 handhelds, it would help save on battery life where a lot of these handhelds have only 1 supported refresh rate that you can vsync games to and thats 60 or 120 hz. This is overkill for a handheld. This feature would allow for the customizability to have the screen oriented at a desired resolution and frequency.

@manfredi90

Copy link
Copy Markdown

I'd like to add my +1 support for this initiative too. I'm especially interested in the potential implications using batocera with CRTs, but overall it would be a really significant development...

@tenyuhuang

Copy link
Copy Markdown

Definitely would want this for x86_64 devices in general instead of a confined set of hardware. Low-res LCDs and CRTs, which are ideal for low res content display, would benefit a lot from this without having to abide to hardware confinements (i.e. you should be able to use whatever modern hardware you want to).

@aderumier aderumier force-pushed the gamescope branch 2 times, most recently from 434fd80 to 87596ef Compare November 30, 2025 13:35
@aderumier

Copy link
Copy Markdown
Contributor Author

I have updated the PR.

  • merged commits
  • change Config.ini && .mk file like dmanlfc proposal
  • fix Bryan comments
  • added a detection of gamescope support through driver gbm EGL_KHR_platform_gbm support

@Redemp

Redemp commented Nov 30, 2025

Copy link
Copy Markdown
Contributor

I have updated the PR.

  • merged commits
  • change Config.ini && .mk file like dmanlfc proposal
  • fix Bryan comments
  • added a detection of gamescope support through driver gbm EGL_KHR_platform_gbm support

Thanks a lot for the update @aderumier this looks really good.

The new GBM / EGL_KHR_platform_gbm detection is exactly the kind of capability check we were talking about.

So this should directly address one of the main concerns that was raised about older unsupported NVIDIA cards, while still keeping the door open for the hardware that already runs Gamescope without issues.

@aderumier

Copy link
Copy Markdown
Contributor Author

The new GBM / EGL_KHR_platform_gbm detection is exactly the kind of capability check we were talking about.

could be great if somebody can test it, as I don't have old gpu without wayland support

@crcerror

Copy link
Copy Markdown
Contributor

I've a AMD Radeon HD 8280E - it should support wayland but it is very vey old .... ? So I'm eager to test yet

@dmanlfc

dmanlfc commented Nov 30, 2025

Copy link
Copy Markdown
Collaborator

It needs to be a card that doesn't support Wayland or Vulkan. These are the checks you need. There is also probably a minimum Vulkan version. We already have a script for Vulkan that is used in configgen for emulators that Bryan standardised.

@aderumier

Copy link
Copy Markdown
Contributor Author

AMD Radeon HD 8280E

They are a not in gamescope github about old card using radeonsi

"
If running RadeonSI clients with older cards (GFX8 and below), currently have to set R600_DEBUG=nodcc, or corruption will be observed until the stack picks up DRM modifiers support.
"

but it should work. (Thanks amd && kernel devs to still support older cards).

With nvidia, i'll be more difficult, as It'll really need 515.43.04+ nvidia driver, as nvidia never wanted to implemented gbm before

So these nvndia cards should work:
https://download.nvidia.com/XFree86/Linux-x86_64/515.43.04/README/supportedchips.html

@skysix2

skysix2 commented Dec 4, 2025

Copy link
Copy Markdown

Want to add my +1 support for this initiative, Other emulators that would benefit from Gamescope are Mugen (obviously Wine) and Ikemen, there are often games that offer resolutions/aspect ratios that do not match well with modern monitors.

@msrecko

msrecko commented Dec 5, 2025

Copy link
Copy Markdown

Great work, everyone — truly impressive progress.
I want to express my full support for this initiative. Features like this can significantly improve the overall experience, and I’m very glad to see it moving forward.

I also hope that the advancements around Gamescope integration may eventually help us get closer to a proper solution for Wine bezels as well. That would be a huge milestone for many of us who rely on Wine systems inside Batocera.

Once again, hats off to the whole team for the dedication and continuous improvements. Keep up the amazing work!

@Tovarichtch

Copy link
Copy Markdown
Collaborator

More comments from unknown users won't help merge the PR. Commits will.

Please fix what's required to be done, thanks.

@aderumier

Copy link
Copy Markdown
Contributor Author

More comments from unknown users won't help merge the PR. Commits will.

Please fix what's required to be done, thanks.

So far, Bryan comments about generator have been addressed or commented, && dmanlfc packaging .mk && Config.in have been implemented.

So , please make code comments if something else need to be fixed.

I think the main concern of users is that they would like to be able use use it over Xorg too and not on wayland (so only on zen3 images).

I think, what is could be great, is to be able to enable gamescope options menu in ES, based on presence of gamescope binary && driver support (gbm driver support function is already implemented)
Like this, if you don't want support images with gamescope on xorg, people could still easily manually add the binaries and the 3~4 lib from the zen3 image.

Not sure if they are some options is ES to call a script to hide/show a submenu based on a script ? (I known it's already possible to display dynamic values)

@dmanlfc

dmanlfc commented Dec 5, 2025

Copy link
Copy Markdown
Collaborator

@aderumier you haven't selected gamescope in any package or batocera-system Config.in, you haven't added it to the utils in Config.in.
therefore this won't be added to any image in the current state.
i did ask you multiple times to mark it as draft until you finished, this hasn't happened either. so I have no idea whether you think it's ready or not. as it stands for me currently it's not ready.
because of these basics I therefore know you haven't built a x86_64 cleanbuild image from scratch to determine the effects of bringing in the dependencies of gamescope to the x86_64 image and it's possible effects on emulators.

so if you want this added quickly, fix the basics outlined above with the selection for the zen3 image currently and then we can look at x86_64 after.
if you want to add x86_64 support within this single PR then you need to handle legacy x86_64 drivers without gbm & vulkan support. i don't see this code yet (again mark it draft).

welcome to the wider ecosystem :-)

i'm also not sure on the es_features.yml changes but that's more of a design discussion the bato dev team need to have.

@dmanlfc

dmanlfc commented Dec 6, 2025

Copy link
Copy Markdown
Collaborator

fyi - #14914

@aderumier aderumier marked this pull request as draft December 6, 2025 12:49
@aderumier

aderumier commented Dec 6, 2025

Copy link
Copy Markdown
Contributor Author

@aderumier you haven't selected gamescope in any package or batocera-system Config.in, you haven't added it to the utils in Config.in. therefore this won't be added to any image in the current state.

yes, I known, I wanted to have more review before enabled it in

i did ask you multiple times to mark it as draft until you finished, this hasn't happened either. so I have no idea whether >>you think it's ready or not. as it stands for me currently it's not ready. because of these basics I therefore know you >>haven't built a x86_64 cleanbuild image from scratch to determine the effects of bringing in the dependencies of >>gamescope to the x86_64 image and it's possible effects on emulators.

I don't known enough buildroot, if isn't it possible to build only gamescope with wayland dependencies , and other package without wayland ? (as It seem to using BR2_PACKAGE_WAYLAND for gamescope, will impact other package guild ?)
wlroots itself is static linked, so they are no conflict possible. The are only libwaylab-client/server.so.

I'll add zen3 for now, and look to do more their to build on generic x86. (I'm really not familiar with buildroot)

so if you want this added quickly, fix the basics outlined above with the selection for the zen3 image currently and then we can look at x86_64 after. if you want to add x86_64 support within this single PR then you nee

to handle legacy x86_64 drivers without gbm & vulkan support. i don't see this code yet (again mark it draft).

(draft done)

the gbm detection is already in the code (in gamescope.py), throwning an error when game is launching if gbm support is not available. (but it could be even better if we could hide or greyout the gamescope menu if support is not available)

gamescope is using specific versions of wlroots,libliftoff,vkroots.
They are statically linked in the gamescope binary

when enabled, gamescope is prefixing the emulator commandline.

ex: gamescope -W 3840 -H 2160 -f -- /usr/bin/retroarch ....

default gamescope output resolution is set to current monitor resolution
@aderumier

Copy link
Copy Markdown
Contributor Author

@dmanlfc I have include gamescope in batocera/system/Config.ini

select BR2_PACKAGE_GAMESCOPE if BR2_PACKAGE_BATOCERA_TARGET_ZEN3

and fixed gamescope in es_features

    gamescope:
      archs_include: [x86-64-v3]

btw, BR2_PACKAGE_BATOCERA_TARGET_ZEN3 is confusing, as it's seem to enable x86-64-v3, but x86-64-v3 existing since haswell in 2013, so it's really not related to zen3.

It could be great for some emus to have avx support, I don't known what is the plan is to only use "zen3" image for console like steamdeck or make is more generic pc image, but for "modern" cpus with x86-64-v3 support ?

@dmanlfc

dmanlfc commented Dec 7, 2025

Copy link
Copy Markdown
Collaborator

@dmanlfc I have include gamescope in batocera/system/Config.ini

select BR2_PACKAGE_GAMESCOPE if BR2_PACKAGE_BATOCERA_TARGET_ZEN3

and fixed gamescope in es_features

    gamescope:
      archs_include: [x86-64-v3]

btw, BR2_PACKAGE_BATOCERA_TARGET_ZEN3 is confusing, as it's seem to enable x86-64-v3, but x86-64-v3 existing since haswell in 2013, so it's really not related to zen3.

It could be great for some emus to have avx support, I don't known what is the plan is to only use "zen3" image for console like steamdeck or make is more generic pc image, but for "modern" cpus with x86-64-v3 support ?

It's just a name convention Buildroot uses. The Zen3 image is aimed at x86 handhelds and has more cpu extensions than the standard x86_64 build providing compatibility to more hardware. For this image, Wayland is a first class citizen that's why we'll bring it in here first.

@dmanlfc

dmanlfc commented Dec 7, 2025

Copy link
Copy Markdown
Collaborator

@aderumier you haven't selected gamescope in any package or batocera-system Config.in, you haven't added it to the utils in Config.in. therefore this won't be added to any image in the current state.

yes, I known, I wanted to have more review before enabled it in

i did ask you multiple times to mark it as draft until you finished, this hasn't happened either. so I have no idea whether >>you think it's ready or not. as it stands for me currently it's not ready. because of these basics I therefore know you >>haven't built a x86_64 cleanbuild image from scratch to determine the effects of bringing in the dependencies of >>gamescope to the x86_64 image and it's possible effects on emulators.

I don't known enough buildroot, if isn't it possible to build only gamescope with wayland dependencies , and other package without wayland ? (as It seem to using BR2_PACKAGE_WAYLAND for gamescope, will impact other package guild ?) wlroots itself is static linked, so they are no conflict possible. The are only libwaylab-client/server.so.

No it's not possible. Many other packages will pick-up in the build that wayland is part of the ecosystem and enable wayland features in the package.

I'll add zen3 for now, and look to do more their to build on generic x86. (I'm really not familiar with buildroot)

so if you want this added quickly, fix the basics outlined above with the selection for the zen3 image currently and then we can look at x86_64 after. if you want to add x86_64 support within this single PR then you nee

to handle legacy x86_64 drivers without gbm & vulkan support. i don't see this code yet (again mark it draft).

(draft done)

the gbm detection is already in the code (in gamescope.py), throwning an error when game is launching if gbm support is not available. (but it could be even better if we could hide or greyout the gamescope menu if support is not available)

Yes this is what I want

@crcerror

crcerror commented Dec 7, 2025

Copy link
Copy Markdown
Contributor

@aderumier Can you post result if you setup WinLems 1.42 with gamescope?
Download is here: https://winlems.en.uptodown.com/windows
Source: https://github.com/warrengalyen/WinLems (for legal reasons)

you need 2 files in WinLems dir

  1. msvbvm50.dll (http://www.dll-found.com/msvbvm50.dll_download.html)
  2. comctl32.ocx (http://www.dll-found.com/comctl32.ocx_download.html)

Then extract place the 2 files to WinLems.pc-root-dir and setup autorun.cmd

ENV=WINEDLLOVERRIDES="msvbvm50,comctl32.ocx=n"
CMD="WinLems.exe"
DIR=.

The game has no fullscreen-mode, just windowed - gamescope should push it to fullscreen ;)

@aderumier

Copy link
Copy Markdown
Contributor Author

No it's not possible. Many other packages will pick-up in the build that wayland is part of the ecosystem and enable >>wayland features in the package.

Ah ok, thanks. I understand now.

so , I'll try to see the behaviour of other package with wayland enabled. I don't think it should hurt for emu, as it's not black|white , it should just add wayland lib support to the emu, not forcing it with breaking xorg support.
But everything need to be needed indeed.

@dmanlfc

dmanlfc commented Jan 14, 2026

Copy link
Copy Markdown
Collaborator

@aderumier what's the status?

@aderumier

aderumier commented Jan 22, 2026

Copy link
Copy Markdown
Contributor Author

@aderumier what's the status?

I didn't have time to work on yet (super busy at work). I'll try to test next week. (I need to prepare a big vm for building the whole image,as it's pretty long).

I want to test it on wayland image first, to see if they are no conflict with sway .(I have seen some report where it need special command line option).

I could also be possible to run as main compositor instead sway (like on the steamos), but I don't known if it's handling fine multi monitors && other things.

I have prepared amd && nvidia hardware to test, now I just need time

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.