1
0
mirror of https://github.com/RPCS3/rpcs3.git synced 2024-11-22 02:32:36 +01:00

rsx: Clear vertex output register if nothing is written to it

- On NVIDIA GPUs, gl_Position is not initialized. Always clear to 0 to avoid on-screen crap
This commit is contained in:
kd-11 2021-02-05 21:42:00 +03:00 committed by kd-11
parent 2865865382
commit ddac4686a7

View File

@ -269,7 +269,7 @@ std::string VertexProgramDecompiler::GetRawCond()
swizzle += f[d0.mask_w]; swizzle += f[d0.mask_w];
swizzle = swizzle == "xyzw" ? "" : "." + swizzle; swizzle = swizzle == "xyzw" ? "" : "." + swizzle;
return compareFunction(cond_string_table[d0.cond], AddCondReg() + swizzle, getFloatTypeName(4) + "(0., 0., 0., 0.)" + swizzle); return compareFunction(cond_string_table[d0.cond], AddCondReg() + swizzle, getFloatTypeName(4) + "(0.)" + swizzle);
} }
std::string VertexProgramDecompiler::GetCond() std::string VertexProgramDecompiler::GetCond()
@ -320,12 +320,12 @@ std::string VertexProgramDecompiler::AddAddrReg()
{ {
static const char f[] = { 'x', 'y', 'z', 'w' }; static const char f[] = { 'x', 'y', 'z', 'w' };
const auto mask = std::string(".") + f[d0.addr_swz]; const auto mask = std::string(".") + f[d0.addr_swz];
return m_parr.AddParam(PF_PARAM_NONE, getIntTypeName(4), "a" + std::to_string(d0.addr_reg_sel_1), getIntTypeName(4) + "(0, 0, 0, 0)") + mask; return m_parr.AddParam(PF_PARAM_NONE, getIntTypeName(4), "a" + std::to_string(d0.addr_reg_sel_1), getIntTypeName(4) + "(0)") + mask;
} }
std::string VertexProgramDecompiler::AddCondReg() std::string VertexProgramDecompiler::AddCondReg()
{ {
return m_parr.AddParam(PF_PARAM_NONE, getFloatTypeName(4), "cc" + std::to_string(d0.cond_reg_sel_1), getFloatTypeName(4) + "(0., 0., 0., 0.)"); return m_parr.AddParam(PF_PARAM_NONE, getFloatTypeName(4), "cc" + std::to_string(d0.cond_reg_sel_1), getFloatTypeName(4) + "(0.)");
} }
u32 VertexProgramDecompiler::GetAddr() u32 VertexProgramDecompiler::GetAddr()
@ -383,11 +383,13 @@ std::string VertexProgramDecompiler::BuildCode()
lvl += m_instructions[i].open_scopes; lvl += m_instructions[i].open_scopes;
} }
bool is_valid = m_parr.HasParam(PF_PARAM_OUT, getFloatTypeName(4), "dst_reg0"); if (const auto float4_type = getFloatTypeName(4); !m_parr.HasParam(PF_PARAM_OUT, float4_type, "dst_reg0"))
if (!is_valid)
{ {
rsx_log.warning("Vertex program has no POS output, shader will be NOPed"); rsx_log.warning("Vertex program has no POS output, shader will be NOPed");
main_body = "/*" + main_body + "*/"; main_body = "/*" + main_body + "*/";
// Initialize vertex output register to all 0, GPU hw does not always clear position register
m_parr.AddParam(PF_PARAM_OUT, float4_type, "dst_reg0", float4_type + "(0., 0., 0., 1.)");
} }
std::stringstream OS; std::stringstream OS;