On Tuesday, 2019-02-05 15:31:08 +0000, Emil Velikov wrote:
> From: Emil Velikov <emil.veli...@collabora.com>
> 
> VGEM and kms_swrast were introduced to work with one another.
> 
> All we do is CPU rendering to dumb buffers. There is no reason to carve
> out GPU memory, increasing the memory pressure on a device that could
> make a better use of it.
> 
> For kms_swrast to work properly we require the primary node, as the dumb
> buffer ioctls are not exposed via the render node.
> 
> Note that this requires libdrm commit 3df8a7f0 ("xf86drm: fallback to
> MODALIAS for OF less platform devices")

Without this, what happens? swrast stops working?

A couple style comments below, but this question is my main concern.

> 
> Signed-off-by: Emil Velikov <emil.veli...@collabora.com>
> ---
>  src/egl/drivers/dri2/platform_surfaceless.c | 20 ++++++++++++++------
>  1 file changed, 14 insertions(+), 6 deletions(-)
> 
> diff --git a/src/egl/drivers/dri2/platform_surfaceless.c 
> b/src/egl/drivers/dri2/platform_surfaceless.c
> index e1151e3585c..54c6856c63c 100644
> --- a/src/egl/drivers/dri2/platform_surfaceless.c
> +++ b/src/egl/drivers/dri2/platform_surfaceless.c
> @@ -286,10 +286,11 @@ surfaceless_probe_device(_EGLDisplay *dpy, bool swrast)
>     for (i = 0; i < num_devices; ++i) {
>        device = devices[i];
>  
> -      if (!(device->available_nodes & (1 << DRM_NODE_RENDER)))
> +      const unsigned node_type = swrast ? DRM_NODE_PRIMARY : DRM_NODE_RENDER;
> +      if (!(device->available_nodes & (1 << node_type)))
>           continue;
>  
> -      dri2_dpy->fd = loader_open_device(device->nodes[DRM_NODE_RENDER]);
> +      dri2_dpy->fd = loader_open_device(device->nodes[node_type]);
>        if (dri2_dpy->fd < 0)
>           continue;
>  
> @@ -300,10 +301,17 @@ surfaceless_probe_device(_EGLDisplay *dpy, bool swrast)
>           continue;
>        }
>  
> -      if (swrast)
> -         dri2_dpy->driver_name = strdup("kms_swrast");
> -      else
> -         dri2_dpy->driver_name = loader_get_driver_for_fd(dri2_dpy->fd);
> +      dri2_dpy->driver_name = loader_get_driver_for_fd(dri2_dpy->fd);

Can you keep the else branch like before? Makes it more readable IMO,
and avoids allocating memory just to free it a couple lines below.

> +      if (swrast) {
> +         /* Use kms swrast only with vgem */
> +         if (strcmp(dri2_dpy->driver_name, "vgem") != 0) {
> +            free(dri2_dpy->driver_name);
> +            dri2_dpy->driver_name = NULL;
> +         } else {
> +            free(dri2_dpy->driver_name);
> +            dri2_dpy->driver_name = strdup("kms_swrast");

Again, IMO this would be more readable as "if vgem use kms_swrast"
instead of "if not vgem skip else use kms_swrast".

The above two comments combined give us this code instead:

  if swrast
    if driver == vgem
      driver = kms_swrast
  else
    driver = get_driver(fd)

> +         }
> +      }
>  
>        if (dri2_dpy->driver_name && dri2_load_driver_dri3(dpy))
>           break;
> -- 
> 2.20.1
> 
> _______________________________________________
> mesa-dev mailing list
> mesa-dev@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/mesa-dev
_______________________________________________
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev

Reply via email to