summaryrefslogtreecommitdiffstats
path: root/src/gallium/drivers/llvmpipe
diff options
context:
space:
mode:
authorJosé Fonseca <[email protected]>2010-04-24 13:20:39 +0100
committerJosé Fonseca <[email protected]>2010-04-24 13:20:39 +0100
commit39be50dcdebe6bcbb48cb6aa8ac151eee811acb1 (patch)
tree8eea7003235544c246bd3bbaf7e7f96025457ecd /src/gallium/drivers/llvmpipe
parente7a8cfc8776c70f8c4cc3e158f663f6c630169ed (diff)
llvmpipe: Move the determination of the number of threads to the screen.
Diffstat (limited to 'src/gallium/drivers/llvmpipe')
-rw-r--r--src/gallium/drivers/llvmpipe/lp_limits.h3
-rw-r--r--src/gallium/drivers/llvmpipe/lp_rast.c18
-rw-r--r--src/gallium/drivers/llvmpipe/lp_rast.h2
-rw-r--r--src/gallium/drivers/llvmpipe/lp_rast_priv.h8
-rw-r--r--src/gallium/drivers/llvmpipe/lp_screen.c21
-rw-r--r--src/gallium/drivers/llvmpipe/lp_screen.h2
-rw-r--r--src/gallium/drivers/llvmpipe/lp_setup.c6
-rw-r--r--src/gallium/drivers/llvmpipe/lp_setup_context.h1
8 files changed, 36 insertions, 25 deletions
diff --git a/src/gallium/drivers/llvmpipe/lp_limits.h b/src/gallium/drivers/llvmpipe/lp_limits.h
index 9ab1b4b36e3..c7c5a1eca87 100644
--- a/src/gallium/drivers/llvmpipe/lp_limits.h
+++ b/src/gallium/drivers/llvmpipe/lp_limits.h
@@ -58,4 +58,7 @@
#define LP_MAX_WIDTH (1 << (LP_MAX_TEXTURE_LEVELS - 1))
+#define LP_MAX_THREADS 8
+
+
#endif /* LP_LIMITS_H */
diff --git a/src/gallium/drivers/llvmpipe/lp_rast.c b/src/gallium/drivers/llvmpipe/lp_rast.c
index 0a41b6406bd..c3e186b2a06 100644
--- a/src/gallium/drivers/llvmpipe/lp_rast.c
+++ b/src/gallium/drivers/llvmpipe/lp_rast.c
@@ -869,20 +869,6 @@ create_rast_threads(struct lp_rasterizer *rast)
{
unsigned i;
-#ifdef PIPE_OS_WINDOWS
- /* Multithreading not supported on windows until conditions and barriers are
- * properly implemented. */
- rast->num_threads = 0;
-#else
-#ifdef PIPE_OS_EMBEDDED
- rast->num_threads = 0;
-#else
- rast->num_threads = util_cpu_caps.nr_cpus;
-#endif
- rast->num_threads = debug_get_num_option("LP_NUM_THREADS", rast->num_threads);
- rast->num_threads = MIN2(rast->num_threads, MAX_THREADS);
-#endif
-
/* NOTE: if num_threads is zero, we won't use any threads */
for (i = 0; i < rast->num_threads; i++) {
pipe_semaphore_init(&rast->tasks[i].work_ready, 0);
@@ -900,7 +886,7 @@ create_rast_threads(struct lp_rasterizer *rast)
* processing them.
*/
struct lp_rasterizer *
-lp_rast_create( void )
+lp_rast_create( unsigned num_threads )
{
struct lp_rasterizer *rast;
unsigned i;
@@ -917,6 +903,8 @@ lp_rast_create( void )
task->thread_index = i;
}
+ rast->num_threads = num_threads;
+
create_rast_threads(rast);
/* for synchronizing rasterization threads */
diff --git a/src/gallium/drivers/llvmpipe/lp_rast.h b/src/gallium/drivers/llvmpipe/lp_rast.h
index a0ecb2fc47f..e2f6f926779 100644
--- a/src/gallium/drivers/llvmpipe/lp_rast.h
+++ b/src/gallium/drivers/llvmpipe/lp_rast.h
@@ -134,7 +134,7 @@ struct lp_rast_triangle {
struct lp_rasterizer *
-lp_rast_create( void );
+lp_rast_create( unsigned num_threads );
void
lp_rast_destroy( struct lp_rasterizer * );
diff --git a/src/gallium/drivers/llvmpipe/lp_rast_priv.h b/src/gallium/drivers/llvmpipe/lp_rast_priv.h
index 8bf2b92a6ab..18457ff4ce2 100644
--- a/src/gallium/drivers/llvmpipe/lp_rast_priv.h
+++ b/src/gallium/drivers/llvmpipe/lp_rast_priv.h
@@ -35,9 +35,7 @@
#include "lp_scene.h"
#include "lp_texture.h"
#include "lp_tile_soa.h"
-
-
-#define MAX_THREADS 8 /* XXX probably temporary here */
+#include "lp_limits.h"
struct lp_rasterizer;
@@ -113,10 +111,10 @@ struct lp_rasterizer
struct lp_scene *curr_scene;
/** A task object for each rasterization thread */
- struct lp_rasterizer_task tasks[MAX_THREADS];
+ struct lp_rasterizer_task tasks[LP_MAX_THREADS];
unsigned num_threads;
- pipe_thread threads[MAX_THREADS];
+ pipe_thread threads[LP_MAX_THREADS];
/** For synchronizing the rasterization threads */
pipe_barrier barrier;
diff --git a/src/gallium/drivers/llvmpipe/lp_screen.c b/src/gallium/drivers/llvmpipe/lp_screen.c
index 7d2cd0c7679..88c0604c541 100644
--- a/src/gallium/drivers/llvmpipe/lp_screen.c
+++ b/src/gallium/drivers/llvmpipe/lp_screen.c
@@ -27,6 +27,8 @@
#include "util/u_memory.h"
+#include "util/u_math.h"
+#include "util/u_cpu_detect.h"
#include "util/u_format.h"
#include "util/u_format_s3tc.h"
#include "pipe/p_defines.h"
@@ -39,6 +41,7 @@
#include "lp_context.h"
#include "lp_debug.h"
#include "lp_public.h"
+#include "lp_limits.h"
#include "state_tracker/sw_winsys.h"
@@ -284,12 +287,26 @@ llvmpipe_create_screen(struct sw_winsys *winsys)
screen->base.context_create = llvmpipe_create_context;
screen->base.flush_frontbuffer = llvmpipe_flush_frontbuffer;
- util_format_s3tc_init();
-
llvmpipe_init_screen_resource_funcs(&screen->base);
llvmpipe_init_screen_fence_funcs(&screen->base);
lp_jit_screen_init(screen);
+#ifdef PIPE_OS_WINDOWS
+ /* Multithreading not supported on windows until conditions and barriers are
+ * properly implemented. */
+ screen->num_threads = 0;
+#else
+#ifdef PIPE_OS_EMBEDDED
+ screen->num_threads = 0;
+#else
+ screen->num_threads = util_cpu_caps.nr_cpus;
+#endif
+ screen->num_threads = debug_get_num_option("LP_NUM_THREADS", screen->num_threads);
+ screen->num_threads = MIN2(screen->num_threads, LP_MAX_THREADS);
+#endif
+
+ util_format_s3tc_init();
+
return &screen->base;
}
diff --git a/src/gallium/drivers/llvmpipe/lp_screen.h b/src/gallium/drivers/llvmpipe/lp_screen.h
index af25e043cc9..4f394326103 100644
--- a/src/gallium/drivers/llvmpipe/lp_screen.h
+++ b/src/gallium/drivers/llvmpipe/lp_screen.h
@@ -58,6 +58,8 @@ struct llvmpipe_screen
LLVMTypeRef context_ptr_type;
+ unsigned num_threads;
+
/* Increments whenever textures are modified. Contexts can track
* this.
*/
diff --git a/src/gallium/drivers/llvmpipe/lp_setup.c b/src/gallium/drivers/llvmpipe/lp_setup.c
index 210c7b8a908..0dad4c259ec 100644
--- a/src/gallium/drivers/llvmpipe/lp_setup.c
+++ b/src/gallium/drivers/llvmpipe/lp_setup.c
@@ -765,8 +765,9 @@ struct lp_setup_context *
lp_setup_create( struct pipe_context *pipe,
struct draw_context *draw )
{
- unsigned i;
+ struct llvmpipe_screen *screen = llvmpipe_screen(pipe->screen);
struct lp_setup_context *setup = CALLOC_STRUCT(lp_setup_context);
+ unsigned i;
if (!setup)
return NULL;
@@ -779,7 +780,8 @@ lp_setup_create( struct pipe_context *pipe,
/* XXX: move this to the screen and share between contexts:
*/
- setup->rast = lp_rast_create();
+ setup->num_threads = screen->num_threads;
+ setup->rast = lp_rast_create(screen->num_threads);
if (!setup->rast)
goto fail;
diff --git a/src/gallium/drivers/llvmpipe/lp_setup_context.h b/src/gallium/drivers/llvmpipe/lp_setup_context.h
index 4594f7597d5..584764ce8ac 100644
--- a/src/gallium/drivers/llvmpipe/lp_setup_context.h
+++ b/src/gallium/drivers/llvmpipe/lp_setup_context.h
@@ -80,6 +80,7 @@ struct lp_setup_context
* create/install this itself now.
*/
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 */