GraphicsTimingFrame

Package: Libraries.Game.Graphics.Timing · Inherits from: Libraries.Language.Object

A GraphicsTimingFrame is the GPU time one frame took, measured by a GraphicsTimer: the whole frame, and each phase, such as "Shadows" or "G-buffer", in milliseconds. A phase timed more than once in a frame, such as one shadow pass per light, is added up, and its call count says how many times.

Example Code

use Libraries.Game.Graphics.Timing.GraphicsTimingFrame
use Libraries.Game.Game

class Main is Game
action Update(number seconds)
    GraphicsTimingFrame frame = GetGraphicsTimer():GetLatestFrame()
    if frame not= undefined
        output "GPU frame " + frame:GetFrameNumber() + ": " + frame:GetTotal() + " ms"
    end
end
end

Actions

AddPhaseTime(text name, number milliseconds, number start)

This action adds time to a phase, making it if it's new. The timer calls it for each start and end it finds.

Parameters

  • name text: The phase's name
  • milliseconds number: The time to add
  • start number: When this part of it started, in milliseconds after the frame started

GetFrameNumber()

This action returns the frame's number, counted from the game's start.

Returns

integer: The number

GetPhaseCalls(integer index)

This action returns how many times a phase was timed in the frame.

Parameters

  • index integer: The phase, from 0

Returns

integer: The count

GetPhaseCount()

This action returns how many phases the frame has.

Returns

integer: The count

GetPhaseIndex(text name)

This action returns a phase's place, or -1 if the frame doesn't have it.

Parameters

  • name text: The phase's name

Returns

integer: The place, from 0, or -1

GetPhaseName(integer index)

This action returns a phase's name, in the order they were first timed.

Parameters

  • index integer: The phase, from 0

Returns

text: The name

GetPhaseStart(integer index)

This action returns when a phase first started, after the frame started.

Parameters

  • index integer: The phase, from 0

Returns

number: Milliseconds

GetPhaseTime(integer index)

This action returns a phase's GPU time, all its parts added together.

Parameters

  • index integer: The phase, from 0

Returns

number: Milliseconds

GetTime(text name)

This action returns a phase's GPU time by name, or 0 if the frame doesn't have it.

Parameters

  • name text: The phase's name

Returns

number: Milliseconds

GetTotal()

This action returns the frame's whole GPU time, from its first stamp to its last.

Returns

number: Milliseconds

SetFrame(integer frame, number milliseconds)

This action sets which frame this is and its whole GPU time. The timer calls it.

Parameters

  • frame integer: The frame's number
  • milliseconds number: The frame's GPU time

Inherited Actions

3 actions from Libraries.Language.Object