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>GXReadGP1Metric</title>
10</head>
11
12<body>
13
14<h1 align="left">GXReadGP1Metric</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>u32 GXReadGP1Metric( 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 1.</p>
33<H2>Description</H2>
34<P>The Graphics Processor (GP) can count many internal events that give detailed information on performance.&nbsp;This convenient function returns the current value of performance counter 1, <code>perf1</code>. After the current value of the counter is read, the counter is reset.&nbsp;The metric to be measured is set using <a href="GXSetGPMetric.html"><code>GXSetGP1Metric</code></a>. The initial metric measured is <code>GX_PERF1_NONE</code> which returns zero for the first call to <a href="GXReadGP1Metric.html"><code>GXReadGP1Metric</code></a>.&nbsp;If you want to monitor GP counter 0 and 1 at the same time, use <code><a href="GXSetGPMetric.html">GXSetGPMetric</a>/<a href="GXReadGPMetric.html">GXReadGPMetric</a></code>.</P>
35<P>This function reads results from CPU-accessible registers in the GP; this command must not be used in a display list.&nbsp;Furthermore, in some cases the performance counters are triggered by sending tokens through the graphics FIFO to the GP.&nbsp;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).&nbsp;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/GXSetDrawDone.html"><code>GXSetDrawDone</code></a> after <a href="GXReadGP1Metric.html"><code>GXReadGP1Metric</code></a> to ensure that the state has actually been processed by the GP.</P>
36<P><CODE>GXSetGP0Metric( GX_PERF0_NONE );<BR> GXSetGP1Metric( GX_PERF1_TEXELS );<BR> drawSphere();<BR> GXSetDrawSync(0xbabe);<BR> while (0xbabe != GXReadDrawSync())<BR> &nbsp;&nbsp;&nbsp; ;<BR> count = GXReadGP1Metric();<BR> OSReport(&quot;Number of texels in sphere: %d\n&quot;, count);</CODE></P>
37<P>The <a href="GXReadGP1Metric.html"><code>GXReadGP1Metric</code></a> function 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> &nbsp;&nbsp;&nbsp; count[token - 1] = GXReadGP1Metric();<BR> }</CODE></P>
40<P><CODE>void myDraw( void )<BR> {<BR> &nbsp;&nbsp;&nbsp; GXSetDrawSyncCallback( myDrawSyncCallback );<BR> &nbsp;&nbsp;&nbsp; GXSetGP1Metric( GX_PERF1_TEXELS );<BR> &nbsp;&nbsp;&nbsp; drawSphere();<BR> &nbsp;&nbsp;&nbsp; GXSetDrawSync(0x1);<BR> &nbsp;&nbsp;&nbsp; drawCube();<BR> &nbsp;&nbsp;&nbsp; GXSetDrawSync(0x2);<BR> &nbsp;&nbsp;&nbsp; drawCylinder();<BR> &nbsp;&nbsp;&nbsp; GXSetDrawSync(0x3);<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;texels object %d: %d\n&quot;, 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 using both counters. For example, there are <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 1 Details</H3>
43<P>For details on the metrics that GP counter 1 can measure, see the <a href="GXSetGPMetric.html"><code>GXSetGP1Metric</code></a> function.</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></p>
51<H2>Revision History</H2>
52<P>03/01/2006 Initial version.</P>