vulkan: Support VK_EXT_debug_report in loader and nulldrv

* Add extension to vulkan.api.
* Fix a few errors in upstream vk_ext_debug_report.h; bugs filed.
* Loader enumerates extension iff the driver supports it.
  - TODO: Also enumerate if any layers that support it are implicitly
    enabled.
  - Note extension may still be enabled if any layer supports it.
* Add loader bottom procs for the extension functions. These will call
  through to the driver version if the driver supports the extension.
* Add no-op support to nulldrv, mostly for testing the loader.

Change-Id: I092d2da56ee4c64498f8edae75e0d995478bb6f2
(cherry picked from commit a5ef7c27bc85e3628814532a32ffb9a5c33c4b73)
diff --git a/vulkan/api/vulkan.api b/vulkan/api/vulkan.api
index 5d35ddf..d735844 100644
--- a/vulkan/api/vulkan.api
+++ b/vulkan/api/vulkan.api
@@ -75,6 +75,9 @@
 @extension("VK_KHR_win32_surface") define VK_KHR_WIN32_SURFACE_SPEC_VERSION     5
 @extension("VK_KHR_win32_surface") define VK_KHR_WIN32_SURFACE_NAME             "VK_KHR_win32_surface"
 
+@extension("VK_EXT_debug_report") define VK_EXT_DEBUG_REPORT_SPEC_VERSION       2
+@extension("VK_EXT_debug_report") define VK_EXT_DEBUG_REPORT_NAME               "VK_EXT_debug_report"
+
 
 /////////////
 //  Types  //
@@ -121,6 +124,8 @@
 @extension("VK_KHR_display")    @nonDispatchHandle type u64 VkDisplayKHR
 @extension("VK_KHR_display")    @nonDispatchHandle type u64 VkDisplayModeKHR
 
+@extension("VK_EXT_debug_report") @nonDispatchHandle type u64 VkDebugReportCallbackEXT
+
 
 /////////////
 //  Enums  //
@@ -722,6 +727,46 @@
     VK_COLORSPACE_SRGB_NONLINEAR_KHR                        = 0x00000000,
 }
 
+@extension("VK_EXT_debug_report")
+enum VkDebugReportObjectTypeEXT {
+    VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT                 = 0,
+    VK_DEBUG_REPORT_OBJECT_TYPE_INSTANCE_EXT                = 1,
+    VK_DEBUG_REPORT_OBJECT_TYPE_PHYSICAL_DEVICE_EXT         = 2,
+    VK_DEBUG_REPORT_OBJECT_TYPE_DEVICE_EXT                  = 3,
+    VK_DEBUG_REPORT_OBJECT_TYPE_QUEUE_EXT                   = 4,
+    VK_DEBUG_REPORT_OBJECT_TYPE_SEMAPHORE_EXT               = 5,
+    VK_DEBUG_REPORT_OBJECT_TYPE_COMMAND_BUFFER_EXT          = 6,
+    VK_DEBUG_REPORT_OBJECT_TYPE_FENCE_EXT                   = 7,
+    VK_DEBUG_REPORT_OBJECT_TYPE_DEVICE_MEMORY_EXT           = 8,
+    VK_DEBUG_REPORT_OBJECT_TYPE_BUFFER_EXT                  = 9,
+    VK_DEBUG_REPORT_OBJECT_TYPE_IMAGE_EXT                   = 10,
+    VK_DEBUG_REPORT_OBJECT_TYPE_EVENT_EXT                   = 11,
+    VK_DEBUG_REPORT_OBJECT_TYPE_QUERY_POOL_EXT              = 12,
+    VK_DEBUG_REPORT_OBJECT_TYPE_BUFFER_VIEW_EXT             = 13,
+    VK_DEBUG_REPORT_OBJECT_TYPE_IMAGE_VIEW_EXT              = 14,
+    VK_DEBUG_REPORT_OBJECT_TYPE_SHADER_MODULE_EXT           = 15,
+    VK_DEBUG_REPORT_OBJECT_TYPE_PIPELINE_CACHE_EXT          = 16,
+    VK_DEBUG_REPORT_OBJECT_TYPE_PIPELINE_LAYOUT_EXT         = 17,
+    VK_DEBUG_REPORT_OBJECT_TYPE_RENDER_PASS_EXT             = 18,
+    VK_DEBUG_REPORT_OBJECT_TYPE_PIPELINE_EXT                = 19,
+    VK_DEBUG_REPORT_OBJECT_TYPE_DESCRIPTOR_SET_LAYOUT_EXT   = 20,
+    VK_DEBUG_REPORT_OBJECT_TYPE_SAMPLER_EXT                 = 21,
+    VK_DEBUG_REPORT_OBJECT_TYPE_DESCRIPTOR_POOL_EXT         = 22,
+    VK_DEBUG_REPORT_OBJECT_TYPE_DESCRIPTOR_SET_EXT          = 23,
+    VK_DEBUG_REPORT_OBJECT_TYPE_FRAMEBUFFER_EXT             = 24,
+    VK_DEBUG_REPORT_OBJECT_TYPE_COMMAND_POOL_EXT            = 25,
+    VK_DEBUG_REPORT_OBJECT_TYPE_SURFACE_KHR_EXT             = 26,
+    VK_DEBUG_REPORT_OBJECT_TYPE_SWAPCHAIN_KHR_EXT           = 27,
+    VK_DEBUG_REPORT_OBJECT_TYPE_DEBUG_REPORT_EXT            = 28,
+}
+
+@extension("VK_EXT_debug_report")
+enum VkDebugReportErrorEXT {
+    VK_DEBUG_REPORT_ERROR_NONE_EXT                          = 0,
+    VK_DEBUG_REPORT_ERROR_CALLBACK_REF_EXT                  = 1,
+}
+
+
 /////////////////
 //  Bitfields  //
 /////////////////
@@ -1249,6 +1294,17 @@
 //bitfield VkWin32SurfaceCreateFlagBitsKHR {
 //}
 
+@extension("VK_EXT_debug_report")
+type VkFlags VkDebugReportFlagsEXT
+@extension("VK_EXT_debug_report")
+bitfield VkDebugReportFlagBitsEXT {
+    VK_DEBUG_REPORT_INFO_BIT_EXT                            = 0x00000001,
+    VK_DEBUG_REPORT_WARN_BIT_EXT                            = 0x00000002,
+    VK_DEBUG_REPORT_PERF_WARN_BIT_EXT                       = 0x00000004,
+    VK_DEBUG_REPORT_ERROR_BIT_EXT                           = 0x00000008,
+    VK_DEBUG_REPORT_DEBUG_BIT_EXT                           = 0x00000010,
+}
+
 
 //////////////////
 //  Structures  //
@@ -2534,6 +2590,15 @@
     platform.HWND                               hwnd
 }
 
+@extension("VK_EXT_debug_report")
+class VkDebugReportCallbackCreateInfoEXT {
+    VkStructureType                             sType
+    const void*                                 pNext
+    VkDebugReportFlagsEXT                       flags
+    PFN_vkDebugReportCallbackEXT                pfnCallback
+    void*                                       pUserData
+}
+
 
 ////////////////
 //  Commands  //
@@ -5068,6 +5133,49 @@
     return ?
 }
 
+@extension("VK_EXT_debug_report")
+@external type void* PFN_vkDebugReportCallbackEXT
+@extension("VK_EXT_debug_report")
+@pfn cmd VkBool32 vkDebugReportCallbackEXT(
+        VkDebugReportFlagsEXT                   flags,
+        VkDebugReportObjectTypeEXT              objectType,
+        u64                                     object,
+        platform.size_t                         location,
+        s32                                     messageCode,
+        const char*                             pLayerPrefix,
+        const char*                             pMessage,
+        void*                                   pUserData) {
+    return ?
+}
+
+@extension("VK_EXT_debug_report")
+cmd VkResult vkCreateDebugReportCallbackEXT(
+        VkInstance                                  instance,
+        const VkDebugReportCallbackCreateInfoEXT*   pCreateInfo,
+        const VkAllocationCallbacks*                pAllocator,
+        VkDebugReportCallbackEXT*                   pCallback) {
+    return ?
+}
+
+@extension("VK_EXT_debug_report")
+cmd void vkDestroyDebugReportCallbackEXT(
+        VkInstance                                  instance,
+        VkDebugReportCallbackEXT                    callback,
+        const VkAllocationCallbacks*                pAllocator) {
+}
+
+@extension("VK_EXT_debug_report")
+cmd void vkDebugReportMessageEXT(
+        VkInstance                                  instance,
+        VkDebugReportFlagsEXT                       flags,
+        VkDebugReportObjectTypeEXT                  objectType,
+        u64                                         object,
+        platform.size_t                             location,
+        s32                                         messageCode,
+        const char*                                 pLayerPrefix,
+        const char*                                 pMessage) {
+}
+
 
 ////////////////
 // Validation //