summaryrefslogtreecommitdiff
path: root/src/mesa/pipe
diff options
context:
space:
mode:
authorZack Rusin <zack@tungstengraphics.com>2008-02-13 04:38:10 -0500
committerZack Rusin <zack@tungstengraphics.com>2008-02-13 04:38:10 -0500
commit4bb1a14d901fcddb25efeeff49c4dea8ca872f73 (patch)
tree9abc2e5fe642b06374d6690035174918ebd12b06 /src/mesa/pipe
parente179d5bdd199e3747773f5b07efcf9a635c41089 (diff)
handle temporaries in llvm code generated paths
Diffstat (limited to 'src/mesa/pipe')
-rw-r--r--src/mesa/pipe/draw/draw_vertex_shader.c3
-rw-r--r--src/mesa/pipe/llvm/gallivm.h3
-rw-r--r--src/mesa/pipe/llvm/gallivm_cpu.cpp10
-rw-r--r--src/mesa/pipe/llvm/storagesoa.cpp23
-rw-r--r--src/mesa/pipe/llvm/storagesoa.h4
-rw-r--r--src/mesa/pipe/llvm/tgsitollvm.cpp32
6 files changed, 50 insertions, 25 deletions
diff --git a/src/mesa/pipe/draw/draw_vertex_shader.c b/src/mesa/pipe/draw/draw_vertex_shader.c
index 9c31df1e3e..c824c1407e 100644
--- a/src/mesa/pipe/draw/draw_vertex_shader.c
+++ b/src/mesa/pipe/draw/draw_vertex_shader.c
@@ -119,7 +119,8 @@ run_vertex_program(struct draw_context *draw,
gallivm_cpu_vs_exec(prog,
machine->Inputs,
machine->Outputs,
- machine->Consts);
+ machine->Consts,
+ machine->Temps);
} else
#elif defined(__i386__) || defined(__386__)
if (draw->use_sse) {
diff --git a/src/mesa/pipe/llvm/gallivm.h b/src/mesa/pipe/llvm/gallivm.h
index b104520cb7..92da4bca7f 100644
--- a/src/mesa/pipe/llvm/gallivm.h
+++ b/src/mesa/pipe/llvm/gallivm.h
@@ -82,7 +82,8 @@ struct gallivm_cpu_engine *gallivm_global_cpu_engine();
int gallivm_cpu_vs_exec(struct gallivm_prog *prog,
struct tgsi_exec_vector *inputs,
struct tgsi_exec_vector *dests,
- float (*consts)[4]);
+ float (*consts)[4],
+ struct tgsi_exec_vector *temps);
int gallivm_cpu_fs_exec(struct gallivm_prog *prog,
float x, float y,
float (*dests)[PIPE_MAX_SHADER_INPUTS][4],
diff --git a/src/mesa/pipe/llvm/gallivm_cpu.cpp b/src/mesa/pipe/llvm/gallivm_cpu.cpp
index 011cba55c2..dc4d92a72a 100644
--- a/src/mesa/pipe/llvm/gallivm_cpu.cpp
+++ b/src/mesa/pipe/llvm/gallivm_cpu.cpp
@@ -177,10 +177,7 @@ struct gallivm_cpu_engine * gallivm_global_cpu_engine()
typedef void (*vertex_shader_runner)(void *ainputs,
void *dests,
float (*aconsts)[4],
- int num_vertices,
- int num_inputs,
- int num_attribs,
- int num_consts);
+ void *temps);
/*!
@@ -191,12 +188,13 @@ typedef void (*vertex_shader_runner)(void *ainputs,
int gallivm_cpu_vs_exec(struct gallivm_prog *prog,
struct tgsi_exec_vector *inputs,
struct tgsi_exec_vector *dests,
- float (*consts)[4])
+ float (*consts)[4],
+ struct tgsi_exec_vector *temps)
{
vertex_shader_runner runner = reinterpret_cast<vertex_shader_runner>(prog->function);
assert(runner);
/*FIXME*/
- runner(inputs, dests, consts, 4, 4, 4, prog->num_consts);
+ runner(inputs, dests, consts, temps);
return 0;
}
diff --git a/src/mesa/pipe/llvm/storagesoa.cpp b/src/mesa/pipe/llvm/storagesoa.cpp
index ef14e29bfe..e09e9e8fe7 100644
--- a/src/mesa/pipe/llvm/storagesoa.cpp
+++ b/src/mesa/pipe/llvm/storagesoa.cpp
@@ -44,11 +44,13 @@ using namespace llvm;
StorageSoa::StorageSoa(llvm::BasicBlock *block,
llvm::Value *input,
llvm::Value *output,
- llvm::Value *consts)
+ llvm::Value *consts,
+ llvm::Value *temps)
: m_block(block),
m_input(input),
m_output(output),
m_consts(consts),
+ m_temps(temps),
m_idx(0)
{
}
@@ -101,6 +103,11 @@ std::vector<llvm::Value*> StorageSoa::tempElement(int idx, int swizzle,
{
std::vector<llvm::Value*> res(4);
+ res[0] = element(m_temps, idx, 0);
+ res[1] = element(m_temps, idx, 1);
+ res[2] = element(m_temps, idx, 2);
+ res[3] = element(m_temps, idx, 3);
+
return res;
}
@@ -138,6 +145,20 @@ void StorageSoa::storeOutput(int dstIdx, const std::vector<llvm::Value*> &val,
void StorageSoa::storeTemp(int idx, const std::vector<llvm::Value*> &val,
int mask)
{
+ if (mask != TGSI_WRITEMASK_XYZW) {
+ fprintf(stderr, "requires swizzle!!\n");
+ assert(0);
+ } else {
+ llvm::Value *xChannel = elementPointer(m_temps, idx, 0);
+ llvm::Value *yChannel = elementPointer(m_temps, idx, 1);
+ llvm::Value *zChannel = elementPointer(m_temps, idx, 2);
+ llvm::Value *wChannel = elementPointer(m_temps, idx, 3);
+
+ StoreInst *st = new StoreInst(val[0], xChannel, false, m_block);
+ st = new StoreInst(val[1], yChannel, false, m_block);
+ st = new StoreInst(val[2], zChannel, false, m_block);
+ st = new StoreInst(val[3], wChannel, false, m_block);
+ }
}
void StorageSoa::storeAddress(int idx, const std::vector<llvm::Value*> &val,
diff --git a/src/mesa/pipe/llvm/storagesoa.h b/src/mesa/pipe/llvm/storagesoa.h
index 9d5609f539..84db7726a7 100644
--- a/src/mesa/pipe/llvm/storagesoa.h
+++ b/src/mesa/pipe/llvm/storagesoa.h
@@ -46,7 +46,8 @@ public:
StorageSoa(llvm::BasicBlock *block,
llvm::Value *input,
llvm::Value *output,
- llvm::Value *consts);
+ llvm::Value *consts,
+ llvm::Value *temps);
void addImmediate(float *vec);
@@ -79,6 +80,7 @@ private:
llvm::Value *m_input;
llvm::Value *m_output;
llvm::Value *m_consts;
+ llvm::Value *m_temps;
mutable std::map<int, llvm::ConstantInt*> m_constInts;
mutable char m_name[32];
diff --git a/src/mesa/pipe/llvm/tgsitollvm.cpp b/src/mesa/pipe/llvm/tgsitollvm.cpp
index 070c9a67f3..3497eebcd9 100644
--- a/src/mesa/pipe/llvm/tgsitollvm.cpp
+++ b/src/mesa/pipe/llvm/tgsitollvm.cpp
@@ -53,23 +53,23 @@ static inline FunctionType *vertexShaderFunctionType()
// pass are castable to the following:
// [4 x <4 x float>] inputs,
// [4 x <4 x float>] output,
- // [4 x [4 x float]] consts
+ // [4 x [4 x float]] consts,
+ // [4 x <4 x float>] temps
+
std::vector<const Type*> funcArgs;
- {
- VectorType *vectorType = VectorType::get(Type::FloatTy, 4);
- ArrayType *vectorArray = ArrayType::get(vectorType, 4);
- PointerType *vectorArrayPtr = PointerType::get(vectorArray, 0);
+ VectorType *vectorType = VectorType::get(Type::FloatTy, 4);
+ ArrayType *vectorArray = ArrayType::get(vectorType, 4);
+ PointerType *vectorArrayPtr = PointerType::get(vectorArray, 0);
- funcArgs.push_back(vectorArrayPtr);//inputs
- funcArgs.push_back(vectorArrayPtr);//output
- }
- {
- ArrayType *floatArray = ArrayType::get(Type::FloatTy, 4);
- ArrayType *constsArray = ArrayType::get(floatArray, 4);
- PointerType *constsArrayPtr = PointerType::get(constsArray, 0);
+ ArrayType *floatArray = ArrayType::get(Type::FloatTy, 4);
+ ArrayType *constsArray = ArrayType::get(floatArray, 4);
+ PointerType *constsArrayPtr = PointerType::get(constsArray, 0);
+
+ funcArgs.push_back(vectorArrayPtr);//inputs
+ funcArgs.push_back(vectorArrayPtr);//output
+ funcArgs.push_back(constsArrayPtr);//consts
+ funcArgs.push_back(vectorArrayPtr);//temps
- funcArgs.push_back(constsArrayPtr);//consts
- }
FunctionType *functionType = FunctionType::get(
/*Result=*/Type::VoidTy,
/*Params=*/funcArgs,
@@ -1162,6 +1162,8 @@ llvm::Module * tgsi_to_llvmir(struct gallivm_ir *ir,
output->setName("outputs");
Value *consts = args++;
consts->setName("consts");
+ Value *temps = args++;
+ temps->setName("temps");
BasicBlock *label_entry = new BasicBlock("entry", shader, 0);
@@ -1170,7 +1172,7 @@ llvm::Module * tgsi_to_llvmir(struct gallivm_ir *ir,
fi = tgsi_default_full_instruction();
fd = tgsi_default_full_declaration();
- StorageSoa storage(label_entry, input, output, consts);
+ StorageSoa storage(label_entry, input, output, consts, temps);
InstructionsSoa instr(mod, shader, label_entry, &storage);
while(!tgsi_parse_end_of_tokens(&parse)) {