void FragmentProgramDecompiler::SetDst(std::string code, bool append_mask) { if (!src0.exec_if_eq && !src0.exec_if_gr && !src0.exec_if_lt) return; switch (src1.scale) { case 0: break; case 1: code = "(" + code + " * 2.0)"; break; case 2: code = "(" + code + " * 4.0)"; break; case 3: code = "(" + code + " * 8.0)"; break; case 5: code = "(" + code + " / 2.0)"; break; case 6: code = "(" + code + " / 4.0)"; break; case 7: code = "(" + code + " / 8.0)"; break; default: LOG_ERROR(RSX, "Bad scale: %d", u32{ src1.scale }); Emu.Pause(); break; } if (dst.saturate) { code = saturate(code); } code += (append_mask ? "$m" : ""); if (dst.no_dest) { if (dst.set_cond) { AddCode("$ifcond " + m_parr.AddParam(PF_PARAM_NONE, getFloatTypeName(4), "cc" + std::to_string(src0.cond_mod_reg_index)) + "$m = " + code + ";"); } else { AddCode("$ifcond " + code + ";"); } return; } std::string dest = AddReg(dst.dest_reg, dst.fp16) + "$m"; AddCodeCond(Format(dest), code); //AddCode("$ifcond " + dest + code + (append_mask ? "$m;" : ";")); if (dst.set_cond) { AddCode(m_parr.AddParam(PF_PARAM_NONE, getFloatTypeName(4), "cc" + std::to_string(src0.cond_mod_reg_index)) + "$m = " + dest + ";"); } }
void VertexProgramDecompiler::SetDST(bool is_sca, std::string value) { if (d0.cond == 0) return; enum { lt = 0x1, eq = 0x2, gt = 0x4, }; std::string mask = GetMask(is_sca); if (is_sca) { value = getFloatTypeName(4) + "(" + value + ")"; } value += mask; if (d0.staturate) { value = "clamp(" + value + ", 0.0, 1.0)"; } std::string dest; if (d0.cond_update_enable_0 && d0.cond_update_enable_1) { dest = m_parr.AddParam(PF_PARAM_NONE, getFloatTypeName(4), "cc" + std::to_string(d0.cond_reg_sel_1), getFloatTypeName(4) + "(0., 0., 0., 0.)") + mask; } else if (d3.dst != 0x1f || (is_sca ? d3.sca_dst_tmp != 0x3f : d0.dst_tmp != 0x3f)) { dest = GetDST(is_sca) + mask; } //std::string code; //if (d0.cond_test_enable) // code += "$ifcond "; //code += dest + value; //AddCode(code + ";"); AddCodeCond(Format(dest), value); }
void GLVertexDecompilerThread::SetDST(bool is_sca, std::string value) { if (d0.cond == 0) return; enum { lt = 0x1, eq = 0x2, gt = 0x4, }; std::string mask = GetMask(is_sca); value += mask; if (is_sca && d0.vec_result) { //value = "vec4(" + value + ")"; } if (d0.staturate) { value = "clamp(" + value + ", 0.0, 1.0)"; } std::string dest; if (d0.cond_update_enable_0 && d0.cond_update_enable_1) { dest = m_parr.AddParam(PARAM_NONE, "vec4", "cc" + std::to_string(d0.cond_reg_sel_1), "vec4(0.0)") + mask; } else if (d3.dst != 0x1f || (is_sca ? d3.sca_dst_tmp != 0x3f : d0.dst_tmp != 0x3f)) { dest = GetDST(is_sca) + mask; } //std::string code; //if (d0.cond_test_enable) // code += "$ifcond "; //code += dest + value; //AddCode(code + ";"); AddCodeCond(Format(dest), value); }