vk: Fix fragment constants indexing

This commit is contained in:
kd-11 2025-07-27 19:13:47 +03:00 committed by kd-11
parent 33e4b11509
commit aa119e1413
2 changed files with 21 additions and 2 deletions

View file

@ -232,12 +232,29 @@ std::string FragmentProgramDecompiler::AddCond()
std::string FragmentProgramDecompiler::AddConst()
{
const u32 constant_id = m_size + (4 * sizeof(u32));
int index = -1, ctr = 0;
// Have we seen this constant before?
for (auto it = properties.constant_offsets.rbegin(); it != properties.constant_offsets.rend(); ++it, ++ctr)
{
if (*it == constant_id)
{
index = ctr;
break;
}
}
if (index == -1)
{
index = static_cast<int>(properties.constant_offsets.size());
properties.constant_offsets.push_back(constant_id);
}
// Skip next instruction, its just a literal
m_offset = 2 * 4 * sizeof(u32);
// Return the next offset index
const u32 index = ::size32(properties.constant_offsets);
properties.constant_offsets.push_back(m_size + 4 * 4);
return "_fetch_constant(" + std::to_string(index) + ")";
}

View file

@ -2185,6 +2185,7 @@ void VKGSRender::upload_transform_constants(const rsx::io_buffer& buffer)
void VKGSRender::update_vertex_env(u32 id, const vk::vertex_upload_info& vertex_info)
{
#pragma pack(push, 1)
struct rsx_vs_prog_push_constants_block_t
{
u32 xform_constants_offset;
@ -2205,6 +2206,7 @@ void VKGSRender::update_vertex_env(u32 id, const vk::vertex_upload_info& vertex_
u32 reserved;
s32 attrib_data[1];
};
#pragma pack(pop)
// Actual allocation must have been done previously
const u32 vs_constant_id_offset = static_cast<u32>(m_xform_constants_dynamic_offset) / 16u;