Add xglEnumerateLayers function including support in layers.
authorJon Ashburn <jon@lunarg.com>
Wed, 15 Oct 2014 21:30:23 +0000 (15:30 -0600)
committerCourtney Goeltzenleuchter <courtney@LunarG.com>
Thu, 30 Oct 2014 00:01:59 +0000 (18:01 -0600)
Also add this call to xglbase (init.cpp) test.

include/xgl.h
include/xglLayer.h
layers/basic_plugin.c
loader/loader.c
xgl.py

index 7f3986c..b810c04 100644 (file)
@@ -1796,6 +1796,14 @@ XGL_RESULT XGLAPI xglGetExtensionSupport(
     XGL_PHYSICAL_GPU                            gpu,
     const XGL_CHAR*                             pExtName);
 
+// Layer discovery function
+XGL_RESULT XGLAPI xglEnumerateLayers(
+    XGL_PHYSICAL_GPU gpu,
+    XGL_SIZE maxLayerCount,
+    XGL_SIZE maxStringSize,
+    XGL_CHAR* const* pOutLayers,
+    XGL_SIZE* pOutLayerCount);
+
 // Queue functions
 
 XGL_RESULT XGLAPI xglGetDeviceQueue(
index b762e57..f139fff 100644 (file)
@@ -21,6 +21,7 @@ typedef XGL_RESULT (XGLAPI *GetGpuInfoType)(XGL_PHYSICAL_GPU gpu, XGL_PHYSICAL_G
 typedef XGL_RESULT (XGLAPI *CreateDeviceType)(XGL_PHYSICAL_GPU gpu, const XGL_DEVICE_CREATE_INFO* pCreateInfo, XGL_DEVICE* pDevice);
 typedef XGL_RESULT (XGLAPI *DestroyDeviceType)(XGL_DEVICE device);
 typedef XGL_RESULT (XGLAPI *GetExtensionSupportType)(XGL_PHYSICAL_GPU gpu, const XGL_CHAR* pExtName);
+typedef XGL_RESULT (XGLAPI *EnumerateLayersType)(XGL_PHYSICAL_GPU gpu, XGL_SIZE maxLayerCount, XGL_SIZE maxStringSize, XGL_CHAR* const* pOutLayers, XGL_SIZE* pOutLayerCount);
 typedef XGL_RESULT (XGLAPI *GetDeviceQueueType)(XGL_DEVICE device, XGL_QUEUE_TYPE queueType, XGL_UINT queueIndex, XGL_QUEUE* pQueue);
 typedef XGL_RESULT (XGLAPI *QueueSubmitType)(XGL_QUEUE queue, XGL_UINT cmdBufferCount, const XGL_CMD_BUFFER* pCmdBuffers, XGL_UINT memRefCount, const XGL_MEMORY_REF* pMemRefs, XGL_FENCE fence);
 typedef XGL_RESULT (XGLAPI *QueueSetGlobalMemReferencesType)(XGL_QUEUE queue, XGL_UINT memRefCount, const XGL_MEMORY_REF* pMemRefs);
@@ -150,6 +151,7 @@ typedef struct _XGL_LAYER_DISPATCH_TABLE
     CreateDeviceType CreateDevice;
     DestroyDeviceType DestroyDevice;
     GetExtensionSupportType GetExtensionSupport;
+    EnumerateLayersType EnumerateLayers;
     GetDeviceQueueType GetDeviceQueue;
     QueueSubmitType QueueSubmit;
     QueueSetGlobalMemReferencesType QueueSetGlobalMemReferences;
@@ -267,8 +269,3 @@ typedef struct _XGL_LAYER_DISPATCH_TABLE
 
 // ------------------------------------------------------------------------------------------------
 // API functions
-XGL_RESULT xglEnumerateLayers(
-    XGL_PHYSICAL_GPU gpu,
-    XGL_SIZE maxLayerCount,
-    XGL_CHAR* const* pOutLayers,
-    XGL_SIZE* pOutLayerCount);
index c13aace..e0928c2 100644 (file)
@@ -22,6 +22,7 @@ static void initLayerTable()
     myTable.CreateDevice = fpGPA((XGL_PHYSICAL_GPU) pCurObj->nextObject, (const XGL_CHAR *) "xglCreateDevice");
     myTable.DestroyDevice = fpGPA((XGL_PHYSICAL_GPU) pCurObj->nextObject, (const XGL_CHAR *) "xglDestroyDevice");
     myTable.GetExtensionSupport = fpGPA((XGL_PHYSICAL_GPU) pCurObj->nextObject, (const XGL_CHAR *) "xglGetExtensionSupport");
+    myTable.EnumerateLayers = fpGPA((XGL_PHYSICAL_GPU) pCurObj->nextObject, (const XGL_CHAR *) "xglEnumerateLayers");
     myTable.GetDeviceQueue = fpGPA((XGL_PHYSICAL_GPU) pCurObj->nextObject, (const XGL_CHAR *) "xglGetDeviceQueue");
     myTable.QueueSubmit = fpGPA((XGL_PHYSICAL_GPU) pCurObj->nextObject, (const XGL_CHAR *) "xglQueueSubmit");
     myTable.QueueSetGlobalMemReferences = fpGPA((XGL_PHYSICAL_GPU) pCurObj->nextObject, (const XGL_CHAR *) "xglQueueSetGlobalMemReferences");
@@ -185,6 +186,8 @@ XGL_LAYER_EXPORT void * XGLAPI xglGetProcAddr(XGL_PHYSICAL_GPU gpu, const XGL_CH
         return myTable.DestroyDevice;
     else if (!strncmp("xglGetExtensionSupport", (const char *) pName, sizeof ("xglGetExtensionSupport")))
         return myTable.GetExtensionSupport;
+    else if (!strncmp("xglEnumerateLayers", (const char *) pName, sizeof ("xglEnumerateLayers")))
+        return myTable.EnumerateLayers;
     else if (!strncmp("xglGetDeviceQueue", (const char *) pName, sizeof ("xglGetDeviceQueue")))
         return myTable.GetDeviceQueue;
     else if (!strncmp("xglQueueSubmit", (const char *) pName, sizeof ("xglQueueSubmit")))
index c86ada2..952367f 100644 (file)
@@ -491,6 +491,9 @@ static void init_dispatch_table(XGL_LAYER_DISPATCH_TABLE *tab, GetProcAddrType f
     tab->CreateDevice = fpGPA(gpu, (const XGL_CHAR *) "xglCreateDevice");
     tab->DestroyDevice = fpGPA(gpu, (const XGL_CHAR *) "xglDestroyDevice");
     tab->GetExtensionSupport = fpGPA(gpu, (const XGL_CHAR *) "xglGetExtensionSupport");
+    tab->EnumerateLayers = fpGPA(gpu, (const XGL_CHAR *) "xglEnumerateLayers");
+    if (tab->EnumerateLayers == NULL)
+        tab->EnumerateLayers = xglEnumerateLayers;
     tab->GetDeviceQueue = fpGPA(gpu, (const XGL_CHAR *) "xglGetDeviceQueue");
     tab->QueueSubmit = fpGPA(gpu, (const XGL_CHAR *) "xglQueueSubmit");
     tab->QueueSetGlobalMemReferences = fpGPA(gpu, (const XGL_CHAR *) "xglQueueSetGlobalMemReferences");
@@ -722,6 +725,8 @@ LOADER_EXPORT void * XGLAPI xglGetProcAddr(XGL_PHYSICAL_GPU gpu, const XGL_CHAR
         return disp_table->DestroyDevice;
     else if (!strncmp("xglGetExtensionSupport", (const char *) pName, sizeof ("xglGetExtensionSupport")))
         return disp_table->GetExtensionSupport;
+    else if (!strncmp("xglEnumerateLayers", (const char *) pName, sizeof ("xglEnumerateLayers")))
+        return disp_table->EnumerateLayers;
     else if (!strncmp("xglGetDeviceQueue", (const char *) pName, sizeof ("xglGetDeviceQueue")))
         return disp_table->GetDeviceQueue;
     else if (!strncmp("xglQueueSubmit", (const char *) pName, sizeof ("xglQueueSubmit")))
@@ -1012,6 +1017,28 @@ LOADER_EXPORT XGL_RESULT XGLAPI xglInitAndEnumerateGpus(const XGL_APPLICATION_IN
     return (count > 0) ? XGL_SUCCESS : res;
 }
 
+LOADER_EXPORT XGL_RESULT XGLAPI xglEnumerateLayers(XGL_PHYSICAL_GPU gpu, XGL_SIZE maxLayerCount, XGL_SIZE maxStringSize, XGL_CHAR* const* pOutLayers, XGL_SIZE* pOutLayerCount)
+{
+    XGL_SIZE count = loader.layer_count;
+    // TODO handle layers per GPU, multiple icds
+
+    if (pOutLayerCount == NULL)
+        return XGL_ERROR_INVALID_POINTER;
+
+    if (maxLayerCount < loader.layer_count)
+        count = maxLayerCount;
+    *pOutLayerCount = count;
+
+    if (pOutLayers == NULL)
+        return XGL_SUCCESS;
+    for (XGL_SIZE i = 0; i < count; i++) {
+        strncpy((char *) (pOutLayers[i]), loader.layer_libs[i].lib_name, maxStringSize);
+        if (maxStringSize > 0)
+            pOutLayers[i][maxStringSize - 1] = '\0';
+    }
+    return XGL_SUCCESS;
+}
+
 LOADER_EXPORT XGL_RESULT XGLAPI xglDbgRegisterMsgCallback(XGL_DBG_MSG_CALLBACK_FUNCTION pfnMsgCallback, XGL_VOID* pUserData)
 {
     const struct loader_icd *icd = loader.icds;
diff --git a/xgl.py b/xgl.py
index 6f2b738..dbdd063 100644 (file)
--- a/xgl.py
+++ b/xgl.py
@@ -116,6 +116,13 @@ core = (
         (Param("XGL_PHYSICAL_GPU", "gpu"),
          Param("const XGL_CHAR*", "pExtName"))),
 
+    Proto("XGL_RESULT", "EnumerateLayers",
+        (Param("XGL_PHYSICAL_GPU", "gpu"),
+         Param("XGL_SIZE", "maxLayerCount"),
+         Param("XGL_SIZE", "maxStringSize"),
+         Param("XGL_CHAR* const*", "pOutLayers"),
+         Param("XGL_SIZE *", "pOutLayerCount"))),
+
     Proto("XGL_RESULT", "GetDeviceQueue",
         (Param("XGL_DEVICE", "device"),
          Param("XGL_QUEUE_TYPE", "queueType"),
@@ -736,6 +743,7 @@ icd_dispatch_table = (
     "CreateDevice",
     "DestroyDevice",
     "GetExtensionSupport",
+    "EnumerateLayers",
     "GetDeviceQueue",
     "QueueSubmit",
     "QueueSetGlobalMemReferences",
@@ -856,6 +864,7 @@ def is_name_dispatchable(name):
     return name not in (
         "GetProcAddr",
         "InitAndEnumerateGpus",
+        "EnumerateLayers",
         "DbgRegisterMsgCallback",
         "DbgUnregisterMsgCallback",
         "DbgSetGlobalOption")