Graphics Reference
In-Depth Information
As seen in Listing 3.22, the viewport structure defines a region that the normalized
device coordinates will be mapped to in order to convert from the unit-sized coordinates
of the unit cube to the pixel based coordinate system of a render target. As an example, if
the entire render target should be covered by the viewport, the top and left values will be 0
and the width and height parameters will be the width and height of the render target being
used. The MinDepth and MaxDepth parameters are used to scale the range of depth values
being used to a subset of the complete regular range.
The application can either provide a single viewport, or it can specify multiple viewports
simultaneously. If multiple viewports have been set, the viewport that is used for a particu-
lar primitive rasterization is determined by the value of the SV_ViewportArrayIndex sys-
tem value semantic. Binding of viewports is performed with the ID3DllDeviceContext::
RSSetViewports method. Unlike the state arrays that we have discussed previously, any
viewports that are not set in the most recent set call will be cleared. In addition, there is the
usual Get counterpart method for retrieving the currently set array of viewports.
Scissor Rectangle State
The final configuration available in the rasterizer stage is the ability to specify an array
of scissor rectangles. These rectangles are used during the scissor test to specify a par-
ticular region of the render target for which fragments can be generated. This effectively
eliminates any fragments that would have been generated for a region outside of the cur-
rent scissor rectangle, which can reduce unnecessary computation. If multiple scissor rect-
angles are bound, the rectangle used for a given primitive is determined by the same SV_
ViewportArraylndex. This ensures that the viewport and scissor rectangle that are used
together are a matching pair. The array of scissor rectangles is also managed in the same
way as the array of viewports. It can be bound using the ID3DllDeviceContext: :RSSet
ScissorRects() method, making only the scissor rectangles that were specified in the
most recent set call remain active.
3.10.3 Rasterizer Stage Processing
All of the processes performed in the rasterizer stage are vital components for efficiently
converting geometric data into image-based data suitable for storage in a render target.
This section explores in greater detail what each of these processes encompasses, and at-
tempts to provide some insight into how they can be used in common real-time rendering
contexts. Figure 3.52 shows a block diagram of the functional operations performed within
the rasterizer stage. These processes may be implemented in a different order in the actual
GPU hardware, but we will conceptually consider them in the shown sequence.
Search WWH ::




Custom Search