layers: Update xglEnumerateLayers() to work with layer names
Use layer names in the librarires rather than library filenames.
diff --git a/layers/draw_state.c b/layers/draw_state.c
index 1ad7667..d5b8f19 100644
--- a/layers/draw_state.c
+++ b/layers/draw_state.c
@@ -929,11 +929,22 @@
XGL_LAYER_EXPORT XGL_RESULT XGLAPI xglEnumerateLayers(XGL_PHYSICAL_GPU gpu, XGL_SIZE maxLayerCount, XGL_SIZE maxStringSize, XGL_CHAR* const* pOutLayers, XGL_SIZE * pOutLayerCount)
{
- XGL_BASE_LAYER_OBJECT* gpuw = (XGL_BASE_LAYER_OBJECT *) gpu;
- pCurObj = gpuw;
- pthread_once(&tabOnce, initLayerTable);
- XGL_RESULT result = nextTable.EnumerateLayers((XGL_PHYSICAL_GPU)gpuw->nextObject, maxLayerCount, maxStringSize, pOutLayers, pOutLayerCount);
- return result;
+ if (gpu != NULL)
+ {
+ XGL_BASE_LAYER_OBJECT* gpuw = (XGL_BASE_LAYER_OBJECT *) gpu;
+ pCurObj = gpuw;
+ pthread_once(&tabOnce, initLayerTable);
+ XGL_RESULT result = nextTable.EnumerateLayers((XGL_PHYSICAL_GPU)gpuw->nextObject, maxLayerCount, maxStringSize, pOutLayers, pOutLayerCount);
+ return result;
+ } else
+ {
+ if (pOutLayerCount == NULL || pOutLayers == NULL || pOutLayers[0] == NULL)
+ return XGL_ERROR_INVALID_POINTER;
+ // This layer compatible with all GPUs
+ *pOutLayerCount = 1;
+ strncpy(pOutLayers[0], "draw_state", maxStringSize);
+ return XGL_SUCCESS;
+ }
}
XGL_LAYER_EXPORT XGL_RESULT XGLAPI xglGetDeviceQueue(XGL_DEVICE device, XGL_QUEUE_TYPE queueType, XGL_UINT queueIndex, XGL_QUEUE* pQueue)
diff --git a/layers/mem_tracker.c b/layers/mem_tracker.c
index 22da4d2..9cf7e93 100644
--- a/layers/mem_tracker.c
+++ b/layers/mem_tracker.c
@@ -1094,11 +1094,22 @@
XGL_LAYER_EXPORT XGL_RESULT XGLAPI xglEnumerateLayers(XGL_PHYSICAL_GPU gpu, XGL_SIZE maxLayerCount, XGL_SIZE maxStringSize, XGL_CHAR* const* pOutLayers, XGL_SIZE * pOutLayerCount)
{
- XGL_BASE_LAYER_OBJECT* gpuw = (XGL_BASE_LAYER_OBJECT *) gpu;
- pCurObj = gpuw;
- pthread_once(&tabOnce, initLayerTable);
- XGL_RESULT result = nextTable.EnumerateLayers((XGL_PHYSICAL_GPU)gpuw->nextObject, maxLayerCount, maxStringSize, pOutLayers, pOutLayerCount);
- return result;
+ if (gpu != NULL)
+ {
+ XGL_BASE_LAYER_OBJECT* gpuw = (XGL_BASE_LAYER_OBJECT *) gpu;
+ pCurObj = gpuw;
+ pthread_once(&tabOnce, initLayerTable);
+ XGL_RESULT result = nextTable.EnumerateLayers((XGL_PHYSICAL_GPU)gpuw->nextObject, maxLayerCount, maxStringSize, pOutLayers, pOutLayerCount);
+ return result;
+ } else
+ {
+ if (pOutLayerCount == NULL || pOutLayers == NULL || pOutLayers[0] == NULL)
+ return XGL_ERROR_INVALID_POINTER;
+ // This layer compatible with all GPUs
+ *pOutLayerCount = 1;
+ strncpy(pOutLayers[0], "mem_tracker", maxStringSize);
+ return XGL_SUCCESS;
+ }
}
XGL_LAYER_EXPORT XGL_RESULT XGLAPI xglGetDeviceQueue(XGL_DEVICE device, XGL_QUEUE_TYPE queueType, XGL_UINT queueIndex, XGL_QUEUE* pQueue)
diff --git a/xgl-layer-generate.py b/xgl-layer-generate.py
index 5746ea7..1fc9b2a 100755
--- a/xgl-layer-generate.py
+++ b/xgl-layer-generate.py
@@ -153,7 +153,29 @@
if proto.ret != "XGL_VOID":
ret_val = "XGL_RESULT result = "
stmt = " return result;\n"
- if proto.params[0].ty != "XGL_PHYSICAL_GPU":
+ if proto.name == "EnumerateLayers":
+ c_call = proto.c_call().replace("(" + proto.params[0].name, "((XGL_PHYSICAL_GPU)gpuw->nextObject", 1)
+ funcs.append('%s%s\n'
+ '{\n'
+ ' if (gpu != NULL) {\n'
+ ' XGL_BASE_LAYER_OBJECT* gpuw = (XGL_BASE_LAYER_OBJECT *) %s;\n'
+ ' printf("At start of layered %s\\n");\n'
+ ' pCurObj = gpuw;\n'
+ ' pthread_once(&tabOnce, initLayerTable);\n'
+ ' %snextTable.%s;\n'
+ ' printf("Completed layered %s\\n");\n'
+ ' fflush(stdout);\n'
+ ' %s'
+ ' } else {\n'
+ ' if (pOutLayerCount == NULL || pOutLayers == NULL || pOutLayers[0] == NULL)\n'
+ ' return XGL_ERROR_INVALID_POINTER;\n'
+ ' // This layer compatible with all GPUs\n'
+ ' *pOutLayerCount = 1;\n'
+ ' strncpy(pOutLayers[0], "%s", maxStringSize);\n'
+ ' return XGL_SUCCESS;\n'
+ ' }\n'
+ '}' % (qual, decl, proto.params[0].name, proto.name, ret_val, c_call, proto.name, stmt, layer))
+ elif proto.params[0].ty != "XGL_PHYSICAL_GPU":
funcs.append('%s%s\n'
'{\n'
' %snextTable.%s;\n'
@@ -236,7 +258,27 @@
log_func += '\n printf(" %s (%%p)\\n%%s\\n", (void*)%s, pTmpStr);' % (proto.params[sp_index].name, proto.params[sp_index].name)
log_func += '\n fflush(stdout);'
log_func += '\n free(pTmpStr);\n }'
- if proto.params[0].ty != "XGL_PHYSICAL_GPU":
+ if proto.name == "EnumerateLayers":
+ c_call = proto.c_call().replace("(" + proto.params[0].name, "((XGL_PHYSICAL_GPU)gpuw->nextObject", 1)
+ funcs.append('%s%s\n'
+ '{\n'
+ ' if (gpu != NULL) {\n'
+ ' XGL_BASE_LAYER_OBJECT* gpuw = (XGL_BASE_LAYER_OBJECT *) %s;\n'
+ ' pCurObj = gpuw;\n'
+ ' pthread_once(&tabOnce, initLayerTable);\n'
+ ' %snextTable.%s;\n'
+ ' %s %s %s\n'
+ ' %s'
+ ' } else {\n'
+ ' if (pOutLayerCount == NULL || pOutLayers == NULL || pOutLayers[0] == NULL)\n'
+ ' return XGL_ERROR_INVALID_POINTER;\n'
+ ' // This layer compatible with all GPUs\n'
+ ' *pOutLayerCount = 1;\n'
+ ' strncpy(pOutLayers[0], "%s", maxStringSize);\n'
+ ' return XGL_SUCCESS;\n'
+ ' }\n'
+ '}' % (qual, decl, proto.params[0].name, ret_val, c_call,f_open, log_func, f_close, stmt, layer))
+ elif proto.params[0].ty != "XGL_PHYSICAL_GPU":
funcs.append('%s%s\n'
'{\n'
' %snextTable.%s;\n'
@@ -321,7 +363,28 @@
if proto.ret != "XGL_VOID":
ret_val = "XGL_RESULT result = "
stmt = " return result;\n"
- if proto.params[0].ty != "XGL_PHYSICAL_GPU":
+ if proto.name == "EnumerateLayers":
+ c_call = proto.c_call().replace("(" + proto.params[0].name, "((XGL_PHYSICAL_GPU)gpuw->nextObject", 1)
+ funcs.append('%s%s\n'
+ '{\n'
+ ' if (gpu != NULL) {\n'
+ ' XGL_BASE_LAYER_OBJECT* gpuw = (XGL_BASE_LAYER_OBJECT *) %s;\n'
+ ' %s'
+ ' pCurObj = gpuw;\n'
+ ' pthread_once(&tabOnce, initLayerTable);\n'
+ ' %snextTable.%s;\n'
+ ' %s%s'
+ ' %s'
+ ' } else {\n'
+ ' if (pOutLayerCount == NULL || pOutLayers == NULL || pOutLayers[0] == NULL)\n'
+ ' return XGL_ERROR_INVALID_POINTER;\n'
+ ' // This layer compatible with all GPUs\n'
+ ' *pOutLayerCount = 1;\n'
+ ' strncpy(pOutLayers[0], "%s", maxStringSize);\n'
+ ' return XGL_SUCCESS;\n'
+ ' }\n'
+ '}' % (qual, decl, proto.params[0].name, using_line, ret_val, c_call, create_line, destroy_line, stmt, layer))
+ elif proto.params[0].ty != "XGL_PHYSICAL_GPU":
funcs.append('%s%s\n'
'{\n'
'%s'