From 8c91d5c16614ac42efee7c1858cb338d65861154 Mon Sep 17 00:00:00 2001 From: Fernando Sahmkow Date: Thu, 4 Jul 2019 09:55:50 -0400 Subject: Nv_Host_Ctrl: Correct difference calculation --- src/core/hle/service/nvdrv/devices/nvhost_ctrl.cpp | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/core/hle/service/nvdrv/devices/nvhost_ctrl.cpp b/src/core/hle/service/nvdrv/devices/nvhost_ctrl.cpp index 1f178d17d..9a66a5f88 100644 --- a/src/core/hle/service/nvdrv/devices/nvhost_ctrl.cpp +++ b/src/core/hle/service/nvdrv/devices/nvhost_ctrl.cpp @@ -68,12 +68,14 @@ u32 nvhost_ctrl::IocCtrlEventWait(const std::vector& input, std::vector& return NvResult::Success; } auto lock = gpu.LockSync(); - u32 current_syncpoint_value = gpu.GetSyncpointValue(params.syncpt_id); - if (current_syncpoint_value >= params.threshold) { + const u32 current_syncpoint_value = gpu.GetSyncpointValue(params.syncpt_id); + const s32 diff = current_syncpoint_value - params.threshold; + if (diff >= 0) { params.value = current_syncpoint_value; std::memcpy(output.data(), ¶ms, sizeof(params)); return NvResult::Success; } + const u32 target_value = current_syncpoint_value - diff; if (!is_async) { params.value = 0; @@ -109,7 +111,7 @@ u32 nvhost_ctrl::IocCtrlEventWait(const std::vector& input, std::vector& if (event_id < MaxNvEvents || status == EventState::Free || status == EventState::Registered) { events_interface.SetEventStatus(event_id, EventState::Waiting); events_interface.assigned_syncpt[event_id] = params.syncpt_id; - events_interface.assigned_value[event_id] = params.threshold; + events_interface.assigned_value[event_id] = target_value; if (is_async) { params.value = params.syncpt_id << 4; } else { @@ -117,7 +119,7 @@ u32 nvhost_ctrl::IocCtrlEventWait(const std::vector& input, std::vector& } params.value |= event_id; events_interface.events[event_id].writable->Clear(); - gpu.RegisterSyncptInterrupt(params.syncpt_id, params.threshold); + gpu.RegisterSyncptInterrupt(params.syncpt_id, target_value); if (!is_async && ctrl.fresh_call) { ctrl.must_delay = true; ctrl.timeout = params.timeout; @@ -167,7 +169,7 @@ u32 nvhost_ctrl::IocCtrlEventSignal(const std::vector& input, std::vector= MaxNvEvents) { return NvResult::BadParameter; } -- cgit v1.2.3