aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJon Ashburn <jon@lunarg.com>2015-04-04 14:52:07 -0600
committerChia-I Wu <olv@lunarg.com>2015-04-16 17:33:29 +0800
commitab46b3609d75079ae5aedba8d7a04e666eab19dd (patch)
tree402fe078662793a962db536313ebe48c55250417
parent3d98fec8d8c5b9a1e9b45c32ba50ca4ab651754c (diff)
downloadusermoji-ab46b3609d75079ae5aedba8d7a04e666eab19dd.tar.xz
misc: Add create_info struct to CreateInstance()
Allows extnesion or layer enablement at CreateInstance Khronos Bug 13637
-rw-r--r--demos/cube.c11
-rw-r--r--demos/tri.c11
-rw-r--r--demos/xglinfo.c11
-rw-r--r--icd/nulldrv/nulldrv.c3
-rw-r--r--include/xgl.h20
-rw-r--r--layers/glave_snapshot.c6
-rw-r--r--layers/param_checker.cpp6
-rw-r--r--loader/loader.c7
-rw-r--r--xgl.py3
9 files changed, 56 insertions, 22 deletions
diff --git a/demos/cube.c b/demos/cube.c
index e8f174c7..b356bc38 100644
--- a/demos/cube.c
+++ b/demos/cube.c
@@ -1731,6 +1731,14 @@ static void demo_init_xgl(struct demo *demo)
.engineVersion = 0,
.apiVersion = XGL_API_VERSION,
};
+ const XGL_INSTANCE_CREATE_INFO inst_info = {
+ .sType = XGL_STRUCTURE_TYPE_INSTANCE_CREATE_INFO,
+ .pNext = NULL,
+ .pAppInfo = &app,
+ .pAllocCb = NULL,
+ .extensionCount = 0,
+ .ppEnabledExtensionNames = NULL,
+ };
const XGL_WSI_X11_CONNECTION_INFO connection = {
.pConnection = demo->connection,
.root = demo->screen->root,
@@ -1759,7 +1767,7 @@ static void demo_init_xgl(struct demo *demo)
size_t data_size;
uint32_t queue_count;
- err = xglCreateInstance(&app, NULL, &demo->inst);
+ err = xglCreateInstance(&inst_info, &demo->inst);
if (err == XGL_ERROR_INCOMPATIBLE_DRIVER) {
printf("Cannot find a compatible Vulkan installable client driver "
"(ICD).\nExiting ...\n");
@@ -1768,6 +1776,7 @@ static void demo_init_xgl(struct demo *demo)
} else {
assert(!err);
}
+
err = xglEnumerateGpus(demo->inst, 1, &gpu_count, &demo->gpu);
assert(!err && gpu_count == 1);
diff --git a/demos/tri.c b/demos/tri.c
index b702cab7..1dfd5c97 100644
--- a/demos/tri.c
+++ b/demos/tri.c
@@ -1253,6 +1253,14 @@ static void demo_init_xgl(struct demo *demo)
.engineVersion = 0,
.apiVersion = XGL_API_VERSION,
};
+ const XGL_INSTANCE_CREATE_INFO inst_info = {
+ .sType = XGL_STRUCTURE_TYPE_INSTANCE_CREATE_INFO,
+ .pNext = NULL,
+ .pAppInfo = &app,
+ .pAllocCb = NULL,
+ .extensionCount = 0,
+ .ppEnabledExtensionNames = NULL,
+ };
const XGL_WSI_X11_CONNECTION_INFO connection = {
.pConnection = demo->connection,
.root = demo->screen->root,
@@ -1281,7 +1289,7 @@ static void demo_init_xgl(struct demo *demo)
size_t data_size;
uint32_t queue_count;
- err = xglCreateInstance(&app, NULL, &demo->inst);
+ err = xglCreateInstance(&inst_info, &demo->inst);
if (err == XGL_ERROR_INCOMPATIBLE_DRIVER) {
printf("Cannot find a compatible Vulkan installable client driver "
"(ICD).\nExiting ...\n");
@@ -1290,6 +1298,7 @@ static void demo_init_xgl(struct demo *demo)
} else {
assert(!err);
}
+
err = xglEnumerateGpus(demo->inst, 1, &gpu_count, &demo->gpu);
assert(!err && gpu_count == 1);
diff --git a/demos/xglinfo.c b/demos/xglinfo.c
index 76d70c5c..ace6d03b 100644
--- a/demos/xglinfo.c
+++ b/demos/xglinfo.c
@@ -652,19 +652,28 @@ int main(int argc, char **argv)
.engineVersion = 1,
.apiVersion = XGL_API_VERSION,
};
+ static const XGL_INSTANCE_CREATE_INFO inst_info = {
+ .sType = XGL_STRUCTURE_TYPE_INSTANCE_CREATE_INFO,
+ .pNext = NULL,
+ .pAppInfo = &app_info,
+ .pAllocCb = NULL,
+ .extensionCount = 0,
+ .ppEnabledExtensionNames = NULL,
+ };
struct app_gpu gpus[MAX_GPUS];
XGL_PHYSICAL_GPU objs[MAX_GPUS];
XGL_INSTANCE inst;
uint32_t gpu_count, i;
XGL_RESULT err;
- err = xglCreateInstance(&app_info, NULL, &inst);
+ err = xglCreateInstance(&inst_info, &inst);
if (err == XGL_ERROR_INCOMPATIBLE_DRIVER) {
printf("Cannot find a compatible Vulkan installable client driver "
"(ICD).\nExiting ...\n");
fflush(stdout);
exit(1);
} else if (err) {
+
ERR_EXIT(err);
}
err = xglEnumerateGpus(inst, MAX_GPUS, &gpu_count, objs);
diff --git a/icd/nulldrv/nulldrv.c b/icd/nulldrv/nulldrv.c
index 43a35af1..0769fc83 100644
--- a/icd/nulldrv/nulldrv.c
+++ b/icd/nulldrv/nulldrv.c
@@ -1492,8 +1492,7 @@ ICD_EXPORT XGL_RESULT XGLAPI xglOpenPeerMemory(
}
ICD_EXPORT XGL_RESULT XGLAPI xglCreateInstance(
- const XGL_APPLICATION_INFO* pAppInfo,
- const XGL_ALLOC_CALLBACKS* pAllocCb,
+ const XGL_INSTANCE_CREATE_INFO* pCreateInfo,
XGL_INSTANCE* pInstance)
{
NULLDRV_LOG_FUNC;
diff --git a/include/xgl.h b/include/xgl.h
index 92fb1ccb..28c32d0d 100644
--- a/include/xgl.h
+++ b/include/xgl.h
@@ -1056,9 +1056,9 @@ typedef enum _XGL_STRUCTURE_TYPE
XGL_STRUCTURE_TYPE_UPDATE_AS_COPY = 53,
XGL_STRUCTURE_TYPE_MEMORY_ALLOC_BUFFER_INFO = 54,
XGL_STRUCTURE_TYPE_MEMORY_ALLOC_IMAGE_INFO = 55,
-
+ XGL_STRUCTURE_TYPE_INSTANCE_CREATE_INFO = 56,
XGL_STRUCTURE_TYPE_BEGIN_RANGE = XGL_STRUCTURE_TYPE_APPLICATION_INFO,
- XGL_STRUCTURE_TYPE_END_RANGE = XGL_STRUCTURE_TYPE_MEMORY_ALLOC_IMAGE_INFO,
+ XGL_STRUCTURE_TYPE_END_RANGE = XGL_STRUCTURE_TYPE_INSTANCE_CREATE_INFO,
XGL_NUM_STRUCTURE_TYPE = (XGL_STRUCTURE_TYPE_END_RANGE - XGL_STRUCTURE_TYPE_BEGIN_RANGE + 1),
XGL_MAX_ENUM(_XGL_STRUCTURE_TYPE)
} XGL_STRUCTURE_TYPE;
@@ -1411,6 +1411,17 @@ typedef struct _XGL_DEVICE_CREATE_INFO
XGL_FLAGS flags; // XGL_DEVICE_CREATE_FLAGS
} XGL_DEVICE_CREATE_INFO;
+typedef struct _XGL_INSTANCE_CREATE_INFO
+{
+ XGL_STRUCTURE_TYPE sType; // Should be XGL_STRUCTURE_TYPE_INSTANCE_CREATE_INFO
+ const void* pNext; // Pointer to next structure
+ const XGL_APPLICATION_INFO* pAppInfo;
+ const XGL_ALLOC_CALLBACKS* pAllocCb;
+ uint32_t extensionCount;
+ const char*const* ppEnabledExtensionNames; // layer or extension name to be enabled
+} XGL_INSTANCE_CREATE_INFO;
+
+// can be added to XGL_DEVICE_CREATE_INFO or XGL_INSTANCE_CREATE_INFO via pNext
typedef struct _XGL_LAYER_CREATE_INFO
{
XGL_STRUCTURE_TYPE sType; // Should be XGL_STRUCTURE_TYPE_LAYER_CREATE_INFO
@@ -2252,7 +2263,7 @@ typedef struct _XGL_DISPATCH_INDIRECT_CMD
// ------------------------------------------------------------------------------------------------
// API functions
-typedef XGL_RESULT (XGLAPI *xglCreateInstanceType)(const XGL_APPLICATION_INFO* pAppInfo, const XGL_ALLOC_CALLBACKS* pAllocCb, XGL_INSTANCE* pInstance);
+typedef XGL_RESULT (XGLAPI *xglCreateInstanceType)(const XGL_INSTANCE_CREATE_INFO* pCreateInfo, XGL_INSTANCE* pInstance);
typedef XGL_RESULT (XGLAPI *xglDestroyInstanceType)(XGL_INSTANCE instance);
typedef XGL_RESULT (XGLAPI *xglEnumerateGpusType)(XGL_INSTANCE instance, uint32_t maxGpus, uint32_t* pGpuCount, XGL_PHYSICAL_GPU* pGpus);
typedef XGL_RESULT (XGLAPI *xglGetGpuInfoType)(XGL_PHYSICAL_GPU gpu, XGL_PHYSICAL_GPU_INFO_TYPE infoType, size_t* pDataSize, void* pData);
@@ -2372,8 +2383,7 @@ typedef void (XGLAPI *xglCmdEndRenderPassType)(XGL_CMD_BUFFER cmdBuffer, X
// GPU initialization
XGL_RESULT XGLAPI xglCreateInstance(
- const XGL_APPLICATION_INFO* pAppInfo,
- const XGL_ALLOC_CALLBACKS* pAllocCb,
+ const XGL_INSTANCE_CREATE_INFO* pCreateInfo,
XGL_INSTANCE* pInstance);
XGL_RESULT XGLAPI xglDestroyInstance(
diff --git a/layers/glave_snapshot.c b/layers/glave_snapshot.c
index 3af97440..e757f2b0 100644
--- a/layers/glave_snapshot.c
+++ b/layers/glave_snapshot.c
@@ -463,11 +463,11 @@ static void initGlaveSnapshot(void)
//=============================================================================
// vulkan entrypoints
//=============================================================================
-XGL_LAYER_EXPORT XGL_RESULT XGLAPI xglCreateInstance(const XGL_APPLICATION_INFO* pAppInfo, const XGL_ALLOC_CALLBACKS* pAllocCb, XGL_INSTANCE* pInstance)
+XGL_LAYER_EXPORT XGL_RESULT XGLAPI xglCreateInstance(const XGL_INSTANCE_CREATE_INFO* pCreateInfo, XGL_INSTANCE* pInstance)
{
- XGL_RESULT result = nextTable.CreateInstance(pAppInfo, pAllocCb, pInstance);
+ XGL_RESULT result = nextTable.CreateInstance(pCreateInfo, pInstance);
loader_platform_thread_lock_mutex(&objLock);
-
+ snapshot_insert_object(&s_delta, *pInstance, XGL_OBJECT_TYPE_INSTANCE);
loader_platform_thread_unlock_mutex(&objLock);
return result;
}
diff --git a/layers/param_checker.cpp b/layers/param_checker.cpp
index 6da0f0c5..ebfe65fc 100644
--- a/layers/param_checker.cpp
+++ b/layers/param_checker.cpp
@@ -123,10 +123,10 @@ void PostCreateInstance(XGL_RESULT result, XGL_INSTANCE* pInstance)
}
}
-XGL_LAYER_EXPORT XGL_RESULT XGLAPI xglCreateInstance(const XGL_APPLICATION_INFO* pAppInfo, const XGL_ALLOC_CALLBACKS* pAllocCb, XGL_INSTANCE* pInstance)
+XGL_LAYER_EXPORT XGL_RESULT XGLAPI xglCreateInstance(const XGL_INSTANCE_CREATE_INFO* pCreateInfo, XGL_INSTANCE* pInstance)
{
- PreCreateInstance(pAppInfo, pAllocCb);
- XGL_RESULT result = nextTable.CreateInstance(pAppInfo, pAllocCb, pInstance);
+ PreCreateInstance(pCreateInfo->pAppInfo, pCreateInfo->pAllocCb);
+ XGL_RESULT result = nextTable.CreateInstance(pCreateInfo, pInstance);
PostCreateInstance(result, pInstance);
return result;
}
diff --git a/loader/loader.c b/loader/loader.c
index 556c2b3c..7ea486a8 100644
--- a/loader/loader.c
+++ b/loader/loader.c
@@ -858,9 +858,8 @@ extern uint32_t loader_activate_layers(XGL_PHYSICAL_GPU gpu, const XGL_DEVICE_CR
}
LOADER_EXPORT XGL_RESULT XGLAPI xglCreateInstance(
- const XGL_APPLICATION_INFO* pAppInfo,
- const XGL_ALLOC_CALLBACKS* pAllocCb,
- XGL_INSTANCE* pInstance)
+ const XGL_INSTANCE_CREATE_INFO* pCreateInfo,
+ XGL_INSTANCE* pInstance)
{
static LOADER_PLATFORM_THREAD_ONCE_DECLARATION(once_icd);
static LOADER_PLATFORM_THREAD_ONCE_DECLARATION(once_layer);
@@ -888,7 +887,7 @@ LOADER_EXPORT XGL_RESULT XGLAPI xglCreateInstance(
while (scanned_icds) {
icd = loader_icd_add(ptr_instance, scanned_icds);
if (icd) {
- res = scanned_icds->CreateInstance(pAppInfo, pAllocCb,
+ res = scanned_icds->CreateInstance(pCreateInfo,
&(scanned_icds->instance));
if (res != XGL_SUCCESS)
{
diff --git a/xgl.py b/xgl.py
index 1b372f0e..3a2d7287 100644
--- a/xgl.py
+++ b/xgl.py
@@ -218,8 +218,7 @@ core = Extension(
],
protos=[
Proto("XGL_RESULT", "CreateInstance",
- [Param("const XGL_APPLICATION_INFO*", "pAppInfo"),
- Param("const XGL_ALLOC_CALLBACKS*", "pAllocCb"),
+ [Param("const XGL_INSTANCE_CREATE_INFO*", "pCreateInfo"),
Param("XGL_INSTANCE*", "pInstance")]),
Proto("XGL_RESULT", "DestroyInstance",