Skip to content

Commit

Permalink
Make vulkan build as optional (#4814) (#4815)
Browse files Browse the repository at this point in the history
Add option WITH_VULKAN, which is ON by default.
If set to OFF, modules OrbitTriggerCaptureVulkanLayer, OrbitVulkanLayer,
and VulkanTutorial won't be built
  • Loading branch information
alexkalmuk authored Mar 8, 2023
1 parent 46bd4ec commit e9d7974
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 7 deletions.
24 changes: 18 additions & 6 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,14 @@ set(CMAKE_EXPORT_COMPILE_COMMANDS ON)

option(WITH_GUI "Setting this option will enable the Qt-based UI client." ON)

if(NOT WIN32)
option(WITH_VULKAN "Setting this option will enable Vulkan" ON)

if(WITH_VULKAN)
add_definitions(-DVULKAN_ENABLED)
endif()
endif()

# This is only for designated initializers
if(WIN32)
set(CMAKE_CXX_STANDARD 20 CACHE STRING "C++ Standard" FORCE)
Expand Down Expand Up @@ -127,9 +135,11 @@ else()
find_package(libbase REQUIRED)
find_package(liblog REQUIRED)
find_package(libprocinfo REQUIRED)
find_package(volk REQUIRED)
find_package(VulkanHeaders REQUIRED)
find_package(vulkan-validationlayers REQUIRED)
if(WITH_VULKAN)
find_package(volk REQUIRED)
find_package(VulkanHeaders REQUIRED)
find_package(vulkan-validationlayers REQUIRED)
endif()
endif()

include("cmake/protobuf.cmake")
Expand Down Expand Up @@ -173,13 +183,15 @@ else()
add_subdirectory(src/OrbitClientGgp)
add_subdirectory(src/OrbitCaptureGgpClient)
add_subdirectory(src/OrbitCaptureGgpService)
add_subdirectory(src/OrbitTriggerCaptureVulkanLayer)
add_subdirectory(src/OrbitVulkanLayer)
add_subdirectory(src/ProcessService)
add_subdirectory(src/TracepointService)
add_subdirectory(src/UserSpaceInstrumentation)
add_subdirectory(src/VulkanTutorial)
add_subdirectory(third_party/libunwindstack)
if(WITH_VULKAN)
add_subdirectory(src/OrbitTriggerCaptureVulkanLayer)
add_subdirectory(src/OrbitVulkanLayer)
add_subdirectory(src/VulkanTutorial)
endif()
endif()

add_subdirectory(src/Api)
Expand Down
5 changes: 4 additions & 1 deletion src/LinuxTracingIntegrationTests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -35,14 +35,17 @@ target_link_libraries(IntegrationTestCommons PUBLIC
ModuleUtils
ObjectUtils
OrbitBase
OffscreenRenderingVulkanTutorialLib
GTest::gtest
absl::base
absl::time
absl::flat_hash_set
absl::strings
absl::synchronization)

if(WITH_VULKAN)
target_link_libraries(IntegrationTestCommons PUBLIC OffscreenRenderingVulkanTutorialLib)
endif()


add_executable(LinuxTracingIntegrationTests)

Expand Down
8 changes: 8 additions & 0 deletions src/LinuxTracingIntegrationTests/IntegrationTestPuppet.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,9 @@
#include "OrbitBase/ExecutablePath.h"
#include "OrbitBase/Logging.h"
#include "OrbitBase/ThreadUtils.h"
#ifdef VULKAN_ENABLED
#include "VulkanTutorial/OffscreenRenderingVulkanTutorial.h"
#endif

// This executable is used by LinuxTracingIntegrationTest to test the generation of specific
// perf_event_open events. The behavior is controlled by commands sent on standard input.
Expand Down Expand Up @@ -104,10 +106,12 @@ static void LoadSoWithDlopenAndCallFunction() {
ORBIT_LOG("Function call completed: %f", function());
}

#ifdef VULKAN_ENABLED
static void RunVulkanTutorial() {
orbit_vulkan_tutorial::OffscreenRenderingVulkanTutorial tutorial;
tutorial.Run(PuppetConstants::kFrameCount);
}
#endif

extern "C" __attribute__((noinline)) void UseOrbitApi() {
for (uint64_t i = 0; i < PuppetConstants::kOrbitApiUsageCount; ++i) {
Expand Down Expand Up @@ -194,7 +198,11 @@ int IntegrationTestPuppetMain() {
} else if (command == PuppetConstants::kDlopenCommand) {
LoadSoWithDlopenAndCallFunction();
} else if (command == PuppetConstants::kVulkanTutorialCommand) {
#ifdef VULKAN_ENABLED
RunVulkanTutorial();
#else
ORBIT_ERROR("Vulkan isn't enabled. Build with WITH_VULKAN=ON");
#endif
} else if (command == PuppetConstants::kOrbitApiCommand) {
UseOrbitApi();
} else if (command == PuppetConstants::kIncreaseRssCommand) {
Expand Down

0 comments on commit e9d7974

Please sign in to comment.