summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVincent Lejeune <vljn@ovi.com>2013-01-18 20:59:54 +0100
committerVincent Lejeune <vljn@ovi.com>2013-01-18 20:59:54 +0100
commit122a8a42935d2d73573cbec590f79dc3b6c50615 (patch)
tree0563d258d8f2a465accf3867da42fa051646feab
parent8bd0116d8cfba246e03f3dcb4ab3a5f0fc97adab (diff)
final fixes for tfbglsl-to-llvm-wip
-rw-r--r--src/mesa/state_tracker/st_glsl_to_llvm_helper.h20
-rw-r--r--src/mesa/state_tracker/st_glsl_to_llvm_visitor.cpp19
2 files changed, 25 insertions, 14 deletions
diff --git a/src/mesa/state_tracker/st_glsl_to_llvm_helper.h b/src/mesa/state_tracker/st_glsl_to_llvm_helper.h
index bcd7b99b48..6046a948d8 100644
--- a/src/mesa/state_tracker/st_glsl_to_llvm_helper.h
+++ b/src/mesa/state_tracker/st_glsl_to_llvm_helper.h
@@ -170,11 +170,20 @@ static void apply(IRBuilder<> &builder, Value *v1, Value *v2) {
}
};
+template<typename T>
+class store_scalar<intrinsic_one_argument<T> > {
+public:
+static void apply(IRBuilder<> &builder, Value *v, Value *) {
+ intrinsic_one_argument<T>(builder).apply(v);
+}
+};
+
template<typename store_intrinsic>
class store_output {
protected:
IRBuilder<> &builder;
std::vector<TFBOutput> TFBInfo;
+ unsigned TFBRegisterOffset;
void save_scalar(Value * val, unsigned loc, bool clamp) {
Value * idx = Int32Type::getConstant(builder.getContext(), loc);
@@ -187,11 +196,12 @@ protected:
if (clamp)
val = int_clamp(builder).apply(val, FloatType::getConstant(builder.getContext(), 0.0f), FloatType::getConstant(builder.getContext(), 1.0f));
store_scalar<store_intrinsic>::apply(builder, val, idx);
+ unsigned TFBloc = 4 * TFBRegisterOffset + loc;
for (unsigned i = 0; i < TFBInfo.size(); i++) {
struct TFBOutput &Output = TFBInfo[i];
- if (loc >= Output.Register * 4 + Output.ComponentOffset &&
- loc < Output.Register * 4 + Output.ComponentOffset + Output.NumComponents) {
- unsigned DeltaDstOffset = (loc % 4) - Output.ComponentOffset;
+ if (TFBloc >= Output.Register * 4 + Output.ComponentOffset &&
+ TFBloc < Output.Register * 4 + Output.ComponentOffset + Output.NumComponents) {
+ unsigned DeltaDstOffset = (TFBloc % 4) - Output.ComponentOffset;
Value *OutOffset = Int32Type::getConstant(builder.getContext(), 4 * Output.DstOffset + DeltaDstOffset);
Value *Buffer = Int32Type::getConstant(builder.getContext(), Output.Buffer);
int_stream_output(builder).apply(val, OutOffset, Buffer);
@@ -199,8 +209,8 @@ protected:
}
}
public:
- store_output(IRBuilder<> &b, std::vector<TFBOutput> info = std::vector<TFBOutput>())
- : builder(b), TFBInfo(info) {
+ store_output(IRBuilder<> &b, std::vector<TFBOutput> info = std::vector<TFBOutput>(), unsigned RO = 0)
+ : builder(b), TFBInfo(info), TFBRegisterOffset(RO) {
}
void apply(const glsl_type *const type, Value * ValToStore, unsigned loc = 0, bool clamp= false) {
diff --git a/src/mesa/state_tracker/st_glsl_to_llvm_visitor.cpp b/src/mesa/state_tracker/st_glsl_to_llvm_visitor.cpp
index d78eed3432..db8bf80462 100644
--- a/src/mesa/state_tracker/st_glsl_to_llvm_visitor.cpp
+++ b/src/mesa/state_tracker/st_glsl_to_llvm_visitor.cpp
@@ -1014,33 +1014,34 @@ glsl_to_llvm_visitor::visit_leave(ir_function *function)
((is_vertex_shader && is_clampable_vertex(ir->location)) ||
(is_fragment_shader && is_clampable_fragment(ir->location))) ;*/
if (is_vertex_shader) {
+ unsigned mapped_location = result_to_output[ir->location + ir->index];
switch (ir->location) {
case VERT_RESULT_HPOS:
- store_output<int_store_vertex_pos>(builder).apply(ir->type, Val);
+ store_output<int_store_vertex_pos>(builder, TFBOutputs, mapped_location).apply(ir->type, Val);
break;
case VERT_RESULT_COL0:
- store_output<int_store_vertex_col0>(builder).apply(ir->type, Val, 0, clamp);
+ store_output<int_store_vertex_col0>(builder, TFBOutputs, mapped_location).apply(ir->type, Val, 0, clamp);
break;
case VERT_RESULT_COL1:
- store_output<int_store_vertex_col1>(builder).apply(ir->type, Val, 0, clamp);
+ store_output<int_store_vertex_col1>(builder, TFBOutputs, mapped_location).apply(ir->type, Val, 0, clamp);
break;
case VERT_RESULT_BFC0:
- store_output<int_store_vertex_bcol0>(builder).apply(ir->type, Val, 0, clamp);
+ store_output<int_store_vertex_bcol0>(builder, TFBOutputs, mapped_location).apply(ir->type, Val, 0, clamp);
break;
case VERT_RESULT_BFC1:
- store_output<int_store_vertex_bcol1>(builder).apply(ir->type, Val, 0, clamp);
+ store_output<int_store_vertex_bcol1>(builder, TFBOutputs, mapped_location).apply(ir->type, Val, 0, clamp);
break;
case VERT_RESULT_PSIZ:
- int_store_vertex_psize(builder).apply(Val);
+ store_output<int_store_vertex_psize>(builder, TFBOutputs, mapped_location).apply(ir->type, Val);
break;
case VERT_RESULT_CLIP_VERTEX:
- store_output<int_store_vertex_clipvertex>(builder).apply(ir->type, Val);
+ store_output<int_store_vertex_clipvertex>(builder, TFBOutputs, mapped_location).apply(ir->type, Val);
break;
case VERT_RESULT_CLIP_DIST0:
- store_output<int_store_vertex_clipdistance>(builder).apply(ir->type, Val);
+ store_output<int_store_vertex_clipdistance>(builder, TFBOutputs, mapped_location).apply(ir->type, Val);
break;
default:
- store_output<int_store_output>(builder, TFBOutputs).apply(ir->type, Val, result_to_output[ir->location + ir->index]);
+ store_output<int_store_output>(builder, TFBOutputs).apply(ir->type, Val, mapped_location);
}
} else if (is_fragment_shader) {
LoadInst *LI = builder.CreateLoad(ptr);