From 98ad5b5caacb0ccaddc84d6c593ef100b9b96430 Mon Sep 17 00:00:00 2001 From: Carl Worth Date: Fri, 17 May 2013 12:50:21 -0700 Subject: [PATCH] stash: Trace and replay of gnome-shell works Obviously, the patch series needs to be cleaned up quite a bit. --- retrace/glretrace_glx.cpp | 30 ++++++++++++++++++++++++++---- retrace/glws_glx.cpp | 6 ------ wrappers/glxtrace.py | 3 +++ wrappers/trace.py | 6 ++++++ 4 files changed, 35 insertions(+), 10 deletions(-) diff --git a/retrace/glretrace_glx.cpp b/retrace/glretrace_glx.cpp index eb64b6b..f740a8c 100644 --- a/retrace/glretrace_glx.cpp +++ b/retrace/glretrace_glx.cpp @@ -28,6 +28,7 @@ #include "retrace.hpp" #include "glretrace.hpp" +#include #ifndef GLX_PBUFFER_HEIGHT #define GLX_PBUFFER_HEIGHT 0x8040 @@ -50,10 +51,12 @@ typedef std::map DrawableMap; typedef std::map ContextMap; typedef std::map PixmapDescMap; typedef std::map ConfigMap; +typedef std::map > ConfigAttribListMap; static DrawableMap drawable_map; static ContextMap context_map; static PixmapDescMap pixmap_desc_map; static ConfigMap config_map; +static ConfigAttribListMap config_attrib_list_map; static glws::Drawable * getDrawable(unsigned long drawable_id) { @@ -219,9 +222,19 @@ static void retrace_glXCreatePixmap(trace::Call &call) { } } - printf("Looking for %p in FB-config map\n", orig_fbconfig); fbconfig = config_map[orig_fbconfig]; + if (! fbconfig) { + std::vector *attrib_list = &config_attrib_list_map[orig_fbconfig]; + attrib_list->push_back(0); + fbconfig = glretrace::chooseConfig(attrib_list->data()); + if (fbconfig) { + config_map[orig_fbconfig] = fbconfig; + } else { + fprintf(stderr, "Error: Failed to find suitable fbconfig\n"); + } + } + pixmap = glretrace::createPixmap(desc->width, desc->height, desc->depth); gl_pixmap = glretrace::createGLPixmap(fbconfig, pixmap, desc->width, desc->height, attrib_list); @@ -291,11 +304,20 @@ static void retrace_glXChooseFBConfig(trace::Call &call) { config = glretrace::chooseConfig(attrib_list); for (size_t i = 0; i < orig_nelements; i++) { - printf("Mapping FB config %p to %p\n", orig_configs->values[i]->toPointer(), config); config_map[static_cast(orig_configs->values[i]->toPointer())] = config; } } +static void retrace_glXGetFBConfigAttrib(trace::Call &call) { + GLXFBConfig config = static_cast(call.arg(1).toPointer()); + int attribute = call.arg(2).toUInt(); + int value = dynamic_cast(&call.arg(3))->values[0]->toSInt(); + + std::vector *attrib_list = &config_attrib_list_map[config]; + attrib_list->push_back(attribute); + attrib_list->push_back(value); +} + const retrace::Entry glretrace::glx_callbacks[] = { //{"glXBindChannelToWindowSGIX", &retrace_glXBindChannelToWindowSGIX}, //{"glXBindSwapBarrierNV", &retrace_glXBindSwapBarrierNV}, @@ -340,7 +362,7 @@ const retrace::Entry glretrace::glx_callbacks[] = { {"glXGetCurrentDrawable", &retrace::ignore}, {"glXGetCurrentReadDrawable", &retrace::ignore}, {"glXGetCurrentReadDrawableSGI", &retrace::ignore}, - {"glXGetFBConfigAttrib", &retrace::ignore}, + {"glXGetFBConfigAttrib", &retrace_glXGetFBConfigAttrib}, {"glXGetFBConfigAttribSGIX", &retrace::ignore}, {"glXGetFBConfigFromVisualSGIX", &retrace::ignore}, {"glXGetFBConfigs", &retrace::ignore}, @@ -378,7 +400,7 @@ const retrace::Entry glretrace::glx_callbacks[] = { //{"glXReleaseBuffersMESA", &retrace_glXReleaseBuffersMESA}, {"glXReleaseTexImageEXT", &retrace_glXReleaseTexImageEXT}, //{"glXResetFrameCountNV", &retrace_glXResetFrameCountNV}, - //{"glXSelectEvent", &retrace_glXSelectEvent}, + {"glXSelectEvent", &retrace::ignore}, //{"glXSelectEventSGIX", &retrace_glXSelectEventSGIX}, //{"glXSet3DfxModeMESA", &retrace_glXSet3DfxModeMESA}, //{"glXSwapBuffersMscOML", &retrace_glXSwapBuffersMscOML}, diff --git a/retrace/glws_glx.cpp b/retrace/glws_glx.cpp index ce742ac..b75945c 100644 --- a/retrace/glws_glx.cpp +++ b/retrace/glws_glx.cpp @@ -422,8 +422,6 @@ createPixmap(unsigned width, unsigned height, unsigned depth) pixmap = XCreatePixmap(display, DefaultRootWindow(display), width, height, depth); - printf ("Replayed XCreatePixmap to create pixmap %ld\n", pixmap); - return new GlxDrawable(pixmap, width, height); } @@ -436,8 +434,6 @@ createGLPixmap(GLXFBConfig fbconfig, Drawable *_pixmap, gl_pixmap = glXCreatePixmap(display, fbconfig, pixmap->window, attrib_list); - printf ("And replayed glXCreatePixmap to create pixmap %ld\n", gl_pixmap); - return new GlxDrawable(gl_pixmap, width, height); } @@ -484,8 +480,6 @@ putImageData(glws::Drawable *drawable, char *data, GC gc; XImage image; - printf ("Calling XPutImage to pixmap %ld\n", glxDrawable->window); - image.width = width; image.height = height; image.format = ZPixmap; diff --git a/wrappers/glxtrace.py b/wrappers/glxtrace.py index 9c0f87d..97de045 100644 --- a/wrappers/glxtrace.py +++ b/wrappers/glxtrace.py @@ -100,6 +100,9 @@ if __name__ == '__main__': print '#include "glproc.hpp"' print '#include "glsize.hpp"' print + print 'static std::map underlying_x_pixmaps;' + print 'void emit_fake_x_create_pixmap(Display *dpy, Drawable pixmap);' + print 'void emit_fake_put_image_data(Display *dpy, Drawable pixmap);' module = Module() module.mergeModule(glxapi) diff --git a/wrappers/trace.py b/wrappers/trace.py index d9c2900..e48a703 100644 --- a/wrappers/trace.py +++ b/wrappers/trace.py @@ -488,6 +488,10 @@ class Tracer: print def traceFunctionImplBody(self, function): + if function.name == 'glXCreatePixmap': + print ' emit_fake_x_create_pixmap(dpy, pixmap);' + if function.name == 'glXBindTexImageEXT': + print ' emit_fake_put_image_data(display, underlying_x_pixmaps[drawable]);' if not function.internal: print ' unsigned _call = trace::localWriter.beginEnter(&_%s_sig);' % (function.name,) for arg in function.args: @@ -498,6 +502,8 @@ class Tracer: self.serializeArg(function, arg) print ' trace::localWriter.endEnter();' self.invokeFunction(function) + if function.name == 'glXCreatePixmap': + print ' underlying_x_pixmaps[_result] = pixmap;' if not function.internal: print ' trace::localWriter.beginLeave(_call);' print ' if (%s) {' % self.wasFunctionSuccessful(function) -- 2.43.0