mirror of
https://github.com/RPCSX/rpcsx.git
synced 2026-04-04 14:08:37 +00:00
rsx/decompilers: Avoid std::endl like the plague. It adds extra processing overhead
This commit is contained in:
parent
d7662e54cc
commit
a69f19a9ab
6 changed files with 244 additions and 244 deletions
|
|
@ -30,13 +30,13 @@ std::string GLVertexDecompilerThread::compareFunction(COMPARE f, const std::stri
|
|||
|
||||
void GLVertexDecompilerThread::insertHeader(std::stringstream &OS)
|
||||
{
|
||||
OS << "#version 430" << std::endl << std::endl;
|
||||
OS << "layout(std140, binding = 0) uniform ScaleOffsetBuffer" << std::endl;
|
||||
OS << "{" << std::endl;
|
||||
OS << " mat4 scaleOffsetMat;" << std::endl;
|
||||
OS << " ivec4 userClipEnabled[2];" << std::endl;
|
||||
OS << " vec4 userClipFactor[2];" << std::endl;
|
||||
OS << "};" << std::endl;
|
||||
OS << "#version 430\n\n";
|
||||
OS << "layout(std140, binding = 0) uniform ScaleOffsetBuffer\n";
|
||||
OS << "{\n";
|
||||
OS << " mat4 scaleOffsetMat;\n";
|
||||
OS << " ivec4 userClipEnabled[2];\n";
|
||||
OS << " vec4 userClipFactor[2];\n";
|
||||
OS << "};\n";
|
||||
}
|
||||
|
||||
void GLVertexDecompilerThread::insertInputs(std::stringstream & OS, const std::vector<ParamType>& inputs)
|
||||
|
|
@ -77,7 +77,7 @@ void GLVertexDecompilerThread::insertInputs(std::stringstream & OS, const std::v
|
|||
}
|
||||
|
||||
std::string samplerType = is_int ? "isamplerBuffer" : "samplerBuffer";
|
||||
OS << "layout(location=" << location++ << ")" << " uniform " << samplerType << " " << PI.name << "_buffer;" << std::endl;
|
||||
OS << "layout(location=" << location++ << ")" << " uniform " << samplerType << " " << PI.name << "_buffer;\n";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -86,11 +86,11 @@ void GLVertexDecompilerThread::insertInputs(std::stringstream & OS, const std::v
|
|||
|
||||
void GLVertexDecompilerThread::insertConstants(std::stringstream & OS, const std::vector<ParamType> & constants)
|
||||
{
|
||||
OS << "layout(std140, binding = 1) uniform VertexConstantsBuffer" << std::endl;
|
||||
OS << "{" << std::endl;
|
||||
OS << " vec4 vc[468];" << std::endl;
|
||||
OS << " uint transform_branch_bits;" << std::endl;
|
||||
OS << "};" << std::endl << std::endl;
|
||||
OS << "layout(std140, binding = 1) uniform VertexConstantsBuffer\n";
|
||||
OS << "{\n";
|
||||
OS << " vec4 vc[468];\n";
|
||||
OS << " uint transform_branch_bits;\n";
|
||||
OS << "};\n\n";
|
||||
|
||||
for (const ParamType &PT: constants)
|
||||
{
|
||||
|
|
@ -99,7 +99,7 @@ void GLVertexDecompilerThread::insertConstants(std::stringstream & OS, const std
|
|||
if (PI.name == "vc[468]")
|
||||
continue;
|
||||
|
||||
OS << "uniform " << PT.type << " " << PI.name << ";" << std::endl;
|
||||
OS << "uniform " << PT.type << " " << PI.name << ";\n";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -166,7 +166,7 @@ void GLVertexDecompilerThread::insertOutputs(std::stringstream & OS, const std::
|
|||
if (front_back_specular && name == "spec_color")
|
||||
name = "back_spec_color";
|
||||
|
||||
OS << "out vec4 " << name << ";" << std::endl;
|
||||
OS << "out vec4 " << name << ";\n";
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
@ -174,16 +174,16 @@ void GLVertexDecompilerThread::insertOutputs(std::stringstream & OS, const std::
|
|||
//Force some outputs to be declared even if unused
|
||||
if (i.need_declare && (rsx_vertex_program.output_mask & i.check_mask_value) > 0)
|
||||
{
|
||||
OS << "out vec4 " << i.name << ";" << std::endl;
|
||||
OS << "out vec4 " << i.name << ";\n";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (insert_back_diffuse && insert_front_diffuse)
|
||||
OS << "out vec4 front_diff_color;" << std::endl;
|
||||
OS << "out vec4 front_diff_color;\n";
|
||||
|
||||
if (insert_back_specular && insert_front_specular)
|
||||
OS << "out vec4 front_spec_color;" << std::endl;
|
||||
OS << "out vec4 front_spec_color;\n";
|
||||
}
|
||||
|
||||
namespace
|
||||
|
|
@ -228,7 +228,7 @@ namespace
|
|||
|
||||
if (!real_input.is_array)
|
||||
{
|
||||
OS << vecType << PI.name << " = texelFetch(" << PI.name << "_buffer, 0)" << scale << ";" << std::endl;
|
||||
OS << vecType << PI.name << " = texelFetch(" << PI.name << "_buffer, 0)" << scale << ";\n";
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
@ -236,21 +236,21 @@ namespace
|
|||
{
|
||||
if (real_input.is_modulo)
|
||||
{
|
||||
OS << vecType << PI.name << "= texelFetch(" << PI.name << "_buffer, gl_VertexID %" << real_input.frequency << ")" << scale << ";" << std::endl;
|
||||
OS << vecType << PI.name << "= texelFetch(" << PI.name << "_buffer, gl_VertexID %" << real_input.frequency << ")" << scale << ";\n";
|
||||
return;
|
||||
}
|
||||
|
||||
OS << vecType << PI.name << "= texelFetch(" << PI.name << "_buffer, gl_VertexID /" << real_input.frequency << ")" << scale << ";" << std::endl;
|
||||
OS << vecType << PI.name << "= texelFetch(" << PI.name << "_buffer, gl_VertexID /" << real_input.frequency << ")" << scale << ";\n";
|
||||
return;
|
||||
}
|
||||
|
||||
OS << vecType << PI.name << "= texelFetch(" << PI.name << "_buffer, gl_VertexID)" << scale << ";" << std::endl;
|
||||
OS << vecType << PI.name << "= texelFetch(" << PI.name << "_buffer, gl_VertexID)" << scale << ";\n";
|
||||
return;
|
||||
}
|
||||
|
||||
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);\n";
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -271,8 +271,8 @@ void GLVertexDecompilerThread::insertMainStart(std::stringstream & OS)
|
|||
}
|
||||
}
|
||||
|
||||
OS << "void vs_main(" << parameters << ")" << std::endl;
|
||||
OS << "{" << std::endl;
|
||||
OS << "void vs_main(" << parameters << ")\n";
|
||||
OS << "{\n";
|
||||
|
||||
//Declare temporary registers, ignoring those mapped to outputs
|
||||
for (const ParamType PT : m_parr.params[PF_PARAM_NONE])
|
||||
|
|
@ -286,7 +286,7 @@ void GLVertexDecompilerThread::insertMainStart(std::stringstream & OS)
|
|||
if (!PI.value.empty())
|
||||
OS << " = " << PI.value;
|
||||
|
||||
OS << ";" << std::endl;
|
||||
OS << ";\n";
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -302,7 +302,7 @@ void GLVertexDecompilerThread::insertMainStart(std::stringstream & OS)
|
|||
{
|
||||
for (const ParamItem &PI : PT.items)
|
||||
{
|
||||
OS << " vec2 " << PI.name << "_coord_scale = vec2(1.);" << std::endl;
|
||||
OS << " vec2 " << PI.name << "_coord_scale = vec2(1.);\n";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -310,10 +310,10 @@ void GLVertexDecompilerThread::insertMainStart(std::stringstream & OS)
|
|||
|
||||
void GLVertexDecompilerThread::insertMainEnd(std::stringstream & OS)
|
||||
{
|
||||
OS << "}" << std::endl << std::endl;
|
||||
OS << "}\n\n";
|
||||
|
||||
OS << "void main ()" << std::endl;
|
||||
OS << "{" << std::endl;
|
||||
OS << "void main ()\n";
|
||||
OS << "{\n";
|
||||
|
||||
std::string parameters = "";
|
||||
|
||||
|
|
@ -335,13 +335,13 @@ void GLVertexDecompilerThread::insertMainEnd(std::stringstream & OS)
|
|||
if (!PI.value.empty())
|
||||
OS << "= " << PI.value;
|
||||
|
||||
OS << ";" << std::endl;
|
||||
OS << ";\n";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
OS << std::endl << " vs_main(" << parameters << ");" << std::endl << std::endl;
|
||||
OS << "\n" << " vs_main(" << parameters << ");\n\n";
|
||||
|
||||
bool insert_front_diffuse = (rsx_vertex_program.output_mask & CELL_GCM_ATTRIB_OUTPUT_MASK_FRONTDIFFUSE) != 0;
|
||||
bool insert_front_specular = (rsx_vertex_program.output_mask & CELL_GCM_ATTRIB_OUTPUT_MASK_FRONTSPECULAR) != 0;
|
||||
|
|
@ -377,19 +377,19 @@ void GLVertexDecompilerThread::insertMainEnd(std::stringstream & OS)
|
|||
if (condition.empty() || i.default_val.empty())
|
||||
{
|
||||
if (!condition.empty()) condition = "if " + condition;
|
||||
OS << " " << condition << name << " = " << i.src_reg << i.src_reg_mask << ";" << std::endl;
|
||||
OS << " " << condition << name << " = " << i.src_reg << i.src_reg_mask << ";\n";
|
||||
}
|
||||
else
|
||||
{
|
||||
//Insert if-else condition
|
||||
OS << " " << name << " = " << condition << "? " << i.src_reg << i.src_reg_mask << ": " << i.default_val << ";" << std::endl;
|
||||
OS << " " << name << " = " << condition << "? " << i.src_reg << i.src_reg_mask << ": " << i.default_val << ";\n";
|
||||
}
|
||||
}
|
||||
else if (i.need_declare && (rsx_vertex_program.output_mask & i.check_mask_value) > 0)
|
||||
{
|
||||
//An output was declared but nothing was written to it
|
||||
//Set it to all ones (Atelier Escha)
|
||||
OS << " " << i.name << " = vec4(1.);" << std::endl;
|
||||
OS << " " << i.name << " = vec4(1.);\n";
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -401,7 +401,7 @@ void GLVertexDecompilerThread::insertMainEnd(std::stringstream & OS)
|
|||
if (m_parr.HasParam(PF_PARAM_NONE, "vec4", "dst_reg2"))
|
||||
OS << " front_spec_color = dst_reg2;\n";
|
||||
|
||||
OS << " gl_Position = gl_Position * scaleOffsetMat;" << std::endl;
|
||||
OS << " gl_Position = gl_Position * scaleOffsetMat;\n";
|
||||
|
||||
//Since our clip_space is symetrical [-1, 1] we map it to linear space using the eqn:
|
||||
//ln = (clip * 2) - 1 to fully utilize the 0-1 range of the depth buffer
|
||||
|
|
@ -413,10 +413,10 @@ void GLVertexDecompilerThread::insertMainEnd(std::stringstream & OS)
|
|||
//It is therefore critical that this step is done post-transform and the result re-scaled by w
|
||||
//SEE Naruto: UNS
|
||||
|
||||
OS << " float ndc_z = gl_Position.z / gl_Position.w;" << std::endl;
|
||||
OS << " ndc_z = (ndc_z * 2.) - 1.;" << std::endl;
|
||||
OS << " gl_Position.z = ndc_z * gl_Position.w;" << std::endl;
|
||||
OS << "}" << std::endl;
|
||||
OS << " float ndc_z = gl_Position.z / gl_Position.w;\n";
|
||||
OS << " ndc_z = (ndc_z * 2.) - 1.;\n";
|
||||
OS << " gl_Position.z = ndc_z * gl_Position.w;\n";
|
||||
OS << "}\n";
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue