diff options
author | Zack Rusin <[email protected]> | 2007-10-22 14:01:52 -0400 |
---|---|---|
committer | Zack Rusin <[email protected]> | 2007-10-24 11:21:05 -0400 |
commit | 1248b9776bfeec1f61962604b21212d2cf336283 (patch) | |
tree | 818f5877f83cf386b6903520360f53196bd68f5d | |
parent | 743e96eec5f89cf55873b82ee58b4a06d094c0e9 (diff) |
Implement extended swizzling.
-rw-r--r-- | src/mesa/pipe/llvm/llvmtgsi.cpp | 29 | ||||
-rw-r--r-- | src/mesa/pipe/llvm/storage.cpp | 25 | ||||
-rw-r--r-- | src/mesa/pipe/llvm/storage.h | 2 |
3 files changed, 50 insertions, 6 deletions
diff --git a/src/mesa/pipe/llvm/llvmtgsi.cpp b/src/mesa/pipe/llvm/llvmtgsi.cpp index d40a7cc380a..69d54bf9af2 100644 --- a/src/mesa/pipe/llvm/llvmtgsi.cpp +++ b/src/mesa/pipe/llvm/llvmtgsi.cpp @@ -162,10 +162,26 @@ translate_instruction(llvm::Module *module, src->SrcRegisterExtSwz.ExtSwizzleY != TGSI_EXTSWIZZLE_Y || src->SrcRegisterExtSwz.ExtSwizzleZ != TGSI_EXTSWIZZLE_Z || src->SrcRegisterExtSwz.ExtSwizzleW != TGSI_EXTSWIZZLE_W) { - int swizzle = src->SrcRegisterExtSwz.ExtSwizzleX * 1000; - swizzle += src->SrcRegisterExtSwz.ExtSwizzleY * 100; - swizzle += src->SrcRegisterExtSwz.ExtSwizzleZ * 10; - swizzle += src->SrcRegisterExtSwz.ExtSwizzleW * 1; + int swizzle = 0; + + if (src->SrcRegisterExtSwz.ExtSwizzleX != TGSI_EXTSWIZZLE_X) + swizzle = src->SrcRegisterExtSwz.ExtSwizzleX * 1000; + else + swizzle = src->SrcRegister.SwizzleX * 1000; + if (src->SrcRegisterExtSwz.ExtSwizzleY != TGSI_EXTSWIZZLE_Y) + swizzle += src->SrcRegisterExtSwz.ExtSwizzleY * 100; + else + swizzle += src->SrcRegister.SwizzleY * 100; + if (src->SrcRegisterExtSwz.ExtSwizzleZ != TGSI_EXTSWIZZLE_Z) + swizzle += src->SrcRegisterExtSwz.ExtSwizzleZ * 10; + else + swizzle += src->SrcRegister.SwizzleZ * 10; + if (src->SrcRegisterExtSwz.ExtSwizzleW != TGSI_EXTSWIZZLE_W) + swizzle += src->SrcRegisterExtSwz.ExtSwizzleW * 1; + else + swizzle += src->SrcRegister.SwizzleW * 1; + /*fprintf(stderr, "EXT XXXXXXXX swizzle x = %d\n", swizzle);*/ + val = storage->shuffleVector(val, swizzle); } } else if (src->SrcRegister.SwizzleX != TGSI_SWIZZLE_X || @@ -176,13 +192,16 @@ translate_instruction(llvm::Module *module, swizzle += src->SrcRegister.SwizzleY * 100; swizzle += src->SrcRegister.SwizzleZ * 10; swizzle += src->SrcRegister.SwizzleW * 1; + /*fprintf(stderr, "XXXXXXXX swizzle = %d\n", swizzle);*/ val = storage->shuffleVector(val, swizzle); } inputs[i] = val; } /*if (inputs[0]) - instr->printVector(inputs[0]);*/ + instr->printVector(inputs[0]); + if (inputs[1]) + instr->printVector(inputs[1]);*/ llvm::Value *out = 0; switch (inst->Instruction.Opcode) { case TGSI_OPCODE_ARL: diff --git a/src/mesa/pipe/llvm/storage.cpp b/src/mesa/pipe/llvm/storage.cpp index 0fe973b78e8..3bf37c75673 100644 --- a/src/mesa/pipe/llvm/storage.cpp +++ b/src/mesa/pipe/llvm/storage.cpp @@ -25,6 +25,7 @@ Storage::Storage(llvm::BasicBlock *block, llvm::Value *out, m_undefFloatVec = UndefValue::get(m_floatVecType); m_undefIntVec = UndefValue::get(m_intVecType); + m_extSwizzleVec = 0; m_numConsts = 0; } @@ -32,6 +33,27 @@ Storage::Storage(llvm::BasicBlock *block, llvm::Value *out, //can only build vectors with all members in the [0, 9] range llvm::Constant *Storage::shuffleMask(int vec) { + if (!m_extSwizzleVec) { + Constant *const_vec = Constant::getNullValue(m_floatVecType); + InsertElementInst *res = new InsertElementInst(const_vec, + ConstantFP::get(Type::FloatTy, APFloat(0.f)), + unsigned(0), + name("extswx"), m_block); + res = new InsertElementInst(res, ConstantFP::get(Type::FloatTy, APFloat(1.f)), + unsigned(1), + name("extswy"), + m_block); + res = new InsertElementInst(res, ConstantFP::get(Type::FloatTy, APFloat(0.f)), + unsigned(2), + name("extswz"), + m_block); + res = new InsertElementInst(res, ConstantFP::get(Type::FloatTy, APFloat(1.f)), + unsigned(3), + name("extsww"), + m_block); + m_extSwizzleVec = res; + } + if (m_intVecs.find(vec) != m_intVecs.end()) { return m_intVecs[vec]; } @@ -79,6 +101,7 @@ llvm::Value *Storage::inputElement(int idx) false, m_block); load->setAlignment(8); m_inputs[idx] = load; + return load; } @@ -103,7 +126,7 @@ llvm::Value *Storage::shuffleVector(llvm::Value *vec, int shuffle) { Constant *mask = shuffleMask(shuffle); ShuffleVectorInst *res = - new ShuffleVectorInst(vec, m_undefFloatVec, mask, + new ShuffleVectorInst(vec, m_extSwizzleVec, mask, name("shuffle"), m_block); return res; } diff --git a/src/mesa/pipe/llvm/storage.h b/src/mesa/pipe/llvm/storage.h index 66a33633325..da7b0dbe014 100644 --- a/src/mesa/pipe/llvm/storage.h +++ b/src/mesa/pipe/llvm/storage.h @@ -57,6 +57,8 @@ private: llvm::Value *m_undefFloatVec; llvm::Value *m_undefIntVec; + llvm::Value *m_extSwizzleVec; + char m_name[32]; int m_idx; |