gl: Properly emulate signed normalized wide integers

Another fix for signed normalized formats; single component vectors are swizzled
This commit is contained in:
kd-11 2017-06-14 19:24:32 +03:00
parent 98cf72e0fb
commit 30f276a49b
1 changed files with 49 additions and 30 deletions

View File

@ -186,8 +186,26 @@ void GLVertexDecompilerThread::insertOutputs(std::stringstream & OS, const std::
OS << "out vec4 front_spec_color;" << std::endl; OS << "out vec4 front_spec_color;" << std::endl;
} }
void add_input(std::stringstream & OS, const ParamItem &PI, const std::vector<rsx_vertex_input> &inputs) namespace
{ {
std::string expand_to_vec4(std::string value, u8 vector_size)
{
switch (vector_size)
{
case 2:
return "vec4(" + value + ", " + value + ", 1., 1.)";
case 3:
return "vec4(" + value + ", " + value + ", " + value + ", 1.)";
case 1:
case 4:
//Expand not required
//In case its one component, read is swizzled as .xxxx (GOW1 loading screen)
return value;
}
}
void add_input(std::stringstream & OS, const ParamItem &PI, const std::vector<rsx_vertex_input> &inputs)
{
for (const auto &real_input : inputs) for (const auto &real_input : inputs)
{ {
if (real_input.location != PI.location) if (real_input.location != PI.location)
@ -201,9 +219,9 @@ void add_input(std::stringstream & OS, const ParamItem &PI, const std::vector<rs
if (real_input.flags & GL_VP_SINT_MASK) if (real_input.flags & GL_VP_SINT_MASK)
{ {
if (real_input.flags & GL_VP_ATTRIB_S16_INT) if (real_input.flags & GL_VP_ATTRIB_S16_INT)
scale = " / 32767."; scale = " / " + expand_to_vec4("32767.", real_input.size);
else else
scale = " / 2147483647."; scale = " / " + expand_to_vec4("2147483647.", real_input.size);
} }
if (!real_input.is_array) if (!real_input.is_array)
@ -231,6 +249,7 @@ void add_input(std::stringstream & OS, const ParamItem &PI, const std::vector<rs
LOG_WARNING(RSX, "Vertex input %s does not have a matching vertex_input declaration", PI.name.c_str()); LOG_WARNING(RSX, "Vertex input %s does not have a matching vertex_input declaration", PI.name.c_str());
OS << " vec4 " << PI.name << "= texelFetch(" << PI.name << "_buffer, gl_VertexID);" << std::endl; OS << " vec4 " << PI.name << "= texelFetch(" << PI.name << "_buffer, gl_VertexID);" << std::endl;
}
} }
void GLVertexDecompilerThread::insertMainStart(std::stringstream & OS) void GLVertexDecompilerThread::insertMainStart(std::stringstream & OS)