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>GXReadGPMetric</title>
10</head>
11
12<body>
13
14<h1 align="left">GXReadGPMetric</h1>
15
16
17<h2>C Specification</h2>
18
19<dl>
20<dd><PRE><CODE>#include &lt;revolution/gx.h&gt;</CODE></PRE>
21  </dd>
22<dd><pre><CODE>void GXReadGPMetric( u32* cnt0, u32* cnt1 );</CODE></pre>
23  </dd>
24</dl>
25
26<h2>Arguments</h2>
27<TABLE border="1" cellpadding="3" cellspacing="0.1">
28  <tr>
29<TD width="120" bgcolor="#ffffe8"><em><strong><CODE>cnt0</font></strong></em></TD>
30<TD width="520">returns the current value of GP Counter 0</TD>
31    </tr>
32  <tr>
33<TD width="120" bgcolor="#ffffe8"><em><strong><CODE>cnt1</font></strong></em></TD>
34<TD width="520">returns the current value of GP Counter 1</TD>
35    </tr>
36</TABLE>
37<h2>Return Values</h2>
38
39<p>None.</p>
40<H2>Description</H2>
41<P>The graphics processor (GP) can count many internal events that give detailed information on performance.&nbsp;This function&nbsp; returns the count of previous performance metrics that were set using <a href="GXSetGPMetric.html"><code>GXSetGPMetric</code></a>, <a href="GXSetGPMetric.html"><code>GXSetGP0Metric</code></a> or <a href="GXSetGPMetric.html"><code>GXSetGP1Metric</code></a>.&nbsp;The counters can be cleared using <a href="GXClearGPMetric.html"><code>GXClearGPMetric</code></a>, <a href="GXClearGPMetric.html"><code>GXClearGP0Metric</code></a> or <a href="GXClearGPMetric.html"><code>GXClearGP1Metric</code></a>.</P>
42<P>Because this function reads results from CPU-accessible registers in the GP, this command must not be used in a display list.&nbsp;It may also be necessary to send a draw sync token using <a href="../Management/GXSetDrawSync.html"><code>GXSetDrawSync</code></a> or to call <a href="../Management/GXSetDrawDone.html"><code>GXSetDrawDone</code></a> before <a href="GXReadGPMetric.html"><code>GXReadGPMetric</code></a> to ensure that the state has actually been processed by the GP.</P>
43<P><CODE>GXSetGPMetric( GX_PERF0_VERTICES, GX_PERF1_TEXELS );<BR> GXClearGPMetric( );<BR> drawSphere();<BR> GXSetDrawSync(0xbabe);<BR> while (0xbabe != GXReadDrawSync())<BR> &nbsp;&nbsp;&nbsp; ;<BR> GXReadGPMetric(&amp;verts, &amp;texels);<BR> OSReport(&quot;vertices in sphere %d, texels %d\n&quot;, verts, texels);</CODE></P>
44<P>The <a href="GXReadGPMetric.html"><code>GXReadGPMetric</code></a> and <a href="GXClearGPMetric.html"><code>GXClearGPMetric</code></a> functions can be used in the callback associated with the draw sync interrupt. Please refer to <a href="../Management/GXSetDrawSyncCallback.html"><code>GXSetDrawSyncCallback</code></a>. Because it will insert 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>
45<P><code>#define OBJECTS 3<br> u32 count[OBJECTS][2]</code></P>
46<P><CODE>void myDrawSyncCallback( u16 token ) <BR> {<BR> &nbsp;&nbsp;&nbsp; GXReadGPMetric(&amp;count[token-1][0], &amp;count[token-1][1]);<BR> &nbsp;&nbsp;&nbsp; GXClearGPMetric();<BR> }</CODE></P>
47<P><CODE>void myDraw( void ) <BR> {<BR> &nbsp;&nbsp;&nbsp; GXSetDrawSyncCallback( myDrawSyncCallback );<BR> &nbsp;&nbsp;&nbsp; GXSetGPMetric( GX_PERF0_VERTICES, GX_PERF1_TEXELS );<BR> &nbsp;&nbsp;&nbsp; drawSphere();<BR> &nbsp;&nbsp;&nbsp; GXSetDrawSync(1);<BR> &nbsp;&nbsp;&nbsp; drawCube();<BR> &nbsp;&nbsp;&nbsp; GXSetDrawSync(2);<BR> &nbsp;&nbsp;&nbsp; drawCylinder();<BR> &nbsp;&nbsp;&nbsp; GXSetDrawSync(3);<BR> &nbsp;&nbsp;&nbsp; GXDrawDone();<BR> &nbsp;&nbsp;&nbsp; for (i = 0; i &lt; OBJECTS; i++)<BR> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; OSReport(&quot;object %d: vertices %d, texels %d\n&quot;, i, count[i][0],<BR> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; count[i][1]);<BR> }</CODE><BR></P>
48<H3>Convenient Functions</H3>
49<P>The functions <a href="GXReadGP0Metric.html"><code>GXReadGP0Metric</code></a> and <a href="GXReadGP1Metric.html"><code>GXReadGP1Metric</code></a> can be used to read only one counter.&nbsp;Be aware that <a href="GXReadGP0Metric.html"><code>GXReadGP0Metric</code></a> and <a href="GXReadGP1Metric.html"><code>GXReadGP1Metric</code></a>&nbsp;should not be called at the same time.&nbsp; The <a href="GXReadGPMetric.html"><code>GXReadGPMetric</code></a> function should be called instead.</P>
50<H3>Counter 0 Details</H3>
51<P>Refer to the <a href="GXSetGPMetric.html"><code>GXSetGP0Metric</code></a> function for details on counter 0 metrics.</P>
52<H3>Counter 1 Details</H3>
53<P>Refer to the <a href="GXSetGPMetric.html"><code>GXSetGP1Metric</code></a> function for details on counter 1 metrics.</P>
54
55
56
57
58<h2>See Also</h2>
59
60<p><a href="GXReadMemMetric.html"><CODE>GXReadMemMetric</CODE></a><br> <CODE><a href="GXClearMemMetric.html">GXClearMemMetric</a></CODE><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="GXClearVCacheMetric.html"><CODE>GXClearVCacheMetric</CODE></a><br> <a href="GXSetVCacheMetric.html"><CODE>GXSetVCacheMetric</CODE></a></p>
61<H2>Revision History</H2>
62<P>2006/03/01 Initial version.</P>