From c022e15d1e56ba3a9c6b74eef6556d6063e2e322 Mon Sep 17 00:00:00 2001 From: José Fonseca Date: Sun, 23 Aug 2009 06:35:09 +0100 Subject: llvmpipe: Pass fragment context to generated function in a single structure. --- src/gallium/drivers/llvmpipe/lp_jit.c | 38 ++++++++++++++++++++++++++++++++++- 1 file changed, 37 insertions(+), 1 deletion(-) (limited to 'src/gallium/drivers/llvmpipe/lp_jit.c') diff --git a/src/gallium/drivers/llvmpipe/lp_jit.c b/src/gallium/drivers/llvmpipe/lp_jit.c index c3ba03a5a18..92d5d43d0cc 100644 --- a/src/gallium/drivers/llvmpipe/lp_jit.c +++ b/src/gallium/drivers/llvmpipe/lp_jit.c @@ -35,10 +35,42 @@ #include +#include "util/u_memory.h" #include "lp_screen.h" #include "lp_jit.h" +static void +lp_jit_init_types(struct llvmpipe_screen *screen) +{ + /* struct lp_jit_context */ + { + LLVMTypeRef elem_types[2]; + LLVMTypeRef context_type; + + elem_types[0] = LLVMPointerType(LLVMFloatType(), 0); /* constants */ + elem_types[1] = LLVMPointerType(LLVMInt8Type(), 0); /* samplers */ + + context_type = LLVMStructType(elem_types, Elements(elem_types), 0); + + LP_CHECK_MEMBER_OFFSET(struct lp_jit_context, constants, + screen->target, context_type, 0); + LP_CHECK_MEMBER_OFFSET(struct lp_jit_context, samplers, + screen->target, context_type, 1); + LP_CHECK_STRUCT_SIZE(struct lp_jit_context, + screen->target, context_type); + + LLVMAddTypeName(screen->module, "context", context_type); + + screen->context_ptr_type = LLVMPointerType(context_type, 0); + } + +#ifdef DEBUG + LLVMDumpModule(screen->module); +#endif +} + + void lp_jit_screen_cleanup(struct llvmpipe_screen *screen) { @@ -65,8 +97,10 @@ lp_jit_screen_init(struct llvmpipe_screen *screen) abort(); } + screen->target = LLVMGetExecutionEngineTargetData(screen->engine); + screen->pass = LLVMCreateFunctionPassManager(screen->provider); - LLVMAddTargetData(LLVMGetExecutionEngineTargetData(screen->engine), screen->pass); + LLVMAddTargetData(screen->target, screen->pass); /* These are the passes currently listed in llvm-c/Transforms/Scalar.h, * but there are more on SVN. */ LLVMAddConstantPropagationPass(screen->pass); @@ -74,4 +108,6 @@ lp_jit_screen_init(struct llvmpipe_screen *screen) LLVMAddPromoteMemoryToRegisterPass(screen->pass); LLVMAddGVNPass(screen->pass); LLVMAddCFGSimplificationPass(screen->pass); + + lp_jit_init_types(screen); } -- cgit v1.2.3