review comments applied

This commit is contained in:
psucien 2024-05-10 23:51:24 +02:00
parent 37014394fd
commit d804a66aa2
5 changed files with 32 additions and 24 deletions

View File

@ -1307,8 +1307,8 @@ static inline s32 PatchFlipRequest(u32* cmdbuf, u32 size, u32 vo_handle, u32 buf
auto* write_lock = reinterpret_cast<PM4CmdWriteData*>(cmdbuf);
write_lock->header = PM4Type3Header{PM4ItOpcode::WriteData, 3};
write_lock->raw = 0x500u;
*reinterpret_cast<uintptr_t*>(&write_lock->dst_addr_lo) =
(label_addr + buf_idx * sizeof(uintptr_t)) & ~0x3ull;
const auto addr = (label_addr + buf_idx * sizeof(label_addr)) & ~0x3ull;
write_lock->Address<uintptr_t>(addr);
write_lock->data[0] = 1;
auto* nop = reinterpret_cast<PM4CmdNop*>(cmdbuf + 5);

View File

@ -21,8 +21,8 @@ int EqueueInternal::addEvent(const EqueueEvent& event) {
}
int EqueueInternal::removeEvent(u64 id) {
const auto& event_q = std::find_if(m_events.cbegin(), m_events.cend(),
[id](auto& ev) { return ev.event.ident == id; });
const auto& event_q =
std::ranges::find_if(m_events, [id](auto& ev) { return ev.event.ident == id; });
ASSERT(event_q != m_events.cend());
m_events.erase(event_q);
return 0;

View File

@ -38,11 +38,10 @@ struct IrqController {
void Register(IrqHandler handler) {
ASSERT_MSG(!persistent_handler.has_value(),
"Too many persistent handlers"); // Add a slot map if so
{
std::unique_lock lock{m_lock};
persistent_handler.emplace(handler);
}
}
void Unregister() {
std::unique_lock lock{m_lock};
@ -50,10 +49,10 @@ struct IrqController {
}
void Signal(InterruptId irq) {
LOG_TRACE(Core, "IRQ signaled: {}", magic_enum::enum_name(irq));
{
std::unique_lock lock{m_lock};
LOG_TRACE(Core, "IRQ signaled: {}", magic_enum::enum_name(irq));
if (persistent_handler) {
persistent_handler.value()(irq);
}
@ -65,7 +64,6 @@ struct IrqController {
one_time_subscribers.pop();
}
}
}
private:
std::optional<IrqHandler> persistent_handler{};

View File

@ -90,8 +90,7 @@ void Liverpool::ProcessCmdList(u32* cmdbuf, u32 size_in_bytes) {
ASSERT(write_data->dst_sel.Value() == 2 || write_data->dst_sel.Value() == 5);
const u32 data_size = (header->type3.count.Value() - 2) * 4;
if (!write_data->wr_one_addr.Value()) {
std::memcpy(reinterpret_cast<void*>(write_data->Address()), write_data->data,
data_size);
std::memcpy(write_data->Address<void*>(), write_data->data, data_size);
} else {
UNREACHABLE();
}

View File

@ -428,12 +428,23 @@ struct PM4CmdWriteData {
BitField<30, 1, u32> engine_sel;
u32 raw;
};
union {
struct {
u32 dst_addr_lo;
u32 dst_addr_hi;
};
u64 addr64;
};
u32 data[0];
uintptr_t Address() const {
return (uintptr_t(dst_addr_hi) << 32) | dst_addr_lo;
template <typename T>
void Address(T addr) {
addr64 = reinterpret_cast<u64>(addr);
}
template <typename T>
T* Address() const {
return reinterpret_cast<T*>(addr64);
}
};