1<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
2<HTML>
3<HEAD>
4<META http-equiv="Content-Type" content="text/html; charset=windows-1252">
5<META name="GENERATOR" content="Microsoft FrontPage 5.0">
6<META http-equiv="Content-Style-Type" content="text/css">
7<LINK rel="stylesheet" type="text/css" href="../../CSS/revolution.css">
8<TITLE>Render Modes</TITLE>
9</HEAD>
10<BODY>
11<H1 align="left">Render Modes</H1>
12<H2>Syntax</H2>
13<dl><dd><pre class="construction">
14#include &lt;revolution/gx.h&gt;
15</pre></dd></dl>
16
17<H2>Description</H2>
18<P>To enable the render mode variables for the GX API, initialize the <A href="../Structures/GXRenderModeObj.html"><CODE>GXRenderModeObj</CODE></A> structure set. Active render modes are as indicated on the <A href="#Render Mode Structures">lower half</A> of this page. The application can provide the default values for display-related functions and, if preferred, disable them.</P>
19<P><A href="../Management/GXInit.html"><CODE>GXInit</CODE></A> sets the render mode to the appropriate <A href="#GXNtsc480IntDf"><CODE>GXNtsc480IntDf</CODE></A> and <CODE><A href="#GXPal528IntDf">GXPal528IntDf</A></CODE>.</P>
20
21<H2>Code Example</H2>
22<P>The following is just a basic example.&nbsp; It is not necessarily the optimal way of managing your frame loop.</P>
23<DL><DD><CODE>main()<BR> {<BR> &nbsp;&nbsp;&nbsp; // Set up rendering display mode to NTSC 240 <BR> &nbsp;&nbsp;&nbsp; // lines per field interlaced.<BR> &nbsp;&nbsp;&nbsp; // Antialiased rendering.<BR> &nbsp;&nbsp;&nbsp; <A href="../Structures/GXRenderModeObj.html">GXRenderModeObj</A>* &nbsp;&nbsp;&nbsp; rmode = &amp;<A href="#GXNtsc240IntAa">GXNtsc240IntAa</A>;<BR> &nbsp;&nbsp;&nbsp; u16* &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; bufA, bufB, nextbuffer;<BR> &nbsp;&nbsp;&nbsp; u32 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; count;<BR> &nbsp;&nbsp;&nbsp; u8* &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;fifo;<BR> &nbsp;&nbsp;&nbsp; f32&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; yScale;<BR> &nbsp;&nbsp;&nbsp; u32 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;n_xfb_lines;<BR> <BR> &nbsp;&nbsp;&nbsp; fifo = <A href="../../os/Alloc/OSAlloc.html">OSAlloc</A>(FIFO_SIZE);<BR> &nbsp;&nbsp;&nbsp; <A href="../Management/GXInit.html">GXInit</A>(fifo, FIFO_SIZE); <BR> &nbsp;&nbsp;&nbsp; <A href="../../vi/VIInit.html">VIInit</A>();<BR> <BR> &nbsp;&nbsp;&nbsp; // Set up video<BR> &nbsp;&nbsp;&nbsp; <A href="../../vi/VIConfigure.html">VIConfigure</A>(rmode);<BR> <BR> &nbsp;&nbsp;&nbsp; // Set other GX state&nbsp;&nbsp;&nbsp; <BR> &nbsp;&nbsp;&nbsp; <A href="../Culling/GXSetScissor.html">GXSetScissor</A>(&nbsp; 0, 0, rmode-&gt;fbWidth, rmode-&gt;efbHeight );<BR> <BR> &nbsp;&nbsp;&nbsp; <A href="GXSetDispCopySrc.html">GXSetDispCopySrc</A>(0, 0, rmode-&gt;fbWidth, rmode-&gt;efbHeight);<BR> <BR> &nbsp;&nbsp;&nbsp; // call yscale after setting display copy source<BR> &nbsp;&nbsp;&nbsp; n_xfb_lines =&nbsp; // account for yscale in xfb height<BR> &nbsp;&nbsp;&nbsp;&nbsp;<A href="GXSetDispCopyYScale.html">GXSetDispCopyYScale</A>((f32)(rmode-&gt;xfbHeight /<BR> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; (f32)(rmode-&gt;efbHeight));<BR> <BR> &nbsp;&nbsp;&nbsp; <A href="GXSetDispCopyDst.html">GXSetDispCopyDst</A>(rmode-&gt;fbWidth, n_xfb_lines);<BR> &nbsp;&nbsp;&nbsp; <A href="GXSetCopyFilter.html">GXSetCopyFilter</A>(rmode-&gt;aa, rmode-&gt;sample_pattern,<BR> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; GX_TRUE, rmode-&gt;vfilter);<BR> &nbsp;&nbsp;&nbsp; <BR> &nbsp;&nbsp;&nbsp; if (rmode-&gt;aa)<BR> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <A href="../PixelProc/GXSetPixelFmt.html">GXSetPixelFmt</A>(GX_PF_RGB565_Z16, GX_ZC_LINEAR);<BR> &nbsp;&nbsp;&nbsp; else<BR> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <A href="../PixelProc/GXSetPixelFmt.html">GXSetPixelFmt</A>(GX_PF_RGB8_Z24, GX_ZC_LINEAR);<BR> <BR> &nbsp;&nbsp;&nbsp; <A href="../PixelProc/GXSetFieldMode.html">GXSetFieldMode</A>(rmode-&gt;field_rendering, rmode-&gt;xfbHeight &lt; rmode-&gt;viHeight);</CODE></DD></DL>
24<DL><DD><CODE>&nbsp;&nbsp;&nbsp; // Allocate the main memory for the framebuffer<BR> &nbsp;&nbsp;&nbsp; bufA = <A href="../../os/Alloc/OSAlloc.html">OSAlloc</A>( <A href="../../vi/VIPadFrameBufferWidth.html">VIPadFramebufferWidth</A>(rmode-&gt;fbWidth) * n_xfb_lines * VI_DISPLAY_PIX_SZ);<BR> &nbsp;&nbsp;&nbsp; bufB = <A href="../../os/Alloc/OSAlloc.html">OSAlloc</A>( <A href="../../vi/VIPadFrameBufferWidth.html">VIPadFramebufferWidth</A>(rmode-&gt;fbWidth) * n_xfb_lines * VI_DISPLAY_PIX_SZ);<BR> <BR> &nbsp;&nbsp;&nbsp; // main rendering loop<BR> &nbsp;&nbsp;&nbsp; nextbuffer = bufA;<BR> &nbsp;&nbsp;&nbsp; count = 0;<BR> <BR> &nbsp;&nbsp;&nbsp; while (1) {<BR> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; // jitter frustum for field rendering<BR> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if (rmode-&gt;field_rendering)<BR> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <A href="../Transform/GXSetViewportJitter.html">GXSetViewportJitter</A>(<BR> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 0.0f, 0.0f,<BR> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; (f32)(rmode-&gt;fbWidth), <BR> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&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p;&nbsp;&nbsp; (f32)(rmode-&gt;efbHeight), <BR> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 0.0f, 1.0f );<BR> <BR> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; // do some rendering<BR> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; doRendering();<BR> <BR> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; // copy framebuffer from EFB (on chip) to XFB (main memory)<BR> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; // and clear the color and z buffer<BR> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <A href="GXCopyDisp.html">GXCopyDisp</A>(nextbuffer, GX_TRUE);<BR> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <A href="../Management/GXDrawDone.html">GXDrawDone</A>();<BR> <BR> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; // tell VI that a new buffer is done and its type<BR> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <A href="../../vi/VISetNextFrameBuffer.html">VISetNextFrameBuffer</A>(nextbuffer);<BR> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <A href="../../vi/VIFlush.html">VIFlush</A>();<BR> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <A href="../../vi/VIWaitForRetrace.html">VIWaitForRetrace</A>();<BR> <BR> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; // swap buffers<BR> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if (count ^= 1)&nbsp;&nbsp;&nbsp; nextbuffer = bufB;<BR> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; else &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;nextbuffer = bufA;<BR> &nbsp;&nbsp;&nbsp; }<BR> }</CODE></DD></DL>
25
26<H2>Definitions</H2>
27<P>NTSC - Video standard used in North America and Japan.</P>
28<P>PAL - Video standard used in Europe.</P>
29<P>EURGB60Hz - RGB 60Hz, 480 line mode (same timing and aspect ratio as NTSC) used in Europe.</P>
30<P>Double-Strike (Ds) - Display two fields at the same location on the TV. This is as opposed to interlaced displays, in which one field represents even lines and the other field represents odd lines.&nbsp;The advantage of this mode is that it is easy to drop fields.&nbsp;The disadvantage is that it is half the resolution vertically of interlaced displays.</P>
31<P>Interlaced (Int) - Display one field as even lines on the TV and display the next field as odd lines on the TV.</P>
32<P>Progressive (Prog) - Display all lines of a frame in one pass.</P>
33<P>De-Flicker (Df) - A method of filtering the flicker artifacts that occur when displaying objects that appear in one field but not the next of an interlaced display.&nbsp;Deflickering uses information from both fields and applies a (vertical) filter to this information to create each displayed line.</P>
34<P>Anti-alias (Aa) - Anti-aliasing on Wii uses a subsampling method. Three samples are computed for each pixel and stored in the EFB.&nbsp;A filter is applied to these samples during the copy from the EFB to the XFB.&nbsp;When anti-aliasing, each pixel occupies 2 times the memory in the EFB versus not anti-aliasing.&nbsp;For the largest frame sizes (640 x 480 or 640 x 528), there is not enough memory to render an entire anti-aliased image, so the application must render the image in two passes.&nbsp;Typically the application would first render the top half of the frame and copy it out, then render the bottom half and copy it out to the XFB.</P>
35
36<H2><A name="Render Mode Structures">Render Mode Structures</A></H2>
37<P>Note that any Render Mode structures that are not referenced by the application code will be dead-stripped from the object file by the linker.</P>
38
39<H3>GXNtsc240Ds</H3>
40<P>This render mode can be considered a 'non-interlaced low-res' render mode since both fields are drawn at the same location on the display (double-strike).</P>
41
42<H3>GXNtsc240DsAa</H3>
43<P>This render mode combines double-strike frame rendering with antialiasing.</P>
44
45<H3><A name="GXNtsc240Int">GXNtsc240Int</A></H3>
46<P>This render mode requires the application to maintain a 60Hz field update rate. This is an interlaced render mode, so effectively it appears to the viewer to be 480 lines (although it blinks at very high speed). However, the application only needs to fill 240 lines (per frame). If the application cannot maintain the 60Hz rate, it will need to make provisions for dropping fields, which can be visually strange.</P>
47
48<H3><A name="GXNtsc240IntAa">GXNtsc240IntAa</A></H3>
49<P>This mode enables anti-aliasing so each pixel will be the average of three subpixels. However, anti-aliasing incurs a fill rate penalty (1/2 of the maximum fill rate).&nbsp;But if the application uses an average of two textures/pixel, the fill rate is still close to 1/2 of the maximum (so use some multi-texture in this mode).&nbsp;This mode must also maintain a 60Hz field update rate or be prepared to drop fields.</P>
50
51<H3><A name="GXNtsc480IntDf">GXNtsc480IntDf</A></H3>
52<P>This mode renders 480 lines in order to produce two deflickered fields (240 lines each).&nbsp;The frame rate is 60Hz or less. Each field will be deflickered, meaning some of the information from the odd lines will be present in the even lines and vice versa.&nbsp;This makes for a more <EM>flicker-free</EM> display.&nbsp;If one renders at 60Hz, it may appear that there is a fill-rate penalty since one rendered field is thrown away during each cycle. However, that field had to be computed in order to perform proper deflickering.&nbsp;Also, the <EM>extra</EM> field is available as a backup in case the update rate drops below 60Hz, preventing some of the unpleasant anomalies that occur when a field is dropped in field-rendering mode.</P>
53
54<H3>GXNtsc480Int</H3>
55<P>This render mode is the standard 'frame' rendering mode.&nbsp;This mode produces both even and odd lines at the same time -- a frame.&nbsp;Usually the update rate for this mode is 30Hz.</P>
56
57<H3>GXNtsc480IntAa</H3>
58<P>This render mode requires more memory than the EFB has available, so the application must do two passes, each pass rendering half the lines. Since this mode also produces both fields, the update rate is normally 30Hz.&nbsp;Deflicker is available in this mode as well.&nbsp;Note that proper deflicker filtering requires overlapping each half slightly.</P>
59
60<H3>GXNtsc480Prog</H3>
61<P>This mode renders 480 lines and display all the lines at 60Hz. The frame rate is 60Hz or less. The vertical filter is effectively turned off in this mode; that may produce a &quot;sharper&quot; image.</P>
62
63<H3>GXNtsc480ProgSoft</H3>
64<P>This mode renders 480 lines and display all the lines at 60Hz. The frame rate is 60Hz or less. The vertical filter is turned on in this mode to produce a softer or more blurred image than <CODE>GXNtsc480Prog</CODE>.</P>
65
66<H3>GXNtsc480ProgAa</H3>
67<P>This mode renders 480 lines and display all the lines at 60Hz. The frame rate is 60 Hz or less. As with <CODE>GXNtsc480IntAa</CODE>, rendering a full frame in this mode requires doing two (overlapped) rendering passes. The vertical filter is enabled in order to do proper antialiasing.</P>
68
69<H3>GXPal264Ds</H3>
70<H3>GXPal264DsAa</H3>
71<H3>GXPal264Int</H3>
72<H3>GXPal264IntAa</H3>
73<H3><A name="GXPal528IntDf">GXPal528IntDf</A></H3>
74<H3>GXPal528Int</H3>
75<H3>GXPal524IntAa</H3>
76<P>These modes are similar to the NTSC modes; only the video format differs.</P>
77<P>Note that PAL interlaced anti-aliased mode is only 524 lines tall.&nbsp;Rendering an anti-aliased frame requires rendering two half-height sub-images.&nbsp;However, proper filtering requires overlapping the two sub-images. Due to various hardware restrictions, 4 lines are duplicated.&nbsp;Since the anti-aliased EFB is only 264 lines tall, a maximum size of 524 lines results from these requirements.</P>
78
79<H3>GXEurgb60Hz240Ds</H3>
80<H3>GXEurgb60Hz240DsAa</H3>
81<H3>GXEurgb60Hz240Int</H3>
82<H3>GXEurgb60Hz240IntAa</H3>
83<H3><A name="GXEurgb60Hz480IntDf">GXEurgb60Hz480IntDf</A></H3>
84<H3>GXEurgb60Hz480Int</H3>
85<H3>GXEurgb60Hz480IntAa</H3>
86<H3>GXEurgb60Hz480Prog</H3>
87<H3>GXEurgb60Hz480ProgSoft</H3>
88<H3>GXEurgb60Hz480ProgAa</H3>
89<P>These modes are similar to the NTSC modes; only the video format differs.</P>
90
91<H2>Arguments</H2>
92<P>None.</P>
93
94<H2>Return Values</H2>
95<P>None.</P>
96
97<H2>See Also</H2>
98<P>None.</P>
99
100<H2>Revision History</H2>
101<P>
1022008/06/19 Removed mention of MPAL.<br>2006/06/16 Added progressive scan mode for PAL, EURGB60, and MPAL.<br>2006/03/01 Initial version.<br>
103</P>
104
105<hr><p>CONFIDENTIAL</p></body>
106</HTML>