Fixed Sacred 2 Remaster - added indexed texture handles support

This commit is contained in:
PavelBARABANOV 2026-10-22 00:03:30 +03:00 • committed by crueter
parent 05b4d7f4cc
commit a72d30642f
19 changed files with 527 additions and 52 deletions

View file

@ -40,9 +40,10 @@ struct HandleKey {
u32 sec_index, sec_offset, sec_shift_left;
u32 count;
bool has_secondary;
u32 mask, sec_mask;
constexpr bool operator==(const HandleKey& o) const noexcept {
return std::tie(index, offset, shift_left, sec_index, sec_offset, sec_shift_left, count, has_secondary)
== std::tie(o.index, o.offset, o.shift_left, o.sec_index, o.sec_offset, o.sec_shift_left, o.count, o.has_secondary);
return std::tie(index, offset, shift_left, sec_index, sec_offset, sec_shift_left, count, has_secondary, mask, sec_mask)
== std::tie(o.index, o.offset, o.shift_left, o.sec_index, o.sec_offset, o.sec_shift_left, o.count, o.has_secondary, o.mask, o.sec_mask);
}
};
struct HandleKeyHash {
@ -52,6 +53,7 @@ struct HandleKeyHash {
h ^= (size_t(k.sec_index) << 33) ^ (size_t(k.sec_offset) << 2);
h ^= (size_t(k.sec_shift_left) << 3);
h ^= (size_t(k.count) << 7);
h ^= (size_t(k.mask) << 11) ^ (size_t(k.sec_mask) << 13);
return h ^ (k.has_secondary ? 0x9e3779b97f4a7c15ULL : 0ULL);
}
};
@ -66,6 +68,14 @@ struct ConstBufferAddr {
IR::U32 dynamic_offset;
u32 count;
bool has_secondary;
/// The dynamic offset is a constant buffer value shifted left, the same for the whole draw
bool has_index_cbuf;
u32 index_cbuf_index;
u32 index_cbuf_offset;
u32 index_shift;
/// Applied after the shifts
u32 mask = 0xffffffff;
u32 secondary_mask = 0xffffffff;
};
class Environment {