* Create new draw module context with gallivm state for LLVM JIT.
*/
static struct draw_context *
-draw_create_context(struct pipe_context *pipe, boolean try_llvm)
+draw_create_context(struct pipe_context *pipe, void *context,
+ boolean try_llvm)
{
struct draw_context *draw = CALLOC_STRUCT( draw_context );
if (draw == NULL)
#if HAVE_LLVM
if (try_llvm && draw_get_option_use_llvm()) {
- draw->llvm = draw_llvm_create(draw);
+ draw->llvm = draw_llvm_create(draw, (LLVMContextRef)context);
}
#endif
struct draw_context *
draw_create(struct pipe_context *pipe)
{
- return draw_create_context(pipe, TRUE);
+ return draw_create_context(pipe, NULL, TRUE);
}
+#if HAVE_LLVM
+struct draw_context *
+draw_create_with_llvm_context(struct pipe_context *pipe,
+ void *context)
+{
+ return draw_create_context(pipe, context, TRUE);
+}
+#endif
+
/**
* Create a new draw context, without LLVM JIT.
*/
struct draw_context *
draw_create_no_llvm(struct pipe_context *pipe)
{
- return draw_create_context(pipe, FALSE);
+ return draw_create_context(pipe, NULL, FALSE);
}
struct draw_context *draw_create( struct pipe_context *pipe );
+#if HAVE_LLVM
+struct draw_context *draw_create_with_llvm_context(struct pipe_context *pipe,
+ void *context);
+#endif
+
struct draw_context *draw_create_no_llvm(struct pipe_context *pipe);
void draw_destroy( struct draw_context *draw );
* Create per-context LLVM info.
*/
struct draw_llvm *
-draw_llvm_create(struct draw_context *draw)
+draw_llvm_create(struct draw_context *draw, LLVMContextRef context)
{
struct draw_llvm *llvm;
llvm->draw = draw;
- llvm->context = LLVMContextCreate();
+ llvm->context = context;
+ if (!llvm->context) {
+ llvm->context = LLVMContextCreate();
+ llvm->context_owned = true;
+ }
if (!llvm->context)
goto fail;
void
draw_llvm_destroy(struct draw_llvm *llvm)
{
- LLVMContextDispose(llvm->context);
+ if (llvm->context_owned)
+ LLVMContextDispose(llvm->context);
llvm->context = NULL;
/* XXX free other draw_llvm data? */
struct draw_context *draw;
LLVMContextRef context;
+ boolean context_owned;
struct draw_jit_context jit_context;
struct draw_gs_jit_context gs_jit_context;
struct draw_llvm *
-draw_llvm_create(struct draw_context *draw);
+draw_llvm_create(struct draw_context *draw, LLVMContextRef llvm_context);
void
draw_llvm_destroy(struct draw_llvm *llvm);
/*
* Create drawing context and plug our rendering stage into it.
*/
- llvmpipe->draw = draw_create(&llvmpipe->pipe);
+ llvmpipe->draw = draw_create_with_llvm_context(&llvmpipe->pipe,
+ llvmpipe->context);
if (!llvmpipe->draw)
goto fail;