public NvInternalResult SignalEvent(uint eventId) { if (eventId >= EventsCount) { return(NvInternalResult.InvalidInput); } NvHostEvent hostEvent = Events[eventId]; if (hostEvent == null) { return(NvInternalResult.InvalidInput); } NvHostEventState oldState = hostEvent.State; if (oldState == NvHostEventState.Waiting) { hostEvent.State = NvHostEventState.Cancelling; hostEvent.Cancel(_device.Gpu); } hostEvent.State = NvHostEventState.Cancelled; return(NvInternalResult.Success); }
private NvInternalResult EventSignal(ref uint userEventId) { uint eventId = userEventId & ushort.MaxValue; if (eventId >= EventsCount) { return(NvInternalResult.InvalidInput); } lock (_events) { NvHostEvent hostEvent = _events[eventId]; if (hostEvent == null) { return(NvInternalResult.InvalidInput); } hostEvent.Cancel(_device.Gpu); _device.System.HostSyncpoint.UpdateMin(hostEvent.Fence.Id); return(NvInternalResult.Success); } }
private NvInternalResult EventSignal(ref uint userEventId) { uint eventId = userEventId & ushort.MaxValue; if (eventId >= EventsCount) { return(NvInternalResult.InvalidInput); } NvHostEvent hostEvent = _events[eventId]; if (hostEvent == null) { return(NvInternalResult.InvalidInput); } NvHostEventState oldState = hostEvent.State; if (oldState == NvHostEventState.Waiting) { hostEvent.State = NvHostEventState.Cancelling; hostEvent.Cancel(_device.Gpu); } hostEvent.State = NvHostEventState.Cancelled; return(NvInternalResult.Success); }
public override void Close() { Logger.Warning?.Print(LogClass.ServiceNv, "Closing channel"); lock (_events) { // If the device file need to be closed, cancel all user events and dispose events. for (int i = 0; i < _events.Length; i++) { NvHostEvent evnt = _events[i]; if (evnt != null) { lock (evnt.Lock) { if (evnt.State == NvHostEventState.Waiting) { evnt.State = NvHostEventState.Cancelling; evnt.Cancel(_device.Gpu); } else if (evnt.State == NvHostEventState.Signaling) { // Wait at max 9ms if the guest app is trying to signal the event while closing it.. int retryCount = 0; do { if (retryCount++ > 9) { break; } // TODO: This should be handled by the kernel (reschedule the current thread ect), waiting for Kernel decoupling work. Thread.Sleep(1); } while (evnt.State != NvHostEventState.Signaled); } evnt.CloseEvent(Context); _events[i] = null; } } } } }