From f1d025eb07c62ef2c0e79ffebcaa60aeda841c47 Mon Sep 17 00:00:00 2001 From: Jon Ashburn Date: Wed, 3 Dec 2014 14:30:48 -0700 Subject: loader: handle inserting dispatch table pointer into all created objects Remove the setDispatch calls into cid driver. Replace with inserting the current dispatch table into created objects. Requires icd driver to still have a slot for the dispatch table pointer in first location of every created object. --- loader/loader.c | 6 ------ xgl-generate.py | 39 +++++++++++++++++++++++++++++++++------ xgl.py | 33 +++++++++++++++++++++++++++++++++ 3 files changed, 66 insertions(+), 12 deletions(-) diff --git a/loader/loader.c b/loader/loader.c index 6cb7b136..7229cf0a 100644 --- a/loader/loader.c +++ b/loader/loader.c @@ -41,8 +41,6 @@ #include #include "loader.h" -typedef XGL_VOID (* SetDispatchType)(XGL_LAYER_DISPATCH_TABLE * disp, XGL_BOOL debug); - struct loader_layers { void *lib_handle; char name[256]; @@ -65,7 +63,6 @@ struct loader_icd { GetProcAddrType GetProcAddr; InitAndEnumerateGpusType InitAndEnumerateGpus; - SetDispatchType SetDispatch; struct loader_icd *next; }; @@ -226,7 +223,6 @@ loader_icd_create(const char *filename) } while (0) LOOKUP(icd, GetProcAddr); LOOKUP(icd, InitAndEnumerateGpus); - LOOKUP(icd, SetDispatch); #undef LOOKUP return icd; @@ -792,7 +788,6 @@ static void loader_deactivate_layer() if (icd->loader_dispatch) free(icd->loader_dispatch); icd->loader_dispatch = NULL; - icd->SetDispatch(NULL, true); for (XGL_UINT j = 0; j < icd->gpu_count; j++) { if (icd->layer_count[j] > 0) { for (XGL_UINT i = 0; i < icd->layer_count[j]; i++) { @@ -1178,7 +1173,6 @@ LOADER_EXPORT XGL_RESULT XGLAPI xglInitAndEnumerateGpus(const XGL_APPLICATION_IN loader_init_dispatch_table(icd->loader_dispatch + i, getProcAddr, gpus[i]); const XGL_LAYER_DISPATCH_TABLE * *disp = (const XGL_LAYER_DISPATCH_TABLE * *) gpus[i]; *disp = icd->loader_dispatch + i; - icd->SetDispatch(icd->loader_dispatch + i, true); } count += n; diff --git a/xgl-generate.py b/xgl-generate.py index ed5b636b..9a06778a 100755 --- a/xgl-generate.py +++ b/xgl-generate.py @@ -118,19 +118,44 @@ class Subcommand(object): continue decl = proto.c_func(prefix="xgl", attr="XGLAPI") stmt = "(*disp)->%s" % proto.c_call() - if proto.ret != "XGL_VOID": - stmt = "return " + stmt if proto.name == "CreateDevice" and qual == "LOADER_EXPORT ": funcs.append("%s%s\n" "{\n" " loader_activate_layers(%s, %s);\n" " XGL_BASE_LAYER_OBJECT* wrapped_obj = (XGL_BASE_LAYER_OBJECT*)%s;\n" - " const XGL_LAYER_DISPATCH_TABLE * const *disp =\n" - " (const XGL_LAYER_DISPATCH_TABLE * const *) wrapped_obj->baseObject;\n" + " const XGL_LAYER_DISPATCH_TABLE **disp =\n" + " (const XGL_LAYER_DISPATCH_TABLE **) wrapped_obj->baseObject;\n" " %s = wrapped_obj->nextObject;\n" - " %s;\n" - "}" % (qual, decl, proto.params[0].name, proto.params[1].name, proto.params[0].name, proto.params[0].name, stmt)) + " XGL_RESULT res = %s;\n" + " *(const XGL_LAYER_DISPATCH_TABLE **) (*%s) = *disp;\n" + " return res;\n" + "}" % (qual, decl, proto.params[0].name, proto.params[1].name, + proto.params[0].name, proto.params[0].name, stmt, + proto.params[-1].name)) + elif xgl.does_function_create_object(proto.name) and qual == "LOADER_EXPORT ": + funcs.append("%s%s\n" + "{\n" + " const XGL_LAYER_DISPATCH_TABLE **disp =\n" + " (const XGL_LAYER_DISPATCH_TABLE **) %s;\n" + " XGL_RESULT res = %s;\n" + " *(const XGL_LAYER_DISPATCH_TABLE **) (*%s) = *disp;\n" + " return res;\n" + "}" % (qual, decl, proto.params[0].name, stmt, proto.params[-1].name)) + elif proto.name == "GetMultiGpuCompatibility" and qual == "LOADER_EXPORT ": + funcs.append("%s%s\n" + "{\n" + " XGL_BASE_LAYER_OBJECT* wrapped_obj0 = (XGL_BASE_LAYER_OBJECT*)%s;\n" + " XGL_BASE_LAYER_OBJECT* wrapped_obj1 = (XGL_BASE_LAYER_OBJECT*)%s;\n" + " const XGL_LAYER_DISPATCH_TABLE * const *disp =\n" + " (const XGL_LAYER_DISPATCH_TABLE * const *) wrapped_obj0->baseObject;\n" + " %s = wrapped_obj0->nextObject;\n" + " %s = wrapped_obj1->nextObject;\n" + " return %s;\n" + "}" % (qual, decl, proto.params[0].name, proto.params[1].name, + proto.params[0].name, proto.params[1].name, stmt)) elif proto.params[0].ty != "XGL_PHYSICAL_GPU" or qual != "LOADER_EXPORT ": + if proto.ret != "XGL_VOID": + stmt = "return " + stmt funcs.append("%s%s\n" "{\n" " const XGL_LAYER_DISPATCH_TABLE * const *disp =\n" @@ -138,6 +163,8 @@ class Subcommand(object): " %s;\n" "}" % (qual, decl, proto.params[0].name, stmt)) else: + if proto.ret != "XGL_VOID": + stmt = "return " + stmt funcs.append("%s%s\n" "{\n" " XGL_BASE_LAYER_OBJECT* wrapped_obj = (XGL_BASE_LAYER_OBJECT*)%s;\n" diff --git a/xgl.py b/xgl.py index fc8e9127..f4df85ba 100644 --- a/xgl.py +++ b/xgl.py @@ -869,6 +869,39 @@ icd_dispatch_table = ( "WsiX11QueuePresent", ) +def does_function_create_object(name): + return name in ( + "CreateDevice", + "GetDeviceQueue", + "AllocMemory", + "PinSystemMemory", + "OpenSharedMemory", + "OpenSharedQueueSemaphore", + "OpenPeerMemory", + "OpenPeerImage", + "CreateFence", + "CreateQueueSemaphore", + "CreateEvent", + "CreateQueryPool", + "CreateImage", + "CreateImageView", + "CreateColorAttachmentView", + "CreateDepthStencilView", + "CreateShader", + "CreateGraphicsPipeline", + "CreateComputePipeline", + "LoadPipeline", + "CreatePipelineDelta", + "CreateSampler", + "CreateDescriptorSet", + "CreateViewportState", + "CreateRasterState", + "CreateMsaaState", + "CreateColorBlendState", + "CreateDepthStencilState", + "CreateCommandBuffer", + "WsiX11CreatePresentableImage") + def is_name_dispatchable(name): return name not in ( "GetProcAddr", -- cgit v1.2.3