mirror of
https://github.com/RPCS3/rpcs3.git
synced 2025-04-28 13:28:01 +03:00
rsx: Don't accept garbage shader input
This commit is contained in:
parent
0d2714a1d9
commit
9a35684507
2 changed files with 31 additions and 11 deletions
|
@ -270,11 +270,6 @@ std::string FragmentProgramDecompiler::AddTex()
|
||||||
return m_parr.AddParam(PF_PARAM_UNIFORM, sampler, std::string("tex") + std::to_string(dst.tex_num));
|
return m_parr.AddParam(PF_PARAM_UNIFORM, sampler, std::string("tex") + std::to_string(dst.tex_num));
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string FragmentProgramDecompiler::AddType3()
|
|
||||||
{
|
|
||||||
return m_parr.AddParam(PF_PARAM_NONE, getFloatTypeName(4), "src3", getFloatTypeName(4) + "(1.)");
|
|
||||||
}
|
|
||||||
|
|
||||||
std::string FragmentProgramDecompiler::AddX2d()
|
std::string FragmentProgramDecompiler::AddX2d()
|
||||||
{
|
{
|
||||||
return m_parr.AddParam(PF_PARAM_NONE, getFloatTypeName(4), "x2d", getFloatTypeName(4) + "(0.)");
|
return m_parr.AddParam(PF_PARAM_NONE, getFloatTypeName(4), "x2d", getFloatTypeName(4) + "(0.)");
|
||||||
|
@ -562,6 +557,12 @@ template<typename T> std::string FragmentProgramDecompiler::GetSRC(T src)
|
||||||
const std::string reg_var = (register_id < std::size(reg_table))? reg_table[register_id] : "unk";
|
const std::string reg_var = (register_id < std::size(reg_table))? reg_table[register_id] : "unk";
|
||||||
bool insert = true;
|
bool insert = true;
|
||||||
|
|
||||||
|
if (reg_var == "unk")
|
||||||
|
{
|
||||||
|
m_is_valid_ucode = false;
|
||||||
|
insert = false;
|
||||||
|
}
|
||||||
|
|
||||||
if (src2.use_index_reg && m_loop_count)
|
if (src2.use_index_reg && m_loop_count)
|
||||||
{
|
{
|
||||||
// Dynamically load the input
|
// Dynamically load the input
|
||||||
|
@ -704,7 +705,10 @@ template<typename T> std::string FragmentProgramDecompiler::GetSRC(T src)
|
||||||
rsx_log.error("Src type 3 used, opcode=0x%X, dst=0x%X s0=0x%X s1=0x%X s2=0x%X",
|
rsx_log.error("Src type 3 used, opcode=0x%X, dst=0x%X s0=0x%X s1=0x%X s2=0x%X",
|
||||||
dst.opcode, dst.HEX, src0.HEX, src1.HEX, src2.HEX);
|
dst.opcode, dst.HEX, src0.HEX, src1.HEX, src2.HEX);
|
||||||
|
|
||||||
ret += AddType3();
|
// This is not some special type, it is a bug indicating memory corruption
|
||||||
|
// Shaders that are even slightly off do not execute on realhw to any meaningful degree
|
||||||
|
m_is_valid_ucode = false;
|
||||||
|
ret += "src3";
|
||||||
precision_modifier = RSX_FP_PRECISION_REAL;
|
precision_modifier = RSX_FP_PRECISION_REAL;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
@ -801,6 +805,22 @@ std::string FragmentProgramDecompiler::BuildCode()
|
||||||
}
|
}
|
||||||
|
|
||||||
std::stringstream OS;
|
std::stringstream OS;
|
||||||
|
|
||||||
|
if (!m_is_valid_ucode)
|
||||||
|
{
|
||||||
|
// If the code is broken, do not compile. Simply NOP main and write empty outputs
|
||||||
|
insertHeader(OS);
|
||||||
|
OS << "\n";
|
||||||
|
OS << "void main()\n";
|
||||||
|
OS << "{\n";
|
||||||
|
OS << "#if 0\n";
|
||||||
|
OS << main << "\n";
|
||||||
|
OS << "#endif\n";
|
||||||
|
OS << " discard;\n";
|
||||||
|
OS << "}\n";
|
||||||
|
return OS.str();
|
||||||
|
}
|
||||||
|
|
||||||
insertHeader(OS);
|
insertHeader(OS);
|
||||||
OS << "\n";
|
OS << "\n";
|
||||||
insertConstants(OS);
|
insertConstants(OS);
|
||||||
|
@ -1206,6 +1226,7 @@ std::string FragmentProgramDecompiler::Decompile()
|
||||||
m_location = 0;
|
m_location = 0;
|
||||||
m_loop_count = 0;
|
m_loop_count = 0;
|
||||||
m_code_level = 1;
|
m_code_level = 1;
|
||||||
|
m_is_valid_ucode = true;
|
||||||
|
|
||||||
enum
|
enum
|
||||||
{
|
{
|
||||||
|
|
|
@ -155,6 +155,8 @@ class FragmentProgramDecompiler
|
||||||
std::vector<u32> m_end_offsets;
|
std::vector<u32> m_end_offsets;
|
||||||
std::vector<u32> m_else_offsets;
|
std::vector<u32> m_else_offsets;
|
||||||
|
|
||||||
|
bool m_is_valid_ucode = true;
|
||||||
|
|
||||||
std::array<temp_register, 64> temp_registers;
|
std::array<temp_register, 64> temp_registers;
|
||||||
|
|
||||||
std::string GetMask() const;
|
std::string GetMask() const;
|
||||||
|
@ -169,13 +171,10 @@ class FragmentProgramDecompiler
|
||||||
void AddFlowOp(const std::string& code);
|
void AddFlowOp(const std::string& code);
|
||||||
std::string Format(const std::string& code, bool ignore_redirects = false);
|
std::string Format(const std::string& code, bool ignore_redirects = false);
|
||||||
|
|
||||||
//Technically a temporary workaround until we know what type3 is
|
// Support the transform-2d temp result for use with TEXBEM
|
||||||
std::string AddType3();
|
|
||||||
|
|
||||||
//Support the transform-2d temp result for use with TEXBEM
|
|
||||||
std::string AddX2d();
|
std::string AddX2d();
|
||||||
|
|
||||||
//Prevents operations from overflowing the desired range (tested with fp_dynamic3 autotest sample, DS2 for src1.input_prec_mod)
|
// Prevents operations from overflowing the desired range (tested with fp_dynamic3 autotest sample, DS2 for src1.input_prec_mod)
|
||||||
std::string ClampValue(const std::string& code, u32 precision);
|
std::string ClampValue(const std::string& code, u32 precision);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue