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=utf-8">
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. This function 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. 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. 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> ;<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> GXReadGPMetric(&amp;count[token-1][0], &amp;count[token-1][1]);<BR> GXClearGPMetric();<BR> }</CODE></DD></DL>
45<DL><DD><CODE>void myDraw( void ) <BR> {<BR> GXSetDrawSyncCallback( myDrawSyncCallback );<BR> GXSetGPMetric( GX_PERF0_VERTICES, GX_PERF1_TEXELS );<BR> drawSphere();<BR> GXSetDrawSync(1);<BR> drawCube();<BR> GXSetDrawSync(2);<BR> drawCylinder();<BR> GXSetDrawSync(3);<BR> GXDrawDone();<BR> for (i = 0; i &lt; OBJECTS; i++)<BR>
46       
47OSReport(&quot;object %d:vertices %d, texels %d\n&quot;, i, count[i][0],<BR>
48           
49count[i][1]);<BR> }</CODE></DD></DL>
50
51<H3>Convenient Functions</H3>
52<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. Be aware that <a href="GXReadGP0Metric.html"><code>GXReadGP0Metric</code></a> and <a href="GXReadGP1Metric.html"><code>GXReadGP1Metric</code></a> should not be called at the same time. Call the <A href="GXReadGPMetric.html"><CODE>GXReadGPMetric</CODE></A> function instead.</P>
53
54<H3>Counter 0 Details</H3>
55<P>Refer to the <CODE><A href="GXSetGPMetric.html">GXSetGP0Metric</A></CODE> function for details on counter 0 metrics.</P>
56
57<H3>Counter 1 Details</H3>
58<P>Refer to the <CODE><A href="GXSetGPMetric.html">GXSetGP1Metric</A></CODE> function for details on counter 1 metrics.</P>
59
60<h2>See Also</h2>
61<P class="reference">
62<a href="GXReadMemMetric.html">GXReadMemMetric</a><BR> <a href="GXClearMemMetric.html">GXClearMemMetric</a><BR> <a href="GXReadPixMetric.html">GXReadPixMetric</a><BR> <a href="GXClearPixMetric.html">GXClearPixMetric</a><BR> <a href="GXReadVCacheMetric.html">GXReadVCacheMetric</a><BR> <a href="GXClearVCacheMetric.html">GXClearVCacheMetric</a><BR> <a href="GXSetVCacheMetric.html">GXSetVCacheMetric</a>
63</p>
64
65<H2>Revision History</H2>
66<P>
672006/03/01 Initial version.<br>
68</P>
69
70<hr><p>CONFIDENTIAL</p></body>
71</HTML>