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>GXReadGP0Metric</title> 10</head> 11 12<body> 13 14<h1 align="left">GXReadGP0Metric</h1> 15 16<h2>Syntax</h2> 17<dl><dd><pre class="construction"> 18#include <revolution/gx.h> 19 20u32 GXReadGP0Metric( 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 0.</p> 28 29<H2>Description</H2> 30<P>The graphics processor (GP) can count many internal events that give detailed information on performance. This function returns the current value of performance counter 0. The GP counter 0 is reset using the <A href="GXClearGPMetric.html"><CODE>GXClearGP0Metric</CODE></A> function. The metric measured for GP counter 0 is set by calling the <A href="GXSetGPMetric.html"><CODE>GXSetGP0Metric</CODE></A> function. The initial metric measured is <CODE>GX_PERF0_NONE</CODE>, which returns zero for the first call to the <A href="GXReadGP0Metric.html"><CODE>GXReadGP0Metric</CODE></A> function. If you want to monitor GP counters 0 and 1 simultaneously, use the <A href="GXSetGPMetric.html"><CODE>GXSetGPMetric</CODE></A> and <A href="GXReadGPMetric.html"><CODE>GXReadGPMetric</CODE></A> functions.</P> 31<P>Because this function reads results from CPU-accessible registers in the GP, this command must not be used in a display list. Furthermore, in some cases the performance counters are triggered by sending tokens through the graphics FIFO to the GP. 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). It may also be necessary to send a rendering synchronization token using the <A href="../Management/GXSetDrawSync.html"><CODE>GXSetDrawSync</CODE></A> function, or call the <A href="../Management/GXDrawDone.html"><CODE>GXDrawDone</CODE></A> function after the <A href="GXReadGP0Metric.html"><CODE>GXReadGP0Metric</CODE></A> function to ensure that the state has actually been processed by the GP.</P> 32<DL><DD><CODE>GXSetGP0Metric( GX_PERF0_VERTICES );<BR> GXClearGP0Metric( );<BR> drawSphere();<BR> GXSetDrawSync(0xbabe);<BR> while (0xbabe != GXReadDrawSync())<BR> ;<BR> count = GXReadGP0Metric();<BR> OSReport("Number of vertices in sphere: %d\n", count);</CODE></DD></DL> 33<P>The <A href="GXReadGP0Metric.html"><CODE>GXReadGP0Metric</CODE></A> and <A href="GXClearGPMetric.html"><CODE>GXClearGP0Metric</CODE></A> functions can be used in the callback associated with the rendering synchronization interrupt. See the <A href="../Management/GXSetDrawSyncCallback.html"><CODE>GXSetDrawSyncCallback</CODE></A> function. Because it inserts random tokens in the GP command stream, the <a href="GXSetGPMetric.html"><code>GXSetGP0Metric</code></a> function should not be used in the rendering 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> count[token - 1] = GXReadGP0Metric();<BR> GXClearGP0Metric();<BR> }</CODE></DD></DL> 36<DL><DD><CODE>void myDraw( void ) <BR> {<BR> GXSetDrawSyncCallback( myDrawSyncCallback );<BR> GXSetGP0Metric( GX_PERF0_VERTICES );<BR> drawSphere();<BR> GXSetDrawSync(0x1);<BR> drawCube();<BR> GXSetDrawSync(0x2);<BR> drawCylinder();<BR> GXSetDrawSync(0x3);<BR> GXDrawDone();<BR> for (i = 0; i < OBJECTS; i++)<BR> OSReport("vertices object %d: %d\n", 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 with both counters.<BR>For example <CODE>GX_PERF0_VERTICES</CODE> and <CODE>GX_PERF1_VERTICES</CODE>.<BR>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 0 Details</H3> 40<P>See the <A href="GXSetGPMetric.html"><CODE>GXSetGP0Metric</CODE></A> function for details on metrics that can be measured using GP counter 0.</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>