summaryrefslogtreecommitdiffstats
path: root/src/mesa/pipe/llvm
diff options
context:
space:
mode:
authorZack Rusin <[email protected]>2007-10-15 09:59:19 -0400
committerZack Rusin <[email protected]>2007-10-24 11:21:03 -0400
commit5ffdada717466a78b5b148764ba23c7a95098887 (patch)
treec7005dde4cfd245d650b21278f8d358397a34564 /src/mesa/pipe/llvm
parent9e6d58fac26a12246e9e560f3802ebcbce2423bc (diff)
Execution engine is a singleton, for now keep it in the pipe.
Diffstat (limited to 'src/mesa/pipe/llvm')
-rw-r--r--src/mesa/pipe/llvm/llvmtgsi.cpp30
-rw-r--r--src/mesa/pipe/llvm/llvmtgsi.h5
2 files changed, 24 insertions, 11 deletions
diff --git a/src/mesa/pipe/llvm/llvmtgsi.cpp b/src/mesa/pipe/llvm/llvmtgsi.cpp
index 1abc148521f..a616355f8fd 100644
--- a/src/mesa/pipe/llvm/llvmtgsi.cpp
+++ b/src/mesa/pipe/llvm/llvmtgsi.cpp
@@ -1,5 +1,6 @@
#include "llvmtgsi.h"
+#include "pipe/p_context.h"
#include "pipe/tgsi/exec/tgsi_exec.h"
#include "pipe/tgsi/exec/tgsi_token.h"
#include "pipe/tgsi/exec/tgsi_build.h"
@@ -469,7 +470,7 @@ tgsi_to_llvm(const struct tgsi_token *tokens)
}
struct ga_llvm_prog *
-ga_llvm_from_tgsi(const struct tgsi_token *tokens)
+ga_llvm_from_tgsi(struct pipe_context *pipe, const struct tgsi_token *tokens)
{
std::cout << "Creating llvm " <<std::endl;
struct ga_llvm_prog *ga_llvm =
@@ -487,20 +488,24 @@ ga_llvm_from_tgsi(const struct tgsi_token *tokens)
llvm::ExistingModuleProvider *mp =
new llvm::ExistingModuleProvider(mod);
- llvm::ExecutionEngine *ee =
- llvm::ExecutionEngine::create(mp, false);
-
+ llvm::ExecutionEngine *ee = 0;
+ if (!pipe->llvm_execution_engine) {
+ ee = llvm::ExecutionEngine::create(mp, false);
+ pipe->llvm_execution_engine = ee;
+ } else {
+ ee = (llvm::ExecutionEngine*)pipe->llvm_execution_engine;
+ ee->addModuleProvider(mp);
+ }
ga_llvm->module = mod;
- ga_llvm->engine = ee;
fprintf(stderr, "DUMPX \n");
//tgsi_dump(tokens, TGSI_DUMP_VERBOSE);
tgsi_dump(tokens, 0);
fprintf(stderr, "DUMPEND \n");
Function *func = mod->getFunction("run_vertex_shader");
- std::cout << "run_vertex_shader = "<<func;
+ std::cout << "run_vertex_shader = "<<func<<std::endl;
ga_llvm->function = ee->getPointerToFunctionOrStub(func);
- std::cout << " -- FUNC is " <<ga_llvm->function;
+ std::cout << " -- FUNC is " <<ga_llvm->function<<std::endl;
return ga_llvm;
}
@@ -515,15 +520,22 @@ void ga_llvm_prog_delete(struct ga_llvm_prog *prog)
free(prog);
}
+typedef void (*vertex_shader_runner)(float (*ainputs)[32][4],
+ float (*dests)[32][4],
+ float (*aconsts)[4],
+ int count,
+ int num_attribs);
+
int ga_llvm_prog_exec(struct ga_llvm_prog *prog,
float (*inputs)[32][4],
- void *dests[16*32*4],
+ float (*dests)[32][4],
float (*consts)[4],
int count,
int num_attribs)
{
std::cout << "---- START LLVM Execution "<<std::endl;
-
+ vertex_shader_runner runner = reinterpret_cast<vertex_shader_runner>(prog->function);
+ runner(inputs, dests, consts, count, num_attribs);
std::cout << "---- END LLVM Execution "<<std::endl;
return 0;
diff --git a/src/mesa/pipe/llvm/llvmtgsi.h b/src/mesa/pipe/llvm/llvmtgsi.h
index b1b5717f6d0..f78fbce4c61 100644
--- a/src/mesa/pipe/llvm/llvmtgsi.h
+++ b/src/mesa/pipe/llvm/llvmtgsi.h
@@ -8,6 +8,7 @@ extern "C" {
struct tgsi_exec_machine;
struct tgsi_token;
struct tgsi_sampler;
+struct pipe_context;
struct ga_llvm_prog {
void *module;
@@ -15,13 +16,13 @@ struct ga_llvm_prog {
void *function;
};
struct ga_llvm_prog *
-ga_llvm_from_tgsi(const struct tgsi_token *tokens);
+ga_llvm_from_tgsi(struct pipe_context *pipe, const struct tgsi_token *tokens);
void ga_llvm_prog_delete(struct ga_llvm_prog *prog);
int ga_llvm_prog_exec(struct ga_llvm_prog *prog,
float (*inputs)[32][4],
- void *dests[16*32*4],
+ float (*dests)[32][4],
float (*consts)[4],
int count,
int num_attribs);