[Mesa-dev] [PATCH] gallium: add Tegra renderonly support

Emil Velikov emil.l.velikov at gmail.com
Fri Jan 13 15:42:07 UTC 2017


Hi Alexandre,

On 13 January 2017 at 07:47, Alexandre Courbot <acourbot at nvidia.com> wrote:

> @@ -2559,6 +2559,10 @@ if test -n "$with_gallium_drivers"; then
>              require_libdrm "virgl"
>              require_basic_egl "virgl"
>              ;;
> +        xtegra)
> +            HAVE_GALLIUM_TEGRA=yes
> +            require_libdrm "tegra"
> +            ;;
You'll need a similar inter-dependency as imx. Namely: either require
nouveau gallium driver, or implicitly enable it (add new
NEED_GALLIUM_NOUVEAU and update all the tracking). Former is one-line,
whist latter might be better in the long run but rather picky to get
right.

> --- a/src/gallium/auxiliary/target-helpers/drm_helper.h
> +++ b/src/gallium/auxiliary/target-helpers/drm_helper.h
> @@ -312,5 +312,27 @@ pipe_imx_drm_create_screen(int fd)
>
>  #endif
>
> +#ifdef GALLIUM_TEGRA
> +#include "tegra/drm/tegra_drm_public.h"
> +
> +struct pipe_screen *
> +pipe_tegra_create_screen(int fd)
> +{
> +   struct pipe_screen *screen;
> +
> +   screen = tegra_drm_screen_create(fd);
> +   return screen ? debug_screen_wrap(screen) : NULL;
> +}
> +
> +#else
> +
> +struct pipe_screen *
> +pipe_tegra_create_screen(int fd)
> +{
> +   fprintf(stderr, "tegra: driver missing\n");
> +   return NULL;
> +}
> +
> +#endif
>
Out of curiosity: have you tried adding a macro which lets us minimise
all this boilerplate ?
Similar question for the one in dri/targets.c. Neither of these
questions is a requirement for merging tegra.

> --- /dev/null
> +++ b/src/gallium/drivers/tegra/Makefile.am
> @@ -0,0 +1,9 @@
> +include $(top_srcdir)/src/gallium/Automake.inc
> +
> +AM_CPPFLAGS = \
> +       $(GALLIUM_CFLAGS) \
> +       $(TEGRA_CFLAGS)
This seems like a leftover from when libdrm_tegra was used.


> --- /dev/null
> +++ b/src/gallium/winsys/tegra/drm/tegra_drm_winsys.c

> +#include "tegra_drm_public.h"
> +#include "nouveau/drm/nouveau_drm_public.h"
> +#include "renderonly/renderonly.h"
> +
> +#include <libdrm/tegra_drm.h>
Drop the "libdrm/" part.


> +struct pipe_screen *tegra_drm_screen_create(int fd)
> +{
> +   struct renderonly ro = {
> +      .create_for_resource = tegra_create_with_tiling_for_resource,
> +      .kms_fd = fd,
> +      .gpu_fd = drmOpenWithType("nouveau", NULL, DRM_NODE_RENDER),
All the drmOpen() API carries a lot of UMS legacy and nasty 'hacks'.
Do not use it, please ?
Please use the drmDevice API to query all devices and pick one based
on $heuristics. We might want to add "driver" to the retrieved
information [to make things a bit easier], but that has it's own set
of problems.

> +   };
> +
> +   if (ro.gpu_fd < 0)
> +      return NULL;
> +
> +   struct pipe_screen *screen = nouveau_drm_screen_create_renderonly(ro.gpu_fd, &ro);
> +   if (!screen)
> +      drmClose(ro.gpu_fd);
Thus this will become close().

Thanks
Emil


More information about the mesa-dev mailing list