OSDN Git Service

gallium: implement clamping controls (ARB_color_buffer_float)
[android-x86/external-mesa.git] / src / gallium / docs / source / cso / rasterizer.rst
1 .. _rasterizer:
2
3 Rasterizer
4 ==========
5
6 The rasterizer state controls the rendering of points, lines and triangles.
7 Attributes include polygon culling state, line width, line stipple,
8 multisample state, scissoring and flat/smooth shading.
9
10 Linkage
11
12 clamp_vertex_color
13 ^^^^^^^^^^^^^^^^^^
14
15 If set, TGSI_SEMANTIC_COLOR registers are clamped to the [0, 1] range after
16 the execution of the vertex shader, before being passed to the geometry
17 shader or fragment shader.
18
19 OpenGL: glClampColor(GL_CLAMP_VERTEX_COLOR) in GL 3.0 or GL_ARB_color_buffer_float
20
21 D3D11: seems always disabled
22
23 clamp_fragment_color
24 ^^^^^^^^^^^^^^^^^^^^
25
26 Controls whether TGSI_SEMANTIC_COLOR outputs of the fragment shader
27 are clamped to [0, 1].
28
29 OpenGL: glClampColor(GL_CLAMP_FRAGMENT_COLOR) in GL 3.0 or ARB_color_buffer_float
30
31 D3D11: seems always disabled
32
33
34 Shading
35 -------
36
37 flatshade
38 ^^^^^^^^^
39
40 If set, the provoking vertex of each polygon is used to determine the color
41 of the entire polygon.  If not set, fragment colors will be interpolated
42 between the vertex colors.
43
44 The actual interpolated shading algorithm is obviously
45 implementation-dependent, but will usually be Gourard for most hardware.
46
47 .. note::
48
49     This is separate from the fragment shader input attributes
50     CONSTANT, LINEAR and PERSPECTIVE. The flatshade state is needed at
51     clipping time to determine how to set the color of new vertices.
52
53     :ref:`Draw` can implement flat shading by copying the provoking vertex
54     color to all the other vertices in the primitive.
55
56 flatshade_first
57 ^^^^^^^^^^^^^^^
58
59 Whether the first vertex should be the provoking vertex, for most primitives.
60 If not set, the last vertex is the provoking vertex.
61
62 There are several important exceptions to the specification of this rule.
63
64 * ``PIPE_PRIMITIVE_POLYGON``: The provoking vertex is always the first
65   vertex. If the caller wishes to change the provoking vertex, they merely
66   need to rotate the vertices themselves.
67 * ``PIPE_PRIMITIVE_QUAD``, ``PIPE_PRIMITIVE_QUAD_STRIP``: This option has no
68   effect; the provoking vertex is always the last vertex.
69 * ``PIPE_PRIMITIVE_TRIANGLE_FAN``: When set, the provoking vertex is the
70   second vertex, not the first. This permits each segment of the fan to have
71   a different color.
72
73 Polygons
74 --------
75
76 light_twoside
77 ^^^^^^^^^^^^^
78
79 If set, there are per-vertex back-facing colors.  The hardware
80 (perhaps assisted by :ref:`Draw`) should be set up to use this state
81 along with the front/back information to set the final vertex colors
82 prior to rasterization.
83
84 The frontface vertex shader color output is marked with TGSI semantic
85 COLOR[0], and backface COLOR[1].
86
87 front_ccw
88     Indicates whether the window order of front-facing polygons is
89     counter-clockwise (TRUE) or clockwise (FALSE).
90
91 cull_mode
92     Indicates which faces of polygons to cull, either PIPE_FACE_NONE
93     (cull no polygons), PIPE_FACE_FRONT (cull front-facing polygons),
94     PIPE_FACE_BACK (cull back-facing polygons), or
95     PIPE_FACE_FRONT_AND_BACK (cull all polygons).
96
97 fill_front
98     Indicates how to fill front-facing polygons, either
99     PIPE_POLYGON_MODE_FILL, PIPE_POLYGON_MODE_LINE or
100     PIPE_POLYGON_MODE_POINT.
101 fill_back
102     Indicates how to fill back-facing polygons, either
103     PIPE_POLYGON_MODE_FILL, PIPE_POLYGON_MODE_LINE or
104     PIPE_POLYGON_MODE_POINT.
105
106 poly_stipple_enable
107     Whether polygon stippling is enabled.
108 poly_smooth
109     Controls OpenGL-style polygon smoothing/antialiasing
110
111 offset_point
112     If set, point-filled polygons will have polygon offset factors applied
113 offset_line
114     If set, line-filled polygons will have polygon offset factors applied
115 offset_tri
116     If set, filled polygons will have polygon offset factors applied
117
118 offset_units
119     Specifies the polygon offset bias
120 offset_scale
121     Specifies the polygon offset scale
122
123
124
125 Lines
126 -----
127
128 line_width
129     The width of lines.
130 line_smooth
131     Whether lines should be smoothed. Line smoothing is simply anti-aliasing.
132 line_stipple_enable
133     Whether line stippling is enabled.
134 line_stipple_pattern
135     16-bit bitfield of on/off flags, used to pattern the line stipple.
136 line_stipple_factor
137     When drawing a stippled line, each bit in the stipple pattern is
138     repeated N times, where N = line_stipple_factor + 1.
139 line_last_pixel
140     Controls whether the last pixel in a line is drawn or not.  OpenGL
141     omits the last pixel to avoid double-drawing pixels at the ends of lines
142     when drawing connected lines.
143
144
145 Points
146 ------
147
148 sprite_coord_enable
149 ^^^^^^^^^^^^^^^^^^^
150
151 Controls automatic texture coordinate generation for rendering sprite points.
152
153 When bit k in the sprite_coord_enable bitfield is set, then generic
154 input k to the fragment shader will get an automatically computed
155 texture coordinate.
156
157 The texture coordinate will be of the form (s, t, 0, 1) where s varies
158 from 0 to 1 from left to right while t varies from 0 to 1 according to
159 the state of 'sprite_coord_mode' (see below).
160
161 If any bit is set, then point_smooth MUST be disabled (there are no
162 round sprites) and point_quad_rasterization MUST be true (sprites are
163 always rasterized as quads).  Any mismatch between these states should
164 be considered a bug in the state-tracker.
165
166 This feature is implemented in the :ref:`Draw` module but may also be
167 implemented natively by GPUs or implemented with a geometry shader.
168
169
170 sprite_coord_mode
171 ^^^^^^^^^^^^^^^^^
172
173 Specifies how the value for each shader output should be computed when drawing
174 point sprites. For PIPE_SPRITE_COORD_LOWER_LEFT, the lower-left vertex will
175 have coordinates (0,0,0,1). For PIPE_SPRITE_COORD_UPPER_LEFT, the upper-left
176 vertex will have coordinates (0,0,0,1).
177 This state is used by :ref:`Draw` to generate texcoords.
178
179
180 point_quad_rasterization
181 ^^^^^^^^^^^^^^^^^^^^^^^^
182
183 Determines if points should be rasterized according to quad or point
184 rasterization rules.
185
186 OpenGL actually has quite different rasterization rules for points and
187 point sprites - hence this indicates if points should be rasterized as
188 points or according to point sprite (which decomposes them into quads,
189 basically) rules.
190
191 Additionally Direct3D will always use quad rasterization rules for
192 points, regardless of whether point sprites are enabled or not.
193
194 If this state is enabled, point smoothing and antialiasing are
195 disabled. If it is disabled, point sprite coordinates are not
196 generated.
197
198 .. note::
199
200    Some renderers always internally translate points into quads; this state
201    still affects those renderers by overriding other rasterization state.
202
203 point_smooth
204     Whether points should be smoothed. Point smoothing turns rectangular
205     points into circles or ovals.
206 point_size_per_vertex
207     Whether the vertex shader is expected to have a point size output.
208     Undefined behaviour is permitted if there is disagreement between
209     this flag and the actual bound shader.
210 point_size
211     The size of points, if not specified per-vertex.
212
213
214
215 Other Members
216 -------------
217
218 scissor
219     Whether the scissor test is enabled.
220
221 multisample
222     Whether :term:`MSAA` is enabled.
223
224 gl_rasterization_rules
225     Whether the rasterizer should use (0.5, 0.5) pixel centers. When not set,
226     the rasterizer will use (0, 0) for pixel centers.
227