rsx: Fix program generation and compact referenced data blocks

This commit is contained in:
kd-11 2022-03-23 23:59:42 +03:00 committed by kd-11
parent 9a2d4fe46b
commit d057ffe80f
8 changed files with 61 additions and 41 deletions

View file

@ -58,17 +58,21 @@ void GLVertexDecompilerThread::insertInputs(std::stringstream& OS, const std::ve
void GLVertexDecompilerThread::insertConstants(std::stringstream& OS, const std::vector<ParamType>& constants)
{
OS << "layout(std140, binding = 2) uniform VertexConstantsBuffer\n";
OS << "{\n";
OS << " vec4 vc[468];\n";
OS << "};\n\n";
for (const ParamType &PT: constants)
{
for (const ParamItem &PI : PT.items)
{
if (PI.name == "vc[468]")
if (PI.name.starts_with("vc["))
{
OS << "layout(std140, binding = 2) uniform VertexConstantsBuffer\n";
OS << "{\n";
OS << " vec4 " << PI.name << ";\n";
OS << "};\n\n";
continue;
}
OS << "uniform " << PT.type << " " << PI.name << ";\n";
}
@ -272,10 +276,14 @@ void GLVertexProgram::Decompile(const RSXVertexProgram& prog)
GLVertexDecompilerThread decompiler(prog, source, parr);
decompiler.Task();
if (has_indexed_constants = decompiler.properties.has_indexed_constants;
!has_indexed_constants)
{
constant_ids = std::vector<u16>(decompiler.m_constant_ids.begin(), decompiler.m_constant_ids.end());
}
shader.create(::glsl::program_domain::glsl_vertex_program, source);
id = shader.id();
has_indexed_constants = decompiler.properties.has_indexed_constants;
constant_ids = std::move(decompiler.m_constant_ids);
}
void GLVertexProgram::Delete()