Class TracyClient

java.lang.Object
com.mojang.jtracy.TracyClient

public class TracyClient extends Object
  • Constructor Details

    • TracyClient

      public TracyClient()
  • Method Details

    • isAvailable

      public static boolean isAvailable()
      Returns true if the Tracy client is available.

      This will only be the case if the natives have been loaded successfully. This will not be the case until the first call to load(), and only if that call was successful.

      Returns:
      true if Tracy is available
    • load

      public static void load() throws UnsatisfiedLinkError
      Attempt to load the Tracy client.

      This will only function if the client is so far unavailable. Repeated calls after it's loaded will do nothing. If the library fails to load, it will throw an exception.

      Throws:
      UnsatisfiedLinkError - Any appropriate error that caused the library to not load.
    • markFrame

      public static void markFrame()
      Mark the boundary between two render frames. This ideally should be after the swap buffers command, when all rendering is submitted to the gpu.
    • frameImage

      public static void frameImage(ByteBuffer image, int width, int height, int offset, boolean flip)
      Upload an image representing a captured frame.

      It is strongly recommended to use a small an image as possible; ideally 320x180. A large image (256 KB after compression) may not be accepted.

      Parameters:
      image - The image to upload. It must be a direct buffer.
      width - Width of the image, in pixels. It must be divisible by 4.
      height - Height of the image, in pixels. It must be divisible by 4.
      offset - The offset of this image from the current frame. 0 means this frame, 1 is last frame, etc.
      flip - If this image is upside-down (e.g. OpenGL)
    • beginZone

      public static Zone beginZone(String name, boolean captureSource)
      Begin a zone with the given name. You must end the zone after it is finished, in the correct (reverse) order they were created.
      Parameters:
      name - Name of the zone to display
      captureSource - Whether to capture the callers source location. This adds more overhead.
      Returns:
      A handle to a zone that you can end
    • beginZone

      public static Zone beginZone(String name, String function, String file, int line)
      Begin a zone with the given name and source location.
      Parameters:
      name - Name of the zone to display
      function - Name of the function that this zone belongs to
      file - Name of the file that this zone belongs to
      line - Line number of the file that this zone belongs to
      Returns:
      A handle to a zone that you can end
    • setThreadName

      public static void setThreadName(String name, int group)
      Set the name of the current thread in Tracy.
      Parameters:
      name - Name of the thread to display
      group - An arbitrary group id; 0 means no group!
    • createPlot

      public static Plot createPlot(String name)
      Creates a plot with the given name. Names should be unique, you should reuse the object returned instead of creating multiple plots for the same name.
      Parameters:
      name - Name of the plot
      Returns:
      A plot that you can interact with
      See Also:
    • createDiscontinuousFrame

      public static DiscontinuousFrame createDiscontinuousFrame(String name)
      Creates a secondary discontinuous frame type with the given name. Names should be unique, you should reuse the object returned instead of creating multiple discontinuous frames for the same name.

      Unlike continuous frames, discontinuous frames must have their beginning and end explicitly marked, and there may be gaps.

      Parameters:
      name - Name of the frame
      Returns:
      A frame that you can interact with
      See Also:
    • createContinuousFrame

      public static ContinuousFrame createContinuousFrame(String name)
      Creates a secondary continuous frame type with the given name. Names should be unique, you should reuse the object returned instead of creating multiple continuous frames for the same name.

      Unlike discontinuous frames, continuous frames have no gaps, and marking the end of one frame is immediately followed by the beginning of the next.

      Parameters:
      name - Name of the frame
      Returns:
      A frame that you can interact with
      See Also:
    • createMemoryPool

      public static MemoryPool createMemoryPool(String name)
      Creates a pool of memory with the given name. Names should be unique, you should reuse the object returned instead of creating multiple MemoryPools for the same name.

      This pool will not allocate, but should be used to inform Tracy of real allocations made by the application.

      Parameters:
      name - Name of the pool of memory
      Returns:
      A pool that you can interact with
    • reportAppInfo

      public static void reportAppInfo(String text)
      Records any information about this application into the profiled data.

      This can be useful for recording the version, whether debugging is enabled, etc.

      Parameters:
      text - Any information you wish to record
    • message

      public static void message(String text)
      Records a message in Tracy's timeline. This might be used, for example, to capture the debug output of your application.
      Parameters:
      text - Message text to log
      See Also:
    • message

      public static void message(String text, int color)
      Records a colored message in Tracy's timeline. This might be used, for example, to capture the debug output of your application.

      Color should be in 0xRRGGBB style.

      Parameters:
      text - Message text to log
      color - Color for this message
      See Also:
    • message

      public static void message(Supplier<String> text)
      Records a message in Tracy's timeline. This might be used, for example, to capture the debug output of your application.
      Parameters:
      text - Supplier to provide the message text to log
      See Also:
    • message

      public static void message(Supplier<String> text, int color)
      Records a colored message in Tracy's timeline. This might be used, for example, to capture the debug output of your application.

      Color should be in 0xRRGGBB style.

      Parameters:
      text - Supplier to provide the message text to log
      color - Color for this message
      See Also:
    • createGpuContext

      public static GpuContext createGpuContext(GpuApi api, long gpuTimestamp, float gpuPeriod)
      Creates a new GPU context that you can use to record GPU zones on.

      Reuse the GpuContext returned by this object, as each context is unique. Multiple GPU contexts can live at the same time, but no more than 255.

      See Also:
    • createSectionCategory

      public static SectionCategory createSectionCategory(String name)
      Creates a new high-level section category for recording the stage of the program.
      Parameters:
      name - The name of the section category.
      Returns:
      The created section category.