#include <revolution/gx.h> u32 GXReadGP1Metric( void );
None.
The current unsigned 32-bit value (u32) for the GP counter 1.
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 1, perf1. After the current value of the counter is read, the counter is reset. The metric to be measured is set using the GXSetGP1Metric function. The initial metric measured is GX_PERF1_NONE, which returns zero on the first call to the GXReadGP1Metric function. If you want to monitor GP counter 0 and 1 at the same time, use the GXSetGPMetric and GXReadGPMetric functions.
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 render synchronization token using the GXSetDrawSync function, or call the GXSetDrawDone function after the GXReadGP1Metric function to ensure that the state has actually been processed by the GP.
GXSetGP0Metric( GX_PERF0_NONE );
GXSetGP1Metric( GX_PERF1_TEXELS );
drawSphere();
GXSetDrawSync(0xbabe);
while (0xbabe != GXReadDrawSync())
;
count = GXReadGP1Metric();
OSReport("Number of texels in sphere: %d\n", count);The GXReadGP1Metric function can be used in the callback associated with the render synchronization interrupt. See the GXSetDrawSyncCallback function. Because it inserts tokens in the GP command stream at random cycles, the GXSetGP1Metric function should not be used in the render synchronization callback.
#define OBJECTS 3
u32 count[OBJECTS]void myDrawSyncCallback( u16 token )
{
count[token - 1] = GXReadGP1Metric();
}void myDraw( void )
{
GXSetDrawSyncCallback( myDrawSyncCallback );
GXSetGP1Metric( GX_PERF1_TEXELS );
drawSphere();
GXSetDrawSync(0x1);
drawCube();
GXSetDrawSync(0x2);
drawCylinder();
GXSetDrawSync(0x3);
GXDrawDone();
for (i = 0; i < OBJECTS; i++)
OSReport("texels 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 using both counters. For example, there are 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.).
For details on the metrics that GP counter 1 can measure, see the GXSetGP1Metric function.
GXReadMemMetric, GXClearMemMetric, GXReadPixMetric, GXClearPixMetric, GXReadVCacheMetric, GXSetVCacheMetric, GXClearVCacheMetric
2006/03/01 Initial version.
CONFIDENTIAL