mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2025-12-23 17:40:11 +01:00
Implement dot4 opcode
This commit is contained in:
parent
e20294be11
commit
7abe3364b2
3 changed files with 35 additions and 5 deletions
|
|
@ -226,3 +226,30 @@ llvm::Value * Instructions::rcp(llvm::Value *in1)
|
|||
return vectorFromVals(res, res, res, res);
|
||||
}
|
||||
|
||||
llvm::Value * Instructions::dp4(llvm::Value *in1, llvm::Value *in2)
|
||||
{
|
||||
Value *mulRes = mul(in1, in2);
|
||||
ExtractElementInst *x = new ExtractElementInst(mulRes, unsigned(0),
|
||||
name("extractx"),
|
||||
m_block);
|
||||
ExtractElementInst *y = new ExtractElementInst(mulRes, unsigned(1),
|
||||
name("extracty"),
|
||||
m_block);
|
||||
ExtractElementInst *z = new ExtractElementInst(mulRes, unsigned(2),
|
||||
name("extractz"),
|
||||
m_block);
|
||||
ExtractElementInst *w = new ExtractElementInst(mulRes, unsigned(3),
|
||||
name("extractw"),
|
||||
m_block);
|
||||
BinaryOperator *xy = BinaryOperator::create(Instruction::Add, x, y,
|
||||
name("xy"),
|
||||
m_block);
|
||||
BinaryOperator *xyz = BinaryOperator::create(Instruction::Add, xy, z,
|
||||
name("xyz"),
|
||||
m_block);
|
||||
BinaryOperator *dot4 = BinaryOperator::create(Instruction::Add, xyz, w,
|
||||
name("dot4"),
|
||||
m_block);
|
||||
return vectorFromVals(dot4, dot4, dot4, dot4);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -16,6 +16,7 @@ public:
|
|||
|
||||
llvm::Value *add(llvm::Value *in1, llvm::Value *in2);
|
||||
llvm::Value *dp3(llvm::Value *in1, llvm::Value *in2);
|
||||
llvm::Value *dp4(llvm::Value *in1, llvm::Value *in2);
|
||||
llvm::Value *lit(llvm::Value *in1);
|
||||
llvm::Value *madd(llvm::Value *in1, llvm::Value *in2,
|
||||
llvm::Value *in2);
|
||||
|
|
|
|||
|
|
@ -205,7 +205,9 @@ translate_instruction(llvm::Module *module,
|
|||
out = instr->dp3(inputs[0], inputs[1]);
|
||||
}
|
||||
break;
|
||||
case TGSI_OPCODE_DP4:
|
||||
case TGSI_OPCODE_DP4: {
|
||||
out = instr->dp4(inputs[0], inputs[1]);
|
||||
}
|
||||
break;
|
||||
case TGSI_OPCODE_DST:
|
||||
break;
|
||||
|
|
@ -767,6 +769,10 @@ 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 =
|
||||
(struct ga_llvm_prog *)malloc(sizeof(struct ga_llvm_prog));
|
||||
fprintf(stderr, "DUMPX \n");
|
||||
//tgsi_dump(tokens, TGSI_DUMP_VERBOSE);
|
||||
tgsi_dump(tokens, 0);
|
||||
fprintf(stderr, "DUMPEND \n");
|
||||
llvm::Module *mod = tgsi_to_llvm(tokens);
|
||||
|
||||
/* Run optimization passes over it */
|
||||
|
|
@ -789,10 +795,6 @@ ga_llvm_from_tgsi(struct pipe_context *pipe, const struct tgsi_token *tokens)
|
|||
ee->addModuleProvider(mp);
|
||||
}
|
||||
ga_llvm->module = mod;
|
||||
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::endl;
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue