#include <revolution/gx.h>
void GXReadGPMetric( u32* cnt0, u32* cnt1 );
cnt0 |
returns the current value of GP Counter 0 |
cnt1 |
returns the current value of GP Counter 1 |
None.
The graphics processor (GP) can count many internal events that give detailed information on performance. This function returns the count of previous performance metrics that were set using GXSetGPMetric, GXSetGP0Metric or GXSetGP1Metric. The counters can be cleared using GXClearGPMetric, GXClearGP0Metric or GXClearGP1Metric.
Because this function reads results from CPU-accessible registers in the GP, this command must not be used in a display list. It may also be necessary to send a draw sync token using GXSetDrawSync or to call GXSetDrawDone before GXReadGPMetric to ensure that the state has actually been processed by the GP.
GXSetGPMetric( GX_PERF0_VERTICES, GX_PERF1_TEXELS );
GXClearGPMetric( );
drawSphere();
GXSetDrawSync(0xbabe);
while (0xbabe != GXReadDrawSync())
;
GXReadGPMetric(&verts, &texels);
OSReport("vertices in sphere %d, texels %d\n", verts, texels);
The GXReadGPMetric and GXClearGPMetric functions can be used in the callback associated with the draw sync interrupt. Please refer to GXSetDrawSyncCallback. Because it will insert 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][2]
void myDrawSyncCallback( u16 token )
{
GXReadGPMetric(&count[token-1][0], &count[token-1][1]);
GXClearGPMetric();
}
void myDraw( void )
{
GXSetDrawSyncCallback( myDrawSyncCallback );
GXSetGPMetric( GX_PERF0_VERTICES, GX_PERF1_TEXELS );
drawSphere();
GXSetDrawSync(1);
drawCube();
GXSetDrawSync(2);
drawCylinder();
GXSetDrawSync(3);
GXDrawDone();
for (i = 0; i < OBJECTS; i++)
OSReport("object %d: vertices %d, texels %d\n", i, count[i][0],
count[i][1]);
}
The functions GXReadGP0Metric and GXReadGP1Metric can be used to read only one counter. Be aware that GXReadGP0Metric and GXReadGP1Metric should not be called at the same time. The GXReadGPMetric function should be called instead.
Refer to the GXSetGP0Metric function for details on counter 0 metrics.
Refer to the GXSetGP1Metric function for details on counter 1 metrics.
GXReadMemMetric
GXClearMemMetric
GXReadPixMetric
GXClearPixMetric
GXReadVCacheMetric
GXClearVCacheMetric
GXSetVCacheMetric
03/01/2006 Initial version.