/// <summary> /// Internal method for calculating the average time between recently fired events. /// </summary> /// <param name="time">The current time in milliseconds.</param> /// <param name="type">The type event to calculate.</param> /// <returns>Average time since last event of the same type.</returns> private float CalculateEventTime( long time, FrameEventType type ) { //calculate the average time passed between events of the given type //during the last frameSmoothingTime seconds float result = 0; float discardThreshold = this.frameSmoothingTime*1000.0f; if ( time > discardThreshold ) { time -= (long)( this.frameSmoothingTime*discardThreshold ); } if ( type == FrameEventType.Start ) { result = (float)( time - this.lastStartTime )/1000; // update the last start time before the render targets are rendered this.lastStartTime = time; } else if ( type == FrameEventType.Queued ) { result = (float)( time - this.lastQueuedTime )/1000; // update the last queued time before the render targets are rendered this.lastQueuedTime = time; } else if ( type == FrameEventType.End ) { // increment frameCount this.frameCount++; // collect performance stats if ( ( time - this.lastCalculationTime ) > this.secondsBetweenFPSAverages*1000f ) { // Is It Time To Update Our Calculations? // Calculate New Framerate this.currentFPS = (float)this.frameCount/(float)( time - this.lastCalculationTime )*1000f; // calculate the average framerate if ( this.averageFPS == 0 ) { this.averageFPS = this.currentFPS; } else { this.averageFPS = ( this.averageFPS + this.currentFPS )/2.0f; } // Is The New Framerate A New Low? if ( this.currentFPS < this.lowestFPS || (int)this.lowestFPS == 0 ) { // Set It To The New Low this.lowestFPS = this.currentFPS; } // Is The New Framerate A New High? if ( this.currentFPS > this.highestFPS ) { // Set It To The New High this.highestFPS = this.currentFPS; } // Update Our Last Frame Time To Now this.lastCalculationTime = time; // Reset Our Frame Count this.frameCount = 0; } result = (float)( time - this.lastEndTime )/1000; this.lastEndTime = time; } return result; }
static bool IsHiddenEventType(FrameEventType et) { return(et == FrameEventType.BeginSubpass); }
public static FrameEventType ConvertFrameEventType(int i) { return(FrameEventType.GetFrameEventType(i)); }
/// <summary> /// Internal method for calculating the average time between recently fired events. /// </summary> /// <param name="time">The current time in milliseconds.</param> /// <param name="type">The type event to calculate.</param> /// <returns>Average time since last event of the same type in seconds.</returns> private float CalculateEventTime(long time, FrameEventType type) { float result = 0; if(type == FrameEventType.Start) { result = (float)(time - lastStartTime) / 1000; // update the last start time before the render targets are rendered lastStartTime = time; } else { // increment frameCount frameCount++; // collect performance stats if((time - lastCalculationTime) > secondsBetweenFPSAverages * 1000f) { // Is It Time To Update Our Calculations? // Calculate New Framerate currentFPS = (float)frameCount / (float)(time - lastCalculationTime) * 1000f; // calculate the averge framerate if(averageFPS == 0) averageFPS = currentFPS; else averageFPS = (averageFPS + currentFPS) / 2.0f; // Is The New Framerate A New Low? if(currentFPS < lowestFPS || (int) lowestFPS == 0) { // Set It To The New Low lowestFPS = currentFPS; } // Is The New Framerate A New High? if(currentFPS > highestFPS) { // Set It To The New High highestFPS = currentFPS; } // Update Our Last Frame Time To Now lastCalculationTime = time; // Reset Our Frame Count frameCount = 0; } result = (float)(time - lastEndTime) / 1000; lastEndTime = time; } return result; }
internal static bool IsAHiddenEvent(FrameEventType eventType) => eventType == FrameEventType.BeginSubpass;
internal static bool IsAHierarchyLevelBreakEvent(FrameEventType eventType) => eventType == FrameEventType.HierarchyLevelBreak;
internal static bool IsARayTracingEvent(FrameEventType eventType) => eventType == FrameEventType.RayTracingDispatch;
internal static bool IsAComputeEvent(FrameEventType eventType) => eventType == FrameEventType.ComputeDispatch;
internal static bool IsAResolveEvent(FrameEventType eventType) => eventType == FrameEventType.ResolveRT || eventType == FrameEventType.ResolveDepth;
internal static bool IsAClearEvent(FrameEventType eventType) => eventType >= FrameEventType.ClearNone && eventType <= FrameEventType.ClearAll;
/// <summary> /// Internal method for calculating the average time between recently fired events. /// </summary> /// <param name="time">The current time in milliseconds.</param> /// <param name="type">The type event to calculate.</param> /// <returns>Average time since last event of the same type in seconds.</returns> private float CalculateEventTime(long time, FrameEventType type) { float result = 0; if (type == FrameEventType.Start) { result = (float)(time - lastStartTime) / 1000; // update the last start time before the render targets are rendered lastStartTime = time; } else { // increment frameCount frameCount++; // collect performance stats if ((time - lastCalculationTime) > secondsBetweenFPSAverages * 1000f) { // Is It Time To Update Our Calculations? // Calculate New Framerate currentFPS = (float)frameCount / (float)(time - lastCalculationTime) * 1000f; // calculate the averge framerate if (averageFPS == 0) { averageFPS = currentFPS; } else { averageFPS = (averageFPS + currentFPS) / 2.0f; } // Is The New Framerate A New Low? if (currentFPS < lowestFPS || (int)lowestFPS == 0) { // Set It To The New Low lowestFPS = currentFPS; } // Is The New Framerate A New High? if (currentFPS > highestFPS) { // Set It To The New High highestFPS = currentFPS; } // Update Our Last Frame Time To Now lastCalculationTime = time; // Reset Our Frame Count frameCount = 0; } result = (float)(time - lastEndTime) / 1000; lastEndTime = time; } return(result); }