Skip to content

Commit 59f879a

Browse files
committed
initial multidisplay work
- add multidisplay plugin stub - make compositor multiview capable - use klib (khash) to implement the view id -> window mapping - use evloop as platform and raster thread event loop (mt-safe wrapper around sd-event) - add own mutex type & fns with thread safety annotations - generally refactor flutter-pi.c and drmdev - fix function mixup in sentry plugin - kms: add drm device monitor
1 parent 26686d6 commit 59f879a

30 files changed

+1892
-1095
lines changed

CMakeLists.txt

Lines changed: 11 additions & 71 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ option(ENABLE_MTRACE "True if flutter-pi should call GNU mtrace() on startup." O
5555
option(ENABLE_TESTS "True if tests should be built. Requires Unity to be checked out at third_party/Unity." OFF)
5656
option(ENABLE_SESSION_SWITCHING "True if flutter-pi should be built with session switching support. Requires libseat-dev to be installed." ON)
5757
option(TRY_ENABLE_SESSION_SWITCHING "Don't throw an error if libseat isn't found, instead just build without session switching support in that case." ON)
58-
option(LTO "Check for IPO/LTO support and enable, if supported. May require gold/lld when building with clang. (Either using `-fuse-ld` in CMAKE_C_FLAGS or by setting as the default system linker.) Only applies to Release or RelWithDebInfo build types." ON)
58+
option(LTO "Enable LTO. Does not work with all toolchains. May require gold/lld when building with clang. (Either using `-fuse-ld` in CMAKE_C_FLAGS or by setting as the default system linker.) Only applies to Release or RelWithDebInfo build types." OFF)
5959
option(LINT_EGL_HEADERS "Set an define that'll make the egl.h only export the extension definitions, prototypes that are explicitly marked as required." OFF)
6060
option(DEBUG_DRM_PLANE_ALLOCATIONS "Add logging in modesetting.c for debugging the process of choosing a fitting DRM plane for a framebuffer layer." OFF)
6161
option(USE_LEGACY_KMS "Force the use of legacy KMS." OFF)
@@ -80,7 +80,7 @@ endif()
8080
if (BUILD_SENTRY_PLUGIN)
8181
set(flutterpi_languages C CXX ASM)
8282
else()
83-
set(flutterpi_languages C ASM)
83+
set(flutterpi_languages C)
8484
endif()
8585

8686
project(flutter-pi LANGUAGES ${flutterpi_languages} VERSION "1.0.0")
@@ -89,6 +89,7 @@ message(STATUS "Generator .............. ${CMAKE_GENERATOR}")
8989
message(STATUS "Build Type ............. ${CMAKE_BUILD_TYPE}")
9090

9191
include(CheckCCompilerFlag)
92+
include(CheckCXXCompilerFlag)
9293

9394
# Those libraries we definitely need.
9495
include(FindPkgConfig)
@@ -130,9 +131,11 @@ add_library(
130131
src/kms/drmdev.c
131132
src/kms/req_builder.c
132133
src/kms/resources.c
134+
src/kms/monitor.c
135+
src/util/event_loop.c
136+
src/util/lock_ops.c
133137
src/util/bitscan.c
134138
src/util/vector.c
135-
src/util/collection.c
136139
src/cursor.c
137140
src/keyboard.c
138141
src/user_input.c
@@ -427,6 +430,7 @@ if (ENABLE_TSAN)
427430
target_link_options(flutterpi_module PUBLIC -fsanitize=thread)
428431
target_compile_options(flutterpi_module PUBLIC -fsanitize=thread)
429432
endif()
433+
430434
if (ENABLE_ASAN)
431435
# when we use asan, we need to force linking against the C++ stdlib.
432436
# If we don't link against it, and load a dynamic library that's linked against the C++ stdlib (like the flutter engine),
@@ -437,8 +441,9 @@ if (ENABLE_ASAN)
437441
target_link_options(flutterpi_module PUBLIC -fsanitize=address -fno-omit-frame-pointer -Wl,--no-as-needed)
438442
target_compile_options(flutterpi_module PUBLIC -fsanitize=address)
439443

440-
check_c_compiler_flag(-static-libasan HAVE_STATIC_LIBASAN)
441-
if (HAVE_STATIC_LIBASAN)
444+
check_c_compiler_flag(-static-libasan HAVE_C_STATIC_LIBASAN)
445+
check_cxx_compiler_flag(-static-libasan HAVE_CXX_STATIC_LIBASAN)
446+
if (HAVE_C_STATIC_LIBASAN AND HAVE_CXX_STATIC_LIBASAN)
442447
target_link_options(flutterpi_module PUBLIC -static-libasan)
443448
endif()
444449
endif()
@@ -466,84 +471,19 @@ install(TARGETS flutter-pi RUNTIME DESTINATION bin)
466471

467472
# Enable lto if supported.
468473
cmake_policy(SET CMP0069 NEW)
469-
include(CheckIPOSupported)
470474
# include(CheckLinkerFlag)
471475

472476
set(USE_LTO OFF)
473477
# set(NEEDS_GOLD OFF)
474478
# set(NEEDS_LLD OFF)
475479
if(LTO AND (CMAKE_BUILD_TYPE STREQUAL Release OR CMAKE_BUILD_TYPE STREQUAL RelWithDebInfo))
476-
# So people can specify `-fuse-ld=lld` in the CMAKE_C_FLAGS.
477-
# Otherwise check_ipo_supported will not use CMAKE_C_FLAGS.
478-
if (POLICY CMP0138)
479-
cmake_policy(SET CMP0138 NEW)
480-
endif()
481-
482-
check_ipo_supported(RESULT IPO_SUPPORTED OUTPUT IPO_SUPPORT_OUTPUT)
483-
if (NOT IPO_SUPPORTED)
484-
message(WARNING "IPO/LTO was requested in the configure options, but is not supported by the toolchain. Check CMakeFiles/CMakeError.log for details.")
485-
endif()
486-
487-
# Try to enable IPO with gold and lld.
488-
# Needs CMP0138.
489-
# (untested because CMP0138 required CMake 3.24, that's why it's commented out)
490-
# if (NOT IPO_SUPPORTED)
491-
# check_linker_flag(C "-fuse-ld=gold" SUPPORTS_GOLD)
492-
# if (SUPPORTS_GOLD)
493-
# set(OLD_CMAKE_C_FLAGS "${CMAKE_C_FLAGS}")
494-
#
495-
# set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fuse-ld=gold")
496-
# try_compile()
497-
# check_ipo_supported(RESULT IPO_SUPPORTED_WITH_GOLD OUTPUT IPO_SUPPORT_OUTPUT)
498-
# if (IPO_SUPPORTED_WITH_GOLD)
499-
# set(IPO_SUPPORTED ON)
500-
# set(NEEDS_GOLD ON)
501-
# endif()
502-
#
503-
# set(CMAKE_C_FLAGS "${OLD_CMAKE_C_FLAGS}")
504-
# endif()
505-
#
506-
# check_linker_flag(C "-fuse-ld=lld" SUPPORTS_LLD)
507-
# if (SUPPORTS_LLD)
508-
# set(OLD_CMAKE_C_FLAGS "${CMAKE_C_FLAGS}")
509-
#
510-
# set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fuse-ld=lld")
511-
# check_ipo_supported(RESULT IPO_SUPPORTED_WITH_LLD OUTPUT IPO_SUPPORT_OUTPUT)
512-
# if (IPO_SUPPORTED_WITH_LLD)
513-
# set(IPO_SUPPORTED ON)
514-
# set(NEEDS_LLD ON)
515-
# endif()
516-
#
517-
# set(CMAKE_C_FLAGS "${OLD_CMAKE_C_FLAGS}")
518-
# endif()
519-
# endif()
520-
521-
# clang doesn't support LTO when using GNU ld.
522-
if(IPO_SUPPORTED AND ("${CMAKE_C_COMPILER_ID}" STREQUAL "Clang"))
523-
execute_process(COMMAND ${CMAKE_C_COMPILER} -Wl,--version OUTPUT_VARIABLE LINKER_VERSION_OUTPUT ERROR_QUIET)
524-
if("${LINKER_VERSION_OUTPUT}" MATCHES "GNU ld")
525-
message(WARNING "IPO/LTO was requested, but is not supported when using clang with GNU ld as the linker. Try setting gold or lld as the system linker.")
526-
set(IPO_SUPPORTED OFF)
527-
endif()
528-
endif()
529-
530-
if (IPO_SUPPORTED)
531-
set(USE_LTO ON)
532-
endif()
480+
set(USE_LTO ON)
533481
endif()
534482

535483
message(STATUS "IPO/LTO ................ ${USE_LTO}")
536484
if (USE_LTO)
537485
set_property(TARGET flutterpi_module PROPERTY INTERPROCEDURAL_OPTIMIZATION TRUE)
538486
set_property(TARGET flutter-pi PROPERTY INTERPROCEDURAL_OPTIMIZATION TRUE)
539-
# if (NEEDS_GOLD)
540-
# Technically specifying only for one would suffice.
541-
# target_link_options(flutterpi_module PUBLIC "-fuse-ld=gold")
542-
# target_link_options(flutter-pi PUBLIC "-fuse-ld=gold")
543-
# elseif (NEEDS_LLD)
544-
# target_link_options(flutterpi_module PUBLIC "-fuse-ld=lld")
545-
# target_link_options(flutter-pi PUBLIC "-fuse-ld=lld")
546-
# endif()
547487
endif()
548488

549489
if(ENABLE_TESTS)

CMakePresets.json

Lines changed: 36 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22
"version": 2,
33
"configurePresets": [
44
{
5-
"name": "default",
6-
"displayName": "Default OpenGL host build",
5+
"name": "default-debug",
6+
"displayName": "Default OpenGL host build (Debug)",
77
"description": "Sets Ninja generator, build and install directory",
88
"generator": "Ninja",
99
"binaryDir": "${sourceDir}/out/build/${presetName}",
@@ -20,7 +20,40 @@
2020
"BUILD_GSTREAMER_AUDIO_PLAYER_PLUGIN": true,
2121
"TRY_BUILD_GSTREAMER_AUDIO_PLAYER_PLUGIN": false,
2222
"BUILD_SENTRY_PLUGIN": true,
23-
"ENABLE_TESTS": true
23+
"ENABLE_TESTS": true,
24+
"ENABLE_ASAN": true
25+
}
26+
},
27+
{
28+
"name": "default-relwithdebinfo",
29+
"displayName": "Default OpenGL host build (Release with Debug Info)",
30+
"description": "Sets Ninja generator, build and install directory",
31+
"generator": "Ninja",
32+
"binaryDir": "${sourceDir}/out/build/${presetName}",
33+
"cacheVariables": {
34+
"CMAKE_BUILD_TYPE": "RelWithDebInfo",
35+
"CMAKE_INSTALL_PREFIX": "${sourceDir}/out/install/${presetName}",
36+
"ENABLE_OPENGL": true,
37+
"BUILD_GSTREAMER_AUDIO_PLAYER_PLUGIN": true,
38+
"BUILD_SENTRY_PLUGIN": true,
39+
"ENABLE_TESTS": false,
40+
"ENABLE_ASAN": false
41+
}
42+
},
43+
{
44+
"name": "default-release",
45+
"displayName": "Default OpenGL host build (Release)",
46+
"description": "Sets Ninja generator, build and install directory",
47+
"generator": "Ninja",
48+
"binaryDir": "${sourceDir}/out/build/${presetName}",
49+
"cacheVariables": {
50+
"CMAKE_BUILD_TYPE": "Release",
51+
"CMAKE_INSTALL_PREFIX": "${sourceDir}/out/install/${presetName}",
52+
"ENABLE_OPENGL": true,
53+
"BUILD_GSTREAMER_AUDIO_PLAYER_PLUGIN": true,
54+
"BUILD_SENTRY_PLUGIN": true,
55+
"ENABLE_TESTS": false,
56+
"ENABLE_ASAN": false
2457
}
2558
},
2659
{

0 commit comments

Comments
 (0)