[Mesa-dev] [PATCH] virgl: use primconvert provoking vertex properly

Gert Wollny gert.wollny at collabora.com
Thu Jan 3 13:28:13 UTC 2019


Tested it, looks fine, 
Reviewed-By: Gert Wollny <gert.wollny at gmail.com>

Am Freitag, den 28.12.2018, 16:54 +1000 schrieb Dave Airlie:
> From: Dave Airlie <airlied at redhat.com>
> 
> This stores the raster state and calls the correct primconvert
> interface
> using the currently bound raster state.
> 
> This fixes piglit glsl-fs-flat-color
> ---
>  src/gallium/drivers/virgl/virgl_context.c | 26 ++++++++++++++++-----
> --
>  src/gallium/drivers/virgl/virgl_context.h |  6 ++++++
>  2 files changed, 24 insertions(+), 8 deletions(-)
> 
> diff --git a/src/gallium/drivers/virgl/virgl_context.c
> b/src/gallium/drivers/virgl/virgl_context.c
> index f095920489f..6ed4e2f8394 100644
> --- a/src/gallium/drivers/virgl/virgl_context.c
> +++ b/src/gallium/drivers/virgl/virgl_context.c
> @@ -322,19 +322,27 @@ static void
> *virgl_create_rasterizer_state(struct pipe_context *ctx,
>                                                     const struct
> pipe_rasterizer_state *rs_state)
>  {
>     struct virgl_context *vctx = virgl_context(ctx);
> -   uint32_t handle;
> -   handle = virgl_object_assign_handle();
> +   struct virgl_rasterizer_state *vrs =
> CALLOC_STRUCT(virgl_rasterizer_state);
>  
> -   virgl_encode_rasterizer_state(vctx, handle, rs_state);
> -   return (void *)(unsigned long)handle;
> +   if (!vrs)
> +      return NULL;
> +   vrs->rs = *rs_state;
> +   vrs->handle = virgl_object_assign_handle();
> +
> +   virgl_encode_rasterizer_state(vctx, vrs->handle, rs_state);
> +   return (void *)vrs;
>  }
>  
>  static void virgl_bind_rasterizer_state(struct pipe_context *ctx,
>                                                  void *rs_state)
>  {
>     struct virgl_context *vctx = virgl_context(ctx);
> -   uint32_t handle = (unsigned long)rs_state;
> -
> +   uint32_t handle = 0;
> +   if (rs_state) {
> +      struct virgl_rasterizer_state *vrs = rs_state;
> +      vctx->rs_state = *vrs;
> +      handle = vrs->handle;
> +   }
>     virgl_encode_bind_object(vctx, handle, VIRGL_OBJECT_RASTERIZER);
>  }
>  
> @@ -342,8 +350,9 @@ static void virgl_delete_rasterizer_state(struct
> pipe_context *ctx,
>                                           void *rs_state)
>  {
>     struct virgl_context *vctx = virgl_context(ctx);
> -   uint32_t handle = (unsigned long)rs_state;
> -   virgl_encode_delete_object(vctx, handle,
> VIRGL_OBJECT_RASTERIZER);
> +   struct virgl_rasterizer_state *vrs = rs_state;
> +   virgl_encode_delete_object(vctx, vrs->handle,
> VIRGL_OBJECT_RASTERIZER);
> +   FREE(vrs);
>  }
>  
>  static void virgl_set_framebuffer_state(struct pipe_context *ctx,
> @@ -695,6 +704,7 @@ static void virgl_draw_vbo(struct pipe_context
> *ctx,
>        return;
>  
>     if (!(rs->caps.caps.v1.prim_mask & (1 << dinfo->mode))) {
> +      util_primconvert_save_rasterizer_state(vctx->primconvert,
> &vctx->rs_state.rs);
>        util_primconvert_draw_vbo(vctx->primconvert, dinfo);
>        return;
>     }
> diff --git a/src/gallium/drivers/virgl/virgl_context.h
> b/src/gallium/drivers/virgl/virgl_context.h
> index 0f51d730985..79a1a73e615 100644
> --- a/src/gallium/drivers/virgl/virgl_context.h
> +++ b/src/gallium/drivers/virgl/virgl_context.h
> @@ -49,6 +49,11 @@ struct virgl_textures_info {
>     uint32_t enabled_mask;
>  };
>  
> +struct virgl_rasterizer_state {
> +   struct pipe_rasterizer_state rs;
> +   uint32_t handle;
> +};
> +
>  struct virgl_context {
>     struct pipe_context base;
>     struct virgl_cmd_buf *cbuf;
> @@ -66,6 +71,7 @@ struct virgl_context {
>     unsigned num_vertex_buffers;
>     boolean vertex_array_dirty;
>  
> +   struct virgl_rasterizer_state rs_state;
>     struct virgl_so_target so_targets[PIPE_MAX_SO_BUFFERS];
>     unsigned num_so_targets;
>  


More information about the mesa-dev mailing list