[Mesa-dev] [PATCH] draw: don't cull tris with zero aera

Brian Paul brianp at vmware.com
Thu Oct 26 19:44:56 UTC 2017


In subject and comments: s/aera/area/

I'm not sure about DX line rasterization, but IIRC for GL, if a line's 
endpoints are identical, nothing should be drawn.

I can see how this is relevant for point mode though.

Reviewed-by: Brian Paul <brianp at vmware.com>


On 10/26/2017 01:24 PM, sroland at vmware.com wrote:
> From: Roland Scheidegger <sroland at vmware.com>
>
> Culling tris with zero aera seems like a great idea, but apparently with
> fill mode line (and point) we're supposed to draw them, at least some tests
> for some other state tracker complained otherwise.
> Such tris also always seem to be back facing (not sure if this can be
> inferred from anything, since in a mathematical sense it cannot really be
> determined), so make sure to account for this when filling in the face
> information.
> (For solid tris, this is of course unnecessary, drivers will throw the tris
> away later in any case.)
> ---
>   src/gallium/auxiliary/draw/draw_pipe_cull.c     | 10 ++++++++++
>   src/gallium/auxiliary/draw/draw_pipe_unfilled.c |  5 ++---
>   2 files changed, 12 insertions(+), 3 deletions(-)
>
> diff --git a/src/gallium/auxiliary/draw/draw_pipe_cull.c b/src/gallium/auxiliary/draw/draw_pipe_cull.c
> index 3e8e458..3863485 100644
> --- a/src/gallium/auxiliary/draw/draw_pipe_cull.c
> +++ b/src/gallium/auxiliary/draw/draw_pipe_cull.c
> @@ -181,6 +181,16 @@ static void cull_tri( struct draw_stage *stage,
>               /* triangle is not culled, pass to next stage */
>               stage->next->tri( stage->next, header );
>            }
> +      } else {
> +         /*
> +          * With zero aera, this is back facing (because the spec says
> +          * it's front facing if sign is positive?).
> +          * Some apis apparently do not allow us to cull zero aera tris
> +          * here, in case of fill mode line (which is rather lame).
> +          */
> +         if ((PIPE_FACE_BACK & cull_stage(stage)->cull_face) == 0) {
> +            stage->next->tri( stage->next, header );
> +         }
>         }
>      }
>   }
> diff --git a/src/gallium/auxiliary/draw/draw_pipe_unfilled.c b/src/gallium/auxiliary/draw/draw_pipe_unfilled.c
> index c465c75..f39db0e 100644
> --- a/src/gallium/auxiliary/draw/draw_pipe_unfilled.c
> +++ b/src/gallium/auxiliary/draw/draw_pipe_unfilled.c
> @@ -63,10 +63,9 @@ inject_front_face_info(struct draw_stage *stage,
>                          struct prim_header *header)
>   {
>      struct unfilled_stage *unfilled = unfilled_stage(stage);
> -   unsigned ccw = header->det < 0.0;
>      boolean is_front_face = (
> -      (stage->draw->rasterizer->front_ccw && ccw) ||
> -      (!stage->draw->rasterizer->front_ccw && !ccw));
> +      (stage->draw->rasterizer->front_ccw && header->det < 0.0f) ||
> +      (!stage->draw->rasterizer->front_ccw && header->det > 0.0f));
>      int slot = unfilled->face_slot;
>      unsigned i;
>
>



More information about the mesa-dev mailing list