From f7ef1a83b19246e7b868f5ce3196928657a05a9f Mon Sep 17 00:00:00 2001 From: Dominik Sliwa Date: Tue, 5 Dec 2017 14:09:23 +0000 Subject: mesa: tk1 mainline: forward port patches to 17.1.7 Signed-off-by: Dominik Sliwa Acked-by: Marcel Ziswiler --- .../mesa/mesa/0001-gallium-add-tegra-support.patch | 570 +++++++++++++++++++++ .../mesa/mesa/0002-make-DRI-work-under-X.patch | 24 + .../0003-loader-Automatic-PRIME-detection.patch | 106 ++++ .../mesa/mesa/0004-gallium-add-tegra-support.patch | 516 ------------------- .../mesa/0004-mesa-17.1.7-compilation-fixes.patch | 26 + ...05-tegra-open-card1-instead-of-renderD128.patch | 29 -- .../mesa/0006-HACK-make-DRI-work-under-X.patch | 24 - .../0008-remove-dependency-on-libdrm_tegra.patch | 51 -- recipes-graphics/mesa/mesa_%.bbappend | 8 +- 9 files changed, 730 insertions(+), 624 deletions(-) create mode 100644 recipes-graphics/mesa/mesa/0001-gallium-add-tegra-support.patch create mode 100644 recipes-graphics/mesa/mesa/0002-make-DRI-work-under-X.patch create mode 100644 recipes-graphics/mesa/mesa/0003-loader-Automatic-PRIME-detection.patch delete mode 100644 recipes-graphics/mesa/mesa/0004-gallium-add-tegra-support.patch create mode 100644 recipes-graphics/mesa/mesa/0004-mesa-17.1.7-compilation-fixes.patch delete mode 100644 recipes-graphics/mesa/mesa/0005-tegra-open-card1-instead-of-renderD128.patch delete mode 100644 recipes-graphics/mesa/mesa/0006-HACK-make-DRI-work-under-X.patch delete mode 100644 recipes-graphics/mesa/mesa/0008-remove-dependency-on-libdrm_tegra.patch (limited to 'recipes-graphics') diff --git a/recipes-graphics/mesa/mesa/0001-gallium-add-tegra-support.patch b/recipes-graphics/mesa/mesa/0001-gallium-add-tegra-support.patch new file mode 100644 index 0000000..f47e2c5 --- /dev/null +++ b/recipes-graphics/mesa/mesa/0001-gallium-add-tegra-support.patch @@ -0,0 +1,570 @@ +From 2ec5a4bc8eec0908275f3a3259376f1ad8efaaa6 Mon Sep 17 00:00:00 2001 +From: Christian Gmeiner +Date: Sun, 21 Aug 2016 22:10:12 +0200 +Subject: [PATCH 1/4] gallium: add tegra support + +Signed-off-by: Christian Gmeiner +[acourbot@nvidia.com: port to latest branch] +Signed-off-by: Alexandre Courbot + +forward port to mesa 17.0.2 +Signed-off-by: Max Krummenacher + +forward port to mesa 17.1.7 +Signed-off-by: Dominik Sliwa +--- + configure.ac | 13 +++- + src/gallium/Makefile.am | 4 ++ + .../auxiliary/pipe-loader/pipe_loader_drm.c | 5 ++ + src/gallium/auxiliary/target-helpers/drm_helper.h | 23 +++++++ + .../auxiliary/target-helpers/drm_helper_public.h | 3 + + src/gallium/drivers/nouveau/nouveau_buffer.c | 4 ++ + src/gallium/drivers/nouveau/nouveau_buffer.h | 2 + + src/gallium/drivers/nouveau/nouveau_screen.h | 3 + + src/gallium/drivers/nouveau/nv50/nv50_miptree.c | 3 + + src/gallium/drivers/nouveau/nvc0/nvc0_resource.c | 18 +++++- + src/gallium/drivers/tegra/Automake.inc | 9 +++ + src/gallium/drivers/tegra/Makefile.am | 10 +++ + src/gallium/targets/dri/Makefile.am | 2 + + src/gallium/targets/dri/target.c | 4 ++ + .../winsys/nouveau/drm/nouveau_drm_public.h | 2 + + .../winsys/nouveau/drm/nouveau_drm_winsys.c | 10 +++ + src/gallium/winsys/tegra/drm/Android.mk | 33 ++++++++++ + src/gallium/winsys/tegra/drm/Makefile.am | 34 ++++++++++ + src/gallium/winsys/tegra/drm/Makefile.sources | 3 + + src/gallium/winsys/tegra/drm/tegra_drm_public.h | 8 +++ + src/gallium/winsys/tegra/drm/tegra_drm_winsys.c | 74 ++++++++++++++++++++++ + src/mesa/drivers/dri/nouveau/nouveau_screen.h | 1 + + 21 files changed, 262 insertions(+), 3 deletions(-) + create mode 100644 src/gallium/drivers/tegra/Automake.inc + create mode 100644 src/gallium/drivers/tegra/Makefile.am + create mode 100644 src/gallium/winsys/tegra/drm/Android.mk + create mode 100644 src/gallium/winsys/tegra/drm/Makefile.am + create mode 100644 src/gallium/winsys/tegra/drm/Makefile.sources + create mode 100644 src/gallium/winsys/tegra/drm/tegra_drm_public.h + create mode 100644 src/gallium/winsys/tegra/drm/tegra_drm_winsys.c + +diff --git a/configure.ac b/configure.ac +index fd346c8..790388b 100644 +--- a/configure.ac ++++ b/configure.ac +@@ -79,6 +79,7 @@ LIBDRM_INTEL_REQUIRED=2.4.75 + LIBDRM_NVVIEUX_REQUIRED=2.4.66 + LIBDRM_NOUVEAU_REQUIRED=2.4.66 + LIBDRM_FREEDRENO_REQUIRED=2.4.74 ++LIBDRM_TEGRA_REQUIRED=2.4.66 + LIBDRM_VC4_REQUIRED=2.4.69 + LIBDRM_ETNAVIV_REQUIRED=2.4.80 + +@@ -1245,7 +1246,7 @@ GALLIUM_DRIVERS_DEFAULT="r300,r600,svga,swrast" + AC_ARG_WITH([gallium-drivers], + [AS_HELP_STRING([--with-gallium-drivers@<:@=DIRS...@:>@], + [comma delimited Gallium drivers list, e.g. +- "i915,nouveau,r300,r600,radeonsi,freedreno,svga,swrast,swr,vc4,virgl,etnaviv,imx" ++ "i915,nouveau,r300,r600,radeonsi,freedreno,svga,swrast,swr,vc4,virgl,etnaviv,imx,tegra" + @<:@default=r300,r600,svga,swrast@:>@])], + [with_gallium_drivers="$withval"], + [with_gallium_drivers="$GALLIUM_DRIVERS_DEFAULT"]) +@@ -2518,6 +2519,13 @@ if test -n "$with_gallium_drivers"; then + require_basic_egl "virgl" + fi + ;; ++ xtegra) ++# PKG_CHECK_MODULES([TEGRA], [libdrm_tegra >= $LIBDRM_TEGRA_REQUIRED]) ++ HAVE_GALLIUM_TEGRA=yes ++ require_libdrm "tegra" ++# gallium_require_drm_loader ++# require_egl_drm "tegra" ++ ;; + *) + AC_MSG_ERROR([Unknown Gallium driver: $driver]) + ;; +@@ -2621,6 +2629,7 @@ AM_CONDITIONAL(HAVE_GALLIUM_SWRAST, test "x$HAVE_GALLIUM_SOFTPIPE" = xyes -o \ + "x$HAVE_GALLIUM_SWR" = xyes) + AM_CONDITIONAL(HAVE_GALLIUM_VC4, test "x$HAVE_GALLIUM_VC4" = xyes) + AM_CONDITIONAL(HAVE_GALLIUM_VIRGL, test "x$HAVE_GALLIUM_VIRGL" = xyes) ++AM_CONDITIONAL(HAVE_GALLIUM_TEGRA, test "x$HAVE_GALLIUM_TEGRA" = xyes) + + AM_CONDITIONAL(HAVE_GALLIUM_STATIC_TARGETS, test "x$enable_shared_pipe_drivers" = xno) + +@@ -2766,6 +2775,7 @@ AC_CONFIG_FILES([Makefile + src/gallium/drivers/imx/Makefile + src/gallium/drivers/vc4/Makefile + src/gallium/drivers/virgl/Makefile ++ src/gallium/drivers/tegra/Makefile + src/gallium/state_trackers/clover/Makefile + src/gallium/state_trackers/dri/Makefile + src/gallium/state_trackers/glx/xlib/Makefile +@@ -2809,6 +2819,7 @@ AC_CONFIG_FILES([Makefile + src/gallium/winsys/vc4/drm/Makefile + src/gallium/winsys/virgl/drm/Makefile + src/gallium/winsys/virgl/vtest/Makefile ++ src/gallium/winsys/tegra/drm/Makefile + src/gbm/Makefile + src/gbm/main/gbm.pc + src/glx/Makefile +diff --git a/src/gallium/Makefile.am b/src/gallium/Makefile.am +index 38da63b..1df0d3c 100644 +--- a/src/gallium/Makefile.am ++++ b/src/gallium/Makefile.am +@@ -95,6 +95,10 @@ if HAVE_GALLIUM_VIRGL + SUBDIRS += drivers/virgl winsys/virgl/drm winsys/virgl/vtest + endif + ++if HAVE_GALLIUM_TEGRA ++SUBDIRS += drivers/tegra winsys/tegra/drm ++endif ++ + ## the sw winsys' + SUBDIRS += winsys/sw/null + +diff --git a/src/gallium/auxiliary/pipe-loader/pipe_loader_drm.c b/src/gallium/auxiliary/pipe-loader/pipe_loader_drm.c +index a4f5cfc..3cad124 100644 +--- a/src/gallium/auxiliary/pipe-loader/pipe_loader_drm.c ++++ b/src/gallium/auxiliary/pipe-loader/pipe_loader_drm.c +@@ -139,6 +139,11 @@ static const struct drm_driver_descriptor driver_descriptors[] = { + .configuration = configuration_query, + }, + { ++ .driver_name = "tegra", ++ .create_screen = pipe_tegra_create_screen, ++ .configuration = configuration_query, ++ }, ++ { + .driver_name = "etnaviv", + .create_screen = pipe_etna_create_screen, + .configuration = configuration_query, +diff --git a/src/gallium/auxiliary/target-helpers/drm_helper.h b/src/gallium/auxiliary/target-helpers/drm_helper.h +index 3159df6..99b6cb5 100644 +--- a/src/gallium/auxiliary/target-helpers/drm_helper.h ++++ b/src/gallium/auxiliary/target-helpers/drm_helper.h +@@ -284,4 +284,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 ++ + #endif /* DRM_HELPER_H */ +diff --git a/src/gallium/auxiliary/target-helpers/drm_helper_public.h b/src/gallium/auxiliary/target-helpers/drm_helper_public.h +index bc12b21..5525bdf 100644 +--- a/src/gallium/auxiliary/target-helpers/drm_helper_public.h ++++ b/src/gallium/auxiliary/target-helpers/drm_helper_public.h +@@ -40,4 +40,7 @@ pipe_etna_create_screen(int fd); + struct pipe_screen * + pipe_imx_drm_create_screen(int fd); + ++struct pipe_screen * ++pipe_tegra_create_screen(int fd); ++ + #endif /* _DRM_HELPER_PUBLIC_H */ +diff --git a/src/gallium/drivers/nouveau/nouveau_buffer.c b/src/gallium/drivers/nouveau/nouveau_buffer.c +index 2c60441..b45cc7b 100644 +--- a/src/gallium/drivers/nouveau/nouveau_buffer.c ++++ b/src/gallium/drivers/nouveau/nouveau_buffer.c +@@ -117,6 +117,7 @@ nouveau_buffer_destroy(struct pipe_screen *pscreen, + struct pipe_resource *presource) + { + struct nv04_resource *res = nv04_resource(presource); ++ struct nouveau_screen *scr = nouveau_screen(pscreen); + + nouveau_buffer_release_gpu_storage(res); + +@@ -128,6 +129,9 @@ nouveau_buffer_destroy(struct pipe_screen *pscreen, + + util_range_destroy(&res->valid_buffer_range); + ++ if (res->scanout) ++ renderonly_scanout_destroy(res->scanout, scr->ro); ++ + FREE(res); + + NOUVEAU_DRV_STAT(nouveau_screen(pscreen), buf_obj_current_count, -1); +diff --git a/src/gallium/drivers/nouveau/nouveau_buffer.h b/src/gallium/drivers/nouveau/nouveau_buffer.h +index 3a33fae..c01fda4 100644 +--- a/src/gallium/drivers/nouveau/nouveau_buffer.h ++++ b/src/gallium/drivers/nouveau/nouveau_buffer.h +@@ -50,6 +50,8 @@ struct nv04_resource { + + /* buffer range that has been initialized */ + struct util_range valid_buffer_range; ++ ++ struct renderonly_scanout *scanout; + }; + + void +diff --git a/src/gallium/drivers/nouveau/nouveau_screen.h b/src/gallium/drivers/nouveau/nouveau_screen.h +index e4fbae9..b326c52 100644 +--- a/src/gallium/drivers/nouveau/nouveau_screen.h ++++ b/src/gallium/drivers/nouveau/nouveau_screen.h +@@ -2,6 +2,7 @@ + #define __NOUVEAU_SCREEN_H__ + + #include "pipe/p_screen.h" ++#include "renderonly/renderonly.h" + #include "util/disk_cache.h" + #include "util/u_memory.h" + +@@ -62,6 +63,8 @@ struct nouveau_screen { + + struct disk_cache *disk_shader_cache; + ++ struct renderonly *ro; ++ + #ifdef NOUVEAU_ENABLE_DRIVER_STATISTICS + union { + uint64_t v[29]; +diff --git a/src/gallium/drivers/nouveau/nv50/nv50_miptree.c b/src/gallium/drivers/nouveau/nv50/nv50_miptree.c +index f2e304f..29e95a6 100644 +--- a/src/gallium/drivers/nouveau/nv50/nv50_miptree.c ++++ b/src/gallium/drivers/nouveau/nv50/nv50_miptree.c +@@ -189,6 +189,9 @@ nv50_miptree_get_handle(struct pipe_screen *pscreen, + if (!mt || !mt->base.bo) + return false; + ++ if (renderonly_get_handle(mt->base.scanout, whandle)) ++ return TRUE; ++ + stride = mt->level[0].pitch; + + return nouveau_screen_bo_get_handle(pscreen, +diff --git a/src/gallium/drivers/nouveau/nvc0/nvc0_resource.c b/src/gallium/drivers/nouveau/nvc0/nvc0_resource.c +index 9bafe3d..adfd61c 100644 +--- a/src/gallium/drivers/nouveau/nvc0/nvc0_resource.c ++++ b/src/gallium/drivers/nouveau/nvc0/nvc0_resource.c +@@ -8,12 +8,26 @@ static struct pipe_resource * + nvc0_resource_create(struct pipe_screen *screen, + const struct pipe_resource *templ) + { ++ struct nouveau_screen *scr = nouveau_screen(screen); ++ struct pipe_resource *pres; ++ + switch (templ->target) { + case PIPE_BUFFER: +- return nouveau_buffer_create(screen, templ); ++ pres = nouveau_buffer_create(screen, templ); ++ break; + default: +- return nvc0_miptree_create(screen, templ); ++ pres = nvc0_miptree_create(screen, templ); ++ break; + } ++ ++ if (pres) { ++ struct nv04_resource *res = nv04_resource(pres); ++ ++ if (templ->bind & PIPE_BIND_SCANOUT && scr->ro) ++ res->scanout = renderonly_scanout_for_resource(pres, scr->ro); ++ } ++ ++ return pres; + } + + static struct pipe_resource * +diff --git a/src/gallium/drivers/tegra/Automake.inc b/src/gallium/drivers/tegra/Automake.inc +new file mode 100644 +index 0000000..89e0441 +--- /dev/null ++++ b/src/gallium/drivers/tegra/Automake.inc +@@ -0,0 +1,9 @@ ++if HAVE_GALLIUM_TEGRA ++ ++TARGET_DRIVERS += tegra ++TARGET_CPPFLAGS += -DGALLIUM_TEGRA ++TARGET_LIB_DEPS += \ ++ $(top_builddir)/src/gallium/winsys/tegra/drm/libtegradrm.la \ ++ $(LIBDRM_LIBS) ++ ++endif +diff --git a/src/gallium/drivers/tegra/Makefile.am b/src/gallium/drivers/tegra/Makefile.am +new file mode 100644 +index 0000000..30f4689 +--- /dev/null ++++ b/src/gallium/drivers/tegra/Makefile.am +@@ -0,0 +1,10 @@ ++include $(top_srcdir)/src/gallium/Automake.inc ++ ++AM_CPPFLAGS = \ ++ $(GALLIUM_CFLAGS) \ ++ $(TEGRA_CFLAGS) \ ++ $(LIBDRM_CFLAGS) ++ ++noinst_LTLIBRARIES = libtegra.la ++ ++libtegra_la_SOURCES = +diff --git a/src/gallium/targets/dri/Makefile.am b/src/gallium/targets/dri/Makefile.am +index 8363406..4bfcf3e 100644 +--- a/src/gallium/targets/dri/Makefile.am ++++ b/src/gallium/targets/dri/Makefile.am +@@ -92,6 +92,8 @@ include $(top_srcdir)/src/gallium/drivers/virgl/Automake.inc + include $(top_srcdir)/src/gallium/drivers/etnaviv/Automake.inc + include $(top_srcdir)/src/gallium/drivers/imx/Automake.inc + ++include $(top_srcdir)/src/gallium/drivers/tegra/Automake.inc ++ + include $(top_srcdir)/src/gallium/drivers/softpipe/Automake.inc + include $(top_srcdir)/src/gallium/drivers/llvmpipe/Automake.inc + include $(top_srcdir)/src/gallium/drivers/swr/Automake.inc +diff --git a/src/gallium/targets/dri/target.c b/src/gallium/targets/dri/target.c +index d24a61d..600557b 100644 +--- a/src/gallium/targets/dri/target.c ++++ b/src/gallium/targets/dri/target.c +@@ -79,3 +79,7 @@ DEFINE_LOADER_DRM_ENTRYPOINT(vc4) + DEFINE_LOADER_DRM_ENTRYPOINT(imx_drm) + DEFINE_LOADER_DRM_ENTRYPOINT(etnaviv) + #endif ++ ++#if defined(GALLIUM_TEGRA) ++DEFINE_LOADER_DRM_ENTRYPOINT(tegra) ++#endif +diff --git a/src/gallium/winsys/nouveau/drm/nouveau_drm_public.h b/src/gallium/winsys/nouveau/drm/nouveau_drm_public.h +index 67b7c44..455ea77 100644 +--- a/src/gallium/winsys/nouveau/drm/nouveau_drm_public.h ++++ b/src/gallium/winsys/nouveau/drm/nouveau_drm_public.h +@@ -3,7 +3,9 @@ + #define __NOUVEAU_DRM_PUBLIC_H__ + + struct pipe_screen; ++struct renderonly; + + struct pipe_screen *nouveau_drm_screen_create(int drmFD); ++struct pipe_screen *nouveau_drm_screen_create_renderonly(int fd, struct renderonly *ro); + + #endif +diff --git a/src/gallium/winsys/nouveau/drm/nouveau_drm_winsys.c b/src/gallium/winsys/nouveau/drm/nouveau_drm_winsys.c +index 4ca2d35..8a457d5 100644 +--- a/src/gallium/winsys/nouveau/drm/nouveau_drm_winsys.c ++++ b/src/gallium/winsys/nouveau/drm/nouveau_drm_winsys.c +@@ -157,3 +157,13 @@ err: + mtx_unlock(&nouveau_screen_mutex); + return NULL; + } ++ ++struct pipe_screen *nouveau_drm_screen_create_renderonly(int fd, struct renderonly *ro) ++{ ++ struct nouveau_screen *screen = nouveau_drm_screen_create(fd); ++ ++ if (screen) ++ screen->ro = renderonly_dup(ro); ++ ++ return screen; ++} +diff --git a/src/gallium/winsys/tegra/drm/Android.mk b/src/gallium/winsys/tegra/drm/Android.mk +new file mode 100644 +index 0000000..a48dca4 +--- /dev/null ++++ b/src/gallium/winsys/tegra/drm/Android.mk +@@ -0,0 +1,33 @@ ++# Copyright (C) 2014 Emil Velikov ++# ++# Permission is hereby granted, free of charge, to any person obtaining a ++# copy of this software and associated documentation files (the "Software"), ++# to deal in the Software without restriction, including without limitation ++# the rights to use, copy, modify, merge, publish, distribute, sublicense, ++# and/or sell copies of the Software, and to permit persons to whom the ++# Software is furnished to do so, subject to the following conditions: ++# ++# The above copyright notice and this permission notice shall be included ++# in all copies or substantial portions of the Software. ++# ++# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR ++# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, ++# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL ++# THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER ++# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING ++# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER ++# DEALINGS IN THE SOFTWARE. ++ ++LOCAL_PATH := $(call my-dir) ++ ++# get C_SOURCES ++include $(LOCAL_PATH)/Makefile.sources ++ ++include $(CLEAR_VARS) ++ ++LOCAL_SRC_FILES := $(C_SOURCES) ++ ++LOCAL_MODULE := libmesa_winsys_tegra ++ ++include $(GALLIUM_COMMON_MK) ++include $(BUILD_STATIC_LIBRARY) +diff --git a/src/gallium/winsys/tegra/drm/Makefile.am b/src/gallium/winsys/tegra/drm/Makefile.am +new file mode 100644 +index 0000000..39068fe +--- /dev/null ++++ b/src/gallium/winsys/tegra/drm/Makefile.am +@@ -0,0 +1,34 @@ ++# Copyright © 2012 Intel Corporation ++# ++# Permission is hereby granted, free of charge, to any person obtaining a ++# copy of this software and associated documentation files (the "Software"), ++# to deal in the Software without restriction, including without limitation ++# the rights to use, copy, modify, merge, publish, distribute, sublicense, ++# and/or sell copies of the Software, and to permit persons to whom the ++# Software is furnished to do so, subject to the following conditions: ++# ++# The above copyright notice and this permission notice (including the next ++# paragraph) shall be included in all copies or substantial portions of the ++# Software. ++# ++# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, ++# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF ++# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND ++# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT ++# HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, ++# WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, ++# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER ++# DEALINGS IN THE SOFTWARE. ++ ++include Makefile.sources ++include $(top_srcdir)/src/gallium/Automake.inc ++ ++AM_CFLAGS = \ ++ -I$(top_srcdir)/src/gallium/drivers \ ++ $(GALLIUM_WINSYS_CFLAGS) \ ++ $(TEGRA_CFLAGS) \ ++ $(LIBDRM_CFLAGS) ++ ++noinst_LTLIBRARIES = libtegradrm.la ++ ++libtegradrm_la_SOURCES = $(C_SOURCES) +diff --git a/src/gallium/winsys/tegra/drm/Makefile.sources b/src/gallium/winsys/tegra/drm/Makefile.sources +new file mode 100644 +index 0000000..29a0edc +--- /dev/null ++++ b/src/gallium/winsys/tegra/drm/Makefile.sources +@@ -0,0 +1,3 @@ ++C_SOURCES := \ ++ tegra_drm_public.h \ ++ tegra_drm_winsys.c +diff --git a/src/gallium/winsys/tegra/drm/tegra_drm_public.h b/src/gallium/winsys/tegra/drm/tegra_drm_public.h +new file mode 100644 +index 0000000..813268f +--- /dev/null ++++ b/src/gallium/winsys/tegra/drm/tegra_drm_public.h +@@ -0,0 +1,8 @@ ++#ifndef __TEGRA_DRM_PUBLIC_H__ ++#define __TEGRA_DRM_PUBLIC_H__ ++ ++struct pipe_screen; ++ ++struct pipe_screen *tegra_drm_screen_create(int drmFD); ++ ++#endif /* __TEGRA_DRM_PUBLIC_H__ */ +diff --git a/src/gallium/winsys/tegra/drm/tegra_drm_winsys.c b/src/gallium/winsys/tegra/drm/tegra_drm_winsys.c +new file mode 100644 +index 0000000..c439b8d +--- /dev/null ++++ b/src/gallium/winsys/tegra/drm/tegra_drm_winsys.c +@@ -0,0 +1,76 @@ ++/* ++ * Copyright (C) 2016 Christian Gmeiner ++ * ++ * Permission is hereby granted, free of charge, to any person obtaining a ++ * copy of this software and associated documentation files (the "Software"), ++ * to deal in the Software without restriction, including without limitation ++ * the rights to use, copy, modify, merge, publish, distribute, sublicense, ++ * and/or sell copies of the Software, and to permit persons to whom the ++ * Software is furnished to do so, subject to the following conditions: ++ * ++ * The above copyright notice and this permission notice (including the next ++ * paragraph) shall be included in all copies or substantial portions of the ++ * Software. ++ * ++ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR ++ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, ++ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL ++ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER ++ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, ++ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE ++ * SOFTWARE. ++ * ++ * Authors: ++ * Christian Gmeiner ++ * Alexandre Courbot ++ */ ++ ++#include "tegra_drm_public.h" ++#include "../../nouveau/drm/nouveau_drm_public.h" ++#include "renderonly/renderonly.h" ++ ++#include ++#include ++#include ++ ++static struct renderonly_scanout * ++tegra_create_with_tiling_for_resource(struct pipe_resource *rsc, ++ struct renderonly *ro) ++{ ++ struct renderonly_scanout *scanout; ++ ++ scanout = renderonly_create_gpu_import_for_resource(rsc, ro); ++ if (!scanout) ++ return NULL; ++ ++ struct drm_tegra_gem_set_tiling args = { ++ .handle = scanout->handle, ++ .mode = DRM_TEGRA_GEM_TILING_MODE_BLOCK, ++ .value = 4 ++ }; ++ ++ int ret = drmIoctl(ro->kms_fd, DRM_IOCTL_TEGRA_GEM_SET_TILING, &args); ++ if (ret) ++ return NULL; ++ ++ return scanout; ++} ++ ++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), ++ }; ++ ++ 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); ++ ++ /* printf("Tegra + Nouveau renderonly mode\n"); */ ++ return screen; ++}; +diff --git a/src/mesa/drivers/dri/nouveau/nouveau_screen.h b/src/mesa/drivers/dri/nouveau/nouveau_screen.h +index e3c1928..720ee31 100644 +--- a/src/mesa/drivers/dri/nouveau/nouveau_screen.h ++++ b/src/mesa/drivers/dri/nouveau/nouveau_screen.h +@@ -36,6 +36,7 @@ struct nouveau_screen { + struct nouveau_drm *drm; + struct nouveau_device *device; + const struct nouveau_driver *driver; ++ struct renderonly *ro; + }; + + #endif +-- +2.7.4 + diff --git a/recipes-graphics/mesa/mesa/0002-make-DRI-work-under-X.patch b/recipes-graphics/mesa/mesa/0002-make-DRI-work-under-X.patch new file mode 100644 index 0000000..799eddd --- /dev/null +++ b/recipes-graphics/mesa/mesa/0002-make-DRI-work-under-X.patch @@ -0,0 +1,24 @@ +From 0919eb301de1512bd24298d7f11a0dc6309fb029 Mon Sep 17 00:00:00 2001 +From: Alexandre Courbot +Date: Mon, 11 Jul 2016 14:44:59 +0900 +Subject: [PATCH 2/4] make DRI work under X + +--- + src/loader/loader_dri3_helper.c | 1 + + 1 files changed, 1 insertions(+), 0 deletion(-) + +diff --git a/src/loader/loader_dri3_helper.c b/src/loader/loader_dri3_helper.c +index c2ae895..1d01193 100644 +--- a/src/loader/loader_dri3_helper.c ++++ b/src/loader/loader_dri3_helper.c +@@ -145,6 +145,7 @@ loader_dri3_drawable_init(xcb_connection_t *conn, + draw->drawable = drawable; + draw->dri_screen = dri_screen; + draw->is_different_gpu = is_different_gpu; ++ draw->is_different_gpu = 1; + + draw->have_back = 0; + draw->have_fake_front = 0; +-- +2.7.4 + diff --git a/recipes-graphics/mesa/mesa/0003-loader-Automatic-PRIME-detection.patch b/recipes-graphics/mesa/mesa/0003-loader-Automatic-PRIME-detection.patch new file mode 100644 index 0000000..d252b18 --- /dev/null +++ b/recipes-graphics/mesa/mesa/0003-loader-Automatic-PRIME-detection.patch @@ -0,0 +1,106 @@ +From 0f4808856ce42de4e0cf7e0c3af114165c105003 Mon Sep 17 00:00:00 2001 +From: Thierry Reding +Date: Fri, 23 Dec 2016 21:36:00 +0100 +Subject: [PATCH 3/4] loader: Automatic PRIME detection + +If a device doesn't support rendering and support for PRIME isn't +enabled via the DRI_PRIME environment variable or dri.conf, attempt to +find a render node which can be used to offload rendering. + +Signed-off-by: Thierry Reding +--- + src/loader/loader.c | 71 ++++++++++++++++++++++++++++++++++++++++++++++++++--- + 1 file changed, 67 insertions(+), 4 deletions(-) + +diff --git a/src/loader/loader.c b/src/loader/loader.c +index 5541ccc..19e73a7 100644 +--- a/src/loader/loader.c ++++ b/src/loader/loader.c +@@ -108,6 +108,71 @@ static char *loader_get_dri_config_device_id(void) + } + #endif + ++/* ++ * For all devices that do not support rendering, try to find a different ++ * device that will. ++ * ++ * Note that the absence of a render node doesn't technically imply that ++ * the device can't render, but in practice this should work out fine. ++ */ ++static int drm_detect_prime_fd(int default_fd, int *different_device) ++{ ++ int err, fd = -ENODEV; ++ drmDevicePtr device; ++ ++ err = drmGetDevice(default_fd, &device); ++ if (err < 0) ++ goto err; ++ ++ if ((device->available_nodes & (1 << DRM_NODE_RENDER)) == 0) { ++ unsigned int num_devices, i; ++ drmDevicePtr *devices; ++ ++ err = drmGetDevices(NULL, 0); ++ if (err < 0) ++ goto err; ++ ++ num_devices = err; ++ ++ devices = calloc(num_devices, sizeof(drmDevicePtr)); ++ if (!devices) ++ goto err; ++ ++ err = drmGetDevices(devices, num_devices); ++ if (err < 0) { ++ free(devices); ++ goto err; ++ } ++ ++ num_devices = err; ++ ++ for (i = 0; i < num_devices; i++) { ++ if (devices[i]->available_nodes & (1 << DRM_NODE_RENDER)) { ++ fd = loader_open_device(devices[i]->nodes[DRM_NODE_RENDER]); ++ if (fd < 0) { ++ fd = -errno; ++ continue; ++ } ++ ++ close(default_fd); ++ break; ++ } ++ } ++ ++ drmFreeDevices(devices, num_devices); ++ free(devices); ++ } ++ ++err: ++ if (fd < 0) { ++ *different_device = 0; ++ return default_fd; ++ } ++ ++ *different_device = 1; ++ return fd; ++} ++ + static char *drm_construct_id_path_tag(drmDevicePtr device) + { + /* Length of "pci-xxxx_xx_xx_x\0" */ +@@ -170,10 +235,8 @@ int loader_get_user_preferred_fd(int default_fd, int *different_device) + prime = loader_get_dri_config_device_id(); + #endif + +- if (prime == NULL) { +- *different_device = 0; +- return default_fd; +- } ++ if (prime == NULL || *prime == '\0') ++ return drm_detect_prime_fd(default_fd, different_device); + + default_tag = drm_get_id_path_tag_for_fd(default_fd); + if (default_tag == NULL) +-- +2.7.4 + diff --git a/recipes-graphics/mesa/mesa/0004-gallium-add-tegra-support.patch b/recipes-graphics/mesa/mesa/0004-gallium-add-tegra-support.patch deleted file mode 100644 index 022c7f0..0000000 --- a/recipes-graphics/mesa/mesa/0004-gallium-add-tegra-support.patch +++ /dev/null @@ -1,516 +0,0 @@ -From b1f2a37552e3ff244e3c79b609c66a63c109915a Mon Sep 17 00:00:00 2001 -From: Christian Gmeiner -Date: Sun, 21 Aug 2016 22:10:12 +0200 -Subject: [PATCH 1/4] gallium: add tegra support - -Signed-off-by: Christian Gmeiner -[acourbot@nvidia.com: port to latest branch] -Signed-off-by: Alexandre Courbot - -forward port to mesa 17.0.2 -Signed-off-by: Max Krummenacher ---- - configure.ac | 13 ++++++- - src/gallium/Makefile.am | 4 +++ - .../auxiliary/pipe-loader/pipe_loader_drm.c | 6 ++++ - src/gallium/auxiliary/target-helpers/drm_helper.h | 23 ++++++++++++ - .../auxiliary/target-helpers/drm_helper_public.h | 3 ++ - src/gallium/drivers/nouveau/nouveau_buffer.c | 3 ++ - src/gallium/drivers/nouveau/nouveau_buffer.h | 2 ++ - src/gallium/drivers/nouveau/nouveau_screen.h | 3 ++ - src/gallium/drivers/nouveau/nv50/nv50_miptree.c | 3 ++ - src/gallium/drivers/nouveau/nvc0/nvc0_resource.c | 18 ++++++++-- - src/gallium/drivers/tegra/Automake.inc | 9 +++++ - src/gallium/drivers/tegra/Makefile.am | 9 +++++ - src/gallium/targets/dri/Makefile.am | 2 ++ - src/gallium/targets/dri/target.c | 11 ++++++ - .../winsys/nouveau/drm/nouveau_drm_public.h | 2 ++ - .../winsys/nouveau/drm/nouveau_drm_winsys.c | 10 ++++++ - src/gallium/winsys/tegra/drm/Android.mk | 33 +++++++++++++++++ - src/gallium/winsys/tegra/drm/Makefile.am | 33 +++++++++++++++++ - src/gallium/winsys/tegra/drm/Makefile.sources | 3 ++ - src/gallium/winsys/tegra/drm/tegra_drm_public.h | 8 +++++ - src/gallium/winsys/tegra/drm/tegra_drm_winsys.c | 41 ++++++++++++++++++++++ - 21 files changed, 236 insertions(+), 3 deletions(-) - create mode 100644 src/gallium/drivers/tegra/Automake.inc - create mode 100644 src/gallium/drivers/tegra/Makefile.am - create mode 100644 src/gallium/winsys/tegra/drm/Android.mk - create mode 100644 src/gallium/winsys/tegra/drm/Makefile.am - create mode 100644 src/gallium/winsys/tegra/drm/Makefile.sources - create mode 100644 src/gallium/winsys/tegra/drm/tegra_drm_public.h - create mode 100644 src/gallium/winsys/tegra/drm/tegra_drm_winsys.c - -diff --git a/configure.ac b/configure.ac -index ac110e8..f7f94ee 100644 ---- a/configure.ac -+++ b/configure.ac -@@ -74,6 +74,7 @@ LIBDRM_INTEL_REQUIRED=2.4.61 - LIBDRM_NVVIEUX_REQUIRED=2.4.66 - LIBDRM_NOUVEAU_REQUIRED=2.4.66 - LIBDRM_FREEDRENO_REQUIRED=2.4.74 -+LIBDRM_TEGRA_REQUIRED=2.4.68 - LIBDRM_VC4_REQUIRED=2.4.69 - LIBDRM_ETNAVIV_REQUIRED=2.4.74 - DRI2PROTO_REQUIRED=2.6 -@@ -1228,7 +1229,7 @@ GALLIUM_DRIVERS_DEFAULT="r300,r600,svga,swrast" - AC_ARG_WITH([gallium-drivers], - [AS_HELP_STRING([--with-gallium-drivers@<:@=DIRS...@:>@], - [comma delimited Gallium drivers list, e.g. -- "i915,ilo,nouveau,r300,r600,radeonsi,freedreno,svga,swrast,vc4,virgl,etnaviv,imx" -+ "i915,ilo,nouveau,r300,r600,radeonsi,freedreno,svga,swrast,vc4,virgl,etnaviv,imx,tegra" - @<:@default=r300,r600,svga,swrast@:>@])], - [with_gallium_drivers="$withval"], - [with_gallium_drivers="$GALLIUM_DRIVERS_DEFAULT"]) -@@ -2391,6 +2392,13 @@ if test -n "$with_gallium_drivers"; then - require_libdrm "virgl" - require_basic_egl "virgl" - ;; -+ xtegra) -+ PKG_CHECK_MODULES([TEGRA], [libdrm_tegra >= $LIBDRM_TEGRA_REQUIRED]) -+ HAVE_GALLIUM_TEGRA=yes -+ gallium_require_drm "tegra" -+ gallium_require_drm_loader -+ require_egl_drm "tegra" -+ ;; - *) - AC_MSG_ERROR([Unknown Gallium driver: $driver]) - ;; -@@ -2491,6 +2499,7 @@ AM_CONDITIONAL(HAVE_GALLIUM_SWRAST, test "x$HAVE_GALLIUM_SOFTPIPE" = xyes -o \ - "x$HAVE_GALLIUM_SWR" = xyes) - AM_CONDITIONAL(HAVE_GALLIUM_VC4, test "x$HAVE_GALLIUM_VC4" = xyes) - AM_CONDITIONAL(HAVE_GALLIUM_VIRGL, test "x$HAVE_GALLIUM_VIRGL" = xyes) -+AM_CONDITIONAL(HAVE_GALLIUM_TEGRA, test "x$HAVE_GALLIUM_TEGRA" = xyes) - - AM_CONDITIONAL(HAVE_GALLIUM_STATIC_TARGETS, test "x$enable_shared_pipe_drivers" = xno) - -@@ -2639,6 +2648,7 @@ AC_CONFIG_FILES([Makefile - src/gallium/drivers/imx/Makefile - src/gallium/drivers/vc4/Makefile - src/gallium/drivers/virgl/Makefile -+ src/gallium/drivers/tegra/Makefile - src/gallium/state_trackers/clover/Makefile - src/gallium/state_trackers/dri/Makefile - src/gallium/state_trackers/glx/xlib/Makefile -@@ -2683,6 +2693,7 @@ AC_CONFIG_FILES([Makefile - src/gallium/winsys/vc4/drm/Makefile - src/gallium/winsys/virgl/drm/Makefile - src/gallium/winsys/virgl/vtest/Makefile -+ src/gallium/winsys/tegra/drm/Makefile - src/gbm/Makefile - src/gbm/main/gbm.pc - src/glx/Makefile -diff --git a/src/gallium/Makefile.am b/src/gallium/Makefile.am -index f910f31..0f887d2 100644 ---- a/src/gallium/Makefile.am -+++ b/src/gallium/Makefile.am -@@ -100,6 +100,10 @@ if HAVE_GALLIUM_VIRGL - SUBDIRS += drivers/virgl winsys/virgl/drm winsys/virgl/vtest - endif - -+if HAVE_GALLIUM_TEGRA -+SUBDIRS += drivers/tegra winsys/tegra/drm -+endif -+ - ## the sw winsys' - SUBDIRS += winsys/sw/null - -diff --git a/src/gallium/auxiliary/pipe-loader/pipe_loader_drm.c b/src/gallium/auxiliary/pipe-loader/pipe_loader_drm.c -index 6c89fe5..a08d00d 100644 ---- a/src/gallium/auxiliary/pipe-loader/pipe_loader_drm.c -+++ b/src/gallium/auxiliary/pipe-loader/pipe_loader_drm.c -@@ -155,6 +155,11 @@ static const struct drm_driver_descriptor driver_descriptors[] = { - .configuration = configuration_query, - }, - { -+ .driver_name = "tegra", -+ .create_screen = pipe_tegra_create_screen, -+ .configuration = configuration_query, -+ }, -+ { - .driver_name = "etnaviv", - .create_screen = pipe_etna_create_screen, - .configuration = configuration_query, -diff --git a/src/gallium/auxiliary/target-helpers/drm_helper.h b/src/gallium/auxiliary/target-helpers/drm_helper.h -index f847b17..ae641b9 100644 ---- a/src/gallium/auxiliary/target-helpers/drm_helper.h -+++ b/src/gallium/auxiliary/target-helpers/drm_helper.h -@@ -313,4 +313,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 -+ - #endif /* DRM_HELPER_H */ -diff --git a/src/gallium/auxiliary/target-helpers/drm_helper_public.h b/src/gallium/auxiliary/target-helpers/drm_helper_public.h -index bc12b21..5525bdf 100644 ---- a/src/gallium/auxiliary/target-helpers/drm_helper_public.h -+++ b/src/gallium/auxiliary/target-helpers/drm_helper_public.h -@@ -40,4 +40,7 @@ pipe_etna_create_screen(int fd); - struct pipe_screen * - pipe_imx_drm_create_screen(int fd); - -+struct pipe_screen * -+pipe_tegra_create_screen(int fd); -+ - #endif /* _DRM_HELPER_PUBLIC_H */ -diff --git a/src/gallium/drivers/nouveau/nouveau_buffer.c b/src/gallium/drivers/nouveau/nouveau_buffer.c -index 17052b2..95dcaad 100644 ---- a/src/gallium/drivers/nouveau/nouveau_buffer.c -+++ b/src/gallium/drivers/nouveau/nouveau_buffer.c -@@ -128,6 +128,9 @@ nouveau_buffer_destroy(struct pipe_screen *pscreen, - - util_range_destroy(&res->valid_buffer_range); - -+ if (res->scanout) -+ renderonly_scanout_destroy(res->scanout); -+ - FREE(res); - - NOUVEAU_DRV_STAT(nouveau_screen(pscreen), buf_obj_current_count, -1); -diff --git a/src/gallium/drivers/nouveau/nouveau_buffer.h b/src/gallium/drivers/nouveau/nouveau_buffer.h -index 3a33fae..c01fda4 100644 ---- a/src/gallium/drivers/nouveau/nouveau_buffer.h -+++ b/src/gallium/drivers/nouveau/nouveau_buffer.h -@@ -50,6 +50,8 @@ struct nv04_resource { - - /* buffer range that has been initialized */ - struct util_range valid_buffer_range; -+ -+ struct renderonly_scanout *scanout; - }; - - void -diff --git a/src/gallium/drivers/nouveau/nouveau_screen.h b/src/gallium/drivers/nouveau/nouveau_screen.h -index 28c4760..e0ec614 100644 ---- a/src/gallium/drivers/nouveau/nouveau_screen.h -+++ b/src/gallium/drivers/nouveau/nouveau_screen.h -@@ -2,6 +2,7 @@ - #define __NOUVEAU_SCREEN_H__ - - #include "pipe/p_screen.h" -+#include "renderonly/renderonly.h" - #include "util/u_memory.h" - - #ifdef DEBUG -@@ -59,6 +60,8 @@ struct nouveau_screen { - unsigned profiles_present; - } firmware_info; - -+ struct renderonly *ro; -+ - #ifdef NOUVEAU_ENABLE_DRIVER_STATISTICS - union { - uint64_t v[29]; -diff --git a/src/gallium/drivers/nouveau/nv50/nv50_miptree.c b/src/gallium/drivers/nouveau/nv50/nv50_miptree.c -index f2e304f..29e95a6 100644 ---- a/src/gallium/drivers/nouveau/nv50/nv50_miptree.c -+++ b/src/gallium/drivers/nouveau/nv50/nv50_miptree.c -@@ -189,6 +189,9 @@ nv50_miptree_get_handle(struct pipe_screen *pscreen, - if (!mt || !mt->base.bo) - return false; - -+ if (renderonly_get_handle(mt->base.scanout, whandle)) -+ return TRUE; -+ - stride = mt->level[0].pitch; - - return nouveau_screen_bo_get_handle(pscreen, -diff --git a/src/gallium/drivers/nouveau/nvc0/nvc0_resource.c b/src/gallium/drivers/nouveau/nvc0/nvc0_resource.c -index 9bafe3d..adfd61c 100644 ---- a/src/gallium/drivers/nouveau/nvc0/nvc0_resource.c -+++ b/src/gallium/drivers/nouveau/nvc0/nvc0_resource.c -@@ -8,12 +8,26 @@ static struct pipe_resource * - nvc0_resource_create(struct pipe_screen *screen, - const struct pipe_resource *templ) - { -+ struct nouveau_screen *scr = nouveau_screen(screen); -+ struct pipe_resource *pres; -+ - switch (templ->target) { - case PIPE_BUFFER: -- return nouveau_buffer_create(screen, templ); -+ pres = nouveau_buffer_create(screen, templ); -+ break; - default: -- return nvc0_miptree_create(screen, templ); -+ pres = nvc0_miptree_create(screen, templ); -+ break; - } -+ -+ if (pres) { -+ struct nv04_resource *res = nv04_resource(pres); -+ -+ if (templ->bind & PIPE_BIND_SCANOUT) -+ res->scanout = renderonly_scanout_for_resource(pres, scr->ro); -+ } -+ -+ return pres; - } - - static struct pipe_resource * -diff --git a/src/gallium/drivers/tegra/Automake.inc b/src/gallium/drivers/tegra/Automake.inc -new file mode 100644 -index 0000000..89e0441 ---- /dev/null -+++ b/src/gallium/drivers/tegra/Automake.inc -@@ -0,0 +1,9 @@ -+if HAVE_GALLIUM_TEGRA -+ -+TARGET_DRIVERS += tegra -+TARGET_CPPFLAGS += -DGALLIUM_TEGRA -+TARGET_LIB_DEPS += \ -+ $(top_builddir)/src/gallium/winsys/tegra/drm/libtegradrm.la \ -+ $(LIBDRM_LIBS) -+ -+endif -diff --git a/src/gallium/drivers/tegra/Makefile.am b/src/gallium/drivers/tegra/Makefile.am -new file mode 100644 -index 0000000..30f4689 ---- /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) -+ -+noinst_LTLIBRARIES = libtegra.la -+ -+libtegra_la_SOURCES = -diff --git a/src/gallium/targets/dri/Makefile.am b/src/gallium/targets/dri/Makefile.am -index bca747f..4236da1 100644 ---- a/src/gallium/targets/dri/Makefile.am -+++ b/src/gallium/targets/dri/Makefile.am -@@ -94,6 +94,8 @@ include $(top_srcdir)/src/gallium/drivers/virgl/Automake.inc - include $(top_srcdir)/src/gallium/drivers/etnaviv/Automake.inc - include $(top_srcdir)/src/gallium/drivers/imx/Automake.inc - -+include $(top_srcdir)/src/gallium/drivers/tegra/Automake.inc -+ - include $(top_srcdir)/src/gallium/drivers/softpipe/Automake.inc - include $(top_srcdir)/src/gallium/drivers/llvmpipe/Automake.inc - include $(top_srcdir)/src/gallium/drivers/swr/Automake.inc -diff --git a/src/gallium/targets/dri/target.c b/src/gallium/targets/dri/target.c -index 441a27f..5e4db62 100644 ---- a/src/gallium/targets/dri/target.c -+++ b/src/gallium/targets/dri/target.c -@@ -181,3 +181,14 @@ PUBLIC const __DRIextension **__driDriverGetExtensions_etnaviv(void) - return galliumdrm_driver_extensions; - } - #endif -+ -+#if defined(GALLIUM_TEGRA) -+ -+const __DRIextension **__driDriverGetExtensions_tegra(void); -+ -+PUBLIC const __DRIextension **__driDriverGetExtensions_tegra(void) -+{ -+ globalDriverAPI = &galliumdrm_driver_api; -+ return galliumdrm_driver_extensions; -+} -+#endif -diff --git a/src/gallium/winsys/nouveau/drm/nouveau_drm_public.h b/src/gallium/winsys/nouveau/drm/nouveau_drm_public.h -index 67b7c44..455ea77 100644 ---- a/src/gallium/winsys/nouveau/drm/nouveau_drm_public.h -+++ b/src/gallium/winsys/nouveau/drm/nouveau_drm_public.h -@@ -3,7 +3,9 @@ - #define __NOUVEAU_DRM_PUBLIC_H__ - - struct pipe_screen; -+struct renderonly; - - struct pipe_screen *nouveau_drm_screen_create(int drmFD); -+struct pipe_screen *nouveau_drm_screen_create_renderonly(int fd, struct renderonly *ro); - - #endif -diff --git a/src/gallium/winsys/nouveau/drm/nouveau_drm_winsys.c b/src/gallium/winsys/nouveau/drm/nouveau_drm_winsys.c -index cc9dfa7..acbd3fe 100644 ---- a/src/gallium/winsys/nouveau/drm/nouveau_drm_winsys.c -+++ b/src/gallium/winsys/nouveau/drm/nouveau_drm_winsys.c -@@ -157,3 +157,13 @@ err: - pipe_mutex_unlock(nouveau_screen_mutex); - return NULL; - } -+ -+struct pipe_screen *nouveau_drm_screen_create_renderonly(int fd, struct renderonly *ro) -+{ -+ struct nouveau_screen *screen = nouveau_drm_screen_create(fd); -+ -+ if (screen) -+ screen->ro = ro; -+ -+ return screen; -+} -diff --git a/src/gallium/winsys/tegra/drm/Android.mk b/src/gallium/winsys/tegra/drm/Android.mk -new file mode 100644 -index 0000000..a48dca4 ---- /dev/null -+++ b/src/gallium/winsys/tegra/drm/Android.mk -@@ -0,0 +1,33 @@ -+# Copyright (C) 2014 Emil Velikov -+# -+# Permission is hereby granted, free of charge, to any person obtaining a -+# copy of this software and associated documentation files (the "Software"), -+# to deal in the Software without restriction, including without limitation -+# the rights to use, copy, modify, merge, publish, distribute, sublicense, -+# and/or sell copies of the Software, and to permit persons to whom the -+# Software is furnished to do so, subject to the following conditions: -+# -+# The above copyright notice and this permission notice shall be included -+# in all copies or substantial portions of the Software. -+# -+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -+# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -+# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL -+# THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -+# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -+# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER -+# DEALINGS IN THE SOFTWARE. -+ -+LOCAL_PATH := $(call my-dir) -+ -+# get C_SOURCES -+include $(LOCAL_PATH)/Makefile.sources -+ -+include $(CLEAR_VARS) -+ -+LOCAL_SRC_FILES := $(C_SOURCES) -+ -+LOCAL_MODULE := libmesa_winsys_tegra -+ -+include $(GALLIUM_COMMON_MK) -+include $(BUILD_STATIC_LIBRARY) -diff --git a/src/gallium/winsys/tegra/drm/Makefile.am b/src/gallium/winsys/tegra/drm/Makefile.am -new file mode 100644 -index 0000000..39068fe ---- /dev/null -+++ b/src/gallium/winsys/tegra/drm/Makefile.am -@@ -0,0 +1,33 @@ -+# Copyright © 2012 Intel Corporation -+# -+# Permission is hereby granted, free of charge, to any person obtaining a -+# copy of this software and associated documentation files (the "Software"), -+# to deal in the Software without restriction, including without limitation -+# the rights to use, copy, modify, merge, publish, distribute, sublicense, -+# and/or sell copies of the Software, and to permit persons to whom the -+# Software is furnished to do so, subject to the following conditions: -+# -+# The above copyright notice and this permission notice (including the next -+# paragraph) shall be included in all copies or substantial portions of the -+# Software. -+# -+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -+# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -+# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -+# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT -+# HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, -+# WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -+# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER -+# DEALINGS IN THE SOFTWARE. -+ -+include Makefile.sources -+include $(top_srcdir)/src/gallium/Automake.inc -+ -+AM_CFLAGS = \ -+ -I$(top_srcdir)/src/gallium/drivers \ -+ $(GALLIUM_WINSYS_CFLAGS) \ -+ $(TEGRA_CFLAGS) -+ -+noinst_LTLIBRARIES = libtegradrm.la -+ -+libtegradrm_la_SOURCES = $(C_SOURCES) -diff --git a/src/gallium/winsys/tegra/drm/Makefile.sources b/src/gallium/winsys/tegra/drm/Makefile.sources -new file mode 100644 -index 0000000..29a0edc ---- /dev/null -+++ b/src/gallium/winsys/tegra/drm/Makefile.sources -@@ -0,0 +1,3 @@ -+C_SOURCES := \ -+ tegra_drm_public.h \ -+ tegra_drm_winsys.c -diff --git a/src/gallium/winsys/tegra/drm/tegra_drm_public.h b/src/gallium/winsys/tegra/drm/tegra_drm_public.h -new file mode 100644 -index 0000000..813268f ---- /dev/null -+++ b/src/gallium/winsys/tegra/drm/tegra_drm_public.h -@@ -0,0 +1,8 @@ -+#ifndef __TEGRA_DRM_PUBLIC_H__ -+#define __TEGRA_DRM_PUBLIC_H__ -+ -+struct pipe_screen; -+ -+struct pipe_screen *tegra_drm_screen_create(int drmFD); -+ -+#endif /* __TEGRA_DRM_PUBLIC_H__ */ -diff --git a/src/gallium/winsys/tegra/drm/tegra_drm_winsys.c b/src/gallium/winsys/tegra/drm/tegra_drm_winsys.c -new file mode 100644 -index 0000000..361370d ---- /dev/null -+++ b/src/gallium/winsys/tegra/drm/tegra_drm_winsys.c -@@ -0,0 +1,41 @@ -+#include "tegra_drm_public.h" -+ -+#include "renderonly/renderonly.h" -+#include "../winsys/nouveau/drm/nouveau_drm_public.h" -+ -+#include -+#include -+#include -+ -+static struct pipe_screen * -+tegra_create(struct renderonly *ro) -+{ -+ int fd = open("/dev/dri/renderD128", O_RDWR | O_CLOEXEC); -+ -+ if (fd == -1) -+ return NULL; -+ -+ return nouveau_drm_screen_create_renderonly(fd, ro); -+} -+ -+static int -+tegra_tiling(int fd, uint32_t handle) -+{ -+ struct drm_tegra_gem_set_tiling args = { -+ .handle = handle, -+ .mode = DRM_TEGRA_GEM_TILING_MODE_BLOCK, -+ .value = 4 -+ }; -+ -+ return drmIoctl(fd, DRM_IOCTL_TEGRA_GEM_SET_TILING, &args); -+} -+ -+static const struct renderonly_ops ro_ops = { -+ .create = tegra_create, -+ .tiling = tegra_tiling -+}; -+ -+struct pipe_screen *tegra_drm_screen_create(int fd) -+{ -+ return renderonly_screen_create(fd, &ro_ops, NULL); -+} --- -2.9.3 - diff --git a/recipes-graphics/mesa/mesa/0004-mesa-17.1.7-compilation-fixes.patch b/recipes-graphics/mesa/mesa/0004-mesa-17.1.7-compilation-fixes.patch new file mode 100644 index 0000000..f9e9a45 --- /dev/null +++ b/recipes-graphics/mesa/mesa/0004-mesa-17.1.7-compilation-fixes.patch @@ -0,0 +1,26 @@ +From 3fd098d1127695a2ba5f9e56eb51c0c26c928d2c Mon Sep 17 00:00:00 2001 +From: Dominik Sliwa +Date: Tue, 5 Dec 2017 15:33:29 +0000 +Subject: [PATCH 4/4] mesa: 17.1.7 compilation fixes + +Signed-off-by: Dominik Sliwa +--- + src/gallium/drivers/nouveau/codegen/nv50_ir_peephole.cpp | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/src/gallium/drivers/nouveau/codegen/nv50_ir_peephole.cpp b/src/gallium/drivers/nouveau/codegen/nv50_ir_peephole.cpp +index 68d02f8..958f1be 100644 +--- a/src/gallium/drivers/nouveau/codegen/nv50_ir_peephole.cpp ++++ b/src/gallium/drivers/nouveau/codegen/nv50_ir_peephole.cpp +@@ -1250,7 +1250,7 @@ ConstantFolding::opnd(Instruction *i, ImmediateValue &imm0, int s) + + cmp->dType = TYPE_F32; + if (i->src(t).mod != Modifier(0)) { +- assert(i->src(t).mod == Modifier(NV50_IR_MOD_NOT)); ++ // assert(i->src(t).mod == Modifier(NV50_IR_MOD_NOT)); + i->src(t).mod = Modifier(0); + cmp->setCond = inverseCondCode(cmp->setCond); + } +-- +2.7.4 + diff --git a/recipes-graphics/mesa/mesa/0005-tegra-open-card1-instead-of-renderD128.patch b/recipes-graphics/mesa/mesa/0005-tegra-open-card1-instead-of-renderD128.patch deleted file mode 100644 index 14a867a..0000000 --- a/recipes-graphics/mesa/mesa/0005-tegra-open-card1-instead-of-renderD128.patch +++ /dev/null @@ -1,29 +0,0 @@ -From a97f868a806ab4f1aaab88c72d4b55bfb18cc3cc Mon Sep 17 00:00:00 2001 -From: Alexandre Courbot -Date: Fri, 9 Dec 2016 17:04:16 +0900 -Subject: [PATCH 5/8] tegra: open card1 instead of renderD128 - -Mesa wants to perform a FLINK ioctl to share GPU buffers. This ioctl is -not valid on render-nodes. - -This fixes rendering with Weston, but GLX is still broken. ---- - src/gallium/winsys/tegra/drm/tegra_drm_winsys.c | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -diff --git a/src/gallium/winsys/tegra/drm/tegra_drm_winsys.c b/src/gallium/winsys/tegra/drm/tegra_drm_winsys.c -index 361370d..e213942 100644 ---- a/src/gallium/winsys/tegra/drm/tegra_drm_winsys.c -+++ b/src/gallium/winsys/tegra/drm/tegra_drm_winsys.c -@@ -10,7 +10,7 @@ - static struct pipe_screen * - tegra_create(struct renderonly *ro) - { -- int fd = open("/dev/dri/renderD128", O_RDWR | O_CLOEXEC); -+ int fd = open("/dev/dri/card1", O_RDWR | O_CLOEXEC); - - if (fd == -1) - return NULL; --- -2.9.3 - diff --git a/recipes-graphics/mesa/mesa/0006-HACK-make-DRI-work-under-X.patch b/recipes-graphics/mesa/mesa/0006-HACK-make-DRI-work-under-X.patch deleted file mode 100644 index ecafa3f..0000000 --- a/recipes-graphics/mesa/mesa/0006-HACK-make-DRI-work-under-X.patch +++ /dev/null @@ -1,24 +0,0 @@ -From bb572a449b8c168dbe6d723692e4c1c8801f15b8 Mon Sep 17 00:00:00 2001 -From: Alexandre Courbot -Date: Mon, 11 Jul 2016 14:44:59 +0900 -Subject: [PATCH 6/8] [HACK] make DRI work under X - ---- - src/loader/loader_dri3_helper.c | 1 + - 1 file changed, 1 insertion(+) - -diff --git a/src/loader/loader_dri3_helper.c b/src/loader/loader_dri3_helper.c -index ca02e97..568a1c7 100644 ---- a/src/loader/loader_dri3_helper.c -+++ b/src/loader/loader_dri3_helper.c -@@ -145,6 +145,7 @@ loader_dri3_drawable_init(xcb_connection_t *conn, - draw->drawable = drawable; - draw->dri_screen = dri_screen; - draw->is_different_gpu = is_different_gpu; -+ draw->is_different_gpu = 1; - - draw->have_back = 0; - draw->have_fake_front = 0; --- -2.9.3 - diff --git a/recipes-graphics/mesa/mesa/0008-remove-dependency-on-libdrm_tegra.patch b/recipes-graphics/mesa/mesa/0008-remove-dependency-on-libdrm_tegra.patch deleted file mode 100644 index b197b93..0000000 --- a/recipes-graphics/mesa/mesa/0008-remove-dependency-on-libdrm_tegra.patch +++ /dev/null @@ -1,51 +0,0 @@ -From b91f178edf3ba6969120a8ad2f5a7a4d330e2b64 Mon Sep 17 00:00:00 2001 -From: Alexandre Courbot -Date: Tue, 20 Dec 2016 15:20:20 +0900 -Subject: [PATCH 4/4] remove dependency on libdrm_tegra - -Functions provided by this library are not required as we perform ioctls -directly. - -Forward port to mesa 17.0.2 -Signed-off-by: Max Krummenacher ---- - configure.ac | 2 -- - src/gallium/winsys/tegra/drm/Makefile.am | 2 +- - 2 files changed, 1 insertion(+), 3 deletions(-) - -diff --git a/configure.ac b/configure.ac -index f7f94ee..4ce5d37 100644 ---- a/configure.ac -+++ b/configure.ac -@@ -74,7 +74,6 @@ LIBDRM_INTEL_REQUIRED=2.4.61 - LIBDRM_NVVIEUX_REQUIRED=2.4.66 - LIBDRM_NOUVEAU_REQUIRED=2.4.66 - LIBDRM_FREEDRENO_REQUIRED=2.4.74 --LIBDRM_TEGRA_REQUIRED=2.4.68 - LIBDRM_VC4_REQUIRED=2.4.69 - LIBDRM_ETNAVIV_REQUIRED=2.4.74 - DRI2PROTO_REQUIRED=2.6 -@@ -2393,7 +2392,6 @@ if test -n "$with_gallium_drivers"; then - require_basic_egl "virgl" - ;; - xtegra) -- PKG_CHECK_MODULES([TEGRA], [libdrm_tegra >= $LIBDRM_TEGRA_REQUIRED]) - HAVE_GALLIUM_TEGRA=yes - gallium_require_drm "tegra" - gallium_require_drm_loader -diff --git a/src/gallium/winsys/tegra/drm/Makefile.am b/src/gallium/winsys/tegra/drm/Makefile.am -index 39068fe..eada86a 100644 ---- a/src/gallium/winsys/tegra/drm/Makefile.am -+++ b/src/gallium/winsys/tegra/drm/Makefile.am -@@ -26,7 +26,7 @@ include $(top_srcdir)/src/gallium/Automake.inc - AM_CFLAGS = \ - -I$(top_srcdir)/src/gallium/drivers \ - $(GALLIUM_WINSYS_CFLAGS) \ -- $(TEGRA_CFLAGS) -+ $(LIBDRM_CFLAGS) - - noinst_LTLIBRARIES = libtegradrm.la - --- -2.9.3 - diff --git a/recipes-graphics/mesa/mesa_%.bbappend b/recipes-graphics/mesa/mesa_%.bbappend index d56760a..14500a3 100644 --- a/recipes-graphics/mesa/mesa_%.bbappend +++ b/recipes-graphics/mesa/mesa_%.bbappend @@ -32,10 +32,10 @@ DRIDRIVERS_tegra124m = " " GALLIUMDRIVERS_tegra124m = "tegra" SRC_URI_append_tegra124m = " \ - file://0004-gallium-add-tegra-support.patch \ - file://0005-tegra-open-card1-instead-of-renderD128.patch \ - file://0006-HACK-make-DRI-work-under-X.patch \ - file://0008-remove-dependency-on-libdrm_tegra.patch \ + file://0001-gallium-add-tegra-support.patch \ + file://0002-make-DRI-work-under-X.patch \ + file://0003-loader-Automatic-PRIME-detection.patch \ + file://0004-mesa-17.1.7-compilation-fixes.patch \ " PACKAGE_ARCH_tegra124m = "${MACHINE_ARCH}" -- cgit v1.2.3