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) {
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],
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);
/*!
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;
}
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)
{
}
{
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;
}
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,
StorageSoa(llvm::BasicBlock *block,
llvm::Value *input,
llvm::Value *output,
- llvm::Value *consts);
+ llvm::Value *consts,
+ llvm::Value *temps);
void addImmediate(float *vec);
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];
// 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,
output->setName("outputs");
Value *consts = args++;
consts->setName("consts");
+ Value *temps = args++;
+ temps->setName("temps");
BasicBlock *label_entry = new BasicBlock("entry", shader, 0);
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)) {