public CounterQueueEvent QueueReport(EventHandler <ulong> resultHandler, ulong lastDrawIndex) { CounterQueueEvent result; ulong draws = lastDrawIndex - _current.DrawIndex; lock (_lock) { // A query's result only matters if more than one draw was performed during it. // Otherwise, dummy it out and return 0 immediately. if (draws > 0) { _current.Complete(true); _events.Enqueue(_current); _current.OnResult += resultHandler; } else { _current.Complete(false); _current.Dispose(); resultHandler(_current, 0); } result = _current; _current = new CounterQueueEvent(this, GetTarget(Type), lastDrawIndex); } _queuedEvent.Set(); return(result); }
public CounterQueueEvent QueueReport(EventHandler <ulong> resultHandler, ulong lastDrawIndex, bool hostReserved) { CounterQueueEvent result; ulong draws = lastDrawIndex - _current.DrawIndex; lock (_lock) { // A query's result only matters if more than one draw was performed during it. // Otherwise, dummy it out and return 0 immediately. if (hostReserved) { // This counter event is guaranteed to be available for host conditional rendering. _current.ReserveForHostAccess(); } _current.Complete(draws > 0); _events.Enqueue(_current); _current.OnResult += resultHandler; result = _current; _current = new CounterQueueEvent(this, GetTarget(Type), lastDrawIndex); } _queuedEvent.Set(); return(result); }
public CounterQueueEvent QueueReport(EventHandler <ulong> resultHandler) { CounterQueueEvent result; lock (_lock) { _current.Complete(); _events.Enqueue(_current); result = _current; result.OnResult += resultHandler; _current = new CounterQueueEvent(this, GetTarget(Type)); } _queuedEvent.Set(); return(result); }