gallium: convert rasterizer state to use gl-style front/back concepts
Use front/back instead of cw/ccw throughout. Also, use offset_point/line/fill instead of offset_cw/ccw. Brings gallium representation of this state into line with its main user, and also what turns out to be the most common hardware representation. This fixes a long-standing bias in the interface towards the architecture of the software rasterizer.
This commit is contained in:
@@ -36,16 +36,17 @@
|
||||
/* Hardware frontwinding is always set up as SVGA3D_FRONTWINDING_CW.
|
||||
*/
|
||||
static SVGA3dFace svga_translate_cullmode( unsigned mode,
|
||||
unsigned front_winding )
|
||||
unsigned front_ccw )
|
||||
{
|
||||
const int hw_front_ccw = 0; /* hardware is always CW */
|
||||
switch (mode) {
|
||||
case PIPE_WINDING_NONE:
|
||||
case PIPE_FACE_NONE:
|
||||
return SVGA3D_FACE_NONE;
|
||||
case PIPE_WINDING_CCW:
|
||||
return SVGA3D_FACE_BACK;
|
||||
case PIPE_WINDING_CW:
|
||||
return SVGA3D_FACE_FRONT;
|
||||
case PIPE_WINDING_BOTH:
|
||||
case PIPE_FACE_FRONT:
|
||||
return front_ccw == hw_front_ccw ? SVGA3D_FACE_FRONT : SVGA3D_FACE_BACK;
|
||||
case PIPE_FACE_BACK:
|
||||
return front_ccw == hw_front_ccw ? SVGA3D_FACE_BACK : SVGA3D_FACE_FRONT;
|
||||
case PIPE_FACE_FRONT_AND_BACK:
|
||||
return SVGA3D_FACE_FRONT_BACK;
|
||||
default:
|
||||
assert(0);
|
||||
@@ -82,7 +83,7 @@ svga_create_rasterizer_state(struct pipe_context *pipe,
|
||||
|
||||
rast->shademode = svga_translate_flatshade( templ->flatshade );
|
||||
rast->cullmode = svga_translate_cullmode( templ->cull_mode,
|
||||
templ->front_winding );
|
||||
templ->front_ccw );
|
||||
rast->scissortestenable = templ->scissor;
|
||||
rast->multisampleantialias = templ->multisample;
|
||||
rast->antialiasedlineenable = templ->line_smooth;
|
||||
@@ -124,24 +125,24 @@ svga_create_rasterizer_state(struct pipe_context *pipe,
|
||||
int fill_ccw = templ->fill_ccw;
|
||||
int fill = PIPE_POLYGON_MODE_FILL;
|
||||
|
||||
switch (templ->cull_mode) {
|
||||
case PIPE_WINDING_BOTH:
|
||||
switch (templ->cull_face) {
|
||||
case PIPE_FACE_FRONT_AND_BACK:
|
||||
offset = 0;
|
||||
fill = PIPE_POLYGON_MODE_FILL;
|
||||
break;
|
||||
|
||||
case PIPE_WINDING_CW:
|
||||
offset = offset_ccw;
|
||||
fill = fill_ccw;
|
||||
case PIPE_FACE_FRONT:
|
||||
offset = offset_front;
|
||||
fill = fill_front;
|
||||
break;
|
||||
|
||||
case PIPE_WINDING_CCW:
|
||||
offset = offset_cw;
|
||||
fill = fill_cw;
|
||||
case PIPE_FACE_BACK:
|
||||
offset = offset_back;
|
||||
fill = fill_back;
|
||||
break;
|
||||
|
||||
case PIPE_WINDING_NONE:
|
||||
if (fill_cw != fill_ccw || offset_cw != offset_ccw)
|
||||
case PIPE_FACE_NONE:
|
||||
if (fill_front != fill_back || offset_front != offset_back)
|
||||
{
|
||||
/* Always need the draw module to work out different
|
||||
* front/back fill modes:
|
||||
@@ -149,8 +150,8 @@ svga_create_rasterizer_state(struct pipe_context *pipe,
|
||||
rast->need_pipeline |= SVGA_PIPELINE_FLAG_TRIS;
|
||||
}
|
||||
else {
|
||||
offset = offset_ccw;
|
||||
fill = fill_ccw;
|
||||
offset = offset_front;
|
||||
fill = fill_front;
|
||||
}
|
||||
break;
|
||||
|
||||
@@ -167,7 +168,7 @@ svga_create_rasterizer_state(struct pipe_context *pipe,
|
||||
(templ->flatshade ||
|
||||
templ->light_twoside ||
|
||||
offset ||
|
||||
templ->cull_mode != PIPE_WINDING_NONE))
|
||||
templ->cull_face != PIPE_FACE_NONE))
|
||||
{
|
||||
fill = PIPE_POLYGON_MODE_FILL;
|
||||
rast->need_pipeline |= SVGA_PIPELINE_FLAG_TRIS;
|
||||
|
Reference in New Issue
Block a user