Merge commit vkjson-instance into nyc-dev

Bug: 26620936
Change-Id: Id4f5a693cf23384612391e63b0529e31053ceca6
diff --git a/Android.mk b/Android.mk
new file mode 100644
index 0000000..441a0c2
--- /dev/null
+++ b/Android.mk
@@ -0,0 +1 @@
+include $(call my-dir)/libs/vkjson/Android.mk
diff --git a/build-android/android-generate.bat b/build-android/android-generate.bat
new file mode 100644
index 0000000..303177e
--- /dev/null
+++ b/build-android/android-generate.bat
@@ -0,0 +1,61 @@
+@echo off

+REM # Copyright 2015 The Android Open Source Project

+REM # Copyright (C) 2015 Valve Corporation

+REM

+REM # Licensed under the Apache License, Version 2.0 (the "License");

+REM # you may not use this file except in compliance with the License.

+REM # You may obtain a copy of the License at

+REM

+REM #      http://www.apache.org/licenses/LICENSE-2.0

+REM

+REM # Unless required by applicable law or agreed to in writing, software

+REM # distributed under the License is distributed on an "AS IS" BASIS,

+REM # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.

+REM # See the License for the specific language governing permissions and

+REM # limitations under the License.

+

+if exist generated (

+  rmdir /s /q generated

+)

+mkdir generated\include generated\common

+

+python ../vk-generate.py Android dispatch-table-ops layer > generated/include/vk_dispatch_table_helper.h

+

+python ../vk_helper.py --gen_enum_string_helper ../include/vulkan/vulkan.h --abs_out_dir generated/include

+python ../vk_helper.py --gen_struct_wrappers ../include/vulkan/vulkan.h --abs_out_dir generated/include

+

+python ../vk-layer-generate.py Android object_tracker ../include/vulkan/vulkan.h > generated/include/object_tracker.cpp

+python ../vk-layer-generate.py Android unique_objects ../include/vulkan/vulkan.h > generated/include/unique_objects.cpp

+

+cd generated/include

+python ../../../genvk.py threading -registry ../../../vk.xml thread_check.h

+python ../../../genvk.py paramchecker -registry ../../../vk.xml parameter_validation.h

+cd ../..

+

+copy /Y ..\layers\vk_layer_config.cpp   generated\common\

+copy /Y ..\layers\vk_layer_extension_utils.cpp  generated\common\

+copy /Y ..\layers\vk_layer_utils.cpp    generated\common\

+copy /Y ..\layers\vk_layer_table.cpp    generated\common\

+

+REM create build-script root directory

+mkdir generated\gradle-build

+cd generated\gradle-build

+mkdir  core_validation device_limits image object_tracker parameter_validation swapchain threading unique_objects

+cd ..\..

+mkdir generated\layer-src

+cd generated\layer-src

+mkdir  core_validation device_limits image object_tracker parameter_validation swapchain threading unique_objects

+cd ..\..

+xcopy /s gradle-templates\*   generated\gradle-build\

+for %%G in (core_validation device_limits image parameter_validation swapchain threading) Do (

+    copy ..\layers\%%G.cpp   generated\layer-src\%%G

+    echo apply from: "../win.template.gradle"  > generated\gradle-build\%%G\build.gradle

+)

+copy generated\include\object_tracker.cpp   generated\layer-src\object_tracker

+echo apply from: "../win.template.gradle"  > generated\gradle-build\object_tracker\build.gradle

+copy generated\include\unique_objects.cpp   generated\layer-src\unique_objects

+move generated\include\vk_safe_struct.cpp generated\layer-src\unique_objects\vk_safe_struct.cpp

+echo apply from: "../win.template.gradle"  > generated\gradle-build\unique_objects\build.gradle

+

+del  /f /q generated\include\object_tracker.cpp

+del  /f /q generated\include\unique_objects.cpp

diff --git a/build-android/android-generate.sh b/build-android/android-generate.sh
new file mode 100755
index 0000000..0ded569
--- /dev/null
+++ b/build-android/android-generate.sh
@@ -0,0 +1,68 @@
+#!/bin/bash
+
+# Copyright 2015 The Android Open Source Project
+# Copyright (C) 2015 Valve Corporation
+
+# 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.
+
+dir=$(cd -P -- "$(dirname -- "$0")" && pwd -P)
+cd $dir
+
+rm -rf generated
+mkdir -p generated/include generated/common
+
+python ../vk-generate.py Android dispatch-table-ops layer > generated/include/vk_dispatch_table_helper.h
+
+python ../vk_helper.py --gen_enum_string_helper ../include/vulkan/vulkan.h --abs_out_dir generated/include
+python ../vk_helper.py --gen_struct_wrappers ../include/vulkan/vulkan.h --abs_out_dir generated/include
+
+python ../vk-layer-generate.py Android object_tracker ../include/vulkan/vulkan.h > generated/include/object_tracker.cpp
+python ../vk-layer-generate.py Android unique_objects ../include/vulkan/vulkan.h > generated/include/unique_objects.cpp
+( cd generated/include; python ../../../genvk.py threading -registry ../../../vk.xml thread_check.h )
+( cd generated/include; python ../../../genvk.py paramchecker -registry ../../../vk.xml parameter_validation.h )
+
+cp -f ../layers/vk_layer_config.cpp   generated/common/
+cp -f ../layers/vk_layer_extension_utils.cpp  generated/common/
+cp -f ../layers/vk_layer_utils.cpp    generated/common/
+cp -f ../layers/vk_layer_table.cpp    generated/common/
+
+# layer names and their original source files directory
+# 1 to 1 correspondence -- one layer one source file; additional files are copied
+# at fixup step
+declare layers=(core_validation device_limits image object_tracker parameter_validation swapchain threading unique_objects)
+declare src_dirs=(../layers ../layers ../layers generated/include ../layers ../layers ../layers generated/include)
+
+SRC_ROOT=generated/layer-src
+BUILD_ROOT=generated/gradle-build
+
+# create build-script root directory
+cp -fr gradle-templates   generated/gradle-build
+for ((i = 0; i < ${#layers[@]}; i++))
+do
+#   copy the sources
+    mkdir  -p ${SRC_ROOT}/${layers[i]}
+    cp -f ${src_dirs[i]}/${layers[i]}.cpp  ${SRC_ROOT}/${layers[i]}/
+
+#   copy build scripts
+    mkdir -p ${BUILD_ROOT}/${layers[i]}
+    echo "apply from: \"../common.gradle\"" > ${BUILD_ROOT}/${layers[i]}/build.gradle
+done
+
+# fixup - unique_objects need one more file
+mv  generated/include/vk_safe_struct.cpp ${SRC_ROOT}/unique_objects/vk_safe_struct.cpp
+
+# fixup - remove copied files from generated/include
+rm  generated/include/object_tracker.cpp
+rm  generated/include/unique_objects.cpp
+
+exit 0
diff --git a/build-android/gradle-templates/README.md b/build-android/gradle-templates/README.md
new file mode 100644
index 0000000..b4f7d45
--- /dev/null
+++ b/build-android/gradle-templates/README.md
@@ -0,0 +1,3 @@
+#Validation Layers projects
+
+
diff --git a/build-android/gradle-templates/build.gradle b/build-android/gradle-templates/build.gradle
new file mode 100644
index 0000000..c4a425b
--- /dev/null
+++ b/build-android/gradle-templates/build.gradle
@@ -0,0 +1,22 @@
+// Top-level build file where you can add configuration options common to all sub-projects/modules.
+
+buildscript {
+    repositories {
+        jcenter()
+    }
+    dependencies {
+        classpath 'com.android.tools.build:gradle-experimental:0.7.0-alpha1'
+        // NOTE: Do not place your application dependencies here; they belong
+        // in the individual module build.gradle files
+    }
+}
+
+allprojects {
+    repositories {
+        jcenter()
+    }
+}
+
+task clean(type: Delete) {
+    delete rootProject.buildDir
+}
diff --git a/build-android/gradle-templates/common.gradle b/build-android/gradle-templates/common.gradle
new file mode 100644
index 0000000..f39578f
--- /dev/null
+++ b/build-android/gradle-templates/common.gradle
@@ -0,0 +1,71 @@
+apply plugin: 'com.android.model.native'
+
+Properties properties = new Properties()
+properties.load(project.rootProject.file('local.properties').newDataInputStream())
+def ndkDir = properties.getProperty('ndk.dir')
+
+model {
+    android {
+        compileSdkVersion = 23
+        buildToolsVersion = "23.0.2"
+
+        defaultConfig.with {
+            minSdkVersion.apiLevel = 22
+            targetSdkVersion.apiLevel = 24
+            versionCode = 1
+            versionName = "0.0.1"
+        }
+    }
+
+    android.ndk {
+        moduleName = "VkLayer_${project.name}"
+        toolchain = "clang"
+        stl = "gnustl_static"
+        ldLibs.addAll(["log", "android"])
+        cppFlags.addAll(["-std=c++11", "-DVK_PROTOTYPES", "-Wall", "-Werror",
+                         "-Wno-unused-function", "-Wno-unused-const-variable",
+                         "-DVK_USE_PLATFORM_ANDROID_KHR"])
+        cppFlags.addAll(["-I${file("../../../../layers")}".toString(),
+                         "-I${file("../../../../include")}".toString(),
+                         "-I${file("../../../../loader")}".toString(),
+                         "-I${file("../../include")}".toString(),
+                         "-I${file("../../../../../glslang")}".toString()])
+    }
+
+    // Turn on hard float support in armeabi-v7a
+    android.abis {
+        create("armeabi-v7a") {
+            cppFlags.addAll(["-mhard-float", "-D_NDK_MATH_NO_SOFTFP=1", "-mfloat-abi=hard"])
+            ldLibs.add("m_hard")
+            ldFlags.add("-Wl,--no-warn-mismatch")
+        }
+    }
+
+    android.sources {
+        main {
+            jni {
+                source {
+                    srcDir "../../layer-src/${project.name}"
+                    srcDir '../../common'
+
+                }
+            }
+        }
+    }
+
+    android.buildTypes {
+        release {
+            ndk.with {
+                debuggable = true
+            }
+            minifyEnabled = false
+        }
+    }
+    android.productFlavors {
+        create ("all") {
+            ndk.abiFilters.addAll(["armeabi-v7a", 'arm64-v8a',
+                                   'x86', 'x86_64'])
+        }
+    }
+}
+
diff --git a/build-android/gradle-templates/gradle.properties b/build-android/gradle-templates/gradle.properties
new file mode 100644
index 0000000..1d3591c
--- /dev/null
+++ b/build-android/gradle-templates/gradle.properties
@@ -0,0 +1,18 @@
+# Project-wide Gradle settings.
+
+# IDE (e.g. Android Studio) users:
+# Gradle settings configured through the IDE *will override*
+# any settings specified in this file.
+
+# For more details on how to configure your build environment visit
+# http://www.gradle.org/docs/current/userguide/build_environment.html
+
+# Specifies the JVM arguments used for the daemon process.
+# The setting is particularly useful for tweaking memory settings.
+# Default value: -Xmx10248m -XX:MaxPermSize=256m
+# org.gradle.jvmargs=-Xmx2048m -XX:MaxPermSize=512m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8
+
+# When configured, Gradle will run in incubating parallel mode.
+# This option should only be used with decoupled projects. More details, visit
+# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
+# org.gradle.parallel=true
\ No newline at end of file
diff --git a/build-android/gradle-templates/gradle/wrapper/gradle-wrapper.jar b/build-android/gradle-templates/gradle/wrapper/gradle-wrapper.jar
new file mode 100644
index 0000000..8c0fb64
--- /dev/null
+++ b/build-android/gradle-templates/gradle/wrapper/gradle-wrapper.jar
Binary files differ
diff --git a/build-android/gradle-templates/gradle/wrapper/gradle-wrapper.properties b/build-android/gradle-templates/gradle/wrapper/gradle-wrapper.properties
new file mode 100644
index 0000000..80472fb
--- /dev/null
+++ b/build-android/gradle-templates/gradle/wrapper/gradle-wrapper.properties
@@ -0,0 +1,6 @@
+#Wed Nov 25 17:13:33 GMT 2015
+distributionBase=GRADLE_USER_HOME
+distributionPath=wrapper/dists
+zipStoreBase=GRADLE_USER_HOME
+zipStorePath=wrapper/dists
+distributionUrl=https\://services.gradle.org/distributions/gradle-2.10-bin.zip
diff --git a/build-android/gradle-templates/gradlew b/build-android/gradle-templates/gradlew
new file mode 100755
index 0000000..91a7e26
--- /dev/null
+++ b/build-android/gradle-templates/gradlew
@@ -0,0 +1,164 @@
+#!/usr/bin/env bash
+
+##############################################################################
+##
+##  Gradle start up script for UN*X
+##
+##############################################################################
+
+# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
+DEFAULT_JVM_OPTS=""
+
+APP_NAME="Gradle"
+APP_BASE_NAME=`basename "$0"`
+
+# Use the maximum available, or set MAX_FD != -1 to use that value.
+MAX_FD="maximum"
+
+warn ( ) {
+    echo "$*"
+}
+
+die ( ) {
+    echo
+    echo "$*"
+    echo
+    exit 1
+}
+
+# OS specific support (must be 'true' or 'false').
+cygwin=false
+msys=false
+darwin=false
+case "`uname`" in
+  CYGWIN* )
+    cygwin=true
+    ;;
+  Darwin* )
+    darwin=true
+    ;;
+  MINGW* )
+    msys=true
+    ;;
+esac
+
+# For Cygwin, ensure paths are in UNIX format before anything is touched.
+if $cygwin ; then
+    [ -n "$JAVA_HOME" ] && JAVA_HOME=`cygpath --unix "$JAVA_HOME"`
+fi
+
+# Attempt to set APP_HOME
+# Resolve links: $0 may be a link
+PRG="$0"
+# Need this for relative symlinks.
+while [ -h "$PRG" ] ; do
+    ls=`ls -ld "$PRG"`
+    link=`expr "$ls" : '.*-> \(.*\)$'`
+    if expr "$link" : '/.*' > /dev/null; then
+        PRG="$link"
+    else
+        PRG=`dirname "$PRG"`"/$link"
+    fi
+done
+SAVED="`pwd`"
+cd "`dirname \"$PRG\"`/" >&-
+APP_HOME="`pwd -P`"
+cd "$SAVED" >&-
+
+CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
+
+# Determine the Java command to use to start the JVM.
+if [ -n "$JAVA_HOME" ] ; then
+    if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
+        # IBM's JDK on AIX uses strange locations for the executables
+        JAVACMD="$JAVA_HOME/jre/sh/java"
+    else
+        JAVACMD="$JAVA_HOME/bin/java"
+    fi
+    if [ ! -x "$JAVACMD" ] ; then
+        die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
+
+Please set the JAVA_HOME variable in your environment to match the
+location of your Java installation."
+    fi
+else
+    JAVACMD="java"
+    which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
+
+Please set the JAVA_HOME variable in your environment to match the
+location of your Java installation."
+fi
+
+# Increase the maximum file descriptors if we can.
+if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then
+    MAX_FD_LIMIT=`ulimit -H -n`
+    if [ $? -eq 0 ] ; then
+        if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
+            MAX_FD="$MAX_FD_LIMIT"
+        fi
+        ulimit -n $MAX_FD
+        if [ $? -ne 0 ] ; then
+            warn "Could not set maximum file descriptor limit: $MAX_FD"
+        fi
+    else
+        warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
+    fi
+fi
+
+# For Darwin, add options to specify how the application appears in the dock
+if $darwin; then
+    GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
+fi
+
+# For Cygwin, switch paths to Windows format before running java
+if $cygwin ; then
+    APP_HOME=`cygpath --path --mixed "$APP_HOME"`
+    CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
+
+    # We build the pattern for arguments to be converted via cygpath
+    ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
+    SEP=""
+    for dir in $ROOTDIRSRAW ; do
+        ROOTDIRS="$ROOTDIRS$SEP$dir"
+        SEP="|"
+    done
+    OURCYGPATTERN="(^($ROOTDIRS))"
+    # Add a user-defined pattern to the cygpath arguments
+    if [ "$GRADLE_CYGPATTERN" != "" ] ; then
+        OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
+    fi
+    # Now convert the arguments - kludge to limit ourselves to /bin/sh
+    i=0
+    for arg in "$@" ; do
+        CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
+        CHECK2=`echo "$arg"|egrep -c "^-"`                                 ### Determine if an option
+
+        if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then                    ### Added a condition
+            eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
+        else
+            eval `echo args$i`="\"$arg\""
+        fi
+        i=$((i+1))
+    done
+    case $i in
+        (0) set -- ;;
+        (1) set -- "$args0" ;;
+        (2) set -- "$args0" "$args1" ;;
+        (3) set -- "$args0" "$args1" "$args2" ;;
+        (4) set -- "$args0" "$args1" "$args2" "$args3" ;;
+        (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
+        (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
+        (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
+        (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
+        (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
+    esac
+fi
+
+# Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules
+function splitJvmOpts() {
+    JVM_OPTS=("$@")
+}
+eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS
+JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME"
+
+exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@"
diff --git a/build-android/gradle-templates/gradlew.bat b/build-android/gradle-templates/gradlew.bat
new file mode 100644
index 0000000..8a0b282
--- /dev/null
+++ b/build-android/gradle-templates/gradlew.bat
@@ -0,0 +1,90 @@
+@if "%DEBUG%" == "" @echo off
+@rem ##########################################################################
+@rem
+@rem  Gradle startup script for Windows
+@rem
+@rem ##########################################################################
+
+@rem Set local scope for the variables with windows NT shell
+if "%OS%"=="Windows_NT" setlocal
+
+@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
+set DEFAULT_JVM_OPTS=
+
+set DIRNAME=%~dp0
+if "%DIRNAME%" == "" set DIRNAME=.
+set APP_BASE_NAME=%~n0
+set APP_HOME=%DIRNAME%
+
+@rem Find java.exe
+if defined JAVA_HOME goto findJavaFromJavaHome
+
+set JAVA_EXE=java.exe
+%JAVA_EXE% -version >NUL 2>&1
+if "%ERRORLEVEL%" == "0" goto init
+
+echo.
+echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
+echo.
+echo Please set the JAVA_HOME variable in your environment to match the
+echo location of your Java installation.
+
+goto fail
+
+:findJavaFromJavaHome
+set JAVA_HOME=%JAVA_HOME:"=%
+set JAVA_EXE=%JAVA_HOME%/bin/java.exe
+
+if exist "%JAVA_EXE%" goto init
+
+echo.
+echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
+echo.
+echo Please set the JAVA_HOME variable in your environment to match the
+echo location of your Java installation.
+
+goto fail
+
+:init
+@rem Get command-line arguments, handling Windowz variants
+
+if not "%OS%" == "Windows_NT" goto win9xME_args
+if "%@eval[2+2]" == "4" goto 4NT_args
+
+:win9xME_args
+@rem Slurp the command line arguments.
+set CMD_LINE_ARGS=
+set _SKIP=2
+
+:win9xME_args_slurp
+if "x%~1" == "x" goto execute
+
+set CMD_LINE_ARGS=%*
+goto execute
+
+:4NT_args
+@rem Get arguments from the 4NT Shell from JP Software
+set CMD_LINE_ARGS=%$
+
+:execute
+@rem Setup the command line
+
+set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
+
+@rem Execute Gradle
+"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
+
+:end
+@rem End local scope for the variables with windows NT shell
+if "%ERRORLEVEL%"=="0" goto mainEnd
+
+:fail
+rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
+rem the _cmd.exe /c_ return code!
+if  not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
+exit /b 1
+
+:mainEnd
+if "%OS%"=="Windows_NT" endlocal
+
+:omega
diff --git a/build-android/gradle-templates/local.properties b/build-android/gradle-templates/local.properties
new file mode 100644
index 0000000..6679559
--- /dev/null
+++ b/build-android/gradle-templates/local.properties
@@ -0,0 +1,13 @@
+## This file is automatically generated by Android Studio.
+# Do not modify this file -- YOUR CHANGES WILL BE ERASED!
+#
+# This file must *NOT* be checked into Version Control Systems,
+# as it contains information specific to your local configuration.
+#
+# Location of the SDK. This is only used by Gradle.
+# For customization when using a Version Control System, please read the
+# header note.
+#Mon Mar 28 09:29:17 PDT 2016
+sdk.dir=/path/to/your/android_sdk
+ndk.dir=/path/to/your/android_ndk
+
diff --git a/build-android/gradle-templates/settings.gradle b/build-android/gradle-templates/settings.gradle
new file mode 100644
index 0000000..00a0cba
--- /dev/null
+++ b/build-android/gradle-templates/settings.gradle
@@ -0,0 +1,11 @@
+include ':core_validation',
+        ':device_limits',
+        ':image',
+        ':object_tracker',
+        ':parameter_validation',
+        ':swapchain',
+        ':threading',
+        ':unique_objects'
+
+
+
diff --git a/build-android/gradle-templates/win.template.gradle b/build-android/gradle-templates/win.template.gradle
new file mode 100644
index 0000000..6efae6f
--- /dev/null
+++ b/build-android/gradle-templates/win.template.gradle
@@ -0,0 +1,76 @@
+// this template is for windows platform to build

+//   need gcc, could not use clang

+//   disable -Werror compile flag

+// This is temp workaround, clean fix will be provided soon so all OSes should use

+// common.gradle

+

+apply plugin: 'com.android.model.native'

+

+Properties properties = new Properties()

+properties.load(project.rootProject.file('local.properties').newDataInputStream())

+def ndkDir = properties.getProperty('ndk.dir')

+

+model {

+    android {

+        compileSdkVersion = 23

+        buildToolsVersion = "23.0.2"

+

+        defaultConfig.with {

+            minSdkVersion.apiLevel = 22

+            targetSdkVersion.apiLevel = 24

+            versionCode = 1

+            versionName = "0.0.1"

+        }

+    }

+

+    android.ndk {

+        moduleName = "VkLayer_${project.name}"

+        toolchain = "gcc"

+        stl = "gnustl_static"

+        ldLibs.addAll(["log", "android"])

+        cppFlags.addAll(["-std=c++11", "-DVK_PROTOTYPES", "-Wall",

+                         "-Wno-unused-function", "-Wno-unused-const-variable",

+                         "-DVK_USE_PLATFORM_ANDROID_KHR"])

+        cppFlags.addAll(["-I${file("../../../../layers")}".toString(),

+                         "-I${file("../../../../include")}".toString(),

+                         "-I${file("../../../../loader")}".toString(),

+                         "-I${file("../../include")}".toString(),

+                         "-I${file("../../../../../glslang")}".toString()])

+    }

+

+    // Turn on hard float support in armeabi-v7a

+    android.abis {

+        create("armeabi-v7a") {

+            cppFlags.addAll(["-mhard-float", "-D_NDK_MATH_NO_SOFTFP=1", "-mfloat-abi=hard"])

+            ldLibs.add("m_hard")

+            ldFlags.add("-Wl,--no-warn-mismatch")

+        }

+    }

+

+    android.sources {

+        main {

+            jni {

+                source {

+                    srcDir "../../layer-src/${project.name}"

+                    srcDir '../../common'

+

+                }

+            }

+        }

+    }

+

+    android.buildTypes {

+        release {

+            ndk.with {

+                debuggable = true

+            }

+            minifyEnabled = false

+        }

+    }

+    android.productFlavors {

+        create ("all") {

+            ndk.abiFilters.addAll(["armeabi-v7a", 'arm64-v8a',

+                                   'x86', 'x86_64'])

+        }

+    }

+}

diff --git a/buildAndroid/jni/Android.mk b/build-android/jni/Android.mk
similarity index 62%
rename from buildAndroid/jni/Android.mk
rename to build-android/jni/Android.mk
index e9dfc36..bd78520 100644
--- a/buildAndroid/jni/Android.mk
+++ b/build-android/jni/Android.mk
@@ -16,23 +16,26 @@
 LOCAL_PATH := $(abspath $(call my-dir))
 MY_PATH := $(LOCAL_PATH)
 SRC_DIR := $(LOCAL_PATH)/../../
+LAYER_DIR := $(LOCAL_PATH)/../generated
 
 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_SRC_FILES += $(SRC_DIR)/layers/vk_layer_utils.cpp
+LOCAL_SRC_FILES += $(LAYER_DIR)/common/vk_layer_config.cpp
+LOCAL_SRC_FILES += $(LAYER_DIR)/common/vk_layer_extension_utils.cpp
+LOCAL_SRC_FILES += $(LAYER_DIR)/common/vk_layer_utils.cpp
 LOCAL_C_INCLUDES += $(SRC_DIR)/include \
+                    ${SRC_DIR}/layers \
                     $(SRC_DIR)/loader
 LOCAL_CPPFLAGS += -DVK_USE_PLATFORM_ANDROID_KHR
 include $(BUILD_STATIC_LIBRARY)
 
 include $(CLEAR_VARS)
 LOCAL_MODULE := VkLayer_core_validation
-LOCAL_SRC_FILES += $(SRC_DIR)/layers/core_validation.cpp
-LOCAL_SRC_FILES += $(SRC_DIR)/layers/vk_layer_table.cpp
+LOCAL_SRC_FILES += $(LAYER_DIR)/layer-src/core_validation/core_validation.cpp
+LOCAL_SRC_FILES += $(LAYER_DIR)/common/vk_layer_table.cpp
 LOCAL_C_INCLUDES += $(SRC_DIR)/include \
-                    $(MY_PATH)/../generated \
+                    ${SRC_DIR}/layers \
+                    $(MY_PATH)/../generated/include \
                     $(SRC_DIR)/loader \
                     $(SRC_DIR)/../glslang
 LOCAL_STATIC_LIBRARIES += layer_utils
@@ -42,10 +45,11 @@
 
 include $(CLEAR_VARS)
 LOCAL_MODULE := VkLayer_device_limits
-LOCAL_SRC_FILES += $(SRC_DIR)/layers/device_limits.cpp
-LOCAL_SRC_FILES += $(SRC_DIR)/layers/vk_layer_table.cpp
+LOCAL_SRC_FILES += $(LAYER_DIR)/layer-src/device_limits/device_limits.cpp
+LOCAL_SRC_FILES += $(LAYER_DIR)/common/vk_layer_table.cpp
 LOCAL_C_INCLUDES += $(SRC_DIR)/include \
-                    $(MY_PATH)/../generated \
+                    ${SRC_DIR}/layers \
+                    $(MY_PATH)/../generated/include \
                     $(SRC_DIR)/loader
 LOCAL_STATIC_LIBRARIES += layer_utils
 LOCAL_CPPFLAGS += -DVK_USE_PLATFORM_ANDROID_KHR
@@ -54,10 +58,11 @@
 
 include $(CLEAR_VARS)
 LOCAL_MODULE := VkLayer_image
-LOCAL_SRC_FILES += $(SRC_DIR)/layers/image.cpp
-LOCAL_SRC_FILES += $(SRC_DIR)/layers/vk_layer_table.cpp
+LOCAL_SRC_FILES += $(LAYER_DIR)/layer-src/image/image.cpp
+LOCAL_SRC_FILES += $(LAYER_DIR)/common/vk_layer_table.cpp
 LOCAL_C_INCLUDES += $(SRC_DIR)/include \
-                    $(MY_PATH)/../generated \
+                    ${SRC_DIR}/layers \
+                    $(MY_PATH)/../generated/include \
                     $(SRC_DIR)/loader
 LOCAL_STATIC_LIBRARIES += layer_utils
 LOCAL_CPPFLAGS += -DVK_USE_PLATFORM_ANDROID_KHR
@@ -66,10 +71,10 @@
 
 include $(CLEAR_VARS)
 LOCAL_MODULE := VkLayer_parameter_validation
-LOCAL_SRC_FILES += $(SRC_DIR)/layers/parameter_validation.cpp
-LOCAL_SRC_FILES += $(SRC_DIR)/layers/vk_layer_table.cpp
+LOCAL_SRC_FILES += $(LAYER_DIR)/layer-src/parameter_validation/parameter_validation.cpp
+LOCAL_SRC_FILES += $(LAYER_DIR)/common/vk_layer_table.cpp
 LOCAL_C_INCLUDES += $(SRC_DIR)/include \
-                    $(MY_PATH)/../generated \
+                    $(MY_PATH)/../generated/include \
                     $(SRC_DIR)/layers \
                     $(SRC_DIR)/loader
 LOCAL_STATIC_LIBRARIES += layer_utils
@@ -79,11 +84,11 @@
 
 include $(CLEAR_VARS)
 LOCAL_MODULE := VkLayer_object_tracker
-LOCAL_SRC_FILES += $(MY_PATH)/../generated/object_tracker.cpp
-LOCAL_SRC_FILES += $(SRC_DIR)/layers/vk_layer_table.cpp
+LOCAL_SRC_FILES += $(LAYER_DIR)/layer-src/object_tracker/object_tracker.cpp
+LOCAL_SRC_FILES += $(LAYER_DIR)/common/vk_layer_table.cpp
 LOCAL_C_INCLUDES += $(SRC_DIR)/include \
                     $(SRC_DIR)/layers \
-                    $(MY_PATH)/../generated \
+                    $(MY_PATH)/../generated/include \
                     $(SRC_DIR)/loader
 LOCAL_STATIC_LIBRARIES += layer_utils
 LOCAL_CPPFLAGS += -DVK_USE_PLATFORM_ANDROID_KHR
@@ -92,11 +97,11 @@
 
 include $(CLEAR_VARS)
 LOCAL_MODULE := VkLayer_threading
-LOCAL_SRC_FILES += $(SRC_DIR)/layers/threading.cpp
-LOCAL_SRC_FILES += $(SRC_DIR)/layers/vk_layer_table.cpp
+LOCAL_SRC_FILES += $(LAYER_DIR)/layer-src/threading/threading.cpp
+LOCAL_SRC_FILES += $(LAYER_DIR)/common/vk_layer_table.cpp
 LOCAL_C_INCLUDES += $(SRC_DIR)/include \
                     $(SRC_DIR)/layers \
-                    $(MY_PATH)/../generated \
+                    $(MY_PATH)/../generated/include \
                     $(SRC_DIR)/loader
 LOCAL_STATIC_LIBRARIES += layer_utils
 LOCAL_CPPFLAGS += -DVK_USE_PLATFORM_ANDROID_KHR
@@ -105,13 +110,13 @@
 
 include $(CLEAR_VARS)
 LOCAL_MODULE := VkLayer_unique_objects
-LOCAL_SRC_FILES += $(MY_PATH)/../generated/unique_objects.cpp
-LOCAL_SRC_FILES += $(MY_PATH)/../generated/vk_safe_struct.cpp
-LOCAL_SRC_FILES += $(SRC_DIR)/layers/vk_layer_table.cpp
+LOCAL_SRC_FILES += $(LAYER_DIR)/layer-src/unique_objects/unique_objects.cpp
+LOCAL_SRC_FILES += $(LAYER_DIR)/layer-src/unique_objects/vk_safe_struct.cpp
+LOCAL_SRC_FILES += $(LAYER_DIR)/common/vk_layer_table.cpp
 LOCAL_C_INCLUDES += $(SRC_DIR)/include \
                     $(SRC_DIR)/layers \
-		    $(MY_PATH)/../generated \
-		    $(SRC_DIR)/loader
+                    $(MY_PATH)/../generated/include \
+                    $(SRC_DIR)/loader
 LOCAL_STATIC_LIBRARIES += layer_utils
 LOCAL_CPPFLAGS += -DVK_USE_PLATFORM_ANDROID_KHR
 LOCAL_LDLIBS    := -llog
@@ -119,11 +124,12 @@
 
 include $(CLEAR_VARS)
 LOCAL_MODULE := VkLayer_swapchain
-LOCAL_SRC_FILES += $(SRC_DIR)/layers/swapchain.cpp
-LOCAL_SRC_FILES += $(SRC_DIR)/layers/vk_layer_table.cpp
+LOCAL_SRC_FILES += $(LAYER_DIR)/layer-src/swapchain/swapchain.cpp
+LOCAL_SRC_FILES += $(LAYER_DIR)/common/vk_layer_table.cpp
 LOCAL_C_INCLUDES += $(SRC_DIR)/include \
-		    $(MY_PATH)/../generated \
-		    $(SRC_DIR)/loader
+                    ${SRC_DIR}/layers \
+                    $(MY_PATH)/../generated/include \
+                    $(SRC_DIR)/loader
 LOCAL_STATIC_LIBRARIES += layer_utils
 LOCAL_CPPFLAGS += -DVK_USE_PLATFORM_ANDROID_KHR
 LOCAL_LDLIBS    := -llog
diff --git a/buildAndroid/jni/Application.mk b/build-android/jni/Application.mk
similarity index 100%
rename from buildAndroid/jni/Application.mk
rename to build-android/jni/Application.mk
diff --git a/buildAndroid/android-generate.bat b/buildAndroid/android-generate.bat
deleted file mode 100644
index bf05352..0000000
--- a/buildAndroid/android-generate.bat
+++ /dev/null
@@ -1,33 +0,0 @@
-@echo off
-REM # Copyright 2015 The Android Open Source Project
-REM # Copyright (C) 2015 Valve Corporation
-REM
-REM # Licensed under the Apache License, Version 2.0 (the "License");
-REM # you may not use this file except in compliance with the License.
-REM # You may obtain a copy of the License at
-REM
-REM #      http://www.apache.org/licenses/LICENSE-2.0
-REM
-REM # Unless required by applicable law or agreed to in writing, software
-REM # distributed under the License is distributed on an "AS IS" BASIS,
-REM # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-REM # See the License for the specific language governing permissions and
-REM # limitations under the License.
-
-if exist generated (
-  rmdir /s /q generated
-)
-mkdir generated
-
-python ../vk-generate.py Android dispatch-table-ops layer > generated/vk_dispatch_table_helper.h
-
-python ../vk_helper.py --gen_enum_string_helper ../include/vulkan/vulkan.h --abs_out_dir generated
-python ../vk_helper.py --gen_struct_wrappers ../include/vulkan/vulkan.h --abs_out_dir generated
-
-python ../vk-layer-generate.py Android object_tracker ../include/vulkan/vulkan.h > generated/object_tracker.cpp
-python ../vk-layer-generate.py Android unique_objects ../include/vulkan/vulkan.h > generated/unique_objects.cpp
-
-cd generated
-python ../../genvk.py threading -registry ../../vk.xml thread_check.h
-python ../../genvk.py paramchecker -registry ../../vk.xml parameter_validation.h
-cd ..
diff --git a/buildAndroid/android-generate.sh b/buildAndroid/android-generate.sh
deleted file mode 100755
index 928a176..0000000
--- a/buildAndroid/android-generate.sh
+++ /dev/null
@@ -1,33 +0,0 @@
-#!/bin/bash
-
-# Copyright 2015 The Android Open Source Project
-# Copyright (C) 2015 Valve Corporation
-
-# 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.
-
-dir=$(cd -P -- "$(dirname -- "$0")" && pwd -P)
-cd $dir
-
-rm -rf generated
-mkdir -p generated
-python ../vk-generate.py Android dispatch-table-ops layer > generated/vk_dispatch_table_helper.h
-
-python ../vk_helper.py --gen_enum_string_helper ../include/vulkan/vulkan.h --abs_out_dir generated
-python ../vk_helper.py --gen_struct_wrappers ../include/vulkan/vulkan.h --abs_out_dir generated
-
-python ../vk-layer-generate.py Android object_tracker ../include/vulkan/vulkan.h > generated/object_tracker.cpp
-python ../vk-layer-generate.py Android unique_objects ../include/vulkan/vulkan.h > generated/unique_objects.cpp
-( cd generated; python ../../genvk.py threading -registry ../../vk.xml thread_check.h )
-( cd generated; python ../../genvk.py paramchecker -registry ../../vk.xml parameter_validation.h )
-
-exit 0
diff --git a/libs/vkjson/Android.mk b/libs/vkjson/Android.mk
new file mode 100644
index 0000000..d35e36e
--- /dev/null
+++ b/libs/vkjson/Android.mk
@@ -0,0 +1,37 @@
+# Copyright 2016 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 := $(call my-dir)
+include $(CLEAR_VARS)
+
+LOCAL_CPP_EXTENSION := .cc
+LOCAL_CLANG := true
+LOCAL_CPPFLAGS := -std=c++11 \
+	-Wno-sign-compare
+
+LOCAL_C_INCLUDES := \
+	$(LOCAL_PATH)/../../include \
+	$(LOCAL_PATH)/../../loader
+
+LOCAL_SRC_FILES := \
+	vkjson.cc \
+	vkjson_instance.cc \
+	../../loader/cJSON.c
+
+LOCAL_ADDITIONAL_DEPENDENCIES := $(LOCAL_PATH)/Android.mk
+
+LOCAL_MODULE := libvkjson
+
+include $(BUILD_STATIC_LIBRARY)
+
diff --git a/libs/vkjson/vkjson.cc b/libs/vkjson/vkjson.cc
index 63306d5..ee87b91 100644
--- a/libs/vkjson/vkjson.cc
+++ b/libs/vkjson/vkjson.cc
@@ -39,8 +39,8 @@
 #include <type_traits>
 #include <utility>
 
-#include "cJSON.h"
-#include "vk_sdk_platform.h"
+#include <cJSON.h>
+#include <vulkan/vk_sdk_platform.h>
 
 namespace {
 
@@ -467,7 +467,7 @@
   Iterate(visitor, const_cast<T*>(&t));
 }
 
-template <typename T, typename = EnableForStruct<T>, typename = void>
+template <typename T, typename /*= EnableForStruct<T>*/, typename /*= void*/>
 cJSON* ToJsonValue(const T& value) {
   JsonWriterVisitor visitor;
   VisitForWrite(&visitor, value);
@@ -645,7 +645,7 @@
   std::string* errors_;
 };
 
-template <typename T, typename = EnableForStruct<T>>
+template <typename T, typename /*= EnableForStruct<T>*/>
 bool AsValue(cJSON* json_value, T* t) {
   if (json_value->type != cJSON_Object)
     return false;
diff --git a/libs/vkjson/vkjson_instance.cc b/libs/vkjson/vkjson_instance.cc
index 0878a6a..f1cd98d 100644
--- a/libs/vkjson/vkjson_instance.cc
+++ b/libs/vkjson/vkjson_instance.cc
@@ -82,7 +82,7 @@
                                      device.layers.data());
   }
 
-  VkFormatProperties format_properties = {0};
+  VkFormatProperties format_properties = {};
   for (VkFormat format = VK_FORMAT_R4G4_UNORM_PACK8;
        format <= VK_FORMAT_END_RANGE;
        format = static_cast<VkFormat>(format + 1)) {