Make layers build on android.
diff --git a/buildAndroid/android-generate.sh b/buildAndroid/android-generate.sh
new file mode 100755
index 0000000..e1ee4d9
--- /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 0000000..c9270f1
--- /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 0000000..492aa40
--- /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 6a26542..b90c075 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 a4153ec..e3b6d87 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 48ef79c..21cf15c 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 5001fe9..9a690f5 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 @@
{
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 @@
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 @@
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 @@
}
#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 fc2fc99..19c917e 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 f5c2319..091450b 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 @@
return
self.prefix = self.argv[0]
- super().run()
+ super(DispatchTableOpsSubcommand, self).run()
def generate_header(self):
return "\n".join(["#include <vulkan.h>",