diff options
author | Dave Airlie <[email protected]> | 2012-01-06 12:23:00 +0000 |
---|---|---|
committer | Dave Airlie <[email protected]> | 2012-01-11 08:20:11 +0000 |
commit | 1865f341d8f45b389061fc08d2da90b7aa8a6099 (patch) | |
tree | dbe427bbb19465398d3c62f4f0d9b58e30728c3e /src/gallium/auxiliary/draw/draw_cliptest_tmp.h | |
parent | f7e3e46f72fffe4b83cd3f922173ff28e9ab9c7c (diff) |
draw: clipdistance support (v2)
Add support for using the clipdistance instead of clip plane.
Passes all piglit clipdistance tests.
v2: fixup some comments from Brian in review.
Signed-off-by: Dave Airlie <[email protected]>
Diffstat (limited to 'src/gallium/auxiliary/draw/draw_cliptest_tmp.h')
-rw-r--r-- | src/gallium/auxiliary/draw/draw_cliptest_tmp.h | 30 |
1 files changed, 27 insertions, 3 deletions
diff --git a/src/gallium/auxiliary/draw/draw_cliptest_tmp.h b/src/gallium/auxiliary/draw/draw_cliptest_tmp.h index 7dba49b2870..bff266b8f98 100644 --- a/src/gallium/auxiliary/draw/draw_cliptest_tmp.h +++ b/src/gallium/auxiliary/draw/draw_cliptest_tmp.h @@ -36,12 +36,19 @@ static boolean TAG(do_cliptest)( struct pt_post_vs *pvs, /* const */ float (*plane)[4] = pvs->draw->plane; const unsigned pos = draw_current_shader_position_output(pvs->draw); const unsigned cv = draw_current_shader_clipvertex_output(pvs->draw); + unsigned cd[2]; const unsigned ef = pvs->draw->vs.edgeflag_output; const unsigned ucp_enable = pvs->draw->rasterizer->clip_plane_enable; const unsigned flags = (FLAGS); unsigned need_pipeline = 0; unsigned j; unsigned i; + bool have_cd = false; + cd[0] = draw_current_shader_clipdistance_output(pvs->draw, 0); + cd[1] = draw_current_shader_clipdistance_output(pvs->draw, 1); + + if (cd[0] != pos || cd[1] != pos) + have_cd = true; for (j = 0; j < info->count; j++) { float *position = out->data[pos]; @@ -89,14 +96,31 @@ static boolean TAG(do_cliptest)( struct pt_post_vs *pvs, if (flags & DO_CLIP_USER) { unsigned ucp_mask = ucp_enable; - + int num_written_clipdistance = pvs->draw->vs.vertex_shader->info.num_written_clipdistance; while (ucp_mask) { unsigned plane_idx = ffs(ucp_mask)-1; ucp_mask &= ~(1 << plane_idx); plane_idx += 6; - if (dot4(clipvertex, plane[plane_idx]) < 0) { - mask |= 1 << plane_idx; + /* + * for user clipping check if we have a clip distance output + * and the shader has written to it, otherwise use clipvertex + * to decide when the plane is clipping. + */ + if (have_cd && num_written_clipdistance) { + float clipdist; + i = plane_idx - 6; + out->have_clipdist = 1; + /* first four clip distance in first vector etc. */ + if (i < 4) + clipdist = out->data[cd[0]][i]; + else + clipdist = out->data[cd[1]][i-4]; + if (clipdist < 0) + mask |= 1 << plane_idx; + } else { + if (dot4(clipvertex, plane[plane_idx]) < 0) + mask |= 1 << plane_idx; } } } |