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);
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)
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"))
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)
{
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"))
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;
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;
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"
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 += " "
# 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)
body.append(" return NULL;")
body.append("}")
funcs.append("\n".join(body))
-
return "\n\n".join(funcs)
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")
' 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'
' 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'
' 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'