Skip to content

Commit 9d56e48

Browse files
committed
initial multidisplay work
- add multidisplay plugin stub - make compositor multiview capable - use klib (khash) to implement the view id -> window mapping - split drmdev into drm_resources and drmdev - drmdev: (mostly) non-stateful part. Basically a better wrapper around a drm fd. mt-safe - drm_resources: the DRM state / resources. is stateful, but does not update itself. To keep it in sync with kernel state, one needs to listen to kernel events with drm_monitor and call drm_resources_update. - drm_resources is not mt-safe and only supposed to be used on a single thread. - add a bunch of QoL stuff to drm_resources - 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
1 parent 9deaf96 commit 9d56e48

31 files changed

+6394
-4460
lines changed

CMakeLists.txt

Lines changed: 14 additions & 72 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)
@@ -127,8 +128,12 @@ add_library(
127128
src/platformchannel.c
128129
src/pluginregistry.c
129130
src/texture_registry.c
130-
src/modesetting.c
131-
src/util/collection.c
131+
src/kms/drmdev.c
132+
src/kms/req_builder.c
133+
src/kms/resources.c
134+
src/kms/monitor.c
135+
src/util/event_loop.c
136+
src/util/lock_ops.c
132137
src/util/bitscan.c
133138
src/util/vector.c
134139
src/cursor.c
@@ -425,6 +430,7 @@ if (ENABLE_TSAN)
425430
target_link_options(flutterpi_module PUBLIC -fsanitize=thread)
426431
target_compile_options(flutterpi_module PUBLIC -fsanitize=thread)
427432
endif()
433+
428434
if (ENABLE_ASAN)
429435
# when we use asan, we need to force linking against the C++ stdlib.
430436
# If we don't link against it, and load a dynamic library that's linked against the C++ stdlib (like the flutter engine),
@@ -435,8 +441,9 @@ if (ENABLE_ASAN)
435441
target_link_options(flutterpi_module PUBLIC -fsanitize=address -fno-omit-frame-pointer -Wl,--no-as-needed)
436442
target_compile_options(flutterpi_module PUBLIC -fsanitize=address)
437443

438-
check_c_compiler_flag(-static-libasan HAVE_STATIC_LIBASAN)
439-
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)
440447
target_link_options(flutterpi_module PUBLIC -static-libasan)
441448
endif()
442449
endif()
@@ -464,84 +471,19 @@ install(TARGETS flutter-pi RUNTIME DESTINATION bin)
464471

465472
# Enable lto if supported.
466473
cmake_policy(SET CMP0069 NEW)
467-
include(CheckIPOSupported)
468474
# include(CheckLinkerFlag)
469475

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

533483
message(STATUS "IPO/LTO ................ ${USE_LTO}")
534484
if (USE_LTO)
535485
set_property(TARGET flutterpi_module PROPERTY INTERPROCEDURAL_OPTIMIZATION TRUE)
536486
set_property(TARGET flutter-pi PROPERTY INTERPROCEDURAL_OPTIMIZATION TRUE)
537-
# if (NEEDS_GOLD)
538-
# Technically specifying only for one would suffice.
539-
# target_link_options(flutterpi_module PUBLIC "-fuse-ld=gold")
540-
# target_link_options(flutter-pi PUBLIC "-fuse-ld=gold")
541-
# elseif (NEEDS_LLD)
542-
# target_link_options(flutterpi_module PUBLIC "-fuse-ld=lld")
543-
# target_link_options(flutter-pi PUBLIC "-fuse-ld=lld")
544-
# endif()
545487
endif()
546488

547489
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)