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<h2>Syntax</h2>
17<dl><dd><pre class="construction">
18#include &lt;revolution/gx.h&gt;
19
20void GXReadGPMetric( u32* cnt0, u32* cnt1 );
21</pre></dd></dl>
22
23<h2>Arguments</h2>
24<TABLE class="arguments" border="1" >
25  <tr>
26<TH>cnt0</TH>
27<TD>Returns the current value of GP Counter 0.</TD>
28  </tr>
29  <tr>
30<TH>cnt1</TH>
31<TD>Returns the current value of GP Counter 1.</TD>
32  </tr>
33</TABLE>
34
35<h2>Return Values</h2>
36<p>None.</p>
37
38<H2>Description</H2>
39<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 the <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> function.&nbsp;The counters can be cleared using the <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> function.</P>
40<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 render synchronization token using the <A href="../Management/GXSetDrawSync.html"><CODE>GXSetDrawSync</CODE></A> function, or call the <A href="../Management/GXSetDrawDone.html"><CODE>GXSetDrawDone</CODE></A> function after the <A href="GXReadGPMetric.html"><CODE>GXReadGPMetric</CODE></A> function to ensure that the state has actually been processed by the GP.</P>
41<DL><DD><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></DD></DL>
42<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 render synchronization interrupt. See the <A href="../Management/GXSetDrawSyncCallback.html"><CODE>GXSetDrawSyncCallback</CODE></A> function. The <A href="GXSetGPMetric.html"><CODE>GXSetGPMetric</CODE></A> function should not be used in the render synchronization callback, because it will randomly insert tokens in the GP command stream.</P>
43<DL><DD><CODE>#define OBJECTS 3<BR> u32 count[OBJECTS][2]</CODE></DD></DL>
44<DL><DD><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></DD></DL>
45<DL><DD><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></DD></DL>
46
47<H3>Convenient Functions</H3>
48<P>The <A href="GXReadGP0Metric.html"><CODE>GXReadGP0Metric</CODE></A> and <A href="GXReadGP1Metric.html"><CODE>GXReadGP1Metric</CODE></A> functions 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;Call the <A href="GXReadGPMetric.html"><CODE>GXReadGPMetric</CODE></A> function instead.</P>
49
50<H3>Counter 0 Details</H3>
51<P>Refer to the <CODE><A href="GXSetGPMetric.html">GXSetGP0Metric</A></CODE> function for details on counter 0 metrics.</P>
52
53<H3>Counter 1 Details</H3>
54<P>Refer to the <CODE><A href="GXSetGPMetric.html">GXSetGP1Metric</A></CODE> function for details on counter 1 metrics.</P>
55
56<h2>See Also</h2>
57<P class="reference">
58<a href="GXReadMemMetric.html">GXReadMemMetric</a>,
59<a href="GXClearMemMetric.html">GXClearMemMetric</a>,
60<a href="GXReadPixMetric.html">GXReadPixMetric</a>,
61<a href="GXClearPixMetric.html">GXClearPixMetric</a>,
62<a href="GXReadVCacheMetric.html">GXReadVCacheMetric</a>,
63<a href="GXClearVCacheMetric.html">GXClearVCacheMetric</a>,
64<a href="GXSetVCacheMetric.html">GXSetVCacheMetric</a>
65</p>
66
67<H2>Revision History</H2>
68<P>
692006/03/01 Initial version.<br>
70</P>
71
72<hr><p>CONFIDENTIAL</p></body>
73</HTML>