llvmpipe: move rasterizer to screen instead of setup context
authorRoland Scheidegger <sroland@vmware.com>
Tue, 13 Jul 2010 17:58:58 +0000 (19:58 +0200)
committerRoland Scheidegger <sroland@vmware.com>
Tue, 13 Jul 2010 17:58:58 +0000 (19:58 +0200)
there's no point of having this per context, so move to screen
(and protect with a mutex).

src/gallium/drivers/llvmpipe/lp_screen.c
src/gallium/drivers/llvmpipe/lp_screen.h
src/gallium/drivers/llvmpipe/lp_setup.c
src/gallium/drivers/llvmpipe/lp_setup_context.h

index e151782ceacf124bf13030ec83a28ad43f48113b..f7f1635ef96b5163363b0e8d0430ef667031df90 100644 (file)
@@ -43,6 +43,7 @@
 #include "lp_debug.h"
 #include "lp_public.h"
 #include "lp_limits.h"
+#include "lp_rast.h"
 
 #include "state_tracker/sw_winsys.h"
 
@@ -296,11 +297,16 @@ llvmpipe_destroy_screen( struct pipe_screen *_screen )
    struct llvmpipe_screen *screen = llvmpipe_screen(_screen);
    struct sw_winsys *winsys = screen->winsys;
 
+   if (screen->rast)
+      lp_rast_destroy(screen->rast);
+
    lp_jit_screen_cleanup(screen);
 
    if(winsys->destroy)
       winsys->destroy(winsys);
 
+   pipe_mutex_destroy(screen->rast_mutex);
+
    FREE(screen);
 }
 
@@ -357,6 +363,14 @@ llvmpipe_create_screen(struct sw_winsys *winsys)
    screen->num_threads = debug_get_num_option("LP_NUM_THREADS", screen->num_threads);
    screen->num_threads = MIN2(screen->num_threads, LP_MAX_THREADS);
 
+   screen->rast = lp_rast_create(screen->num_threads);
+   if (!screen->rast) {
+      lp_jit_screen_cleanup(screen);
+      FREE(screen);
+      return NULL;
+   }
+   pipe_mutex_init(screen->rast_mutex);
+
    util_format_s3tc_init();
 
    return &screen->base;
index eb40f6823f5f946be6fa686022f27a96abf7a304..731526dfabebc72e28d8ddb5a0a0a30a08d29e4f 100644 (file)
@@ -37,6 +37,7 @@
 #include "gallivm/lp_bld.h"
 #include <llvm-c/ExecutionEngine.h>
 
+#include "os/os_thread.h"
 #include "pipe/p_screen.h"
 #include "pipe/p_defines.h"
 
@@ -63,6 +64,9 @@ struct llvmpipe_screen
    /* Increments whenever textures are modified.  Contexts can track this.
     */
    unsigned timestamp;
+
+   struct lp_rasterizer *rast;
+   pipe_mutex rast_mutex;
 };
 
 
index c429f4be0dc9aed9edf911d28679afe6bf49d45f..7d48ad8e741793a7cc2597b2b61d4cb3274c9ab6 100644 (file)
@@ -152,8 +152,11 @@ static void
 lp_setup_rasterize_scene( struct lp_setup_context *setup )
 {
    struct lp_scene *scene = lp_setup_get_current_scene(setup);
+   struct llvmpipe_screen *screen = llvmpipe_screen(scene->pipe->screen);
 
-   lp_scene_rasterize(scene, setup->rast);
+   pipe_mutex_lock(screen->rast_mutex);
+   lp_scene_rasterize(scene, screen->rast);
+   pipe_mutex_unlock(screen->rast_mutex);
 
    reset_context( setup );
 
@@ -851,8 +854,6 @@ lp_setup_destroy( struct lp_setup_context *setup )
 
    lp_scene_queue_destroy(setup->empty_scenes);
 
-   lp_rast_destroy( setup->rast );
-
    FREE( setup );
 }
 
@@ -879,13 +880,7 @@ lp_setup_create( struct pipe_context *pipe,
    if (!setup->empty_scenes)
       goto fail;
 
-   /* XXX: move this to the screen and share between contexts:
-    */
    setup->num_threads = screen->num_threads;
-   setup->rast = lp_rast_create(screen->num_threads);
-   if (!setup->rast) 
-      goto fail;
-
    setup->vbuf = draw_vbuf_stage(draw, &setup->base);
    if (!setup->vbuf)
       goto fail;
@@ -909,9 +904,6 @@ lp_setup_create( struct pipe_context *pipe,
    return setup;
 
 fail:
-   if (setup->rast)
-      lp_rast_destroy( setup->rast );
-   
    if (setup->vbuf)
       ;
 
index 0cea7791f57c84ce1d1ba0676fb2f8364bc786c8..a0606f503408e882db84b176b457f1c450cb5825 100644 (file)
@@ -81,7 +81,6 @@ struct lp_setup_context
     */
    struct draw_stage *vbuf;
    unsigned num_threads;
-   struct lp_rasterizer *rast;
    struct lp_scene *scenes[MAX_SCENES];  /**< all the scenes */
    struct lp_scene *scene;               /**< current scene being built */
    struct lp_scene_queue *empty_scenes;  /**< queue of empty scenes */