ValveSoftware / gamescope

SteamOS session compositing window manager
Other
2.82k stars 186 forks source link

Unable to build with `drm_backend` or `sdl2_backend` disabled #1347

Open HanabishiRecca opened 1 month ago

HanabishiRecca commented 1 month ago

drm_backend and sdl2_backend meson options are effectively useless right now as you can't disable them.

When trying to build with drm_backend=disabled:

[398/424] Compiling C++ object src/gamescope.p/edid.cpp.o
FAILED: src/gamescope.p/edid.cpp.o 
c++ ...
In file included from ../gamescope/src/edid.cpp:5:
../gamescope/src/hdmi.h:28:9: error: ‘__u8’ does not name a type
   28 |         __u8 eotf;
      |         ^~~~
../gamescope/src/hdmi.h:32:9: error: ‘__u8’ does not name a type
   32 |         __u8 metadata_type;
      |         ^~~~
[405/424] Compiling C++ object src/gamescope.p/wlserver.cpp.o
FAILED: src/gamescope.p/wlserver.cpp.o 
c++ ...
In file included from ../gamescope/src/wlserver.cpp:51:
../gamescope/src/hdmi.h:23:8: error: redefinition of ‘struct hdr_metadata_infoframe’
   23 | struct hdr_metadata_infoframe {
      |        ^~~~~~~~~~~~~~~~~~~~~~
In file included from /usr/include/libdrm/drm.h:1025,
                 from /usr/include/xf86drm.h:40,
                 from ../gamescope/src/wlserver.cpp:11:
/usr/include/libdrm/drm_mode.h:869:8: note: previous definition of ‘struct hdr_metadata_infoframe’
  869 | struct hdr_metadata_infoframe {
      |        ^~~~~~~~~~~~~~~~~~~~~~
../gamescope/src/hdmi.h:87:8: error: redefinition of ‘struct hdr_output_metadata’
   87 | struct hdr_output_metadata {
      |        ^~~~~~~~~~~~~~~~~~~
/usr/include/libdrm/drm_mode.h:933:8: note: previous definition of ‘struct hdr_output_metadata’
  933 | struct hdr_output_metadata {
      |        ^~~~~~~~~~~~~~~~~~~
[408/424] Compiling C++ object src/gamescope.p/rendervulkan.cpp.o
FAILED: src/gamescope.p/rendervulkan.cpp.o 
c++ ...
In file included from ../gamescope/src/rendervulkan.cpp:26:
../gamescope/src/hdmi.h:23:8: error: redefinition of ‘struct hdr_metadata_infoframe’
   23 | struct hdr_metadata_infoframe {
      |        ^~~~~~~~~~~~~~~~~~~~~~
In file included from /usr/include/libdrm/drm.h:1025,
                 from /usr/include/libdrm/drm_fourcc.h:27,
                 from ../gamescope/src/rendervulkan.cpp:25:
/usr/include/libdrm/drm_mode.h:869:8: note: previous definition of ‘struct hdr_metadata_infoframe’
  869 | struct hdr_metadata_infoframe {
      |        ^~~~~~~~~~~~~~~~~~~~~~
../gamescope/src/hdmi.h:87:8: error: redefinition of ‘struct hdr_output_metadata’
   87 | struct hdr_output_metadata {
      |        ^~~~~~~~~~~~~~~~~~~
/usr/include/libdrm/drm_mode.h:933:8: note: previous definition of ‘struct hdr_output_metadata’
  933 | struct hdr_output_metadata {
      |        ^~~~~~~~~~~~~~~~~~~
[410/424] Compiling C++ object src/gamescope.p/wayland_backend.cpp.o
FAILED: src/gamescope.p/wayland_backend.cpp.o 
c++ ...
In file included from ../gamescope/src/drm_include.h:13,
                 from ../gamescope/src/wayland_backend.cpp:35:
../gamescope/src/hdmi.h:23:8: error: redefinition of ‘struct hdr_metadata_infoframe’
   23 | struct hdr_metadata_infoframe {
      |        ^~~~~~~~~~~~~~~~~~~~~~
In file included from /usr/include/libdrm/drm.h:1025,
                 from /usr/include/libdrm/drm_fourcc.h:27,
                 from ../gamescope/src/rendervulkan.hpp:75,
                 from ../gamescope/src/wayland_backend.cpp:2:
/usr/include/libdrm/drm_mode.h:869:8: note: previous definition of ‘struct hdr_metadata_infoframe’
  869 | struct hdr_metadata_infoframe {
      |        ^~~~~~~~~~~~~~~~~~~~~~
../gamescope/src/hdmi.h:87:8: error: redefinition of ‘struct hdr_output_metadata’
   87 | struct hdr_output_metadata {
      |        ^~~~~~~~~~~~~~~~~~~
/usr/include/libdrm/drm_mode.h:933:8: note: previous definition of ‘struct hdr_output_metadata’
  933 | struct hdr_output_metadata {
      |        ^~~~~~~~~~~~~~~~~~~
[412/424] Compiling C++ object src/gamescope.p/steamcompmgr.cpp.o
FAILED: src/gamescope.p/steamcompmgr.cpp.o 
c++ ...
In file included from ../gamescope/src/steamcompmgr.cpp:90:
../gamescope/src/hdmi.h:23:8: error: redefinition of ‘struct hdr_metadata_infoframe’
   23 | struct hdr_metadata_infoframe {
      |        ^~~~~~~~~~~~~~~~~~~~~~
In file included from /usr/include/libdrm/drm.h:1025,
                 from /usr/include/libdrm/drm_fourcc.h:27,
                 from ../gamescope/src/rendervulkan.hpp:75,
                 from ../gamescope/src/steamcompmgr.cpp:82:
/usr/include/libdrm/drm_mode.h:869:8: note: previous definition of ‘struct hdr_metadata_infoframe’
  869 | struct hdr_metadata_infoframe {
      |        ^~~~~~~~~~~~~~~~~~~~~~
../gamescope/src/hdmi.h:87:8: error: redefinition of ‘struct hdr_output_metadata’
   87 | struct hdr_output_metadata {
      |        ^~~~~~~~~~~~~~~~~~~
/usr/include/libdrm/drm_mode.h:933:8: note: previous definition of ‘struct hdr_output_metadata’
  933 | struct hdr_output_metadata {
      |        ^~~~~~~~~~~~~~~~~~~

When trying to build with sdl2_backend=disabled:

[462/462] Linking target src/gamescope
FAILED: src/gamescope 
c++  ...
/usr/sbin/ld: /tmp/ccxk8uA1.ltrans4.ltrans.o: in function `main':
<artificial>:(.text.startup+0x1e34): undefined reference to `bool gamescope::IBackend::Set<gamescope::CSDLBackend>()'
/usr/sbin/ld: /tmp/ccxk8uA1.ltrans7.ltrans.o: in function `gamescope::CWaylandBackend::PostInit()':
<artificial>:(.text+0x306f): undefined reference to `gamescope::GetX11HostCursor()'
collect2: error: ld returned 1 exit status
HanabishiRecca commented 1 month ago

I tackled the code and looks like it is pretty much impossible to disable libdrm as Wayland backend really depends on it. So it is easier to just drop drm_backend option at this point. I.e. partially revert 67984a89c5092c4164baef3c1d27fb5d5f1e9fb3 and make it a hard dependency again.


As for sdl2_backend, seems easy to fix:

diff --git a/src/main.cpp b/src/main.cpp
index 01dd8ca..3aa0ffc 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -834,8 +834,10 @@ int main(int argc, char **argv)

        case gamescope::GamescopeBackend::Wayland:
            gamescope::IBackend::Set<gamescope::CWaylandBackend>();
+#if HAVE_SDL2
            if ( !GetBackend() )
                gamescope::IBackend::Set<gamescope::CSDLBackend>();
+#endif
            break;
        default:
            abort();
diff --git a/src/wayland_backend.cpp b/src/wayland_backend.cpp
index c5b33cf..745cb35 100644
--- a/src/wayland_backend.cpp
+++ b/src/wayland_backend.cpp
@@ -1247,8 +1247,10 @@ namespace gamescope
             return false;
         }

+#if HAVE_SDL2
         m_pDefaultCursorInfo = GetX11HostCursor();
         m_pDefaultCursorSurface = CursorInfoToSurface( m_pDefaultCursorInfo );
+#endif

         if ( g_bForceRelativeMouse )
             this->SetRelativeMouseMode( true );
Joshua-Ashton commented 1 month ago

There's another backend for platforms not using libdrm that I haven't pushed up yet.

I think GetX11HostCursor should be moved into its own file, then that can be a proper fix for upstream

HanabishiRecca commented 1 month ago

This seems to work. I'm not a C++ guy though, so I maybe did it wrong.

Edit: actually its easier to review it as a PR: #1350.

HanabishiRecca commented 1 month ago

And another bit of improvement: #1351