diff --git a/CMakeLists.txt b/CMakeLists.txt index 8c53f0aa67..a3f5f2a1fb 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -355,6 +355,28 @@ function(list_licenses OUTPUT MODULES) configure_file(${FILAMENT}/build/licenses.inc.in ${OUTPUT}) endfunction(list_licenses) +set(COMBINE_SCRIPT "${CMAKE_CURRENT_SOURCE_DIR}/build/linux/combine-static-libs.sh") +if (WIN32) + set(COMBINE_SCRIPT "${CMAKE_CURRENT_SOURCE_DIR}/build/windows/combine-static-libs.bat") + set(CMAKE_AR "lib.exe") +endif() + +# Add a custom command to TARGET that combines the static libraries in DEPS into a single archive. +function(combine_static_libs TARGET OUTPUT DEPS) + # Loop through the dependent libraries and query their location on disk. + set(DEPS_FILES ) + foreach(DEPENDENCY ${DEPS}) + list(APPEND DEPS_FILES "$") + endforeach() + + add_custom_command( + TARGET ${TARGET} POST_BUILD + COMMAND "${COMBINE_SCRIPT}" "${CMAKE_AR}" "${OUTPUT}" ${DEPS_FILES} + COMMENT "Combining ${target} dependencies into single shared library" + VERBATIM + ) +endfunction() + # ================================================================================================== # Configuration for CMAKE_CROSSCOMPILING. # ================================================================================================== diff --git a/filament/backend/CMakeLists.txt b/filament/backend/CMakeLists.txt index ba229a0a5e..74736ac107 100644 --- a/filament/backend/CMakeLists.txt +++ b/filament/backend/CMakeLists.txt @@ -276,7 +276,9 @@ install(DIRECTORY ${PUBLIC_HDR_DIR}/backend DESTINATION include) # ================================================================================================== # Test # ================================================================================================== -if (APPLE AND NOT IOS) +option(INSTALL_BACKEND_TEST "Install the backend test library so it can be consumed on iOS" OFF) + +if (APPLE) add_library(backend_test STATIC test/BackendTest.cpp test/ShaderGenerator.cpp @@ -292,6 +294,34 @@ if (APPLE AND NOT IOS) SPIRV spirv-cross-glsl) + set(BACKEND_TEST_DEPS + OGLCompiler + OSDependent + SPIRV + SPIRV-Tools + SPIRV-Tools-opt + backend_test + filabridge + getopt + gtest + glslang + spirv-cross-core + spirv-cross-glsl + spirv-cross-msl + ) + + set(BACKEND_TEST_COMBINED_OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/libbackendtest_combined.a") + combine_static_libs(backend_test "${BACKEND_TEST_COMBINED_OUTPUT}" "${BACKEND_TEST_DEPS}") + + set(BACKEND_TEST_LIB_NAME ${CMAKE_STATIC_LIBRARY_PREFIX}backend_test${CMAKE_STATIC_LIBRARY_SUFFIX}) + + if (INSTALL_BACKEND_TEST) + install(FILES "${BACKEND_TEST_COMBINED_OUTPUT}" DESTINATION lib/${DIST_DIR} RENAME ${BACKEND_TEST_LIB_NAME}) + install(FILES test/PlatformRunner.h DESTINATION include/backend_test) + endif() +endif() + +if (APPLE AND NOT IOS) add_executable(backend_test_mac test/mac_runner.mm) target_link_libraries(backend_test_mac PRIVATE "-framework Metal -framework AppKit -framework QuartzCore") # Because each test case is a separate file, the -force_load flag is necessary to prevent the diff --git a/ios/samples/backend-test/.gitignore b/ios/samples/backend-test/.gitignore new file mode 100644 index 0000000000..bb81151f81 --- /dev/null +++ b/ios/samples/backend-test/.gitignore @@ -0,0 +1,4 @@ +## User settings +xcuserdata/ +/generated/ + diff --git a/ios/samples/backend-test/README.md b/ios/samples/backend-test/README.md new file mode 100644 index 0000000000..6257faf48d --- /dev/null +++ b/ios/samples/backend-test/README.md @@ -0,0 +1,23 @@ +# iOS `backend-test` App + +The `backend-test` app is capable of running unit tests defined in filament/backend/test on an iOS +device. These tests are designed to exercise `libbackend`, Filament's backend library. Tests are +written in files like `test_MissingRequiredAttributes.cpp`. Tests can call driver commands and +render one or more "frames" to invoke functionality. For example, the MissingRequireAttributes test +checks that backends can handle shaders with vertex attributes that aren't set in a renderable. + +In order to run the test cases on iOS, a library called `libbackendtest` must be built for iOS. +This library can be built by setting the `INSTALL_BACKEND_TEST` CMake flag to `ON`. For example, to +turn the flag on for iOS debug builds, + +``` +cd out/cmake-ios-debug-arm64/ +cmake . -DINSTALL_BACKEND_TEST=ON +cd ../.. +./build.sh -i -p ios debug +``` + +You can choose to run the test cases either under the OpenGL or Metal backend by choosing the +appropriate scheme inside the Xcode project. The --gtest_filter argument can be used to control +which test case is run (at the moment, running multiple tests causes some issues on some backends). +To set arguments in Xcode, navigate to Product -> Scheme -> Edit Scheme... -> Arguments. diff --git a/ios/samples/backend-test/backend-test.xcodeproj/project.pbxproj b/ios/samples/backend-test/backend-test.xcodeproj/project.pbxproj new file mode 100644 index 0000000000..a4e18fde9f --- /dev/null +++ b/ios/samples/backend-test/backend-test.xcodeproj/project.pbxproj @@ -0,0 +1,559 @@ +// !$*UTF8*$! +{ + archiveVersion = 1; + classes = { + }; + objectVersion = 50; + objects = { + +/* Begin PBXBuildFile section */ + 06F62A875BB41914867962C761A4EAF5 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 93394D7D4A78C56A2BD31A7DADD23EEF /* Assets.xcassets */; }; + 0D03CD8D532E395F541C52E2DC5CBA91 /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = EB0A767D257F3D05BE9F09604A637414 /* LaunchScreen.storyboard */; }; + 1F794C937765826F24F7B8659EDD39C9 /* main.mm in Sources */ = {isa = PBXBuildFile; fileRef = AE6C78F32A0494087B0CEF322CE9292D /* main.mm */; }; + 634497C6501716CB6CFF82691FED62B7 /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = B63A6E45E40F58037ABD8F849B42EB7E /* Main.storyboard */; }; + 803D9F3AEB828A38EE28952DB0D31801 /* FilamentView.mm in Sources */ = {isa = PBXBuildFile; fileRef = B54DFEB4DB6ACC0289FA3046C904A153 /* FilamentView.mm */; }; + 96A031DD8E9466AFA6FD2D0E7309191F /* ViewController.mm in Sources */ = {isa = PBXBuildFile; fileRef = 33D80A4472074C601C57C773916DF65F /* ViewController.mm */; }; + E5EB2FE4C23A5FE68F92D999D37E5680 /* AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 5FDB89AD408A508D6CB74C329C6C62CE /* AppDelegate.m */; }; +/* End PBXBuildFile section */ + +/* Begin PBXFileReference section */ + 056C16E7805E8D33D4C8F7B45A9CF4E1 /* FilamentView.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = FilamentView.h; sourceTree = ""; }; + 13DDE7723EC1A6EFCA4D2D582CC44EE8 /* backend-test.app */ = {isa = PBXFileReference; includeInIndex = 0; lastKnownFileType = wrapper.application; path = "backend-test.app"; sourceTree = BUILT_PRODUCTS_DIR; }; + 17364ECD407006EEBDC060249F28047C /* AppDelegate.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = AppDelegate.h; sourceTree = ""; }; + 276A0ADD5B521719BBB1DA21DA1FDFD2 /* ViewController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = ViewController.h; sourceTree = ""; }; + 33D80A4472074C601C57C773916DF65F /* ViewController.mm */ = {isa = PBXFileReference; path = ViewController.mm; sourceTree = ""; }; + 5FDB89AD408A508D6CB74C329C6C62CE /* AppDelegate.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = AppDelegate.m; sourceTree = ""; }; + 603475CEE63507AA04A9B21AB6D0022A /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = ""; }; + 93394D7D4A78C56A2BD31A7DADD23EEF /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; }; + A283B2D6DB365368855E2D7A1ADAE875 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; + AE6C78F32A0494087B0CEF322CE9292D /* main.mm */ = {isa = PBXFileReference; path = main.mm; sourceTree = ""; }; + B54DFEB4DB6ACC0289FA3046C904A153 /* FilamentView.mm */ = {isa = PBXFileReference; path = FilamentView.mm; sourceTree = ""; }; + C76230D48038E8109EC121B0B9D475C9 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = ""; }; +/* End PBXFileReference section */ + +/* Begin PBXGroup section */ + 05CA69F10D830E40A8FB561D4B3674F7 /* Products */ = { + isa = PBXGroup; + children = ( + 13DDE7723EC1A6EFCA4D2D582CC44EE8 /* backend-test.app */, + ); + name = Products; + sourceTree = ""; + }; + 3D2B936C924E0DB70941EE6D42812971 = { + isa = PBXGroup; + children = ( + FE198F0E1EF047534F8F3128409AFF7B /* backend-test */, + 05CA69F10D830E40A8FB561D4B3674F7 /* Products */, + ); + sourceTree = ""; + }; + FE198F0E1EF047534F8F3128409AFF7B /* backend-test */ = { + isa = PBXGroup; + children = ( + 17364ECD407006EEBDC060249F28047C /* AppDelegate.h */, + 5FDB89AD408A508D6CB74C329C6C62CE /* AppDelegate.m */, + 93394D7D4A78C56A2BD31A7DADD23EEF /* Assets.xcassets */, + 056C16E7805E8D33D4C8F7B45A9CF4E1 /* FilamentView.h */, + B54DFEB4DB6ACC0289FA3046C904A153 /* FilamentView.mm */, + A283B2D6DB365368855E2D7A1ADAE875 /* Info.plist */, + EB0A767D257F3D05BE9F09604A637414 /* LaunchScreen.storyboard */, + AE6C78F32A0494087B0CEF322CE9292D /* main.mm */, + B63A6E45E40F58037ABD8F849B42EB7E /* Main.storyboard */, + 276A0ADD5B521719BBB1DA21DA1FDFD2 /* ViewController.h */, + 33D80A4472074C601C57C773916DF65F /* ViewController.mm */, + ); + path = "backend-test"; + sourceTree = ""; + }; +/* End PBXGroup section */ + +/* Begin PBXNativeTarget section */ + 196E24C2A15DA6AE6F69371CA6A367C0 /* backend-test */ = { + isa = PBXNativeTarget; + buildConfigurationList = 61ACF592151E648A5C129A90463186B6 /* Build configuration list for PBXNativeTarget "backend-test" */; + buildPhases = ( + 445863ED54C294354A38828145EEC63F /* Sources */, + BD71575ED7ED3237FEFD94C714641FAE /* Resources */, + ); + buildRules = ( + ); + dependencies = ( + ); + name = "backend-test"; + productName = "backend-test"; + productReference = 13DDE7723EC1A6EFCA4D2D582CC44EE8 /* backend-test.app */; + productType = "com.apple.product-type.application"; + }; +/* End PBXNativeTarget section */ + +/* Begin PBXProject section */ + 8A7A83D59A7827D3335343C284020B80 /* Project object */ = { + isa = PBXProject; + attributes = { + LastUpgradeCheck = 1000; + }; + buildConfigurationList = E89E1EEA671E49DBAC9D5A9CB3D340A3 /* Build configuration list for PBXProject "backend-test" */; + compatibilityVersion = "Xcode 9.3"; + developmentRegion = en; + hasScannedForEncodings = 0; + knownRegions = ( + Base, + ); + mainGroup = 3D2B936C924E0DB70941EE6D42812971; + projectDirPath = ""; + projectRoot = ""; + targets = ( + 196E24C2A15DA6AE6F69371CA6A367C0 /* backend-test */, + ); + }; +/* End PBXProject section */ + +/* Begin PBXResourcesBuildPhase section */ + BD71575ED7ED3237FEFD94C714641FAE /* Resources */ = { + isa = PBXResourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 06F62A875BB41914867962C761A4EAF5 /* Assets.xcassets in Resources */, + 0D03CD8D532E395F541C52E2DC5CBA91 /* LaunchScreen.storyboard in Resources */, + 634497C6501716CB6CFF82691FED62B7 /* Main.storyboard in Resources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXResourcesBuildPhase section */ + +/* Begin PBXSourcesBuildPhase section */ + 445863ED54C294354A38828145EEC63F /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + E5EB2FE4C23A5FE68F92D999D37E5680 /* AppDelegate.m in Sources */, + 803D9F3AEB828A38EE28952DB0D31801 /* FilamentView.mm in Sources */, + 96A031DD8E9466AFA6FD2D0E7309191F /* ViewController.mm in Sources */, + 1F794C937765826F24F7B8659EDD39C9 /* main.mm in Sources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXSourcesBuildPhase section */ + +/* Begin PBXVariantGroup section */ + B63A6E45E40F58037ABD8F849B42EB7E /* Main.storyboard */ = { + isa = PBXVariantGroup; + children = ( + 603475CEE63507AA04A9B21AB6D0022A /* Base */, + ); + name = Main.storyboard; + sourceTree = ""; + }; + EB0A767D257F3D05BE9F09604A637414 /* LaunchScreen.storyboard */ = { + isa = PBXVariantGroup; + children = ( + C76230D48038E8109EC121B0B9D475C9 /* Base */, + ); + name = LaunchScreen.storyboard; + sourceTree = ""; + }; +/* End PBXVariantGroup section */ + +/* Begin XCBuildConfiguration section */ + 287974638C9ACB9CA9B2A8856FF3D23B /* OpenGL Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + CLANG_ANALYZER_NONNULL = YES; + CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++14"; + CLANG_CXX_LIBRARY = "libc++"; + CLANG_ENABLE_MODULES = YES; + CLANG_ENABLE_OBJC_ARC = YES; + CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; + CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_COMMA = YES; + CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; + CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; + CLANG_WARN_DOCUMENTATION_COMMENTS = YES; + CLANG_WARN_EMPTY_BODY = YES; + CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INFINITE_RECURSION = YES; + CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; + CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; + CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; + CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; + CLANG_WARN_STRICT_PROTOTYPES = YES; + CLANG_WARN_SUSPICIOUS_MOVE = YES; + CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; + CLANG_WARN_UNREACHABLE_CODE = YES; + CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; + COPY_PHASE_STRIP = NO; + DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; + ENABLE_NS_ASSERTIONS = NO; + ENABLE_STRICT_OBJC_MSGSEND = YES; + GCC_C_LANGUAGE_STANDARD = gnu11; + GCC_NO_COMMON_BLOCKS = YES; + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; + GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; + GCC_WARN_UNDECLARED_SELECTOR = YES; + GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; + GCC_WARN_UNUSED_FUNCTION = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + PRODUCT_NAME = "$(TARGET_NAME)"; + SDKROOT = iphoneos; + SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule"; + SWIFT_VERSION = 4.2; + VALIDATE_PRODUCT = YES; + }; + name = "OpenGL Release"; + }; + 404EBB73A7A0435C20EDBABCDFFD17E4 /* OpenGL Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES; + ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; + CODE_SIGN_IDENTITY = "iPhone Developer"; + ENABLE_BITCODE = NO; + GCC_PREPROCESSOR_DEFINITIONS = ( + "FILAMENT_APP_USE_OPENGL=1", + "$(inherited)", + ); + HEADER_SEARCH_PATHS = ( + "../../../out/ios-debug/filament/include", + generated, + ); + INFOPLIST_FILE = "backend-test/Info.plist"; + IPHONEOS_DEPLOYMENT_TARGET = 12.1; + LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; + LIBRARY_SEARCH_PATHS = ( + "../../../out/ios-debug/filament/lib/$(CURRENT_ARCH)", + ); + OTHER_LDFLAGS = ( + "-lfilament", + "-lbackend", + "-lfilaflat", + "-lfilabridge", + "-lutils", + "-lsmol-v", + "-lgeometry", + "-libl", + "-force_load ../../../out/ios-debug/filament/lib/arm64/libbackend_test.a", + ); + PRODUCT_BUNDLE_IDENTIFIER = "google.filament.backend-test"; + SDKROOT = iphoneos; + TARGETED_DEVICE_FAMILY = "1,2"; + }; + name = "OpenGL Debug"; + }; + 54FB1D2CF3B4145F58866014302FD0D5 /* OpenGL Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + CLANG_ANALYZER_NONNULL = YES; + CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++14"; + CLANG_CXX_LIBRARY = "libc++"; + CLANG_ENABLE_MODULES = YES; + CLANG_ENABLE_OBJC_ARC = YES; + CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; + CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_COMMA = YES; + CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; + CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; + CLANG_WARN_DOCUMENTATION_COMMENTS = YES; + CLANG_WARN_EMPTY_BODY = YES; + CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INFINITE_RECURSION = YES; + CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; + CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; + CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; + CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; + CLANG_WARN_STRICT_PROTOTYPES = YES; + CLANG_WARN_SUSPICIOUS_MOVE = YES; + CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; + CLANG_WARN_UNREACHABLE_CODE = YES; + CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; + COPY_PHASE_STRIP = NO; + DEBUG_INFORMATION_FORMAT = dwarf; + ENABLE_STRICT_OBJC_MSGSEND = YES; + ENABLE_TESTABILITY = YES; + GCC_C_LANGUAGE_STANDARD = gnu11; + GCC_DYNAMIC_NO_PIC = NO; + GCC_NO_COMMON_BLOCKS = YES; + GCC_OPTIMIZATION_LEVEL = 0; + GCC_PREPROCESSOR_DEFINITIONS = ( + "$(inherited)", + "DEBUG=1", + ); + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; + GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; + GCC_WARN_UNDECLARED_SELECTOR = YES; + GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; + GCC_WARN_UNUSED_FUNCTION = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + MTL_ENABLE_DEBUG_INFO = YES; + ONLY_ACTIVE_ARCH = YES; + PRODUCT_NAME = "$(TARGET_NAME)"; + SDKROOT = iphoneos; + SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG; + SWIFT_OPTIMIZATION_LEVEL = "-Onone"; + SWIFT_VERSION = 4.2; + }; + name = "OpenGL Debug"; + }; + 5FB1C7673AA0E8727E86B454231C277C /* OpenGL Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES; + ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; + CODE_SIGN_IDENTITY = "iPhone Developer"; + ENABLE_BITCODE = NO; + GCC_PREPROCESSOR_DEFINITIONS = ( + "FILAMENT_APP_USE_OPENGL=1", + "$(inherited)", + ); + HEADER_SEARCH_PATHS = ( + "../../../out/ios-release/filament/include", + generated, + ); + INFOPLIST_FILE = "backend-test/Info.plist"; + IPHONEOS_DEPLOYMENT_TARGET = 12.1; + LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; + LIBRARY_SEARCH_PATHS = ( + "../../../out/ios-release/filament/lib/$(CURRENT_ARCH)", + ); + OTHER_LDFLAGS = ( + "-lfilament", + "-lbackend", + "-lfilaflat", + "-lfilabridge", + "-lutils", + "-lsmol-v", + "-lgeometry", + "-libl", + "-force_load ../../../out/ios-debug/filament/lib/arm64/libbackend_test.a", + ); + PRODUCT_BUNDLE_IDENTIFIER = "google.filament.backend-test"; + SDKROOT = iphoneos; + TARGETED_DEVICE_FAMILY = "1,2"; + }; + name = "OpenGL Release"; + }; + 64581E4E9CA579C51C57F18835480C4A /* Metal Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + CLANG_ANALYZER_NONNULL = YES; + CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++14"; + CLANG_CXX_LIBRARY = "libc++"; + CLANG_ENABLE_MODULES = YES; + CLANG_ENABLE_OBJC_ARC = YES; + CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; + CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_COMMA = YES; + CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; + CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; + CLANG_WARN_DOCUMENTATION_COMMENTS = YES; + CLANG_WARN_EMPTY_BODY = YES; + CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INFINITE_RECURSION = YES; + CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; + CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; + CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; + CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; + CLANG_WARN_STRICT_PROTOTYPES = YES; + CLANG_WARN_SUSPICIOUS_MOVE = YES; + CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; + CLANG_WARN_UNREACHABLE_CODE = YES; + CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; + COPY_PHASE_STRIP = NO; + DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; + ENABLE_NS_ASSERTIONS = NO; + ENABLE_STRICT_OBJC_MSGSEND = YES; + GCC_C_LANGUAGE_STANDARD = gnu11; + GCC_NO_COMMON_BLOCKS = YES; + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; + GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; + GCC_WARN_UNDECLARED_SELECTOR = YES; + GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; + GCC_WARN_UNUSED_FUNCTION = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + PRODUCT_NAME = "$(TARGET_NAME)"; + SDKROOT = iphoneos; + SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule"; + SWIFT_VERSION = 4.2; + VALIDATE_PRODUCT = YES; + }; + name = "Metal Release"; + }; + 8889A14BBCF0426235E7B530000B3E08 /* Metal Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES; + ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; + CODE_SIGN_IDENTITY = "iPhone Developer"; + ENABLE_BITCODE = NO; + GCC_PREPROCESSOR_DEFINITIONS = ( + "FILAMENT_APP_USE_METAL=1", + "$(inherited)", + ); + HEADER_SEARCH_PATHS = ( + "../../../out/ios-debug/filament/include", + generated, + ); + INFOPLIST_FILE = "backend-test/Info.plist"; + IPHONEOS_DEPLOYMENT_TARGET = 12.1; + LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; + LIBRARY_SEARCH_PATHS = ( + "../../../out/ios-debug/filament/lib/$(CURRENT_ARCH)", + ); + OTHER_LDFLAGS = ( + "-lfilament", + "-lbackend", + "-lfilaflat", + "-lfilabridge", + "-lutils", + "-lsmol-v", + "-lgeometry", + "-libl", + "-force_load ../../../out/ios-debug/filament/lib/arm64/libbackend_test.a", + ); + PRODUCT_BUNDLE_IDENTIFIER = "google.filament.backend-test"; + SDKROOT = iphoneos; + TARGETED_DEVICE_FAMILY = "1,2"; + }; + name = "Metal Debug"; + }; + 984F4F20FD3DBCD92D4F129047C6DFDC /* Metal Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES; + ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; + CODE_SIGN_IDENTITY = "iPhone Developer"; + ENABLE_BITCODE = NO; + GCC_PREPROCESSOR_DEFINITIONS = ( + "FILAMENT_APP_USE_METAL=1", + "$(inherited)", + ); + HEADER_SEARCH_PATHS = ( + "../../../out/ios-release/filament/include", + generated, + ); + INFOPLIST_FILE = "backend-test/Info.plist"; + IPHONEOS_DEPLOYMENT_TARGET = 12.1; + LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; + LIBRARY_SEARCH_PATHS = ( + "../../../out/ios-release/filament/lib/$(CURRENT_ARCH)", + ); + OTHER_LDFLAGS = ( + "-lfilament", + "-lbackend", + "-lfilaflat", + "-lfilabridge", + "-lutils", + "-lsmol-v", + "-lgeometry", + "-libl", + "-force_load ../../../out/ios-debug/filament/lib/arm64/libbackend_test.a", + ); + PRODUCT_BUNDLE_IDENTIFIER = "google.filament.backend-test"; + SDKROOT = iphoneos; + TARGETED_DEVICE_FAMILY = "1,2"; + }; + name = "Metal Release"; + }; + BE208AFFD31FF6385AFB77E166A4A211 /* Metal Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + CLANG_ANALYZER_NONNULL = YES; + CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++14"; + CLANG_CXX_LIBRARY = "libc++"; + CLANG_ENABLE_MODULES = YES; + CLANG_ENABLE_OBJC_ARC = YES; + CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; + CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_COMMA = YES; + CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; + CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; + CLANG_WARN_DOCUMENTATION_COMMENTS = YES; + CLANG_WARN_EMPTY_BODY = YES; + CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INFINITE_RECURSION = YES; + CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; + CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; + CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; + CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; + CLANG_WARN_STRICT_PROTOTYPES = YES; + CLANG_WARN_SUSPICIOUS_MOVE = YES; + CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; + CLANG_WARN_UNREACHABLE_CODE = YES; + CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; + COPY_PHASE_STRIP = NO; + DEBUG_INFORMATION_FORMAT = dwarf; + ENABLE_STRICT_OBJC_MSGSEND = YES; + ENABLE_TESTABILITY = YES; + GCC_C_LANGUAGE_STANDARD = gnu11; + GCC_DYNAMIC_NO_PIC = NO; + GCC_NO_COMMON_BLOCKS = YES; + GCC_OPTIMIZATION_LEVEL = 0; + GCC_PREPROCESSOR_DEFINITIONS = ( + "$(inherited)", + "DEBUG=1", + ); + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; + GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; + GCC_WARN_UNDECLARED_SELECTOR = YES; + GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; + GCC_WARN_UNUSED_FUNCTION = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + MTL_ENABLE_DEBUG_INFO = YES; + ONLY_ACTIVE_ARCH = YES; + PRODUCT_NAME = "$(TARGET_NAME)"; + SDKROOT = iphoneos; + SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG; + SWIFT_OPTIMIZATION_LEVEL = "-Onone"; + SWIFT_VERSION = 4.2; + }; + name = "Metal Debug"; + }; +/* End XCBuildConfiguration section */ + +/* Begin XCConfigurationList section */ + 61ACF592151E648A5C129A90463186B6 /* Build configuration list for PBXNativeTarget "backend-test" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 8889A14BBCF0426235E7B530000B3E08 /* Metal Debug */, + 984F4F20FD3DBCD92D4F129047C6DFDC /* Metal Release */, + 404EBB73A7A0435C20EDBABCDFFD17E4 /* OpenGL Debug */, + 5FB1C7673AA0E8727E86B454231C277C /* OpenGL Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = ""; + }; + E89E1EEA671E49DBAC9D5A9CB3D340A3 /* Build configuration list for PBXProject "backend-test" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + BE208AFFD31FF6385AFB77E166A4A211 /* Metal Debug */, + 64581E4E9CA579C51C57F18835480C4A /* Metal Release */, + 54FB1D2CF3B4145F58866014302FD0D5 /* OpenGL Debug */, + 287974638C9ACB9CA9B2A8856FF3D23B /* OpenGL Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = "Metal Debug"; + }; +/* End XCConfigurationList section */ + }; + rootObject = 8A7A83D59A7827D3335343C284020B80 /* Project object */; +} diff --git a/ios/samples/backend-test/backend-test.xcodeproj/project.xcworkspace/contents.xcworkspacedata b/ios/samples/backend-test/backend-test.xcodeproj/project.xcworkspace/contents.xcworkspacedata new file mode 100644 index 0000000000..919434a625 --- /dev/null +++ b/ios/samples/backend-test/backend-test.xcodeproj/project.xcworkspace/contents.xcworkspacedata @@ -0,0 +1,7 @@ + + + + + diff --git a/ios/samples/backend-test/backend-test.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist b/ios/samples/backend-test/backend-test.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist new file mode 100644 index 0000000000..18d981003d --- /dev/null +++ b/ios/samples/backend-test/backend-test.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist @@ -0,0 +1,8 @@ + + + + + IDEDidComputeMac32BitWarning + + + diff --git a/ios/samples/backend-test/backend-test.xcodeproj/xcshareddata/xcschemes/backend-test Metal.xcscheme b/ios/samples/backend-test/backend-test.xcodeproj/xcshareddata/xcschemes/backend-test Metal.xcscheme new file mode 100644 index 0000000000..8d9c57f970 --- /dev/null +++ b/ios/samples/backend-test/backend-test.xcodeproj/xcshareddata/xcschemes/backend-test Metal.xcscheme @@ -0,0 +1,97 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/ios/samples/backend-test/backend-test.xcodeproj/xcshareddata/xcschemes/backend-test OpenGL.xcscheme b/ios/samples/backend-test/backend-test.xcodeproj/xcshareddata/xcschemes/backend-test OpenGL.xcscheme new file mode 100644 index 0000000000..f4a58fad4a --- /dev/null +++ b/ios/samples/backend-test/backend-test.xcodeproj/xcshareddata/xcschemes/backend-test OpenGL.xcscheme @@ -0,0 +1,97 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/ios/samples/backend-test/backend-test/AppDelegate.h b/ios/samples/backend-test/backend-test/AppDelegate.h new file mode 100644 index 0000000000..6f34e3baa2 --- /dev/null +++ b/ios/samples/backend-test/backend-test/AppDelegate.h @@ -0,0 +1,23 @@ +/* + * Copyright (C) 2019 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#import + +@interface AppDelegate : UIResponder + +@property (strong, nonatomic) UIWindow* window; + +@end diff --git a/ios/samples/backend-test/backend-test/AppDelegate.m b/ios/samples/backend-test/backend-test/AppDelegate.m new file mode 100644 index 0000000000..a4e4e576ce --- /dev/null +++ b/ios/samples/backend-test/backend-test/AppDelegate.m @@ -0,0 +1,25 @@ +/* + * Copyright (C) 2019 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#import "AppDelegate.h" + +@interface AppDelegate () + +@end + +@implementation AppDelegate + +@end diff --git a/ios/samples/backend-test/backend-test/Assets.xcassets/AppIcon.appiconset/Contents.json b/ios/samples/backend-test/backend-test/Assets.xcassets/AppIcon.appiconset/Contents.json new file mode 100644 index 0000000000..d8db8d65fd --- /dev/null +++ b/ios/samples/backend-test/backend-test/Assets.xcassets/AppIcon.appiconset/Contents.json @@ -0,0 +1,98 @@ +{ + "images" : [ + { + "idiom" : "iphone", + "size" : "20x20", + "scale" : "2x" + }, + { + "idiom" : "iphone", + "size" : "20x20", + "scale" : "3x" + }, + { + "idiom" : "iphone", + "size" : "29x29", + "scale" : "2x" + }, + { + "idiom" : "iphone", + "size" : "29x29", + "scale" : "3x" + }, + { + "idiom" : "iphone", + "size" : "40x40", + "scale" : "2x" + }, + { + "idiom" : "iphone", + "size" : "40x40", + "scale" : "3x" + }, + { + "idiom" : "iphone", + "size" : "60x60", + "scale" : "2x" + }, + { + "idiom" : "iphone", + "size" : "60x60", + "scale" : "3x" + }, + { + "idiom" : "ipad", + "size" : "20x20", + "scale" : "1x" + }, + { + "idiom" : "ipad", + "size" : "20x20", + "scale" : "2x" + }, + { + "idiom" : "ipad", + "size" : "29x29", + "scale" : "1x" + }, + { + "idiom" : "ipad", + "size" : "29x29", + "scale" : "2x" + }, + { + "idiom" : "ipad", + "size" : "40x40", + "scale" : "1x" + }, + { + "idiom" : "ipad", + "size" : "40x40", + "scale" : "2x" + }, + { + "idiom" : "ipad", + "size" : "76x76", + "scale" : "1x" + }, + { + "idiom" : "ipad", + "size" : "76x76", + "scale" : "2x" + }, + { + "idiom" : "ipad", + "size" : "83.5x83.5", + "scale" : "2x" + }, + { + "idiom" : "ios-marketing", + "size" : "1024x1024", + "scale" : "1x" + } + ], + "info" : { + "version" : 1, + "author" : "xcode" + } +} \ No newline at end of file diff --git a/ios/samples/backend-test/backend-test/Assets.xcassets/Contents.json b/ios/samples/backend-test/backend-test/Assets.xcassets/Contents.json new file mode 100644 index 0000000000..da4a164c91 --- /dev/null +++ b/ios/samples/backend-test/backend-test/Assets.xcassets/Contents.json @@ -0,0 +1,6 @@ +{ + "info" : { + "version" : 1, + "author" : "xcode" + } +} \ No newline at end of file diff --git a/ios/samples/backend-test/backend-test/Base.lproj/LaunchScreen.storyboard b/ios/samples/backend-test/backend-test/Base.lproj/LaunchScreen.storyboard new file mode 100644 index 0000000000..bfa3612941 --- /dev/null +++ b/ios/samples/backend-test/backend-test/Base.lproj/LaunchScreen.storyboard @@ -0,0 +1,25 @@ + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/ios/samples/backend-test/backend-test/Base.lproj/Main.storyboard b/ios/samples/backend-test/backend-test/Base.lproj/Main.storyboard new file mode 100644 index 0000000000..a4eb46df67 --- /dev/null +++ b/ios/samples/backend-test/backend-test/Base.lproj/Main.storyboard @@ -0,0 +1,27 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/ios/samples/backend-test/backend-test/FilamentView.h b/ios/samples/backend-test/backend-test/FilamentView.h new file mode 100644 index 0000000000..1b3426829e --- /dev/null +++ b/ios/samples/backend-test/backend-test/FilamentView.h @@ -0,0 +1,21 @@ +/* + * Copyright (C) 2019 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#import + +@interface FilamentView : UIView + +@end diff --git a/ios/samples/backend-test/backend-test/FilamentView.mm b/ios/samples/backend-test/backend-test/FilamentView.mm new file mode 100644 index 0000000000..744cafc95f --- /dev/null +++ b/ios/samples/backend-test/backend-test/FilamentView.mm @@ -0,0 +1,61 @@ +/* + * Copyright (C) 2019 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#import "FilamentView.h" + +#import + +@implementation FilamentView + +- (instancetype)initWithCoder:(NSCoder*)coder +{ + if (self = [super initWithCoder:coder]) { +#if FILAMENT_APP_USE_METAL + [self initializeMetalLayer]; +#elif FILAMENT_APP_USE_OPENGL + [self initializeGlLayer]; +#endif + self.contentScaleFactor = UIScreen.mainScreen.nativeScale; + } + + return self; +} + +- (void)initializeMetalLayer +{ + CAMetalLayer* metalLayer = (CAMetalLayer*) self.layer; + metalLayer.pixelFormat = MTLPixelFormatBGRA8Unorm; + + CGRect nativeBounds = [UIScreen mainScreen].nativeBounds; + metalLayer.drawableSize = nativeBounds.size; +} + +- (void)initializeGlLayer +{ + CAEAGLLayer* glLayer = (CAEAGLLayer*) self.layer; + glLayer.opaque = YES; +} + ++ (Class) layerClass +{ +#if FILAMENT_APP_USE_OPENGL + return [CAEAGLLayer class]; +#elif FILAMENT_APP_USE_METAL + return [CAMetalLayer class]; +#endif +} + +@end diff --git a/ios/samples/backend-test/backend-test/Info.plist b/ios/samples/backend-test/backend-test/Info.plist new file mode 100644 index 0000000000..16be3b6811 --- /dev/null +++ b/ios/samples/backend-test/backend-test/Info.plist @@ -0,0 +1,45 @@ + + + + + CFBundleDevelopmentRegion + $(DEVELOPMENT_LANGUAGE) + CFBundleExecutable + $(EXECUTABLE_NAME) + CFBundleIdentifier + $(PRODUCT_BUNDLE_IDENTIFIER) + CFBundleInfoDictionaryVersion + 6.0 + CFBundleName + $(PRODUCT_NAME) + CFBundlePackageType + APPL + CFBundleShortVersionString + 1.0 + CFBundleVersion + 1 + LSRequiresIPhoneOS + + UILaunchStoryboardName + LaunchScreen + UIMainStoryboardFile + Main + UIRequiredDeviceCapabilities + + armv7 + + UISupportedInterfaceOrientations + + UIInterfaceOrientationPortrait + UIInterfaceOrientationLandscapeLeft + UIInterfaceOrientationLandscapeRight + + UISupportedInterfaceOrientations~ipad + + UIInterfaceOrientationPortrait + UIInterfaceOrientationPortraitUpsideDown + UIInterfaceOrientationLandscapeLeft + UIInterfaceOrientationLandscapeRight + + + diff --git a/ios/samples/backend-test/backend-test/ViewController.h b/ios/samples/backend-test/backend-test/ViewController.h new file mode 100644 index 0000000000..37a2a6f2b6 --- /dev/null +++ b/ios/samples/backend-test/backend-test/ViewController.h @@ -0,0 +1,21 @@ +/* + * Copyright (C) 2019 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#import + +@interface ViewController : UIViewController + +@end diff --git a/ios/samples/backend-test/backend-test/ViewController.mm b/ios/samples/backend-test/backend-test/ViewController.mm new file mode 100644 index 0000000000..d8c864d2bb --- /dev/null +++ b/ios/samples/backend-test/backend-test/ViewController.mm @@ -0,0 +1,63 @@ +/* + * Copyright (C) 2019 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#import "ViewController.h" + +#include + +static test::NativeView nativeView; + +namespace test { + +NativeView getNativeView() { + return nativeView; +} + +} // namespace test + +@interface ViewController () + +@end + +@implementation ViewController + +- (BOOL)shouldAutorotate +{ + return NO; +} + +- (void)viewDidAppear:(BOOL)animated +{ + [super viewDidAppear:animated]; + + nativeView.ptr = (__bridge void*) self.view.layer; + CGRect nativeBounds = [UIScreen mainScreen].nativeBounds; + nativeView.height = nativeBounds.size.height; + nativeView.width = nativeBounds.size.width; + + /* + OpenGL doesn't have programatic debugger capture on iOS. Instead, the following can be used to initiate + a frame capture before tests are run. + + NSLog(@"Pausing to allow starting frame capture..."); + sleep(5); + */ + + int result = test::runTests(); + NSLog(@"Tests ran with result: %d", result); +} + +@end diff --git a/ios/samples/backend-test/backend-test/main.mm b/ios/samples/backend-test/backend-test/main.mm new file mode 100644 index 0000000000..25601bc4b7 --- /dev/null +++ b/ios/samples/backend-test/backend-test/main.mm @@ -0,0 +1,32 @@ +/* + * Copyright (C) 2019 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#import +#import "AppDelegate.h" + +#include + +int main(int argc, char* argv[]) { + @autoreleasepool { +#if FILAMENT_APP_USE_METAL + test::Backend backend = test::Backend::METAL; +#elif FILAMENT_APP_USE_OPENGL + test::Backend backend = test::Backend::OPENGL; +#endif + test::initTests(backend, true, argc, argv); + return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class])); + } +} diff --git a/ios/samples/backend-test/project.yml b/ios/samples/backend-test/project.yml new file mode 100644 index 0000000000..74333f23eb --- /dev/null +++ b/ios/samples/backend-test/project.yml @@ -0,0 +1,13 @@ +name: backend-test +options: + bundleIdPrefix: google.filament +include: ../app-template.yml +targets: + backend-test: + templates: + - FilamentApp + settings: + base: + # Because each test case is a separate file, the -force_load flag is necessary to prevent the + # linker from removing "unused" symbols. + OTHER_LDFLAGS: ["-force_load ../../../out/ios-debug/filament/lib/arm64/libbackend_test.a"] diff --git a/libs/filamat/CMakeLists.txt b/libs/filamat/CMakeLists.txt index c118b8fdd4..6d2868f902 100644 --- a/libs/filamat/CMakeLists.txt +++ b/libs/filamat/CMakeLists.txt @@ -151,25 +151,8 @@ set(FILAMAT_DEPS spirv-cross-msl ) -# Loop through the dependent libraries and query their location on disk. -set(FILAMAT_DEPS_FILES ) -foreach(DEPENDENCY ${FILAMAT_DEPS}) - list(APPEND FILAMAT_DEPS_FILES "$") -endforeach() - -# Run the combine-static-libs script to bundle the libraries together. set(FILAMAT_COMBINED_OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/libfilamat_combined.a") -set(COMBINE_SCRIPT "${CMAKE_CURRENT_SOURCE_DIR}/../../build/linux/combine-static-libs.sh") -if (WIN32) - set(COMBINE_SCRIPT "${CMAKE_CURRENT_SOURCE_DIR}/../../build/windows/combine-static-libs.bat") - set(CMAKE_AR "lib.exe") -endif() -add_custom_command( - TARGET filamat POST_BUILD - COMMAND "${COMBINE_SCRIPT}" "${CMAKE_AR}" "${FILAMAT_COMBINED_OUTPUT}" ${FILAMAT_DEPS_FILES} - COMMENT "Combining filamat dependencies into single shared library" - VERBATIM -) +combine_static_libs(filamat "${FILAMAT_COMBINED_OUTPUT}" "${FILAMAT_DEPS}") set(FILAMAT_LIB_NAME ${CMAKE_STATIC_LIBRARY_PREFIX}filamat${CMAKE_STATIC_LIBRARY_SUFFIX}) install(FILES "${FILAMAT_COMBINED_OUTPUT}" DESTINATION lib/${DIST_DIR} RENAME ${FILAMAT_LIB_NAME})