summaryrefslogtreecommitdiffstats
path: root/src/gallium/drivers/llvmpipe
diff options
context:
space:
mode:
authorMathias Fröhlich <[email protected]>2014-08-28 19:49:35 +0200
committerMathias Fröhlich <[email protected]>2014-09-30 20:45:19 +0200
commit83c62597fc8eb38bf274fa1a3ca03c6adafb4bf9 (patch)
tree512da771be3fa564311d151785c62eb06ad40a64 /src/gallium/drivers/llvmpipe
parent98d00d664009c74ac0c827b3c41c15e3fe1993d4 (diff)
llvmpipe: Use two LLVMContexts per OpenGL context instead of a global one.
This is one step to make llvmpipe thread safe as mandated by the OpenGL standard. Using the global LLVMContext is obviously a problem for that kind of use pattern. The patch introduces two LLVMContext instances that are private to an OpenGL context and used for all compiles. One is put into struct draw_llvm and the other one into struct llvmpipe_context. Reviewed-by: Jose Fonseca <[email protected]> Signed-off-by: Mathias Froehlich <[email protected]>
Diffstat (limited to 'src/gallium/drivers/llvmpipe')
-rw-r--r--src/gallium/drivers/llvmpipe/lp_context.c7
-rw-r--r--src/gallium/drivers/llvmpipe/lp_context.h3
-rw-r--r--src/gallium/drivers/llvmpipe/lp_state_fs.c2
-rw-r--r--src/gallium/drivers/llvmpipe/lp_state_setup.c2
-rw-r--r--src/gallium/drivers/llvmpipe/lp_test_arit.c2
-rw-r--r--src/gallium/drivers/llvmpipe/lp_test_blend.c2
-rw-r--r--src/gallium/drivers/llvmpipe/lp_test_conv.c2
-rw-r--r--src/gallium/drivers/llvmpipe/lp_test_format.c2
-rw-r--r--src/gallium/drivers/llvmpipe/lp_test_printf.c2
9 files changed, 17 insertions, 7 deletions
diff --git a/src/gallium/drivers/llvmpipe/lp_context.c b/src/gallium/drivers/llvmpipe/lp_context.c
index d9696c2067d..3a9b4c22a9b 100644
--- a/src/gallium/drivers/llvmpipe/lp_context.c
+++ b/src/gallium/drivers/llvmpipe/lp_context.c
@@ -93,6 +93,9 @@ static void llvmpipe_destroy( struct pipe_context *pipe )
lp_delete_setup_variants(llvmpipe);
+ LLVMContextDispose(llvmpipe->context);
+ llvmpipe->context = NULL;
+
align_free( llvmpipe );
}
@@ -161,6 +164,10 @@ llvmpipe_create_context( struct pipe_screen *screen, void *priv )
llvmpipe_init_context_resource_funcs( &llvmpipe->pipe );
llvmpipe_init_surface_functions(llvmpipe);
+ llvmpipe->context = LLVMContextCreate();
+ if (!llvmpipe->context)
+ goto fail;
+
/*
* Create drawing context and plug our rendering stage into it.
*/
diff --git a/src/gallium/drivers/llvmpipe/lp_context.h b/src/gallium/drivers/llvmpipe/lp_context.h
index ee0831fbb6d..0d47c0d517c 100644
--- a/src/gallium/drivers/llvmpipe/lp_context.h
+++ b/src/gallium/drivers/llvmpipe/lp_context.h
@@ -153,6 +153,9 @@ struct llvmpipe_context {
struct pipe_query *render_cond_query;
uint render_cond_mode;
boolean render_cond_cond;
+
+ /** The LLVMContext to use for LLVM related work */
+ LLVMContextRef context;
};
diff --git a/src/gallium/drivers/llvmpipe/lp_state_fs.c b/src/gallium/drivers/llvmpipe/lp_state_fs.c
index 0b74d15cc64..ff2939d4db4 100644
--- a/src/gallium/drivers/llvmpipe/lp_state_fs.c
+++ b/src/gallium/drivers/llvmpipe/lp_state_fs.c
@@ -2565,7 +2565,7 @@ generate_variant(struct llvmpipe_context *lp,
util_snprintf(module_name, sizeof(module_name), "fs%u_variant%u",
shader->no, shader->variants_created);
- variant->gallivm = gallivm_create(module_name);
+ variant->gallivm = gallivm_create(module_name, lp->context);
if (!variant->gallivm) {
FREE(variant);
return NULL;
diff --git a/src/gallium/drivers/llvmpipe/lp_state_setup.c b/src/gallium/drivers/llvmpipe/lp_state_setup.c
index 63c92d588c9..49741db66f0 100644
--- a/src/gallium/drivers/llvmpipe/lp_state_setup.c
+++ b/src/gallium/drivers/llvmpipe/lp_state_setup.c
@@ -731,7 +731,7 @@ generate_setup_variant(struct lp_setup_variant_key *key,
util_snprintf(func_name, sizeof(func_name), "setup_variant_%u",
variant->no);
- variant->gallivm = gallivm = gallivm_create(func_name);
+ variant->gallivm = gallivm = gallivm_create(func_name, lp->context);
if (!variant->gallivm) {
goto fail;
}
diff --git a/src/gallium/drivers/llvmpipe/lp_test_arit.c b/src/gallium/drivers/llvmpipe/lp_test_arit.c
index bf405a54ae1..660ad4db02e 100644
--- a/src/gallium/drivers/llvmpipe/lp_test_arit.c
+++ b/src/gallium/drivers/llvmpipe/lp_test_arit.c
@@ -354,7 +354,7 @@ test_unary(unsigned verbose, FILE *fp, const struct unary_test_t *test)
in[i] = 1.0;
}
- gallivm = gallivm_create("test_module");
+ gallivm = gallivm_create("test_module", LLVMGetGlobalContext());
test_func = build_unary_test_func(gallivm, test);
diff --git a/src/gallium/drivers/llvmpipe/lp_test_blend.c b/src/gallium/drivers/llvmpipe/lp_test_blend.c
index 4775aff877b..37420b02442 100644
--- a/src/gallium/drivers/llvmpipe/lp_test_blend.c
+++ b/src/gallium/drivers/llvmpipe/lp_test_blend.c
@@ -450,7 +450,7 @@ test_one(unsigned verbose,
if(verbose >= 1)
dump_blend_type(stdout, blend, type);
- gallivm = gallivm_create("test_module");
+ gallivm = gallivm_create("test_module", LLVMGetGlobalContext());
func = add_blend_test(gallivm, blend, type);
diff --git a/src/gallium/drivers/llvmpipe/lp_test_conv.c b/src/gallium/drivers/llvmpipe/lp_test_conv.c
index 948a218d7f7..8290da4004b 100644
--- a/src/gallium/drivers/llvmpipe/lp_test_conv.c
+++ b/src/gallium/drivers/llvmpipe/lp_test_conv.c
@@ -211,7 +211,7 @@ test_one(unsigned verbose,
eps = MAX2(lp_const_eps(src_type), lp_const_eps(dst_type));
- gallivm = gallivm_create("test_module");
+ gallivm = gallivm_create("test_module", LLVMGetGlobalContext());
func = add_conv_test(gallivm, src_type, num_srcs, dst_type, num_dsts);
diff --git a/src/gallium/drivers/llvmpipe/lp_test_format.c b/src/gallium/drivers/llvmpipe/lp_test_format.c
index 2c8321939ae..8a81151f597 100644
--- a/src/gallium/drivers/llvmpipe/lp_test_format.c
+++ b/src/gallium/drivers/llvmpipe/lp_test_format.c
@@ -138,7 +138,7 @@ test_format_float(unsigned verbose, FILE *fp,
boolean success = TRUE;
unsigned i, j, k, l;
- gallivm = gallivm_create("test_module_float");
+ gallivm = gallivm_create("test_module_float", LLVMGetGlobalContext());
fetch = add_fetch_rgba_test(gallivm, verbose, desc, lp_float32_vec4_type());
diff --git a/src/gallium/drivers/llvmpipe/lp_test_printf.c b/src/gallium/drivers/llvmpipe/lp_test_printf.c
index 4b74ae96a7a..fe4ce0fc5d7 100644
--- a/src/gallium/drivers/llvmpipe/lp_test_printf.c
+++ b/src/gallium/drivers/llvmpipe/lp_test_printf.c
@@ -94,7 +94,7 @@ test_printf(unsigned verbose, FILE *fp,
test_printf_t test_printf_func;
boolean success = TRUE;
- gallivm = gallivm_create("test_module");
+ gallivm = gallivm_create("test_module", LLVMGetGlobalContext());
test = add_printf_test(gallivm);