summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBrian Paul <brianp@vmware.com>2013-02-21 08:18:02 -0700
committerIan Romanick <ian.d.romanick@intel.com>2013-03-05 14:57:09 -0800
commit2ac679bc87377c439d5144fc6c59d503aa79d2ae (patch)
tree0dea19b6800ee88d055c476e48f51e0a2b0fb2ff
parentf64664de7f3126339b1c201b0f5da51dc16d2797 (diff)
draw: fix broken polygon offset stage
There were several issues. We weren't handling different front/back polygon fill modes. We weren't checking whether the offset applied to fill mode vs. line mode vs. point mode. Fixes problems found with the Visualization Toolkit (VTK) test suite. Note: This is a candidate for the stable branches. Reviewed-by: Jose Fonseca <jfonseca@vmware.com> (cherry picked from commit d6b8b116eec3c24ef9f2d292315f70ea8cbaa040)
-rw-r--r--src/gallium/auxiliary/draw/draw_pipe_offset.c40
1 files changed, 37 insertions, 3 deletions
diff --git a/src/gallium/auxiliary/draw/draw_pipe_offset.c b/src/gallium/auxiliary/draw/draw_pipe_offset.c
index 3da52b10624..3578525051f 100644
--- a/src/gallium/auxiliary/draw/draw_pipe_offset.c
+++ b/src/gallium/auxiliary/draw/draw_pipe_offset.c
@@ -127,10 +127,44 @@ static void offset_first_tri( struct draw_stage *stage,
struct prim_header *header )
{
struct offset_stage *offset = offset_stage(stage);
+ const struct pipe_rasterizer_state *rast = stage->draw->rasterizer;
+ unsigned fill_mode = rast->fill_front;
+ boolean do_offset;
+
+ if (rast->fill_back != rast->fill_front) {
+ /* Need to check for back-facing triangle */
+ boolean ccw = header->det < 0.0f;
+ if (ccw != rast->front_ccw)
+ fill_mode = rast->fill_back;
+ }
+
+ /* Now determine if we need to do offsetting for the point/line/fill mode */
+ switch (fill_mode) {
+ case PIPE_POLYGON_MODE_FILL:
+ do_offset = rast->offset_tri;
+ break;
+ case PIPE_POLYGON_MODE_LINE:
+ do_offset = rast->offset_line;
+ break;
+ case PIPE_POLYGON_MODE_POINT:
+ do_offset = rast->offset_point;
+ break;
+ default:
+ assert(!"invalid fill_mode in offset_first_tri()");
+ do_offset = rast->offset_tri;
+ }
+
+ if (do_offset) {
+ offset->scale = rast->offset_scale;
+ offset->clamp = rast->offset_clamp;
+ offset->units = (float) (rast->offset_units * stage->draw->mrd);
+ }
+ else {
+ offset->scale = 0.0f;
+ offset->clamp = 0.0f;
+ offset->units = 0.0f;
+ }
- offset->units = (float) (stage->draw->rasterizer->offset_units * stage->draw->mrd);
- offset->scale = stage->draw->rasterizer->offset_scale;
- offset->clamp = stage->draw->rasterizer->offset_clamp;
stage->tri = offset_tri;
stage->tri( stage, header );