#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 function returns the current value of performance counter 0. The GP counter 0 is reset using the GXClearGP0Metric function. The metric measured for GP counter 0 is set by calling the GXSetGP0Metric function. The initial metric measured is GX_PERF0_NONE, which returns zero for the first call to the GXReadGP0Metric function. If you want to monitor GP counters 0 and 1 simultaneously, use the GXSetGPMetric and GXReadGPMetric functions.
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 rendering synchronization token using the GXSetDrawSync function, or call the GXDrawDone function after the GXReadGP0Metric function 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);The GXReadGP0Metric and GXClearGP0Metric functions can be used in the callback associated with the rendering synchronization interrupt. See the GXSetDrawSyncCallback function. Because it inserts random tokens in the GP command stream, the GXSetGP0Metric function should not be used in the rendering synchronization 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 the GXSetGP0Metric function for details on metrics that can be measured using GP counter 0.
GXReadMemMetric, GXClearMemMetric, GXReadPixMetric, GXClearPixMetric, GXReadVCacheMetric, GXSetVCacheMetric, GXClearVCacheMetric
2006/03/01 Initial version.
CONFIDENTIAL