intel: Instance functions create and destroy objects

Also they do the same init and removal as existing InitAndEnumerateGpus.
diff --git a/icd/intel/intel.c b/icd/intel/intel.c
index 95936ec..8a7f02a 100644
--- a/icd/intel/intel.c
+++ b/icd/intel/intel.c
@@ -134,18 +134,56 @@
     return (count > 0) ? XGL_SUCCESS : XGL_ERROR_UNAVAILABLE;
 }
 
+static XGL_RESULT intel_instance_destroy(struct intel_instance *inst)
+{
+    intel_base_destroy(&inst->obj.base);
+    intel_gpu_remove_all();
+    return XGL_SUCCESS;
+}
+
+static void inst_destroy(struct intel_obj *obj)
+{
+    struct intel_instance *inst = intel_instance_from_obj(obj);
+
+    intel_instance_destroy(inst);
+}
+
+static XGL_RESULT intel_instance_create(
+    const XGL_APPLICATION_INFO*                 info,
+    const XGL_ALLOC_CALLBACKS*                  cb,
+    struct intel_instance**                         inst_ret)
+{
+    struct intel_instance *inst;
+    XGL_RESULT ret;
+
+    inst = (struct intel_instance *) intel_base_create(NULL, sizeof(*inst), false,
+                XGL_DBG_OBJECT_INSTANCE, info, 0);
+    if (!inst)
+        return XGL_ERROR_OUT_OF_MEMORY;
+
+    inst->obj.destroy = inst_destroy;
+    inst->obj.base.get_info = intel_base_get_info;
+
+    *inst_ret = inst;
+
+    intel_debug_init();
+
+    ret = icd_allocator_init(cb);
+    return ret;
+}
+
 ICD_EXPORT XGL_RESULT XGLAPI xglCreateInstance(
     const XGL_APPLICATION_INFO*                 pAppInfo,
     const XGL_ALLOC_CALLBACKS*                  pAllocCb,
     XGL_INSTANCE*                               pInstance)
 {
-    return XGL_SUCCESS;
+    return intel_instance_create(pAppInfo, pAllocCb, (struct intel_instance **) pInstance);
 }
 
 ICD_EXPORT XGL_RESULT XGLAPI xglDestroyInstance(
     XGL_INSTANCE                                pInstance)
 {
-    return XGL_SUCCESS;
+    return intel_instance_destroy((struct intel_instance *) pInstance);
 }
 
 ICD_EXPORT XGL_RESULT XGLAPI xglEnumerateGpus(
diff --git a/icd/intel/intel.h b/icd/intel/intel.h
index 809708c..fbef52d 100644
--- a/icd/intel/intel.h
+++ b/icd/intel/intel.h
@@ -44,6 +44,7 @@
 #include "icd-format.h"
 #include "icd-log.h"
 #include "icd-utils.h"
+#include "obj.h"
 
 #define INTEL_API_VERSION XGL_MAKE_VERSION(0, 22, 0)
 #define INTEL_DRIVER_VERSION 0
@@ -54,6 +55,9 @@
 #define INTEL_MAX_VERTEX_ELEMENT_COUNT (INTEL_MAX_VERTEX_BINDING_COUNT + 1)
 #define INTEL_MAX_RENDER_TARGETS 8
 
+struct intel_instance {
+    struct intel_obj obj;
+};
 
 enum intel_debug_flags {
     INTEL_DEBUG_BATCH       = 1 << 0,
@@ -64,4 +68,14 @@
 
 extern int intel_debug;
 
+static inline struct intel_instance *intel_instance_from_base(struct intel_base *base)
+{
+    return (struct intel_instance *) base;
+}
+
+static inline struct intel_instance *intel_instance_from_obj(struct intel_obj *obj)
+{
+    return intel_instance_from_base(&obj->base);
+}
+
 #endif /* INTEL_H */
diff --git a/include/xglDbg.h b/include/xglDbg.h
index b040710..dfed1a8 100644
--- a/include/xglDbg.h
+++ b/include/xglDbg.h
@@ -87,6 +87,7 @@
     XGL_DBG_OBJECT_FRAMEBUFFER            = 0x1d,
     XGL_DBG_OBJECT_RENDER_PASS            = 0x1e,
 
+    XGL_DBG_OBJECT_INSTANCE,
     XGL_DBG_OBJECT_BUFFER,
     XGL_DBG_OBJECT_BUFFER_VIEW,
     XGL_DBG_OBJECT_DESCRIPTOR_SET_LAYOUT,