static void fs_lower_opcode_kil(struct toy_compiler *tc, struct toy_inst *inst) { struct toy_dst pixel_mask_dst; struct toy_src f0, pixel_mask; struct toy_inst *tmp; /* lower half of r1.7:ud */ pixel_mask_dst = tdst_uw(tdst(TOY_FILE_GRF, 1, 7 * 4)); pixel_mask = tsrc_rect(tsrc_from(pixel_mask_dst), TOY_RECT_010); f0 = tsrc_rect(tsrc_uw(tsrc(TOY_FILE_ARF, BRW_ARF_FLAG, 0)), TOY_RECT_010); /* KILP or KIL */ if (tsrc_is_null(inst->src[0])) { struct toy_src dummy = tsrc_uw(tsrc(TOY_FILE_GRF, 0, 0)); struct toy_dst f0_dst = tdst_uw(tdst(TOY_FILE_ARF, BRW_ARF_FLAG, 0)); /* create a mask that masks out all pixels */ tmp = tc_MOV(tc, f0_dst, tsrc_rect(tsrc_imm_uw(0xffff), TOY_RECT_010)); tmp->exec_size = BRW_EXECUTE_1; tmp->mask_ctrl = BRW_MASK_DISABLE; tc_CMP(tc, tdst_null(), dummy, dummy, BRW_CONDITIONAL_NEQ); /* swapping the two src operands breaks glBitmap()!? */ tmp = tc_AND(tc, pixel_mask_dst, f0, pixel_mask); tmp->exec_size = BRW_EXECUTE_1; tmp->mask_ctrl = BRW_MASK_DISABLE; } else { struct toy_src src[4]; int i; tsrc_transpose(inst->src[0], src); /* mask out killed pixels */ for (i = 0; i < 4; i++) { tc_CMP(tc, tdst_null(), src[i], tsrc_imm_f(0.0f), BRW_CONDITIONAL_GE); /* swapping the two src operands breaks glBitmap()!? */ tmp = tc_AND(tc, pixel_mask_dst, f0, pixel_mask); tmp->exec_size = BRW_EXECUTE_1; tmp->mask_ctrl = BRW_MASK_DISABLE; } } tc_discard_inst(tc, inst); }
static void fetch_face(struct fs_compile_context *fcc, struct toy_dst dst) { struct toy_compiler *tc = &fcc->tc; const struct toy_src r0 = tsrc_d(tsrc(TOY_FILE_GRF, 0, 0)); struct toy_dst tmp_f, tmp; struct toy_dst real_dst[4]; tdst_transpose(dst, real_dst); tmp_f = tc_alloc_tmp(tc); tmp = tdst_d(tmp_f); tc_SHR(tc, tmp, tsrc_rect(r0, TOY_RECT_010), tsrc_imm_d(15)); tc_AND(tc, tmp, tsrc_from(tmp), tsrc_imm_d(1)); tc_MOV(tc, tmp_f, tsrc_from(tmp)); /* convert to 1.0 and -1.0 */ tc_MUL(tc, tmp_f, tsrc_from(tmp_f), tsrc_imm_f(-2.0f)); tc_ADD(tc, real_dst[0], tsrc_from(tmp_f), tsrc_imm_f(1.0f)); tc_MOV(tc, real_dst[1], tsrc_imm_f(0.0f)); tc_MOV(tc, real_dst[2], tsrc_imm_f(0.0f)); tc_MOV(tc, real_dst[3], tsrc_imm_f(1.0f)); }
static void gs_lower_opcode_tgsi_in(struct gs_compile_context *gcc, struct toy_dst dst, int dim, int idx) { struct toy_compiler *tc = &gcc->tc; struct toy_src attr; int slot, reg = -1, subreg; slot = toy_tgsi_find_input(&gcc->tgsi, idx); if (slot >= 0) { int i; for (i = 0; i < gcc->variant->u.gs.num_inputs; i++) { if (gcc->variant->u.gs.semantic_names[i] == gcc->tgsi.inputs[slot].semantic_name && gcc->variant->u.gs.semantic_indices[i] == gcc->tgsi.inputs[slot].semantic_index) { reg = i / 2; subreg = (i % 2) * 4; break; } } } if (reg < 0) { tc_MOV(tc, dst, tsrc_imm_f(0.0f)); return; } /* fix vertex ordering for GEN6_3DPRIM_TRISTRIP_REVERSE */ if (gcc->in_vue_count == 3 && dim < 2) { struct toy_inst *inst; /* get PrimType */ inst = tc_AND(tc, tdst_d(gcc->vars.tmp), tsrc_offset(gcc->payload.header, 0, 2), tsrc_imm_d(0x1f)); inst->exec_size = GEN6_EXECSIZE_1; inst->src[0] = tsrc_rect(inst->src[0], TOY_RECT_010); inst->src[1] = tsrc_rect(inst->src[1], TOY_RECT_010); inst = tc_CMP(tc, tdst_null(), tsrc_from(tdst_d(gcc->vars.tmp)), tsrc_imm_d(GEN6_3DPRIM_TRISTRIP_REVERSE), GEN6_COND_NZ); inst->src[0] = tsrc_rect(inst->src[0], TOY_RECT_010); attr = tsrc_offset(gcc->payload.vues[dim], reg, subreg); inst = tc_MOV(tc, dst, attr); inst->pred_ctrl = GEN6_PREDCTRL_NORMAL; /* swap IN[0] and IN[1] for GEN6_3DPRIM_TRISTRIP_REVERSE */ dim = !dim; attr = tsrc_offset(gcc->payload.vues[dim], reg, subreg); inst = tc_MOV(tc, dst, attr); inst->pred_ctrl = GEN6_PREDCTRL_NORMAL; inst->pred_inv = true; } else { attr = tsrc_offset(gcc->payload.vues[dim], reg, subreg); tc_MOV(tc, dst, attr); } }