In XNA, what is the difference between a Viewport and a Scissor Rectangle, and when should I use each one?

It looks like viewport clipping is applied to the geometry before the rasterization state, which should make it "faster", while the scissor test is applied afterwards during the pixel stage.

I primarily work with 2D graphics, and from what I can tell, they both seem to function the exact same way with no appreciable difference otherwise, save that the scissor test is more annoying to set up, because you have to create a new RasterizerState object to enable it.


1 Answer 1


Viewports and Clipping (Direct3D 9) is a good overview that, while specific to D3D9, is relevant to all APIs.

The viewport defines an additional transformation that occurs before rasterization:

Direct3D uses the viewport location and dimensions to scale the vertices to fit a rendered scene into the appropriate location on the target surface. Internally, Direct3D inserts these values into the following matrix that is applied to each vertex. (...matrix description follows...) This matrix scales vertices according to the viewport dimensions and desired depth range and translates them to the appropriate location on the render-target surface.

Scissor Test on the other hand operates within a viewport, occurs after the pixel shader stage, and gives you the ability to constrain per-pixel operations to a rectangular portion of the screen, but without actually modifying the current viewport transform.

  • \$\begingroup\$ Perfect! I knew they were related, but wasn't quite sure how. \$\endgroup\$
    – Kyle Baran
    May 13, 2015 at 21:06
  • 2
    \$\begingroup\$ @KyleBaran - they're not related (it's also perfectly valid for hardware to not support scissor test at all); they're even at completely different stages of the graphics pipeline. \$\endgroup\$ May 13, 2015 at 21:31

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .