summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTom Stellard <thomas.stellard@amd.com>2012-01-04 14:13:34 -0500
committerTom Stellard <thomas.stellard@amd.com>2012-01-05 13:16:59 -0500
commitf32066b55c06904b868abb00589ac892e6ef68b6 (patch)
tree2abbb658210e204842c5c4667dfb7ae3494e4153
parentb5c96e408d401841f46d6ea9f8cf908cecc76dff (diff)
tgsi_llvm: LIT
-rw-r--r--src/gallium/auxiliary/tgsi/tgsi_llvm.c65
1 files changed, 38 insertions, 27 deletions
diff --git a/src/gallium/auxiliary/tgsi/tgsi_llvm.c b/src/gallium/auxiliary/tgsi/tgsi_llvm.c
index 53f528039e4..9fd617f0a7a 100644
--- a/src/gallium/auxiliary/tgsi/tgsi_llvm.c
+++ b/src/gallium/auxiliary/tgsi/tgsi_llvm.c
@@ -847,47 +847,58 @@ emit_instruction(
break;
case TGSI_OPCODE_LIT:
- {
- LLVMValueRef args[3];
- LLVMTypeRef ret_type = base->elem_type;
- LLVMBuilderRef builder = base->gallivm->builder;
- LLVMValueRef one, zero, src_x, src_y, src_w, dst_y, dst_z;
+ emit_data.dst_type = base->elem_type;
+ if (!action->fetch_args) {
+ /* src0.x */
+ emit_data.args[0] = lp_emit_fetch_soa(&ctx->bld_ctx.soa, inst,
+ 0, CHAN_X);
+ /* src0.y */
+ emit_data.args[1] = lp_emit_fetch_soa(&ctx->bld_ctx.soa, inst,
+ 0, CHAN_Y);
+ /* src0.w */
+ emit_data.args[2] = lp_emit_fetch_soa(&ctx->bld_ctx.soa, inst,
+ 0, CHAN_W);
+ } else {
+ action->fetch_args(ctx, &emit_data);
+ }
+
+ if (!action->emit) {
+ struct tgsi_llvm_opcode_action * max_action =
+ &ctx->op_actions[TGSI_OPCODE_MAX];
+ struct tgsi_llvm_emit_data max_emit_data;
+
+ assert(max_action->emit);
assert(!ctx->aos);
- src_x = lp_emit_fetch_soa(&ctx->bld_ctx.soa, inst, 0, 0);
- src_y = lp_emit_fetch_soa(&ctx->bld_ctx.soa, inst, 0, 1);
- src_w = lp_emit_fetch_soa(&ctx->bld_ctx.soa, inst, 0, 3);
- zero = base->zero;
- one = base->one;
+
+ memset(&max_emit_data, 0, sizeof(max_emit_data));
+ max_emit_data.dst_type = base->elem_type;
+ max_emit_data.arg_count = 2;
if (inst->Dst[0].Register.WriteMask & TGSI_WRITEMASK_X) {
- bld_base->emit_store(bld_base, inst, 0, 0, NULL,
- one);
+ values[CHAN_X] = base->one;
}
if (inst->Dst[0].Register.WriteMask & TGSI_WRITEMASK_Y) {
- dst_y = lp_build_intrinsic_binary(builder,
- ctx->op_actions[TGSI_OPCODE_MAX].intr_name,
- ret_type, src_x, zero);
- bld_base->emit_store(bld_base, inst, 0, 1, NULL,
- dst_y);
+ max_emit_data.args[0] = emit_data.args[0] /* src0.x */;
+ max_emit_data.args[1] = base->zero;
+ values[CHAN_Y] = max_action->emit(max_action, ctx, &max_emit_data);
}
if (inst->Dst[0].Register.WriteMask & TGSI_WRITEMASK_Z) {
- args[0] = src_x;
- args[1] = src_y;
- args[2] = src_w;
- dst_z = lp_build_intrinsic(builder, "llvm.TGSI.lit.z", ret_type,
- args, 3);
- bld_base->emit_store(bld_base, inst, 0, 2, NULL,
- dst_z);
+ /* XXX: The default implementation should not use the
+ * llvm.TGSI.lit.z intrinsic. */
+ values[CHAN_Z] = lp_build_intrinsic(builder, "llvm.TGSI.lit.z",
+ emit_data.dst_type, emit_data.args, 3);
}
if (inst->Dst[0].Register.WriteMask & TGSI_WRITEMASK_W) {
- bld_base->emit_store(bld_base, inst, 0, 3, NULL,
- one);
+ values[CHAN_W] = base->one;
}
- break;
+ } else {
+ tgsi_llvm_emit_soa(ctx, inst, action, &emit_data, values);
}
+ store_values(bld_base, inst, values);
+ break;
case TGSI_OPCODE_DDX:
case TGSI_OPCODE_DDY: