* Chia-I Wu <olv@lunarg.com>
*/
+#include "xglIcd.h"
#include "icd-enumerate-drm.h"
#include "gpu.h"
-#include "intel.h"
+#include "instance.h"
static int intel_devid_override;
int intel_debug = -1;
}
}
-static XGL_RESULT intel_instance_destroy(struct intel_instance *inst)
+static void intel_instance_destroy(struct intel_instance *instance)
{
- intel_base_destroy(&inst->obj.base);
intel_gpu_remove_all();
- return XGL_SUCCESS;
+ icd_free(instance);
}
-static void inst_destroy(struct intel_obj *obj)
+static struct intel_instance *intel_instance_create(const XGL_APPLICATION_INFO *app_info,
+ const XGL_ALLOC_CALLBACKS *alloc_cb)
{
- struct intel_instance *inst = intel_instance_from_obj(obj);
-
- intel_instance_destroy(inst);
-}
+ struct intel_instance *instance;
-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;
+ intel_debug_init();
- inst->obj.destroy = inst_destroy;
- inst->obj.base.get_info = intel_base_get_info;
+ instance = icd_alloc(sizeof(*instance), 0, XGL_SYSTEM_ALLOC_API_OBJECT);
+ if (!instance)
+ return NULL;
- *inst_ret = inst;
+ memset(instance, 0, sizeof(*instance));
+ set_loader_magic_value(instance);
- intel_debug_init();
+ icd_allocator_init(alloc_cb);
- ret = icd_allocator_init(cb);
- return ret;
+ return instance;
}
ICD_EXPORT XGL_RESULT XGLAPI xglCreateInstance(
const XGL_ALLOC_CALLBACKS* pAllocCb,
XGL_INSTANCE* pInstance)
{
- return intel_instance_create(pAppInfo, pAllocCb, (struct intel_instance **) pInstance);
+ struct intel_instance *instance;
+
+ instance = intel_instance_create(pAppInfo, pAllocCb);
+ if (!instance)
+ return XGL_ERROR_OUT_OF_MEMORY;
+
+ *pInstance = (XGL_INSTANCE) instance;
+
+ return XGL_SUCCESS;
}
ICD_EXPORT XGL_RESULT XGLAPI xglDestroyInstance(
XGL_INSTANCE pInstance)
{
- return intel_instance_destroy((struct intel_instance *) pInstance);
+ struct intel_instance *instance = intel_instance(pInstance);
+
+ intel_instance_destroy(instance);
+
+ return XGL_SUCCESS;
}
ICD_EXPORT XGL_RESULT XGLAPI xglEnumerateGpus(
--- /dev/null
+/*
+ * XGL
+ *
+ * Copyright (C) 2015 LunarG, Inc.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ * DEALINGS IN THE SOFTWARE.
+ *
+ * Authors:
+ * Chia-I Wu <olv@lunarg.com>
+ */
+
+#ifndef INSTANCE_H
+#define INSTANCE_H
+
+#include "intel.h"
+
+struct intel_instance {
+ /* the loader expects a "void *" at the beginning */
+ void *loader_data;
+};
+
+static inline struct intel_instance *intel_instance(XGL_INSTANCE instance)
+{
+ return (struct intel_instance *) instance;
+}
+
+#endif /* INSTANCE_H */
#include "icd-format.h"
#include "icd-log.h"
#include "icd-utils.h"
-#include "obj.h"
#define INTEL_API_VERSION XGL_API_VERSION
#define INTEL_DRIVER_VERSION 0
#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,
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 */