Skip to content

Commit

Permalink
gl/vk: Flip wpos if origin != top
Browse files Browse the repository at this point in the history
  • Loading branch information
kd-11 committed Sep 27, 2016
1 parent 9481d00 commit eaf94ed
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 3 deletions.
2 changes: 1 addition & 1 deletion rpcs3/Emu/RSX/Common/FragmentProgramDecompiler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
4 changes: 2 additions & 2 deletions rpcs3/Emu/RSX/D3D12/D3D12FragmentProgramDecompiler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 6 additions & 0 deletions rpcs3/Emu/RSX/GL/GLFragmentProgram.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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])
{
Expand Down
6 changes: 6 additions & 0 deletions rpcs3/Emu/RSX/VK/VKFragmentProgram.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down

0 comments on commit eaf94ed

Please sign in to comment.