diff options
| author | Michael Lentine <mlentine@google.com> | 2015-09-09 12:39:13 -0700 |
|---|---|---|
| committer | Courtney Goeltzenleuchter <courtney@LunarG.com> | 2015-09-25 15:22:56 -0600 |
| commit | e82ce7a40f8c5c3fcc4abc8c3d80f8feea6de757 (patch) | |
| tree | 5981f7284432776c77f53c9fe5e75966b31cf0ee | |
| parent | 0d56d995eedbcef487851ea5e42bceddbf76eb53 (diff) | |
| download | usermoji-e82ce7a40f8c5c3fcc4abc8c3d80f8feea6de757.tar.xz | |
Make layers build on android.
| -rwxr-xr-x | buildAndroid/android-generate.sh | 28 | ||||
| -rw-r--r-- | buildAndroid/jni/Android.mk | 140 | ||||
| -rw-r--r-- | buildAndroid/jni/Application.mk | 20 | ||||
| -rw-r--r-- | layers/basic.cpp | 5 | ||||
| -rw-r--r-- | layers/vk_layer_config.cpp | 4 | ||||
| -rw-r--r-- | layers/vk_layer_debug_marker_table.h | 2 | ||||
| -rw-r--r-- | loader/vk_loader_platform.h | 12 | ||||
| -rw-r--r-- | loader/wsi_swapchain.c | 3 | ||||
| -rwxr-xr-x | vk-generate.py | 3 |
9 files changed, 203 insertions, 14 deletions
diff --git a/buildAndroid/android-generate.sh b/buildAndroid/android-generate.sh new file mode 100755 index 00000000..e1ee4d9b --- /dev/null +++ b/buildAndroid/android-generate.sh @@ -0,0 +1,28 @@ +#!/bin/bash + +# Copyright 2015 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. + +rm -rf generated +mkdir -p generated +python ../vk-generate.py dispatch-table-ops layer > generated/vk_dispatch_table_helper.h + +python ../vk_helper.py --gen_enum_string_helper ../include/vulkan.h --abs_out_dir generated +python ../vk_helper.py --gen_struct_wrappers ../include/vulkan.h --abs_out_dir generated + +python ../vk-layer-generate.py Generic ../include/vulkan.h > generated/generic_layer.cpp +python ../vk-layer-generate.py APIDump ../include/vulkan.h > generated/api_dump.cpp +python ../vk-layer-generate.py ObjectTracker ../include/vulkan.h > generated/object_track.cpp +python ../vk-layer-generate.py Threading ../include/vulkan.h > generated/threading.cpp + diff --git a/buildAndroid/jni/Android.mk b/buildAndroid/jni/Android.mk new file mode 100644 index 00000000..c9270f14 --- /dev/null +++ b/buildAndroid/jni/Android.mk @@ -0,0 +1,140 @@ +# Copyright 2015 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.
+
+LOCAL_PATH := $(abspath $(call my-dir))
+MY_PATH := $(LOCAL_PATH)
+SRC_DIR := $(LOCAL_PATH)/../../
+
+include $(CLEAR_VARS)
+LOCAL_MODULE := layer_utils
+LOCAL_SRC_FILES += $(SRC_DIR)/layers/vk_layer_config.cpp
+LOCAL_SRC_FILES += $(SRC_DIR)/layers/vk_layer_extension_utils.cpp
+LOCAL_C_INCLUDES += $(SRC_DIR)/include
+LOCAL_LDLIBS := -llog
+include $(BUILD_SHARED_LIBRARY)
+
+include $(CLEAR_VARS)
+LOCAL_MODULE := VKLayerBasic
+LOCAL_SRC_FILES += $(SRC_DIR)/layers/basic.cpp
+LOCAL_SRC_FILES += $(SRC_DIR)/layers/vk_layer_table.cpp
+LOCAL_C_INCLUDES += $(SRC_DIR)/include \
+ $(SRC_DIR)/buildAndroid/generated
+LOCAL_SHARED_LIBRARIES += layer_utils
+LOCAL_LDLIBS := -llog
+include $(BUILD_SHARED_LIBRARY)
+
+include $(CLEAR_VARS)
+LOCAL_MODULE := VKLayerDrawState
+LOCAL_SRC_FILES += $(SRC_DIR)/layers/draw_state.cpp
+LOCAL_SRC_FILES += $(SRC_DIR)/layers/vk_layer_debug_marker_table.cpp
+LOCAL_SRC_FILES += $(SRC_DIR)/layers/vk_layer_table.cpp
+LOCAL_C_INCLUDES += $(SRC_DIR)/include \
+ $(SRC_DIR)/buildAndroid/generated \
+ $(SRC_DIR)/loader
+LOCAL_SHARED_LIBRARIES += layer_utils
+LOCAL_LDLIBS := -llog
+include $(BUILD_SHARED_LIBRARY)
+
+include $(CLEAR_VARS)
+LOCAL_MODULE := VKLayerMemTracker
+LOCAL_SRC_FILES += $(SRC_DIR)/layers/mem_tracker.cpp
+LOCAL_SRC_FILES += $(SRC_DIR)/layers/vk_layer_table.cpp
+LOCAL_C_INCLUDES += $(SRC_DIR)/include \
+ $(SRC_DIR)/buildAndroid/generated \
+ $(SRC_DIR)/loader
+LOCAL_SHARED_LIBRARIES += layer_utils
+LOCAL_LDLIBS := -llog
+include $(BUILD_SHARED_LIBRARY)
+
+include $(CLEAR_VARS)
+LOCAL_MODULE := VKLayerShaderCheker
+LOCAL_SRC_FILES += $(SRC_DIR)/layers/shader_checker.cpp
+LOCAL_SRC_FILES += $(SRC_DIR)/layers/vk_layer_table.cpp
+LOCAL_C_INCLUDES += $(SRC_DIR)/include \
+ $(SRC_DIR)/buildAndroid/generated \
+ $(SRC_DIR)/loader
+LOCAL_SHARED_LIBRARIES += layer_utils
+LOCAL_LDLIBS := -llog
+include $(BUILD_SHARED_LIBRARY)
+
+include $(CLEAR_VARS)
+LOCAL_MODULE := VKLayerImage
+LOCAL_SRC_FILES += $(SRC_DIR)/layers/image.cpp
+LOCAL_SRC_FILES += $(SRC_DIR)/layers/vk_layer_table.cpp
+LOCAL_C_INCLUDES += $(SRC_DIR)/include \
+ $(SRC_DIR)/buildAndroid/generated \
+ $(SRC_DIR)/loader
+LOCAL_SHARED_LIBRARIES += layer_utils
+LOCAL_LDLIBS := -llog
+include $(BUILD_SHARED_LIBRARY)
+
+include $(CLEAR_VARS)
+LOCAL_MODULE := VKLayerParamChecker
+LOCAL_SRC_FILES += $(SRC_DIR)/layers/param_checker.cpp
+LOCAL_SRC_FILES += $(SRC_DIR)/layers/vk_layer_debug_marker_table.cpp
+LOCAL_SRC_FILES += $(SRC_DIR)/layers/vk_layer_table.cpp
+LOCAL_C_INCLUDES += $(SRC_DIR)/include \
+ $(SRC_DIR)/buildAndroid/generated \
+ $(SRC_DIR)/loader
+LOCAL_SHARED_LIBRARIES += layer_utils
+LOCAL_LDLIBS := -llog
+include $(BUILD_SHARED_LIBRARY)
+
+include $(CLEAR_VARS)
+LOCAL_MODULE := VKLayerGeneric
+LOCAL_SRC_FILES += $(SRC_DIR)/buildAndroid/generated/generic_layer.cpp
+LOCAL_SRC_FILES += $(SRC_DIR)/layers/vk_layer_table.cpp
+LOCAL_C_INCLUDES += $(SRC_DIR)/include \
+ $(SRC_DIR)/layers \
+ $(SRC_DIR)/buildAndroid/generated \
+ $(SRC_DIR)/loader
+LOCAL_SHARED_LIBRARIES += layer_utils
+LOCAL_LDLIBS := -llog
+include $(BUILD_SHARED_LIBRARY)
+
+include $(CLEAR_VARS)
+LOCAL_MODULE := VKLayerAPIDump
+LOCAL_SRC_FILES += $(SRC_DIR)/buildAndroid/generated/api_dump.cpp
+LOCAL_SRC_FILES += $(SRC_DIR)/layers/vk_layer_table.cpp
+LOCAL_C_INCLUDES += $(SRC_DIR)/include \
+ $(SRC_DIR)/layers \
+ $(SRC_DIR)/buildAndroid/generated \
+ $(SRC_DIR)/loader
+LOCAL_SHARED_LIBRARIES += layer_utils
+LOCAL_LDLIBS := -llog
+include $(BUILD_SHARED_LIBRARY)
+
+include $(CLEAR_VARS)
+LOCAL_MODULE := VKLayerObjectTracker
+LOCAL_SRC_FILES += $(SRC_DIR)/buildAndroid/generated/object_track.cpp
+LOCAL_SRC_FILES += $(SRC_DIR)/layers/vk_layer_table.cpp
+LOCAL_C_INCLUDES += $(SRC_DIR)/include \
+ $(SRC_DIR)/layers \
+ $(SRC_DIR)/buildAndroid/generated \
+ $(SRC_DIR)/loader
+LOCAL_SHARED_LIBRARIES += layer_utils
+LOCAL_LDLIBS := -llog
+include $(BUILD_SHARED_LIBRARY)
+
+include $(CLEAR_VARS)
+LOCAL_MODULE := VKLayerThreading
+LOCAL_SRC_FILES += $(SRC_DIR)/buildAndroid/generated/threading.cpp
+LOCAL_SRC_FILES += $(SRC_DIR)/layers/vk_layer_table.cpp
+LOCAL_C_INCLUDES += $(SRC_DIR)/include \
+ $(SRC_DIR)/layers \
+ $(SRC_DIR)/buildAndroid/generated \
+ $(SRC_DIR)/loader
+LOCAL_SHARED_LIBRARIES += layer_utils
+LOCAL_LDLIBS := -llog
+include $(BUILD_SHARED_LIBRARY)
diff --git a/buildAndroid/jni/Application.mk b/buildAndroid/jni/Application.mk new file mode 100644 index 00000000..492aa406 --- /dev/null +++ b/buildAndroid/jni/Application.mk @@ -0,0 +1,20 @@ +# Copyright 2015 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.
+
+APP_ABI := all
+APP_PLATFORM := android-22
+APP_STL := gnustl_static
+APP_MODULES := layer_utils VKLayerBasic VKLayerDrawState VKLayerMemTracker VKLayerShaderCheker VKLayerImage VKLayerParamChecker VKLayerGeneric VKLayerAPIDump VKLayerObjectTracker VKLayerThreading
+APP_CPPFLAGS += -std=c++11 -DVK_PROTOTYPES
+NDK_TOOLCHAIN_VERSION := 4.8
diff --git a/layers/basic.cpp b/layers/basic.cpp index 6a26542b..b90c0755 100644 --- a/layers/basic.cpp +++ b/layers/basic.cpp @@ -2,6 +2,7 @@ * Vulkan * * Copyright (C) 2014 LunarG, Inc. + * Copyright (C) 2015 Google Inc. * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), @@ -24,14 +25,10 @@ #include <string.h> #include <stdlib.h> #include <assert.h> -#include "vk_loader_platform.h" #include "vk_dispatch_table_helper.h" #include "vk_layer.h" #include "vk_layer_table.h" #include "vk_layer_extension_utils.h" -// The following is #included again to catch certain OS-specific functions -// being used: -#include "vk_loader_platform.h" static const VkLayerProperties globalLayerProps[] = { { diff --git a/layers/vk_layer_config.cpp b/layers/vk_layer_config.cpp index a4153ec3..e3b6d873 100644 --- a/layers/vk_layer_config.cpp +++ b/layers/vk_layer_config.cpp @@ -1,6 +1,7 @@ /************************************************************************** * * Copyright 2014 Lunarg, Inc. + * Copyright 2015 Google Inc. * All Rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a copy @@ -28,10 +29,7 @@ #include <string.h> #include <vk_layer.h> #include <iostream> -#include "vk_loader_platform.h" #include "vk_layer_config.h" -// The following is #included again to catch certain OS-specific functions -// being used: #include "vk_loader_platform.h" #define MAX_CHARS_PER_LINE 4096 diff --git a/layers/vk_layer_debug_marker_table.h b/layers/vk_layer_debug_marker_table.h index 48ef79c3..21cf15cc 100644 --- a/layers/vk_layer_debug_marker_table.h +++ b/layers/vk_layer_debug_marker_table.h @@ -2,6 +2,7 @@ * Vulkan * * Copyright (C) 2014 LunarG, Inc. + * Copyright (C) 2015 Google Inc. * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), @@ -23,6 +24,7 @@ */ #pragma once +#include <cassert> #include <unordered_map> extern std::unordered_map<void *, VkLayerDebugMarkerDispatchTable *> tableDebugMarkerMap; diff --git a/loader/vk_loader_platform.h b/loader/vk_loader_platform.h index 5001fe91..9a690f5f 100644 --- a/loader/vk_loader_platform.h +++ b/loader/vk_loader_platform.h @@ -3,6 +3,7 @@ * * Copyright (C) 2015 LunarG, Inc. * Copyright 2014 Valve Software + * Copyright (C) 2015 Google Inc. * All Rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a @@ -46,6 +47,7 @@ #include <pthread.h> #include <assert.h> #include <stdbool.h> +#include <stdlib.h> #include <libgen.h> // VK Library Filenames, Paths, etc.: @@ -127,7 +129,7 @@ static inline loader_platform_dl_handle loader_platform_open_library(const char* { return dlopen(libPath, RTLD_LAZY | RTLD_LOCAL); } -static inline char * loader_platform_open_library_error(const char* libPath) +static inline const char * loader_platform_open_library_error(const char* libPath) { return dlerror(); } @@ -142,7 +144,7 @@ static inline void * loader_platform_get_proc_address(loader_platform_dl_handle assert(name); return dlsym(library, name); } -static inline char * loader_platform_get_proc_address_error(const char *name) +static inline const char * loader_platform_get_proc_address_error(const char *name) { return dlerror(); } @@ -154,11 +156,11 @@ typedef pthread_t loader_platform_thread; pthread_once_t var = PTHREAD_ONCE_INIT; #define LOADER_PLATFORM_THREAD_ONCE_DEFINITION(var) \ pthread_once_t var; -static inline void loader_platform_thread_once(void *ctl, void (* func) (void)) +static inline void loader_platform_thread_once(pthread_once_t *ctl, void (* func) (void)) { assert(func != NULL); assert(ctl != NULL); - pthread_once((pthread_once_t *) ctl, func); + pthread_once(ctl, func); } // Thread IDs: @@ -201,7 +203,7 @@ static inline void loader_platform_thread_cond_broadcast(loader_platform_thread_ } #define loader_stack_alloc(size) alloca(size) -static inline void *loader_aligned_alloc(size_t alignment, size_t size) { return aligned_alloc(alignment, size); } +static inline void *loader_aligned_alloc(size_t alignment, size_t size) { void *ptr; posix_memalign(&ptr, alignment, size); return ptr; } #elif defined(_WIN32) // defined(__linux__) /* Windows-specific common code: */ diff --git a/loader/wsi_swapchain.c b/loader/wsi_swapchain.c index fc2fc995..19c917ed 100644 --- a/loader/wsi_swapchain.c +++ b/loader/wsi_swapchain.c @@ -27,7 +27,8 @@ * Ian Elliott <ian@lunarg.com> */ -#define _ISOC11_SOURCE /* for aligned_alloc() */ +//#define _ISOC11_SOURCE /* for aligned_alloc() */ +#define _GNU_SOURCE #include <stdlib.h> #include <string.h> #include "vk_loader_platform.h" diff --git a/vk-generate.py b/vk-generate.py index f5c23194..091450bc 100755 --- a/vk-generate.py +++ b/vk-generate.py @@ -3,6 +3,7 @@ # VK # # Copyright (C) 2014 LunarG, Inc. +# Copyright (C) 2015 Google Inc. # # Permission is hereby granted, free of charge, to any person obtaining a # copy of this software and associated documentation files (the "Software"), @@ -103,7 +104,7 @@ class DispatchTableOpsSubcommand(Subcommand): return self.prefix = self.argv[0] - super().run() + super(DispatchTableOpsSubcommand, self).run() def generate_header(self): return "\n".join(["#include <vulkan.h>", |
