mirror of
https://github.com/RPCS3/rpcs3.git
synced 2025-07-07 23:41:26 +12:00
vk/gl: Enable alpha test in shaders (#1743)
This commit is contained in:
parent
9710044134
commit
c4102f3b18
6 changed files with 77 additions and 2 deletions
|
@ -35,6 +35,8 @@ void GLFragmentDecompilerThread::insertHeader(std::stringstream & OS)
|
|||
OS << " mat4 scaleOffsetMat;\n";
|
||||
OS << " float fog_param0;\n";
|
||||
OS << " float fog_param1;\n";
|
||||
OS << " uint alpha_test;\n";
|
||||
OS << " float alpha_ref;\n";
|
||||
OS << "};\n";
|
||||
}
|
||||
|
||||
|
@ -205,10 +207,14 @@ void GLFragmentDecompilerThread::insertMainEnd(std::stringstream & OS)
|
|||
{ "ocol3", m_ctrl & CELL_GCM_SHADER_CONTROL_32_BITS_EXPORTS ? "r4" : "h8" },
|
||||
};
|
||||
|
||||
std::string first_output_name;
|
||||
for (int i = 0; i < sizeof(table) / sizeof(*table); ++i)
|
||||
{
|
||||
if (m_parr.HasParam(PF_PARAM_NONE, "vec4", table[i].second))
|
||||
{
|
||||
OS << " " << table[i].first << " = " << table[i].second << ";" << std::endl;
|
||||
if (first_output_name.empty()) first_output_name = table[i].first;
|
||||
}
|
||||
}
|
||||
|
||||
if (m_ctrl & CELL_GCM_SHADER_CONTROL_DEPTH_EXPORT)
|
||||
|
@ -223,6 +229,30 @@ void GLFragmentDecompilerThread::insertMainEnd(std::stringstream & OS)
|
|||
}
|
||||
}
|
||||
|
||||
if (!first_output_name.empty())
|
||||
{
|
||||
switch (m_prog.alpha_func)
|
||||
{
|
||||
case rsx::comparaison_function::equal:
|
||||
OS << " if (bool(alpha_test) && " << first_output_name << ".a != alpha_ref) discard;\n";
|
||||
break;
|
||||
case rsx::comparaison_function::not_equal:
|
||||
OS << " if (bool(alpha_test) && " << first_output_name << ".a == alpha_ref) discard;\n";
|
||||
break;
|
||||
case rsx::comparaison_function::less_or_equal:
|
||||
OS << " if (bool(alpha_test) && " << first_output_name << ".a > alpha_ref) discard;\n";
|
||||
break;
|
||||
case rsx::comparaison_function::less:
|
||||
OS << " if (bool(alpha_test) && " << first_output_name << ".a >= alpha_ref) discard;\n";
|
||||
break;
|
||||
case rsx::comparaison_function::greater:
|
||||
OS << " if (bool(alpha_test) && " << first_output_name << ".a <= alpha_ref) discard;\n";
|
||||
break;
|
||||
case rsx::comparaison_function::greater_or_equal:
|
||||
OS << " if (bool(alpha_test) && " << first_output_name << ".a < alpha_ref) discard;\n";
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
OS << "}" << std::endl;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue