GXReadGPMetric

Syntax

#include <revolution/gx.h>

void GXReadGPMetric( u32* cnt0, u32* cnt1 );

Arguments

cnt0 Returns the current value of GP Counter 0.
cnt1 Returns the current value of GP Counter 1.

Return Values

None.

Description

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 the GXSetGPMetric, GXSetGP0Metric or GXSetGP1Metric function. The counters can be cleared using the GXClearGPMetric, GXClearGP0Metric or GXClearGP1Metric function.

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 render synchronization token using the GXSetDrawSync function, or call the GXSetDrawDone function after the GXReadGPMetric function 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 render synchronization interrupt. See the GXSetDrawSyncCallback function. The GXSetGPMetric function should not be used in the render synchronization callback, because it will randomly insert tokens in the GP command stream.

#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]);
}

Convenient Functions

The GXReadGP0Metric and GXReadGP1Metric functions can be used to read only one counter. Be aware that GXReadGP0Metric and GXReadGP1Metric should not be called at the same time. Call the GXReadGPMetric function instead.

Counter 0 Details

Refer to the GXSetGP0Metric function for details on counter 0 metrics.

Counter 1 Details

Refer to the GXSetGP1Metric function for details on counter 1 metrics.

See Also

GXReadMemMetric, GXClearMemMetric, GXReadPixMetric, GXClearPixMetric, GXReadVCacheMetric, GXClearVCacheMetric, GXSetVCacheMetric

Revision History

2006/03/01 Initial version.


CONFIDENTIAL