From efdeab3a1d5735a8b000241f09ba57e9b981204b Mon Sep 17 00:00:00 2001 From: Fernando Sahmkow Date: Tue, 11 Jun 2019 17:04:24 -0400 Subject: nv_services: Fixes to event liberation. --- src/core/hle/service/nvdrv/nvdrv.h | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) (limited to 'src/core/hle') diff --git a/src/core/hle/service/nvdrv/nvdrv.h b/src/core/hle/service/nvdrv/nvdrv.h index 0e8eed113..597acc9c6 100644 --- a/src/core/hle/service/nvdrv/nvdrv.h +++ b/src/core/hle/service/nvdrv/nvdrv.h @@ -27,16 +27,17 @@ class nvdevice; } struct EventsInterface { - u64 events_mask; + u64 events_mask{}; std::array events; - std::array status; - std::array registered; - std::array assigned_syncpt; - std::array assigned_value; + std::array status{}; + std::array registered{}; + std::array assigned_syncpt{}; + std::array assigned_value{}; u32 GetFreeEvent() { u64 mask = events_mask; for (u32 i = 0; i < MaxNvEvents; i++) { - if (mask & 0x1) { + const bool is_free = (mask & 0x1) == 0; + if (is_free) { if (status[i] == EventState::Registered || status[i] == EventState::Free) { return i; } @@ -46,10 +47,16 @@ struct EventsInterface { return 0xFFFFFFFF; } void SetEventStatus(const u32 event_id, EventState new_status) { + EventState old_status = status[event_id]; + if (old_status == new_status) + return; status[event_id] = new_status; if (new_status == EventState::Registered) { registered[event_id] = true; } + if (new_status == EventState::Waiting || new_status == EventState::Busy) { + events_mask |= (1 << event_id); + } } void RegisterEvent(const u32 event_id) { registered[event_id] = true; @@ -65,6 +72,7 @@ struct EventsInterface { } void LiberateEvent(const u32 event_id) { status[event_id] = registered[event_id] ? EventState::Registered : EventState::Free; + events_mask &= ~(1 << event_id); } }; -- cgit v1.2.3