Make layers build on android.
authorMichael Lentine <mlentine@google.com>
Wed, 9 Sep 2015 19:39:13 +0000 (12:39 -0700)
committerCourtney Goeltzenleuchter <courtney@LunarG.com>
Fri, 25 Sep 2015 21:22:56 +0000 (15:22 -0600)
buildAndroid/android-generate.sh [new file with mode: 0755]
buildAndroid/jni/Android.mk [new file with mode: 0644]
buildAndroid/jni/Application.mk [new file with mode: 0644]
layers/basic.cpp
layers/vk_layer_config.cpp
layers/vk_layer_debug_marker_table.h
loader/vk_loader_platform.h
loader/wsi_swapchain.c
vk-generate.py

diff --git a/buildAndroid/android-generate.sh b/buildAndroid/android-generate.sh
new file mode 100755 (executable)
index 0000000..e1ee4d9
--- /dev/null
@@ -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 (file)
index 0000000..c9270f1
--- /dev/null
@@ -0,0 +1,140 @@
+# Copyright 2015 The Android Open Source Project\r
+\r
+# Licensed under the Apache License, Version 2.0 (the "License");\r
+# you may not use this file except in compliance with the License.\r
+# You may obtain a copy of the License at\r
+\r
+#      http://www.apache.org/licenses/LICENSE-2.0\r
+\r
+# Unless required by applicable law or agreed to in writing, software\r
+# distributed under the License is distributed on an "AS IS" BASIS,\r
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+# See the License for the specific language governing permissions and\r
+# limitations under the License.\r
+\r
+LOCAL_PATH := $(abspath $(call my-dir))\r
+MY_PATH := $(LOCAL_PATH)\r
+SRC_DIR := $(LOCAL_PATH)/../../\r
+\r
+include $(CLEAR_VARS)\r
+LOCAL_MODULE := layer_utils\r
+LOCAL_SRC_FILES += $(SRC_DIR)/layers/vk_layer_config.cpp\r
+LOCAL_SRC_FILES += $(SRC_DIR)/layers/vk_layer_extension_utils.cpp\r
+LOCAL_C_INCLUDES += $(SRC_DIR)/include\r
+LOCAL_LDLIBS    := -llog\r
+include $(BUILD_SHARED_LIBRARY)\r
+\r
+include $(CLEAR_VARS)\r
+LOCAL_MODULE := VKLayerBasic\r
+LOCAL_SRC_FILES += $(SRC_DIR)/layers/basic.cpp\r
+LOCAL_SRC_FILES += $(SRC_DIR)/layers/vk_layer_table.cpp\r
+LOCAL_C_INCLUDES += $(SRC_DIR)/include \\r
+                   $(SRC_DIR)/buildAndroid/generated\r
+LOCAL_SHARED_LIBRARIES += layer_utils\r
+LOCAL_LDLIBS    := -llog\r
+include $(BUILD_SHARED_LIBRARY)\r
+\r
+include $(CLEAR_VARS)\r
+LOCAL_MODULE := VKLayerDrawState\r
+LOCAL_SRC_FILES += $(SRC_DIR)/layers/draw_state.cpp\r
+LOCAL_SRC_FILES += $(SRC_DIR)/layers/vk_layer_debug_marker_table.cpp\r
+LOCAL_SRC_FILES += $(SRC_DIR)/layers/vk_layer_table.cpp\r
+LOCAL_C_INCLUDES += $(SRC_DIR)/include \\r
+                   $(SRC_DIR)/buildAndroid/generated \\r
+                   $(SRC_DIR)/loader\r
+LOCAL_SHARED_LIBRARIES += layer_utils\r
+LOCAL_LDLIBS    := -llog\r
+include $(BUILD_SHARED_LIBRARY)\r
+\r
+include $(CLEAR_VARS)\r
+LOCAL_MODULE := VKLayerMemTracker\r
+LOCAL_SRC_FILES += $(SRC_DIR)/layers/mem_tracker.cpp\r
+LOCAL_SRC_FILES += $(SRC_DIR)/layers/vk_layer_table.cpp\r
+LOCAL_C_INCLUDES += $(SRC_DIR)/include \\r
+                   $(SRC_DIR)/buildAndroid/generated \\r
+                   $(SRC_DIR)/loader\r
+LOCAL_SHARED_LIBRARIES += layer_utils\r
+LOCAL_LDLIBS    := -llog\r
+include $(BUILD_SHARED_LIBRARY)\r
+\r
+include $(CLEAR_VARS)\r
+LOCAL_MODULE := VKLayerShaderCheker\r
+LOCAL_SRC_FILES += $(SRC_DIR)/layers/shader_checker.cpp\r
+LOCAL_SRC_FILES += $(SRC_DIR)/layers/vk_layer_table.cpp\r
+LOCAL_C_INCLUDES += $(SRC_DIR)/include \\r
+                   $(SRC_DIR)/buildAndroid/generated \\r
+                   $(SRC_DIR)/loader\r
+LOCAL_SHARED_LIBRARIES += layer_utils\r
+LOCAL_LDLIBS    := -llog\r
+include $(BUILD_SHARED_LIBRARY)\r
+\r
+include $(CLEAR_VARS)\r
+LOCAL_MODULE := VKLayerImage\r
+LOCAL_SRC_FILES += $(SRC_DIR)/layers/image.cpp\r
+LOCAL_SRC_FILES += $(SRC_DIR)/layers/vk_layer_table.cpp\r
+LOCAL_C_INCLUDES += $(SRC_DIR)/include \\r
+                   $(SRC_DIR)/buildAndroid/generated \\r
+                   $(SRC_DIR)/loader\r
+LOCAL_SHARED_LIBRARIES += layer_utils\r
+LOCAL_LDLIBS    := -llog\r
+include $(BUILD_SHARED_LIBRARY)\r
+\r
+include $(CLEAR_VARS)\r
+LOCAL_MODULE := VKLayerParamChecker\r
+LOCAL_SRC_FILES += $(SRC_DIR)/layers/param_checker.cpp\r
+LOCAL_SRC_FILES += $(SRC_DIR)/layers/vk_layer_debug_marker_table.cpp\r
+LOCAL_SRC_FILES += $(SRC_DIR)/layers/vk_layer_table.cpp\r
+LOCAL_C_INCLUDES += $(SRC_DIR)/include \\r
+                   $(SRC_DIR)/buildAndroid/generated \\r
+                   $(SRC_DIR)/loader\r
+LOCAL_SHARED_LIBRARIES += layer_utils\r
+LOCAL_LDLIBS    := -llog\r
+include $(BUILD_SHARED_LIBRARY)\r
+\r
+include $(CLEAR_VARS)\r
+LOCAL_MODULE := VKLayerGeneric\r
+LOCAL_SRC_FILES += $(SRC_DIR)/buildAndroid/generated/generic_layer.cpp\r
+LOCAL_SRC_FILES += $(SRC_DIR)/layers/vk_layer_table.cpp\r
+LOCAL_C_INCLUDES += $(SRC_DIR)/include \\r
+                   $(SRC_DIR)/layers \\r
+                   $(SRC_DIR)/buildAndroid/generated \\r
+                   $(SRC_DIR)/loader\r
+LOCAL_SHARED_LIBRARIES += layer_utils\r
+LOCAL_LDLIBS    := -llog\r
+include $(BUILD_SHARED_LIBRARY)\r
+\r
+include $(CLEAR_VARS)\r
+LOCAL_MODULE := VKLayerAPIDump\r
+LOCAL_SRC_FILES += $(SRC_DIR)/buildAndroid/generated/api_dump.cpp\r
+LOCAL_SRC_FILES += $(SRC_DIR)/layers/vk_layer_table.cpp\r
+LOCAL_C_INCLUDES += $(SRC_DIR)/include \\r
+                   $(SRC_DIR)/layers \\r
+                   $(SRC_DIR)/buildAndroid/generated \\r
+                   $(SRC_DIR)/loader\r
+LOCAL_SHARED_LIBRARIES += layer_utils\r
+LOCAL_LDLIBS    := -llog\r
+include $(BUILD_SHARED_LIBRARY)\r
+\r
+include $(CLEAR_VARS)\r
+LOCAL_MODULE := VKLayerObjectTracker\r
+LOCAL_SRC_FILES += $(SRC_DIR)/buildAndroid/generated/object_track.cpp\r
+LOCAL_SRC_FILES += $(SRC_DIR)/layers/vk_layer_table.cpp\r
+LOCAL_C_INCLUDES += $(SRC_DIR)/include \\r
+                   $(SRC_DIR)/layers \\r
+                   $(SRC_DIR)/buildAndroid/generated \\r
+                   $(SRC_DIR)/loader\r
+LOCAL_SHARED_LIBRARIES += layer_utils\r
+LOCAL_LDLIBS    := -llog\r
+include $(BUILD_SHARED_LIBRARY)\r
+\r
+include $(CLEAR_VARS)\r
+LOCAL_MODULE := VKLayerThreading\r
+LOCAL_SRC_FILES += $(SRC_DIR)/buildAndroid/generated/threading.cpp\r
+LOCAL_SRC_FILES += $(SRC_DIR)/layers/vk_layer_table.cpp\r
+LOCAL_C_INCLUDES += $(SRC_DIR)/include \\r
+                   $(SRC_DIR)/layers \\r
+                   $(SRC_DIR)/buildAndroid/generated \\r
+                   $(SRC_DIR)/loader\r
+LOCAL_SHARED_LIBRARIES += layer_utils\r
+LOCAL_LDLIBS    := -llog\r
+include $(BUILD_SHARED_LIBRARY)\r
diff --git a/buildAndroid/jni/Application.mk b/buildAndroid/jni/Application.mk
new file mode 100644 (file)
index 0000000..492aa40
--- /dev/null
@@ -0,0 +1,20 @@
+# Copyright 2015 The Android Open Source Project\r
+\r
+# Licensed under the Apache License, Version 2.0 (the "License");\r
+# you may not use this file except in compliance with the License.\r
+# You may obtain a copy of the License at\r
+\r
+#      http://www.apache.org/licenses/LICENSE-2.0\r
+\r
+# Unless required by applicable law or agreed to in writing, software\r
+# distributed under the License is distributed on an "AS IS" BASIS,\r
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+# See the License for the specific language governing permissions and\r
+# limitations under the License.\r
+\r
+APP_ABI := all\r
+APP_PLATFORM := android-22\r
+APP_STL := gnustl_static\r
+APP_MODULES := layer_utils VKLayerBasic VKLayerDrawState VKLayerMemTracker VKLayerShaderCheker VKLayerImage VKLayerParamChecker VKLayerGeneric VKLayerAPIDump VKLayerObjectTracker VKLayerThreading\r
+APP_CPPFLAGS += -std=c++11 -DVK_PROTOTYPES\r
+NDK_TOOLCHAIN_VERSION := 4.8\r
index 6a26542be97a0e0d1cfd56a1e8590f4e1692249c..b90c0755c08ee593e6cf735fa355375bb385dce7 100644 (file)
@@ -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"),
 #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[] = {
     {
index a4153ec3503468eec7c4f2eac9d2e66c5ba6ae55..e3b6d873bf8ef59b417f546e10e7a125a9c08552 100644 (file)
@@ -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
 #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
index 48ef79c356ae14ce6389d786fa64fce41b2826f7..21cf15cc4ac22d7ce98b4647895fa8daf4948813 100644 (file)
@@ -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;
index 5001fe913eb973d3c4e115e57d5af4aaa93c3a5e..9a690f5f7b55ec7d638a3f41b8b64e414d95d8ab 100644 (file)
@@ -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: */
index fc2fc99560637492740a2191ab4cd22a01276269..19c917ed25d786913266c9f805b7bcb26d6fdb39 100644 (file)
@@ -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"
index f5c2319482434e8771cbf4aa01b76138c9ae9a27..091450bcd35a4178b35d30aaa65701fe1005cdc1 100755 (executable)
@@ -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>",