X-Git-Url: https://git.libre-soc.org/?a=blobdiff_plain;f=src%2Fgallium%2Fdrivers%2Fsvga%2Fsvga_pipe_rasterizer.c;h=356898a86e7ef2bb484539def9f611897c20e34c;hb=413bc0a618d39873336cbfaf8fb5e43217f66ccf;hp=660eb0757a6778bfc0c2fdf434a30d20da2039ab;hpb=3293bcdc80cdfa20a2381aae2b94505bdf95d857;p=mesa.git diff --git a/src/gallium/drivers/svga/svga_pipe_rasterizer.c b/src/gallium/drivers/svga/svga_pipe_rasterizer.c index 660eb0757a6..356898a86e7 100644 --- a/src/gallium/drivers/svga/svga_pipe_rasterizer.c +++ b/src/gallium/drivers/svga/svga_pipe_rasterizer.c @@ -30,6 +30,7 @@ #include "util/u_memory.h" #include "svga_context.h" +#include "svga_screen.h" #include "svga_hw_reg.h" @@ -64,20 +65,22 @@ static void * svga_create_rasterizer_state(struct pipe_context *pipe, const struct pipe_rasterizer_state *templ) { + struct svga_context *svga = svga_context(pipe); struct svga_rasterizer_state *rast = CALLOC_STRUCT( svga_rasterizer_state ); + struct svga_screen *screen = svga_screen(pipe->screen); + /* need this for draw module. */ rast->templ = *templ; - /* light_twoside - XXX: need fragment shader varient */ + /* light_twoside - XXX: need fragment shader variant */ /* poly_smooth - XXX: no fallback available */ /* poly_stipple_enable - draw module */ /* sprite_coord_enable - ? */ /* point_quad_rasterization - ? */ /* point_size_per_vertex - ? */ /* sprite_coord_mode - ??? */ - /* bypass_vs_viewport_and_clip - handled by viewport setup */ /* flatshade_first - handled by index translation */ - /* gl_rasterization_rules - XXX - viewport code */ + /* half_pixel_center - XXX - viewport code */ /* line_width - draw module */ /* fill_cw, fill_ccw - draw module or index translation */ @@ -88,34 +91,60 @@ svga_create_rasterizer_state(struct pipe_context *pipe, rast->multisampleantialias = templ->multisample; rast->antialiasedlineenable = templ->line_smooth; rast->lastpixel = templ->line_last_pixel; + rast->pointsprite = templ->sprite_coord_enable != 0x0; rast->pointsize = templ->point_size; rast->hw_unfilled = PIPE_POLYGON_MODE_FILL; /* Use swtnl + decomposition implement these: */ - if (templ->poly_stipple_enable) + if (templ->poly_stipple_enable) { rast->need_pipeline |= SVGA_PIPELINE_FLAG_TRIS; + rast->need_pipeline_tris_str = "poly stipple"; + } - if (templ->line_width != 1.0 && - templ->line_width != 0.0) + if (screen->maxLineWidth > 1.0F) { + /* pass line width to device */ + rast->linewidth = MAX2(1.0F, templ->line_width); + } + else if (svga->debug.no_line_width) { + /* nothing */ + } + else { + /* use 'draw' pipeline for wide line */ rast->need_pipeline |= SVGA_PIPELINE_FLAG_LINES; + rast->need_pipeline_lines_str = "line width"; + } if (templ->line_stipple_enable) { - /* LinePattern not implemented on all backends. - */ - if (0) { + if (screen->haveLineStipple || svga->debug.force_hw_line_stipple) { SVGA3dLinePattern lp; lp.repeat = templ->line_stipple_factor + 1; lp.pattern = templ->line_stipple_pattern; rast->linepattern = lp.uintValue; } else { + /* use 'draw' module to decompose into short line segments */ rast->need_pipeline |= SVGA_PIPELINE_FLAG_LINES; + rast->need_pipeline_lines_str = "line stipple"; } } - if (templ->point_smooth) + if (templ->point_smooth) { rast->need_pipeline |= SVGA_PIPELINE_FLAG_POINTS; + rast->need_pipeline_points_str = "smooth points"; + } + + if (templ->line_smooth && !screen->haveLineSmooth) { + /* + * XXX: Enabling the pipeline slows down performance immensely, so ignore + * line smooth state, where there is very little visual improvement. + * Smooth lines will still be drawn for wide lines. + */ +#if 0 + rast->need_pipeline |= SVGA_PIPELINE_FLAG_LINES; + rast->need_pipeline_lines_str = "smooth lines"; +#endif + } { int fill_front = templ->fill_front; @@ -123,11 +152,11 @@ svga_create_rasterizer_state(struct pipe_context *pipe, int fill = PIPE_POLYGON_MODE_FILL; boolean offset_front = util_get_offset(templ, fill_front); boolean offset_back = util_get_offset(templ, fill_back); - boolean offset = 0; + boolean offset = FALSE; switch (templ->cull_face) { case PIPE_FACE_FRONT_AND_BACK: - offset = 0; + offset = FALSE; fill = PIPE_POLYGON_MODE_FILL; break; @@ -148,6 +177,7 @@ svga_create_rasterizer_state(struct pipe_context *pipe, * front/back fill modes: */ rast->need_pipeline |= SVGA_PIPELINE_FLAG_TRIS; + rast->need_pipeline_tris_str = "different front/back fillmodes"; } else { offset = offset_front; @@ -172,6 +202,7 @@ svga_create_rasterizer_state(struct pipe_context *pipe, { fill = PIPE_POLYGON_MODE_FILL; rast->need_pipeline |= SVGA_PIPELINE_FLAG_TRIS; + rast->need_pipeline_tris_str = "unfilled primitives with no index manipulation"; } /* If we are decomposing to lines, and lines need the pipeline, @@ -182,6 +213,7 @@ svga_create_rasterizer_state(struct pipe_context *pipe, { fill = PIPE_POLYGON_MODE_FILL; rast->need_pipeline |= SVGA_PIPELINE_FLAG_TRIS; + rast->need_pipeline_tris_str = "decomposing lines"; } /* Similarly for points: @@ -191,6 +223,7 @@ svga_create_rasterizer_state(struct pipe_context *pipe, { fill = PIPE_POLYGON_MODE_FILL; rast->need_pipeline |= SVGA_PIPELINE_FLAG_TRIS; + rast->need_pipeline_tris_str = "decomposing points"; } if (offset) { @@ -201,9 +234,6 @@ svga_create_rasterizer_state(struct pipe_context *pipe, rast->hw_unfilled = fill; } - - - if (rast->need_pipeline & SVGA_PIPELINE_FLAG_TRIS) { /* Turn off stuff which will get done in the draw module: */ @@ -212,6 +242,13 @@ svga_create_rasterizer_state(struct pipe_context *pipe, rast->depthbias = 0; } + if (0 && rast->need_pipeline) { + debug_printf("svga: rast need_pipeline = 0x%x\n", rast->need_pipeline); + debug_printf(" pnts: %s \n", rast->need_pipeline_points_str); + debug_printf(" lins: %s \n", rast->need_pipeline_lines_str); + debug_printf(" tris: %s \n", rast->need_pipeline_tris_str); + } + return rast; } @@ -221,11 +258,11 @@ static void svga_bind_rasterizer_state( struct pipe_context *pipe, struct svga_context *svga = svga_context(pipe); struct svga_rasterizer_state *raster = (struct svga_rasterizer_state *)state; - svga->curr.rast = raster; draw_set_rasterizer_state(svga->swtnl.draw, raster ? &raster->templ : NULL, state); - + svga->curr.rast = raster; + svga->dirty |= SVGA_NEW_RAST; }