r600g: atomize stencil ref state
[mesa.git] / src / gallium / drivers / r600 / r600_shader.c
index dfaff832e764f7cec7f288b103b0602550aa934f..3e797645ed9ad53c691af82e41f1c614c16df6e9 100644 (file)
@@ -293,6 +293,7 @@ static unsigned r600_alu_from_byte_stream(struct r600_shader_ctx *ctx,
 {
        unsigned src_idx;
        unsigned inst0, inst1;
+       unsigned push_modifier;
        struct r600_bytecode_alu alu;
        memset(&alu, 0, sizeof(alu));
        for(src_idx = 0; src_idx < 3; src_idx++) {
@@ -310,12 +311,32 @@ static unsigned r600_alu_from_byte_stream(struct r600_shader_ctx *ctx,
        alu.inst = inst0 | (inst1 << 8);
        alu.last = bytes[bytes_read++];
        alu.is_op3 = bytes[bytes_read++];
+       push_modifier = bytes[bytes_read++];
        alu.pred_sel = bytes[bytes_read++];
        alu.bank_swizzle = bytes[bytes_read++];
        alu.bank_swizzle_force = bytes[bytes_read++];
        alu.omod = bytes[bytes_read++];
        alu.index_mode = bytes[bytes_read++];
-       r600_bytecode_add_alu(ctx->bc, &alu);
+
+
+       if (alu.inst == CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_PRED_SETNE) ||
+           alu.inst == CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_PRED_SETE) ||
+           alu.inst == CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_PRED_SETE_INT) ||
+           alu.inst == CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_PRED_SETNE_INT)) {
+               alu.update_pred = 1;
+               alu.dst.write = 0;
+               alu.src[1].sel = V_SQ_ALU_SRC_0;
+               alu.src[1].chan = 0;
+               alu.last = 1;
+    }
+
+    if (push_modifier) {
+        alu.pred_sel = 0;
+               alu.execute_mask = 1;
+               r600_bytecode_add_alu_type(ctx->bc, &alu, CTX_INST(V_SQ_CF_ALU_WORD1_SQ_CF_INST_ALU_PUSH_BEFORE));
+       } else
+               r600_bytecode_add_alu(ctx->bc, &alu);
+
 
        /* XXX: Handle other KILL instructions */
        if (alu.inst == CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_KILLGT)) {
@@ -329,16 +350,6 @@ static unsigned r600_alu_from_byte_stream(struct r600_shader_ctx *ctx,
 static void llvm_if(struct r600_shader_ctx *ctx, struct r600_bytecode_alu * alu,
        unsigned pred_inst)
 {
-       alu->inst = pred_inst; 
-       alu->execute_mask = 1;
-       alu->update_pred = 1;
-       alu->dst.write = 0;
-       alu->src[1].sel = V_SQ_ALU_SRC_0;
-       alu->src[1].chan = 0;
-       alu->last = 1;
-       r600_bytecode_add_alu_type(ctx->bc, alu,
-               CTX_INST(V_SQ_CF_ALU_WORD1_SQ_CF_INST_ALU_PUSH_BEFORE));
-
        r600_bytecode_add_cfinst(ctx->bc, CTX_INST(V_SQ_CF_WORD1_SQ_CF_INST_JUMP));
        fc_pushlevel(ctx, FC_IF);
        callstack_check_depth(ctx, FC_PUSH_VPM, 0);
@@ -4970,7 +4981,7 @@ static void fc_set_mid(struct r600_shader_ctx *ctx, int fc_sp)
 {
        struct r600_cf_stack_entry *sp = &ctx->bc->fc_stack[fc_sp];
 
-       sp->mid = (struct r600_bytecode_cf **)realloc((void *)sp->mid,
+       sp->mid = realloc((void *)sp->mid,
                                                sizeof(struct r600_bytecode_cf *) * (sp->num_mid + 1));
        sp->mid[sp->num_mid] = ctx->bc->cf_last;
        sp->num_mid++;
@@ -4986,10 +4997,8 @@ static void fc_pushlevel(struct r600_shader_ctx *ctx, int type)
 static void fc_poplevel(struct r600_shader_ctx *ctx)
 {
        struct r600_cf_stack_entry *sp = &ctx->bc->fc_stack[ctx->bc->fc_sp];
-       if (sp->mid) {
-               free(sp->mid);
-               sp->mid = NULL;
-       }
+       free(sp->mid);
+       sp->mid = NULL;
        sp->num_mid = 0;
        sp->start = NULL;
        sp->type = 0;
@@ -5345,7 +5354,7 @@ static struct r600_shader_tgsi_instruction r600_shader_tgsi_instruction[] = {
        {TGSI_OPCODE_ISGE,      0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_SETGE_INT, tgsi_op2},
        {TGSI_OPCODE_ISHR,      0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_ASHR_INT, tgsi_op2_trans},
        {TGSI_OPCODE_ISLT,      0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_SETGT_INT, tgsi_op2_swap},
-       {TGSI_OPCODE_F2U,       0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_FLT_TO_UINT, tgsi_op2},
+       {TGSI_OPCODE_F2U,       0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_FLT_TO_UINT, tgsi_op2_trans},
        {TGSI_OPCODE_U2F,       0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_UINT_TO_FLT, tgsi_op2_trans},
        {TGSI_OPCODE_UADD,      0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_ADD_INT, tgsi_op2},
        {TGSI_OPCODE_UDIV,      0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP, tgsi_udiv},