Add xglEnumerateLayers function including support in layers.

Also add this call to xglbase (init.cpp) test.
This commit is contained in:
Jon Ashburn 2014-10-15 15:30:23 -06:00 committed by Courtney Goeltzenleuchter
parent 03989f899d
commit 25767eb45a
3 changed files with 48 additions and 0 deletions

View 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;

View File

@ -110,6 +110,9 @@ TEST(Initialization, xglInitAndEnumerateGpus) {
XGL_UINT gpu_count;
XGL_RESULT err;
XglGpu *gpu;
XGL_CHAR *layers[16];
XGL_SIZE layer_count;
XGL_CHAR layer_buf[16][256];
app_info.sType = XGL_STRUCTURE_TYPE_APPLICATION_INFO;
app_info.pNext = NULL;
@ -124,6 +127,15 @@ TEST(Initialization, xglInitAndEnumerateGpus) {
ASSERT_XGL_SUCCESS(err);
ASSERT_GE(1, gpu_count) << "No GPU available";
for (int i = 0; i < 16; i++)
layers[i] = &layer_buf[i][0];
err = xglEnumerateLayers(objs[0], 16, 256, (XGL_CHAR * const *) layers, &layer_count);
ASSERT_XGL_SUCCESS(err);
for (int i = 0; i < layer_count; i++) {
printf("Enumerated layers: %s ", layers[i]);
}
printf("\n");
// TODO: Iterate over all GPUs
gpu = new XglGpu(0, objs[0]);

9
xgl.py
View File

@ -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")