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<h2>Syntax</h2>
17<dl><dd><pre class="construction">
18#include &lt;revolution/gx.h&gt;
19
20u32 GXReadGP1Metric( void );
21</pre></dd></dl>
22
23<h2>Arguments</h2>
24<p>None.</p>
25
26<h2>Return Values</h2>
27<p>The current unsigned 32-bit value (u32) for the GP counter 1.</p>
28
29<H2>Description</H2>
30<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, <SPAN class="argument">perf1</SPAN>. After the current value of the counter is read, the counter is reset.&nbsp;The metric to be measured is set using the <A href="GXSetGPMetric.html"><CODE>GXSetGP1Metric</CODE></A> function. The initial metric measured is <CODE>GX_PERF1_NONE</CODE>, which returns zero on the first call to the <A href="GXReadGP1Metric.html"><CODE>GXReadGP1Metric</CODE></A> function.&nbsp;If you want to monitor GP counter 0 and 1 at the same time, use the <A href="GXSetGPMetric.html"><CODE>GXSetGPMetric</CODE></A> and <A href="GXReadGPMetric.html"><CODE>GXReadGPMetric</CODE></A> functions.</P>
31<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 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="GXReadGP1Metric.html"><CODE>GXReadGP1Metric</CODE></A> function to ensure that the state has actually been processed by the GP.</P>
32<DL><DD><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></DD></DL>
33<P>The <A href="GXReadGP1Metric.html"><CODE>GXReadGP1Metric</CODE></A> function can be used in the callback associated with the render synchronization interrupt. See the <A href="../Management/GXSetDrawSyncCallback.html"><CODE>GXSetDrawSyncCallback</CODE></A> function. Because it inserts tokens in the GP command stream at random cycles, the <A href="GXSetGPMetric.html"><CODE>GXSetGP1Metric</CODE></A> function should not be used in the render synchronization callback.</P>
34<DL><DD><CODE>#define OBJECTS 3<BR> u32 count[OBJECTS]</CODE></DD></DL>
35<DL><DD><CODE>void myDrawSyncCallback( u16 token ) <BR> {<BR> &nbsp;&nbsp;&nbsp; count[token - 1] = GXReadGP1Metric();<BR> }</CODE></DD></DL>
36<DL><DD><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></DD></DL>
37<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>
38
39<H3>Counter 1 Details</H3>
40<P>For details on the metrics that GP counter 1 can measure, see the <A href="GXSetGPMetric.html"><CODE>GXSetGP1Metric</CODE></A> function.</P>
41
42<h2>See Also</h2>
43<P class="reference">
44<a href="GXReadMemMetric.html">GXReadMemMetric</a>,
45<a href="GXClearMemMetric.html">GXClearMemMetric</a>,
46<a href="GXReadPixMetric.html">GXReadPixMetric</a>,
47<a href="GXClearPixMetric.html">GXClearPixMetric</a>,
48<a href="GXReadVCacheMetric.html">GXReadVCacheMetric</a>,
49<a href="GXSetVCacheMetric.html">GXSetVCacheMetric</a>,
50<a href="GXClearVCacheMetric.html">GXClearVCacheMetric</a>
51</p>
52
53<H2>Revision History</H2>
54<P>
552006/03/01 Initial version.<br>
56</P>
57
58<hr><p>CONFIDENTIAL</p></body>
59</HTML>