#include <revolution/gx.h>
u32 GXReadGP0Metric( void );
None.
The current unsigned 32-bit value (u32) for the GP counter 0.
The Graphics Processor (GP) can count many internal events that give detailed information on performance. This convenient function returns the current value of performance counter 0. The GP counter 0 is reset using GXClearGP0Metric. The metric measured for GP counter 0 is set by calling GXSetGP0Metric. The initial metric measured is GX_PERF0_NONE which returns zero for the first call to GXReadGP0Metric. If you want to monitor GP counters 0 and 1 simultaneously, use GXSetGPMetric/GXReadGPMetric.
Because this function reads results from CPU-accessible registers in the GP, this command must not be used in a display list. Furthermore, in some cases the performance counters are triggered by sending tokens through the graphics FIFO to the GP. This implies that the function should only be used in immediate mode (when the graphics FIFO is connected simultaneously to the CPU and the GP). It may also be necessary to send a draw sync token using GXSetDrawSync or call GXDrawDone after GXReadGPMetric to ensure that the state has actually been processed by the GP.
GXSetGP0Metric( GX_PERF0_VERTICES );
GXClearGP0Metric( );
drawSphere();
GXSetDrawSync(0xbabe);
while (0xbabe != GXReadDrawSync())
;
count = GXReadGP0Metric();
OSReport("Number of vertices in sphere: %d\n", count);
GXReadGP0Metric and GXClearGP0Metric can be used in the callback associated with the draw sync interrupt. Refer to GXSetDrawSyncCallback. Because it inserts random tokens in the GP command stream, the GXSetGPMetric function should not be used in the draw sync callback.
#define OBJECTS 3
u32 count[OBJECTS]
void myDrawSyncCallback( u16 token )
{
count[token - 1] = GXReadGP0Metric();
GXClearGP0Metric();
}
void myDraw( void )
{
GXSetDrawSyncCallback( myDrawSyncCallback );
GXSetGP0Metric( GX_PERF0_VERTICES );
drawSphere();
GXSetDrawSync(0x1);
drawCube();
GXSetDrawSync(0x2);
drawCylinder();
GXSetDrawSync(0x3);
GXDrawDone();
for (i = 0; i < OBJECTS; i++)
OSReport("vertices object %d: %d\n", i, count[i]);
}
Each performance counter has a unique set of events or ratios that it can count. In some cases the same metric can be counted with both counters. For example GX_PERF0_VERTICES and GX_PERF1_VERTICES. Ratios (metric names ending in _RATIO) are multiplied by 1000 (1000 = all misses/clips, etc., 0 = no misses/clips, etc.).
See GXSetGP0Metric for details on metrics that can be measured using GP counter 0.
GXReadMemMetric
GXClearMemMetric
GXReadPixMetric
GXClearPixMetric
GXReadVCacheMetric
GXSetVCacheMetric
GXClearVCacheMetric
2006/03/01 Initial version.