MSAA Rendering Sample

This topic contains the following sections.

  • Goal
  • Description
  • User Scenarios
    • Scenarios that can benefit from MSAA
    • Scenarios that can benefit from PPAA
  • Details
  • Requirements
  • Additional Requirements
  • Downloading the Sample
  • Installation Instructions
    • Configuring without Visual Studio
    • Configuring Visual Studio 2008
  • Building the Sample
    • Building the Sample Using the Command Prompt
    • Building the Sample Using Visual Studio 2008 (Preferred Method)

Goal

Compare the Multi-Sample Anti-Aliasing (MSAA) and Per-Primitive Anti-Aliasing (PPAA) techniques in different scenarios and demonstrate which technique is suited for what scenario.

Description

MSAA: D3D uses MSAA which applies antialiasing to the whole scene to be rendered.

PPAA: D2D uses PPAA which applies antialiasing logic to each rendered primitive instead of against the whole scene.

A developer can either use PPAA offered by D2D or can render the 2D graphics in aliased mode and use D3D's MSAA to perform antialiasing. Both of the techniques offer some advantages and disadvantages.

This sample compares the two antialiasing techniques in different scenarios and shows which technique is suited for what scenario.

This sample produces the output shown in the following screen shot.

Screen shot of D2D Demo App and examples of the MSAA and PPAA techniques

User Scenarios

No one rendering technique is ideal in every case. A user must carefully evaluate what mode is best suited for the scenario being targeted. This sample shows the benefits of using one antialiasing rendering mode over the other.

Scenarios that can benefit from MSAA

  • When you have abutting primitives, MSAA is usually the way to go. PPAA can lead to some rendering artifacts around the edges of the primitives.
  • When a scene has many primitives, MSAA usually scales better than PPAA.

Scenarios that can benefit from PPAA

  • Other than the cases when there are abutting primitives, PPAA usually has a better rendering quality. You can see this by zooming over the edges of the sample and then changing the antialiasing mode. Also, if you change the mode to wireframe and increase the number of primitives, PPAA rendering will have somewhat less-noticeable artifacts than MSAA rendering.

Details

This sample can be run with multiple settings to change rendering modes, scene complexity, and the kind of scene that is rendered. The following table summarizes the various options to choose from:

Control Behavior
Left/Right Arrow Changes the rendering mode to either aliased, multisample antialiasing, or per-primitive antialiasing.
Up/Down Arrow Changes the scene complexity by increasing or decreasing the number of primitives rendered.
Spacebar Pauses or resumes the scene animation.
Mouse Wheel Zooms in and out.
'A' key Switches between antialiasing modes.
'W' key Switches between solid and wireframe modes.
'L' key Turns off the zoom window.

 

Requirements

Minimum supported client Windows 7 or Windows Vista with Service Pack 2 (SP2) and Platform Update for Windows Vista
Minimum supported server Windows Server 2008 R2 or Windows Server 2008 with Service Pack 2 (SP2) and Platform Update for Windows Server 2008
Windows SDK Windows Software Development Kit (SDK) for Windows 7

 

Additional Requirements

Microsoft DirectX SDK (March 2009 or later versions)

Downloading the Sample

This sample is available in the following locations.

Location Path/URL
Windows SDK \Program Files\Microsoft SDKs\Windows\v7.0\Samples\Multimedia\Direct2D\MSAARenderingSample
Code Gallery Download from MSDN Code Gallery

 

Installation Instructions

After you install the DirectX SDK, you must configure your system to use the executables and include files that the DirectX SDK provides.

Configuring without Visual Studio

  1. Open a Windows SDK command shell.
  2. Type <drive>:\Program Files\Microsoft DirectX SDK <version>\Utilities\bin\dx_setenv.cmd. (For 64-bit versions of Windows, type <drive>:\Program Files (x86)\Microsoft DirectX SDK <version>\Utilities\bin\dx_setenv.cmd.) <drive> is the drive to which the DirectX SDK was installed and <version> is the version that you downloaded. For example, the C:\Program Files\Microsoft DirectX SDK (March 2009)\Utilities\bin\dx_setenv.cmd comment uses drive C and the March 2009 version. You must complete this step every time that you compile the sample.
  3. To compile the sample, type vcbuild /u MSAARenderingSample.sln.

Configuring Visual Studio 2008

You must configure Visual Studio for each platform (Win32 or x64) you want to build against.

For Building Against the Win32 Platform

  1. Start Visual Studio 2008.
  2. Open the Tools menu and select Options…. The Options dialog box appears.
  3. In the left pane of the Options dialog box, expand the Projects and Solutions node.
  4. Under Projects and Solutions, select VC++ Directories.
  5. In the right pane, set the Platform list to "Win32" and the Show directories for list to "Executable files".
  6. At the bottom of the list of executable file directories, create a new entry for the DirectX SDK:
    • For computers that are running 32-bit versions of Windows, add the following path: <drive>:\Program Files\Microsoft DirectX SDK <version>\Utilities\bin\x86. (If there was already such an entry, move it to the bottom of the list.)
    • For computers that are running 64-bit versions of Windows, add the following path: <drive>:\Program Files (x86)\Microsoft DirectX SDK <version>\Utilities\bin\x86. (If there was already such an entry, move it to the bottom of the list.)
  7. Set the Show directories for list to "Include" files.
  8. At the bottom of the list of directories, create a new entry for the DirectX SDK:
    • For computers that are running 32-bit versions of Windows, add the following path: <drive>:\Program Files\Microsoft DirectX SDK <version>\Include. (If there was already such an entry, move it to the bottom of the list.)
    • For computers that are running 64-bit versions of Windows, add the following path: <drive>:\Program Files (x86)\Microsoft DirectX SDK <version>\Include. (If there was already such an entry, move it to the bottom of the list.)
  9. Set the Show directories for list to "Library" files.
  10. At the bottom of the list of directories, create a new entry for the DirectX SDK:
    • For computers that are running 32-bit versions of Windows, add the following path: <drive>:\Program Files\Microsoft DirectX SDK <version>\Lib\x86. (If there was already such an entry, move it to the bottom of the list.)
    • For computers that are running 64-bit versions of Windows, add the following path: <drive>:\Program Files (x86)\Microsoft DirectX SDK <version>\Lib\x86. (If there was already such an entry, move it to the bottom of the list.)
  11. Click OK.

For Building Against the x64 Platform

  1. Start Visual Studio 2008.
  2. Open the Tools menu and select Options…. The Options dialog box appears.
  3. In the left pane of the Options dialog box, expand the Projects and Solutions node.
  4. Under Projects and Solutions, select "VC++ Directories".
  5. In the right pane, set the Platform list to "x64" and the Show directories for list to "Executable" files.
  6. At the bottom of the list of executable file directories, create a new entry for the DirectX SDK:
    • For computers that are running 32-bit versions of Windows, add the following path: <drive>:\Program Files\Microsoft DirectX SDK <version>\Utilities\bin\x86. (If there was already such an entry, move it to the bottom of the list.)
    • For computers that are running 64-bit versions of Windows, add the following path: <drive>:\Program Files (x86)\Microsoft DirectX SDK <version>\Utilities\bin\x64. (If there was already such an entry, move it to the bottom of the list.)
  7. Set the Show directories for list to "Include" files.
  8. At the bottom of the list of directories, create a new entry for the DirectX SDK:
    • For computers that are running 32-bit versions of Windows, add the following path: <drive>:\Program Files\Microsoft DirectX SDK <version>\Include. (If there was already such an entry, move it to the bottom of the list.)
    • For computers that are running 64-bit versions of Windows, add the following path: <drive>:\Program Files (x86)\Microsoft DirectX SDK <version>\Include. (If there was already such an entry, move it to the bottom of the list.)
  9. Set the Show directories for list to "Library" files.
  10. At the bottom of the list of directories, create a new entry for the DirectX SDK:
    • For computers that are running 32-bit versions of Windows, add the following path: <drive>:\Program Files\Microsoft DirectX SDK <version>\Lib\x64. (If there was already such an entry, move it to the bottom of the list.)
    • For computers that are running 64-bit versions of Windows, add the following path: <drive>:\Program Files (x86)\Microsoft DirectX SDK <version>\Lib\x64. (If there was already such an entry, move it to the bottom of the list.)
  11. Click OK.

Building the Sample

Building the Sample Using the Command Prompt

  1. Open the Command Prompt window and run the dx_setenv.cmd (see the Configuring without Visual Studio section for more information.)
  2. Browse to the sample directory.
  3. Type vcbuild /u MSAARenderingSample.sln.

Building the Sample Using Visual Studio 2008 (Preferred Method)

  1. Open Windows Explorer and browse to the sample directory.
  2. Double-click the icon for the .sln (solution) file to open the file in Visual Studio.
  3. In the Build menu, select Build Solution. The application will be built in the default \Debug or \Release directory.

 

 

Send comments about this topic to Microsoft

Build date: 1/22/2012