1
0
mirror of https://github.com/RPCS3/rpcs3.git synced 2024-11-26 04:32:35 +01:00

gl/vk: Flip wpos if origin != top

This commit is contained in:
kd-11 2016-09-27 12:54:35 +03:00 committed by raven02
parent 4f74cbe510
commit 38562155d4
4 changed files with 15 additions and 3 deletions

View File

@ -276,7 +276,7 @@ template<typename T> std::string FragmentProgramDecompiler::GetSRC(T src)
{
static const std::string reg_table[] =
{
"gl_FragCoord",
"wpos",
"diff_color", "spec_color",
"fogc",
"tc0", "tc1", "tc2", "tc3", "tc4", "tc5", "tc6", "tc7", "tc8", "tc9",

View File

@ -228,9 +228,9 @@ void D3D12FragmentDecompiler::insertMainStart(std::stringstream & OS)
}
}
// A bit unclean, but works.
OS << " " << "float4 gl_FragCoord = In.Position;" << std::endl;
OS << " " << "float4 wpos = In.Position;" << std::endl;
if (m_prog.origin_mode == rsx::window_origin::bottom)
OS << " gl_FragCoord.y = (" << std::to_string(m_prog.height) << " - gl_FragCoord.y);\n";
OS << " wpos.y = (" << std::to_string(m_prog.height) << " - wpos.y);\n";
OS << " float4 ssa = is_front_face ? float4(1., 1., 1., 1.) : float4(-1., -1., -1., -1.);\n";
// Declare output

View File

@ -250,6 +250,12 @@ void GLFragmentDecompilerThread::insertMainStart(std::stringstream & OS)
}
OS << " vec4 ssa = gl_FrontFacing ? vec4(1.) : vec4(-1.);\n";
OS << " vec4 wpos = gl_FragCoord;\n";
//Flip wpos in Y
//We could optionally export wpos from the VS, but this is so much easier
if (m_prog.origin_mode == rsx::window_origin::bottom)
OS << " wpos.y = " << std::to_string(m_prog.height) << " - wpos.y;\n";
for (const ParamType& PT : m_parr.params[PF_PARAM_UNIFORM])
{

View File

@ -268,6 +268,12 @@ void VKFragmentDecompilerThread::insertMainStart(std::stringstream & OS)
}
OS << " vec4 ssa = gl_FrontFacing ? vec4(1.) : vec4(-1.);\n";
OS << " vec4 wpos = gl_FragCoord;\n";
//Flip wpos in Y
//We could optionally export wpos from the VS, but this is so much easier
if (m_prog.origin_mode == rsx::window_origin::bottom)
OS << " wpos.y = " << std::to_string(m_prog.height) << " - wpos.y;\n";
bool two_sided_enabled = m_prog.front_back_color_enabled && (m_prog.back_color_diffuse_output || m_prog.back_color_specular_output);