Chapter 2. Framebuffer Resources

As noted in the overview, MPK allows you to describe the framebuffer resources ( pipes, windows, and channels), the physical display area (walls), and the rendering options. This chapter describes how you configure the framebuffer resources and contains the following sections:

The MPK Configuration Hierarchy

The MPK configuration file uses a tree data structure to describe the physical graphics resources. The root of the data structure is the whole visualization facility and the leaves are the physical rendering layouts. Figure 2-1 shows the configuration of an application running on a two-pipe platform, two windows handling the GLX context, and four channels.

Figure 2-1. MPK Configuration Hierarchy

MPK Configuration Hierarchy

Example 2-1 shows a skeletal configuration file that describes Figure 2-1.

Example 2-1. Skeletal Configuration File

config {
    pipe {
        window {
            viewport [ parameters1 ]
            channel {
                viewport [ parameters2 ]
                  .
                  .
                  .
            }
            channel {
                viewport [ parameters3 ]
                  .
                  .
                  .
             }
        }
    }
    pipe {
        window {
            viewport [ parameters4 ]
            channel {
                viewport [ parameters5 ]
                  .
                  .
                  .
            }
            channel {
                viewport [ parameters6 ]
                  .
                  .
                  .
             }
        }
    }
}

Reading this configuration file, MPK determines the following:

  • What physical pipes it must allocate

  • What parallel tasks it must create

  • How to synchronize the rendering tasks

  • The final rendering framebuffer area

The following sections describe the function of the framebuffer data structures and Chapter 6, “Configuration File Format” describes their syntax for the configuration file.

The config Data Structure

The configuration level of the hierarchy, denoted in the configuration file by the config data structure, primarily describes the rendering resources of an MPK application as a hierarchy of the following:

  • Hardware rendering pipelines (pipes)

  • GLX software rendering threads (windows)

  • OpenGL framebuffer rendering areas (channels)

It may also describe compounds, various parallelization schemes of the rendering across channels in order to scale performances. Chapter 4, “Compounds” describes the use of compounds in MPK.

As shown in Figure 2-1, pipes are children of the root configuration, windows are children of pipes, and channels are children of windows. As such, you can take advantage of the attendant inheritance. For instance, you can specify the screen dimensions at the pipe level and they will be inherited by the child windows and child channels. This inheritance is made possible because MPK uses no absolute pixel dimensions but fractional viewport descriptions for its window and channels.

The pipe Data Structure

A pipe data structure describes the rendering resources within a configuration that are assigned to a given hardware rendering pipe. You must have one pipe entry for every pipe you want to use in your configuration. The pipe itself is characterized by the name of its corresponding X11 display as well as the expected mono and stereo mechanisms (full-screen, quad-buffer, and the like) to be applied by its rendering threads (windows).

Example 2-2 shows a minimal pipe specification that is superior to that of the windows and channels.

Example 2-2. Sample Pipe Specification

pipe {
    display     “:0.0”
    window {
        .
        .
        .
        channel {
            .
            .
            .
        }
    }
}

You can specify the display sizes corresponding to the various stereo modes using global attributes or pipe attributes; otherwise, MPK uses the values returned by the X11 DisplayWidth() and DisplayHeight() functions. Chapter 6, “Configuration File Format” describes the pipe and global attributes.

The window Data Structure

A window data structure corresponds to a single GLX unit (that is, a single X window with its associated OpenGL visual and context). Essential in the MPK programming model is that each window spawns its own rendering thread.

In the configuration file, the window specification is subordinate to the pipe specification. Example 2-3 shows a minimal specification. Other optional specifications include the processor where the rendering thread is to run and an extensive set of window attributes. Chapter 6, “Configuration File Format” describes the complete set of fields and their syntax.

Example 2-3. Sample Window Specification

window {
    viewport    [ 0., 0., 1., 1. ]
    channel {
        .
        .
        .
    }
}


The channel Data Structure

A channel, denoted by a channel data structure in the configuration file, is essentially a view onto a scene and corresponds to a single viewport inside its parent window. In addition to the viewport description, a channel also contains the modeling coordinates for the projection rectangle in the real world. Chapter 3, “Frustum Descriptions” describes how you describe these coordinates.


Note: MPK allows applications to run in mirrored projection systems, which usually use mirrors to invert the projected image up and down (with respect to left and right) . To do this, you must specify a negative value for the height or width of the corresponding channel's viewport.

Example 2-4 shows a sample channel specification.

Example 2-4. Sample Channel Specification

channel {
    viewport        [ 0., 0., 1., 1. ]
    projection {
        origin      [ 0., 0., 0. ]
        distance    3.
        fov         [ 54., 47. ]
        hpr         [ 0., 0., 0. ]
    }
}

Chapter 6, “Configuration File Format” describes the complete set of fields and their syntax.

Stereo Description

When running an MPK application in stereo mode, you can specify two elements from the configuration file:

  • Stereo type

    This indicates how the framebuffer resources are configured for each eye pass. The stereo type is defined as a pipe attribute either in the global attributes section or per pipe in the pipe data structure. Chapter 6, “Configuration File Format” contains a detailed list of all attributes and describes how to specify global attributes.

  • Stereo command

    This command will be executed by MPK when switching to mono or stereo rendering. The command is specified for mono and stereo in the config data structure.


    Note: If you want to run in quad-buffered stereo mode, your windows must allocate stereo-capable visuals. This can be specified using the stereo window attribute hint.


The following is an example of stereo specifications in the config data structure:

mono "/usr/gfx/setmon -n 60HZ"
stereo "/usr/gfx/setmon -n 1024x768_96s"

Controlling the stereo specifications at the configuration or pipe levels requires you to kill windows and restart them. However, you can switch stereo on and off without killing them if all windows on all quad-stereo pipes have a quad-buffer-capable GLX visual and you use the window hint attribute, as shown in the following:

attributes {
    hints {
        stereo 1
    }
}

See Chapter 6, “Configuration File Format” for a complete description of the options and their syntax.