rsx/decompilers: Avoid std::endl like the plague. It adds extra processing overhead

This commit is contained in:
kd-11 2017-06-28 19:36:27 +03:00
parent d7662e54cc
commit a69f19a9ab
6 changed files with 244 additions and 244 deletions

View File

@ -35,48 +35,48 @@ std::string D3D12FragmentDecompiler::compareFunction(COMPARE f, const std::strin
void D3D12FragmentDecompiler::insertHeader(std::stringstream & OS)
{
OS << "cbuffer SCALE_OFFSET : register(b0)" << std::endl;
OS << "{" << std::endl;
OS << " float4x4 scaleOffsetMat;" << std::endl;
OS << " int4 userClipEnabled[2];" << std::endl;
OS << " float4 userClipFactor[2];" << std::endl;
OS << "cbuffer SCALE_OFFSET : register(b0)\n";
OS << "{\n";
OS << " float4x4 scaleOffsetMat;\n";
OS << " int4 userClipEnabled[2];\n";
OS << " float4 userClipFactor[2];\n";
OS << " float fog_param0;\n";
OS << " float fog_param1;\n";
OS << " int isAlphaTested;" << std::endl;
OS << " float alphaRef;" << std::endl;
OS << " int isAlphaTested;\n";
OS << " float alphaRef;\n";
OS << " float4 texture_parameters[16];\n";
OS << "};" << std::endl;
OS << "};\n";
}
void D3D12FragmentDecompiler::insertIntputs(std::stringstream & OS)
{
OS << "struct PixelInput" << std::endl;
OS << "{" << std::endl;
OS << " float4 Position : SV_POSITION;" << std::endl;
OS << " float4 diff_color : COLOR0;" << std::endl;
OS << " float4 spec_color : COLOR1;" << std::endl;
OS << " float4 dst_reg3 : COLOR2;" << std::endl;
OS << " float4 dst_reg4 : COLOR3;" << std::endl;
OS << " float4 fogc : FOG;" << std::endl;
OS << " float4 tc9 : TEXCOORD9;" << std::endl;
OS << " float4 tc0 : TEXCOORD0;" << std::endl;
OS << " float4 tc1 : TEXCOORD1;" << std::endl;
OS << " float4 tc2 : TEXCOORD2;" << std::endl;
OS << " float4 tc3 : TEXCOORD3;" << std::endl;
OS << " float4 tc4 : TEXCOORD4;" << std::endl;
OS << " float4 tc5 : TEXCOORD5;" << std::endl;
OS << " float4 tc6 : TEXCOORD6;" << std::endl;
OS << " float4 tc7 : TEXCOORD7;" << std::endl;
OS << " float4 tc8 : TEXCOORD8;" << std::endl;
OS << " float4 dst_userClip0 : SV_ClipDistance0;" << std::endl;
OS << " float4 dst_userClip1 : SV_ClipDistance1;" << std::endl;
OS << "};" << std::endl;
OS << "struct PixelInput\n";
OS << "{\n";
OS << " float4 Position : SV_POSITION;\n";
OS << " float4 diff_color : COLOR0;\n";
OS << " float4 spec_color : COLOR1;\n";
OS << " float4 dst_reg3 : COLOR2;\n";
OS << " float4 dst_reg4 : COLOR3;\n";
OS << " float4 fogc : FOG;\n";
OS << " float4 tc9 : TEXCOORD9;\n";
OS << " float4 tc0 : TEXCOORD0;\n";
OS << " float4 tc1 : TEXCOORD1;\n";
OS << " float4 tc2 : TEXCOORD2;\n";
OS << " float4 tc3 : TEXCOORD3;\n";
OS << " float4 tc4 : TEXCOORD4;\n";
OS << " float4 tc5 : TEXCOORD5;\n";
OS << " float4 tc6 : TEXCOORD6;\n";
OS << " float4 tc7 : TEXCOORD7;\n";
OS << " float4 tc8 : TEXCOORD8;\n";
OS << " float4 dst_userClip0 : SV_ClipDistance0;\n";
OS << " float4 dst_userClip1 : SV_ClipDistance1;\n";
OS << "};\n";
}
void D3D12FragmentDecompiler::insertOutputs(std::stringstream & OS)
{
OS << "struct PixelOutput" << std::endl;
OS << "{" << std::endl;
OS << "struct PixelOutput\n";
OS << "{\n";
const std::pair<std::string, std::string> table[] =
{
{ "ocol0", m_ctrl & CELL_GCM_SHADER_CONTROL_32_BITS_EXPORTS ? "r0" : "h0" },
@ -88,25 +88,25 @@ void D3D12FragmentDecompiler::insertOutputs(std::stringstream & OS)
for (int i = 0; i < sizeof(table) / sizeof(*table); ++i)
{
if (m_parr.HasParam(PF_PARAM_NONE, "float4", table[i].second))
OS << " " << "float4" << " " << table[i].first << " : SV_TARGET" << idx++ << ";" << std::endl;
OS << " " << "float4" << " " << table[i].first << " : SV_TARGET" << idx++ << ";\n";
}
if (m_ctrl & CELL_GCM_SHADER_CONTROL_DEPTH_EXPORT)
OS << " float depth : SV_Depth;" << std::endl;
OS << "};" << std::endl;
OS << " float depth : SV_Depth;\n";
OS << "};\n";
}
void D3D12FragmentDecompiler::insertConstants(std::stringstream & OS)
{
OS << "cbuffer CONSTANT : register(b2)" << std::endl;
OS << "{" << std::endl;
OS << "cbuffer CONSTANT : register(b2)\n";
OS << "{\n";
for (const ParamType &PT : m_parr.params[PF_PARAM_UNIFORM])
{
if (PT.type == "sampler1D" || PT.type == "sampler2D" || PT.type == "samplerCube" || PT.type == "sampler3D")
continue;
for (const ParamItem &PI : PT.items)
OS << " " << PT.type << " " << PI.name << ";" << std::endl;
OS << " " << PT.type << " " << PI.name << ";\n";
}
OS << "};" << std::endl << std::endl;
OS << "};\n\n";
for (const ParamType &PT : m_parr.params[PF_PARAM_UNIFORM])
{
@ -115,8 +115,8 @@ void D3D12FragmentDecompiler::insertConstants(std::stringstream & OS)
for (const ParamItem &PI : PT.items)
{
size_t textureIndex = atoi(PI.name.data() + 3);
OS << "Texture1D " << PI.name << " : register(t" << textureIndex << ");" << std::endl;
OS << "sampler " << PI.name << "sampler : register(s" << textureIndex << ");" << std::endl;
OS << "Texture1D " << PI.name << " : register(t" << textureIndex << ");\n";
OS << "sampler " << PI.name << "sampler : register(s" << textureIndex << ");\n";
}
}
else if (PT.type == "sampler2D")
@ -124,8 +124,8 @@ void D3D12FragmentDecompiler::insertConstants(std::stringstream & OS)
for (const ParamItem &PI : PT.items)
{
size_t textureIndex = atoi(PI.name.data() + 3);
OS << "Texture2D " << PI.name << " : register(t" << textureIndex << ");" << std::endl;
OS << "sampler " << PI.name << "sampler : register(s" << textureIndex << ");" << std::endl;
OS << "Texture2D " << PI.name << " : register(t" << textureIndex << ");\n";
OS << "sampler " << PI.name << "sampler : register(s" << textureIndex << ");\n";
}
}
else if (PT.type == "sampler3D")
@ -133,8 +133,8 @@ void D3D12FragmentDecompiler::insertConstants(std::stringstream & OS)
for (const ParamItem &PI : PT.items)
{
size_t textureIndex = atoi(PI.name.data() + 3);
OS << "Texture3D " << PI.name << " : register(t" << textureIndex << ");" << std::endl;
OS << "sampler " << PI.name << "sampler : register(s" << textureIndex << ");" << std::endl;
OS << "Texture3D " << PI.name << " : register(t" << textureIndex << ");\n";
OS << "sampler " << PI.name << "sampler : register(s" << textureIndex << ");\n";
}
}
else if (PT.type == "samplerCube")
@ -142,8 +142,8 @@ void D3D12FragmentDecompiler::insertConstants(std::stringstream & OS)
for (const ParamItem &PI : PT.items)
{
size_t textureIndex = atoi(PI.name.data() + 3);
OS << "TextureCube " << PI.name << " : register(t" << textureIndex << ");" << std::endl;
OS << "sampler " << PI.name << "sampler : register(s" << textureIndex << ");" << std::endl;
OS << "TextureCube " << PI.name << " : register(t" << textureIndex << ");\n";
OS << "sampler " << PI.name << "sampler : register(s" << textureIndex << ");\n";
}
}
}
@ -210,8 +210,8 @@ void D3D12FragmentDecompiler::insertMainStart(std::stringstream & OS)
"r0", "r1", "r2", "r3", "r4",
"h0", "h2", "h4", "h6", "h8"
};
OS << "void ps_impl(bool is_front_face, PixelInput In, inout float4 r0, inout float4 h0, inout float4 r1, inout float4 h2, inout float4 r2, inout float4 h4, inout float4 r3, inout float4 h6, inout float4 r4, inout float4 h8)" << std::endl;
OS << "{" << std::endl;
OS << "void ps_impl(bool is_front_face, PixelInput In, inout float4 r0, inout float4 h0, inout float4 r1, inout float4 h2, inout float4 r2, inout float4 h4, inout float4 r3, inout float4 h6, inout float4 r4, inout float4 h8)\n";
OS << "{\n";
for (const ParamType &PT : m_parr.params[PF_PARAM_IN])
{
for (const ParamItem &PI : PT.items)
@ -236,11 +236,11 @@ void D3D12FragmentDecompiler::insertMainStart(std::stringstream & OS)
}
if (PI.name == "ssa")
continue;
OS << " " << PT.type << " " << PI.name << " = In." << PI.name << ";" << std::endl;
OS << " " << PT.type << " " << PI.name << " = In." << PI.name << ";\n";
}
}
// A bit unclean, but works.
OS << " " << "float4 wpos = In.Position;" << std::endl;
OS << " " << "float4 wpos = In.Position;\n";
if (m_prog.origin_mode == rsx::window_origin::bottom)
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";
@ -250,7 +250,7 @@ void D3D12FragmentDecompiler::insertMainStart(std::stringstream & OS)
{
for (const ParamItem &PI : PT.items)
if (output_value.find(PI.name) == output_value.end())
OS << " " << PT.type << " " << PI.name << " = float4(0., 0., 0., 0.);" << std::endl;
OS << " " << PT.type << " " << PI.name << " = float4(0., 0., 0., 0.);\n";
}
// Declare texture coordinate scaling component (to handle unormalized texture coordinates)
@ -264,34 +264,34 @@ void D3D12FragmentDecompiler::insertMainStart(std::stringstream & OS)
bool is_unorm = !!(m_prog.unnormalized_coords & (1 << textureIndex));
if (!is_unorm)
{
OS << " float2 " << PI.name << "_scale = float2(1., 1.);" << std::endl;
OS << " float2 " << PI.name << "_scale = float2(1., 1.);\n";
continue;
}
OS << " float2 " << PI.name << "_dim;" << std::endl;
OS << " " << PI.name << ".GetDimensions(" << PI.name << "_dim.x, " << PI.name << "_dim.y);" << std::endl;
OS << " float2 " << PI.name << "_scale = texture_parameters[" << textureIndex << "] / " << PI.name << "_dim;" << std::endl;
OS << " float2 " << PI.name << "_dim;\n";
OS << " " << PI.name << ".GetDimensions(" << PI.name << "_dim.x, " << PI.name << "_dim.y);\n";
OS << " float2 " << PI.name << "_scale = texture_parameters[" << textureIndex << "] / " << PI.name << "_dim;\n";
}
}
}
void D3D12FragmentDecompiler::insertMainEnd(std::stringstream & OS)
{
OS << "}" << std::endl;
OS << std::endl;
OS << "PixelOutput main(PixelInput In, bool is_front_face : SV_IsFrontFace)" << std::endl;
OS << "{" << std::endl;
OS << " float4 r0 = float4(0., 0., 0., 0.);" << std::endl;
OS << " float4 r1 = float4(0., 0., 0., 0.);" << std::endl;
OS << " float4 r2 = float4(0., 0., 0., 0.);" << std::endl;
OS << " float4 r3 = float4(0., 0., 0., 0.);" << std::endl;
OS << " float4 r4 = float4(0., 0., 0., 0.);" << std::endl;
OS << " float4 h0 = float4(0., 0., 0., 0.);" << std::endl;
OS << " float4 h2 = float4(0., 0., 0., 0.);" << std::endl;
OS << " float4 h4 = float4(0., 0., 0., 0.);" << std::endl;
OS << " float4 h6 = float4(0., 0., 0., 0.);" << std::endl;
OS << " float4 h8 = float4(0., 0., 0., 0.);" << std::endl;
OS << " ps_impl(is_front_face, In, r0, h0, r1, h2, r2, h4, r3, h6, r4, h8);" << std::endl;
OS << "}\n";
OS << "\n";
OS << "PixelOutput main(PixelInput In, bool is_front_face : SV_IsFrontFace)\n";
OS << "{\n";
OS << " float4 r0 = float4(0., 0., 0., 0.);\n";
OS << " float4 r1 = float4(0., 0., 0., 0.);\n";
OS << " float4 r2 = float4(0., 0., 0., 0.);\n";
OS << " float4 r3 = float4(0., 0., 0., 0.);\n";
OS << " float4 r4 = float4(0., 0., 0., 0.);\n";
OS << " float4 h0 = float4(0., 0., 0., 0.);\n";
OS << " float4 h2 = float4(0., 0., 0., 0.);\n";
OS << " float4 h4 = float4(0., 0., 0., 0.);\n";
OS << " float4 h6 = float4(0., 0., 0., 0.);\n";
OS << " float4 h8 = float4(0., 0., 0., 0.);\n";
OS << " ps_impl(is_front_face, In, r0, h0, r1, h2, r2, h4, r3, h6, r4, h8);\n";
const std::pair<std::string, std::string> table[] =
{
@ -302,12 +302,12 @@ void D3D12FragmentDecompiler::insertMainEnd(std::stringstream & OS)
};
std::string first_output_name;
OS << " PixelOutput Out = (PixelOutput)0;" << std::endl;
OS << " PixelOutput Out = (PixelOutput)0;\n";
for (int i = 0; i < sizeof(table) / sizeof(*table); ++i)
{
if (m_parr.HasParam(PF_PARAM_NONE, "float4", table[i].second))
{
OS << " Out." << table[i].first << " = " << table[i].second << ";" << std::endl;
OS << " Out." << table[i].first << " = " << table[i].second << ";\n";
if (first_output_name.empty()) first_output_name = table[i].first;
}
}
@ -320,7 +320,7 @@ void D3D12FragmentDecompiler::insertMainEnd(std::stringstream & OS)
* but it writes depth in r1.z and not h2.z.
* Maybe there's a different flag for depth ?
*/
// OS << " Out.depth = " << ((m_ctrl & CELL_GCM_SHADER_CONTROL_32_BITS_EXPORTS) ? "r1.z;" : "h2.z;") << std::endl;
// OS << " Out.depth = " << ((m_ctrl & CELL_GCM_SHADER_CONTROL_32_BITS_EXPORTS) ? "r1.z;" : "h2.z;") << "\n";
OS << " Out.depth = r1.z;\n";
}
else
@ -366,7 +366,7 @@ void D3D12FragmentDecompiler::insertMainEnd(std::stringstream & OS)
OS << make_comparison_test(m_prog.alpha_func, "isAlphaTested && ", "Out." + first_output_name + ".a", "alphaRef");
}
OS << " return Out;" << std::endl;
OS << "}" << std::endl;
OS << " return Out;\n";
OS << "}\n";
}
#endif

View File

@ -28,17 +28,17 @@ std::string D3D12VertexProgramDecompiler::compareFunction(COMPARE f, const std::
void D3D12VertexProgramDecompiler::insertHeader(std::stringstream &OS)
{
OS << "cbuffer SCALE_OFFSET : register(b0)" << std::endl;
OS << "{" << std::endl;
OS << " float4x4 scaleOffsetMat;" << std::endl;
OS << " int4 userClipEnabled[2];" << std::endl;
OS << " float4 userClipFactor[2];" << std::endl;
OS << " float fog_param0;" << std::endl;
OS << " float fog_param1;" << std::endl;
OS << " int isAlphaTested;" << std::endl;
OS << " float alphaRef;" << std::endl;
OS << " float4 texture_parameters[16];" << std::endl;
OS << "};" << std::endl;
OS << "cbuffer SCALE_OFFSET : register(b0)\n";
OS << "{\n";
OS << " float4x4 scaleOffsetMat;\n";
OS << " int4 userClipEnabled[2];\n";
OS << " float4 userClipFactor[2];\n";
OS << " float fog_param0;\n";
OS << " float fog_param1;\n";
OS << " int isAlphaTested;\n";
OS << " float alphaRef;\n";
OS << " float4 texture_parameters[16];\n";
OS << "};\n";
}
namespace
@ -79,36 +79,36 @@ void D3D12VertexProgramDecompiler::insertInputs(std::stringstream & OS, const st
void D3D12VertexProgramDecompiler::insertConstants(std::stringstream & OS, const std::vector<ParamType> & constants)
{
OS << "cbuffer CONSTANT_BUFFER : register(b1)" << std::endl;
OS << "{" << std::endl;
OS << " float4 vc[468];" << std::endl;
OS << " uint transform_branch_bits;" << std::endl;
OS << "};" << std::endl;
OS << "cbuffer CONSTANT_BUFFER : register(b1)\n";
OS << "{\n";
OS << " float4 vc[468];\n";
OS << " uint transform_branch_bits;\n";
OS << "};\n";
}
void D3D12VertexProgramDecompiler::insertOutputs(std::stringstream & OS, const std::vector<ParamType> & outputs)
{
OS << "struct PixelInput" << std::endl;
OS << "{" << std::endl;
OS << " float4 dst_reg0 : SV_POSITION;" << std::endl;
OS << " float4 dst_reg1 : COLOR0;" << std::endl;
OS << " float4 dst_reg2 : COLOR1;" << std::endl;
OS << " float4 dst_reg3 : COLOR2;" << std::endl;
OS << " float4 dst_reg4 : COLOR3;" << std::endl;
OS << " float4 dst_reg5 : FOG;" << std::endl;
OS << " float4 dst_reg6 : TEXCOORD9;" << std::endl;
OS << " float4 dst_reg7 : TEXCOORD0;" << std::endl;
OS << " float4 dst_reg8 : TEXCOORD1;" << std::endl;
OS << " float4 dst_reg9 : TEXCOORD2;" << std::endl;
OS << " float4 dst_reg10 : TEXCOORD3;" << std::endl;
OS << " float4 dst_reg11 : TEXCOORD4;" << std::endl;
OS << " float4 dst_reg12 : TEXCOORD5;" << std::endl;
OS << " float4 dst_reg13 : TEXCOORD6;" << std::endl;
OS << " float4 dst_reg14 : TEXCOORD7;" << std::endl;
OS << " float4 dst_reg15 : TEXCOORD8;" << std::endl;
OS << " float4 dst_userClip0 : SV_ClipDistance0;" << std::endl;
OS << " float4 dst_userClip1 : SV_ClipDistance1;" << std::endl;
OS << "};" << std::endl;
OS << "struct PixelInput\n";
OS << "{\n";
OS << " float4 dst_reg0 : SV_POSITION;\n";
OS << " float4 dst_reg1 : COLOR0;\n";
OS << " float4 dst_reg2 : COLOR1;\n";
OS << " float4 dst_reg3 : COLOR2;\n";
OS << " float4 dst_reg4 : COLOR3;\n";
OS << " float4 dst_reg5 : FOG;\n";
OS << " float4 dst_reg6 : TEXCOORD9;\n";
OS << " float4 dst_reg7 : TEXCOORD0;\n";
OS << " float4 dst_reg8 : TEXCOORD1;\n";
OS << " float4 dst_reg9 : TEXCOORD2;\n";
OS << " float4 dst_reg10 : TEXCOORD3;\n";
OS << " float4 dst_reg11 : TEXCOORD4;\n";
OS << " float4 dst_reg12 : TEXCOORD5;\n";
OS << " float4 dst_reg13 : TEXCOORD6;\n";
OS << " float4 dst_reg14 : TEXCOORD7;\n";
OS << " float4 dst_reg15 : TEXCOORD8;\n";
OS << " float4 dst_userClip0 : SV_ClipDistance0;\n";
OS << " float4 dst_userClip1 : SV_ClipDistance1;\n";
OS << "};\n";
}
static const vertex_reg_info reg_table[] =
@ -172,8 +172,8 @@ void D3D12VertexProgramDecompiler::insertMainStart(std::stringstream & OS)
{
insert_d3d12_legacy_function(OS, false);
OS << "PixelInput main(uint vertex_id : SV_VertexID)" << std::endl;
OS << "{" << std::endl;
OS << "PixelInput main(uint vertex_id : SV_VertexID)\n";
OS << "{\n";
// Declare inside main function
for (const ParamType PT : m_parr.params[PF_PARAM_NONE])
@ -185,7 +185,7 @@ void D3D12VertexProgramDecompiler::insertMainStart(std::stringstream & OS)
OS << " = " << PI.value;
else
OS << " = " << "float4(0., 0., 0., 0.);";
OS << ";" << std::endl;
OS << ";\n";
}
}
@ -201,7 +201,7 @@ void D3D12VertexProgramDecompiler::insertMainStart(std::stringstream & OS)
void D3D12VertexProgramDecompiler::insertMainEnd(std::stringstream & OS)
{
OS << " PixelInput Out = (PixelInput)0;" << std::endl;
OS << " PixelInput Out = (PixelInput)0;\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;
@ -226,12 +226,12 @@ void D3D12VertexProgramDecompiler::insertMainEnd(std::stringstream & OS)
if (condition.empty() || i.default_val.empty())
{
if (!condition.empty()) condition = "if " + condition;
OS << " " << condition << output_name << " = " << i.src_reg << i.src_reg_mask << ";" << std::endl;
OS << " " << condition << output_name << " = " << i.src_reg << i.src_reg_mask << ";\n";
}
else
{
//Condition and fallback values provided
OS << " " << output_name << " = " << condition << "? " << i.src_reg << i.src_reg_mask << ": " << i.default_val << ";" << std::endl;
OS << " " << output_name << " = " << condition << "? " << i.src_reg << i.src_reg_mask << ": " << i.default_val << ";\n";
}
}
}
@ -245,9 +245,9 @@ void D3D12VertexProgramDecompiler::insertMainEnd(std::stringstream & OS)
if (m_parr.HasParam(PF_PARAM_NONE, "float4", "dst_reg2"))
OS << " Out.dst_reg4 = dst_reg2;\n";
OS << " Out.dst_reg0 = mul(Out.dst_reg0, scaleOffsetMat);" << std::endl;
OS << " return Out;" << std::endl;
OS << "}" << std::endl;
OS << " Out.dst_reg0 = mul(Out.dst_reg0, scaleOffsetMat);\n";
OS << " return Out;\n";
OS << "}\n";
}
D3D12VertexProgramDecompiler::D3D12VertexProgramDecompiler(const RSXVertexProgram &prog) :

View File

@ -29,7 +29,7 @@ std::string GLFragmentDecompilerThread::compareFunction(COMPARE f, const std::st
void GLFragmentDecompilerThread::insertHeader(std::stringstream & OS)
{
OS << "#version 420" << std::endl;
OS << "#version 420\n";
}
void GLFragmentDecompilerThread::insertIntputs(std::stringstream & OS)
@ -57,7 +57,7 @@ void GLFragmentDecompilerThread::insertIntputs(std::stringstream & OS)
if (var_name == "fogc")
var_name = "fog_c";
OS << "in " << PT.type << " " << var_name << ";" << std::endl;
OS << "in " << PT.type << " " << var_name << ";\n";
}
}
@ -65,12 +65,12 @@ void GLFragmentDecompilerThread::insertIntputs(std::stringstream & OS)
{
if (m_prog.front_color_diffuse_output && m_prog.back_color_diffuse_output)
{
OS << "in vec4 front_diff_color;" << std::endl;
OS << "in vec4 front_diff_color;\n";
}
if (m_prog.front_color_specular_output && m_prog.back_color_specular_output)
{
OS << "in vec4 front_spec_color;" << std::endl;
OS << "in vec4 front_spec_color;\n";
}
}
}
@ -88,7 +88,7 @@ void GLFragmentDecompilerThread::insertOutputs(std::stringstream & OS)
for (int i = 0; i < sizeof(table) / sizeof(*table); ++i)
{
if (m_parr.HasParam(PF_PARAM_NONE, "vec4", table[i].second))
OS << "out vec4 " << table[i].first << ";" << std::endl;
OS << "out vec4 " << table[i].first << ";\n";
}
}
@ -120,13 +120,13 @@ void GLFragmentDecompilerThread::insertConstants(std::stringstream & OS)
}
}
OS << "uniform " << samplerType << " " << PI.name << ";" << std::endl;
OS << "uniform " << samplerType << " " << PI.name << ";\n";
}
}
OS << std::endl;
OS << "layout(std140, binding = 2) uniform FragmentConstantsBuffer" << std::endl;
OS << "{" << std::endl;
OS << "\n";
OS << "layout(std140, binding = 2) uniform FragmentConstantsBuffer\n";
OS << "{\n";
for (const ParamType& PT : m_parr.params[PF_PARAM_UNIFORM])
{
@ -137,7 +137,7 @@ void GLFragmentDecompilerThread::insertConstants(std::stringstream & OS)
continue;
for (const ParamItem& PI : PT.items)
OS << " " << PT.type << " " << PI.name << ";" << std::endl;
OS << " " << PT.type << " " << PI.name << ";\n";
}
// Fragment state parameters
@ -146,7 +146,7 @@ void GLFragmentDecompilerThread::insertConstants(std::stringstream & OS)
OS << " uint alpha_test;\n";
OS << " float alpha_ref;\n";
OS << " vec4 texture_parameters[16];\n"; //sampling: x,y scaling and (unused) offsets data
OS << "};" << std::endl;
OS << "};\n";
}
@ -241,8 +241,8 @@ void GLFragmentDecompilerThread::insertMainStart(std::stringstream & OS)
}
}
OS << "void fs_main(" << parameters << ")" << std::endl;
OS << "{" << std::endl;
OS << "void fs_main(" << parameters << ")\n";
OS << "{\n";
for (const ParamType& PT : m_parr.params[PF_PARAM_NONE])
{
@ -255,7 +255,7 @@ void GLFragmentDecompilerThread::insertMainStart(std::stringstream & OS)
if (!PI.value.empty())
OS << " = " << PI.value;
OS << ";" << std::endl;
OS << ";\n";
}
}
@ -397,10 +397,10 @@ void GLFragmentDecompilerThread::insertMainEnd(std::stringstream & OS)
OS << make_comparison_test(m_prog.alpha_func, "alpha_test != 0 && ", first_output_name + ".a", "alpha_ref");
}
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 = "";
for (auto &reg_name : output_values)
@ -411,11 +411,11 @@ void GLFragmentDecompilerThread::insertMainEnd(std::stringstream & OS)
parameters += ", ";
parameters += reg_name;
OS << " vec4 " << reg_name << " = vec4(0.);" << std::endl;
OS << " vec4 " << reg_name << " = vec4(0.);\n";
}
}
OS << std::endl << " fs_main(" + parameters + ");" << std::endl << std::endl;
OS << "\n" << " fs_main(" + parameters + ");\n\n";
//Append the color output assignments
OS << color_output_block;
@ -428,7 +428,7 @@ void GLFragmentDecompilerThread::insertMainEnd(std::stringstream & OS)
* but it writes depth in r1.z and not h2.z.
* Maybe there's a different flag for depth ?
*/
//OS << ((m_ctrl & CELL_GCM_SHADER_CONTROL_32_BITS_EXPORTS) ? "\tgl_FragDepth = r1.z;\n" : "\tgl_FragDepth = h0.z;\n") << std::endl;
//OS << ((m_ctrl & CELL_GCM_SHADER_CONTROL_32_BITS_EXPORTS) ? "\tgl_FragDepth = r1.z;\n" : "\tgl_FragDepth = h0.z;\n") << "\n";
OS << " gl_FragDepth = r1.z;\n";
}
else
@ -438,7 +438,7 @@ void GLFragmentDecompilerThread::insertMainEnd(std::stringstream & OS)
}
}
OS << "}" << std::endl;
OS << "}\n";
}
void GLFragmentDecompilerThread::Task()

View File

@ -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";
}

View File

@ -29,8 +29,8 @@ std::string VKFragmentDecompilerThread::compareFunction(COMPARE f, const std::st
void VKFragmentDecompilerThread::insertHeader(std::stringstream & OS)
{
OS << "#version 420" << std::endl;
OS << "#extension GL_ARB_separate_shader_objects: enable" << std::endl << std::endl;
OS << "#version 420\n";
OS << "#extension GL_ARB_separate_shader_objects: enable\n\n";
}
void VKFragmentDecompilerThread::insertIntputs(std::stringstream & OS)
@ -60,7 +60,7 @@ void VKFragmentDecompilerThread::insertIntputs(std::stringstream & OS)
if (var_name == "fogc")
var_name = "fog_c";
OS << "layout(location=" << reg.reg_location << ") in " << PT.type << " " << var_name << ";" << std::endl;
OS << "layout(location=" << reg.reg_location << ") in " << PT.type << " " << var_name << ";\n";
}
}
@ -70,13 +70,13 @@ void VKFragmentDecompilerThread::insertIntputs(std::stringstream & OS)
if (m_prog.front_color_diffuse_output && m_prog.back_color_diffuse_output)
{
const vk::varying_register_t &reg = vk::get_varying_register("front_diff_color");
OS << "layout(location=" << reg.reg_location << ") in vec4 front_diff_color;" << std::endl;
OS << "layout(location=" << reg.reg_location << ") in vec4 front_diff_color;\n";
}
if (m_prog.front_color_specular_output && m_prog.back_color_specular_output)
{
const vk::varying_register_t &reg = vk::get_varying_register("front_spec_color");
OS << "layout(location=" << reg.reg_location << ") in vec4 front_spec_color;" << std::endl;
OS << "layout(location=" << reg.reg_location << ") in vec4 front_spec_color;\n";
}
}
}
@ -96,7 +96,7 @@ void VKFragmentDecompilerThread::insertOutputs(std::stringstream & OS)
for (int i = 0; i < sizeof(table) / sizeof(*table); ++i)
{
if (m_parr.HasParam(PF_PARAM_NONE, "vec4", table[i].second))
OS << "layout(location=" << std::to_string(output_index++) << ") " << "out vec4 " << table[i].first << ";" << std::endl;
OS << "layout(location=" << std::to_string(output_index++) << ") " << "out vec4 " << table[i].first << ";\n";
}
}
@ -142,12 +142,12 @@ void VKFragmentDecompilerThread::insertConstants(std::stringstream & OS)
inputs.push_back(in);
OS << "layout(set=0, binding=" << 19 + location++ << ") uniform " << samplerType << " " << PI.name << ";" << std::endl;
OS << "layout(set=0, binding=" << 19 + location++ << ") uniform " << samplerType << " " << PI.name << ";\n";
}
}
OS << "layout(std140, set = 0, binding = 2) uniform FragmentConstantsBuffer" << std::endl;
OS << "{" << std::endl;
OS << "layout(std140, set = 0, binding = 2) uniform FragmentConstantsBuffer\n";
OS << "{\n";
for (const ParamType& PT : m_parr.params[PF_PARAM_UNIFORM])
{
@ -158,15 +158,15 @@ void VKFragmentDecompilerThread::insertConstants(std::stringstream & OS)
continue;
for (const ParamItem& PI : PT.items)
OS << " " << PT.type << " " << PI.name << ";" << std::endl;
OS << " " << PT.type << " " << PI.name << ";\n";
}
OS << " float fog_param0;" << std::endl;
OS << " float fog_param1;" << std::endl;
OS << " uint alpha_test;" << std::endl;
OS << " float alpha_ref;" << std::endl;
OS << " vec4 texture_parameters[16];" << std::endl;
OS << "};" << std::endl;
OS << " float fog_param0;\n";
OS << " float fog_param1;\n";
OS << " uint alpha_test;\n";
OS << " float alpha_ref;\n";
OS << " vec4 texture_parameters[16];\n";
OS << "};\n";
vk::glsl::program_input in;
in.location = 1;
@ -250,8 +250,8 @@ void VKFragmentDecompilerThread::insertMainStart(std::stringstream & OS)
}
}
OS << "void fs_main(" << parameters << ")" << std::endl;
OS << "{" << std::endl;
OS << "void fs_main(" << parameters << ")\n";
OS << "{\n";
for (const ParamType& PT : m_parr.params[PF_PARAM_NONE])
{
@ -264,7 +264,7 @@ void VKFragmentDecompilerThread::insertMainStart(std::stringstream & OS)
if (!PI.value.empty())
OS << " = " << PI.value;
OS << ";" << std::endl;
OS << ";\n";
}
}
@ -395,10 +395,10 @@ void VKFragmentDecompilerThread::insertMainEnd(std::stringstream & OS)
OS << make_comparison_test(m_prog.alpha_func, "bool(alpha_test) && ", first_output_name + ".a", "alpha_ref");
}
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 = "";
for (auto &reg_name : output_values)
@ -409,11 +409,11 @@ void VKFragmentDecompilerThread::insertMainEnd(std::stringstream & OS)
parameters += ", ";
parameters += reg_name;
OS << " vec4 " << reg_name << " = vec4(0.);" << std::endl;
OS << " vec4 " << reg_name << " = vec4(0.);\n";
}
}
OS << std::endl << " fs_main(" + parameters + ");" << std::endl << std::endl;
OS << "\n" << " fs_main(" + parameters + ");\n\n";
//Append the color output assignments
OS << color_output_block;
@ -426,7 +426,7 @@ void VKFragmentDecompilerThread::insertMainEnd(std::stringstream & OS)
* but it writes depth in r1.z and not h2.z.
* Maybe there's a different flag for depth ?
*/
//OS << ((m_ctrl & CELL_GCM_SHADER_CONTROL_32_BITS_EXPORTS) ? "\tgl_FragDepth = r1.z;\n" : "\tgl_FragDepth = h0.z;\n") << std::endl;
//OS << ((m_ctrl & CELL_GCM_SHADER_CONTROL_32_BITS_EXPORTS) ? "\tgl_FragDepth = r1.z;\n" : "\tgl_FragDepth = h0.z;\n") << "\n";
OS << " gl_FragDepth = r1.z;\n";
}
else
@ -436,7 +436,7 @@ void VKFragmentDecompilerThread::insertMainEnd(std::stringstream & OS)
}
}
OS << "}" << std::endl;
OS << "}\n";
}
void VKFragmentDecompilerThread::Task()

View File

@ -28,14 +28,14 @@ std::string VKVertexDecompilerThread::compareFunction(COMPARE f, const std::stri
void VKVertexDecompilerThread::insertHeader(std::stringstream &OS)
{
OS << "#version 450" << std::endl << std::endl;
OS << "#extension GL_ARB_separate_shader_objects : enable" << std::endl;
OS << "layout(std140, set = 0, 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 450\n\n";
OS << "#extension GL_ARB_separate_shader_objects : enable\n";
OS << "layout(std140, set = 0, binding = 0) uniform ScaleOffsetBuffer\n";
OS << "{\n";
OS << " mat4 scaleOffsetMat;\n";
OS << " ivec4 userClipEnabled[2];\n";
OS << " vec4 userClipFactor[2];\n";
OS << "};\n";
vk::glsl::program_input in;
in.location = 0;
@ -92,7 +92,7 @@ void VKVertexDecompilerThread::insertInputs(std::stringstream & OS, const std::v
}
std::string samplerType = is_int ? "isamplerBuffer" : "samplerBuffer";
OS << "layout(set = 0, binding=" << 3 + location++ << ")" << " uniform " << samplerType << " " << PI.name << "_buffer;" << std::endl;
OS << "layout(set = 0, binding=" << 3 + location++ << ")" << " uniform " << samplerType << " " << PI.name << "_buffer;\n";
}
}
}
@ -101,11 +101,11 @@ void VKVertexDecompilerThread::insertInputs(std::stringstream & OS, const std::v
void VKVertexDecompilerThread::insertConstants(std::stringstream & OS, const std::vector<ParamType> & constants)
{
OS << "layout(std140, set=0, 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, set=0, binding = 1) uniform VertexConstantsBuffer\n";
OS << "{\n";
OS << " vec4 vc[468];\n";
OS << " uint transform_branch_bits;\n";
OS << "};\n\n";
vk::glsl::program_input in;
in.location = 1;
@ -137,7 +137,7 @@ void VKVertexDecompilerThread::insertConstants(std::stringstream & OS, const std
inputs.push_back(in);
OS << "layout(set = 0, binding=" << 19 + location++ << ") uniform " << PT.type << " " << PI.name << ";" << std::endl;
OS << "layout(set = 0, binding=" << 19 + location++ << ") uniform " << PT.type << " " << PI.name << ";\n";
}
}
}
@ -193,15 +193,15 @@ void VKVertexDecompilerThread::insertOutputs(std::stringstream & OS, const std::
insert_front_specular = false;
const vk::varying_register_t &reg = vk::get_varying_register(i.name);
OS << "layout(location=" << reg.reg_location << ") out vec4 " << i.name << ";" << std::endl;
OS << "layout(location=" << reg.reg_location << ") out vec4 " << i.name << ";\n";
}
}
if (insert_back_diffuse && insert_front_diffuse)
OS << "layout(location=" << vk::get_varying_register("front_diff_color").reg_location << ") out vec4 front_diff_color;" << std::endl;
OS << "layout(location=" << vk::get_varying_register("front_diff_color").reg_location << ") out vec4 front_diff_color;\n";
if (insert_back_specular && insert_front_specular)
OS << "layout(location=" << vk::get_varying_register("front_spec_color").reg_location << ") out vec4 front_spec_color;" << std::endl;
OS << "layout(location=" << vk::get_varying_register("front_spec_color").reg_location << ") out vec4 front_spec_color;\n";
}
namespace vk
@ -215,7 +215,7 @@ namespace vk
if (!real_input.is_array)
{
OS << " vec4 " << PI.name << " = vec4(texelFetch(" << PI.name << "_buffer, 0));" << std::endl;
OS << " vec4 " << PI.name << " = vec4(texelFetch(" << PI.name << "_buffer, 0));\n";
return;
}
@ -223,19 +223,19 @@ namespace vk
{
if (real_input.is_modulo)
{
OS << " vec4 " << PI.name << "= vec4(texelFetch(" << PI.name << "_buffer, gl_VertexIndex %" << real_input.frequency << "));" << std::endl;
OS << " vec4 " << PI.name << "= vec4(texelFetch(" << PI.name << "_buffer, gl_VertexIndex %" << real_input.frequency << "));\n";
return;
}
OS << " vec4 " << PI.name << "= vec4(texelFetch(" << PI.name << "_buffer, gl_VertexIndex /" << real_input.frequency << "));" << std::endl;
OS << " vec4 " << PI.name << "= vec4(texelFetch(" << PI.name << "_buffer, gl_VertexIndex /" << real_input.frequency << "));\n";
return;
}
OS << " vec4 " << PI.name << "= vec4(texelFetch(" << PI.name << "_buffer, gl_VertexIndex).rgba);" << std::endl;
OS << " vec4 " << PI.name << "= vec4(texelFetch(" << PI.name << "_buffer, gl_VertexIndex).rgba);\n";
return;
}
OS << " vec4 " << PI.name << "= vec4(texelFetch(" << PI.name << "_buffer, gl_VertexIndex).rgba);" << std::endl;
OS << " vec4 " << PI.name << "= vec4(texelFetch(" << PI.name << "_buffer, gl_VertexIndex).rgba);\n";
}
}
@ -256,8 +256,8 @@ void VKVertexDecompilerThread::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])
@ -271,7 +271,7 @@ void VKVertexDecompilerThread::insertMainStart(std::stringstream & OS)
if (!PI.value.empty())
OS << " = " << PI.value;
OS << ";" << std::endl;
OS << ";\n";
}
}
@ -284,10 +284,10 @@ void VKVertexDecompilerThread::insertMainStart(std::stringstream & OS)
void VKVertexDecompilerThread::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 = "";
@ -309,13 +309,13 @@ void VKVertexDecompilerThread::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;
@ -341,19 +341,19 @@ void VKVertexDecompilerThread::insertMainEnd(std::stringstream & OS)
if (condition.empty() || i.default_val.empty())
{
if (!condition.empty()) condition = "if " + condition;
OS << " " << condition << i.name << " = " << i.src_reg << i.src_reg_mask << ";" << std::endl;
OS << " " << condition << i.name << " = " << i.src_reg << i.src_reg_mask << ";\n";
}
else
{
//Insert if-else condition
OS << " " << i.name << " = " << condition << "? " << i.src_reg << i.src_reg_mask << ": " << i.default_val << ";" << std::endl;
OS << " " << i.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";
}
}
@ -365,8 +365,8 @@ void VKVertexDecompilerThread::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 << "}" << std::endl;
OS << " gl_Position = gl_Position * scaleOffsetMat;\n";
OS << "}\n";
}