Class ThreadActivityRecorder
Task submission sites (transform chunks, paint tiles, tile binning) and render-thread phases (orchestration, waiting, blit) record their [start, end) intervals here when enabled. The timeline component paints each thread as a row, time on the X axis, the interval kind as color — the software-renderer equivalent of a GPU frame-profiler occupancy view. Idle time is simply the absence of intervals (black).
Overhead when disabled: one volatile read per task. When enabled:
two System.nanoTime() calls, one atomic increment and four
array stores per task (~100 ns), negligible at hundreds of tasks per
frame.
Frame parity distinguishes "current frame" work from "next frame" work in the colors: transform/paint/binning kinds come in an even and an odd variant, selected by the parity that was current when the task was SUBMITTED (captured at task creation, so overlapping frames keep their own color).
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final intKind: render thread blocked waiting for worker tasks.static final intKind base: tile binning task (add frame parity 0..2).static final intKind: render thread blitting the finished frame to screen.static final intNumber of distinct kinds (three parities each for transform/paint/bin, plus 9..14).static final intKind: continuation sub-phase: draining and merging transform chunks.static final intKind base: paint tile task (add frame parity 0..2).static final intKind: a pass's asynchronous continuation (drain, sort, bin, paint submission).static final intKind: render thread orchestration (tree walk, submission, merges).static final intKind: continuation sub-phase: depth sort.static final intKind base: vertex transform chunk (add frame parity 0..2). -
Method Summary
Modifier and TypeMethodDescriptionstatic intcapacity()static voidclear()Drops all recorded intervals and thread-row assignments.static intcursor()static long[]ends()static intstatic booleanstatic byte[]kinds()static voidrecord(int kind, long t0, long t1) Records one work interval on the calling thread.static introwCount()static StringrowName(int row) static byte[]rows()static voidsetEnabled(boolean value) Enables or disables recording.static voidsetFrameParity(int parity) Sets the parity (0/1) of the frame currently being prepared.static long[]starts()
-
Field Details
-
KIND_TRANSFORM
public static final int KIND_TRANSFORMKind base: vertex transform chunk (add frame parity 0..2).- See Also:
-
KIND_PAINT
public static final int KIND_PAINTKind base: paint tile task (add frame parity 0..2).- See Also:
-
KIND_BIN
public static final int KIND_BINKind base: tile binning task (add frame parity 0..2).- See Also:
-
KIND_RENDER
public static final int KIND_RENDERKind: render thread orchestration (tree walk, submission, merges).- See Also:
-
KIND_AWAIT
public static final int KIND_AWAITKind: render thread blocked waiting for worker tasks.- See Also:
-
KIND_BLIT
public static final int KIND_BLITKind: render thread blitting the finished frame to screen.- See Also:
-
KIND_PREP
public static final int KIND_PREPKind: a pass's asynchronous continuation (drain, sort, bin, paint submission).- See Also:
-
KIND_DRAIN
public static final int KIND_DRAINKind: continuation sub-phase: draining and merging transform chunks.- See Also:
-
KIND_SORT
public static final int KIND_SORTKind: continuation sub-phase: depth sort.- See Also:
-
KIND_COUNT
public static final int KIND_COUNTNumber of distinct kinds (three parities each for transform/paint/bin, plus 9..14).- See Also:
-
-
Method Details
-
isEnabled
public static boolean isEnabled()- Returns:
- true when recording is active (checked by task submission sites)
-
setEnabled
public static void setEnabled(boolean value) Enables or disables recording. Enabling starts with a clean buffer and fresh thread-row assignment.- Parameters:
value- true to start recording
-
clear
public static void clear()Drops all recorded intervals and thread-row assignments. -
setFrameParity
public static void setFrameParity(int parity) Sets the parity (0/1) of the frame currently being prepared. Called by the render thread at the start of each frame; task submission sites capture it into their tasks so overlapping frames keep distinct colors.- Parameters:
parity- frame parity, 0 or 1
-
frameParity
public static int frameParity()- Returns:
- parity of the frame currently being prepared
-
record
public static void record(int kind, long t0, long t1) Records one work interval on the calling thread.- Parameters:
kind- interval kind (one of the KIND_* bases, plus parity for transform/paint/binning)t0- interval start, fromSystem.nanoTime()t1- interval end, fromSystem.nanoTime()
-
cursor
public static int cursor()- Returns:
- total number of intervals recorded since the last clear
-
capacity
public static int capacity()- Returns:
- ring buffer capacity
-
starts
public static long[] starts()- Returns:
- interval start array (index space of the ring buffer)
-
ends
public static long[] ends()- Returns:
- interval end array (index space of the ring buffer)
-
kinds
public static byte[] kinds()- Returns:
- interval kind array (index space of the ring buffer)
-
rows
public static byte[] rows()- Returns:
- interval thread-row array (index space of the ring buffer)
-
rowCount
public static int rowCount()- Returns:
- number of distinct thread rows seen so far
-
rowName
- Parameters:
row- thread row index- Returns:
- display name for the row ("render" for the render thread, otherwise the thread name with the e3d- prefix stripped)
-