Render Modes

C Specification

#include <revolution/gx.h>

Description

To enable the render mode variables for the GX API, initialize the GXRenderModeObj structure set. Active render modes are as indicated on the lower half of this page. The application can provide the default values for display-related functions and, if preferred, disable them.

In GXInit, render mode is set to the appropriate GXNtsc480IntDf, GXMpal480IntDf or GXPal528IntDf.

Code Example

The following is just a basic example.  It is not necessarily the optimal way of managing your frame loop.

main()
{
    // Set up rendering display mode to NTSC 240
    // lines per field interlaced.
    // Antialised rendering.
    GXRenderModeObj*     rmode = &GXNtsc240IntAa;
    u16*                 bufA, bufB, nextbuffer;
    u32                  count;
    u8*                  fifo;
    f32                  yScale;
    u32                  n_xfb_lines;

    fifo = OSAlloc(FIFO_SIZE);
    GXInit(fifo, FIFO_SIZE);
    VIInit();

    // Set up video
    VIConfigure(rmode);

    // Set other GX state   
    GXSetScissor(  0, 0, rmode->fbWidth, rmode->efbHeight );

    GXSetDispCopySrc(0, 0, rmode->fbWidth, rmode->efbHeight);

    // call yscale after setting display copy source
    n_xfb_lines =  // account for yscale in xfb height
    GXSetDispCopyYScale((f32)(rmode->xfbHeight /
                        (f32)(rmode->efbHeight));

    GXSetDispCopyDst(rmode->fbWidth, n_xfb_lines);
    GXSetCopyFilter(rmode->aa, rmode->sample_pattern,
                    GX_TRUE, rmode->vfilter);
   
    if (rmode->aa)
        GXSetPixelFmt(GX_PF_RGB565_Z16, GX_ZC_LINEAR);
    else
        GXSetPixelFmt(GX_PF_RGB8_Z24, GX_ZC_LINEAR);

    GXSetFieldMode(rmode->field_rendering, rmode->xfbHeight < rmode->viHeight);
    // Allocate the main memory for the framebuffer
    bufA = OSAlloc( VIPadFramebufferWidth(rmode->fbWidth) * n_xfb_lines * VI_DISPLAY_PIX_SZ);
    bufB = OSAlloc( VIPadFramebufferWidth(rmode->fbWidth) * n_xfb_lines * VI_DISPLAY_PIX_SZ);

    // main rendering loop
    nextbuffer = bufA;
    count = 0;

    while (1) {
        // jitter frustum for field rendering
        if (rmode->field_rendering)
            GXSetViewportJitter(
                        0.0f, 0.0f,
                        (f32)(rmode->fbWidth),
                        (f32)(rmode->efbHeight),
                         0.0f, 1.0f,
                        VIGetNextField());
        else
            GXSetViewport(
                       0.0f, 0.0f,
                       (f32)(rmode->fbWidth),
                       (f32)(rmode->efbHeight),
                       0.0f, 1.0f );

        // do some rendering
        doRendering();

        // copy framebuffer from EFB (on chip) to XFB (main memory)
        // and clear the color and z buffer
        GXCopyDisp(nextbuffer, GX_TRUE);
        GXDrawDone();

        // tell VI that a new buffer is done and its type
        VISetNextFrameBuffer(nextbuffer);
        VIFlush();
        VIWaitForRetrace();

        // swap buffers
        if (count ^= 1)    nextbuffer = bufB;
        else               nextbuffer = bufA;
    }
}

Definitions

Ntsc - Video standard used in North America and Japan.

Mpal - Video standard, similar to Ntsc, used in Brazil.

Pal - Video standard used in Europe.

Eurgb60Hz - RGB 60Hz, 480 line mode (same timing and aspect ratio as NTSC) used in Europe.

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. The advantage of this mode is that it is easy to drop fields. The disadvantage is that it is half the resolution vertically of interlaced displays.

Interlaced (Int) - Display one field as even lines on the TV and display the next field as odd lines on the TV.

Progressive (Prog) - Display all lines of a frame in one path.

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. Deflickering uses information from both fields and applies a (vertical) filter to this information to create each displayed line.

Antialias (Aa) - Antialiasing on Revolution uses a subsampling method. Three samples are computed for each pixel and stored in the EFB. A filter is applied to these samples during the copy from the EFB to the XFB. When antialiasing, each pixel occupies 2 times the memory in the EFB versus not antialiasing. For the largest frame sizes (640 x 480 or 640 x 528), there is not enough memory to render an entire antialiased image, so the application must render the image in two passes. 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.

Render Mode Structures

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.

GXNtsc240Ds

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).

GXNtsc240DsAa

This render mode combines double-strike frame rendering with antialiasing.

GXNtsc240Int

This render mode requires the application to maintain a 60Hz field update rate.   This is an interlaced render mode, so effectively the viewer sees 480 lines (unless they blink really fast) but the application only needs to fill 240 lines (a field). If the application cannot maintain the 60Hz rate, it will need to make provisions for dropping fields, which can be visually unpleasant.

GXNtsc240IntAa

This mode enables antialiasing so each pixel will be the average of three subpixels. However, antialiasing incurs a fill rate penalty (1/2 of the maximum). 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). This mode must also maintain a 60Hz field update rate or be prepared to drop fields.

GXNtsc480IntDf

This mode renders 480 lines in order to produce two deflickered fields (240 lines each). The frame rate can be 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. This makes for a more 'flicker-free' display. 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. Also, the 'extra' field is available as a backup in case the update rate drops below 60Hz, preventing some of the unpleasant anamolies that occur when a field is dropped in field-rendering mode.

GXNtsc480Int

This render mode is the standard 'frame' rendering mode. This mode produces both even and odd lines at the same time -- a frame. Usually the update rate for this mode is 30Hz.

GXNtsc480IntAa

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. Deflicker is available in this mode as well. Note that proper deflicker filtering requires overlapping each half slightly.

GXNtsc480Prog

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 "sharper" image.

GXNtsc480ProgSoft

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 " blurry" image than GXNtsc480Prog.

GXNtsc480ProgAa

This mode renders 480 lines and display all the lines at 60Hz. The frame rate is 60Hz or less. As with GXNtsc480IntAa, rendering a full frame in this mode requires doing two (overlapped) rendering passes. The vertical filter is enabled in order to do proper antialiasing.

GXMpal240Ds

GXMpal240DsAa

GXMpal240Int

GXMpal240IntAa

GXMpal480IntDf

GXMpal480Int

GXMpal480IntAa

GXMpal480Prog

GXMpal480ProgSoft

GXMpal480ProgAa

These modes are similar to the NTSC modes; only the video format differs.

GXPal264Ds

GXPal264DsAa

GXPal264Int

GXPal264IntAa

GXPal528IntDf

GXPal528Int

GXPal524IntAa

These modes are similar to the NTSC modes; only the video format differs.

Note that PAL interlaced anti-aliased mode is only 524 lines tall. Rendering an anti-aliased frame requires rendering two half-height sub-images. However, proper filtering requires overlapping the two sub-images. Due to various hardware restrictions, 4 lines are duplicated. Since the anti-aliased EFB is only 264 lines tall, a maximum size of 524 lines results from these requirements.

GXEurgb60Hz240Ds

GXEurgb60Hz240DsAa

GXEurgb60Hz240Int

GXEurgb60Hz240IntAa

GXEurgb60Hz480IntDf

GXEurgb60Hz480Int

GXEurgb60Hz480IntAa

GXEurgb60Hz480Prog

GXEurgb60Hz480ProgSoft

GXEurgb60Hz480ProgAa

These modes are similar to the NTSC modes; only the video format differs.

Arguments

None.

Return Values

None.

See Also

Revision History

2006/6/16 Added progressive scan mode for PAL, EURGB60, and MPAL
2006/03/01 Initial version.

CONFIDENTIAL