mirror of
https://github.com/MobileGL-Dev/MobileGL
synced 2026-09-08 12:18:30 +09:00
- New CMake option MOBILEGL_BUILD_DISAGGREGATED (default OFF, plan B appendix B). ON appends the MG_Remote sources to SOURCE_FILES, puts 3rdparty/flatbuffers/include on the include path and defines MOBILEGL_BUILD_DISAGGREGATED=1. OFF compiles nothing from MG_Remote and adds no include path and no library, which is one of the two byte-level equalities plan B section 10.3 keeps: measured `nm --defined-only build-linux/libMobileGL.so | grep -ic MG_Remote` = 0 with the option OFF and 93 with it ON, with an identical ldd set in both configurations.
- The option forces itself OFF with message(WARNING) when 3rdparty/flatbuffers/include/flatbuffers/flatbuffers.h is missing, so a checkout without the submodule still configures and builds rather than failing a hundred lines later on a missing header.
- ITransport.h: SendFrame / ReceiveFrame / PeekFrameSize / ShareFd / ReceiveFd / Shutdown. ReceiveFrame's contract is the fix for a defect of the earlier branch: a destination buffer smaller than the pending message returns MOBILEGL_ERR_BUFFER_TOO_SMALL with the required size and KEEPS the message queued. The earlier transport failed the call and popped the message anyway, which wedges the stream permanently the first time a reader guesses a size wrong.
- Framing.h: [u32 'MGLF'][u32 len][payload], 64 MiB cap, validated on read. A bad magic or an oversized length latches the reader dead, is logged at ERROR and makes every later call return MOBILEGL_ERR_PROTOCOL_MISMATCH. This is the second inherited defect: Feat/CS-Delta-IPC's Framing.h:41-45 Feed() always returned OK and its header peek merely returned false, so a desynchronized stream became a silent permanent hang; its LocalSocketTransport.cpp:232-236 then allocated on the peer-supplied length with no cap. The magic is also byte-ordered so it reads "MGLF" on the wire, where the earlier constant spelled "FLGM".
- Ring.h/.cpp: RingControl exactly as the inherited design (plan B section 8.1 -> earlier section 6.2): two independent cursor triples (cmd and stage, each {head, appliedTail, retiredTail}), appliedSeq / submittedSeq / retiredSeq / completedFrameSerial / presentAckSerial, serverEpoch, ringGeneration, consumerParked, producerParked, eventRingFull, eventDropped. One 4096-byte page with each contended group on its own cache line, pinned by static_assert on size and alignment and by an offset test.
- The SPSC pair uses monotonic byte cursors and a power-of-two mask, so a torn read can never look like a valid earlier position. A record never straddles the wrap: the producer emits a kPad filler to the boundary, which is always a multiple of 8 and therefore always has room for a header. The producer reclaims against retiredTail rather than appliedTail, so the day the server borrows a ring slot into the GPU timeline (kRecBorrowSlot) it does not silently degrade to early recycling. HardDrainRing bumps ringGeneration only when the ring is quiesced, and leaves the cursors monotonic so cached offsets are recognisably stale.
- The consumer bounds-checks every record header before dispatch (8-aligned, at least a header, no larger than what the producer published, contiguous inside the mapping) and reports corruption to the caller instead of dispatching into undefined behaviour. That is the runtime half of the earlier section 6.3 discipline: SEG_CMD is written by another process, so a compile-time static_assert on record sizes proves nothing about what is in the mapping.
- Doorbell.h/.cpp: spin then park, both directions (earlier section 6.2a). CondVarDoorbell for inproc, SocketDoorbell for spawn (one byte, codes 0x01 ring-advanced and 0x02 watermark-advanced) - no futex, eventfd or named event anywhere. The lost-wakeup window is closed by ordering: the waiter stores its park flag seq_cst and then re-tests the condition, NotifyIfParked loads the same flag seq_cst after the watermark is published, so one of the two always sees the other. kDefaultSpinUs is 50, the MOBILEGL_IPC_SPIN_US default.
- ShmSegment.{h,cpp} + ShmSegmentPosix.cpp: memfd_create by raw syscall on desktop Linux (the glibc wrapper is too recent to rely on), ASharedMemory_create on Android (API 26; libc's memfd_create wrapper is API 30, above MobileGL's floor), shm_open + immediate shm_unlink as the fallback. Adopt() refuses a descriptor whose fstat size is smaller than the size the peer announced, so a short segment cannot turn every later offset into an out-of-bounds map. ShmSegmentWin32.cpp (CreateFileMappingW in Local\) is compile-guarded and untested - this project's Windows machine is not a correctness gate.
- The Android path is compile-verified, not just written: an arm64-v8a NDK build with the option ON links, ShmSegmentPosix.cpp.o carries an undefined ASharedMemory_create, and ShmSegmentWin32.cpp.o is empty there. That build is also what caught the missing <cstddef> in ShmSegment.h and Framing.h, where std::size_t / std::ptrdiff_t only resolved through a transitive include on the host sysroot.
- FdPassing.{h,cpp}: SCM_RIGHTS in the FIRST transport commit, as plan B section 8.1 demands, over a dedicated AF_UNIX SOCK_DGRAM socketpair rather than the control byte stream (message boundaries survive on every POSIX - SOCK_SEQPACKET does not exist on macOS - and ancillary data can never be split from its payload). The third inherited defect this replaces: Feat/CS-Delta-IPC deferred fd passing and hardcoded `out->fd = -1` in LocalSocketTransport.cpp:296, so on the only platform that matters its data plane could not move one byte between processes. MSG_CTRUNC, an unexpected descriptor count and a malformed sideband header all close every descriptor received before failing, and a too-small sideband buffer is refused before the recvmsg so a datagram is never half-consumed.
- InProcessTransport.{h,cpp}: two in-memory queues plus the condvar doorbell pair. It keeps the frame size cap so nothing that passes in inproc becomes illegal after the switch to spawn, hands descriptors over with dup() under the same ownership rule as SCM_RIGHTS, and lets a peer's queued messages be drained after Shutdown - usually the last one says why it is going away.
- Not done here on purpose: the MOBILEGL_IPC_* environment variables are parsed in ConfigLoader.cpp, which belongs to another P0 work package running in parallel; this commit only exposes the constants (kDefaultSpinUs, kMaxFramePayloadSize, FdPassing::kMaxSidebandBytes) so that plumbing has something to set.
760 lines
34 KiB
CMake
760 lines
34 KiB
CMake
cmake_minimum_required(VERSION 3.22.1)
|
|
|
|
project("MobileGL")
|
|
|
|
option(MOBILEGL_BUILD_TEST "Build MobileGL tests" ON )
|
|
option(MOBILEGL_BUILD_BENCHMARK "Build MobileGL benchmarks" ON )
|
|
# Headless end-to-end GPU scenarios (MobileGL/MG_IntegrationTest). They need a
|
|
# real GPU/ICD to do anything, so they are off by default for CI; every scenario
|
|
# skips cleanly where there is none. Registered under the `integration-gpu`
|
|
# ctest label so a run can select or exclude them.
|
|
option(MOBILEGL_BUILD_INTEGRATION_TEST "Build MobileGL headless GPU integration tests" OFF)
|
|
option(MOBILEGL_FORCE_RELEASE_OPT "Enable Release optimization flags in Debug build" ON )
|
|
option(MOBILEGL_ENABLE_TRACY "Enable tracy for profiling" OFF)
|
|
option(MOBILEGL_BUILD_TRACE_REPLAY "Build desktop apitrace replay runner" OFF)
|
|
option(MOBILEGL_TRACE_ANGLE_VARIANTS "Enable signed trace-APK ANGLE variant loading" OFF)
|
|
option(MOBILEGL_IOS "Build MobileGL for iOS instead of macOS when APPLE is set" OFF)
|
|
# The disaggregated (two-process) shape. OFF is the shipping default and OFF
|
|
# must stay byte-comparable to a tree without MG_Remote at all: nothing under
|
|
# MobileGL/MG_Remote/ is compiled, no include path is added, and no library is
|
|
# linked, so `nm --defined-only libMobileGL.so | grep -i MG_Remote` is empty.
|
|
# That emptiness is one of the two byte-level equalities the plan's validation
|
|
# gates keep (section 10.3).
|
|
option(MOBILEGL_BUILD_DISAGGREGATED "Build the MG_Remote transport layer (two-process shape)" OFF)
|
|
set(MOBILEGL_LOG_ACTIVE_LEVEL "MOBILEGL_LOG_LEVEL_INFO" CACHE STRING "MobileGL active log level macro")
|
|
set(MOBILEGL_VULKAN_LIBRARY "" CACHE FILEPATH "Vulkan loader/MoltenVK library to link for iOS builds")
|
|
|
|
if (ANDROID)
|
|
set(MOBILEGL_BUILD_TEST OFF CACHE BOOL "Build MobileGL tests" FORCE)
|
|
set(MOBILEGL_BUILD_BENCHMARK OFF CACHE BOOL "Build MobileGL benchmarks" FORCE)
|
|
|
|
# ------- Android API level policy: minimum 26, decided here and only here -------
|
|
# MobileGL ships against API 26: the codebase must not use any API introduced
|
|
# after 26. That usage constraint is enforced where it is real - the shipping
|
|
# gradle build compiles at minSdk 26, where a newer API is simply undeclared
|
|
# and fails to compile. Configuring at a HIGHER level is therefore allowed
|
|
# (nothing in the tree may rely on it), but a LOWER level would change the
|
|
# libc contract underneath the shipped library and is refused.
|
|
#
|
|
# This has to live at configure time because the level cannot be corrected
|
|
# from a source header. A `#define __ANDROID_API__ 26` in a common header
|
|
# only rewrites the macro for the bionic headers that happen to be included
|
|
# after it; any libc++ header pulled in earlier has already latched its
|
|
# feature macros at the real configure-time level. libc++ and bionic then
|
|
# disagree about which symbols exist - libc++ calls e.g.
|
|
# pthread_cond_clockwait while bionic, re-read at the lowered level, has
|
|
# hidden its declaration. MobileGL/Defines.h carried exactly that pin from
|
|
# the first commit until it was removed; this guard is what replaces it.
|
|
#
|
|
# Read the level back from the compiler target triple first. Its trailing
|
|
# number (aarch64-none-linux-android26) is precisely what clang turns into
|
|
# __ANDROID_API__, so it cannot disagree with the compile itself, and it is
|
|
# already past every NDK normalisation step - codename aliases, "latest",
|
|
# and per-ABI minimum pull-ups. ANDROID_PLATFORM_LEVEL is the fallback for
|
|
# generators/languages where the triple variable is not populated.
|
|
#
|
|
# Note CMAKE_SYSTEM_VERSION is deliberately NOT consulted: it holds the API
|
|
# level only under the NDK's newer toolchain path, and is a meaningless 1
|
|
# when ANDROID_USE_LEGACY_TOOLCHAIN_FILE is on (which is what AGP has been
|
|
# defaulting to). Reading it would fail every legacy-mode build.
|
|
set(MOBILEGL_ANDROID_API_LEVEL 26)
|
|
|
|
set(_mobilegl_android_api "")
|
|
foreach (_mobilegl_api_triple "${CMAKE_CXX_COMPILER_TARGET}"
|
|
"${CMAKE_C_COMPILER_TARGET}")
|
|
if (NOT _mobilegl_android_api AND
|
|
_mobilegl_api_triple MATCHES "-android([0-9]+)$")
|
|
set(_mobilegl_android_api "${CMAKE_MATCH_1}")
|
|
endif()
|
|
endforeach()
|
|
|
|
foreach (_mobilegl_api_var ANDROID_PLATFORM_LEVEL ANDROID_NATIVE_API_LEVEL
|
|
ANDROID_PLATFORM)
|
|
if (NOT _mobilegl_android_api AND ${_mobilegl_api_var})
|
|
string(REGEX REPLACE "^android-" ""
|
|
_mobilegl_android_api "${${_mobilegl_api_var}}")
|
|
endif()
|
|
endforeach()
|
|
|
|
if (NOT _mobilegl_android_api MATCHES "^[0-9]+$")
|
|
message(FATAL_ERROR
|
|
"MobileGL: could not determine the Android API level (got "
|
|
"\"${_mobilegl_android_api}\"). Configure with the NDK toolchain "
|
|
"file and -DANDROID_PLATFORM=android-${MOBILEGL_ANDROID_API_LEVEL}.")
|
|
elseif (_mobilegl_android_api LESS MOBILEGL_ANDROID_API_LEVEL)
|
|
message(FATAL_ERROR
|
|
"MobileGL requires at least Android API ${MOBILEGL_ANDROID_API_LEVEL}, "
|
|
"but this build resolved to API ${_mobilegl_android_api}.\n"
|
|
"Configure with -DANDROID_PLATFORM=android-${MOBILEGL_ANDROID_API_LEVEL} "
|
|
"(gradle builds get this from minSdk ${MOBILEGL_ANDROID_API_LEVEL}, so "
|
|
"check that minSdk instead of adding an override).")
|
|
elseif (_mobilegl_android_api GREATER MOBILEGL_ANDROID_API_LEVEL)
|
|
message(STATUS
|
|
"MobileGL: configuring at Android API ${_mobilegl_android_api} "
|
|
"(> shipping minimum ${MOBILEGL_ANDROID_API_LEVEL}). Allowed, but the "
|
|
"tree must not use post-${MOBILEGL_ANDROID_API_LEVEL} APIs - the "
|
|
"minSdk-${MOBILEGL_ANDROID_API_LEVEL} gradle build is the enforcing "
|
|
"compile.")
|
|
endif()
|
|
|
|
message(STATUS "MobileGL: Android API level ${_mobilegl_android_api}")
|
|
|
|
unset(_mobilegl_android_api)
|
|
unset(_mobilegl_api_var)
|
|
unset(_mobilegl_api_triple)
|
|
endif()
|
|
|
|
option(MOBILEGL_ENABLE_LTO "Build with ThinLTO/IPO" OFF)
|
|
|
|
if ((NOT CMAKE_BUILD_TYPE STREQUAL "Debug" OR MOBILEGL_FORCE_RELEASE_OPT) AND MOBILEGL_ENABLE_LTO)
|
|
# Check if ThinLTO or LTO is suppported
|
|
include(CheckIPOSupported)
|
|
include(CheckCCompilerFlag)
|
|
include(CheckCXXCompilerFlag)
|
|
|
|
check_ipo_supported(RESULT LTOSupported OUTPUT LTOError)
|
|
|
|
check_c_compiler_flag("-flto" HAS_LTO_C)
|
|
check_cxx_compiler_flag("-flto" HAS_LTO_CXX)
|
|
|
|
if (LTOSupported OR (HAS_LTO_C AND HAS_LTO_CXX))
|
|
# Check ThinLTO
|
|
check_c_compiler_flag("-flto=thin" HAS_THINLTO_C)
|
|
check_cxx_compiler_flag("-flto=thin" HAS_THINLTO_CXX)
|
|
if (HAS_THINLTO_C AND HAS_THINLTO_CXX)
|
|
message(STATUS "ThinLTO supported, using -flto=thin")
|
|
|
|
add_compile_options(-flto=thin)
|
|
add_link_options(-flto=thin)
|
|
else()
|
|
# ThinLTO is not supported
|
|
message(STATUS "ThinLTO not available, fallback to CMAKE IPO")
|
|
set(CMAKE_INTERPROCEDURAL_OPTIMIZATION TRUE)
|
|
endif()
|
|
else()
|
|
message(STATUS "IPO not supported: ${LTOError}")
|
|
endif()
|
|
|
|
if (CMAKE_CXX_COMPILER_ID MATCHES "GNU|Clang" AND NOT MATCHES "AppleClang")
|
|
add_compile_options(-O3 -ffunction-sections -fdata-sections)
|
|
add_link_options(-Wl,--gc-sections)
|
|
elseif (CMAKE_CXX_COMPILER_ID MATCHES "MSVC")
|
|
# add_compile_options(/O2)
|
|
else ()
|
|
add_compile_options(-O2)
|
|
endif()
|
|
endif()
|
|
|
|
if (CMAKE_CXX_COMPILER_ID MATCHES "MSVC")
|
|
add_compile_options(/Zc:preprocessor)
|
|
add_compile_options(/Zc:__cplusplus)
|
|
endif()
|
|
|
|
enable_language(CXX)
|
|
|
|
set(CMAKE_CXX_STANDARD 23)
|
|
|
|
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
|
|
|
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
|
|
|
|
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
|
|
|
|
if (MSVC)
|
|
set(CMAKE_CXX_FLAGS "/EHsc ${CMAKE_CXX_FLAGS}")
|
|
endif()
|
|
|
|
# Generate MGGitHash.h
|
|
execute_process(
|
|
COMMAND git rev-parse HEAD
|
|
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
|
|
OUTPUT_VARIABLE GIT_COMMIT_HASH_FULL
|
|
OUTPUT_STRIP_TRAILING_WHITESPACE
|
|
)
|
|
|
|
string(SUBSTRING "${GIT_COMMIT_HASH_FULL}" 0 7 GIT_COMMIT_HASH_SHORT)
|
|
|
|
configure_file(
|
|
${CMAKE_SOURCE_DIR}/MobileGL/MG_Util/Miscellany/MGGitHash.h.in
|
|
${CMAKE_BINARY_DIR}/generated/MGGitHash.h
|
|
@ONLY
|
|
)
|
|
|
|
include_directories(${CMAKE_BINARY_DIR}/generated)
|
|
|
|
set(ENABLE_RTTI ON CACHE BOOL "Enables RTTI (will be took by glslang)" FORCE)
|
|
|
|
set(ENABLE_GLSLANG_BINARIES OFF CACHE BOOL "Enable glslangValidator/spirv-remap" FORCE)
|
|
set(ENABLE_SPVREMAPPER OFF CACHE BOOL "Enable SPVRemapper" FORCE)
|
|
set(ENABLE_OPT ON CACHE BOOL "Enable SPIRV-Tools opt usage in glslang" FORCE)
|
|
set(BUILD_EXTERNAL ON CACHE BOOL "Build external deps in External/" FORCE)
|
|
set(ENABLE_GLSLANG_INSTALL OFF CACHE BOOL "Install glslang targets" FORCE)
|
|
set(SPIRV_SKIP_EXECUTABLES ON CACHE BOOL "Skip building SPIRV-Tools executables" FORCE)
|
|
|
|
set(SPIRV_CROSS_C_API ON CACHE BOOL "Enable C API" FORCE)
|
|
set(SPIRV_CROSS_ENABLE_GLSL ON CACHE BOOL "Enable GLSL backend" FORCE)
|
|
set(SPIRV_CROSS_ENABLE_HLSL OFF CACHE BOOL "Disable HLSL backend" FORCE)
|
|
set(SPIRV_CROSS_ENABLE_MSL OFF CACHE BOOL "Disable MSL backend" FORCE)
|
|
set(SPIRV_CROSS_ENABLE_CPP OFF CACHE BOOL "Disable C++ API target" FORCE)
|
|
set(SPIRV_CROSS_CLI OFF CACHE BOOL "Disable CLI binary" FORCE)
|
|
set(SPIRV_CROSS_STATIC ON CACHE BOOL "Prefer static libs" FORCE)
|
|
|
|
set(SPIRV_REFLECT_EXECUTABLE OFF CACHE BOOL "Build spirv-reflect executable" FORCE)
|
|
set(SPIRV_REFLECT_STATIC_LIB ON CACHE BOOL "Build a SPIRV-Reflect static library" FORCE)
|
|
set(SPIRV_REFLECT_BUILD_TESTS OFF CACHE BOOL "Build the SPIRV-Reflect test suite" FORCE)
|
|
set(SPIRV_REFLECT_ENABLE_ASSERTS OFF CACHE BOOL "Enable asserts for debugging" FORCE)
|
|
set(SPIRV_REFLECT_ENABLE_ASAN OFF CACHE BOOL "Use address sanitization" FORCE)
|
|
set(SPIRV_REFLECT_INSTALL OFF CACHE BOOL "Whether to install" FORCE)
|
|
|
|
# add_subdirectory(3rdparty/DiligentCore)
|
|
add_subdirectory(3rdparty/glslang)
|
|
add_subdirectory(3rdparty/SPIRV-Cross)
|
|
add_subdirectory(3rdparty/VulkanMemoryAllocator)
|
|
add_subdirectory(3rdparty/Vulkan-Headers)
|
|
add_subdirectory(3rdparty/Vulkan-Utility-Libraries)
|
|
add_subdirectory(3rdparty/SPIRV-Reflect)
|
|
|
|
set(XXHASH_BUILD_XXHSUM OFF)
|
|
option(BUILD_SHARED_LIBS OFF)
|
|
add_subdirectory(3rdparty/xxHash/build/cmake xxhash_build EXCLUDE_FROM_ALL)
|
|
|
|
set(TRACY_ENABLE ${MOBILEGL_ENABLE_TRACY} CACHE BOOL "Enable Tracy, this is an internal variable" FORCE)
|
|
|
|
if (TRACY_ENABLE)
|
|
set(TRACY_ON_DEMAND ON CACHE BOOL "Enable profiling only connected" FORCE)
|
|
set(TRACY_NO_EXIT OFF CACHE BOOL "Don't exit Tracy until connected" FORCE)
|
|
set(TRACY_DELAYED_INIT ON CACHE BOOL "Don't init Tracy on library load" FORCE)
|
|
set(TRACY_MANUAL_LIFETIME ON CACHE BOOL "Manually control Tracy lifetime" FORCE)
|
|
set(TRACY_NO_CRASH_HANDLER ON CACHE BOOL "Disable crash handling" FORCE)
|
|
|
|
add_subdirectory(3rdparty/tracy)
|
|
endif ()
|
|
|
|
set(SOURCE_FILES
|
|
MobileGL/Init.cpp
|
|
MobileGL/GlobalObjects.cpp
|
|
MobileGL/ConfigLoader.cpp
|
|
|
|
MobileGL/MG_Util/Debug/Log.cpp
|
|
|
|
MobileGL/MG_Util/Async/JobNode.cpp
|
|
MobileGL/MG_Util/Async/ShaderCompilePool.cpp
|
|
|
|
MobileGL/MG_Util/Math/VectorTypes.cpp
|
|
MobileGL/MG_Util/Metrics/TextureMetrics.cpp
|
|
|
|
MobileGL/MG_Util/Metrics/BufferMetrics.cpp
|
|
|
|
MobileGL/MG_Util/Metrics/PipeStats.cpp
|
|
|
|
MobileGL/MG_Util/Converters/GLToStr/GLEnumConverter.cpp
|
|
MobileGL/MG_Util/Converters/EGLToStr/EGLEnumConverter.cpp
|
|
MobileGL/MG_Util/Converters/MGToStr/DataTypeConverter.cpp
|
|
MobileGL/MG_Util/Converters/MGToStr/RenderStateEnumConverter.cpp
|
|
MobileGL/MG_Util/Converters/MGToStr/GLExtensionConverter.cpp
|
|
MobileGL/MG_Util/Converters/MGToStr/BufferEnumConverter.cpp
|
|
MobileGL/MG_Util/Converters/MGToStr/FramebufferEnumConverter.cpp
|
|
MobileGL/MG_Util/Converters/MGToStr/TextureEnumConverter.cpp
|
|
MobileGL/MG_Util/Converters/GLToGlslang/ProgramEnumConverter.cpp
|
|
MobileGL/MG_Util/Converters/MGToGL/ErrorCodeConverter.cpp
|
|
MobileGL/MG_Util/Converters/MGToGL/BufferEnumConverter.cpp
|
|
MobileGL/MG_Util/Converters/MGToGL/FramebufferEnumConverter.cpp
|
|
MobileGL/MG_Util/Converters/MGToGL/TextureEnumConverter.cpp
|
|
MobileGL/MG_Util/Converters/MGToGL/DataTypeConverter.cpp
|
|
MobileGL/MG_Util/Converters/MGToGL/RenderStateEnumConverter.cpp
|
|
MobileGL/MG_Util/Converters/MGToGL/ProgramEnumConverter.cpp
|
|
MobileGL/MG_Util/Converters/GLToMG/BufferEnumConverter.cpp
|
|
MobileGL/MG_Util/Converters/GLToMG/FramebufferEnumConverter.cpp
|
|
MobileGL/MG_Util/Converters/GLToMG/TextureEnumConverter.cpp
|
|
MobileGL/MG_Util/Converters/GLToMG/DataTypeConverter.cpp
|
|
MobileGL/MG_Util/Converters/GLToMG/RenderStateEnumConverter.cpp
|
|
MobileGL/MG_Util/Converters/GLToMG/ProgramEnumConverter.cpp
|
|
MobileGL/MG_Util/Converters/MGToMG/TextureEnumConverter.cpp
|
|
MobileGL/MG_Util/Converters/MGToVk/RenderStateEnumConverter.cpp
|
|
MobileGL/MG_Util/Converters/MGToVk/TextureEnumConverter.cpp
|
|
|
|
MobileGL/MG_Util/Classifiers/TextureEnumClassifier.cpp
|
|
|
|
MobileGL/MG_Util/ShaderTranspiler/CompileEnv.cpp
|
|
MobileGL/MG_Util/ShaderTranspiler/ShaderCompiler.cpp
|
|
MobileGL/MG_Util/ShaderTranspiler/SpvcSession.cpp
|
|
MobileGL/MG_Util/ShaderTranspiler/ShaderSourceProcessor.cpp
|
|
MobileGL/MG_Util/ShaderTranspiler/TranslationCache.cpp
|
|
MobileGL/MG_Util/ShaderTranspiler/glslang/TMglGlslIoResolver.cpp
|
|
MobileGL/MG_Util/ShaderTranspiler/SpirvPasses/FlattenInterfaceStructPass.cpp
|
|
MobileGL/MG_Util/ShaderTranspiler/SpirvPasses/EliminateFloatEqualsZeroPass.cpp
|
|
MobileGL/MG_Util/ShaderTranspiler/SpirvPasses/RenameSamplerFunctionParameterPass.cpp
|
|
MobileGL/MG_Util/ShaderTranspiler/SpirvPasses/RenameBuiltinShadowingFunctionsPass.cpp
|
|
MobileGL/MG_Util/ShaderTranspiler/SpirvPasses/DecomposeWorkgroupVec3Pass.cpp
|
|
MobileGL/MG_Util/ShaderTranspiler/SpirvPasses/DecoratePositionInvariantPass.cpp
|
|
MobileGL/MG_Util/ShaderTranspiler/SpirvPasses/DemoteFloat64Pass.cpp
|
|
MobileGL/MG_Util/ShaderTranspiler/SpirvPasses/FlattenFloat64StorageBlockPass.cpp
|
|
MobileGL/MG_Util/ShaderTranspiler/SpirvPasses/LowerDrawParametersPass.cpp
|
|
MobileGL/MG_Util/ShaderTranspiler/SpirvPasses/LowerViewportIndexPass.cpp
|
|
MobileGL/MG_Util/ShaderTranspiler/SpirvPasses/PackDoubleVertexInputsPass.cpp
|
|
MobileGL/MG_Util/ShaderTranspiler/SpirvPasses/FlattenXfbInterfaceBlocksPass.cpp
|
|
MobileGL/MG_Util/ShaderTranspiler/SpirvPasses/UniquifyIoBlockNamesPass.cpp
|
|
MobileGL/MG_Util/ShaderTranspiler/SpirvPasses/StripIoBlockLocationsPass.cpp
|
|
MobileGL/MG_Util/ShaderTranspiler/SpirvPasses/SplitArrayVertexInputsPass.cpp
|
|
MobileGL/MG_Util/ShaderTranspiler/SpirvPasses/RebaseInstanceIndexPass.cpp
|
|
MobileGL/MG_Util/ShaderTranspiler/SpirvPasses/ZeroBaseVertexPass.cpp
|
|
MobileGL/MG_Util/ShaderTranspiler/SpirvPasses/DeriveNumSubgroupsPass.cpp
|
|
MobileGL/MG_Util/ShaderTranspiler/SpirvPasses/FixIterationRPBarrierPass.cpp
|
|
MobileGL/MG_Util/ShaderTranspiler/SpirvPasses/FixIterationRPSubgroupScratchPass.cpp
|
|
MobileGL/MG_Util/ShaderTranspiler/SpirvPasses/EmulateSubgroupsPass.cpp
|
|
MobileGL/MG_Util/ShaderTranspiler/SpirvPasses/NormalizeRectCoordinatesPass.cpp
|
|
MobileGL/MG_Util/ShaderTranspiler/SpirvPasses/Lower1DArrayImagesPass.cpp
|
|
MobileGL/MG_Util/ShaderTranspiler/SpirvPasses/Lower1DSampledImagesPass.cpp
|
|
MobileGL/MG_Util/ShaderTranspiler/SpirvPasses/BakeImageFormatsPass.cpp
|
|
MobileGL/MG_Util/ShaderTranspiler/SpirvPasses/WidenImageFormatsPass.cpp
|
|
MobileGL/MG_Util/ShaderTranspiler/SpirvPasses/ClampMultisampleFetchPass.cpp
|
|
MobileGL/MG_Util/ShaderTranspiler/SpirvPasses/PrivateToEntryLocalPass.cpp
|
|
MobileGL/MG_Util/ShaderTranspiler/SpirvPasses/StripUniformLocationsPass.cpp
|
|
MobileGL/MG_Util/ShaderTranspiler/SpirvPasses/StripUboMemberRelaxedPrecisionPass.cpp
|
|
MobileGL/MG_Util/ShaderTranspiler/SpirvPasses/StripNoPerspectivePass.cpp
|
|
MobileGL/MG_Util/ShaderTranspiler/SpirvPasses/EmulateNoPerspectivePass.cpp
|
|
MobileGL/MG_Util/ShaderTranspiler/SpirvPasses/LegalizeFragmentOutputIndexPass.cpp
|
|
MobileGL/MG_Util/ShaderTranspiler/SpirvPasses/LegalizeResourceArrayIndexPass.cpp
|
|
MobileGL/MG_Util/ShaderTranspiler/SpirvPasses/FlattenAtomicCounterBlockPass.cpp
|
|
MobileGL/MG_Util/ShaderTranspiler/SpirvPasses/DemotePointSizePass.cpp
|
|
|
|
MobileGL/MG_Util/BackendLoaders/OpenGL/Loader.cpp
|
|
MobileGL/MG_Util/BackendLoaders/Vulkan/Loader.cpp
|
|
|
|
MobileGL/MG_Util/SelfTest/DriverBugProbes.cpp
|
|
MobileGL/MG_Util/SelfTest/DriverPost.cpp
|
|
MobileGL/MG_Util/SelfTest/DriverPostIterationRPWitness.cpp
|
|
MobileGL/MG_Util/SelfTest/PrimitivesGeneratedNoXfbProbe.cpp
|
|
|
|
MobileGL/MG_Util/Texture/PixelStoreProcessor.cpp
|
|
MobileGL/MG_Util/Texture/TextureFormatProcessor.cpp
|
|
|
|
MobileGL/MG_Impl/GLXImpl/Exporting/Definitions.cpp
|
|
MobileGL/MG_Impl/GLXImpl/GLXImpl.cpp
|
|
MobileGL/MG_Impl/GLXImpl/LookUp/LookUp.cpp
|
|
|
|
MobileGL/MG_Impl/EGLImpl/Exporting/Definitions.cpp
|
|
MobileGL/MG_Impl/EGLImpl/EGLImpl.cpp
|
|
|
|
# @INSERTION_POINT:SOURCE_FILE_GLIMPL@ #
|
|
MobileGL/MG_Impl/GLImpl/Sampler/Validators.cpp
|
|
MobileGL/MG_Impl/GLImpl/Sampler/GL_Sampler.cpp
|
|
MobileGL/MG_Impl/GLImpl/Drawing/GL_Drawing.cpp
|
|
MobileGL/MG_Impl/GLImpl/RenderState/GL_RenderState.cpp
|
|
MobileGL/MG_Impl/GLImpl/Framebuffer/Validators.cpp
|
|
MobileGL/MG_Impl/GLImpl/Framebuffer/GL_Framebuffer.cpp
|
|
MobileGL/MG_Impl/GLImpl/Program/GL_Program.cpp
|
|
MobileGL/MG_Impl/GLImpl/Program/ProgramInterface.cpp
|
|
MobileGL/MG_Impl/GLImpl/Program/GL_ProgramPipeline.cpp
|
|
MobileGL/MG_Impl/GLImpl/Texture/GL_Texture.cpp
|
|
MobileGL/MG_Impl/GLImpl/Debug/GL_Debug.cpp
|
|
MobileGL/MG_Impl/GLImpl/Texture/Validators.cpp
|
|
MobileGL/MG_Impl/GLImpl/Texture/ProxyTexture.cpp
|
|
MobileGL/MG_Impl/GLImpl/VertexArray/GL_VertexArray.cpp
|
|
MobileGL/MG_Impl/GLImpl/VertexArray/Validators.cpp
|
|
MobileGL/MG_Impl/GLImpl/Buffer/GL_Buffer.cpp
|
|
MobileGL/MG_Impl/GLImpl/Buffer/Validators.cpp
|
|
MobileGL/MG_Impl/GLImpl/Exporting/Definitions.cpp
|
|
MobileGL/MG_Impl/GLImpl/Getter/GL_Getter.cpp
|
|
MobileGL/MG_Impl/GLImpl/Sync/GL_Sync.cpp
|
|
MobileGL/MG_Impl/GLImpl/Query/GL_Query.cpp
|
|
|
|
MobileGL/MG_Impl/Init.cpp
|
|
MobileGL/MG_Impl/GetProcAddress.cpp
|
|
|
|
MobileGL/MG_Backend/Init.cpp
|
|
MobileGL/MG_Backend/BackendObject.cpp
|
|
|
|
MobileGL/MG_Backend/DirectGLES/DirectGLES.cpp
|
|
MobileGL/MG_Backend/DirectGLES/BackendObject_DirectGLES.cpp
|
|
MobileGL/MG_Backend/DirectGLES/Utils.cpp
|
|
MobileGL/MG_Backend/DirectGLES/Managers.cpp
|
|
MobileGL/MG_Backend/DirectGLES/MultiDraw.cpp
|
|
|
|
MobileGL/MG_Backend/DirectVulkan/DirectVulkan.cpp
|
|
MobileGL/MG_Backend/DirectVulkan/BackendObject_DirectVulkan.cpp
|
|
MobileGL/MG_Backend/DirectVulkan/VmaImpl.cpp
|
|
MobileGL/MG_Backend/DirectVulkan/Renderer/VulkanRenderer.cpp
|
|
MobileGL/MG_Backend/DirectVulkan/Renderer/SwapchainObject.cpp
|
|
MobileGL/MG_Backend/DirectVulkan/Renderer/FrameContext.cpp
|
|
MobileGL/MG_Backend/DirectVulkan/Renderer/PipelineFactory.cpp
|
|
MobileGL/MG_Backend/DirectVulkan/Renderer/ProgramFactory.cpp
|
|
MobileGL/MG_Backend/DirectVulkan/Renderer/UniformManager.cpp
|
|
MobileGL/MG_Backend/DirectVulkan/Renderer/BufferArena.cpp
|
|
MobileGL/MG_Backend/DirectVulkan/Renderer/VkBufferManager.cpp
|
|
MobileGL/MG_Backend/DirectVulkan/Renderer/VertexInputStateBuilder.cpp
|
|
MobileGL/MG_Backend/DirectVulkan/Renderer/VertexInputStateFactory.cpp
|
|
MobileGL/MG_Backend/DirectVulkan/Renderer/VkBufferObject.cpp
|
|
MobileGL/MG_Backend/DirectVulkan/Renderer/VkTextureManager.cpp
|
|
MobileGL/MG_Backend/DirectVulkan/Renderer/VkTimerQueryManager.cpp
|
|
MobileGL/MG_Backend/DirectVulkan/Renderer/VkSamplerManager.cpp
|
|
MobileGL/MG_Backend/DirectVulkan/Renderer/VkClearManager.cpp
|
|
MobileGL/MG_Backend/DirectVulkan/Renderer/VkRenderPassManager.cpp
|
|
|
|
MobileGL/MG_State/GLState/Core.cpp
|
|
MobileGL/MG_State/EGLState/Core.cpp
|
|
MobileGL/MG_State/GLState/ErrorState/Error.cpp
|
|
MobileGL/MG_State/GLState/BufferState/BufferState.cpp
|
|
MobileGL/MG_State/GLState/BufferState/BufferObject.cpp
|
|
MobileGL/MG_State/GLState/VertexArrayState/VertexArrayState.cpp
|
|
MobileGL/MG_State/GLState/VertexArrayState/VertexArrayObject.cpp
|
|
MobileGL/MG_State/GLState/TextureState/MipmapStorage.cpp
|
|
MobileGL/MG_State/GLState/TextureState/TextureObject.cpp
|
|
MobileGL/MG_State/GLState/TextureState/TextureObject1D.cpp
|
|
MobileGL/MG_State/GLState/TextureState/TextureObject2D.cpp
|
|
MobileGL/MG_State/GLState/TextureState/TextureObject2DCube.cpp
|
|
MobileGL/MG_State/GLState/TextureState/TextureObject3D.cpp
|
|
MobileGL/MG_State/GLState/TextureState/TextureObjectBuffer.cpp
|
|
MobileGL/MG_State/GLState/TextureState/TextureObjectView.cpp
|
|
MobileGL/MG_State/GLState/TextureState/TextureUnit.cpp
|
|
MobileGL/MG_State/GLState/TextureState/TextureState.cpp
|
|
MobileGL/MG_State/GLState/ProgramState/ProgramObject.cpp
|
|
MobileGL/MG_State/GLState/ProgramState/ProgramLinkTask.cpp
|
|
MobileGL/MG_State/GLState/ProgramState/ProgramTranslationCache.cpp
|
|
MobileGL/MG_State/GLState/ProgramState/ProgramSpirvTask.cpp
|
|
MobileGL/MG_State/GLState/ProgramState/ShaderCompileTask.cpp
|
|
MobileGL/MG_State/GLState/ProgramState/ShaderObject.cpp
|
|
MobileGL/MG_State/GLState/ProgramState/ShaderPreprocessCache.cpp
|
|
MobileGL/MG_State/GLState/ProgramState/ShaderCompileAdoptionMap.cpp
|
|
MobileGL/MG_State/GLState/ProgramState/ProgramState.cpp
|
|
MobileGL/MG_State/GLState/RenderState/RenderState.cpp
|
|
MobileGL/MG_State/GLState/FramebufferState/FramebufferObject.cpp
|
|
MobileGL/MG_State/GLState/FramebufferState/FramebufferState.cpp
|
|
MobileGL/MG_State/GLState/SamplerState/SamplerObject.cpp
|
|
MobileGL/MG_State/GLState/SamplerState/SamplerState.cpp
|
|
MobileGL/MG_State/GLState/RenderbufferState/RenderbufferObject.cpp
|
|
MobileGL/MG_State/GLState/RenderbufferState/RenderbufferState.cpp
|
|
)
|
|
|
|
# ---------------------------------------------------------------------------
|
|
# MG_Remote (disaggregated transport). Everything below is gated: with the
|
|
# option OFF not one file here is compiled and no include path is added.
|
|
# ---------------------------------------------------------------------------
|
|
|
|
# FlatBuffers is a submodule and its runtime is header-only. Guard both ways:
|
|
# a checkout without the submodule must configure and build, just without the
|
|
# disaggregated shape, rather than fail with a missing-header error a hundred
|
|
# lines later. Note this only checks for the RUNTIME headers - flatc is never
|
|
# built here (see scripts/gen_protocol.py).
|
|
if (MOBILEGL_BUILD_DISAGGREGATED AND
|
|
NOT EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/3rdparty/flatbuffers/include/flatbuffers/flatbuffers.h")
|
|
message(WARNING
|
|
"MOBILEGL_BUILD_DISAGGREGATED=ON but 3rdparty/flatbuffers/include is missing. "
|
|
"Run `git submodule update --init 3rdparty/flatbuffers`. Forcing the option OFF.")
|
|
set(MOBILEGL_BUILD_DISAGGREGATED OFF CACHE BOOL
|
|
"Build the MG_Remote transport layer (two-process shape)" FORCE)
|
|
endif()
|
|
|
|
if (MOBILEGL_BUILD_DISAGGREGATED)
|
|
message(STATUS "MobileGL: disaggregated transport ON, appending MG_Remote sources")
|
|
list(APPEND SOURCE_FILES
|
|
MobileGL/MG_Remote/Transport/Ring.cpp
|
|
MobileGL/MG_Remote/Transport/Doorbell.cpp
|
|
MobileGL/MG_Remote/Transport/ShmSegment.cpp
|
|
# Both platform halves are listed unconditionally and each is empty on
|
|
# the other OS, so neither can rot behind an `if (WIN32)` nobody
|
|
# configures.
|
|
MobileGL/MG_Remote/Transport/ShmSegmentPosix.cpp
|
|
MobileGL/MG_Remote/Transport/ShmSegmentWin32.cpp
|
|
MobileGL/MG_Remote/Transport/FdPassing.cpp
|
|
MobileGL/MG_Remote/Transport/InProcessTransport.cpp
|
|
)
|
|
endif()
|
|
|
|
if (APPLE AND NOT MOBILEGL_IOS)
|
|
list(APPEND SOURCE_FILES
|
|
MobileGL/MG_Impl/CGLImpl/CGLImpl.cpp
|
|
MobileGL/MG_Impl/CGLImpl/Exporting/Definitions.cpp
|
|
MobileGL/MG_Impl/DyldInterpose/DyldInterpose.cpp
|
|
MobileGL/MG_Impl/NSOpenGLImpl/NSOpenGLImpl.cpp
|
|
)
|
|
endif()
|
|
|
|
if (ANDROID)
|
|
list(APPEND SOURCE_FILES
|
|
MobileGL/MG_Util/SelfTest/DriverPostJni.cpp
|
|
MobileGL/MG_Util/SelfTest/DriverBenchJni.cpp
|
|
)
|
|
endif()
|
|
|
|
if (WIN32)
|
|
list(APPEND SOURCE_FILES
|
|
MobileGL/MG_Impl/WGLImpl/WGLImpl.cpp
|
|
MobileGL/MG_Impl/WGLImpl/Exporting/Definitions.cpp
|
|
)
|
|
endif()
|
|
|
|
# The shader-compile pool runs standalone Asio on real threads. This host's glibc (>= 2.34)
|
|
# merged pthread into libc, so it links without asking, but the NDK and musl are not
|
|
# guaranteed to be as forgiving - ask for it explicitly rather than rely on the accident.
|
|
find_package(Threads REQUIRED)
|
|
|
|
set(MOBILEGL_LINK_LIBRARIES
|
|
glslang::glslang
|
|
spirv-cross-c
|
|
SPIRV-Tools-opt
|
|
SPIRV-Tools
|
|
xxHash::xxhash
|
|
GPUOpen::VulkanMemoryAllocator
|
|
Vulkan::UtilityHeaders
|
|
spirv-reflect-static
|
|
Threads::Threads
|
|
)
|
|
|
|
set(MOBILEGL_COMPILE_DEF
|
|
-DVMA_STATIC_VULKAN_FUNCTIONS=0
|
|
-DVMA_DYNAMIC_VULKAN_FUNCTIONS=1
|
|
-DVMA_VULKAN_VERSION=1001000
|
|
# Header-only Asio, no Boost, no deprecated interfaces. Set on the definition list
|
|
# rather than per-target so the shared library and the _s static target agree.
|
|
-DASIO_STANDALONE
|
|
-DASIO_NO_DEPRECATED
|
|
)
|
|
|
|
if (MOBILEGL_BUILD_DISAGGREGATED)
|
|
list(APPEND MOBILEGL_COMPILE_DEF -DMOBILEGL_BUILD_DISAGGREGATED=1)
|
|
endif()
|
|
|
|
message(STATUS "MOBILEGL_COMPILE_DEF=${MOBILEGL_COMPILE_DEF}")
|
|
|
|
set(MOBILEGL_INCLUDE_DIR
|
|
${CMAKE_SOURCE_DIR}/include
|
|
${CMAKE_SOURCE_DIR}/MobileGL
|
|
# The MGPipe boundary headers. They are reachable as <MG_Pipe/MGPipe.h> through the
|
|
# line above too; this entry lets the client, the backends and MG_Remote spell them
|
|
# as <MGPipe.h> once MG_Pipe stops being a leaf of the frontend tree.
|
|
${CMAKE_SOURCE_DIR}/MobileGL/MG_Pipe
|
|
${spirv-tools_SOURCE_DIR}
|
|
${spirv-tools_SOURCE_DIR}/include
|
|
${spirv-tools_BINARY_DIR}
|
|
${SPIRV-Headers_SOURCE_DIR}/include
|
|
# Header-only submodule: no add_subdirectory, no link target. Only
|
|
# MG_Util/Async/ShaderCompilePool.cpp includes it, and it stays behind that file's
|
|
# pimpl so no consumer target needs this path.
|
|
${CMAKE_SOURCE_DIR}/3rdparty/asio/include
|
|
)
|
|
|
|
if (MOBILEGL_BUILD_DISAGGREGATED)
|
|
# Header-only runtime: an include path, no add_subdirectory, no link
|
|
# target, and above all no flatc in the build graph. protocol_generated.h
|
|
# is committed and regenerated by scripts/gen_protocol.py.
|
|
list(APPEND MOBILEGL_INCLUDE_DIR ${CMAKE_SOURCE_DIR}/3rdparty/flatbuffers/include)
|
|
endif()
|
|
|
|
add_library(${CMAKE_PROJECT_NAME} SHARED
|
|
${SOURCE_FILES}
|
|
)
|
|
|
|
if (WIN32)
|
|
# The wgl* entry points are exported via .def (see the comment in wgl.def);
|
|
# only the shared library links it.
|
|
target_sources(${CMAKE_PROJECT_NAME} PRIVATE
|
|
MobileGL/MG_Impl/WGLImpl/Exporting/wgl.def
|
|
)
|
|
endif()
|
|
|
|
if (CMAKE_BUILD_TYPE STREQUAL "Debug")
|
|
set_target_properties(${CMAKE_PROJECT_NAME} PROPERTIES
|
|
C_VISIBILITY_PRESET default
|
|
CXX_VISIBILITY_PRESET default
|
|
VISIBILITY_INLINES_HIDDEN OFF
|
|
)
|
|
else()
|
|
set_target_properties(${CMAKE_PROJECT_NAME} PROPERTIES
|
|
C_VISIBILITY_PRESET hidden
|
|
CXX_VISIBILITY_PRESET hidden
|
|
VISIBILITY_INLINES_HIDDEN ON
|
|
)
|
|
endif()
|
|
|
|
target_include_directories(${CMAKE_PROJECT_NAME} PUBLIC
|
|
${MOBILEGL_INCLUDE_DIR}
|
|
)
|
|
|
|
target_link_libraries(${CMAKE_PROJECT_NAME}
|
|
PUBLIC
|
|
${MOBILEGL_LINK_LIBRARIES}
|
|
)
|
|
|
|
target_compile_definitions(${CMAKE_PROJECT_NAME}
|
|
PUBLIC
|
|
${MOBILEGL_COMPILE_DEF}
|
|
MOBILEGL_LOG_ACTIVE_LEVEL=${MOBILEGL_LOG_ACTIVE_LEVEL}
|
|
$<$<BOOL:${MOBILEGL_TRACE_ANGLE_VARIANTS}>:MOBILEGL_TRACE_ANGLE_VARIANTS=1>
|
|
)
|
|
|
|
if(UNIX AND NOT APPLE AND NOT ANDROID)
|
|
foreach(MOBILEGL_LOADER_ALIAS
|
|
libEGL.so libEGL.so.1)
|
|
add_custom_command(TARGET ${CMAKE_PROJECT_NAME} POST_BUILD
|
|
COMMAND ${CMAKE_COMMAND} -E create_symlink
|
|
"$<TARGET_FILE_NAME:${CMAKE_PROJECT_NAME}>"
|
|
"$<TARGET_FILE_DIR:${CMAKE_PROJECT_NAME}>/${MOBILEGL_LOADER_ALIAS}"
|
|
COMMENT "Creating ${MOBILEGL_LOADER_ALIAS} alias for Linux GL/EGL loaders"
|
|
)
|
|
endforeach()
|
|
endif()
|
|
|
|
if(WIN32)
|
|
# Drop-in for the classic GL loader path: a copy named opengl32.dll placed
|
|
# next to a host executable is what LoadLibrary("opengl32.dll") and gdi32's
|
|
# pixel-format forwarding will resolve.
|
|
add_custom_command(TARGET ${CMAKE_PROJECT_NAME} POST_BUILD
|
|
COMMAND ${CMAKE_COMMAND} -E copy_if_different
|
|
"$<TARGET_FILE:${CMAKE_PROJECT_NAME}>"
|
|
"$<TARGET_FILE_DIR:${CMAKE_PROJECT_NAME}>/opengl32.dll"
|
|
COMMENT "Creating opengl32.dll drop-in copy"
|
|
)
|
|
endif()
|
|
|
|
if(NOT ANDROID)
|
|
add_library(${CMAKE_PROJECT_NAME}_s STATIC
|
|
${SOURCE_FILES}
|
|
)
|
|
|
|
if (CMAKE_BUILD_TYPE STREQUAL "Debug")
|
|
set_target_properties(${CMAKE_PROJECT_NAME}_s PROPERTIES
|
|
C_VISIBILITY_PRESET default
|
|
CXX_VISIBILITY_PRESET default
|
|
VISIBILITY_INLINES_HIDDEN OFF
|
|
)
|
|
else()
|
|
set_target_properties(${CMAKE_PROJECT_NAME}_s PROPERTIES
|
|
C_VISIBILITY_PRESET hidden
|
|
CXX_VISIBILITY_PRESET hidden
|
|
VISIBILITY_INLINES_HIDDEN ON
|
|
)
|
|
endif()
|
|
|
|
target_include_directories(${CMAKE_PROJECT_NAME}_s PUBLIC
|
|
${MOBILEGL_INCLUDE_DIR}
|
|
)
|
|
|
|
target_link_libraries(${CMAKE_PROJECT_NAME}_s
|
|
PUBLIC
|
|
${MOBILEGL_LINK_LIBRARIES}
|
|
)
|
|
|
|
target_compile_definitions(${CMAKE_PROJECT_NAME}_s
|
|
PUBLIC
|
|
${MOBILEGL_COMPILE_DEF}
|
|
MOBILEGL_LOG_ACTIVE_LEVEL=${MOBILEGL_LOG_ACTIVE_LEVEL}
|
|
)
|
|
endif()
|
|
|
|
if (TRACY_ENABLE)
|
|
target_link_libraries(${CMAKE_PROJECT_NAME} PUBLIC Tracy::TracyClient)
|
|
target_link_libraries(${CMAKE_PROJECT_NAME}_s PUBLIC Tracy::TracyClient)
|
|
target_compile_definitions(${CMAKE_PROJECT_NAME} PUBLIC -DTRACY_ENABLE)
|
|
target_compile_definitions(${CMAKE_PROJECT_NAME}_s PUBLIC -DTRACY_ENABLE)
|
|
endif ()
|
|
|
|
if (ANDROID)
|
|
target_link_libraries(${CMAKE_PROJECT_NAME} PUBLIC
|
|
android
|
|
log
|
|
vulkan
|
|
)
|
|
endif()
|
|
|
|
if (APPLE AND NOT MOBILEGL_IOS)
|
|
# MobileGL statically embeds glslang, SPIRV-Tools, and SPIRV-Cross. When
|
|
# this dylib is injected with DYLD_INSERT_LIBRARIES, exporting those C++
|
|
# symbols interposes incompatible copies embedded by host libraries such
|
|
# as shaderc. Keep only the public GL/EGL/CGL loader surface globally
|
|
# visible; GetProcAddress can still return pointers to hidden internals.
|
|
set(MOBILEGL_MACOS_EXPORTED_SYMBOLS
|
|
"${CMAKE_CURRENT_SOURCE_DIR}/MobileGL/MG_Impl/DyldInterpose/ExportedSymbols.txt")
|
|
target_link_options(${CMAKE_PROJECT_NAME} PRIVATE
|
|
"LINKER:-exported_symbols_list,${MOBILEGL_MACOS_EXPORTED_SYMBOLS}")
|
|
set_property(TARGET ${CMAKE_PROJECT_NAME} APPEND PROPERTY
|
|
LINK_DEPENDS "${MOBILEGL_MACOS_EXPORTED_SYMBOLS}")
|
|
|
|
target_link_libraries(${CMAKE_PROJECT_NAME} PUBLIC
|
|
"-framework Cocoa"
|
|
"-framework CoreVideo"
|
|
"-framework QuartzCore"
|
|
"-framework Foundation"
|
|
"-framework OpenGL"
|
|
objc)
|
|
if(TARGET ${CMAKE_PROJECT_NAME}_s)
|
|
target_link_libraries(${CMAKE_PROJECT_NAME}_s PUBLIC
|
|
"-framework Cocoa"
|
|
"-framework CoreVideo"
|
|
"-framework QuartzCore"
|
|
"-framework Foundation"
|
|
"-framework OpenGL"
|
|
objc)
|
|
endif()
|
|
endif()
|
|
|
|
if (APPLE AND MOBILEGL_IOS)
|
|
target_compile_definitions(${CMAKE_PROJECT_NAME} PUBLIC MOBILEGL_IOS=1 _LIBCPP_DISABLE_AVAILABILITY)
|
|
target_link_libraries(${CMAKE_PROJECT_NAME} PUBLIC
|
|
"-framework CoreGraphics"
|
|
"-framework Foundation"
|
|
"-framework QuartzCore"
|
|
objc)
|
|
if (MOBILEGL_VULKAN_LIBRARY)
|
|
target_link_libraries(${CMAKE_PROJECT_NAME} PUBLIC "${MOBILEGL_VULKAN_LIBRARY}")
|
|
endif()
|
|
|
|
if(TARGET ${CMAKE_PROJECT_NAME}_s)
|
|
target_compile_definitions(${CMAKE_PROJECT_NAME}_s PUBLIC MOBILEGL_IOS=1 _LIBCPP_DISABLE_AVAILABILITY)
|
|
target_link_libraries(${CMAKE_PROJECT_NAME}_s PUBLIC
|
|
"-framework CoreGraphics"
|
|
"-framework Foundation"
|
|
"-framework QuartzCore"
|
|
objc)
|
|
if (MOBILEGL_VULKAN_LIBRARY)
|
|
target_link_libraries(${CMAKE_PROJECT_NAME}_s PUBLIC "${MOBILEGL_VULKAN_LIBRARY}")
|
|
endif()
|
|
endif()
|
|
endif()
|
|
|
|
if (NOT ANDROID AND NOT MOBILEGL_IOS)
|
|
find_package(Vulkan)
|
|
if (Vulkan_FOUND)
|
|
target_link_libraries(${CMAKE_PROJECT_NAME} PUBLIC Vulkan::Vulkan Vulkan::Headers)
|
|
target_link_libraries(${CMAKE_PROJECT_NAME}_s PUBLIC Vulkan::Vulkan Vulkan::Headers)
|
|
target_include_directories(${CMAKE_PROJECT_NAME} PUBLIC ${Vulkan_INCLUDE_DIR})
|
|
target_include_directories(${CMAKE_PROJECT_NAME}_s PUBLIC ${Vulkan_INCLUDE_DIR})
|
|
endif ()
|
|
endif ()
|
|
|
|
if (NOT ANDROID)
|
|
# Enable testing in the top-level scope so a CTestTestfile.cmake is emitted
|
|
# at the build-tree root. This lets `ctest` be invoked from the top-level
|
|
# build directory (IDE "run all tests", CI) and discover every test in the
|
|
# subdirectories below, instead of having to descend into each
|
|
# MG_Test/MG_Benchmark subdirectory. Tests are tagged with CTest labels
|
|
# (unit / benchmark / integration), so e.g. `ctest -L unit` selects just
|
|
# the unit suite.
|
|
enable_testing()
|
|
|
|
if (MOBILEGL_BUILD_TEST)
|
|
add_subdirectory(MobileGL/MG_Test)
|
|
endif()
|
|
|
|
# After MG_Test so googletest is already available when the unit tests are
|
|
# built; the module fetches its own copy when they are not.
|
|
if (MOBILEGL_BUILD_INTEGRATION_TEST)
|
|
add_subdirectory(MobileGL/MG_IntegrationTest)
|
|
endif()
|
|
|
|
if (MOBILEGL_BUILD_BENCHMARK)
|
|
add_subdirectory(MobileGL/MG_Benchmark)
|
|
endif()
|
|
|
|
if (MOBILEGL_BUILD_TRACE_REPLAY)
|
|
add_subdirectory(tools/trace_replay)
|
|
endif()
|
|
endif()
|
|
|
|
# The integration binary is also useful as a standalone adb-shell executable.
|
|
# Android cannot use the desktop-only MobileGL_s target, so its CMake module
|
|
# links libMobileGL.so and creates an AImageReader-backed window instead.
|
|
if (ANDROID AND MOBILEGL_BUILD_INTEGRATION_TEST)
|
|
add_subdirectory(MobileGL/MG_IntegrationTest)
|
|
endif()
|