diff options
| author | Jon Ashburn <jon@lunarg.com> | 2015-04-02 12:06:28 -0600 |
|---|---|---|
| committer | Chia-I Wu <olv@lunarg.com> | 2015-04-16 17:33:29 +0800 |
| commit | 3d98fec8d8c5b9a1e9b45c32ba50ca4ab651754c (patch) | |
| tree | 1d07d0cc90ffc123e33a0425a0c8d811ed4fe36d | |
| parent | 07b8cc331f9eb6c53cd32d4eeaff1c12f4685203 (diff) | |
| download | usermoji-3d98fec8d8c5b9a1e9b45c32ba50ca4ab651754c.tar.xz | |
layers: Update GetExtensionSupport() to handle queries for layer name
Layers now support loader querying their layer name via GetExtensionSupport
in addition to EnumerateLayers.
Also fixed bugs in ObjectTracker and DrawState to add the extensions they
support in the GetExtensionSupport queries.
Conflicts:
xgl-layer-generate.py
| -rw-r--r-- | layers/basic.cpp | 22 | ||||
| -rw-r--r-- | layers/draw_state.cpp | 21 | ||||
| -rw-r--r-- | layers/mem_tracker.cpp | 20 | ||||
| -rw-r--r-- | layers/multi.cpp | 31 | ||||
| -rwxr-xr-x | xgl-layer-generate.py | 91 |
5 files changed, 176 insertions, 9 deletions
diff --git a/layers/basic.cpp b/layers/basic.cpp index 2f3deac0..627dc879 100644 --- a/layers/basic.cpp +++ b/layers/basic.cpp @@ -63,23 +63,33 @@ XGL_LAYER_EXPORT XGL_RESULT XGLAPI xglLayerExtension1(XGL_DEVICE device) XGL_LAYER_EXPORT XGL_RESULT XGLAPI xglGetExtensionSupport(XGL_PHYSICAL_GPU gpu, const char* pExtName) { - XGL_BASE_LAYER_OBJECT* gpuw = (XGL_BASE_LAYER_OBJECT *) gpu; XGL_RESULT result; - XGL_LAYER_DISPATCH_TABLE* pTable = initLayerTable(gpuw); + XGL_BASE_LAYER_OBJECT* gpuw = (XGL_BASE_LAYER_OBJECT *) gpu; - printf("At start of wrapped xglGetExtensionSupport() call w/ gpu: %p\n", (void*)gpu); + /* This entrypoint is NOT going to init it's own dispatch table since loader calls here early */ if (!strncmp(pExtName, "xglLayerExtension1", strlen("xglLayerExtension1"))) + { + result = XGL_SUCCESS; + } else if (!strncmp(pExtName, "Basic", strlen("Basic"))) + { result = XGL_SUCCESS; - else + } else if (!tableMap.empty() && (tableMap.find(gpuw) != tableMap.end())) + { + printf("At start of wrapped xglGetExtensionSupport() call w/ gpu: %p\n", (void*)gpu); + XGL_LAYER_DISPATCH_TABLE* pTable = tableMap[gpuw]; result = pTable->GetExtensionSupport((XGL_PHYSICAL_GPU)gpuw->nextObject, pExtName); - printf("Completed wrapped xglGetExtensionSupport() call w/ gpu: %p\n", (void*)gpu); + printf("Completed wrapped xglGetExtensionSupport() call w/ gpu: %p\n", (void*)gpu); + } else + { + result = XGL_ERROR_INVALID_EXTENSION; + } return result; } XGL_LAYER_EXPORT XGL_RESULT XGLAPI xglCreateDevice(XGL_PHYSICAL_GPU gpu, const XGL_DEVICE_CREATE_INFO* pCreateInfo, XGL_DEVICE* pDevice) { XGL_BASE_LAYER_OBJECT* gpuw = (XGL_BASE_LAYER_OBJECT *) gpu; - XGL_LAYER_DISPATCH_TABLE* pTable = initLayerTable(gpuw); + XGL_LAYER_DISPATCH_TABLE* pTable = tableMap[gpuw]; printf("At start of wrapped xglCreateDevice() call w/ gpu: %p\n", (void*)gpu); XGL_RESULT result = pTable->CreateDevice((XGL_PHYSICAL_GPU)gpuw->nextObject, pCreateInfo, pDevice); diff --git a/layers/draw_state.cpp b/layers/draw_state.cpp index c2391192..503c08ac 100644 --- a/layers/draw_state.cpp +++ b/layers/draw_state.cpp @@ -1514,6 +1514,25 @@ XGL_LAYER_EXPORT XGL_RESULT XGLAPI xglDestroyDevice(XGL_DEVICE device) return result; } +XGL_LAYER_EXPORT XGL_RESULT XGLAPI xglGetExtensionSupport(XGL_PHYSICAL_GPU gpu, const char* pExtName) +{ + XGL_BASE_LAYER_OBJECT* gpuw = (XGL_BASE_LAYER_OBJECT *) gpu; + XGL_RESULT result; + /* This entrypoint is NOT going to init its own dispatch table since loader calls here early */ + if (!strcmp(pExtName, "DrawState") || !strcmp(pExtName, "drawStateDumpDotFile") || + !strcmp(pExtName, "drawStateDumpCommandBufferDotFile") || !strcmp(pExtName, "drawStateDumpPngFile")) + { + result = XGL_SUCCESS; + } else if (nextTable.GetExtensionSupport != NULL) + { + result = nextTable.GetExtensionSupport((XGL_PHYSICAL_GPU)gpuw->nextObject, pExtName); + } else + { + result = XGL_ERROR_INVALID_EXTENSION; + } + return result; +} + XGL_LAYER_EXPORT XGL_RESULT XGLAPI xglEnumerateLayers(XGL_PHYSICAL_GPU gpu, size_t maxLayerCount, size_t maxStringSize, size_t* pOutLayerCount, char* const* pOutLayers, void* pReserved) { if (gpu != NULL) @@ -2741,6 +2760,8 @@ XGL_LAYER_EXPORT void* XGLAPI xglGetProcAddr(XGL_PHYSICAL_GPU gpu, const char* f return (void*) xglCreateDevice; if (!strcmp(funcName, "xglDestroyDevice")) return (void*) xglDestroyDevice; + if (!strcmp(funcName, "xglGetExtensionSupport")) + return (void*) xglGetExtensionSupport; if (!strcmp(funcName, "xglEnumerateLayers")) return (void*) xglEnumerateLayers; if (!strcmp(funcName, "xglQueueSubmit")) diff --git a/layers/mem_tracker.cpp b/layers/mem_tracker.cpp index a6bc088a..5b47bfc5 100644 --- a/layers/mem_tracker.cpp +++ b/layers/mem_tracker.cpp @@ -865,6 +865,24 @@ XGL_LAYER_EXPORT XGL_RESULT XGLAPI xglDestroyDevice(XGL_DEVICE device) return result; } +XGL_LAYER_EXPORT XGL_RESULT XGLAPI xglGetExtensionSupport(XGL_PHYSICAL_GPU gpu, const char* pExtName) +{ + XGL_BASE_LAYER_OBJECT* gpuw = (XGL_BASE_LAYER_OBJECT *) gpu; + XGL_RESULT result; + /* This entrypoint is NOT going to init its own dispatch table since loader calls here early */ + if (!strcmp(pExtName, "MemTracker")) + { + result = XGL_SUCCESS; + } else if (nextTable.GetExtensionSupport != NULL) + { + result = nextTable.GetExtensionSupport((XGL_PHYSICAL_GPU)gpuw->nextObject, pExtName); + } else + { + result = XGL_ERROR_INVALID_EXTENSION; + } + return result; +} + XGL_LAYER_EXPORT XGL_RESULT XGLAPI xglEnumerateLayers(XGL_PHYSICAL_GPU gpu, size_t maxLayerCount, size_t maxStringSize, size_t* pOutLayerCount, char* const* pOutLayers, void* pReserved) { @@ -1900,6 +1918,8 @@ XGL_LAYER_EXPORT void* XGLAPI xglGetProcAddr(XGL_PHYSICAL_GPU gpu, const char* f return (void*) xglCreateDevice; if (!strcmp(funcName, "xglDestroyDevice")) return (void*) xglDestroyDevice; + if (!strcmp(funcName, "xglGetExtensionSupport")) + return (void*) xglGetExtensionSupport; if (!strcmp(funcName, "xglEnumerateLayers")) return (void*) xglEnumerateLayers; if (!strcmp(funcName, "xglQueueSubmit")) diff --git a/layers/multi.cpp b/layers/multi.cpp index 3a5e4fcc..f8c2bc9f 100644 --- a/layers/multi.cpp +++ b/layers/multi.cpp @@ -132,6 +132,8 @@ XGL_LAYER_EXPORT void * XGLAPI multi1GetProcAddr(XGL_PHYSICAL_GPU gpu, const cha return (void *) multi1CreateGraphicsPipeline; else if (!strncmp("xglStorePipeline", pName, sizeof ("xglStorePipeline"))) return (void *) multi1StorePipeline; + else if (!strncmp("xglGetExtensionSupport", pName, sizeof ("xglGetExtensionSupport"))) + return (void *) xglGetExtensionSupport; else { if (gpuw->pGPA == NULL) return NULL; @@ -232,6 +234,8 @@ XGL_LAYER_EXPORT void * XGLAPI multi2GetProcAddr(XGL_PHYSICAL_GPU gpu, const cha return (void *) multi2CreateCommandBuffer; else if (!strncmp("xglBeginCommandBuffer", pName, sizeof ("xglBeginCommandBuffer"))) return (void *) multi2BeginCommandBuffer; + else if (!strncmp("xglGetExtensionSupport", pName, sizeof ("xglGetExtensionSupport"))) + return (void *) xglGetExtensionSupport; else { if (gpuw->pGPA == NULL) return NULL; @@ -255,6 +259,33 @@ XGL_LAYER_EXPORT XGL_RESULT XGLAPI xglEnumerateLayers(XGL_PHYSICAL_GPU gpu, size return XGL_SUCCESS; } +XGL_LAYER_EXPORT XGL_RESULT XGLAPI xglGetExtensionSupport(XGL_PHYSICAL_GPU gpu, const char* pExtName) +{ + XGL_RESULT result; + XGL_BASE_LAYER_OBJECT* gpuw = (XGL_BASE_LAYER_OBJECT *) gpu; + + /* This entrypoint is NOT going to init it's own dispatch table since loader calls here early */ + if (!strncmp(pExtName, "multi1", strlen("multi1"))) + { + result = XGL_SUCCESS; + } else if (!strncmp(pExtName, "multi2", strlen("multi2"))) + { + result = XGL_SUCCESS; + } else if (!tableMap1.empty() && (tableMap1.find(gpuw) != tableMap1.end())) + { + XGL_LAYER_DISPATCH_TABLE* pTable = tableMap1[gpuw]; + result = pTable->GetExtensionSupport((XGL_PHYSICAL_GPU)gpuw->nextObject, pExtName); + } else if (!tableMap2.empty() && (tableMap2.find(gpuw) != tableMap2.end())) + { + XGL_LAYER_DISPATCH_TABLE* pTable = tableMap2[gpuw]; + result = pTable->GetExtensionSupport((XGL_PHYSICAL_GPU)gpuw->nextObject, pExtName); + } else + { + result = XGL_ERROR_INVALID_EXTENSION; + } + return result; +} + XGL_LAYER_EXPORT void * XGLAPI xglGetProcAddr(XGL_PHYSICAL_GPU gpu, const char* pName) { // to find each layers GPA routine Loader will search via "<layerName>GetProcAddr" diff --git a/xgl-layer-generate.py b/xgl-layer-generate.py index 01b1dd74..38a08899 100755 --- a/xgl-layer-generate.py +++ b/xgl-layer-generate.py @@ -194,6 +194,28 @@ class Subcommand(object): ur_body.append('}') return "\n".join(ur_body) + def _gen_layer_get_extension_support(self, layer="Generic"): + ges_body = [] + ges_body.append('XGL_LAYER_EXPORT XGL_RESULT XGLAPI xglGetExtensionSupport(XGL_PHYSICAL_GPU gpu, const char* pExtName)') + ges_body.append('{') + ges_body.append(' XGL_RESULT result;') + ges_body.append(' XGL_BASE_LAYER_OBJECT* gpuw = (XGL_BASE_LAYER_OBJECT *) gpu;') + ges_body.append('') + ges_body.append(' /* This entrypoint is NOT going to init its own dispatch table since loader calls here early */') + ges_body.append(' if (!strncmp(pExtName, "%s", strlen("%s")))' % (layer, layer)) + ges_body.append(' {') + ges_body.append(' result = XGL_SUCCESS;') + ges_body.append(' } else if (nextTable.GetExtensionSupport != NULL)') + ges_body.append(' {') + ges_body.append(' result = nextTable.GetExtensionSupport((XGL_PHYSICAL_GPU)gpuw->nextObject, pExtName);') + ges_body.append(' } else') + ges_body.append(' {') + ges_body.append(' result = XGL_ERROR_INVALID_EXTENSION;') + ges_body.append(' }') + ges_body.append(' return result;') + ges_body.append('}') + return "\n".join(ges_body) + def _generate_dispatch_entrypoints(self, qual=""): if qual: qual += " " @@ -207,8 +229,10 @@ class Subcommand(object): # fill in default intercept for certain entrypoints if 'DbgRegisterMsgCallback' == proto.name: intercept = self._gen_layer_dbg_callback_register() - if 'DbgUnregisterMsgCallback' == proto.name: + elif 'DbgUnregisterMsgCallback' == proto.name: intercept = self._gen_layer_dbg_callback_unregister() + elif 'GetExtensionSupport' == proto.name: + funcs.append(self._gen_layer_get_extension_support(self.layer_name)) if intercept is not None: funcs.append(intercept) intercepted.append(proto) @@ -236,7 +260,6 @@ class Subcommand(object): body.append(" return NULL;") body.append("}") funcs.append("\n".join(body)) - return "\n\n".join(funcs) @@ -374,7 +397,7 @@ class GenericLayerSubcommand(Subcommand): return '#include <stdio.h>\n#include <stdlib.h>\n#include <string.h>\n#include "loader_platform.h"\n#include "xglLayer.h"\n//The following is #included again to catch certain OS-specific functions being used:\n#include "loader_platform.h"\n\n#include "layers_config.h"\n#include "layers_msg.h"\n\nstatic XGL_LAYER_DISPATCH_TABLE nextTable;\nstatic XGL_BASE_LAYER_OBJECT *pCurObj;\n\nstatic LOADER_PLATFORM_THREAD_ONCE_DECLARATION(tabOnce);' def generate_intercept(self, proto, qual): - if proto.name in [ 'DbgRegisterMsgCallback', 'DbgUnregisterMsgCallback' ]: + if proto.name in [ 'DbgRegisterMsgCallback', 'DbgUnregisterMsgCallback' , 'GetExtensionSupport']: # use default version return None decl = proto.c_func(prefix="xgl", attr="XGLAPI") @@ -614,6 +637,26 @@ class ApiDumpSubcommand(Subcommand): ' return XGL_SUCCESS;\n' ' }\n' '}' % (qual, decl, proto.params[0].name, self.layer_name, ret_val, c_call,f_open, log_func, f_close, stmt, self.layer_name)) + elif 'GetExtensionSupport' == proto.name: + c_call = proto.c_call().replace("(" + proto.params[0].name, "((XGL_PHYSICAL_GPU)gpuw->nextObject", 1) + funcs.append('%s%s\n' + '{\n' + ' XGL_BASE_LAYER_OBJECT* gpuw = (XGL_BASE_LAYER_OBJECT *) %s;\n' + ' XGL_RESULT result;\n' + ' /* This entrypoint is NOT going to init its own dispatch table since loader calls here early */\n' + ' if (!strncmp(pExtName, "%s", strlen("%s")))\n' + ' {\n' + ' result = XGL_SUCCESS;\n' + ' } else if (nextTable.GetExtensionSupport != NULL)\n' + ' {\n' + ' result = nextTable.%s;\n' + ' %s %s %s\n' + ' } else\n' + ' {\n' + ' result = XGL_ERROR_INVALID_EXTENSION;\n' + ' }\n' + '%s' + '}' % (qual, decl, proto.params[0].name, self.layer_name, self.layer_name, c_call, f_open, log_func, f_close, stmt)) elif proto.params[0].ty != "XGL_PHYSICAL_GPU": funcs.append('%s%s\n' '{\n' @@ -823,6 +866,26 @@ class ApiDumpCppSubcommand(Subcommand): ' return XGL_SUCCESS;\n' ' }\n' '}' % (qual, decl, proto.params[0].name, self.layer_name, ret_val, c_call,f_open, log_func, f_close, stmt, self.layer_name)) + elif 'GetExtensionSupport' == proto.name: + c_call = proto.c_call().replace("(" + proto.params[0].name, "((XGL_PHYSICAL_GPU)gpuw->nextObject", 1) + funcs.append('%s%s\n' + '{\n' + ' XGL_BASE_LAYER_OBJECT* gpuw = (XGL_BASE_LAYER_OBJECT *) %s;\n' + ' XGL_RESULT result;\n' + ' /* This entrypoint is NOT going to init its own dispatch table since loader calls here early */\n' + ' if (!strncmp(pExtName, "%s", strlen("%s")))\n' + ' {\n' + ' result = XGL_SUCCESS;\n' + ' } else if (nextTable.GetExtensionSupport != NULL)\n' + ' {\n' + ' result = nextTable.%s;\n' + ' %s %s %s\n' + ' } else\n' + ' {\n' + ' result = XGL_ERROR_INVALID_EXTENSION;\n' + ' }\n' + '%s' + '}' % (qual, decl, proto.params[0].name, self.layer_name, self.layer_name, c_call, f_open, log_func, f_close, stmt)) elif proto.params[0].ty != "XGL_PHYSICAL_GPU": funcs.append('%s%s\n' '{\n' @@ -1378,6 +1441,28 @@ class ObjectTrackerSubcommand(Subcommand): ' return XGL_SUCCESS;\n' ' }\n' '}' % (qual, decl, proto.params[0].name, using_line, self.layer_name, ret_val, c_call, create_line, destroy_line, stmt, self.layer_name)) + elif 'GetExtensionSupport' == proto.name: + c_call = proto.c_call().replace("(" + proto.params[0].name, "((XGL_PHYSICAL_GPU)gpuw->nextObject", 1) + funcs.append('%s%s\n' + '{\n' + ' XGL_BASE_LAYER_OBJECT* gpuw = (XGL_BASE_LAYER_OBJECT *) %s;\n' + ' XGL_RESULT result;\n' + ' /* This entrypoint is NOT going to init its own dispatch table since loader calls this early */\n' + ' if (!strncmp(pExtName, "%s", strlen("%s")) ||\n' + ' !strncmp(pExtName, "objTrackGetObjectCount", strlen("objTrackGetObjectCount")) ||\n' + ' !strncmp(pExtName, "objTrackGetObjects", strlen("objTrackGetObjects")))\n' + ' {\n' + ' result = XGL_SUCCESS;\n' + ' } else if (nextTable.GetExtensionSupport != NULL)\n' + ' {\n' + ' %s' + ' result = nextTable.%s;\n' + ' } else\n' + ' {\n' + ' result = XGL_ERROR_INVALID_EXTENSION;\n' + ' }\n' + '%s' + '}' % (qual, decl, proto.params[0].name, self.layer_name, self.layer_name, using_line, c_call, stmt)) elif proto.params[0].ty != "XGL_PHYSICAL_GPU": funcs.append('%s%s\n' '{\n' |
