• 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()
826 TEX_if_fetch4(struct shader_translator *tx, struct ureg_dst dst, in TEX_if_fetch4() argument
831 struct ureg_src src_tg4[3] = {src0, ureg_imm1f(tx->ureg, 0.f), src1}; in TEX_if_fetch4()
833 if (!(tx->info->fetch4 & (1 << idx))) in TEX_if_fetch4()
838 tmp = tx_scratch(tx); in TEX_if_fetch4()
839 ureg_tex_insn(tx->ureg, TGSI_OPCODE_TG4, &tmp, 1, target, TGSI_RETURN_TYPE_FLOAT, in TEX_if_fetch4()
841 ureg_MOV(tx->ureg, dst, ureg_swizzle(ureg_src(tmp), NINE_SWIZZLE4(Z, X, Y, W))); in TEX_if_fetch4()
854 apply_ps1x_projection(struct shader_translator *tx, struct ureg_dst dst, in apply_ps1x_projection() argument
858 unsigned dim = 1 + ((tx->info->projected >> (2 * idx)) & 3); in apply_ps1x_projection()
862 ureg_MOV(tx->ureg, dst, src); in apply_ps1x_projection()
864 tmp = tx_scratch_scalar(tx); in apply_ps1x_projection()
865 ureg_RCP(tx->ureg, tmp, ureg_scalar(src, dim-1)); in apply_ps1x_projection()
866 ureg_MUL(tx->ureg, dst, tx_src_scalar(tmp), src); in apply_ps1x_projection()
871 TEX_with_ps1x_projection(struct shader_translator *tx, struct ureg_dst dst, in TEX_with_ps1x_projection() argument
875 unsigned dim = 1 + ((tx->info->projected >> (2 * idx)) & 3); in TEX_with_ps1x_projection()
877 boolean shadow = !!(tx->info->sampler_mask_shadow & (1 << idx)); in TEX_with_ps1x_projection()
884 ureg_TEX(tx->ureg, dst, target, src0, src1); in TEX_with_ps1x_projection()
886 ureg_TXP(tx->ureg, dst, target, src0, src1); in TEX_with_ps1x_projection()
888 tmp = tx_scratch(tx); in TEX_with_ps1x_projection()
889 apply_ps1x_projection(tx, tmp, src0, idx); in TEX_with_ps1x_projection()
890 ureg_TEX(tx->ureg, dst, target, ureg_src(tmp), src1); in TEX_with_ps1x_projection()
895 tx_texcoord_alloc(struct shader_translator *tx, INT idx) in tx_texcoord_alloc() argument
898 assert(idx >= 0 && idx < ARRAY_SIZE(tx->regs.vT)); in tx_texcoord_alloc()
899 if (ureg_src_is_undef(tx->regs.vT[idx])) in tx_texcoord_alloc()
900 tx->regs.vT[idx] = ureg_DECL_fs_input(tx->ureg, tx->texcoord_sn, idx, in tx_texcoord_alloc()
905 tx_bgnloop(struct shader_translator *tx) in tx_bgnloop() argument
907 tx->loop_depth++; in tx_bgnloop()
908 if (tx->loop_depth_max < tx->loop_depth) in tx_bgnloop()
909 tx->loop_depth_max = tx->loop_depth; in tx_bgnloop()
910 assert(tx->loop_depth < NINE_MAX_LOOP_DEPTH); in tx_bgnloop()
911 return &tx->loop_labels[tx->loop_depth - 1]; in tx_bgnloop()
915 tx_endloop(struct shader_translator *tx) in tx_endloop() argument
917 assert(tx->loop_depth); in tx_endloop()
918 tx->loop_depth--; in tx_endloop()
919 ureg_fixup_label(tx->ureg, tx->loop_labels[tx->loop_depth], in tx_endloop()
920 ureg_get_instruction_number(tx->ureg)); in tx_endloop()
921 return &tx->loop_labels[tx->loop_depth]; in tx_endloop()
925 tx_get_loopctr(struct shader_translator *tx, boolean loop_or_rep) in tx_get_loopctr() argument
927 const unsigned l = tx->loop_depth - 1; in tx_get_loopctr()
929 if (!tx->loop_depth) in tx_get_loopctr()
935 if (ureg_dst_is_undef(tx->regs.rL[l])) { in tx_get_loopctr()
937 tx->regs.rL[l] = ureg_DECL_local_temporary(tx->ureg); in tx_get_loopctr()
938 tx->loop_or_rep[l] = loop_or_rep; in tx_get_loopctr()
941 assert(tx->loop_or_rep[l] == loop_or_rep); in tx_get_loopctr()
943 return tx->regs.rL[l]; in tx_get_loopctr()
947 tx_get_loopal(struct shader_translator *tx) in tx_get_loopal() argument
949 int loop_level = tx->loop_depth - 1; in tx_get_loopal()
953 if (tx->loop_or_rep[loop_level]) in tx_get_loopal()
955 return ureg_scalar(ureg_src(tx->regs.rL[loop_level]), TGSI_SWIZZLE_Y); in tx_get_loopal()
964 tx_cond(struct shader_translator *tx) in tx_cond() argument
966 assert(tx->cond_depth <= NINE_MAX_COND_DEPTH); in tx_cond()
967 tx->cond_depth++; in tx_cond()
968 return &tx->cond_labels[tx->cond_depth - 1]; in tx_cond()
972 tx_elsecond(struct shader_translator *tx) in tx_elsecond() argument
974 assert(tx->cond_depth); in tx_elsecond()
975 return &tx->cond_labels[tx->cond_depth - 1]; in tx_elsecond()
979 tx_endcond(struct shader_translator *tx) in tx_endcond() argument
981 assert(tx->cond_depth); in tx_endcond()
982 tx->cond_depth--; in tx_endcond()
983 ureg_fixup_label(tx->ureg, tx->cond_labels[tx->cond_depth], in tx_endcond()
984 ureg_get_instruction_number(tx->ureg)); in tx_endcond()
994 nine_get_position_input(struct shader_translator *tx) in nine_get_position_input() argument
996 struct ureg_program *ureg = tx->ureg; in nine_get_position_input()
998 if (tx->wpos_is_sysval) in nine_get_position_input()
1006 tx_src_param(struct shader_translator *tx, const struct sm1_src_param *param) in tx_src_param() argument
1008 struct ureg_program *ureg = tx->ureg; in tx_src_param()
1013 (param->file == D3DSPR_INPUT && tx->version.major == 3)); in tx_src_param()
1018 tx_temp_alloc(tx, param->idx); in tx_src_param()
1019 src = ureg_src(tx->regs.r[param->idx]); in tx_src_param()
1027 assert(!ureg_dst_is_undef(tx->regs.a0)); in tx_src_param()
1030 if (tx->version.major < 2 && tx->version.minor < 2) in tx_src_param()
1031 ureg_ARL(ureg, tx->regs.address, ureg_src(tx->regs.a0)); in tx_src_param()
1033 ureg_ARR(ureg, tx->regs.address, ureg_src(tx->regs.a0)); in tx_src_param()
1034 src = ureg_src(tx->regs.address); in tx_src_param()
1036 if (tx->version.major < 2 && tx->version.minor < 4) { in tx_src_param()
1038 src = ureg_src(tx->regs.tS[param->idx]); in tx_src_param()
1040 tx_texcoord_alloc(tx, param->idx); in tx_src_param()
1041 src = tx->regs.vT[param->idx]; in tx_src_param()
1049 if (tx->version.major < 3) { in tx_src_param()
1053 tx->info->force_color_in_centroid ? in tx_src_param()
1068 if (ureg_src_is_undef(tx->regs.v_consecutive)) { in tx_src_param()
1070 tx->regs.v_consecutive = ureg_src(ureg_DECL_array_temporary(ureg, 10, 0)); in tx_src_param()
1072 if (!ureg_src_is_undef(tx->regs.v[i])) in tx_src_param()
1073 … ureg_MOV(ureg, ureg_dst_array_offset(ureg_dst(tx->regs.v_consecutive), i), tx->regs.v[i]); in tx_src_param()
1075 …ureg_MOV(ureg, ureg_dst_array_offset(ureg_dst(tx->regs.v_consecutive), i), ureg_imm4f(ureg, 0.0f, … in tx_src_param()
1078 src = ureg_src_array_offset(tx->regs.v_consecutive, param->idx); in tx_src_param()
1080 assert(param->idx < ARRAY_SIZE(tx->regs.v)); in tx_src_param()
1081 src = tx->regs.v[param->idx]; in tx_src_param()
1086 src = ureg_src_indirect(src, tx_src_param(tx, param->rel)); in tx_src_param()
1089 if (ureg_dst_is_undef(tx->regs.predicate)) { in tx_src_param()
1091 tx->failure = TRUE; in tx_src_param()
1092 tx->regs.predicate = ureg_DECL_temporary(tx->ureg); in tx_src_param()
1094 src = ureg_src(tx->regs.predicate); in tx_src_param()
1102 if (param->rel || !tx_lconstf(tx, &src, param->idx)) { in tx_src_param()
1103 src = nine_float_constant_src(tx, param->idx); in tx_src_param()
1105 tx->indirect_const_access = TRUE; in tx_src_param()
1106 src = ureg_src_indirect(src, tx_src_param(tx, param->rel)); in tx_src_param()
1109 if (!IS_VS && tx->version.major < 2) { in tx_src_param()
1111 tmp = tx_scratch(tx); in tx_src_param()
1126 if (!tx_lconsti(tx, &src, param->idx)) in tx_src_param()
1127 src = nine_integer_constant_src(tx, param->idx); in tx_src_param()
1130 if (!tx_lconstb(tx, &src, param->idx)) in tx_src_param()
1131 src = nine_boolean_constant_src(tx, param->idx); in tx_src_param()
1134 if (ureg_dst_is_undef(tx->regs.address)) in tx_src_param()
1135 tx->regs.address = ureg_DECL_address(ureg); in tx_src_param()
1136 if (!tx->native_integers) in tx_src_param()
1137 ureg_ARR(ureg, tx->regs.address, tx_get_loopal(tx)); in tx_src_param()
1139 ureg_UARL(ureg, tx->regs.address, tx_get_loopal(tx)); in tx_src_param()
1140 src = ureg_src(tx->regs.address); in tx_src_param()
1145 if (ureg_src_is_undef(tx->regs.vPos)) in tx_src_param()
1146 tx->regs.vPos = nine_get_position_input(tx); in tx_src_param()
1147 if (tx->shift_wpos) { in tx_src_param()
1149 struct ureg_dst wpos = tx_scratch(tx); in tx_src_param()
1150 ureg_ADD(ureg, wpos, tx->regs.vPos, in tx_src_param()
1154 src = tx->regs.vPos; in tx_src_param()
1158 if (ureg_src_is_undef(tx->regs.vFace)) { in tx_src_param()
1159 if (tx->face_is_sysval_integer) { in tx_src_param()
1161 tx->regs.vFace = in tx_src_param()
1165 ureg_UCMP(ureg, tmp, ureg_scalar(tx->regs.vFace, TGSI_SWIZZLE_X), in tx_src_param()
1167 tx->regs.vFace = ureg_src(tmp); in tx_src_param()
1169 tx->regs.vFace = ureg_DECL_fs_input(ureg, in tx_src_param()
1173 tx->regs.vFace = ureg_scalar(tx->regs.vFace, TGSI_SWIZZLE_X); in tx_src_param()
1175 src = tx->regs.vFace; in tx_src_param()
1190 tmp = tx_scratch(tx); in tx_src_param()
1197 tmp = tx_scratch(tx); in tx_src_param()
1225 tmp = tx_scratch(tx); in tx_src_param()
1230 tmp = tx_scratch(tx); in tx_src_param()
1235 if (tx->native_integers && param->file == D3DSPR_CONSTBOOL) { in tx_src_param()
1236 tmp = tx_scratch(tx); in tx_src_param()
1241 tmp = tx_scratch(tx); in tx_src_param()
1247 tmp = tx_scratch(tx); in tx_src_param()
1256 tmp = tx_scratch(tx); in tx_src_param()
1261 tmp = tx_scratch(tx); in tx_src_param()
1266 tmp = tx_scratch(tx); in tx_src_param()
1271 tmp = tx_scratch(tx); in tx_src_param()
1284 _tx_dst_param(struct shader_translator *tx, const struct sm1_dst_param *param) in _tx_dst_param() argument
1292 tx_temp_alloc(tx, param->idx); in _tx_dst_param()
1293 dst = tx->regs.r[param->idx]; in _tx_dst_param()
1298 if (tx->version.major < 2 && !IS_VS) { in _tx_dst_param()
1299 if (ureg_dst_is_undef(tx->regs.tS[param->idx])) in _tx_dst_param()
1300 tx->regs.tS[param->idx] = ureg_DECL_temporary(tx->ureg); in _tx_dst_param()
1301 dst = tx->regs.tS[param->idx]; in _tx_dst_param()
1303 if (!IS_VS && tx->insn.opcode == D3DSIO_TEXKILL) { /* maybe others, too */ in _tx_dst_param()
1304 tx_texcoord_alloc(tx, param->idx); in _tx_dst_param()
1305 dst = ureg_dst(tx->regs.vT[param->idx]); in _tx_dst_param()
1307 tx_addr_alloc(tx, param->idx); in _tx_dst_param()
1308 dst = tx->regs.a0; in _tx_dst_param()
1315 if (ureg_dst_is_undef(tx->regs.oPos)) in _tx_dst_param()
1316 tx->regs.oPos = in _tx_dst_param()
1317 ureg_DECL_output(tx->ureg, TGSI_SEMANTIC_POSITION, 0); in _tx_dst_param()
1318 dst = tx->regs.oPos; in _tx_dst_param()
1321 if (ureg_dst_is_undef(tx->regs.oFog)) in _tx_dst_param()
1322 tx->regs.oFog = in _tx_dst_param()
1323 ureg_saturate(ureg_DECL_output(tx->ureg, TGSI_SEMANTIC_GENERIC, 16)); in _tx_dst_param()
1324 dst = tx->regs.oFog; in _tx_dst_param()
1327 if (ureg_dst_is_undef(tx->regs.oPts)) in _tx_dst_param()
1328 tx->regs.oPts = ureg_DECL_temporary(tx->ureg); in _tx_dst_param()
1329 dst = tx->regs.oPts; in _tx_dst_param()
1338 if (tx->version.major < 3) { in _tx_dst_param()
1340 dst = ureg_DECL_output(tx->ureg, tx->texcoord_sn, param->idx); in _tx_dst_param()
1343 assert(param->idx < ARRAY_SIZE(tx->regs.o)); in _tx_dst_param()
1344 dst = tx->regs.o[param->idx]; in _tx_dst_param()
1351 tx->info->rt_mask |= 1 << param->idx; in _tx_dst_param()
1352 if (ureg_dst_is_undef(tx->regs.oCol[param->idx])) { in _tx_dst_param()
1354 if (!IS_VS && tx->version.major < 3 && param->idx == 0) { in _tx_dst_param()
1355 tx->regs.oCol[0] = ureg_DECL_temporary(tx->ureg); in _tx_dst_param()
1357 tx->regs.oCol[param->idx] = in _tx_dst_param()
1358 ureg_DECL_output(tx->ureg, TGSI_SEMANTIC_COLOR, param->idx); in _tx_dst_param()
1361 dst = tx->regs.oCol[param->idx]; in _tx_dst_param()
1362 if (IS_VS && tx->version.major < 3) in _tx_dst_param()
1367 if (ureg_dst_is_undef(tx->regs.oDepth)) in _tx_dst_param()
1368 tx->regs.oDepth = in _tx_dst_param()
1369 ureg_DECL_output_masked(tx->ureg, TGSI_SEMANTIC_POSITION, 0, in _tx_dst_param()
1371 dst = tx->regs.oDepth; /* XXX: must write .z component */ in _tx_dst_param()
1374 if (ureg_dst_is_undef(tx->regs.predicate)) in _tx_dst_param()
1375 tx->regs.predicate = ureg_DECL_temporary(tx->ureg); in _tx_dst_param()
1376 dst = tx->regs.predicate; in _tx_dst_param()
1386 dst = ureg_dst_indirect(dst, tx_src_param(tx, param->rel)); in _tx_dst_param()
1393 if (tx->predicated_activated) { in _tx_dst_param()
1394 tx->regs.predicate_dst = dst; in _tx_dst_param()
1395 dst = tx->regs.predicate_tmp; in _tx_dst_param()
1402 tx_dst_param(struct shader_translator *tx, const struct sm1_dst_param *param) in tx_dst_param() argument
1405 tx->regs.tdst = ureg_writemask(tx_scratch(tx), param->mask); in tx_dst_param()
1406 return tx->regs.tdst; in tx_dst_param()
1408 return _tx_dst_param(tx, param); in tx_dst_param()
1412 tx_apply_dst0_modifiers(struct shader_translator *tx) in tx_apply_dst0_modifiers() argument
1417 if (!tx->insn.ndst || !tx->insn.dst[0].shift || tx->insn.opcode == D3DSIO_TEXKILL) in tx_apply_dst0_modifiers()
1419 rdst = _tx_dst_param(tx, &tx->insn.dst[0]); in tx_apply_dst0_modifiers()
1423 if (tx->insn.dst[0].shift < 0) in tx_apply_dst0_modifiers()
1424 f = 1.0f / (1 << -tx->insn.dst[0].shift); in tx_apply_dst0_modifiers()
1426 f = 1 << tx->insn.dst[0].shift; in tx_apply_dst0_modifiers()
1428 ureg_MUL(tx->ureg, rdst, ureg_src(tx->regs.tdst), ureg_imm1f(tx->ureg, f)); in tx_apply_dst0_modifiers()
1432 tx_dst_param_as_src(struct shader_translator *tx, const struct sm1_dst_param *param) in tx_dst_param_as_src() argument
1445 assert(param->idx < ARRAY_SIZE(tx->regs.v)); in tx_dst_param_as_src()
1446 src = tx->regs.v[param->idx]; in tx_dst_param_as_src()
1450 src = ureg_src(tx_dst_param(tx, param)); in tx_dst_param_as_src()
1454 src = ureg_src_indirect(src, tx_src_param(tx, param->rel)); in tx_dst_param_as_src()
1475 NineTranslateInstruction_Mkxn(struct shader_translator *tx, const unsigned k, const unsigned n) in NineTranslateInstruction_Mkxn() argument
1477 struct ureg_program *ureg = tx->ureg; in NineTranslateInstruction_Mkxn()
1480 struct sm1_src_param *src_mat = &tx->insn.src[1]; in NineTranslateInstruction_Mkxn()
1483 dst = tx_dst_param(tx, &tx->insn.dst[0]); in NineTranslateInstruction_Mkxn()
1484 src[0] = tx_src_param(tx, &tx->insn.src[0]); in NineTranslateInstruction_Mkxn()
1490 src[1] = tx_src_param(tx, src_mat); in NineTranslateInstruction_Mkxn()
1642 NineTranslateInstruction_##name( struct shader_translator *tx )
1656 struct ureg_program *ureg = tx->ureg; in DECL_SPECIAL()
1657 struct ureg_dst dst = tx_dst_param(tx, &tx->insn.dst[0]); in DECL_SPECIAL()
1658 struct ureg_src src0 = tx_src_param(tx, &tx->insn.src[0]); in DECL_SPECIAL()
1659 struct ureg_src src1 = tx_src_param(tx, &tx->insn.src[1]); in DECL_SPECIAL()
1667 struct ureg_program *ureg = tx->ureg; in DECL_SPECIAL()
1668 struct ureg_dst dst = tx_dst_param(tx, &tx->insn.dst[0]); in DECL_SPECIAL()
1669 struct ureg_src src = tx_src_param(tx, &tx->insn.src[0]); in DECL_SPECIAL()
1677 struct ureg_program *ureg = tx->ureg; in DECL_SPECIAL()
1678 struct ureg_dst dst = tx_dst_param(tx, &tx->insn.dst[0]); in DECL_SPECIAL()
1679 struct ureg_src src0 = tx_src_param(tx, &tx->insn.src[0]); in DECL_SPECIAL()
1680 struct ureg_src src1 = tx_src_param(tx, &tx->insn.src[1]); in DECL_SPECIAL()
1700 return NineTranslateInstruction_Mkxn(tx, 4, 4); in DECL_SPECIAL()
1705 return NineTranslateInstruction_Mkxn(tx, 4, 3); in DECL_SPECIAL()
1710 return NineTranslateInstruction_Mkxn(tx, 3, 4); in DECL_SPECIAL()
1715 return NineTranslateInstruction_Mkxn(tx, 3, 3); in DECL_SPECIAL()
1720 return NineTranslateInstruction_Mkxn(tx, 3, 2); in DECL_SPECIAL()
1725 ureg_CMP(tx->ureg, tx_dst_param(tx, &tx->insn.dst[0]), in DECL_SPECIAL()
1726 tx_src_param(tx, &tx->insn.src[0]), in DECL_SPECIAL()
1727 tx_src_param(tx, &tx->insn.src[2]), in DECL_SPECIAL()
1728 tx_src_param(tx, &tx->insn.src[1])); in DECL_SPECIAL()
1734 struct ureg_dst dst = tx_dst_param(tx, &tx->insn.dst[0]); in DECL_SPECIAL()
1744 …if (tx->insn.coissue && tx->version.major == 1 && tx->version.minor < 4 && tx->insn.dst[0].mask !=… in DECL_SPECIAL()
1745 ureg_MOV(tx->ureg, in DECL_SPECIAL()
1746 dst, tx_src_param(tx, &tx->insn.src[1])); in DECL_SPECIAL()
1750 cnd = tx_src_param(tx, &tx->insn.src[0]); in DECL_SPECIAL()
1751 cgt = tx_scratch(tx); in DECL_SPECIAL()
1753 if (tx->version.major == 1 && tx->version.minor < 4) in DECL_SPECIAL()
1756 ureg_SGT(tx->ureg, cgt, cnd, ureg_imm1f(tx->ureg, 0.5f)); in DECL_SPECIAL()
1758 ureg_CMP(tx->ureg, dst, ureg_negate(ureg_src(cgt)), in DECL_SPECIAL()
1759 tx_src_param(tx, &tx->insn.src[1]), in DECL_SPECIAL()
1760 tx_src_param(tx, &tx->insn.src[2])); in DECL_SPECIAL()
1766 assert(tx->insn.src[0].idx < tx->num_inst_labels); in DECL_SPECIAL()
1767 ureg_CAL(tx->ureg, &tx->inst_labels[tx->insn.src[0].idx]); in DECL_SPECIAL()
1773 struct ureg_program *ureg = tx->ureg; in DECL_SPECIAL()
1774 struct ureg_src src = tx_src_param(tx, &tx->insn.src[1]); in DECL_SPECIAL()
1776 if (!tx->native_integers) in DECL_SPECIAL()
1777 ureg_IF(ureg, src, tx_cond(tx)); in DECL_SPECIAL()
1779 ureg_UIF(ureg, src, tx_cond(tx)); in DECL_SPECIAL()
1780 ureg_CAL(ureg, &tx->inst_labels[tx->insn.src[0].idx]); in DECL_SPECIAL()
1781 tx_endcond(tx); in DECL_SPECIAL()
1788 struct ureg_program *ureg = tx->ureg; in DECL_SPECIAL()
1790 struct ureg_src src = tx_src_param(tx, &tx->insn.src[1]); in DECL_SPECIAL()
1795 label = tx_bgnloop(tx); in DECL_SPECIAL()
1796 ctr = tx_get_loopctr(tx, TRUE); in DECL_SPECIAL()
1801 ureg_BGNLOOP(tx->ureg, label); in DECL_SPECIAL()
1802 tmp = tx_scratch_scalar(tx); in DECL_SPECIAL()
1808 if (!tx->native_integers) { in DECL_SPECIAL()
1812 ureg_IF(ureg, tx_src_scalar(tmp), tx_cond(tx)); in DECL_SPECIAL()
1816 ureg_UIF(ureg, tx_src_scalar(tmp), tx_cond(tx)); in DECL_SPECIAL()
1819 tx_endcond(tx); in DECL_SPECIAL()
1830 if (*(tx->parse_next) != NINED3DSP_END) { in DECL_SPECIAL()
1831 ureg_RET(tx->ureg); in DECL_SPECIAL()
1838 struct ureg_program *ureg = tx->ureg; in DECL_SPECIAL()
1839 struct ureg_dst ctr = tx_get_loopctr(tx, TRUE); in DECL_SPECIAL()
1850 if (!tx->native_integers) { in DECL_SPECIAL()
1857 ureg_ENDLOOP(tx->ureg, tx_endloop(tx)); in DECL_SPECIAL()
1863 unsigned k = tx->num_inst_labels; in DECL_SPECIAL()
1864 unsigned n = tx->insn.src[0].idx; in DECL_SPECIAL()
1867 tx->inst_labels = REALLOC(tx->inst_labels, in DECL_SPECIAL()
1868 k * sizeof(tx->inst_labels[0]), in DECL_SPECIAL()
1869 n * sizeof(tx->inst_labels[0])); in DECL_SPECIAL()
1871 tx->inst_labels[n] = ureg_get_instruction_number(tx->ureg); in DECL_SPECIAL()
1877 struct ureg_program *ureg = tx->ureg; in DECL_SPECIAL()
1878 struct ureg_dst dst = tx_dst_param(tx, &tx->insn.dst[0]); in DECL_SPECIAL()
1879 struct ureg_src src = tx_src_param(tx, &tx->insn.src[0]); in DECL_SPECIAL()
1880 struct ureg_dst tmp = tx_scratch_scalar(tx); in DECL_SPECIAL()
1898 ureg_SSG(tx->ureg, in DECL_SPECIAL()
1899 tx_dst_param(tx, &tx->insn.dst[0]), in DECL_SPECIAL()
1900 tx_src_param(tx, &tx->insn.src[0])); in DECL_SPECIAL()
1906 struct ureg_program *ureg = tx->ureg; in DECL_SPECIAL()
1908 struct ureg_src rep = tx_src_param(tx, &tx->insn.src[0]); in DECL_SPECIAL()
1913 label = tx_bgnloop(tx); in DECL_SPECIAL()
1914 ctr = ureg_writemask(tx_get_loopctr(tx, FALSE), NINED3DSP_WRITEMASK_0); in DECL_SPECIAL()
1923 tmp = tx_scratch_scalar(tx); in DECL_SPECIAL()
1928 if (!tx->native_integers) { in DECL_SPECIAL()
1932 ureg_IF(ureg, tx_src_scalar(tmp), tx_cond(tx)); in DECL_SPECIAL()
1936 ureg_UIF(ureg, tx_src_scalar(tmp), tx_cond(tx)); in DECL_SPECIAL()
1939 tx_endcond(tx); in DECL_SPECIAL()
1947 struct ureg_program *ureg = tx->ureg; in DECL_SPECIAL()
1948 struct ureg_dst ctr = tx_get_loopctr(tx, FALSE); in DECL_SPECIAL()
1953 if (!tx->native_integers) in DECL_SPECIAL()
1958 ureg_ENDLOOP(tx->ureg, tx_endloop(tx)); in DECL_SPECIAL()
1964 tx_endcond(tx); in DECL_SPECIAL()
1965 ureg_ENDIF(tx->ureg); in DECL_SPECIAL()
1971 struct ureg_src src = tx_src_param(tx, &tx->insn.src[0]); in DECL_SPECIAL()
1973 if (tx->native_integers && tx->insn.src[0].file == D3DSPR_CONSTBOOL) in DECL_SPECIAL()
1974 ureg_UIF(tx->ureg, src, tx_cond(tx)); in DECL_SPECIAL()
1976 ureg_IF(tx->ureg, src, tx_cond(tx)); in DECL_SPECIAL()
1999 const unsigned cmp_op = sm1_insn_flags_to_tgsi_setop(tx->insn.flags); in DECL_SPECIAL()
2001 struct ureg_dst tmp = ureg_writemask(tx_scratch(tx), TGSI_WRITEMASK_X); in DECL_SPECIAL()
2002 src[0] = tx_src_param(tx, &tx->insn.src[0]); in DECL_SPECIAL()
2003 src[1] = tx_src_param(tx, &tx->insn.src[1]); in DECL_SPECIAL()
2004 ureg_insn(tx->ureg, cmp_op, &tmp, 1, src, 2, 0); in DECL_SPECIAL()
2005 ureg_IF(tx->ureg, ureg_scalar(ureg_src(tmp), TGSI_SWIZZLE_X), tx_cond(tx)); in DECL_SPECIAL()
2011 ureg_ELSE(tx->ureg, tx_elsecond(tx)); in DECL_SPECIAL()
2017 const unsigned cmp_op = sm1_insn_flags_to_tgsi_setop(tx->insn.flags); in DECL_SPECIAL()
2019 struct ureg_dst tmp = ureg_writemask(tx_scratch(tx), TGSI_WRITEMASK_X); in DECL_SPECIAL()
2020 src[0] = tx_src_param(tx, &tx->insn.src[0]); in DECL_SPECIAL()
2021 src[1] = tx_src_param(tx, &tx->insn.src[1]); in DECL_SPECIAL()
2022 ureg_insn(tx->ureg, cmp_op, &tmp, 1, src, 2, 0); in DECL_SPECIAL()
2023 ureg_IF(tx->ureg, ureg_scalar(ureg_src(tmp), TGSI_SWIZZLE_X), tx_cond(tx)); in DECL_SPECIAL()
2024 ureg_BRK(tx->ureg); in DECL_SPECIAL()
2025 tx_endcond(tx); in DECL_SPECIAL()
2026 ureg_ENDIF(tx->ureg); in DECL_SPECIAL()
2242 struct ureg_program *ureg = tx->ureg; in DECL_SPECIAL()
2247 sm1_read_semantic(tx, &sem); in DECL_SPECIAL()
2258 if (tx->version.major >= 3) in DECL_SPECIAL()
2269 tx->info->sampler_mask |= m; in DECL_SPECIAL()
2270 tx->sampler_targets[sem.reg.idx] = (tx->info->sampler_mask_shadow & m) ? in DECL_SPECIAL()
2276 sm1_declusage_to_tgsi(&tgsi, tx->want_texcoord, &sem); in DECL_SPECIAL()
2281 assert(sem.reg.idx < ARRAY_SIZE(tx->info->input_map)); in DECL_SPECIAL()
2282 tx->info->input_map[sem.reg.idx] = sm1_to_nine_declusage(&sem); in DECL_SPECIAL()
2283 tx->info->num_inputs = MAX2(tx->info->num_inputs, sem.reg.idx + 1); in DECL_SPECIAL()
2286 if (tx->version.major >= 3) { in DECL_SPECIAL()
2290 tx->info->position_t = TRUE; in DECL_SPECIAL()
2291 assert(sem.reg.idx < ARRAY_SIZE(tx->regs.o)); in DECL_SPECIAL()
2292 … assert(ureg_dst_is_undef(tx->regs.o[sem.reg.idx]) && "Nine doesn't support yet packing"); in DECL_SPECIAL()
2293 tx->regs.o[sem.reg.idx] = ureg_DECL_output_masked( in DECL_SPECIAL()
2295 nine_record_outputs(tx, sem.usage, sem.usage_idx, sem.reg.mask, sem.reg.idx); in DECL_SPECIAL()
2296 … if (tx->info->process_vertices && sem.usage == D3DDECLUSAGE_POSITION && sem.usage_idx == 0) { in DECL_SPECIAL()
2297 tx->regs.oPos_out = tx->regs.o[sem.reg.idx]; in DECL_SPECIAL()
2298 tx->regs.o[sem.reg.idx] = ureg_DECL_temporary(ureg); in DECL_SPECIAL()
2299 tx->regs.oPos = tx->regs.o[sem.reg.idx]; in DECL_SPECIAL()
2303 tx->regs.o[sem.reg.idx] = ureg_DECL_temporary(ureg); in DECL_SPECIAL()
2304 tx->regs.oPts = tx->regs.o[sem.reg.idx]; in DECL_SPECIAL()
2308 if (is_input && tx->version.major >= 3) { in DECL_SPECIAL()
2311 assert(sem.reg.idx < ARRAY_SIZE(tx->regs.v)); in DECL_SPECIAL()
2312 … assert(ureg_src_is_undef(tx->regs.v[sem.reg.idx]) && "Nine doesn't support yet packing"); in DECL_SPECIAL()
2322 tx->regs.v[sem.reg.idx] = nine_get_position_input(tx); in DECL_SPECIAL()
2327 (tgsi.Name == TGSI_SEMANTIC_COLOR && tx->info->force_color_in_centroid)) in DECL_SPECIAL()
2330 tx->regs.v[sem.reg.idx] = ureg_DECL_fs_input_centroid( in DECL_SPECIAL()
2347 tx_set_lconstf(tx, tx->insn.dst[0].idx, tx->insn.src[0].imm.f); in DECL_SPECIAL()
2353 tx_set_lconstb(tx, tx->insn.dst[0].idx, tx->insn.src[0].imm.b); in DECL_SPECIAL()
2359 tx_set_lconsti(tx, tx->insn.dst[0].idx, tx->insn.src[0].imm.i); in DECL_SPECIAL()
2365 struct ureg_dst dst = tx_dst_param(tx, &tx->insn.dst[0]); in DECL_SPECIAL()
2367 tx_src_param(tx, &tx->insn.src[0]), in DECL_SPECIAL()
2368 tx_src_param(tx, &tx->insn.src[1]) in DECL_SPECIAL()
2370 ureg_POW(tx->ureg, dst, ureg_abs(src[0]), src[1]); in DECL_SPECIAL()
2405 struct ureg_program *ureg = tx->ureg; in DECL_SPECIAL()
2406 struct ureg_dst dst = tx_dst_param(tx, &tx->insn.dst[0]); in DECL_SPECIAL()
2407 struct ureg_src src = tx_src_param(tx, &tx->insn.src[0]); in DECL_SPECIAL()
2408 struct ureg_dst tmp = tx->mul_zero_wins ? dst : tx_scratch(tx); in DECL_SPECIAL()
2410 if (!tx->mul_zero_wins) { in DECL_SPECIAL()
2420 struct ureg_program *ureg = tx->ureg; in DECL_SPECIAL()
2421 struct ureg_dst dst = tx_dst_param(tx, &tx->insn.dst[0]); in DECL_SPECIAL()
2422 struct ureg_src src = tx_src_param(tx, &tx->insn.src[0]); in DECL_SPECIAL()
2423 struct ureg_dst tmp = tx->mul_zero_wins ? dst : tx_scratch(tx); in DECL_SPECIAL()
2425 if (!tx->mul_zero_wins) in DECL_SPECIAL()
2432 struct ureg_program *ureg = tx->ureg; in DECL_SPECIAL()
2433 struct ureg_dst tmp = tx_scratch_scalar(tx); in DECL_SPECIAL()
2434 struct ureg_dst dst = tx_dst_param(tx, &tx->insn.dst[0]); in DECL_SPECIAL()
2435 struct ureg_src src = tx_src_param(tx, &tx->insn.src[0]); in DECL_SPECIAL()
2437 if (tx->mul_zero_wins) { in DECL_SPECIAL()
2447 struct ureg_program *ureg = tx->ureg; in DECL_SPECIAL()
2448 struct ureg_dst tmp = tx_scratch(tx); in DECL_SPECIAL()
2449 struct ureg_dst dst = tx_dst_param(tx, &tx->insn.dst[0]); in DECL_SPECIAL()
2450 struct ureg_src src = tx_src_param(tx, &tx->insn.src[0]); in DECL_SPECIAL()
2464 struct ureg_program *ureg = tx->ureg; in DECL_SPECIAL()
2465 struct ureg_dst tmp = tx_scratch_scalar(tx); in DECL_SPECIAL()
2467 struct ureg_dst dst = tx_dst_param(tx, &tx->insn.dst[0]); in DECL_SPECIAL()
2468 struct ureg_src src = tx_src_param(tx, &tx->insn.src[0]); in DECL_SPECIAL()
2471 if (!tx->mul_zero_wins) in DECL_SPECIAL()
2479 struct ureg_dst tmp = tx_scratch_scalar(tx); in DECL_SPECIAL()
2481 struct ureg_dst dst = tx_dst_param(tx, &tx->insn.dst[0]); in DECL_SPECIAL()
2485 src[i] = tx_src_param(tx, &tx->insn.src[i]); in DECL_SPECIAL()
2488 ureg_DP2(tx->ureg, tmp, src[0], src[1]); in DECL_SPECIAL()
2489 ureg_ADD(tx->ureg, dst, src[2], dp2); in DECL_SPECIAL()
2496 struct ureg_program *ureg = tx->ureg; in DECL_SPECIAL()
2497 const unsigned s = tx->insn.dst[0].idx; in DECL_SPECIAL()
2498 struct ureg_dst dst = tx_dst_param(tx, &tx->insn.dst[0]); in DECL_SPECIAL()
2500 tx_texcoord_alloc(tx, s); in DECL_SPECIAL()
2501 ureg_MOV(ureg, ureg_writemask(ureg_saturate(dst), TGSI_WRITEMASK_XYZ), tx->regs.vT[s]); in DECL_SPECIAL()
2502 ureg_MOV(ureg, ureg_writemask(dst, TGSI_WRITEMASK_W), ureg_imm1f(tx->ureg, 1.0f)); in DECL_SPECIAL()
2509 struct ureg_program *ureg = tx->ureg; in DECL_SPECIAL()
2510 struct ureg_src src = tx_src_param(tx, &tx->insn.src[0]); in DECL_SPECIAL()
2511 struct ureg_dst dst = tx_dst_param(tx, &tx->insn.dst[0]); in DECL_SPECIAL()
2513 assert(tx->insn.src[0].file == D3DSPR_TEXTURE); in DECL_SPECIAL()
2524 if (tx->version.major > 1 || tx->version.minor > 3) { in DECL_SPECIAL()
2525 reg = tx_dst_param_as_src(tx, &tx->insn.dst[0]); in DECL_SPECIAL()
2527 tx_texcoord_alloc(tx, tx->insn.dst[0].idx); in DECL_SPECIAL()
2528 reg = tx->regs.vT[tx->insn.dst[0].idx]; in DECL_SPECIAL()
2530 if (tx->version.major < 2) in DECL_SPECIAL()
2532 ureg_KILL_IF(tx->ureg, reg); in DECL_SPECIAL()
2539 struct ureg_program *ureg = tx->ureg; in DECL_SPECIAL()
2540 struct ureg_dst dst = tx_dst_param(tx, &tx->insn.dst[0]); in DECL_SPECIAL()
2541 struct ureg_src src = tx_src_param(tx, &tx->insn.src[0]); /* t[n] */ in DECL_SPECIAL()
2545 const int m = tx->insn.dst[0].idx; in DECL_SPECIAL()
2547 assert(tx->version.major == 1); in DECL_SPECIAL()
2550 tx->info->sampler_mask |= 1 << m; in DECL_SPECIAL()
2552 tx_texcoord_alloc(tx, m); in DECL_SPECIAL()
2554 tmp = tx_scratch(tx); in DECL_SPECIAL()
2555 tmp2 = tx_scratch(tx); in DECL_SPECIAL()
2556 texcoord = tx_scratch(tx); in DECL_SPECIAL()
2564 c8m = nine_float_constant_src(tx, 8+m); in DECL_SPECIAL()
2565 c16m2 = nine_float_constant_src(tx, 8+8+m/2); in DECL_SPECIAL()
2581 apply_ps1x_projection(tx, texcoord, tx->regs.vT[m], m); in DECL_SPECIAL()
2601 if (tx->insn.opcode == D3DSIO_TEXBEM) { in DECL_SPECIAL()
2602 ureg_TEX(ureg, dst, ps1x_sampler_type(tx->info, m), ureg_src(tmp), sample); in DECL_SPECIAL()
2603 } else if (tx->insn.opcode == D3DSIO_TEXBEML) { in DECL_SPECIAL()
2605 ureg_TEX(ureg, tmp, ps1x_sampler_type(tx->info, m), ureg_src(tmp), sample); in DECL_SPECIAL()
2611 tx->info->bumpenvmat_needed = 1; in DECL_SPECIAL()
2618 struct ureg_program *ureg = tx->ureg; in DECL_SPECIAL()
2619 struct ureg_dst dst = tx_dst_param(tx, &tx->insn.dst[0]); in DECL_SPECIAL()
2620 struct ureg_src src = tx_src_param(tx, &tx->insn.src[0]); /* t[n] */ in DECL_SPECIAL()
2622 const int m = tx->insn.dst[0].idx; in DECL_SPECIAL()
2623 ASSERTED const int n = tx->insn.src[0].idx; in DECL_SPECIAL()
2627 tx->info->sampler_mask |= 1 << m; in DECL_SPECIAL()
2628 …ureg_TEX(ureg, dst, ps1x_sampler_type(tx->info, m), ureg_swizzle(src, NINE_SWIZZLE4(W,X,X,X)), sam… in DECL_SPECIAL()
2635 struct ureg_program *ureg = tx->ureg; in DECL_SPECIAL()
2636 struct ureg_dst dst = tx_dst_param(tx, &tx->insn.dst[0]); in DECL_SPECIAL()
2637 struct ureg_src src = tx_src_param(tx, &tx->insn.src[0]); /* t[n] */ in DECL_SPECIAL()
2639 const int m = tx->insn.dst[0].idx; in DECL_SPECIAL()
2640 ASSERTED const int n = tx->insn.src[0].idx; in DECL_SPECIAL()
2644 tx->info->sampler_mask |= 1 << m; in DECL_SPECIAL()
2645 …ureg_TEX(ureg, dst, ps1x_sampler_type(tx->info, m), ureg_swizzle(src, NINE_SWIZZLE4(Y,Z,Z,Z)), sam… in DECL_SPECIAL()
2657 struct ureg_program *ureg = tx->ureg; in DECL_SPECIAL()
2658 struct ureg_dst dst = tx_dst_param(tx, &tx->insn.dst[0]); in DECL_SPECIAL()
2659 struct ureg_src src = tx_src_param(tx, &tx->insn.src[0]); /* t[n] */ in DECL_SPECIAL()
2661 const int m = tx->insn.dst[0].idx - 1; in DECL_SPECIAL()
2662 ASSERTED const int n = tx->insn.src[0].idx; in DECL_SPECIAL()
2665 tx_texcoord_alloc(tx, m); in DECL_SPECIAL()
2666 tx_texcoord_alloc(tx, m+1); in DECL_SPECIAL()
2669 ureg_DP3(ureg, ureg_writemask(dst, TGSI_WRITEMASK_X), tx->regs.vT[m], src); in DECL_SPECIAL()
2670 ureg_DP3(ureg, ureg_writemask(dst, TGSI_WRITEMASK_Y), tx->regs.vT[m+1], src); in DECL_SPECIAL()
2673 tx->info->sampler_mask |= 1 << (m + 1); in DECL_SPECIAL()
2674 ureg_TEX(ureg, dst, ps1x_sampler_type(tx->info, m + 1), ureg_src(dst), sample); in DECL_SPECIAL()
2686 struct ureg_program *ureg = tx->ureg; in DECL_SPECIAL()
2687 struct ureg_dst dst = tx_dst_param(tx, &tx->insn.dst[0]); in DECL_SPECIAL()
2688 struct ureg_src src = tx_src_param(tx, &tx->insn.src[0]); /* t[n] */ in DECL_SPECIAL()
2689 struct ureg_src E = tx_src_param(tx, &tx->insn.src[1]); in DECL_SPECIAL()
2692 const int m = tx->insn.dst[0].idx - 2; in DECL_SPECIAL()
2693 ASSERTED const int n = tx->insn.src[0].idx; in DECL_SPECIAL()
2696 tx_texcoord_alloc(tx, m); in DECL_SPECIAL()
2697 tx_texcoord_alloc(tx, m+1); in DECL_SPECIAL()
2698 tx_texcoord_alloc(tx, m+2); in DECL_SPECIAL()
2700 ureg_DP3(ureg, ureg_writemask(dst, TGSI_WRITEMASK_X), tx->regs.vT[m], src); in DECL_SPECIAL()
2701 ureg_DP3(ureg, ureg_writemask(dst, TGSI_WRITEMASK_Y), tx->regs.vT[m+1], src); in DECL_SPECIAL()
2702 ureg_DP3(ureg, ureg_writemask(dst, TGSI_WRITEMASK_Z), tx->regs.vT[m+2], src); in DECL_SPECIAL()
2705 tx->info->sampler_mask |= 1 << (m + 2); in DECL_SPECIAL()
2706 tmp = ureg_writemask(tx_scratch(tx), TGSI_WRITEMASK_XYZ); in DECL_SPECIAL()
2722 ureg_TEX(ureg, dst, ps1x_sampler_type(tx->info, m + 2), ureg_src(tmp), sample); in DECL_SPECIAL()
2729 struct ureg_program *ureg = tx->ureg; in DECL_SPECIAL()
2730 struct ureg_dst dst = tx_dst_param(tx, &tx->insn.dst[0]); in DECL_SPECIAL()
2731 struct ureg_src src = tx_src_param(tx, &tx->insn.src[0]); /* t[n] */ in DECL_SPECIAL()
2733 const int m = tx->insn.dst[0].idx; in DECL_SPECIAL()
2734 ASSERTED const int n = tx->insn.src[0].idx; in DECL_SPECIAL()
2738 tx->info->sampler_mask |= 1 << m; in DECL_SPECIAL()
2739 ureg_TEX(ureg, dst, ps1x_sampler_type(tx->info, m), src, sample); in DECL_SPECIAL()
2746 struct ureg_program *ureg = tx->ureg; in DECL_SPECIAL()
2747 struct ureg_dst dst = tx_dst_param(tx, &tx->insn.dst[0]); in DECL_SPECIAL()
2748 struct ureg_src src = tx_src_param(tx, &tx->insn.src[0]); /* t[n] */ in DECL_SPECIAL()
2751 const int m = tx->insn.dst[0].idx; in DECL_SPECIAL()
2752 ASSERTED const int n = tx->insn.src[0].idx; in DECL_SPECIAL()
2755 tx_texcoord_alloc(tx, m); in DECL_SPECIAL()
2757 tmp = tx_scratch(tx); in DECL_SPECIAL()
2758 ureg_DP3(ureg, ureg_writemask(tmp, TGSI_WRITEMASK_X), tx->regs.vT[m], src); in DECL_SPECIAL()
2762 tx->info->sampler_mask |= 1 << m; in DECL_SPECIAL()
2763 ureg_TEX(ureg, dst, ps1x_sampler_type(tx->info, m), ureg_src(tmp), sample); in DECL_SPECIAL()
2770 struct ureg_program *ureg = tx->ureg; in DECL_SPECIAL()
2771 struct ureg_src src = tx_src_param(tx, &tx->insn.src[0]); /* t[n] */ in DECL_SPECIAL()
2773 const int m = tx->insn.dst[0].idx - 1; in DECL_SPECIAL()
2774 ASSERTED const int n = tx->insn.src[0].idx; in DECL_SPECIAL()
2777 tx_texcoord_alloc(tx, m); in DECL_SPECIAL()
2778 tx_texcoord_alloc(tx, m+1); in DECL_SPECIAL()
2780 tmp = tx_scratch(tx); in DECL_SPECIAL()
2783 ureg_DP3(ureg, ureg_writemask(tmp, TGSI_WRITEMASK_X), tx->regs.vT[m], src); in DECL_SPECIAL()
2784 ureg_DP3(ureg, ureg_writemask(tmp, TGSI_WRITEMASK_Y), tx->regs.vT[m+1], src); in DECL_SPECIAL()
2793 tx->regs.oDepth = ureg_DECL_output_masked(ureg, TGSI_SEMANTIC_POSITION, 0, in DECL_SPECIAL()
2795 ureg_MOV(ureg, tx->regs.oDepth, ureg_scalar(ureg_src(tmp), TGSI_SWIZZLE_X)); in DECL_SPECIAL()
2802 struct ureg_program *ureg = tx->ureg; in DECL_SPECIAL()
2803 struct ureg_dst dst = tx_dst_param(tx, &tx->insn.dst[0]); in DECL_SPECIAL()
2804 struct ureg_src src = tx_src_param(tx, &tx->insn.src[0]); /* t[n] */ in DECL_SPECIAL()
2805 const int m = tx->insn.dst[0].idx; in DECL_SPECIAL()
2806 ASSERTED const int n = tx->insn.src[0].idx; in DECL_SPECIAL()
2809 tx_texcoord_alloc(tx, m); in DECL_SPECIAL()
2811 ureg_DP3(ureg, dst, tx->regs.vT[m], src); in DECL_SPECIAL()
2818 struct ureg_program *ureg = tx->ureg; in DECL_SPECIAL()
2819 struct ureg_dst dst = tx_dst_param(tx, &tx->insn.dst[0]); in DECL_SPECIAL()
2820 struct ureg_src src = tx_src_param(tx, &tx->insn.src[0]); /* t[n] */ in DECL_SPECIAL()
2823 const int m = tx->insn.dst[0].idx - 2; in DECL_SPECIAL()
2824 ASSERTED const int n = tx->insn.src[0].idx; in DECL_SPECIAL()
2827 tx_texcoord_alloc(tx, m); in DECL_SPECIAL()
2828 tx_texcoord_alloc(tx, m+1); in DECL_SPECIAL()
2829 tx_texcoord_alloc(tx, m+2); in DECL_SPECIAL()
2831 ureg_DP3(ureg, ureg_writemask(dst, TGSI_WRITEMASK_X), tx->regs.vT[m], src); in DECL_SPECIAL()
2832 ureg_DP3(ureg, ureg_writemask(dst, TGSI_WRITEMASK_Y), tx->regs.vT[m+1], src); in DECL_SPECIAL()
2833 ureg_DP3(ureg, ureg_writemask(dst, TGSI_WRITEMASK_Z), tx->regs.vT[m+2], src); in DECL_SPECIAL()
2835 switch (tx->insn.opcode) { in DECL_SPECIAL()
2841 tx->info->sampler_mask |= 1 << (m + 2); in DECL_SPECIAL()
2842 ureg_TEX(ureg, dst, ps1x_sampler_type(tx->info, m + 2), ureg_src(dst), sample); in DECL_SPECIAL()
2846 tx->info->sampler_mask |= 1 << (m + 2); in DECL_SPECIAL()
2847 E = tx_scratch(tx); in DECL_SPECIAL()
2848 tmp = ureg_writemask(tx_scratch(tx), TGSI_WRITEMASK_XYZ); in DECL_SPECIAL()
2849 … ureg_MOV(ureg, ureg_writemask(E, TGSI_WRITEMASK_X), ureg_scalar(tx->regs.vT[m], TGSI_SWIZZLE_W)); in DECL_SPECIAL()
2850 …ureg_MOV(ureg, ureg_writemask(E, TGSI_WRITEMASK_Y), ureg_scalar(tx->regs.vT[m+1], TGSI_SWIZZLE_W)); in DECL_SPECIAL()
2851 …ureg_MOV(ureg, ureg_writemask(E, TGSI_WRITEMASK_Z), ureg_scalar(tx->regs.vT[m+2], TGSI_SWIZZLE_W)); in DECL_SPECIAL()
2866 ureg_TEX(ureg, dst, ps1x_sampler_type(tx->info, m + 2), ureg_src(tmp), sample); in DECL_SPECIAL()
2876 struct ureg_program *ureg = tx->ureg; in DECL_SPECIAL()
2880 assert(tx->insn.dst[0].idx == 5); /* instruction must get r5 here */ in DECL_SPECIAL()
2884 r5 = tx->regs.r[5]; in DECL_SPECIAL()
2894 tx->regs.oDepth = ureg_DECL_output_masked(ureg, TGSI_SEMANTIC_POSITION, 0, in DECL_SPECIAL()
2896 ureg_MOV(ureg, tx->regs.oDepth, r5r); in DECL_SPECIAL()
2903 struct ureg_program *ureg = tx->ureg; in DECL_SPECIAL()
2904 struct ureg_dst dst = tx_dst_param(tx, &tx->insn.dst[0]); in DECL_SPECIAL()
2905 struct ureg_src src0 = tx_src_param(tx, &tx->insn.src[0]); in DECL_SPECIAL()
2906 struct ureg_src src1 = tx_src_param(tx, &tx->insn.src[1]); in DECL_SPECIAL()
2908 const int m = tx->insn.dst[0].idx; in DECL_SPECIAL()
2909 struct ureg_dst tmp = tx_scratch(tx); in DECL_SPECIAL()
2917 c8m = nine_float_constant_src(tx, 8+m); in DECL_SPECIAL()
2937 tx->info->bumpenvmat_needed = 1; in DECL_SPECIAL()
2944 struct ureg_program *ureg = tx->ureg; in DECL_SPECIAL()
2946 struct ureg_dst dst = tx_dst_param(tx, &tx->insn.dst[0]); in DECL_SPECIAL()
2948 tx_src_param(tx, &tx->insn.src[0]), in DECL_SPECIAL()
2949 tx_src_param(tx, &tx->insn.src[1]) in DECL_SPECIAL()
2951 assert(tx->insn.src[1].idx >= 0 && in DECL_SPECIAL()
2952 tx->insn.src[1].idx < ARRAY_SIZE(tx->sampler_targets)); in DECL_SPECIAL()
2953 target = tx->sampler_targets[tx->insn.src[1].idx]; in DECL_SPECIAL()
2955 if (TEX_if_fetch4(tx, dst, target, src[0], src[1], tx->insn.src[1].idx)) in DECL_SPECIAL()
2958 switch (tx->insn.flags) { in DECL_SPECIAL()
2977 struct ureg_program *ureg = tx->ureg; in DECL_SPECIAL()
2978 struct ureg_dst dst = tx_dst_param(tx, &tx->insn.dst[0]); in DECL_SPECIAL()
2979 struct ureg_src src = tx_src_param(tx, &tx->insn.src[0]); in DECL_SPECIAL()
2980 const unsigned s = tx->insn.dst[0].idx; in DECL_SPECIAL()
2981 const unsigned t = ps1x_sampler_type(tx->info, s); in DECL_SPECIAL()
2983 tx->info->sampler_mask |= 1 << s; in DECL_SPECIAL()
2991 struct ureg_program *ureg = tx->ureg; in DECL_SPECIAL()
2992 const unsigned s = tx->insn.dst[0].idx; in DECL_SPECIAL()
2993 const unsigned t = ps1x_sampler_type(tx->info, s); in DECL_SPECIAL()
2994 struct ureg_dst dst = tx_dst_param(tx, &tx->insn.dst[0]); in DECL_SPECIAL()
2997 tx_texcoord_alloc(tx, s); in DECL_SPECIAL()
2999 src[0] = tx->regs.vT[s]; in DECL_SPECIAL()
3001 tx->info->sampler_mask |= 1 << s; in DECL_SPECIAL()
3003 TEX_with_ps1x_projection(tx, dst, t, src[0], src[1], s); in DECL_SPECIAL()
3011 struct ureg_dst dst = tx_dst_param(tx, &tx->insn.dst[0]); in DECL_SPECIAL()
3013 tx_src_param(tx, &tx->insn.src[0]), in DECL_SPECIAL()
3014 tx_src_param(tx, &tx->insn.src[1]), in DECL_SPECIAL()
3015 tx_src_param(tx, &tx->insn.src[2]), in DECL_SPECIAL()
3016 tx_src_param(tx, &tx->insn.src[3]) in DECL_SPECIAL()
3018 assert(tx->insn.src[1].idx >= 0 && in DECL_SPECIAL()
3019 tx->insn.src[1].idx < ARRAY_SIZE(tx->sampler_targets)); in DECL_SPECIAL()
3020 target = tx->sampler_targets[tx->insn.src[1].idx]; in DECL_SPECIAL()
3022 if (TEX_if_fetch4(tx, dst, target, src[0], src[1], tx->insn.src[1].idx)) in DECL_SPECIAL()
3025 ureg_TXD(tx->ureg, dst, target, src[0], src[2], src[3], src[1]); in DECL_SPECIAL()
3032 struct ureg_dst dst = tx_dst_param(tx, &tx->insn.dst[0]); in DECL_SPECIAL()
3034 tx_src_param(tx, &tx->insn.src[0]), in DECL_SPECIAL()
3035 tx_src_param(tx, &tx->insn.src[1]) in DECL_SPECIAL()
3037 assert(tx->insn.src[1].idx >= 0 && in DECL_SPECIAL()
3038 tx->insn.src[1].idx < ARRAY_SIZE(tx->sampler_targets)); in DECL_SPECIAL()
3039 target = tx->sampler_targets[tx->insn.src[1].idx]; in DECL_SPECIAL()
3041 if (TEX_if_fetch4(tx, dst, target, src[0], src[1], tx->insn.src[1].idx)) in DECL_SPECIAL()
3044 ureg_TXL(tx->ureg, dst, target, src[0], src[1]); in DECL_SPECIAL()
3050 const unsigned cmp_op = sm1_insn_flags_to_tgsi_setop(tx->insn.flags); in DECL_SPECIAL()
3051 struct ureg_dst dst = tx_dst_param(tx, &tx->insn.dst[0]); in DECL_SPECIAL()
3053 tx_src_param(tx, &tx->insn.src[0]), in DECL_SPECIAL()
3054 tx_src_param(tx, &tx->insn.src[1]) in DECL_SPECIAL()
3056 ureg_insn(tx->ureg, cmp_op, &dst, 1, src, 2, 0); in DECL_SPECIAL()
3062 struct ureg_src src = tx_src_param(tx, &tx->insn.src[0]); in DECL_SPECIAL()
3063 ureg_IF(tx->ureg, src, tx_cond(tx)); in DECL_SPECIAL()
3064 ureg_BRK(tx->ureg); in DECL_SPECIAL()
3065 tx_endcond(tx); in DECL_SPECIAL()
3066 ureg_ENDIF(tx->ureg); in DECL_SPECIAL()
3198 create_op_info_map(struct shader_translator *tx) in create_op_info_map() argument
3200 const unsigned version = (tx->version.major << 8) | tx->version.minor; in create_op_info_map()
3203 for (i = 0; i < ARRAY_SIZE(tx->op_info_map); ++i) in create_op_info_map()
3204 tx->op_info_map[i] = -1; in create_op_info_map()
3206 if (tx->processor == PIPE_SHADER_VERTEX) { in create_op_info_map()
3208 assert(inst_table[i].sio < ARRAY_SIZE(tx->op_info_map)); in create_op_info_map()
3211 tx->op_info_map[inst_table[i].sio] = i; in create_op_info_map()
3215 assert(inst_table[i].sio < ARRAY_SIZE(tx->op_info_map)); in create_op_info_map()
3218 tx->op_info_map[inst_table[i].sio] = i; in create_op_info_map()
3224 NineTranslateInstruction_Generic(struct shader_translator *tx) in NineTranslateInstruction_Generic() argument
3230 for (i = 0; i < tx->insn.ndst && i < ARRAY_SIZE(dst); ++i) in NineTranslateInstruction_Generic()
3231 dst[i] = tx_dst_param(tx, &tx->insn.dst[i]); in NineTranslateInstruction_Generic()
3232 for (i = 0; i < tx->insn.nsrc && i < ARRAY_SIZE(src); ++i) in NineTranslateInstruction_Generic()
3233 src[i] = tx_src_param(tx, &tx->insn.src[i]); in NineTranslateInstruction_Generic()
3235 ureg_insn(tx->ureg, tx->insn.info->opcode, in NineTranslateInstruction_Generic()
3236 dst, tx->insn.ndst, in NineTranslateInstruction_Generic()
3237 src, tx->insn.nsrc, 0); in NineTranslateInstruction_Generic()
3242 TOKEN_PEEK(struct shader_translator *tx) in TOKEN_PEEK() argument
3244 return *(tx->parse); in TOKEN_PEEK()
3248 TOKEN_NEXT(struct shader_translator *tx) in TOKEN_NEXT() argument
3250 return *(tx->parse)++; in TOKEN_NEXT()
3254 TOKEN_JUMP(struct shader_translator *tx) in TOKEN_JUMP() argument
3256 if (tx->parse_next && tx->parse != tx->parse_next) { in TOKEN_JUMP()
3257 WARN("parse(%p) != parse_next(%p) !\n", tx->parse, tx->parse_next); in TOKEN_JUMP()
3258 tx->parse = tx->parse_next; in TOKEN_JUMP()
3263 sm1_parse_eof(struct shader_translator *tx) in sm1_parse_eof() argument
3265 return TOKEN_PEEK(tx) == NINED3DSP_END; in sm1_parse_eof()
3269 sm1_read_version(struct shader_translator *tx) in sm1_read_version() argument
3271 const DWORD tok = TOKEN_NEXT(tx); in sm1_read_version()
3273 tx->version.major = D3DSHADER_VERSION_MAJOR(tok); in sm1_read_version()
3274 tx->version.minor = D3DSHADER_VERSION_MINOR(tok); in sm1_read_version()
3277 case NINED3D_SM1_VS: tx->processor = PIPE_SHADER_VERTEX; break; in sm1_read_version()
3278 case NINED3D_SM1_PS: tx->processor = PIPE_SHADER_FRAGMENT; break; in sm1_read_version()
3281 tx->processor = ~0; in sm1_read_version()
3288 sm1_parse_get_skip(struct shader_translator *tx) in sm1_parse_get_skip() argument
3290 const DWORD tok = TOKEN_PEEK(tx); in sm1_parse_get_skip()
3292 if (tx->version.major >= 2) { in sm1_parse_get_skip()
3293 tx->parse_next = tx->parse + 1 /* this */ + in sm1_parse_get_skip()
3296 tx->parse_next = NULL; /* TODO: determine from param count */ in sm1_parse_get_skip()
3309 sm1_parse_comments(struct shader_translator *tx, BOOL print) in sm1_parse_comments() argument
3311 DWORD tok = TOKEN_PEEK(tx); in sm1_parse_comments()
3317 tx->parse += size + 1; in sm1_parse_comments()
3322 tok = TOKEN_PEEK(tx); in sm1_parse_comments()
3327 sm1_parse_get_param(struct shader_translator *tx, DWORD *reg, DWORD *rel) in sm1_parse_get_param() argument
3329 *reg = TOKEN_NEXT(tx); in sm1_parse_get_param()
3333 if (tx->version.major < 2) in sm1_parse_get_param()
3339 *rel = TOKEN_NEXT(tx); in sm1_parse_get_param()
3381 sm1_parse_immediate(struct shader_translator *tx, in sm1_parse_immediate() argument
3389 switch (tx->insn.opcode) { in sm1_parse_immediate()
3392 memcpy(&imm->imm.d[0], tx->parse, 4 * sizeof(DWORD)); in sm1_parse_immediate()
3393 tx->parse += 4; in sm1_parse_immediate()
3397 memcpy(&imm->imm.d[0], tx->parse, 4 * sizeof(DWORD)); in sm1_parse_immediate()
3398 tx->parse += 4; in sm1_parse_immediate()
3402 memcpy(&imm->imm.d[0], tx->parse, 1 * sizeof(DWORD)); in sm1_parse_immediate()
3403 tx->parse += 1; in sm1_parse_immediate()
3412 sm1_read_dst_param(struct shader_translator *tx, in sm1_read_dst_param() argument
3418 sm1_parse_get_param(tx, &tok_dst, &tok_rel); in sm1_read_dst_param()
3427 sm1_read_src_param(struct shader_translator *tx, in sm1_read_src_param() argument
3433 sm1_parse_get_param(tx, &tok_src, &tok_rel); in sm1_read_src_param()
3443 sm1_read_semantic(struct shader_translator *tx, in sm1_read_semantic() argument
3446 const DWORD tok_usg = TOKEN_NEXT(tx); in sm1_read_semantic()
3447 const DWORD tok_dst = TOKEN_NEXT(tx); in sm1_read_semantic()
3457 sm1_parse_instruction(struct shader_translator *tx) in sm1_parse_instruction() argument
3459 struct sm1_instruction *insn = &tx->insn; in sm1_parse_instruction()
3465 sm1_parse_comments(tx, TRUE); in sm1_parse_instruction()
3466 sm1_parse_get_skip(tx); in sm1_parse_instruction()
3468 tok = TOKEN_NEXT(tx); in sm1_parse_instruction()
3475 if (insn->opcode < ARRAY_SIZE(tx->op_info_map)) { in sm1_parse_instruction()
3476 int k = tx->op_info_map[insn->opcode]; in sm1_parse_instruction()
3487 TOKEN_JUMP(tx); in sm1_parse_instruction()
3498 unsigned ver = (tx->version.major << 8) | tx->version.minor; in sm1_parse_instruction()
3507 sm1_read_dst_param(tx, &insn->dst[i], &insn->dst_rel[i]); in sm1_parse_instruction()
3509 sm1_read_src_param(tx, &insn->pred, NULL); in sm1_parse_instruction()
3511 sm1_read_src_param(tx, &insn->src[i], &insn->src_rel[i]); in sm1_parse_instruction()
3517 sm1_parse_immediate(tx, &tx->insn.src[0]); in sm1_parse_instruction()
3519 sm1_dump_instruction(insn, tx->cond_depth + tx->loop_depth); in sm1_parse_instruction()
3523 tx->predicated_activated = true; in sm1_parse_instruction()
3524 if (ureg_dst_is_undef(tx->regs.predicate_tmp)) { in sm1_parse_instruction()
3525 tx->regs.predicate_tmp = ureg_DECL_temporary(tx->ureg); in sm1_parse_instruction()
3526 tx->regs.predicate_dst = ureg_DECL_temporary(tx->ureg); in sm1_parse_instruction()
3531 hr = info->handler(tx); in sm1_parse_instruction()
3533 hr = NineTranslateInstruction_Generic(tx); in sm1_parse_instruction()
3534 tx_apply_dst0_modifiers(tx); in sm1_parse_instruction()
3537 tx->predicated_activated = false; in sm1_parse_instruction()
3540 ureg_CMP(tx->ureg, tx->regs.predicate_dst, in sm1_parse_instruction()
3541 ureg_negate(tx_src_param(tx, &insn->pred)), in sm1_parse_instruction()
3542 ureg_src(tx->regs.predicate_tmp), in sm1_parse_instruction()
3543 ureg_src(tx->regs.predicate_dst)); in sm1_parse_instruction()
3547 tx->failure = TRUE; in sm1_parse_instruction()
3548 tx->num_scratch = 0; /* reset */ in sm1_parse_instruction()
3550 TOKEN_JUMP(tx); in sm1_parse_instruction()
3559 tx_ctor(struct shader_translator *tx, struct pipe_screen *screen, struct nine_shader_info *info) in tx_ctor() argument
3563 memset(tx, 0, sizeof(*tx)); in tx_ctor()
3565 tx->info = info; in tx_ctor()
3567 tx->byte_code = info->byte_code; in tx_ctor()
3568 tx->parse = info->byte_code; in tx_ctor()
3577 memset(tx->slots_used, 0, sizeof(tx->slots_used)); in tx_ctor()
3581 tx->info->const_float_slots = 0; in tx_ctor()
3582 tx->info->const_int_slots = 0; in tx_ctor()
3583 tx->info->const_bool_slots = 0; in tx_ctor()
3593 for (i = 0; i < ARRAY_SIZE(tx->regs.rL); ++i) { in tx_ctor()
3594 tx->regs.rL[i] = ureg_dst_undef(); in tx_ctor()
3596 tx->regs.address = ureg_dst_undef(); in tx_ctor()
3597 tx->regs.a0 = ureg_dst_undef(); in tx_ctor()
3598 tx->regs.p = ureg_dst_undef(); in tx_ctor()
3599 tx->regs.oDepth = ureg_dst_undef(); in tx_ctor()
3600 tx->regs.vPos = ureg_src_undef(); in tx_ctor()
3601 tx->regs.vFace = ureg_src_undef(); in tx_ctor()
3602 for (i = 0; i < ARRAY_SIZE(tx->regs.o); ++i) in tx_ctor()
3603 tx->regs.o[i] = ureg_dst_undef(); in tx_ctor()
3604 for (i = 0; i < ARRAY_SIZE(tx->regs.oCol); ++i) in tx_ctor()
3605 tx->regs.oCol[i] = ureg_dst_undef(); in tx_ctor()
3606 for (i = 0; i < ARRAY_SIZE(tx->regs.vC); ++i) in tx_ctor()
3607 tx->regs.vC[i] = ureg_src_undef(); in tx_ctor()
3608 for (i = 0; i < ARRAY_SIZE(tx->regs.vT); ++i) in tx_ctor()
3609 tx->regs.vT[i] = ureg_src_undef(); in tx_ctor()
3611 sm1_read_version(tx); in tx_ctor()
3613 info->version = (tx->version.major << 4) | tx->version.minor; in tx_ctor()
3615 tx->num_outputs = 0; in tx_ctor()
3617 create_op_info_map(tx); in tx_ctor()
3619 tx->ureg = ureg_create(info->type); in tx_ctor()
3620 if (!tx->ureg) { in tx_ctor()
3624 tx->native_integers = GET_SHADER_CAP(INTEGERS); in tx_ctor()
3625 tx->inline_subroutines = !GET_SHADER_CAP(SUBROUTINES); in tx_ctor()
3626 tx->want_texcoord = GET_CAP(TGSI_TEXCOORD); in tx_ctor()
3627 tx->shift_wpos = !GET_CAP(FS_COORD_PIXEL_CENTER_INTEGER); in tx_ctor()
3628 tx->texcoord_sn = tx->want_texcoord ? in tx_ctor()
3630 tx->wpos_is_sysval = GET_CAP(FS_POSITION_IS_SYSVAL); in tx_ctor()
3631 tx->face_is_sysval_integer = GET_CAP(FS_FACE_IS_INTEGER_SYSVAL); in tx_ctor()
3634 tx->num_constf_allowed = NINE_MAX_CONST_F; in tx_ctor()
3635 } else if (tx->version.major < 2) {/* IS_PS v1 */ in tx_ctor()
3636 tx->num_constf_allowed = 8; in tx_ctor()
3637 } else if (tx->version.major == 2) {/* IS_PS v2 */ in tx_ctor()
3638 tx->num_constf_allowed = 32; in tx_ctor()
3640 tx->num_constf_allowed = NINE_MAX_CONST_F_PS3; in tx_ctor()
3643 if (tx->version.major < 2) { in tx_ctor()
3644 tx->num_consti_allowed = 0; in tx_ctor()
3645 tx->num_constb_allowed = 0; in tx_ctor()
3647 tx->num_consti_allowed = NINE_MAX_CONST_I; in tx_ctor()
3648 tx->num_constb_allowed = NINE_MAX_CONST_B; in tx_ctor()
3653 tx->num_constf_allowed = 8192; in tx_ctor()
3654 tx->num_consti_allowed = 2048; in tx_ctor()
3655 tx->num_constb_allowed = 2048; in tx_ctor()
3662 tx->regs.oPos = ureg_DECL_output(tx->ureg, TGSI_SEMANTIC_POSITION, 0); in tx_ctor()
3664 ureg_property(tx->ureg, TGSI_PROPERTY_FS_COORD_ORIGIN, TGSI_FS_COORD_ORIGIN_UPPER_LEFT); in tx_ctor()
3665 if (!tx->shift_wpos) in tx_ctor()
3666 … ureg_property(tx->ureg, TGSI_PROPERTY_FS_COORD_PIXEL_CENTER, TGSI_FS_COORD_PIXEL_CENTER_INTEGER); in tx_ctor()
3669 tx->mul_zero_wins = GET_CAP(LEGACY_MATH_RULES); in tx_ctor()
3670 if (tx->mul_zero_wins) in tx_ctor()
3671 ureg_property(tx->ureg, TGSI_PROPERTY_LEGACY_MATH_RULES, 1); in tx_ctor()
3688 tx_set_lconsti(tx, i, info->add_constants_defs.c_combination->const_i[i]); in tx_ctor()
3694 tx_set_lconstb(tx, i, info->add_constants_defs.c_combination->const_b[i]); in tx_ctor()
3702 tx_dtor(struct shader_translator *tx) in tx_dtor() argument
3704 if (tx->slot_map) in tx_dtor()
3705 FREE(tx->slot_map); in tx_dtor()
3706 if (tx->num_inst_labels) in tx_dtor()
3707 FREE(tx->inst_labels); in tx_dtor()
3708 FREE(tx->lconstf); in tx_dtor()
3709 FREE(tx->regs.r); in tx_dtor()
3710 FREE(tx); in tx_dtor()
3716 shader_add_vs_viewport_transform(struct shader_translator *tx) in shader_add_vs_viewport_transform() argument
3718 struct ureg_program *ureg = tx->ureg; in shader_add_vs_viewport_transform()
3730 ureg_MOV(ureg, ureg_writemask(tx->regs.oPos_out, TGSI_WRITEMASK_XYZ), ureg_src(tx->regs.oPos)); in shader_add_vs_viewport_transform()
3734 shader_add_ps_fog_stage(struct shader_translator *tx, struct ureg_src src_col) in shader_add_ps_fog_stage() argument
3736 struct ureg_program *ureg = tx->ureg; in shader_add_ps_fog_stage()
3742 if (!tx->info->fog_enable) { in shader_add_ps_fog_stage()
3747 if (tx->info->fog_mode != D3DFOG_NONE) { in shader_add_ps_fog_stage()
3748 depth = tx_scratch_scalar(tx); in shader_add_ps_fog_stage()
3750 ureg_RCP(ureg, depth, ureg_scalar(nine_get_position_input(tx), TGSI_SWIZZLE_W)); in shader_add_ps_fog_stage()
3751 … ureg_MUL(ureg, depth, ureg_src(depth), ureg_scalar(nine_get_position_input(tx), TGSI_SWIZZLE_Z)); in shader_add_ps_fog_stage()
3754 fog_color = nine_float_constant_src(tx, 32); in shader_add_ps_fog_stage()
3755 fog_params = nine_float_constant_src(tx, 33); in shader_add_ps_fog_stage()
3756 fog_factor = tx_scratch_scalar(tx); in shader_add_ps_fog_stage()
3758 if (tx->info->fog_mode == D3DFOG_LINEAR) { in shader_add_ps_fog_stage()
3763 } else if (tx->info->fog_mode == D3DFOG_EXP) { in shader_add_ps_fog_stage()
3768 } else if (tx->info->fog_mode == D3DFOG_EXP2) { in shader_add_ps_fog_stage()
3786 static void parse_shader(struct shader_translator *tx) in parse_shader() argument
3788 struct nine_shader_info *info = tx->info; in parse_shader()
3790 while (!sm1_parse_eof(tx) && !tx->failure) in parse_shader()
3791 sm1_parse_instruction(tx); in parse_shader()
3792 tx->parse++; /* for byte_size */ in parse_shader()
3794 if (tx->failure) in parse_shader()
3797 if (IS_PS && tx->version.major < 3) { in parse_shader()
3798 if (tx->version.major < 2) { in parse_shader()
3799 assert(tx->num_temp); /* there must be color output */ in parse_shader()
3801 shader_add_ps_fog_stage(tx, ureg_src(tx->regs.r[0])); in parse_shader()
3803 shader_add_ps_fog_stage(tx, ureg_src(tx->regs.oCol[0])); in parse_shader()
3807 if (IS_VS && tx->version.major < 3 && ureg_dst_is_undef(tx->regs.oFog) && info->fog_enable) { in parse_shader()
3808 tx->regs.oFog = ureg_DECL_output(tx->ureg, TGSI_SEMANTIC_GENERIC, 16); in parse_shader()
3809 … ureg_MOV(tx->ureg, ureg_writemask(tx->regs.oFog, TGSI_WRITEMASK_X), ureg_imm1f(tx->ureg, 0.0f)); in parse_shader()
3813 ureg_property(tx->ureg, TGSI_PROPERTY_VS_WINDOW_SPACE_POSITION, TRUE); in parse_shader()
3815 if (IS_VS && !ureg_dst_is_undef(tx->regs.oPts)) { in parse_shader()
3816 struct ureg_dst oPts = ureg_DECL_output(tx->ureg, TGSI_SEMANTIC_PSIZE, 0); in parse_shader()
3817 …ureg_MAX(tx->ureg, tx->regs.oPts, ureg_src(tx->regs.oPts), ureg_imm1f(tx->ureg, info->point_size_m… in parse_shader()
3818 … ureg_MIN(tx->ureg, oPts, ureg_src(tx->regs.oPts), ureg_imm1f(tx->ureg, info->point_size_max)); in parse_shader()
3823 shader_add_vs_viewport_transform(tx); in parse_shader()
3825 ureg_END(tx->ureg); in parse_shader()
3948 struct shader_translator *tx; in nine_translate_shader() local
3956 tx = MALLOC_STRUCT(shader_translator); in nine_translate_shader()
3957 if (!tx) in nine_translate_shader()
3960 if (tx_ctor(tx, screen, info) == E_OUTOFMEMORY) { in nine_translate_shader()
3967 if (((tx->version.major << 16) | tx->version.minor) > 0x00030000) { in nine_translate_shader()
3970 tx->version.major, tx->version.minor); in nine_translate_shader()
3973 if (tx->processor != processor) { in nine_translate_shader()
3975 DBG("Shader type mismatch: %u / %u !\n", tx->processor, processor); in nine_translate_shader()
3979 tx->version.major, tx->version.minor); in nine_translate_shader()
3981 parse_shader(tx); in nine_translate_shader()
3983 if (tx->failure) { in nine_translate_shader()
3988 ureg_destroy(tx->ureg); in nine_translate_shader()
3994 if (!tx->indirect_const_access && !info->swvp_on && tx->num_slots > 0) { in nine_translate_shader()
4000 ureg_destroy(tx->ureg); in nine_translate_shader()
4002 if (tx->num_inst_labels) in nine_translate_shader()
4003 FREE(tx->inst_labels); in nine_translate_shader()
4004 FREE(tx->lconstf); in nine_translate_shader()
4005 FREE(tx->regs.r); in nine_translate_shader()
4010 if (tx->slots_used[i]) { in nine_translate_shader()
4026 if (tx->slots_used[i]) { in nine_translate_shader()
4038 if (tx_ctor(tx, screen, info) == E_OUTOFMEMORY) { in nine_translate_shader()
4042 tx->slot_map = slot_map; in nine_translate_shader()
4043 parse_shader(tx); in nine_translate_shader()
4044 assert(!tx->failure); in nine_translate_shader()
4052 assert(j == tx->num_slots); in nine_translate_shader()
4057 if (tx->num_lconstf && tx->indirect_const_access) { in nine_translate_shader()
4065 data = MALLOC(tx->num_lconstf * 4 * sizeof(float)); in nine_translate_shader()
4070 indices = MALLOC(tx->num_lconstf * sizeof(indices[0])); in nine_translate_shader()
4075 for (n = 0; n < tx->num_lconstf; ++n) { in nine_translate_shader()
4076 for (k = 0, i = 0; i < tx->num_lconstf; ++i) { in nine_translate_shader()
4077 if (tx->lconstf[i].idx < tx->lconstf[k].idx) in nine_translate_shader()
4080 indices[n] = tx->lconstf[k].idx; in nine_translate_shader()
4081 memcpy(&data[n * 4], &tx->lconstf[k].f[0], 4 * sizeof(float)); in nine_translate_shader()
4082 tx->lconstf[k].idx = INT_MAX; in nine_translate_shader()
4086 for (n = 1, i = 1; i < tx->num_lconstf; ++i) in nine_translate_shader()
4098 for (i = 1; i < tx->num_lconstf; ++i) { in nine_translate_shader()
4121 if (tx->indirect_const_access) { /* vs only */ in nine_translate_shader()
4123 tx->num_slots = MAX2(tx->num_slots, device->max_vs_const_f); in nine_translate_shader()
4127 info->const_used_size = sizeof(float[4]) * tx->num_slots; in nine_translate_shader()
4128 if (tx->num_slots) in nine_translate_shader()
4129 ureg_DECL_constant2D(tx->ureg, 0, tx->num_slots-1, 0); in nine_translate_shader()
4131 ureg_DECL_constant2D(tx->ureg, 0, 4095, 0); in nine_translate_shader()
4132 ureg_DECL_constant2D(tx->ureg, 0, 4095, 1); in nine_translate_shader()
4133 ureg_DECL_constant2D(tx->ureg, 0, 2047, 2); in nine_translate_shader()
4134 ureg_DECL_constant2D(tx->ureg, 0, 511, 3); in nine_translate_shader()
4138 ureg_DECL_constant2D(tx->ureg, 0, 2, 4); /* Viewport data */ in nine_translate_shader()
4141 const struct tgsi_token *toks = ureg_get_tokens(tx->ureg, NULL); in nine_translate_shader()
4148 tx->output_info, in nine_translate_shader()
4149 tx->num_outputs, in nine_translate_shader()
4151 info->cso = nine_create_shader_with_so_and_destroy(tx->ureg, pipe, &(info->so)); in nine_translate_shader()
4153 info->cso = nine_create_shader_with_so_and_destroy(tx->ureg, pipe, NULL); in nine_translate_shader()
4163 info->byte_size = (tx->parse - tx->byte_code) * sizeof(DWORD); in nine_translate_shader()
4167 tx_dtor(tx); in nine_translate_shader()