demos: Convert to using Instancing API rather than xglInitAndEnumerateGpus()
authorJon Ashburn <jon@lunarg.com>
Thu, 29 Jan 2015 22:47:01 +0000 (15:47 -0700)
committerCourtney Goeltzenleuchter <courtney@LunarG.com>
Thu, 5 Feb 2015 00:58:10 +0000 (17:58 -0700)
demos/cube.c
demos/tri.c
demos/xglinfo.c
loader/loader.c

index 56b62c1..a963971 100644 (file)
@@ -193,6 +193,7 @@ struct demo {
     xcb_connection_t *connection;
     xcb_screen_t *screen;
 
+    XGL_INSTANCE inst;
     XGL_PHYSICAL_GPU gpu;
     XGL_DEVICE device;
     XGL_QUEUE queue;
@@ -1478,7 +1479,9 @@ static void demo_init_xgl(struct demo *demo)
     uint32_t gpu_count;
     uint32_t i;
 
-    err = xglInitAndEnumerateGpus(&app, NULL, 1, &gpu_count, &demo->gpu);
+    err = xglCreateInstance(&app, NULL, &demo->inst);
+    assert(!err);
+    err = xglEnumerateGpus(demo->inst, 1, &gpu_count, &demo->gpu);
     assert(!err && gpu_count == 1);
 
     for (i = 0; i < device.extensionCount; i++) {
@@ -1580,6 +1583,7 @@ static void demo_cleanup(struct demo *demo)
     }
 
     xglDestroyDevice(demo->device);
+    xglDestroyInstance(demo->inst);
 
     xcb_destroy_window(demo->connection, demo->window);
     xcb_disconnect(demo->connection);
index 1205174..929d158 100644 (file)
@@ -24,6 +24,7 @@ struct demo {
     xcb_connection_t *connection;
     xcb_screen_t *screen;
 
+    XGL_INSTANCE inst;
     XGL_PHYSICAL_GPU gpu;
     XGL_DEVICE device;
     XGL_QUEUE queue;
@@ -1033,7 +1034,9 @@ static void demo_init_xgl(struct demo *demo)
     uint32_t gpu_count;
     uint32_t i;
 
-    err = xglInitAndEnumerateGpus(&app, NULL, 1, &gpu_count, &demo->gpu);
+    err = xglCreateInstance(&app, NULL, &demo->inst);
+    assert(!err);
+    err = xglEnumerateGpus(demo->inst, 1, &gpu_count, &demo->gpu);
     assert(!err && gpu_count == 1);
 
     for (i = 0; i < device.extensionCount; i++) {
@@ -1124,6 +1127,7 @@ static void demo_cleanup(struct demo *demo)
     }
 
     xglDestroyDevice(demo->device);
+    xglDestroyInstance(demo->inst);
 
     xcb_destroy_window(demo->connection, demo->window);
     xcb_disconnect(demo->connection);
index bfe55a5..dedb9ba 100644 (file)
@@ -654,11 +654,14 @@ int main(int argc, char **argv)
     };
     struct app_gpu gpus[MAX_GPUS];
     XGL_PHYSICAL_GPU objs[MAX_GPUS];
+    XGL_INSTANCE inst;
     uint32_t gpu_count, i;
     XGL_RESULT err;
 
-    err = xglInitAndEnumerateGpus(&app_info, NULL,
-            MAX_GPUS, &gpu_count, objs);
+    err = xglCreateInstance(&app_info, NULL, &inst);
+    if (err)
+        ERR_EXIT(err);
+    err = xglEnumerateGpus(inst, MAX_GPUS, &gpu_count, objs);
     if (err)
         ERR_EXIT(err);
 
@@ -673,7 +676,7 @@ int main(int argc, char **argv)
     for (i = 0; i < gpu_count; i++)
         app_gpu_destroy(&gpus[i]);
 
-    xglInitAndEnumerateGpus(&app_info, NULL, 0, &gpu_count, NULL);
+    xglDestroyInstance(inst);
 
     return 0;
 }
index acb430f..343fb14 100644 (file)
@@ -907,7 +907,7 @@ LOADER_EXPORT XGL_RESULT XGLAPI xglEnumerateGpus(
 {
     struct loader_instance *ptr_instance = (struct loader_instance *) instance;
     struct loader_icd *icd;
-    XGL_UINT count = 0;
+    uint32_t count = 0;
     XGL_RESULT res;
 
     //in spirit of XGL don't error check on the instance parameter
@@ -916,7 +916,7 @@ LOADER_EXPORT XGL_RESULT XGLAPI xglEnumerateGpus(
         XGL_PHYSICAL_GPU gpus[XGL_MAX_PHYSICAL_GPUS];
         XGL_BASE_LAYER_OBJECT * wrapped_gpus;
         xglGetProcAddrType get_proc_addr = icd->scanned_icds->GetProcAddr;
-        XGL_UINT n, max = maxGpus - count;
+        uint32_t n, max = maxGpus - count;
 
         if (max > XGL_MAX_PHYSICAL_GPUS) {
             max = XGL_MAX_PHYSICAL_GPUS;