aboutsummaryrefslogtreecommitdiffstats
path: root/src/mesa
diff options
context:
space:
mode:
authorZack Rusin <[email protected]>2008-02-13 22:53:00 -0500
committerZack Rusin <[email protected]>2008-02-15 01:17:16 -0500
commitd0364584bea6c57bb3ac8d616e677fb52b97ea98 (patch)
tree99d2049a79924939e63536a09cee74aa995682af /src/mesa
parent13d9e616f6ee253ecf99dbb67572c87b5dc9270f (diff)
implement swizzling on writes
Diffstat (limited to 'src/mesa')
-rw-r--r--src/mesa/pipe/llvm/storagesoa.cpp87
-rw-r--r--src/mesa/pipe/llvm/storagesoa.h14
-rw-r--r--src/mesa/pipe/llvm/tgsitollvm.cpp9
3 files changed, 56 insertions, 54 deletions
diff --git a/src/mesa/pipe/llvm/storagesoa.cpp b/src/mesa/pipe/llvm/storagesoa.cpp
index a65b5c14d9f..75e7a36bc24 100644
--- a/src/mesa/pipe/llvm/storagesoa.cpp
+++ b/src/mesa/pipe/llvm/storagesoa.cpp
@@ -30,6 +30,8 @@
#include "gallivm_p.h"
#include "pipe/p_shader_tokens.h"
+#include "pipe/p_debug.h"
+
#include <llvm/BasicBlock.h>
#include <llvm/Module.h>
#include <llvm/Value.h>
@@ -158,49 +160,6 @@ llvm::Value * StorageSoa::extractIndex(llvm::Value *vec)
return 0;
}
-void StorageSoa::storeOutput(int dstIdx, 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_output, dstIdx, 0);
- llvm::Value *yChannel = elementPointer(m_output, dstIdx, 1);
- llvm::Value *zChannel = elementPointer(m_output, dstIdx, 2);
- llvm::Value *wChannel = elementPointer(m_output, dstIdx, 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::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,
- int mask)
-{
-}
-
llvm::Value * StorageSoa::elementPointer(llvm::Value *ptr, int index,
int channel) const
{
@@ -309,6 +268,10 @@ std::vector<llvm::Value*> StorageSoa::argument(Argument type, int idx, int swizz
case Immediate:
val = immediateElement(idx);
break;
+ case Address:
+ debug_printf("Address not handled in the fetch phase!\n");
+ assert(0);
+ break;
}
if (!gallivm_is_swizzle(swizzle))
return val;
@@ -321,3 +284,41 @@ std::vector<llvm::Value*> StorageSoa::argument(Argument type, int idx, int swizz
res[3] = val[gallivm_w_swizzle(swizzle)];
return res;
}
+
+void StorageSoa::store(Argument type, int idx, const std::vector<llvm::Value*> &val,
+ int mask)
+{
+ llvm::Value *out = 0;
+ switch(type) {
+ case Output:
+ out = m_output;
+ break;
+ case Temp:
+ out = m_temps;
+ break;
+ case Input:
+ out = m_input;
+ break;
+ default:
+ debug_printf("Can't save output of this type: %d !\n", type);
+ assert(0);
+ break;
+ }
+
+ if ((mask & TGSI_WRITEMASK_X)) {
+ llvm::Value *xChannel = elementPointer(out, idx, 0);
+ new StoreInst(val[0], xChannel, false, m_block);
+ }
+ if ((mask & TGSI_WRITEMASK_Y)) {
+ llvm::Value *yChannel = elementPointer(out, idx, 1);
+ new StoreInst(val[1], yChannel, false, m_block);
+ }
+ if ((mask & TGSI_WRITEMASK_Z)) {
+ llvm::Value *zChannel = elementPointer(out, idx, 2);
+ new StoreInst(val[2], zChannel, false, m_block);
+ }
+ if ((mask & TGSI_WRITEMASK_W)) {
+ llvm::Value *wChannel = elementPointer(out, idx, 3);
+ new StoreInst(val[3], wChannel, false, m_block);
+ }
+}
diff --git a/src/mesa/pipe/llvm/storagesoa.h b/src/mesa/pipe/llvm/storagesoa.h
index 9443234c82f..8880bf5ec67 100644
--- a/src/mesa/pipe/llvm/storagesoa.h
+++ b/src/mesa/pipe/llvm/storagesoa.h
@@ -49,7 +49,8 @@ public:
Output,
Temp,
Const,
- Immediate
+ Immediate,
+ Address
};
public:
StorageSoa(llvm::BasicBlock *block,
@@ -58,20 +59,17 @@ public:
llvm::Value *consts,
llvm::Value *temps);
+
std::vector<llvm::Value*> argument(Argument type, int idx, int swizzle,
llvm::Value *indIdx =0);
+ void store(Argument type, int idx, const std::vector<llvm::Value*> &val,
+ int mask);
+
void addImmediate(float *vec);
llvm::Value * addrElement(int idx) const;
llvm::Value *extractIndex(llvm::Value *vec);
-
- void storeOutput(int dstIdx, const std::vector<llvm::Value*> &val,
- int mask);
- void storeTemp(int idx, const std::vector<llvm::Value*> &val,
- int mask);
- void storeAddress(int idx, const std::vector<llvm::Value*> &val,
- int mask);
private:
llvm::Value *elementPointer(llvm::Value *ptr, int index,
int channel) const;
diff --git a/src/mesa/pipe/llvm/tgsitollvm.cpp b/src/mesa/pipe/llvm/tgsitollvm.cpp
index 10c417996ae..287a86c60cb 100644
--- a/src/mesa/pipe/llvm/tgsitollvm.cpp
+++ b/src/mesa/pipe/llvm/tgsitollvm.cpp
@@ -1063,11 +1063,14 @@ translate_instructionir(llvm::Module *module,
struct tgsi_full_dst_register *dst = &inst->FullDstRegisters[i];
if (dst->DstRegister.File == TGSI_FILE_OUTPUT) {
- storage->storeOutput(dst->DstRegister.Index, out, dst->DstRegister.WriteMask);
+ storage->store(StorageSoa::Output,
+ dst->DstRegister.Index, out, dst->DstRegister.WriteMask);
} else if (dst->DstRegister.File == TGSI_FILE_TEMPORARY) {
- storage->storeTemp(dst->DstRegister.Index, out, dst->DstRegister.WriteMask);
+ storage->store(StorageSoa::Temp,
+ dst->DstRegister.Index, out, dst->DstRegister.WriteMask);
} else if (dst->DstRegister.File == TGSI_FILE_ADDRESS) {
- storage->storeAddress(dst->DstRegister.Index, out, dst->DstRegister.WriteMask);
+ storage->store(StorageSoa::Address,
+ dst->DstRegister.Index, out, dst->DstRegister.WriteMask);
} else {
fprintf(stderr, "ERROR: unsupported LLVM destination!");
assert(!"wrong destination");