[Mesa-dev] [PATCH v2] swr: implement clipPlanes/clipVertex/clipDistance

Ilia Mirkin imirkin at alum.mit.edu
Thu May 26 00:40:50 UTC 2016


On Wed, May 25, 2016 at 8:32 PM, Tim Rowley <timothy.o.rowley at intel.com> wrote:
> v2: only load the clip vertex once
> ---
>  src/gallium/drivers/swr/swr_context.h  |  2 ++
>  src/gallium/drivers/swr/swr_shader.cpp | 65 ++++++++++++++++++++++++++++++++++
>  src/gallium/drivers/swr/swr_shader.h   |  4 +++
>  src/gallium/drivers/swr/swr_state.cpp  | 22 +++++++++++-
>  4 files changed, 92 insertions(+), 1 deletion(-)
>
> diff --git a/src/gallium/drivers/swr/swr_state.cpp b/src/gallium/drivers/swr/swr_state.cpp
> index f9326f3..f8d10ac 100644
> --- a/src/gallium/drivers/swr/swr_state.cpp
> +++ b/src/gallium/drivers/swr/swr_state.cpp
> @@ -849,7 +849,9 @@ swr_update_derived(struct pipe_context *pipe,
>     }
>
>     /* Raster state */
> -   if (ctx->dirty & (SWR_NEW_RASTERIZER | SWR_NEW_FRAMEBUFFER)) {
> +   if (ctx->dirty & (SWR_NEW_RASTERIZER |
> +                     SWR_NEW_VS | // clipping
> +                     SWR_NEW_FRAMEBUFFER)) {
>        pipe_rasterizer_state *rasterizer = ctx->rasterizer;
>        pipe_framebuffer_state *fb = &ctx->framebuffer;
>
> @@ -906,6 +908,11 @@ swr_update_derived(struct pipe_context *pipe,
>
>        rastState->depthClipEnable = rasterizer->depth_clip;
>
> +      rastState->clipDistanceMask =
> +         ctx->vs->info.base.num_written_clipdistance ?
> +         ctx->vs->info.base.clipdist_writemask | rasterizer->clip_plane_enable :

Don't consider this to be a full review, but I think this should be &
rather than |. In addition to actually writing the clip distance, you
also have to glEnable(GL_CLIP_PLANE0..7) in order for that clip
distance to apply.

> +         rasterizer->clip_plane_enable;
> +
>        SwrSetRastState(ctx->swrContext, rastState);
>     }
>

Separately, you make some mentions of culling... if you actually
implemented cull distances, make sure to enable the
PIPE_CAP_CULL_DISTANCE cap.

Cheers,

  -ilia


More information about the mesa-dev mailing list