From 488101bf891623780e2f4d0eaacadc6d02e268f9 Mon Sep 17 00:00:00 2001 From: Nolan Scobie Date: Mon, 20 May 2024 13:32:13 -0400 Subject: [RenderEngine] Only compile Graphite if either Graphite flag is enabled RE-Graphite will be *compiled* if either the graphite_renderengine or force_compile_graphite_renderengine ready-only flag is enabled at compile time (inclusive OR). RE-Graphite can be compiled and *enabled* by: 1. setting just graphite_renderengine=true, or 2. setting both force_compile_graphite_renderengine=true and the debug.renderengine.graphite system property to true. Why RenderEngine needs a dep on libsurfaceflingerflags now: libsurfaceflinger_common pulls in SF's FlagManager, which is layered on top of the API that's autogenerated for SF's aconfig module, libsurfaceflingerflags. The COM_ANDROID_GRAPHICS_SURFACEFLINGER_FLAGS(...) macro is defined by com_android_graphics_surfaceflinger_flags.h in that latter aconfig module, and that header is not exported by the higher-level FlagManager code. Bug: b/293371537 Bug: b/331678326 Bug: b/341728634 Test: boot and bloaty (see b/331678326) Flag: com.android.graphics.surfaceflinger.flags.graphite_renderengine Change-Id: I9d0b15bda08430552716a9a1f7cd59d91ee7b9a6 --- services/surfaceflinger/SurfaceFlinger.cpp | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'services/surfaceflinger/SurfaceFlinger.cpp') diff --git a/services/surfaceflinger/SurfaceFlinger.cpp b/services/surfaceflinger/SurfaceFlinger.cpp index 5f81cd45cc..be0c1548d7 100644 --- a/services/surfaceflinger/SurfaceFlinger.cpp +++ b/services/surfaceflinger/SurfaceFlinger.cpp @@ -40,6 +40,7 @@ #include #include #include +#include #include #include #include @@ -813,8 +814,24 @@ void chooseRenderEngineType(renderengine::RenderEngineCreationArgs::Builder& bui .setGraphicsApi(renderengine::RenderEngine::GraphicsApi::VK); } else { const auto kVulkan = renderengine::RenderEngine::GraphicsApi::VK; +// TODO: b/341728634 - Clean up conditional compilation. +// Note: this guard in particular must check e.g. +// COM_ANDROID_GRAPHICS_SURFACEFLINGER_FLAGS_GRAPHITE_RENDERENGINE directly (instead of calling e.g. +// COM_ANDROID_GRAPHICS_SURFACEFLINGER_FLAGS(GRAPHITE_RENDERENGINE)) because that macro is undefined +// in the libsurfaceflingerflags_test variant of com_android_graphics_surfaceflinger_flags.h, which +// is used by layertracegenerator (which also needs SurfaceFlinger.cpp). :) +#if COM_ANDROID_GRAPHICS_SURFACEFLINGER_FLAGS_GRAPHITE_RENDERENGINE || \ + COM_ANDROID_GRAPHICS_SURFACEFLINGER_FLAGS_FORCE_COMPILE_GRAPHITE_RENDERENGINE const bool useGraphite = FlagManager::getInstance().graphite_renderengine() && renderengine::RenderEngine::canSupport(kVulkan); +#else + const bool useGraphite = false; + if (FlagManager::getInstance().graphite_renderengine()) { + ALOGE("RenderEngine's Graphite Skia backend was requested with the " + "debug.renderengine.graphite system property, but it is not compiled in this " + "build! Falling back to Ganesh backend selection logic."); + } +#endif const bool useVulkan = useGraphite || (FlagManager::getInstance().vulkan_renderengine() && renderengine::RenderEngine::canSupport(kVulkan)); -- cgit v1.2.3-59-g8ed1b