private NvInternalResult SyncptWait(ref SyncptWaitArguments arguments, out int value)
        {
            if (arguments.Id >= NvHostSyncpt.SyncptsCount)
            {
                value = 0;

                return(NvInternalResult.InvalidInput);
            }

            NvInternalResult result;

            if (_syncpt.MinCompare((int)arguments.Id, arguments.Thresh))
            {
                result = NvInternalResult.Success;
            }
            else if (arguments.Timeout == 0)
            {
                result = NvInternalResult.TryAgain;
            }
            else
            {
                Logger.PrintDebug(LogClass.ServiceNv, $"Waiting syncpt with timeout of {arguments.Timeout}ms...");

                using (ManualResetEvent waitEvent = new ManualResetEvent(false))
                {
                    _syncpt.AddWaiter(arguments.Thresh, waitEvent);

                    // Note: Negative (> INT_MAX) timeouts aren't valid on .NET,
                    // in this case we just use the maximum timeout possible.
                    int timeout = arguments.Timeout;

                    if (timeout < -1)
                    {
                        timeout = int.MaxValue;
                    }

                    if (timeout == -1)
                    {
                        waitEvent.WaitOne();

                        result = NvInternalResult.Success;
                    }
                    else if (waitEvent.WaitOne(timeout))
                    {
                        result = NvInternalResult.Success;
                    }
                    else
                    {
                        result = NvInternalResult.TimedOut;
                    }
                }

                Logger.PrintDebug(LogClass.ServiceNv, "Resuming...");
            }

            value = _syncpt.GetMin((int)arguments.Id);

            return(result);
        }
Exemple #2
0
        private NvInternalResult SyncptWait(ref SyncptWaitArguments arguments)
        {
            uint dummyValue = 0;

            return(EventWait(ref arguments.Fence, ref dummyValue, arguments.Timeout, isWaitEventAsyncCmd: false, isWaitEventCmd: false));
        }
 private NvInternalResult SyncptWait(ref SyncptWaitArguments arguments)
 {
     return(SyncptWait(ref arguments, out _));
 }