static void vs_lower_opcode_tgsi_in(struct vs_compile_context *vcc, struct toy_dst dst, int dim, int idx) { struct toy_compiler *tc = &vcc->tc; int slot; assert(!dim); slot = toy_tgsi_find_input(&vcc->tgsi, idx); if (slot >= 0) { const int first_in_grf = vcc->first_vue_grf + (vcc->shader->in.count - vcc->tgsi.num_inputs); const int grf = first_in_grf + vcc->tgsi.inputs[slot].semantic_index; const struct toy_src src = tsrc(TOY_FILE_GRF, grf, 0); tc_MOV(tc, dst, src); } else { /* undeclared input */ tc_MOV(tc, dst, tsrc_imm_f(0.0f)); } }
static void fs_lower_opcode_tgsi_in(struct fs_compile_context *fcc, struct toy_dst dst, int dim, int idx) { int slot; assert(!dim); slot = toy_tgsi_find_input(&fcc->tgsi, idx); if (slot < 0) return; switch (fcc->tgsi.inputs[slot].semantic_name) { case TGSI_SEMANTIC_POSITION: fetch_position(fcc, dst); break; case TGSI_SEMANTIC_FACE: fetch_face(fcc, dst); break; default: fetch_attr(fcc, dst, slot); break; } }
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); } }