From 80ddae038ce1d02e35bf26eada99e9500e01fac1 Mon Sep 17 00:00:00 2001 From: Jon Ashburn Date: Wed, 15 Oct 2014 15:30:23 -0600 Subject: [PATCH] Add xglEnumerateLayers function including support in layers. Also add this call to xglbase (init.cpp) test. --- include/xgl.h | 8 ++++++++ include/xglLayer.h | 7 ++----- layers/basic_plugin.c | 3 +++ loader/loader.c | 27 +++++++++++++++++++++++++++ xgl.py | 9 +++++++++ 5 files changed, 49 insertions(+), 5 deletions(-) diff --git a/include/xgl.h b/include/xgl.h index 7f3986c..b810c04 100644 --- a/include/xgl.h +++ b/include/xgl.h @@ -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( diff --git a/include/xglLayer.h b/include/xglLayer.h index b762e57..f139fff 100644 --- a/include/xglLayer.h +++ b/include/xglLayer.h @@ -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); diff --git a/layers/basic_plugin.c b/layers/basic_plugin.c index c13aace..e0928c2 100644 --- a/layers/basic_plugin.c +++ b/layers/basic_plugin.c @@ -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"))) diff --git a/loader/loader.c b/loader/loader.c index c86ada2..952367f 100644 --- a/loader/loader.c +++ b/loader/loader.c @@ -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 --- 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") -- 2.7.4