summaryrefslogtreecommitdiff
path: root/src/gallium/auxiliary/gallivm/storagesoa.cpp
diff options
context:
space:
mode:
authorStephane Marchesin <marchesin@icps.u-strasbg.fr>2008-10-07 21:11:01 +0200
committerStephane Marchesin <marchesin@icps.u-strasbg.fr>2008-10-07 21:11:01 +0200
commit94ba48bd85ec5c62e1a303d8bb3fc25c8e153247 (patch)
tree5c46163fb530fb6d87ef13f6e66f3d2d7c4e202c /src/gallium/auxiliary/gallivm/storagesoa.cpp
parent8e8208d6db8b764568539784a6473d545dec2265 (diff)
Gallivm: fix the constant layout, this gets a bunch of progs/ working. Notably, gears doesn't.
Diffstat (limited to 'src/gallium/auxiliary/gallivm/storagesoa.cpp')
-rw-r--r--src/gallium/auxiliary/gallivm/storagesoa.cpp71
1 files changed, 60 insertions, 11 deletions
diff --git a/src/gallium/auxiliary/gallivm/storagesoa.cpp b/src/gallium/auxiliary/gallivm/storagesoa.cpp
index 78d754371f..646b9d7ca0 100644
--- a/src/gallium/auxiliary/gallivm/storagesoa.cpp
+++ b/src/gallium/auxiliary/gallivm/storagesoa.cpp
@@ -91,19 +91,29 @@ void StorageSoa::declareImmediates()
for (unsigned int i = 0; i < m_immediatesToFlush.size(); ++i) {
std::vector<float> vec = m_immediatesToFlush[i];
std::vector<float> vals(4);
+ float val;
std::vector<Constant*> channelArray;
- vals[0] = vec[0]; vals[1] = vec[0]; vals[2] = vec[0]; vals[3] = vec[0];
- llvm::Constant *xChannel = createConstGlobalVector(vals);
+ val = vec[0];
+ llvm::Constant *xChannel = createConstGlobalFloat(val);
+ val = vec[1];
+ llvm::Constant *yChannel = createConstGlobalFloat(val);
+ val = vec[2];
+ llvm::Constant *zChannel = createConstGlobalFloat(val);
+ val = vec[3];
+ llvm::Constant *wChannel = createConstGlobalFloat(val);
- vals[0] = vec[1]; vals[1] = vec[1]; vals[2] = vec[1]; vals[3] = vec[1];
+// vals[0] = vec[0]; vals[1] = vec[1]; vals[2] = vec[2]; vals[3] = vec[3];
+// llvm::Constant *xChannel = createConstGlobalVector(vec[0]);
+
+/* vals[0] = vec[1]; vals[1] = vec[1]; vals[2] = vec[1]; vals[3] = vec[1];
llvm::Constant *yChannel = createConstGlobalVector(vals);
vals[0] = vec[2]; vals[1] = vec[2]; vals[2] = vec[2]; vals[3] = vec[2];
llvm::Constant *zChannel = createConstGlobalVector(vals);
vals[0] = vec[3]; vals[1] = vec[3]; vals[2] = vec[3]; vals[3] = vec[3];
- llvm::Constant *wChannel = createConstGlobalVector(vals);
+ llvm::Constant *wChannel = createConstGlobalVector(vals);*/
channelArray.push_back(xChannel);
channelArray.push_back(yChannel);
channelArray.push_back(zChannel);
@@ -144,22 +154,54 @@ std::vector<llvm::Value*> StorageSoa::inputElement(llvm::Value *idx)
return res;
}
-std::vector<llvm::Value*> StorageSoa::constElement(llvm::Value *idx)
+llvm::Value* StorageSoa::unpackConstElement(llvm::IRBuilder<>* m_builder, llvm::Value* vector, int cc)
+{
+ std::vector<llvm::Value*> x(4);
+ x[0] = m_builder->CreateExtractElement(vector,
+ constantInt(cc),
+ name("x"));
+
+ VectorType *vectorType = VectorType::get(Type::FloatTy, 4);
+ Constant *constVector = Constant::getNullValue(vectorType);
+ Value *res = m_builder->CreateInsertElement(constVector, x[0],
+ constantInt(0),
+ name("vecx"));
+ res = m_builder->CreateInsertElement(res, x[0], constantInt(1),
+ name("vecxx"));
+ res = m_builder->CreateInsertElement(res, x[0], constantInt(2),
+ name("vecxxx"));
+ res = m_builder->CreateInsertElement(res, x[0], constantInt(3),
+ name("vecxxxx"));
+ return res;
+}
+
+std::vector<llvm::Value*> StorageSoa::constElement(llvm::IRBuilder<>* m_builder, llvm::Value *idx)
{
std::vector<llvm::Value*> res(4);
+ std::vector<llvm::Value*> res2(4);
llvm::Value *xChannel, *yChannel, *zChannel, *wChannel;
xChannel = elementPointer(m_consts, idx, 0);
- yChannel = elementPointer(m_consts, idx, 1);
+/* yChannel = elementPointer(m_consts, idx, 1);
zChannel = elementPointer(m_consts, idx, 2);
- wChannel = elementPointer(m_consts, idx, 3);
+ wChannel = elementPointer(m_consts, idx, 3);*/
res[0] = alignedArrayLoad(xChannel);
+/* res[1] = alignedArrayLoad(xChannel);
+ res[2] = alignedArrayLoad(xChannel);
+ res[3] = alignedArrayLoad(xChannel);*/
+
+
+ res2[0]=unpackConstElement(m_builder, res[0],0);
+ res2[1]=unpackConstElement(m_builder, res[0],1);
+ res2[2]=unpackConstElement(m_builder, res[0],2);
+ res2[3]=unpackConstElement(m_builder, res[0],3);
+/*res[0] = alignedArrayLoad(xChannel);
res[1] = alignedArrayLoad(yChannel);
res[2] = alignedArrayLoad(zChannel);
- res[3] = alignedArrayLoad(wChannel);
+ res[3] = alignedArrayLoad(wChannel);*/
- return res;
+ return res2;
}
std::vector<llvm::Value*> StorageSoa::outputElement(llvm::Value *idx)
@@ -260,6 +302,12 @@ llvm::Module * StorageSoa::currentModule() const
return m_block->getParent()->getParent();
}
+llvm::Constant * StorageSoa::createConstGlobalFloat(const float val)
+{
+ Constant*c = ConstantFP::get(APFloat(val));
+ return c;
+}
+
llvm::Constant * StorageSoa::createConstGlobalVector(const std::vector<float> &vec)
{
VectorType *vectorType = VectorType::get(Type::FloatTy, 4);
@@ -278,7 +326,7 @@ llvm::Constant * StorageSoa::createConstGlobalVector(const std::vector<float> &v
}
std::vector<llvm::Value*> StorageSoa::load(enum tgsi_file_type type, int idx, int swizzle,
- llvm::Value *indIdx)
+ llvm::IRBuilder<>* m_builder,llvm::Value *indIdx)
{
std::vector<llvm::Value*> val(4);
@@ -302,7 +350,8 @@ std::vector<llvm::Value*> StorageSoa::load(enum tgsi_file_type type, int idx, in
val = tempElement(realIndex);
break;
case TGSI_FILE_CONSTANT:
- val = constElement(realIndex);
+ val = constElement(m_builder, realIndex);
+ printf("constant COUCOU index %d\n",realIndex);
break;
case TGSI_FILE_IMMEDIATE:
val = immediateElement(realIndex);