wgl: Integrate the trace driver on debug builds.
authorJosé Fonseca <jfonseca@vmware.com>
Wed, 8 Apr 2009 14:30:31 +0000 (15:30 +0100)
committerJosé Fonseca <jfonseca@vmware.com>
Wed, 8 Apr 2009 15:26:05 +0000 (16:26 +0100)
src/gallium/state_trackers/wgl/shared/stw_context.c
src/gallium/state_trackers/wgl/shared/stw_device.c
src/gallium/state_trackers/wgl/shared/stw_device.h
src/gallium/state_trackers/wgl/shared/stw_framebuffer.c
src/gallium/winsys/gdi/SConscript

index 82aabe0a7ee025285771e1ee018b742d5fe74902..f890225242a72938e56c47778828a900fd262a9d 100644 (file)
 #include "pipe/p_context.h"
 #include "state_tracker/st_context.h"
 #include "state_tracker/st_public.h"
+
+#ifdef DEBUG
+#include "trace/tr_screen.h"
+#include "trace/tr_context.h"
+#endif
+
 #include "shared/stw_device.h"
 #include "shared/stw_winsys.h"
 #include "shared/stw_framebuffer.h"
@@ -77,6 +83,7 @@ stw_create_layer_context(
    const struct pixelformat_info *pf = NULL;
    struct stw_context *ctx = NULL;
    GLvisual *visual = NULL;
+   struct pipe_screen *screen = NULL;
    struct pipe_context *pipe = NULL;
    UINT_PTR hglrc = 0;
 
@@ -120,10 +127,24 @@ stw_create_layer_context(
    if (visual == NULL) 
       goto fail;
 
-   pipe = stw_dev->stw_winsys->create_context( stw_dev->screen );
+   screen = stw_dev->screen;
+
+#ifdef DEBUG
+   /* Unwrap screen */
+   if(stw_dev->trace_running)
+      screen = trace_screen(screen)->screen;
+#endif
+
+   pipe = stw_dev->stw_winsys->create_context( screen );
    if (pipe == NULL) 
       goto fail;
 
+#ifdef DEBUG
+   /* Wrap context */
+   if(stw_dev->trace_running)
+      pipe = trace_context_create(stw_dev->screen, pipe);
+#endif
+
    assert(!pipe->priv);
    pipe->priv = hdc;
 
index c5501727d4edbe4a0e1e048286ac7b14626ff893..51936c2bdd68a9219dd340dab38a05057ab3ff45 100644 (file)
 #include "util/u_debug.h"
 #include "pipe/p_screen.h"
 
+#ifdef DEBUG
+#include "trace/tr_screen.h"
+#include "trace/tr_texture.h"
+#endif
+
 #include "shared/stw_device.h"
 #include "shared/stw_winsys.h"
 #include "shared/stw_pixelformat.h"
@@ -52,13 +57,20 @@ struct stw_device *stw_dev = NULL;
  */
 static void 
 st_flush_frontbuffer(struct pipe_screen *screen,
-                     struct pipe_surface *surf,
+                     struct pipe_surface *surface,
                      void *context_private )
 {
    const struct stw_winsys *stw_winsys = stw_dev->stw_winsys;
    HDC hdc = (HDC)context_private;
    
-   stw_winsys->flush_frontbuffer(screen, surf, hdc);
+#ifdef DEBUG
+   if(stw_dev->trace_running) {
+      screen = trace_screen(screen)->screen;
+      surface = trace_surface(surface)->surface;
+   }
+#endif
+   
+   stw_winsys->flush_frontbuffer(screen, surface, hdc);
 }
 
 
@@ -66,6 +78,7 @@ boolean
 st_init(const struct stw_winsys *stw_winsys)
 {
    static struct stw_device stw_dev_storage;
+   struct pipe_screen *screen;
 
    debug_printf("%s\n", __FUNCTION__);
    
@@ -86,10 +99,17 @@ st_init(const struct stw_winsys *stw_winsys)
    _glthread_INIT_MUTEX(OneTimeLock);
 #endif
 
-   stw_dev->screen = stw_winsys->create_screen();
-   if(!stw_dev->screen)
+   screen = stw_winsys->create_screen();
+   if(!screen)
       goto error1;
 
+#ifdef DEBUG
+   stw_dev->screen = trace_screen_create(screen);
+   stw_dev->trace_running = stw_dev->screen != screen ? TRUE : FALSE;
+#else
+   stw_dev->screen = screen;
+#endif
+   
    stw_dev->screen->flush_frontbuffer = st_flush_frontbuffer;
    
    pipe_mutex_init( stw_dev->mutex );
index 6a9cee0d028ce28326f170aaa12a49f9fd31bf1c..703cb67081625b01da6bed5c694b6fa347f495f4 100644 (file)
@@ -39,8 +39,13 @@ struct pipe_screen;
 struct stw_device
 {
    const struct stw_winsys *stw_winsys;
+   
    struct pipe_screen *screen;
    
+#ifdef DEBUG
+   boolean trace_running;
+#endif
+   
    pipe_mutex mutex;
 
    struct handle_table *ctx_table;
index c289a8aeffc01ae17696924fbb7076ee8c6af2c1..c96c4b8dfa8ace6c2bfecf7ea00c4f996ae6cb0d 100644 (file)
 #include "pipe/p_screen.h"
 #include "state_tracker/st_context.h"
 #include "state_tracker/st_public.h"
+
+#ifdef DEBUG
+#include "trace/tr_screen.h"
+#include "trace/tr_texture.h"
+#endif
+
 #include "stw_framebuffer.h"
 #include "stw_device.h"
 #include "stw_public.h"
@@ -246,7 +252,8 @@ stw_swap_buffers(
    HDC hdc )
 {
    struct stw_framebuffer *fb;
-   struct pipe_surface *surf;
+   struct pipe_screen *screen;
+   struct pipe_surface *surface;
 
    fb = framebuffer_from_hdc( hdc );
    if (fb == NULL)
@@ -257,14 +264,20 @@ stw_swap_buffers(
     */
    st_notify_swapbuffers( fb->stfb );
 
-   if(st_get_framebuffer_surface( fb->stfb, ST_SURFACE_BACK_LEFT, &surf )) {
-      stw_dev->stw_winsys->flush_frontbuffer(stw_dev->screen,
-                                             surf,
-                                             hdc );
-   }
-   else {
-       /* FIXME: this shouldn't happen, but does on glean */
+   screen = stw_dev->screen;
+   
+   if(!st_get_framebuffer_surface( fb->stfb, ST_SURFACE_BACK_LEFT, &surface ))
+      /* FIXME: this shouldn't happen, but does on glean */
+      return FALSE;
+
+#ifdef DEBUG
+   if(stw_dev->trace_running) {
+      screen = trace_screen(screen)->screen;
+      surface = trace_surface(surface)->surface;
    }
+#endif
 
+   stw_dev->stw_winsys->flush_frontbuffer( screen, surface, hdc );
+   
    return TRUE;
 }
index 42290d7603eca37b9a20d1c599476b53aff0c05c..aabab95f3a8070cf1e4454e6d7022b673d4795b5 100644 (file)
@@ -27,6 +27,7 @@ if env['platform'] == 'windows':
                sources += ['#src/gallium/state_trackers/wgl/opengl32.def']
                
        drivers = [
+               trace,
                softpipe,
        ]