1<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> 2<html> 3 4<head> 5<META http-equiv="Content-Type" content="text/html; charset=windows-1252"> 6<META name="GENERATOR" content="Microsoft FrontPage 5.0"> 7<META http-equiv="Content-Style-Type" content="text/css"> 8<LINK rel="stylesheet" type="text/css" href="../../CSS/revolution.css"> 9<title>GXReadGP0Metric</title> 10</head> 11 12<body> 13 14<h1 align="left">GXReadGP0Metric</h1> 15 16 17<h2>C Specification</h2> 18 19<dl> 20<dd><PRE><CODE>#include <revolution/gx.h></CODE></PRE> 21 </dd> 22<dd><pre><CODE>u32 GXReadGP0Metric( void );</CODE></pre> 23 </dd> 24</dl> 25 26<h2>Arguments</h2> 27 28<p>None.</p> 29 30<h2>Return Values</h2> 31 32<p>The current unsigned 32-bit value (u32) for the GP counter 0.</p> 33<H2>Description</H2> 34<P>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 <a href="GXClearGPMetric.html"><code>GXClearGP0Metric</code></a>. The metric measured for GP counter 0 is set by calling <a href="GXSetGPMetric.html"><code>GXSetGP0Metric</code></a>. The initial metric measured is <code>GX_PERF0_NONE</code> which returns zero for the first call to <a href="GXReadGP0Metric.html"><code>GXReadGP0Metric</code></a>. If you want to monitor GP counters 0 and 1 simultaneously, use <code><a href="GXSetGPMetric.html">GXSetGPMetric</a>/<a href="GXReadGPMetric.html">GXReadGPMetric</a></code>.</P> 35<P>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 <a href="../Management/GXSetDrawSync.html"><code>GXSetDrawSync</code></a> or call <a href="../Management/GXDrawDone.html"><code>GXDrawDone</code></a> after <a href="GXReadGP0Metric.html"><code>GXReadGPMetric</code></a> to ensure that the state has actually been processed by the GP.</P> 36<P><CODE>GXSetGP0Metric( GX_PERF0_VERTICES );<BR> GXClearGP0Metric( );<BR> drawSphere();<BR> GXSetDrawSync(0xbabe);<BR> while (0xbabe != GXReadDrawSync())<BR> ;<BR> count = GXReadGP0Metric();<BR> OSReport("Number of vertices in sphere: %d\n", count);</CODE></P> 37<P><a href="GXReadGP0Metric.html"><code>GXReadGP0Metric</code></a> and <a href="GXClearGPMetric.html"><code>GXClearGP0Metric</code></a> can be used in the callback associated with the draw sync interrupt. Refer to <a href="../Management/GXSetDrawSyncCallback.html"><code>GXSetDrawSyncCallback</code></a>. Because it inserts random tokens in the GP command stream, the <a href="GXSetGPMetric.html"><code>GXSetGPMetric</code></a> function should not be used in the draw sync callback.</P> 38<P><code>#define OBJECTS 3<br> u32 count[OBJECTS]</code></P> 39<P><CODE>void myDrawSyncCallback( u16 token ) <BR> {<BR> count[token - 1] = GXReadGP0Metric();<BR> GXClearGP0Metric();<BR> }</CODE></P> 40<P><CODE>void myDraw( void ) <BR> {<BR> GXSetDrawSyncCallback( myDrawSyncCallback );<BR> GXSetGP0Metric( GX_PERF0_VERTICES );<BR> drawSphere();<BR> GXSetDrawSync(0x1);<BR> drawCube();<BR> GXSetDrawSync(0x2);<BR> drawCylinder();<BR> GXSetDrawSync(0x3);<BR> GXDrawDone();<BR> for (i = 0; i < OBJECTS; i++)<BR> OSReport("vertices object %d: %d\n", i, count[i]);<BR> }</CODE></P> 41<P>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 <code>GX_PERF0_VERTICES</code> and <code>GX_PERF1_VERTICES</code>. Ratios (metric names ending in <code>_RATIO</code>) are multiplied by 1000 (1000 = all misses/clips, etc., 0 = no misses/clips, etc.).</P> 42<H3>Counter 0 Details</H3> 43<P>See <a href="GXSetGPMetric.html"><code>GXSetGP0Metric</code></a> for details on metrics that can be measured using GP counter 0.</P> 44 45 46 47 48<h2>See Also</h2> 49 50<p><a href="GXReadMemMetric.html"><CODE>GXReadMemMetric</CODE></a><br> <a href="GXClearMemMetric.html"><CODE>GXClearMemMetric</CODE></a><br> <a href="GXReadPixMetric.html"><CODE>GXReadPixMetric</CODE></a><br> <a href="GXClearPixMetric.html"><CODE>GXClearPixMetric</CODE></a><br> <a href="GXReadVCacheMetric.html"><CODE>GXReadVCacheMetric</CODE></a><br> <a href="GXSetVCacheMetric.html"><CODE>GXSetVCacheMetric</CODE></a><br> <a href="GXClearVCacheMetric.html"><CODE>GXClearVCacheMetric</CODE></a> 51</p> 52<H2>Revision History</H2> 53<P>03/01/2006 Initial version.</P>