#include "draw_llvm.h"
#include "gallivm/lp_bld_arit.h"
-#include "gallivm/lp_bld_interp.h"
#include "gallivm/lp_bld_struct.h"
-#include "gallivm/lp_bld_type.h"
-#include "gallivm/lp_bld_flow.h"
+#include "gallivm/lp_bld_format.h"
#include "gallivm/lp_bld_debug.h"
-#include "gallivm/lp_bld_tgsi.h"
-#include "gallivm/lp_bld_printf.h"
#include "util/u_memory.h"
+#include "util/u_format.h"
#include "pipe/p_state.h"
{PIPE_FORMAT_R32G32_FIXED, from_32_fixed, to_32_fixed, LL_Int32, 2},
{PIPE_FORMAT_R32G32B32_FIXED, from_32_fixed, to_32_fixed, LL_Int32, 3},
{PIPE_FORMAT_R32G32B32A32_FIXED, from_32_fixed, to_32_fixed, LL_Int32, 4},
-
- {PIPE_FORMAT_A8R8G8B8_UNORM, from_8_unorm, to_8_unorm, LL_Int8, 4},
- {PIPE_FORMAT_B8G8R8A8_UNORM, from_8_unorm, to_8_unorm, LL_Int8, 4},
};
int offset = 0;
LLVMValueRef res = LLVMConstNull(
LLVMVectorType(LLVMFloatType(), 4));
+ LLVMValueRef defaults[4];
+
+ defaults[0] = LLVMConstReal(LLVMFloatType(), 0);
+ defaults[1] = LLVMConstReal(LLVMFloatType(), 0);
+ defaults[2] = LLVMConstReal(LLVMFloatType(), 0);
+ defaults[3] = LLVMConstReal(LLVMFloatType(), 1);
for (i = 0; i < nr_components; ++i) {
LLVMValueRef src_index = LLVMConstInt(LLVMInt32Type(), offset, 0);
dst_index, "");
offset += val_size;
}
+ for (; i < 4; ++i) {
+ LLVMValueRef dst_index = LLVMConstInt(LLVMInt32Type(), i, 0);
+ res = LLVMBuildInsertElement(builder,
+ res,
+ defaults[i],
+ dst_index, "");
+ }
return res;
}
LLVMValueRef vbuffer,
enum pipe_format from_format)
{
+ const struct util_format_description *format_desc;
+ LLVMValueRef zero;
int i;
+
+ /*
+ * The above can only cope with straight arrays: no bitfields,
+ * swizzles, or half floats.
+ */
+
for (i = 0; i < Elements(translates); ++i) {
if (translates[i].format == from_format) {
/*LLVMTypeRef type = ll_type_to_llvm(translates[i].type);*/
translates[i].from);
}
}
- return LLVMGetUndef(LLVMVectorType(LLVMFloatType(), 4));
+
+
+ /*
+ * This doesn't handle anything bigger than 32bits, or half floats
+ * yet.
+ *
+ * TODO: unify all this code into lp_build_fetch_rgba_aos().
+ */
+
+ format_desc = util_format_description(from_format);
+ zero = LLVMConstNull(LLVMInt32Type());
+ return lp_build_fetch_rgba_aos(builder, format_desc, vbuffer, zero, zero);
}