rsx/vk: Implement hardware instancing (#16466)

* rsx: Add code to detect instanced draw commands

* rsx: Add GLSL support for instanced rendering

* rsx: Move draw call related functions to their own class

* rsx: Move more functions from rsx thread to the draw command processor

* rsx: Fix vertex program compiler crash

* vk: Add support for hardware instanced draws

* rsx: Fix instancing bug when indexed addressing is used to read constants

* rsx: Fix rare crash in vertex program decompiler

- This whole decompiler mess needs a rewrite

* rsx: Handle dangling execution barriers

* rsx: Do not use global registers object in logical "firmware" units

* Cosmetic improvements

* rsx: Test vertex program flags on each draw

* rsx: Properly track changes in instancing state
This commit is contained in:
kd-11 2024-12-29 18:39:47 +03:00 committed by GitHub
parent 15f29eedee
commit 62701154f1
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
32 changed files with 1411 additions and 906 deletions

View file

@ -131,7 +131,7 @@ std::string VertexProgramDecompiler::GetSRC(const u32 n)
m_parr.AddParam(PF_PARAM_UNIFORM, float4, std::string("vc[468]"));
properties.has_indexed_constants |= !!d3.index_const;
m_constant_ids.insert(static_cast<u16>(d1.const_src));
ret += std::string("vc[") + std::to_string(d1.const_src) + (d3.index_const ? " + " + AddAddrReg() : "") + "]";
fmt::append(ret, "_fetch_constant(%u%s)", d1.const_src, (d3.index_const ? " + " + AddAddrReg() : ""));
break;
default:
@ -362,14 +362,13 @@ std::string VertexProgramDecompiler::NotZeroPositive(const std::string& code)
std::string VertexProgramDecompiler::BuildCode()
{
std::string main_body;
for (uint i = 0, lvl = 1; i < m_instr_count; i++)
for (int i = 0, lvl = 1; i < static_cast<int>(m_instr_count); i++)
{
lvl -= m_instructions[i].close_scopes;
if (lvl < 1) lvl = 1;
lvl = std::max<int>(lvl - m_instructions[i].close_scopes, 0);
for (int j = 0; j < m_instructions[i].put_close_scopes; ++j)
{
--lvl;
if (lvl < 1) lvl = 1;
if (lvl > 1) --lvl;
main_body.append(lvl, '\t') += "}\n";
}
@ -380,6 +379,8 @@ std::string VertexProgramDecompiler::BuildCode()
lvl++;
}
ensure(lvl >= 0); // Underflow of indent level will cause crashes!!
for (const auto& instruction_body : m_instructions[i].body)
{
main_body.append(lvl, '\t') += instruction_body + "\n";
@ -409,7 +410,7 @@ std::string VertexProgramDecompiler::BuildCode()
{
const auto i = offset++;
if (i == index) continue; // Replace with self
reloc_table.emplace_back(fmt::format("vc[%d]", index), fmt::format("vc[%d]", i));
reloc_table.emplace_back(fmt::format("_fetch_constant(%d)", index), fmt::format("_fetch_constant(%d)", i));
}
// One-time patch