• Home
  • Raw
  • Download

Lines Matching refs:tx

527 #define IS_VS (tx->processor == PIPE_SHADER_VERTEX)
528 #define IS_PS (tx->processor == PIPE_SHADER_FRAGMENT)
530 #define FAILURE_VOID(cond) if ((cond)) {tx->failure=1;return;}
548 nine_record_outputs(struct shader_translator *tx, BYTE Usage, BYTE UsageIndex, in nine_record_outputs() argument
551 tx->output_info[tx->num_outputs].output_semantic = Usage; in nine_record_outputs()
552 tx->output_info[tx->num_outputs].output_semantic_index = UsageIndex; in nine_record_outputs()
553 tx->output_info[tx->num_outputs].mask = mask; in nine_record_outputs()
554 tx->output_info[tx->num_outputs].output_index = output_index; in nine_record_outputs()
555 tx->num_outputs++; in nine_record_outputs()
558 static struct ureg_src nine_float_constant_src(struct shader_translator *tx, int idx) in nine_float_constant_src() argument
562 if (tx->slot_map) in nine_float_constant_src()
563 idx = tx->slot_map[idx]; in nine_float_constant_src()
569 if (tx->info->swvp_on && idx >= 4096) { in nine_float_constant_src()
578 if (!tx->info->swvp_on) in nine_float_constant_src()
579 tx->slots_used[idx] = TRUE; in nine_float_constant_src()
580 if (tx->info->const_float_slots < (idx + 1)) in nine_float_constant_src()
581 tx->info->const_float_slots = idx + 1; in nine_float_constant_src()
582 if (tx->num_slots < (idx + 1)) in nine_float_constant_src()
583 tx->num_slots = idx + 1; in nine_float_constant_src()
588 static struct ureg_src nine_integer_constant_src(struct shader_translator *tx, int idx) in nine_integer_constant_src() argument
592 if (tx->info->swvp_on) { in nine_integer_constant_src()
596 unsigned slot_idx = tx->info->const_i_base + idx; in nine_integer_constant_src()
597 if (tx->slot_map) in nine_integer_constant_src()
598 slot_idx = tx->slot_map[slot_idx]; in nine_integer_constant_src()
601 tx->slots_used[slot_idx] = TRUE; in nine_integer_constant_src()
602 tx->info->int_slots_used[idx] = TRUE; in nine_integer_constant_src()
603 if (tx->num_slots < (slot_idx + 1)) in nine_integer_constant_src()
604 tx->num_slots = slot_idx + 1; in nine_integer_constant_src()
607 if (tx->info->const_int_slots < (idx + 1)) in nine_integer_constant_src()
608 tx->info->const_int_slots = idx + 1; in nine_integer_constant_src()
613 static struct ureg_src nine_boolean_constant_src(struct shader_translator *tx, int idx) in nine_boolean_constant_src() argument
620 if (tx->info->swvp_on) { in nine_boolean_constant_src()
624 unsigned slot_idx = tx->info->const_b_base + r; in nine_boolean_constant_src()
625 if (tx->slot_map) in nine_boolean_constant_src()
626 slot_idx = tx->slot_map[slot_idx]; in nine_boolean_constant_src()
629 tx->slots_used[slot_idx] = TRUE; in nine_boolean_constant_src()
630 tx->info->bool_slots_used[idx] = TRUE; in nine_boolean_constant_src()
631 if (tx->num_slots < (slot_idx + 1)) in nine_boolean_constant_src()
632 tx->num_slots = slot_idx + 1; in nine_boolean_constant_src()
636 if (tx->info->const_bool_slots < (idx + 1)) in nine_boolean_constant_src()
637 tx->info->const_bool_slots = idx + 1; in nine_boolean_constant_src()
643 tx_lconstf(struct shader_translator *tx, struct ureg_src *src, INT index) in tx_lconstf() argument
647 if (index < 0 || index >= tx->num_constf_allowed) { in tx_lconstf()
648 tx->failure = TRUE; in tx_lconstf()
651 for (i = 0; i < tx->num_lconstf; ++i) { in tx_lconstf()
652 if (tx->lconstf[i].idx == index) { in tx_lconstf()
653 *src = tx->lconstf[i].reg; in tx_lconstf()
660 tx_lconsti(struct shader_translator *tx, struct ureg_src *src, INT index) in tx_lconsti() argument
664 if (index < 0 || index >= tx->num_consti_allowed) { in tx_lconsti()
665 tx->failure = TRUE; in tx_lconsti()
668 for (i = 0; i < tx->num_lconsti; ++i) { in tx_lconsti()
669 if (tx->lconsti[i].idx == index) { in tx_lconsti()
670 *src = tx->lconsti[i].reg; in tx_lconsti()
677 tx_lconstb(struct shader_translator *tx, struct ureg_src *src, INT index) in tx_lconstb() argument
681 if (index < 0 || index >= tx->num_constb_allowed) { in tx_lconstb()
682 tx->failure = TRUE; in tx_lconstb()
685 for (i = 0; i < tx->num_lconstb; ++i) { in tx_lconstb()
686 if (tx->lconstb[i].idx == index) { in tx_lconstb()
687 *src = tx->lconstb[i].reg; in tx_lconstb()
695 tx_set_lconstf(struct shader_translator *tx, INT index, float f[4]) in tx_set_lconstf() argument
699 FAILURE_VOID(index < 0 || index >= tx->num_constf_allowed) in tx_set_lconstf()
701 for (n = 0; n < tx->num_lconstf; ++n) in tx_set_lconstf()
702 if (tx->lconstf[n].idx == index) in tx_set_lconstf()
704 if (n == tx->num_lconstf) { in tx_set_lconstf()
706 tx->lconstf = REALLOC(tx->lconstf, in tx_set_lconstf()
707 (n + 0) * sizeof(tx->lconstf[0]), in tx_set_lconstf()
708 (n + 8) * sizeof(tx->lconstf[0])); in tx_set_lconstf()
709 assert(tx->lconstf); in tx_set_lconstf()
711 tx->num_lconstf++; in tx_set_lconstf()
713 tx->lconstf[n].idx = index; in tx_set_lconstf()
714 tx->lconstf[n].reg = ureg_imm4f(tx->ureg, f[0], f[1], f[2], f[3]); in tx_set_lconstf()
716 memcpy(tx->lconstf[n].f, f, sizeof(tx->lconstf[n].f)); in tx_set_lconstf()
719 tx_set_lconsti(struct shader_translator *tx, INT index, int i[4]) in tx_set_lconsti() argument
723 FAILURE_VOID(index < 0 || index >= tx->num_consti_allowed) in tx_set_lconsti()
725 for (n = 0; n < tx->num_lconsti; ++n) in tx_set_lconsti()
726 if (tx->lconsti[n].idx == index) in tx_set_lconsti()
728 if (n == tx->num_lconsti) { in tx_set_lconsti()
730 tx->lconsti = REALLOC(tx->lconsti, in tx_set_lconsti()
731 (n + 0) * sizeof(tx->lconsti[0]), in tx_set_lconsti()
732 (n + 8) * sizeof(tx->lconsti[0])); in tx_set_lconsti()
733 assert(tx->lconsti); in tx_set_lconsti()
735 tx->num_lconsti++; in tx_set_lconsti()
738 tx->lconsti[n].idx = index; in tx_set_lconsti()
739 tx->lconsti[n].reg = tx->native_integers ? in tx_set_lconsti()
740 ureg_imm4i(tx->ureg, i[0], i[1], i[2], i[3]) : in tx_set_lconsti()
741 ureg_imm4f(tx->ureg, i[0], i[1], i[2], i[3]); in tx_set_lconsti()
744 tx_set_lconstb(struct shader_translator *tx, INT index, BOOL b) in tx_set_lconstb() argument
748 FAILURE_VOID(index < 0 || index >= tx->num_constb_allowed) in tx_set_lconstb()
750 for (n = 0; n < tx->num_lconstb; ++n) in tx_set_lconstb()
751 if (tx->lconstb[n].idx == index) in tx_set_lconstb()
753 if (n == tx->num_lconstb) { in tx_set_lconstb()
755 tx->lconstb = REALLOC(tx->lconstb, in tx_set_lconstb()
756 (n + 0) * sizeof(tx->lconstb[0]), in tx_set_lconstb()
757 (n + 8) * sizeof(tx->lconstb[0])); in tx_set_lconstb()
758 assert(tx->lconstb); in tx_set_lconstb()
760 tx->num_lconstb++; in tx_set_lconstb()
763 tx->lconstb[n].idx = index; in tx_set_lconstb()
764 tx->lconstb[n].reg = tx->native_integers ? in tx_set_lconstb()
765 ureg_imm1u(tx->ureg, b ? 0xffffffff : 0) : in tx_set_lconstb()
766 ureg_imm1f(tx->ureg, b ? 1.0f : 0.0f); in tx_set_lconstb()
770 tx_scratch(struct shader_translator *tx) in tx_scratch() argument
772 if (tx->num_scratch >= ARRAY_SIZE(tx->regs.t)) { in tx_scratch()
773 tx->failure = TRUE; in tx_scratch()
774 return tx->regs.t[0]; in tx_scratch()
776 if (ureg_dst_is_undef(tx->regs.t[tx->num_scratch])) in tx_scratch()
777 tx->regs.t[tx->num_scratch] = ureg_DECL_local_temporary(tx->ureg); in tx_scratch()
778 return tx->regs.t[tx->num_scratch++]; in tx_scratch()
782 tx_scratch_scalar(struct shader_translator *tx) in tx_scratch_scalar() argument
784 return ureg_writemask(tx_scratch(tx), TGSI_WRITEMASK_X); in tx_scratch_scalar()
798 tx_temp_alloc(struct shader_translator *tx, INT idx) in tx_temp_alloc() argument
801 if (idx >= tx->num_temp) { in tx_temp_alloc()
802 unsigned k = tx->num_temp; in tx_temp_alloc()
804 tx->regs.r = REALLOC(tx->regs.r, in tx_temp_alloc()
805 k * sizeof(tx->regs.r[0]), in tx_temp_alloc()
806 n * sizeof(tx->regs.r[0])); in tx_temp_alloc()
808 tx->regs.r[k] = ureg_dst_undef(); in tx_temp_alloc()
809 tx->num_temp = n; in tx_temp_alloc()
811 if (ureg_dst_is_undef(tx->regs.r[idx])) in tx_temp_alloc()
812 tx->regs.r[idx] = ureg_DECL_temporary(tx->ureg); in tx_temp_alloc()
816 tx_addr_alloc(struct shader_translator *tx, INT idx) in tx_addr_alloc() argument
819 if (ureg_dst_is_undef(tx->regs.address)) in tx_addr_alloc()
820 tx->regs.address = ureg_DECL_address(tx->ureg); in tx_addr_alloc()
821 if (ureg_dst_is_undef(tx->regs.a0)) in tx_addr_alloc()
822 tx->regs.a0 = ureg_DECL_temporary(tx->ureg); in tx_addr_alloc()
834 apply_ps1x_projection(struct shader_translator *tx, struct ureg_dst dst, in apply_ps1x_projection() argument
838 unsigned dim = 1 + ((tx->info->projected >> (2 * idx)) & 3); in apply_ps1x_projection()
842 ureg_MOV(tx->ureg, dst, src); in apply_ps1x_projection()
844 tmp = tx_scratch_scalar(tx); in apply_ps1x_projection()
845 ureg_RCP(tx->ureg, tmp, ureg_scalar(src, dim-1)); in apply_ps1x_projection()
846 ureg_MUL(tx->ureg, dst, tx_src_scalar(tmp), src); in apply_ps1x_projection()
851 TEX_with_ps1x_projection(struct shader_translator *tx, struct ureg_dst dst, in TEX_with_ps1x_projection() argument
855 unsigned dim = 1 + ((tx->info->projected >> (2 * idx)) & 3); in TEX_with_ps1x_projection()
857 boolean shadow = !!(tx->info->sampler_mask_shadow & (1 << idx)); in TEX_with_ps1x_projection()
864 ureg_TEX(tx->ureg, dst, target, src0, src1); in TEX_with_ps1x_projection()
866 ureg_TXP(tx->ureg, dst, target, src0, src1); in TEX_with_ps1x_projection()
868 tmp = tx_scratch(tx); in TEX_with_ps1x_projection()
869 apply_ps1x_projection(tx, tmp, src0, idx); in TEX_with_ps1x_projection()
870 ureg_TEX(tx->ureg, dst, target, ureg_src(tmp), src1); in TEX_with_ps1x_projection()
875 tx_texcoord_alloc(struct shader_translator *tx, INT idx) in tx_texcoord_alloc() argument
878 assert(idx >= 0 && idx < ARRAY_SIZE(tx->regs.vT)); in tx_texcoord_alloc()
879 if (ureg_src_is_undef(tx->regs.vT[idx])) in tx_texcoord_alloc()
880 tx->regs.vT[idx] = ureg_DECL_fs_input(tx->ureg, tx->texcoord_sn, idx, in tx_texcoord_alloc()
885 tx_bgnloop(struct shader_translator *tx) in tx_bgnloop() argument
887 tx->loop_depth++; in tx_bgnloop()
888 if (tx->loop_depth_max < tx->loop_depth) in tx_bgnloop()
889 tx->loop_depth_max = tx->loop_depth; in tx_bgnloop()
890 assert(tx->loop_depth < NINE_MAX_LOOP_DEPTH); in tx_bgnloop()
891 return &tx->loop_labels[tx->loop_depth - 1]; in tx_bgnloop()
895 tx_endloop(struct shader_translator *tx) in tx_endloop() argument
897 assert(tx->loop_depth); in tx_endloop()
898 tx->loop_depth--; in tx_endloop()
899 ureg_fixup_label(tx->ureg, tx->loop_labels[tx->loop_depth], in tx_endloop()
900 ureg_get_instruction_number(tx->ureg)); in tx_endloop()
901 return &tx->loop_labels[tx->loop_depth]; in tx_endloop()
905 tx_get_loopctr(struct shader_translator *tx, boolean loop_or_rep) in tx_get_loopctr() argument
907 const unsigned l = tx->loop_depth - 1; in tx_get_loopctr()
909 if (!tx->loop_depth) in tx_get_loopctr()
915 if (ureg_dst_is_undef(tx->regs.rL[l])) { in tx_get_loopctr()
917 tx->regs.rL[l] = ureg_DECL_local_temporary(tx->ureg); in tx_get_loopctr()
918 tx->loop_or_rep[l] = loop_or_rep; in tx_get_loopctr()
921 assert(tx->loop_or_rep[l] == loop_or_rep); in tx_get_loopctr()
923 return tx->regs.rL[l]; in tx_get_loopctr()
927 tx_get_loopal(struct shader_translator *tx) in tx_get_loopal() argument
929 int loop_level = tx->loop_depth - 1; in tx_get_loopal()
933 if (tx->loop_or_rep[loop_level]) in tx_get_loopal()
935 return ureg_scalar(ureg_src(tx->regs.rL[loop_level]), TGSI_SWIZZLE_Y); in tx_get_loopal()
944 tx_cond(struct shader_translator *tx) in tx_cond() argument
946 assert(tx->cond_depth <= NINE_MAX_COND_DEPTH); in tx_cond()
947 tx->cond_depth++; in tx_cond()
948 return &tx->cond_labels[tx->cond_depth - 1]; in tx_cond()
952 tx_elsecond(struct shader_translator *tx) in tx_elsecond() argument
954 assert(tx->cond_depth); in tx_elsecond()
955 return &tx->cond_labels[tx->cond_depth - 1]; in tx_elsecond()
959 tx_endcond(struct shader_translator *tx) in tx_endcond() argument
961 assert(tx->cond_depth); in tx_endcond()
962 tx->cond_depth--; in tx_endcond()
963 ureg_fixup_label(tx->ureg, tx->cond_labels[tx->cond_depth], in tx_endcond()
964 ureg_get_instruction_number(tx->ureg)); in tx_endcond()
974 nine_get_position_input(struct shader_translator *tx) in nine_get_position_input() argument
976 struct ureg_program *ureg = tx->ureg; in nine_get_position_input()
978 if (tx->wpos_is_sysval) in nine_get_position_input()
986 tx_src_param(struct shader_translator *tx, const struct sm1_src_param *param) in tx_src_param() argument
988 struct ureg_program *ureg = tx->ureg; in tx_src_param()
993 (D3DSPR_ADDR && tx->version.major == 3)); in tx_src_param()
998 tx_temp_alloc(tx, param->idx); in tx_src_param()
999 src = ureg_src(tx->regs.r[param->idx]); in tx_src_param()
1007 assert(!ureg_dst_is_undef(tx->regs.a0)); in tx_src_param()
1010 if (tx->version.major < 2 && tx->version.minor < 2) in tx_src_param()
1011 ureg_ARL(ureg, tx->regs.address, ureg_src(tx->regs.a0)); in tx_src_param()
1013 ureg_ARR(ureg, tx->regs.address, ureg_src(tx->regs.a0)); in tx_src_param()
1014 src = ureg_src(tx->regs.address); in tx_src_param()
1016 if (tx->version.major < 2 && tx->version.minor < 4) { in tx_src_param()
1018 src = ureg_src(tx->regs.tS[param->idx]); in tx_src_param()
1020 tx_texcoord_alloc(tx, param->idx); in tx_src_param()
1021 src = tx->regs.vT[param->idx]; in tx_src_param()
1029 if (tx->version.major < 3) { in tx_src_param()
1033 tx->info->force_color_in_centroid ? in tx_src_param()
1048 if (ureg_src_is_undef(tx->regs.v_consecutive)) { in tx_src_param()
1050 tx->regs.v_consecutive = ureg_src(ureg_DECL_array_temporary(ureg, 10, 0)); in tx_src_param()
1052 if (!ureg_src_is_undef(tx->regs.v[i])) in tx_src_param()
1053 … ureg_MOV(ureg, ureg_dst_array_offset(ureg_dst(tx->regs.v_consecutive), i), tx->regs.v[i]); in tx_src_param()
1055 …ureg_MOV(ureg, ureg_dst_array_offset(ureg_dst(tx->regs.v_consecutive), i), ureg_imm4f(ureg, 0.0f, … in tx_src_param()
1058 src = ureg_src_array_offset(tx->regs.v_consecutive, param->idx); in tx_src_param()
1060 assert(param->idx < ARRAY_SIZE(tx->regs.v)); in tx_src_param()
1061 src = tx->regs.v[param->idx]; in tx_src_param()
1066 src = ureg_src_indirect(src, tx_src_param(tx, param->rel)); in tx_src_param()
1069 if (ureg_dst_is_undef(tx->regs.predicate)) { in tx_src_param()
1071 tx->failure = TRUE; in tx_src_param()
1072 tx->regs.predicate = ureg_DECL_temporary(tx->ureg); in tx_src_param()
1074 src = ureg_src(tx->regs.predicate); in tx_src_param()
1082 if (param->rel || !tx_lconstf(tx, &src, param->idx)) { in tx_src_param()
1083 src = nine_float_constant_src(tx, param->idx); in tx_src_param()
1085 tx->indirect_const_access = TRUE; in tx_src_param()
1086 src = ureg_src_indirect(src, tx_src_param(tx, param->rel)); in tx_src_param()
1089 if (!IS_VS && tx->version.major < 2) { in tx_src_param()
1091 tmp = tx_scratch(tx); in tx_src_param()
1106 if (!tx_lconsti(tx, &src, param->idx)) in tx_src_param()
1107 src = nine_integer_constant_src(tx, param->idx); in tx_src_param()
1110 if (!tx_lconstb(tx, &src, param->idx)) in tx_src_param()
1111 src = nine_boolean_constant_src(tx, param->idx); in tx_src_param()
1114 if (ureg_dst_is_undef(tx->regs.address)) in tx_src_param()
1115 tx->regs.address = ureg_DECL_address(ureg); in tx_src_param()
1116 if (!tx->native_integers) in tx_src_param()
1117 ureg_ARR(ureg, tx->regs.address, tx_get_loopal(tx)); in tx_src_param()
1119 ureg_UARL(ureg, tx->regs.address, tx_get_loopal(tx)); in tx_src_param()
1120 src = ureg_src(tx->regs.address); in tx_src_param()
1125 if (ureg_src_is_undef(tx->regs.vPos)) in tx_src_param()
1126 tx->regs.vPos = nine_get_position_input(tx); in tx_src_param()
1127 if (tx->shift_wpos) { in tx_src_param()
1129 struct ureg_dst wpos = tx_scratch(tx); in tx_src_param()
1130 ureg_ADD(ureg, wpos, tx->regs.vPos, in tx_src_param()
1134 src = tx->regs.vPos; in tx_src_param()
1138 if (ureg_src_is_undef(tx->regs.vFace)) { in tx_src_param()
1139 if (tx->face_is_sysval_integer) { in tx_src_param()
1141 tx->regs.vFace = in tx_src_param()
1145 ureg_UCMP(ureg, tmp, ureg_scalar(tx->regs.vFace, TGSI_SWIZZLE_X), in tx_src_param()
1147 tx->regs.vFace = ureg_src(tmp); in tx_src_param()
1149 tx->regs.vFace = ureg_DECL_fs_input(ureg, in tx_src_param()
1153 tx->regs.vFace = ureg_scalar(tx->regs.vFace, TGSI_SWIZZLE_X); in tx_src_param()
1155 src = tx->regs.vFace; in tx_src_param()
1170 tmp = tx_scratch(tx); in tx_src_param()
1177 tmp = tx_scratch(tx); in tx_src_param()
1205 tmp = tx_scratch(tx); in tx_src_param()
1210 tmp = tx_scratch(tx); in tx_src_param()
1215 if (tx->native_integers && param->file == D3DSPR_CONSTBOOL) { in tx_src_param()
1216 tmp = tx_scratch(tx); in tx_src_param()
1221 tmp = tx_scratch(tx); in tx_src_param()
1227 tmp = tx_scratch(tx); in tx_src_param()
1236 tmp = tx_scratch(tx); in tx_src_param()
1241 tmp = tx_scratch(tx); in tx_src_param()
1246 tmp = tx_scratch(tx); in tx_src_param()
1251 tmp = tx_scratch(tx); in tx_src_param()
1264 _tx_dst_param(struct shader_translator *tx, const struct sm1_dst_param *param) in _tx_dst_param() argument
1272 tx_temp_alloc(tx, param->idx); in _tx_dst_param()
1273 dst = tx->regs.r[param->idx]; in _tx_dst_param()
1278 if (tx->version.major < 2 && !IS_VS) { in _tx_dst_param()
1279 if (ureg_dst_is_undef(tx->regs.tS[param->idx])) in _tx_dst_param()
1280 tx->regs.tS[param->idx] = ureg_DECL_temporary(tx->ureg); in _tx_dst_param()
1281 dst = tx->regs.tS[param->idx]; in _tx_dst_param()
1283 if (!IS_VS && tx->insn.opcode == D3DSIO_TEXKILL) { /* maybe others, too */ in _tx_dst_param()
1284 tx_texcoord_alloc(tx, param->idx); in _tx_dst_param()
1285 dst = ureg_dst(tx->regs.vT[param->idx]); in _tx_dst_param()
1287 tx_addr_alloc(tx, param->idx); in _tx_dst_param()
1288 dst = tx->regs.a0; in _tx_dst_param()
1295 if (ureg_dst_is_undef(tx->regs.oPos)) in _tx_dst_param()
1296 tx->regs.oPos = in _tx_dst_param()
1297 ureg_DECL_output(tx->ureg, TGSI_SEMANTIC_POSITION, 0); in _tx_dst_param()
1298 dst = tx->regs.oPos; in _tx_dst_param()
1301 if (ureg_dst_is_undef(tx->regs.oFog)) in _tx_dst_param()
1302 tx->regs.oFog = in _tx_dst_param()
1303 ureg_saturate(ureg_DECL_output(tx->ureg, TGSI_SEMANTIC_GENERIC, 16)); in _tx_dst_param()
1304 dst = tx->regs.oFog; in _tx_dst_param()
1307 if (ureg_dst_is_undef(tx->regs.oPts)) in _tx_dst_param()
1308 tx->regs.oPts = ureg_DECL_temporary(tx->ureg); in _tx_dst_param()
1309 dst = tx->regs.oPts; in _tx_dst_param()
1318 if (tx->version.major < 3) { in _tx_dst_param()
1320 dst = ureg_DECL_output(tx->ureg, tx->texcoord_sn, param->idx); in _tx_dst_param()
1323 assert(param->idx < ARRAY_SIZE(tx->regs.o)); in _tx_dst_param()
1324 dst = tx->regs.o[param->idx]; in _tx_dst_param()
1331 tx->info->rt_mask |= 1 << param->idx; in _tx_dst_param()
1332 if (ureg_dst_is_undef(tx->regs.oCol[param->idx])) { in _tx_dst_param()
1334 if (!IS_VS && tx->version.major < 3 && param->idx == 0) { in _tx_dst_param()
1335 tx->regs.oCol[0] = ureg_DECL_temporary(tx->ureg); in _tx_dst_param()
1337 tx->regs.oCol[param->idx] = in _tx_dst_param()
1338 ureg_DECL_output(tx->ureg, TGSI_SEMANTIC_COLOR, param->idx); in _tx_dst_param()
1341 dst = tx->regs.oCol[param->idx]; in _tx_dst_param()
1342 if (IS_VS && tx->version.major < 3) in _tx_dst_param()
1347 if (ureg_dst_is_undef(tx->regs.oDepth)) in _tx_dst_param()
1348 tx->regs.oDepth = in _tx_dst_param()
1349 ureg_DECL_output_masked(tx->ureg, TGSI_SEMANTIC_POSITION, 0, in _tx_dst_param()
1351 dst = tx->regs.oDepth; /* XXX: must write .z component */ in _tx_dst_param()
1354 if (ureg_dst_is_undef(tx->regs.predicate)) in _tx_dst_param()
1355 tx->regs.predicate = ureg_DECL_temporary(tx->ureg); in _tx_dst_param()
1356 dst = tx->regs.predicate; in _tx_dst_param()
1366 dst = ureg_dst_indirect(dst, tx_src_param(tx, param->rel)); in _tx_dst_param()
1373 if (tx->predicated_activated) { in _tx_dst_param()
1374 tx->regs.predicate_dst = dst; in _tx_dst_param()
1375 dst = tx->regs.predicate_tmp; in _tx_dst_param()
1382 tx_dst_param(struct shader_translator *tx, const struct sm1_dst_param *param) in tx_dst_param() argument
1385 tx->regs.tdst = ureg_writemask(tx_scratch(tx), param->mask); in tx_dst_param()
1386 return tx->regs.tdst; in tx_dst_param()
1388 return _tx_dst_param(tx, param); in tx_dst_param()
1392 tx_apply_dst0_modifiers(struct shader_translator *tx) in tx_apply_dst0_modifiers() argument
1397 if (!tx->insn.ndst || !tx->insn.dst[0].shift || tx->insn.opcode == D3DSIO_TEXKILL) in tx_apply_dst0_modifiers()
1399 rdst = _tx_dst_param(tx, &tx->insn.dst[0]); in tx_apply_dst0_modifiers()
1403 if (tx->insn.dst[0].shift < 0) in tx_apply_dst0_modifiers()
1404 f = 1.0f / (1 << -tx->insn.dst[0].shift); in tx_apply_dst0_modifiers()
1406 f = 1 << tx->insn.dst[0].shift; in tx_apply_dst0_modifiers()
1408 ureg_MUL(tx->ureg, rdst, ureg_src(tx->regs.tdst), ureg_imm1f(tx->ureg, f)); in tx_apply_dst0_modifiers()
1412 tx_dst_param_as_src(struct shader_translator *tx, const struct sm1_dst_param *param) in tx_dst_param_as_src() argument
1425 assert(param->idx < ARRAY_SIZE(tx->regs.v)); in tx_dst_param_as_src()
1426 src = tx->regs.v[param->idx]; in tx_dst_param_as_src()
1430 src = ureg_src(tx_dst_param(tx, param)); in tx_dst_param_as_src()
1434 src = ureg_src_indirect(src, tx_src_param(tx, param->rel)); in tx_dst_param_as_src()
1455 NineTranslateInstruction_Mkxn(struct shader_translator *tx, const unsigned k, const unsigned n) in NineTranslateInstruction_Mkxn() argument
1457 struct ureg_program *ureg = tx->ureg; in NineTranslateInstruction_Mkxn()
1460 struct sm1_src_param *src_mat = &tx->insn.src[1]; in NineTranslateInstruction_Mkxn()
1463 dst = tx_dst_param(tx, &tx->insn.dst[0]); in NineTranslateInstruction_Mkxn()
1464 src[0] = tx_src_param(tx, &tx->insn.src[0]); in NineTranslateInstruction_Mkxn()
1470 src[1] = tx_src_param(tx, src_mat); in NineTranslateInstruction_Mkxn()
1622 NineTranslateInstruction_##name( struct shader_translator *tx )
1636 struct ureg_program *ureg = tx->ureg; in DECL_SPECIAL()
1637 struct ureg_dst dst = tx_dst_param(tx, &tx->insn.dst[0]); in DECL_SPECIAL()
1638 struct ureg_src src0 = tx_src_param(tx, &tx->insn.src[0]); in DECL_SPECIAL()
1639 struct ureg_src src1 = tx_src_param(tx, &tx->insn.src[1]); in DECL_SPECIAL()
1647 struct ureg_program *ureg = tx->ureg; in DECL_SPECIAL()
1648 struct ureg_dst dst = tx_dst_param(tx, &tx->insn.dst[0]); in DECL_SPECIAL()
1649 struct ureg_src src = tx_src_param(tx, &tx->insn.src[0]); in DECL_SPECIAL()
1657 struct ureg_program *ureg = tx->ureg; in DECL_SPECIAL()
1658 struct ureg_dst dst = tx_dst_param(tx, &tx->insn.dst[0]); in DECL_SPECIAL()
1659 struct ureg_src src0 = tx_src_param(tx, &tx->insn.src[0]); in DECL_SPECIAL()
1660 struct ureg_src src1 = tx_src_param(tx, &tx->insn.src[1]); in DECL_SPECIAL()
1680 return NineTranslateInstruction_Mkxn(tx, 4, 4); in DECL_SPECIAL()
1685 return NineTranslateInstruction_Mkxn(tx, 4, 3); in DECL_SPECIAL()
1690 return NineTranslateInstruction_Mkxn(tx, 3, 4); in DECL_SPECIAL()
1695 return NineTranslateInstruction_Mkxn(tx, 3, 3); in DECL_SPECIAL()
1700 return NineTranslateInstruction_Mkxn(tx, 3, 2); in DECL_SPECIAL()
1705 ureg_CMP(tx->ureg, tx_dst_param(tx, &tx->insn.dst[0]), in DECL_SPECIAL()
1706 tx_src_param(tx, &tx->insn.src[0]), in DECL_SPECIAL()
1707 tx_src_param(tx, &tx->insn.src[2]), in DECL_SPECIAL()
1708 tx_src_param(tx, &tx->insn.src[1])); in DECL_SPECIAL()
1714 struct ureg_dst dst = tx_dst_param(tx, &tx->insn.dst[0]); in DECL_SPECIAL()
1724 …if (tx->insn.coissue && tx->version.major == 1 && tx->version.minor < 4 && tx->insn.dst[0].mask !=… in DECL_SPECIAL()
1725 ureg_MOV(tx->ureg, in DECL_SPECIAL()
1726 dst, tx_src_param(tx, &tx->insn.src[1])); in DECL_SPECIAL()
1730 cnd = tx_src_param(tx, &tx->insn.src[0]); in DECL_SPECIAL()
1731 cgt = tx_scratch(tx); in DECL_SPECIAL()
1733 if (tx->version.major == 1 && tx->version.minor < 4) in DECL_SPECIAL()
1736 ureg_SGT(tx->ureg, cgt, cnd, ureg_imm1f(tx->ureg, 0.5f)); in DECL_SPECIAL()
1738 ureg_CMP(tx->ureg, dst, ureg_negate(ureg_src(cgt)), in DECL_SPECIAL()
1739 tx_src_param(tx, &tx->insn.src[1]), in DECL_SPECIAL()
1740 tx_src_param(tx, &tx->insn.src[2])); in DECL_SPECIAL()
1746 assert(tx->insn.src[0].idx < tx->num_inst_labels); in DECL_SPECIAL()
1747 ureg_CAL(tx->ureg, &tx->inst_labels[tx->insn.src[0].idx]); in DECL_SPECIAL()
1753 struct ureg_program *ureg = tx->ureg; in DECL_SPECIAL()
1754 struct ureg_src src = tx_src_param(tx, &tx->insn.src[1]); in DECL_SPECIAL()
1756 if (!tx->native_integers) in DECL_SPECIAL()
1757 ureg_IF(ureg, src, tx_cond(tx)); in DECL_SPECIAL()
1759 ureg_UIF(ureg, src, tx_cond(tx)); in DECL_SPECIAL()
1760 ureg_CAL(ureg, &tx->inst_labels[tx->insn.src[0].idx]); in DECL_SPECIAL()
1761 tx_endcond(tx); in DECL_SPECIAL()
1768 struct ureg_program *ureg = tx->ureg; in DECL_SPECIAL()
1770 struct ureg_src src = tx_src_param(tx, &tx->insn.src[1]); in DECL_SPECIAL()
1775 label = tx_bgnloop(tx); in DECL_SPECIAL()
1776 ctr = tx_get_loopctr(tx, TRUE); in DECL_SPECIAL()
1781 ureg_BGNLOOP(tx->ureg, label); in DECL_SPECIAL()
1782 tmp = tx_scratch_scalar(tx); in DECL_SPECIAL()
1788 if (!tx->native_integers) { in DECL_SPECIAL()
1792 ureg_IF(ureg, tx_src_scalar(tmp), tx_cond(tx)); in DECL_SPECIAL()
1796 ureg_UIF(ureg, tx_src_scalar(tmp), tx_cond(tx)); in DECL_SPECIAL()
1799 tx_endcond(tx); in DECL_SPECIAL()
1810 if (*(tx->parse_next) != NINED3DSP_END) { in DECL_SPECIAL()
1811 ureg_RET(tx->ureg); in DECL_SPECIAL()
1818 struct ureg_program *ureg = tx->ureg; in DECL_SPECIAL()
1819 struct ureg_dst ctr = tx_get_loopctr(tx, TRUE); in DECL_SPECIAL()
1830 if (!tx->native_integers) { in DECL_SPECIAL()
1837 ureg_ENDLOOP(tx->ureg, tx_endloop(tx)); in DECL_SPECIAL()
1843 unsigned k = tx->num_inst_labels; in DECL_SPECIAL()
1844 unsigned n = tx->insn.src[0].idx; in DECL_SPECIAL()
1847 tx->inst_labels = REALLOC(tx->inst_labels, in DECL_SPECIAL()
1848 k * sizeof(tx->inst_labels[0]), in DECL_SPECIAL()
1849 n * sizeof(tx->inst_labels[0])); in DECL_SPECIAL()
1851 tx->inst_labels[n] = ureg_get_instruction_number(tx->ureg); in DECL_SPECIAL()
1857 struct ureg_program *ureg = tx->ureg; in DECL_SPECIAL()
1858 struct ureg_dst dst = tx_dst_param(tx, &tx->insn.dst[0]); in DECL_SPECIAL()
1859 struct ureg_src src = tx_src_param(tx, &tx->insn.src[0]); in DECL_SPECIAL()
1860 struct ureg_dst tmp = tx_scratch_scalar(tx); in DECL_SPECIAL()
1878 ureg_SSG(tx->ureg, in DECL_SPECIAL()
1879 tx_dst_param(tx, &tx->insn.dst[0]), in DECL_SPECIAL()
1880 tx_src_param(tx, &tx->insn.src[0])); in DECL_SPECIAL()
1886 struct ureg_program *ureg = tx->ureg; in DECL_SPECIAL()
1888 struct ureg_src rep = tx_src_param(tx, &tx->insn.src[0]); in DECL_SPECIAL()
1893 label = tx_bgnloop(tx); in DECL_SPECIAL()
1894 ctr = ureg_writemask(tx_get_loopctr(tx, FALSE), NINED3DSP_WRITEMASK_0); in DECL_SPECIAL()
1903 tmp = tx_scratch_scalar(tx); in DECL_SPECIAL()
1908 if (!tx->native_integers) { in DECL_SPECIAL()
1912 ureg_IF(ureg, tx_src_scalar(tmp), tx_cond(tx)); in DECL_SPECIAL()
1916 ureg_UIF(ureg, tx_src_scalar(tmp), tx_cond(tx)); in DECL_SPECIAL()
1919 tx_endcond(tx); in DECL_SPECIAL()
1927 struct ureg_program *ureg = tx->ureg; in DECL_SPECIAL()
1928 struct ureg_dst ctr = tx_get_loopctr(tx, FALSE); in DECL_SPECIAL()
1933 if (!tx->native_integers) in DECL_SPECIAL()
1938 ureg_ENDLOOP(tx->ureg, tx_endloop(tx)); in DECL_SPECIAL()
1944 tx_endcond(tx); in DECL_SPECIAL()
1945 ureg_ENDIF(tx->ureg); in DECL_SPECIAL()
1951 struct ureg_src src = tx_src_param(tx, &tx->insn.src[0]); in DECL_SPECIAL()
1953 if (tx->native_integers && tx->insn.src[0].file == D3DSPR_CONSTBOOL) in DECL_SPECIAL()
1954 ureg_UIF(tx->ureg, src, tx_cond(tx)); in DECL_SPECIAL()
1956 ureg_IF(tx->ureg, src, tx_cond(tx)); in DECL_SPECIAL()
1979 const unsigned cmp_op = sm1_insn_flags_to_tgsi_setop(tx->insn.flags); in DECL_SPECIAL()
1981 struct ureg_dst tmp = ureg_writemask(tx_scratch(tx), TGSI_WRITEMASK_X); in DECL_SPECIAL()
1982 src[0] = tx_src_param(tx, &tx->insn.src[0]); in DECL_SPECIAL()
1983 src[1] = tx_src_param(tx, &tx->insn.src[1]); in DECL_SPECIAL()
1984 ureg_insn(tx->ureg, cmp_op, &tmp, 1, src, 2, 0); in DECL_SPECIAL()
1985 ureg_IF(tx->ureg, ureg_scalar(ureg_src(tmp), TGSI_SWIZZLE_X), tx_cond(tx)); in DECL_SPECIAL()
1991 ureg_ELSE(tx->ureg, tx_elsecond(tx)); in DECL_SPECIAL()
1997 const unsigned cmp_op = sm1_insn_flags_to_tgsi_setop(tx->insn.flags); in DECL_SPECIAL()
1999 struct ureg_dst tmp = ureg_writemask(tx_scratch(tx), TGSI_WRITEMASK_X); in DECL_SPECIAL()
2000 src[0] = tx_src_param(tx, &tx->insn.src[0]); in DECL_SPECIAL()
2001 src[1] = tx_src_param(tx, &tx->insn.src[1]); in DECL_SPECIAL()
2002 ureg_insn(tx->ureg, cmp_op, &tmp, 1, src, 2, 0); in DECL_SPECIAL()
2003 ureg_IF(tx->ureg, ureg_scalar(ureg_src(tmp), TGSI_SWIZZLE_X), tx_cond(tx)); in DECL_SPECIAL()
2004 ureg_BRK(tx->ureg); in DECL_SPECIAL()
2005 tx_endcond(tx); in DECL_SPECIAL()
2006 ureg_ENDIF(tx->ureg); in DECL_SPECIAL()
2222 struct ureg_program *ureg = tx->ureg; in DECL_SPECIAL()
2227 sm1_read_semantic(tx, &sem); in DECL_SPECIAL()
2238 if (tx->version.major >= 3) in DECL_SPECIAL()
2249 tx->info->sampler_mask |= m; in DECL_SPECIAL()
2250 tx->sampler_targets[sem.reg.idx] = (tx->info->sampler_mask_shadow & m) ? in DECL_SPECIAL()
2256 sm1_declusage_to_tgsi(&tgsi, tx->want_texcoord, &sem); in DECL_SPECIAL()
2261 assert(sem.reg.idx < ARRAY_SIZE(tx->info->input_map)); in DECL_SPECIAL()
2262 tx->info->input_map[sem.reg.idx] = sm1_to_nine_declusage(&sem); in DECL_SPECIAL()
2263 tx->info->num_inputs = MAX2(tx->info->num_inputs, sem.reg.idx + 1); in DECL_SPECIAL()
2266 if (tx->version.major >= 3) { in DECL_SPECIAL()
2270 tx->info->position_t = TRUE; in DECL_SPECIAL()
2271 assert(sem.reg.idx < ARRAY_SIZE(tx->regs.o)); in DECL_SPECIAL()
2272 … assert(ureg_dst_is_undef(tx->regs.o[sem.reg.idx]) && "Nine doesn't support yet packing"); in DECL_SPECIAL()
2273 tx->regs.o[sem.reg.idx] = ureg_DECL_output_masked( in DECL_SPECIAL()
2275 nine_record_outputs(tx, sem.usage, sem.usage_idx, sem.reg.mask, sem.reg.idx); in DECL_SPECIAL()
2276 … if (tx->info->process_vertices && sem.usage == D3DDECLUSAGE_POSITION && sem.usage_idx == 0) { in DECL_SPECIAL()
2277 tx->regs.oPos_out = tx->regs.o[sem.reg.idx]; in DECL_SPECIAL()
2278 tx->regs.o[sem.reg.idx] = ureg_DECL_temporary(ureg); in DECL_SPECIAL()
2279 tx->regs.oPos = tx->regs.o[sem.reg.idx]; in DECL_SPECIAL()
2283 tx->regs.o[sem.reg.idx] = ureg_DECL_temporary(ureg); in DECL_SPECIAL()
2284 tx->regs.oPts = tx->regs.o[sem.reg.idx]; in DECL_SPECIAL()
2288 if (is_input && tx->version.major >= 3) { in DECL_SPECIAL()
2291 assert(sem.reg.idx < ARRAY_SIZE(tx->regs.v)); in DECL_SPECIAL()
2292 … assert(ureg_src_is_undef(tx->regs.v[sem.reg.idx]) && "Nine doesn't support yet packing"); in DECL_SPECIAL()
2302 tx->regs.v[sem.reg.idx] = nine_get_position_input(tx); in DECL_SPECIAL()
2307 (tgsi.Name == TGSI_SEMANTIC_COLOR && tx->info->force_color_in_centroid)) in DECL_SPECIAL()
2310 tx->regs.v[sem.reg.idx] = ureg_DECL_fs_input_cyl_centroid( in DECL_SPECIAL()
2328 tx_set_lconstf(tx, tx->insn.dst[0].idx, tx->insn.src[0].imm.f); in DECL_SPECIAL()
2334 tx_set_lconstb(tx, tx->insn.dst[0].idx, tx->insn.src[0].imm.b); in DECL_SPECIAL()
2340 tx_set_lconsti(tx, tx->insn.dst[0].idx, tx->insn.src[0].imm.i); in DECL_SPECIAL()
2346 struct ureg_dst dst = tx_dst_param(tx, &tx->insn.dst[0]); in DECL_SPECIAL()
2348 tx_src_param(tx, &tx->insn.src[0]), in DECL_SPECIAL()
2349 tx_src_param(tx, &tx->insn.src[1]) in DECL_SPECIAL()
2351 ureg_POW(tx->ureg, dst, ureg_abs(src[0]), src[1]); in DECL_SPECIAL()
2386 struct ureg_program *ureg = tx->ureg; in DECL_SPECIAL()
2387 struct ureg_dst dst = tx_dst_param(tx, &tx->insn.dst[0]); in DECL_SPECIAL()
2388 struct ureg_src src = tx_src_param(tx, &tx->insn.src[0]); in DECL_SPECIAL()
2389 struct ureg_dst tmp = tx->mul_zero_wins ? dst : tx_scratch(tx); in DECL_SPECIAL()
2391 if (!tx->mul_zero_wins) { in DECL_SPECIAL()
2401 struct ureg_program *ureg = tx->ureg; in DECL_SPECIAL()
2402 struct ureg_dst dst = tx_dst_param(tx, &tx->insn.dst[0]); in DECL_SPECIAL()
2403 struct ureg_src src = tx_src_param(tx, &tx->insn.src[0]); in DECL_SPECIAL()
2404 struct ureg_dst tmp = tx->mul_zero_wins ? dst : tx_scratch(tx); in DECL_SPECIAL()
2406 if (!tx->mul_zero_wins) in DECL_SPECIAL()
2413 struct ureg_program *ureg = tx->ureg; in DECL_SPECIAL()
2414 struct ureg_dst tmp = tx_scratch_scalar(tx); in DECL_SPECIAL()
2415 struct ureg_dst dst = tx_dst_param(tx, &tx->insn.dst[0]); in DECL_SPECIAL()
2416 struct ureg_src src = tx_src_param(tx, &tx->insn.src[0]); in DECL_SPECIAL()
2418 if (tx->mul_zero_wins) { in DECL_SPECIAL()
2428 struct ureg_program *ureg = tx->ureg; in DECL_SPECIAL()
2429 struct ureg_dst tmp = tx_scratch(tx); in DECL_SPECIAL()
2430 struct ureg_dst dst = tx_dst_param(tx, &tx->insn.dst[0]); in DECL_SPECIAL()
2431 struct ureg_src src = tx_src_param(tx, &tx->insn.src[0]); in DECL_SPECIAL()
2445 struct ureg_program *ureg = tx->ureg; in DECL_SPECIAL()
2446 struct ureg_dst tmp = tx_scratch_scalar(tx); in DECL_SPECIAL()
2448 struct ureg_dst dst = tx_dst_param(tx, &tx->insn.dst[0]); in DECL_SPECIAL()
2449 struct ureg_src src = tx_src_param(tx, &tx->insn.src[0]); in DECL_SPECIAL()
2452 if (!tx->mul_zero_wins) in DECL_SPECIAL()
2460 struct ureg_dst tmp = tx_scratch_scalar(tx); in DECL_SPECIAL()
2462 struct ureg_dst dst = tx_dst_param(tx, &tx->insn.dst[0]); in DECL_SPECIAL()
2466 src[i] = tx_src_param(tx, &tx->insn.src[i]); in DECL_SPECIAL()
2469 ureg_DP2(tx->ureg, tmp, src[0], src[1]); in DECL_SPECIAL()
2470 ureg_ADD(tx->ureg, dst, src[2], dp2); in DECL_SPECIAL()
2477 struct ureg_program *ureg = tx->ureg; in DECL_SPECIAL()
2478 const unsigned s = tx->insn.dst[0].idx; in DECL_SPECIAL()
2479 struct ureg_dst dst = tx_dst_param(tx, &tx->insn.dst[0]); in DECL_SPECIAL()
2481 tx_texcoord_alloc(tx, s); in DECL_SPECIAL()
2482 ureg_MOV(ureg, ureg_writemask(ureg_saturate(dst), TGSI_WRITEMASK_XYZ), tx->regs.vT[s]); in DECL_SPECIAL()
2483 ureg_MOV(ureg, ureg_writemask(dst, TGSI_WRITEMASK_W), ureg_imm1f(tx->ureg, 1.0f)); in DECL_SPECIAL()
2490 struct ureg_program *ureg = tx->ureg; in DECL_SPECIAL()
2491 struct ureg_src src = tx_src_param(tx, &tx->insn.src[0]); in DECL_SPECIAL()
2492 struct ureg_dst dst = tx_dst_param(tx, &tx->insn.dst[0]); in DECL_SPECIAL()
2494 assert(tx->insn.src[0].file == D3DSPR_TEXTURE); in DECL_SPECIAL()
2505 if (tx->version.major > 1 || tx->version.minor > 3) { in DECL_SPECIAL()
2506 reg = tx_dst_param_as_src(tx, &tx->insn.dst[0]); in DECL_SPECIAL()
2508 tx_texcoord_alloc(tx, tx->insn.dst[0].idx); in DECL_SPECIAL()
2509 reg = tx->regs.vT[tx->insn.dst[0].idx]; in DECL_SPECIAL()
2511 if (tx->version.major < 2) in DECL_SPECIAL()
2513 ureg_KILL_IF(tx->ureg, reg); in DECL_SPECIAL()
2520 struct ureg_program *ureg = tx->ureg; in DECL_SPECIAL()
2521 struct ureg_dst dst = tx_dst_param(tx, &tx->insn.dst[0]); in DECL_SPECIAL()
2522 struct ureg_src src = tx_src_param(tx, &tx->insn.src[0]); /* t[n] */ in DECL_SPECIAL()
2526 const int m = tx->insn.dst[0].idx; in DECL_SPECIAL()
2528 assert(tx->version.major == 1); in DECL_SPECIAL()
2531 tx->info->sampler_mask |= 1 << m; in DECL_SPECIAL()
2533 tx_texcoord_alloc(tx, m); in DECL_SPECIAL()
2535 tmp = tx_scratch(tx); in DECL_SPECIAL()
2536 tmp2 = tx_scratch(tx); in DECL_SPECIAL()
2537 texcoord = tx_scratch(tx); in DECL_SPECIAL()
2545 c8m = nine_float_constant_src(tx, 8+m); in DECL_SPECIAL()
2546 c16m2 = nine_float_constant_src(tx, 8+8+m/2); in DECL_SPECIAL()
2562 apply_ps1x_projection(tx, texcoord, tx->regs.vT[m], m); in DECL_SPECIAL()
2582 if (tx->insn.opcode == D3DSIO_TEXBEM) { in DECL_SPECIAL()
2583 ureg_TEX(ureg, dst, ps1x_sampler_type(tx->info, m), ureg_src(tmp), sample); in DECL_SPECIAL()
2584 } else if (tx->insn.opcode == D3DSIO_TEXBEML) { in DECL_SPECIAL()
2586 ureg_TEX(ureg, tmp, ps1x_sampler_type(tx->info, m), ureg_src(tmp), sample); in DECL_SPECIAL()
2592 tx->info->bumpenvmat_needed = 1; in DECL_SPECIAL()
2599 struct ureg_program *ureg = tx->ureg; in DECL_SPECIAL()
2600 struct ureg_dst dst = tx_dst_param(tx, &tx->insn.dst[0]); in DECL_SPECIAL()
2601 struct ureg_src src = tx_src_param(tx, &tx->insn.src[0]); /* t[n] */ in DECL_SPECIAL()
2603 const int m = tx->insn.dst[0].idx; in DECL_SPECIAL()
2604 ASSERTED const int n = tx->insn.src[0].idx; in DECL_SPECIAL()
2608 tx->info->sampler_mask |= 1 << m; in DECL_SPECIAL()
2609 …ureg_TEX(ureg, dst, ps1x_sampler_type(tx->info, m), ureg_swizzle(src, NINE_SWIZZLE4(W,X,X,X)), sam… in DECL_SPECIAL()
2616 struct ureg_program *ureg = tx->ureg; in DECL_SPECIAL()
2617 struct ureg_dst dst = tx_dst_param(tx, &tx->insn.dst[0]); in DECL_SPECIAL()
2618 struct ureg_src src = tx_src_param(tx, &tx->insn.src[0]); /* t[n] */ in DECL_SPECIAL()
2620 const int m = tx->insn.dst[0].idx; in DECL_SPECIAL()
2621 ASSERTED const int n = tx->insn.src[0].idx; in DECL_SPECIAL()
2625 tx->info->sampler_mask |= 1 << m; in DECL_SPECIAL()
2626 …ureg_TEX(ureg, dst, ps1x_sampler_type(tx->info, m), ureg_swizzle(src, NINE_SWIZZLE4(Y,Z,Z,Z)), sam… in DECL_SPECIAL()
2638 struct ureg_program *ureg = tx->ureg; in DECL_SPECIAL()
2639 struct ureg_dst dst = tx_dst_param(tx, &tx->insn.dst[0]); in DECL_SPECIAL()
2640 struct ureg_src src = tx_src_param(tx, &tx->insn.src[0]); /* t[n] */ in DECL_SPECIAL()
2642 const int m = tx->insn.dst[0].idx - 1; in DECL_SPECIAL()
2643 ASSERTED const int n = tx->insn.src[0].idx; in DECL_SPECIAL()
2646 tx_texcoord_alloc(tx, m); in DECL_SPECIAL()
2647 tx_texcoord_alloc(tx, m+1); in DECL_SPECIAL()
2650 ureg_DP3(ureg, ureg_writemask(dst, TGSI_WRITEMASK_X), tx->regs.vT[m], src); in DECL_SPECIAL()
2651 ureg_DP3(ureg, ureg_writemask(dst, TGSI_WRITEMASK_Y), tx->regs.vT[m+1], src); in DECL_SPECIAL()
2654 tx->info->sampler_mask |= 1 << (m + 1); in DECL_SPECIAL()
2655 ureg_TEX(ureg, dst, ps1x_sampler_type(tx->info, m + 1), ureg_src(dst), sample); in DECL_SPECIAL()
2667 struct ureg_program *ureg = tx->ureg; in DECL_SPECIAL()
2668 struct ureg_dst dst = tx_dst_param(tx, &tx->insn.dst[0]); in DECL_SPECIAL()
2669 struct ureg_src src = tx_src_param(tx, &tx->insn.src[0]); /* t[n] */ in DECL_SPECIAL()
2670 struct ureg_src E = tx_src_param(tx, &tx->insn.src[1]); in DECL_SPECIAL()
2673 const int m = tx->insn.dst[0].idx - 2; in DECL_SPECIAL()
2674 ASSERTED const int n = tx->insn.src[0].idx; in DECL_SPECIAL()
2677 tx_texcoord_alloc(tx, m); in DECL_SPECIAL()
2678 tx_texcoord_alloc(tx, m+1); in DECL_SPECIAL()
2679 tx_texcoord_alloc(tx, m+2); in DECL_SPECIAL()
2681 ureg_DP3(ureg, ureg_writemask(dst, TGSI_WRITEMASK_X), tx->regs.vT[m], src); in DECL_SPECIAL()
2682 ureg_DP3(ureg, ureg_writemask(dst, TGSI_WRITEMASK_Y), tx->regs.vT[m+1], src); in DECL_SPECIAL()
2683 ureg_DP3(ureg, ureg_writemask(dst, TGSI_WRITEMASK_Z), tx->regs.vT[m+2], src); in DECL_SPECIAL()
2686 tx->info->sampler_mask |= 1 << (m + 2); in DECL_SPECIAL()
2687 tmp = ureg_writemask(tx_scratch(tx), TGSI_WRITEMASK_XYZ); in DECL_SPECIAL()
2703 ureg_TEX(ureg, dst, ps1x_sampler_type(tx->info, m + 2), ureg_src(tmp), sample); in DECL_SPECIAL()
2710 struct ureg_program *ureg = tx->ureg; in DECL_SPECIAL()
2711 struct ureg_dst dst = tx_dst_param(tx, &tx->insn.dst[0]); in DECL_SPECIAL()
2712 struct ureg_src src = tx_src_param(tx, &tx->insn.src[0]); /* t[n] */ in DECL_SPECIAL()
2714 const int m = tx->insn.dst[0].idx; in DECL_SPECIAL()
2715 ASSERTED const int n = tx->insn.src[0].idx; in DECL_SPECIAL()
2719 tx->info->sampler_mask |= 1 << m; in DECL_SPECIAL()
2720 ureg_TEX(ureg, dst, ps1x_sampler_type(tx->info, m), src, sample); in DECL_SPECIAL()
2727 struct ureg_program *ureg = tx->ureg; in DECL_SPECIAL()
2728 struct ureg_dst dst = tx_dst_param(tx, &tx->insn.dst[0]); in DECL_SPECIAL()
2729 struct ureg_src src = tx_src_param(tx, &tx->insn.src[0]); /* t[n] */ in DECL_SPECIAL()
2732 const int m = tx->insn.dst[0].idx; in DECL_SPECIAL()
2733 ASSERTED const int n = tx->insn.src[0].idx; in DECL_SPECIAL()
2736 tx_texcoord_alloc(tx, m); in DECL_SPECIAL()
2738 tmp = tx_scratch(tx); in DECL_SPECIAL()
2739 ureg_DP3(ureg, ureg_writemask(tmp, TGSI_WRITEMASK_X), tx->regs.vT[m], src); in DECL_SPECIAL()
2743 tx->info->sampler_mask |= 1 << m; in DECL_SPECIAL()
2744 ureg_TEX(ureg, dst, ps1x_sampler_type(tx->info, m), ureg_src(tmp), sample); in DECL_SPECIAL()
2751 struct ureg_program *ureg = tx->ureg; in DECL_SPECIAL()
2752 struct ureg_src src = tx_src_param(tx, &tx->insn.src[0]); /* t[n] */ in DECL_SPECIAL()
2754 const int m = tx->insn.dst[0].idx - 1; in DECL_SPECIAL()
2755 ASSERTED const int n = tx->insn.src[0].idx; in DECL_SPECIAL()
2758 tx_texcoord_alloc(tx, m); in DECL_SPECIAL()
2759 tx_texcoord_alloc(tx, m+1); in DECL_SPECIAL()
2761 tmp = tx_scratch(tx); in DECL_SPECIAL()
2764 ureg_DP3(ureg, ureg_writemask(tmp, TGSI_WRITEMASK_X), tx->regs.vT[m], src); in DECL_SPECIAL()
2765 ureg_DP3(ureg, ureg_writemask(tmp, TGSI_WRITEMASK_Y), tx->regs.vT[m+1], src); in DECL_SPECIAL()
2774 tx->regs.oDepth = ureg_DECL_output_masked(ureg, TGSI_SEMANTIC_POSITION, 0, in DECL_SPECIAL()
2776 ureg_MOV(ureg, tx->regs.oDepth, ureg_scalar(ureg_src(tmp), TGSI_SWIZZLE_X)); in DECL_SPECIAL()
2783 struct ureg_program *ureg = tx->ureg; in DECL_SPECIAL()
2784 struct ureg_dst dst = tx_dst_param(tx, &tx->insn.dst[0]); in DECL_SPECIAL()
2785 struct ureg_src src = tx_src_param(tx, &tx->insn.src[0]); /* t[n] */ in DECL_SPECIAL()
2786 const int m = tx->insn.dst[0].idx; in DECL_SPECIAL()
2787 ASSERTED const int n = tx->insn.src[0].idx; in DECL_SPECIAL()
2790 tx_texcoord_alloc(tx, m); in DECL_SPECIAL()
2792 ureg_DP3(ureg, dst, tx->regs.vT[m], src); in DECL_SPECIAL()
2799 struct ureg_program *ureg = tx->ureg; in DECL_SPECIAL()
2800 struct ureg_dst dst = tx_dst_param(tx, &tx->insn.dst[0]); in DECL_SPECIAL()
2801 struct ureg_src src = tx_src_param(tx, &tx->insn.src[0]); /* t[n] */ in DECL_SPECIAL()
2804 const int m = tx->insn.dst[0].idx - 2; in DECL_SPECIAL()
2805 ASSERTED const int n = tx->insn.src[0].idx; in DECL_SPECIAL()
2808 tx_texcoord_alloc(tx, m); in DECL_SPECIAL()
2809 tx_texcoord_alloc(tx, m+1); in DECL_SPECIAL()
2810 tx_texcoord_alloc(tx, m+2); in DECL_SPECIAL()
2812 ureg_DP3(ureg, ureg_writemask(dst, TGSI_WRITEMASK_X), tx->regs.vT[m], src); in DECL_SPECIAL()
2813 ureg_DP3(ureg, ureg_writemask(dst, TGSI_WRITEMASK_Y), tx->regs.vT[m+1], src); in DECL_SPECIAL()
2814 ureg_DP3(ureg, ureg_writemask(dst, TGSI_WRITEMASK_Z), tx->regs.vT[m+2], src); in DECL_SPECIAL()
2816 switch (tx->insn.opcode) { in DECL_SPECIAL()
2822 tx->info->sampler_mask |= 1 << (m + 2); in DECL_SPECIAL()
2823 ureg_TEX(ureg, dst, ps1x_sampler_type(tx->info, m + 2), ureg_src(dst), sample); in DECL_SPECIAL()
2827 tx->info->sampler_mask |= 1 << (m + 2); in DECL_SPECIAL()
2828 E = tx_scratch(tx); in DECL_SPECIAL()
2829 tmp = ureg_writemask(tx_scratch(tx), TGSI_WRITEMASK_XYZ); in DECL_SPECIAL()
2830 … ureg_MOV(ureg, ureg_writemask(E, TGSI_WRITEMASK_X), ureg_scalar(tx->regs.vT[m], TGSI_SWIZZLE_W)); in DECL_SPECIAL()
2831 …ureg_MOV(ureg, ureg_writemask(E, TGSI_WRITEMASK_Y), ureg_scalar(tx->regs.vT[m+1], TGSI_SWIZZLE_W)); in DECL_SPECIAL()
2832 …ureg_MOV(ureg, ureg_writemask(E, TGSI_WRITEMASK_Z), ureg_scalar(tx->regs.vT[m+2], TGSI_SWIZZLE_W)); in DECL_SPECIAL()
2847 ureg_TEX(ureg, dst, ps1x_sampler_type(tx->info, m + 2), ureg_src(tmp), sample); in DECL_SPECIAL()
2857 struct ureg_program *ureg = tx->ureg; in DECL_SPECIAL()
2861 assert(tx->insn.dst[0].idx == 5); /* instruction must get r5 here */ in DECL_SPECIAL()
2865 r5 = tx->regs.r[5]; in DECL_SPECIAL()
2875 tx->regs.oDepth = ureg_DECL_output_masked(ureg, TGSI_SEMANTIC_POSITION, 0, in DECL_SPECIAL()
2877 ureg_MOV(ureg, tx->regs.oDepth, r5r); in DECL_SPECIAL()
2884 struct ureg_program *ureg = tx->ureg; in DECL_SPECIAL()
2885 struct ureg_dst dst = tx_dst_param(tx, &tx->insn.dst[0]); in DECL_SPECIAL()
2886 struct ureg_src src0 = tx_src_param(tx, &tx->insn.src[0]); in DECL_SPECIAL()
2887 struct ureg_src src1 = tx_src_param(tx, &tx->insn.src[1]); in DECL_SPECIAL()
2889 const int m = tx->insn.dst[0].idx; in DECL_SPECIAL()
2890 struct ureg_dst tmp = tx_scratch(tx); in DECL_SPECIAL()
2898 c8m = nine_float_constant_src(tx, 8+m); in DECL_SPECIAL()
2918 tx->info->bumpenvmat_needed = 1; in DECL_SPECIAL()
2925 struct ureg_program *ureg = tx->ureg; in DECL_SPECIAL()
2927 struct ureg_dst dst = tx_dst_param(tx, &tx->insn.dst[0]); in DECL_SPECIAL()
2929 tx_src_param(tx, &tx->insn.src[0]), in DECL_SPECIAL()
2930 tx_src_param(tx, &tx->insn.src[1]) in DECL_SPECIAL()
2932 assert(tx->insn.src[1].idx >= 0 && in DECL_SPECIAL()
2933 tx->insn.src[1].idx < ARRAY_SIZE(tx->sampler_targets)); in DECL_SPECIAL()
2934 target = tx->sampler_targets[tx->insn.src[1].idx]; in DECL_SPECIAL()
2936 switch (tx->insn.flags) { in DECL_SPECIAL()
2955 struct ureg_program *ureg = tx->ureg; in DECL_SPECIAL()
2956 struct ureg_dst dst = tx_dst_param(tx, &tx->insn.dst[0]); in DECL_SPECIAL()
2957 struct ureg_src src = tx_src_param(tx, &tx->insn.src[0]); in DECL_SPECIAL()
2958 const unsigned s = tx->insn.dst[0].idx; in DECL_SPECIAL()
2959 const unsigned t = ps1x_sampler_type(tx->info, s); in DECL_SPECIAL()
2961 tx->info->sampler_mask |= 1 << s; in DECL_SPECIAL()
2969 struct ureg_program *ureg = tx->ureg; in DECL_SPECIAL()
2970 const unsigned s = tx->insn.dst[0].idx; in DECL_SPECIAL()
2971 const unsigned t = ps1x_sampler_type(tx->info, s); in DECL_SPECIAL()
2972 struct ureg_dst dst = tx_dst_param(tx, &tx->insn.dst[0]); in DECL_SPECIAL()
2975 tx_texcoord_alloc(tx, s); in DECL_SPECIAL()
2977 src[0] = tx->regs.vT[s]; in DECL_SPECIAL()
2979 tx->info->sampler_mask |= 1 << s; in DECL_SPECIAL()
2981 TEX_with_ps1x_projection(tx, dst, t, src[0], src[1], s); in DECL_SPECIAL()
2989 struct ureg_dst dst = tx_dst_param(tx, &tx->insn.dst[0]); in DECL_SPECIAL()
2991 tx_src_param(tx, &tx->insn.src[0]), in DECL_SPECIAL()
2992 tx_src_param(tx, &tx->insn.src[1]), in DECL_SPECIAL()
2993 tx_src_param(tx, &tx->insn.src[2]), in DECL_SPECIAL()
2994 tx_src_param(tx, &tx->insn.src[3]) in DECL_SPECIAL()
2996 assert(tx->insn.src[1].idx >= 0 && in DECL_SPECIAL()
2997 tx->insn.src[1].idx < ARRAY_SIZE(tx->sampler_targets)); in DECL_SPECIAL()
2998 target = tx->sampler_targets[tx->insn.src[1].idx]; in DECL_SPECIAL()
3000 ureg_TXD(tx->ureg, dst, target, src[0], src[2], src[3], src[1]); in DECL_SPECIAL()
3007 struct ureg_dst dst = tx_dst_param(tx, &tx->insn.dst[0]); in DECL_SPECIAL()
3009 tx_src_param(tx, &tx->insn.src[0]), in DECL_SPECIAL()
3010 tx_src_param(tx, &tx->insn.src[1]) in DECL_SPECIAL()
3012 assert(tx->insn.src[1].idx >= 0 && in DECL_SPECIAL()
3013 tx->insn.src[1].idx < ARRAY_SIZE(tx->sampler_targets)); in DECL_SPECIAL()
3014 target = tx->sampler_targets[tx->insn.src[1].idx]; in DECL_SPECIAL()
3016 ureg_TXL(tx->ureg, dst, target, src[0], src[1]); in DECL_SPECIAL()
3022 const unsigned cmp_op = sm1_insn_flags_to_tgsi_setop(tx->insn.flags); in DECL_SPECIAL()
3023 struct ureg_dst dst = tx_dst_param(tx, &tx->insn.dst[0]); in DECL_SPECIAL()
3025 tx_src_param(tx, &tx->insn.src[0]), in DECL_SPECIAL()
3026 tx_src_param(tx, &tx->insn.src[1]) in DECL_SPECIAL()
3028 ureg_insn(tx->ureg, cmp_op, &dst, 1, src, 2, 0); in DECL_SPECIAL()
3034 struct ureg_src src = tx_src_param(tx, &tx->insn.src[0]); in DECL_SPECIAL()
3035 ureg_IF(tx->ureg, src, tx_cond(tx)); in DECL_SPECIAL()
3036 ureg_BRK(tx->ureg); in DECL_SPECIAL()
3037 tx_endcond(tx); in DECL_SPECIAL()
3038 ureg_ENDIF(tx->ureg); in DECL_SPECIAL()
3170 create_op_info_map(struct shader_translator *tx) in create_op_info_map() argument
3172 const unsigned version = (tx->version.major << 8) | tx->version.minor; in create_op_info_map()
3175 for (i = 0; i < ARRAY_SIZE(tx->op_info_map); ++i) in create_op_info_map()
3176 tx->op_info_map[i] = -1; in create_op_info_map()
3178 if (tx->processor == PIPE_SHADER_VERTEX) { in create_op_info_map()
3180 assert(inst_table[i].sio < ARRAY_SIZE(tx->op_info_map)); in create_op_info_map()
3183 tx->op_info_map[inst_table[i].sio] = i; in create_op_info_map()
3187 assert(inst_table[i].sio < ARRAY_SIZE(tx->op_info_map)); in create_op_info_map()
3190 tx->op_info_map[inst_table[i].sio] = i; in create_op_info_map()
3196 NineTranslateInstruction_Generic(struct shader_translator *tx) in NineTranslateInstruction_Generic() argument
3202 for (i = 0; i < tx->insn.ndst && i < ARRAY_SIZE(dst); ++i) in NineTranslateInstruction_Generic()
3203 dst[i] = tx_dst_param(tx, &tx->insn.dst[i]); in NineTranslateInstruction_Generic()
3204 for (i = 0; i < tx->insn.nsrc && i < ARRAY_SIZE(src); ++i) in NineTranslateInstruction_Generic()
3205 src[i] = tx_src_param(tx, &tx->insn.src[i]); in NineTranslateInstruction_Generic()
3207 ureg_insn(tx->ureg, tx->insn.info->opcode, in NineTranslateInstruction_Generic()
3208 dst, tx->insn.ndst, in NineTranslateInstruction_Generic()
3209 src, tx->insn.nsrc, 0); in NineTranslateInstruction_Generic()
3214 TOKEN_PEEK(struct shader_translator *tx) in TOKEN_PEEK() argument
3216 return *(tx->parse); in TOKEN_PEEK()
3220 TOKEN_NEXT(struct shader_translator *tx) in TOKEN_NEXT() argument
3222 return *(tx->parse)++; in TOKEN_NEXT()
3226 TOKEN_JUMP(struct shader_translator *tx) in TOKEN_JUMP() argument
3228 if (tx->parse_next && tx->parse != tx->parse_next) { in TOKEN_JUMP()
3229 WARN("parse(%p) != parse_next(%p) !\n", tx->parse, tx->parse_next); in TOKEN_JUMP()
3230 tx->parse = tx->parse_next; in TOKEN_JUMP()
3235 sm1_parse_eof(struct shader_translator *tx) in sm1_parse_eof() argument
3237 return TOKEN_PEEK(tx) == NINED3DSP_END; in sm1_parse_eof()
3241 sm1_read_version(struct shader_translator *tx) in sm1_read_version() argument
3243 const DWORD tok = TOKEN_NEXT(tx); in sm1_read_version()
3245 tx->version.major = D3DSHADER_VERSION_MAJOR(tok); in sm1_read_version()
3246 tx->version.minor = D3DSHADER_VERSION_MINOR(tok); in sm1_read_version()
3249 case NINED3D_SM1_VS: tx->processor = PIPE_SHADER_VERTEX; break; in sm1_read_version()
3250 case NINED3D_SM1_PS: tx->processor = PIPE_SHADER_FRAGMENT; break; in sm1_read_version()
3253 tx->processor = ~0; in sm1_read_version()
3260 sm1_parse_get_skip(struct shader_translator *tx) in sm1_parse_get_skip() argument
3262 const DWORD tok = TOKEN_PEEK(tx); in sm1_parse_get_skip()
3264 if (tx->version.major >= 2) { in sm1_parse_get_skip()
3265 tx->parse_next = tx->parse + 1 /* this */ + in sm1_parse_get_skip()
3268 tx->parse_next = NULL; /* TODO: determine from param count */ in sm1_parse_get_skip()
3281 sm1_parse_comments(struct shader_translator *tx, BOOL print) in sm1_parse_comments() argument
3283 DWORD tok = TOKEN_PEEK(tx); in sm1_parse_comments()
3289 tx->parse += size + 1; in sm1_parse_comments()
3294 tok = TOKEN_PEEK(tx); in sm1_parse_comments()
3299 sm1_parse_get_param(struct shader_translator *tx, DWORD *reg, DWORD *rel) in sm1_parse_get_param() argument
3301 *reg = TOKEN_NEXT(tx); in sm1_parse_get_param()
3305 if (tx->version.major < 2) in sm1_parse_get_param()
3311 *rel = TOKEN_NEXT(tx); in sm1_parse_get_param()
3353 sm1_parse_immediate(struct shader_translator *tx, in sm1_parse_immediate() argument
3361 switch (tx->insn.opcode) { in sm1_parse_immediate()
3364 memcpy(&imm->imm.d[0], tx->parse, 4 * sizeof(DWORD)); in sm1_parse_immediate()
3365 tx->parse += 4; in sm1_parse_immediate()
3369 memcpy(&imm->imm.d[0], tx->parse, 4 * sizeof(DWORD)); in sm1_parse_immediate()
3370 tx->parse += 4; in sm1_parse_immediate()
3374 memcpy(&imm->imm.d[0], tx->parse, 1 * sizeof(DWORD)); in sm1_parse_immediate()
3375 tx->parse += 1; in sm1_parse_immediate()
3384 sm1_read_dst_param(struct shader_translator *tx, in sm1_read_dst_param() argument
3390 sm1_parse_get_param(tx, &tok_dst, &tok_rel); in sm1_read_dst_param()
3399 sm1_read_src_param(struct shader_translator *tx, in sm1_read_src_param() argument
3405 sm1_parse_get_param(tx, &tok_src, &tok_rel); in sm1_read_src_param()
3415 sm1_read_semantic(struct shader_translator *tx, in sm1_read_semantic() argument
3418 const DWORD tok_usg = TOKEN_NEXT(tx); in sm1_read_semantic()
3419 const DWORD tok_dst = TOKEN_NEXT(tx); in sm1_read_semantic()
3429 sm1_parse_instruction(struct shader_translator *tx) in sm1_parse_instruction() argument
3431 struct sm1_instruction *insn = &tx->insn; in sm1_parse_instruction()
3437 sm1_parse_comments(tx, TRUE); in sm1_parse_instruction()
3438 sm1_parse_get_skip(tx); in sm1_parse_instruction()
3440 tok = TOKEN_NEXT(tx); in sm1_parse_instruction()
3447 if (insn->opcode < ARRAY_SIZE(tx->op_info_map)) { in sm1_parse_instruction()
3448 int k = tx->op_info_map[insn->opcode]; in sm1_parse_instruction()
3459 TOKEN_JUMP(tx); in sm1_parse_instruction()
3470 unsigned ver = (tx->version.major << 8) | tx->version.minor; in sm1_parse_instruction()
3479 sm1_read_dst_param(tx, &insn->dst[i], &insn->dst_rel[i]); in sm1_parse_instruction()
3481 sm1_read_src_param(tx, &insn->pred, NULL); in sm1_parse_instruction()
3483 sm1_read_src_param(tx, &insn->src[i], &insn->src_rel[i]); in sm1_parse_instruction()
3489 sm1_parse_immediate(tx, &tx->insn.src[0]); in sm1_parse_instruction()
3491 sm1_dump_instruction(insn, tx->cond_depth + tx->loop_depth); in sm1_parse_instruction()
3495 tx->predicated_activated = true; in sm1_parse_instruction()
3496 if (ureg_dst_is_undef(tx->regs.predicate_tmp)) { in sm1_parse_instruction()
3497 tx->regs.predicate_tmp = ureg_DECL_temporary(tx->ureg); in sm1_parse_instruction()
3498 tx->regs.predicate_dst = ureg_DECL_temporary(tx->ureg); in sm1_parse_instruction()
3503 hr = info->handler(tx); in sm1_parse_instruction()
3505 hr = NineTranslateInstruction_Generic(tx); in sm1_parse_instruction()
3506 tx_apply_dst0_modifiers(tx); in sm1_parse_instruction()
3509 tx->predicated_activated = false; in sm1_parse_instruction()
3512 ureg_CMP(tx->ureg, tx->regs.predicate_dst, in sm1_parse_instruction()
3513 ureg_negate(tx_src_param(tx, &insn->pred)), in sm1_parse_instruction()
3514 ureg_src(tx->regs.predicate_tmp), in sm1_parse_instruction()
3515 ureg_src(tx->regs.predicate_dst)); in sm1_parse_instruction()
3519 tx->failure = TRUE; in sm1_parse_instruction()
3520 tx->num_scratch = 0; /* reset */ in sm1_parse_instruction()
3522 TOKEN_JUMP(tx); in sm1_parse_instruction()
3531 tx_ctor(struct shader_translator *tx, struct pipe_screen *screen, struct nine_shader_info *info) in tx_ctor() argument
3535 memset(tx, 0, sizeof(*tx)); in tx_ctor()
3537 tx->info = info; in tx_ctor()
3539 tx->byte_code = info->byte_code; in tx_ctor()
3540 tx->parse = info->byte_code; in tx_ctor()
3549 memset(tx->slots_used, 0, sizeof(tx->slots_used)); in tx_ctor()
3553 tx->info->const_float_slots = 0; in tx_ctor()
3554 tx->info->const_int_slots = 0; in tx_ctor()
3555 tx->info->const_bool_slots = 0; in tx_ctor()
3565 for (i = 0; i < ARRAY_SIZE(tx->regs.rL); ++i) { in tx_ctor()
3566 tx->regs.rL[i] = ureg_dst_undef(); in tx_ctor()
3568 tx->regs.address = ureg_dst_undef(); in tx_ctor()
3569 tx->regs.a0 = ureg_dst_undef(); in tx_ctor()
3570 tx->regs.p = ureg_dst_undef(); in tx_ctor()
3571 tx->regs.oDepth = ureg_dst_undef(); in tx_ctor()
3572 tx->regs.vPos = ureg_src_undef(); in tx_ctor()
3573 tx->regs.vFace = ureg_src_undef(); in tx_ctor()
3574 for (i = 0; i < ARRAY_SIZE(tx->regs.o); ++i) in tx_ctor()
3575 tx->regs.o[i] = ureg_dst_undef(); in tx_ctor()
3576 for (i = 0; i < ARRAY_SIZE(tx->regs.oCol); ++i) in tx_ctor()
3577 tx->regs.oCol[i] = ureg_dst_undef(); in tx_ctor()
3578 for (i = 0; i < ARRAY_SIZE(tx->regs.vC); ++i) in tx_ctor()
3579 tx->regs.vC[i] = ureg_src_undef(); in tx_ctor()
3580 for (i = 0; i < ARRAY_SIZE(tx->regs.vT); ++i) in tx_ctor()
3581 tx->regs.vT[i] = ureg_src_undef(); in tx_ctor()
3583 sm1_read_version(tx); in tx_ctor()
3585 info->version = (tx->version.major << 4) | tx->version.minor; in tx_ctor()
3587 tx->num_outputs = 0; in tx_ctor()
3589 create_op_info_map(tx); in tx_ctor()
3591 tx->ureg = ureg_create(info->type); in tx_ctor()
3592 if (!tx->ureg) { in tx_ctor()
3596 tx->native_integers = GET_SHADER_CAP(INTEGERS); in tx_ctor()
3597 tx->inline_subroutines = !GET_SHADER_CAP(SUBROUTINES); in tx_ctor()
3598 tx->want_texcoord = GET_CAP(TGSI_TEXCOORD); in tx_ctor()
3599 tx->shift_wpos = !GET_CAP(TGSI_FS_COORD_PIXEL_CENTER_INTEGER); in tx_ctor()
3600 tx->texcoord_sn = tx->want_texcoord ? in tx_ctor()
3602 tx->wpos_is_sysval = GET_CAP(TGSI_FS_POSITION_IS_SYSVAL); in tx_ctor()
3603 tx->face_is_sysval_integer = GET_CAP(TGSI_FS_FACE_IS_INTEGER_SYSVAL); in tx_ctor()
3606 tx->num_constf_allowed = NINE_MAX_CONST_F; in tx_ctor()
3607 } else if (tx->version.major < 2) {/* IS_PS v1 */ in tx_ctor()
3608 tx->num_constf_allowed = 8; in tx_ctor()
3609 } else if (tx->version.major == 2) {/* IS_PS v2 */ in tx_ctor()
3610 tx->num_constf_allowed = 32; in tx_ctor()
3612 tx->num_constf_allowed = NINE_MAX_CONST_F_PS3; in tx_ctor()
3615 if (tx->version.major < 2) { in tx_ctor()
3616 tx->num_consti_allowed = 0; in tx_ctor()
3617 tx->num_constb_allowed = 0; in tx_ctor()
3619 tx->num_consti_allowed = NINE_MAX_CONST_I; in tx_ctor()
3620 tx->num_constb_allowed = NINE_MAX_CONST_B; in tx_ctor()
3623 if (info->swvp_on && tx->version.major >= 2) { in tx_ctor()
3624 tx->num_constf_allowed = 8192; in tx_ctor()
3625 tx->num_consti_allowed = 2048; in tx_ctor()
3626 tx->num_constb_allowed = 2048; in tx_ctor()
3633 tx->regs.oPos = ureg_DECL_output(tx->ureg, TGSI_SEMANTIC_POSITION, 0); in tx_ctor()
3635 ureg_property(tx->ureg, TGSI_PROPERTY_FS_COORD_ORIGIN, TGSI_FS_COORD_ORIGIN_UPPER_LEFT); in tx_ctor()
3636 if (!tx->shift_wpos) in tx_ctor()
3637 … ureg_property(tx->ureg, TGSI_PROPERTY_FS_COORD_PIXEL_CENTER, TGSI_FS_COORD_PIXEL_CENTER_INTEGER); in tx_ctor()
3640 tx->mul_zero_wins = GET_CAP(TGSI_MUL_ZERO_WINS); in tx_ctor()
3641 if (tx->mul_zero_wins) in tx_ctor()
3642 ureg_property(tx->ureg, TGSI_PROPERTY_MUL_ZERO_WINS, 1); in tx_ctor()
3659 tx_set_lconsti(tx, i, info->add_constants_defs.c_combination->const_i[i]); in tx_ctor()
3665 tx_set_lconstb(tx, i, info->add_constants_defs.c_combination->const_b[i]); in tx_ctor()
3673 tx_dtor(struct shader_translator *tx) in tx_dtor() argument
3675 if (tx->slot_map) in tx_dtor()
3676 FREE(tx->slot_map); in tx_dtor()
3677 if (tx->num_inst_labels) in tx_dtor()
3678 FREE(tx->inst_labels); in tx_dtor()
3679 FREE(tx->lconstf); in tx_dtor()
3680 FREE(tx->regs.r); in tx_dtor()
3681 FREE(tx); in tx_dtor()
3687 shader_add_vs_viewport_transform(struct shader_translator *tx) in shader_add_vs_viewport_transform() argument
3689 struct ureg_program *ureg = tx->ureg; in shader_add_vs_viewport_transform()
3701 ureg_MOV(ureg, ureg_writemask(tx->regs.oPos_out, TGSI_WRITEMASK_XYZ), ureg_src(tx->regs.oPos)); in shader_add_vs_viewport_transform()
3705 shader_add_ps_fog_stage(struct shader_translator *tx, struct ureg_src src_col) in shader_add_ps_fog_stage() argument
3707 struct ureg_program *ureg = tx->ureg; in shader_add_ps_fog_stage()
3713 if (!tx->info->fog_enable) { in shader_add_ps_fog_stage()
3718 if (tx->info->fog_mode != D3DFOG_NONE) { in shader_add_ps_fog_stage()
3719 depth = tx_scratch_scalar(tx); in shader_add_ps_fog_stage()
3721 ureg_RCP(ureg, depth, ureg_scalar(nine_get_position_input(tx), TGSI_SWIZZLE_W)); in shader_add_ps_fog_stage()
3722 … ureg_MUL(ureg, depth, ureg_src(depth), ureg_scalar(nine_get_position_input(tx), TGSI_SWIZZLE_Z)); in shader_add_ps_fog_stage()
3725 fog_color = nine_float_constant_src(tx, 32); in shader_add_ps_fog_stage()
3726 fog_params = nine_float_constant_src(tx, 33); in shader_add_ps_fog_stage()
3727 fog_factor = tx_scratch_scalar(tx); in shader_add_ps_fog_stage()
3729 if (tx->info->fog_mode == D3DFOG_LINEAR) { in shader_add_ps_fog_stage()
3734 } else if (tx->info->fog_mode == D3DFOG_EXP) { in shader_add_ps_fog_stage()
3739 } else if (tx->info->fog_mode == D3DFOG_EXP2) { in shader_add_ps_fog_stage()
3757 static void parse_shader(struct shader_translator *tx) in parse_shader() argument
3759 struct nine_shader_info *info = tx->info; in parse_shader()
3761 while (!sm1_parse_eof(tx) && !tx->failure) in parse_shader()
3762 sm1_parse_instruction(tx); in parse_shader()
3763 tx->parse++; /* for byte_size */ in parse_shader()
3765 if (tx->failure) in parse_shader()
3768 if (IS_PS && tx->version.major < 3) { in parse_shader()
3769 if (tx->version.major < 2) { in parse_shader()
3770 assert(tx->num_temp); /* there must be color output */ in parse_shader()
3772 shader_add_ps_fog_stage(tx, ureg_src(tx->regs.r[0])); in parse_shader()
3774 shader_add_ps_fog_stage(tx, ureg_src(tx->regs.oCol[0])); in parse_shader()
3778 if (IS_VS && tx->version.major < 3 && ureg_dst_is_undef(tx->regs.oFog) && info->fog_enable) { in parse_shader()
3779 tx->regs.oFog = ureg_DECL_output(tx->ureg, TGSI_SEMANTIC_GENERIC, 16); in parse_shader()
3780 … ureg_MOV(tx->ureg, ureg_writemask(tx->regs.oFog, TGSI_WRITEMASK_X), ureg_imm1f(tx->ureg, 0.0f)); in parse_shader()
3784 ureg_property(tx->ureg, TGSI_PROPERTY_VS_WINDOW_SPACE_POSITION, TRUE); in parse_shader()
3786 if (IS_VS && !ureg_dst_is_undef(tx->regs.oPts)) { in parse_shader()
3787 struct ureg_dst oPts = ureg_DECL_output(tx->ureg, TGSI_SEMANTIC_PSIZE, 0); in parse_shader()
3788 …ureg_MAX(tx->ureg, tx->regs.oPts, ureg_src(tx->regs.oPts), ureg_imm1f(tx->ureg, info->point_size_m… in parse_shader()
3789 … ureg_MIN(tx->ureg, oPts, ureg_src(tx->regs.oPts), ureg_imm1f(tx->ureg, info->point_size_max)); in parse_shader()
3794 shader_add_vs_viewport_transform(tx); in parse_shader()
3796 ureg_END(tx->ureg); in parse_shader()
3919 struct shader_translator *tx; in nine_translate_shader() local
3927 tx = MALLOC_STRUCT(shader_translator); in nine_translate_shader()
3928 if (!tx) in nine_translate_shader()
3931 if (tx_ctor(tx, screen, info) == E_OUTOFMEMORY) { in nine_translate_shader()
3938 if (((tx->version.major << 16) | tx->version.minor) > 0x00030000) { in nine_translate_shader()
3941 tx->version.major, tx->version.minor); in nine_translate_shader()
3944 if (tx->processor != processor) { in nine_translate_shader()
3946 DBG("Shader type mismatch: %u / %u !\n", tx->processor, processor); in nine_translate_shader()
3950 tx->version.major, tx->version.minor); in nine_translate_shader()
3952 parse_shader(tx); in nine_translate_shader()
3954 if (tx->failure) { in nine_translate_shader()
3959 ureg_destroy(tx->ureg); in nine_translate_shader()
3965 if (!tx->indirect_const_access && !info->swvp_on && tx->num_slots > 0) { in nine_translate_shader()
3971 ureg_destroy(tx->ureg); in nine_translate_shader()
3973 if (tx->num_inst_labels) in nine_translate_shader()
3974 FREE(tx->inst_labels); in nine_translate_shader()
3975 FREE(tx->lconstf); in nine_translate_shader()
3976 FREE(tx->regs.r); in nine_translate_shader()
3981 if (tx->slots_used[i]) { in nine_translate_shader()
3997 if (tx->slots_used[i]) { in nine_translate_shader()
4009 if (tx_ctor(tx, screen, info) == E_OUTOFMEMORY) { in nine_translate_shader()
4013 tx->slot_map = slot_map; in nine_translate_shader()
4014 parse_shader(tx); in nine_translate_shader()
4015 assert(!tx->failure); in nine_translate_shader()
4023 assert(j == tx->num_slots); in nine_translate_shader()
4028 if (tx->num_lconstf && tx->indirect_const_access) { in nine_translate_shader()
4036 data = MALLOC(tx->num_lconstf * 4 * sizeof(float)); in nine_translate_shader()
4041 indices = MALLOC(tx->num_lconstf * sizeof(indices[0])); in nine_translate_shader()
4046 for (n = 0; n < tx->num_lconstf; ++n) { in nine_translate_shader()
4047 for (k = 0, i = 0; i < tx->num_lconstf; ++i) { in nine_translate_shader()
4048 if (tx->lconstf[i].idx < tx->lconstf[k].idx) in nine_translate_shader()
4051 indices[n] = tx->lconstf[k].idx; in nine_translate_shader()
4052 memcpy(&data[n * 4], &tx->lconstf[k].f[0], 4 * sizeof(float)); in nine_translate_shader()
4053 tx->lconstf[k].idx = INT_MAX; in nine_translate_shader()
4057 for (n = 1, i = 1; i < tx->num_lconstf; ++i) in nine_translate_shader()
4069 for (i = 1; i < tx->num_lconstf; ++i) { in nine_translate_shader()
4092 if (tx->indirect_const_access) { /* vs only */ in nine_translate_shader()
4094 tx->num_slots = MAX2(tx->num_slots, device->max_vs_const_f); in nine_translate_shader()
4098 info->const_used_size = sizeof(float[4]) * tx->num_slots; in nine_translate_shader()
4099 if (tx->num_slots) in nine_translate_shader()
4100 ureg_DECL_constant2D(tx->ureg, 0, tx->num_slots-1, 0); in nine_translate_shader()
4102 ureg_DECL_constant2D(tx->ureg, 0, 4095, 0); in nine_translate_shader()
4103 ureg_DECL_constant2D(tx->ureg, 0, 4095, 1); in nine_translate_shader()
4104 ureg_DECL_constant2D(tx->ureg, 0, 2047, 2); in nine_translate_shader()
4105 ureg_DECL_constant2D(tx->ureg, 0, 511, 3); in nine_translate_shader()
4109 ureg_DECL_constant2D(tx->ureg, 0, 2, 4); /* Viewport data */ in nine_translate_shader()
4112 const struct tgsi_token *toks = ureg_get_tokens(tx->ureg, NULL); in nine_translate_shader()
4119 tx->output_info, in nine_translate_shader()
4120 tx->num_outputs, in nine_translate_shader()
4122 info->cso = nine_create_shader_with_so_and_destroy(tx->ureg, pipe, &(info->so)); in nine_translate_shader()
4124 info->cso = nine_create_shader_with_so_and_destroy(tx->ureg, pipe, NULL); in nine_translate_shader()
4134 info->byte_size = (tx->parse - tx->byte_code) * sizeof(DWORD); in nine_translate_shader()
4138 tx_dtor(tx); in nine_translate_shader()