README_UpdateMesaPrebuilts: Add instructions to update upstream Mesa prebuilts

Signed-off-by: Amit Pundir <amit.pundir@linaro.org>
Change-Id: I7697cfecf75cd1284cb604ad265671b796c92b39
diff --git a/src/db845c/mesa_prebuilt/README_UpdateMesaPrebuilts b/src/db845c/mesa_prebuilt/README_UpdateMesaPrebuilts
new file mode 100644
index 0000000..44e58bb
--- /dev/null
+++ b/src/db845c/mesa_prebuilt/README_UpdateMesaPrebuilts
@@ -0,0 +1,82 @@
+These instructions will help you build upstream Mesa binaries for DB845c/RB5
+and prepare linaro vendor-package.
+
+
+Build and boot upstream Mesa (freedreno) with AOSP:
+---------------------------------------------------
+* Build AOSP with upstream Mesa:
+
+    $ mkdir $AOSP
+    $ cd $AOSP
+    $ repo init -u https://android.googlesource.com/platform/manifest -b master
+    $ repo sync -j`nproc`
+    $ cd $AOSP/external/mesa3d
+    $ git checkout aosp/upstream-main
+    $ cd $AOSP
+    $ . build/envsetup.sh
+    $ lunch db845c-userdebug
+    $ make TARGET_BUILD_MESA=true -j`nproc`
+
+* Boot the DB845c/RB5 in fastboot mode and flash the images:
+
+    $ cd $AOSP/out/target/product/db845c
+    $ fastboot flash super ./super.img flash boot ./boot.img \
+      flash vendor_boot ./vendor_boot.img reboot
+
+
+Updating the Mesa prebuilt binaries in linaro vendor-package:
+------------------------------------------------------------
+* Before we update and ship the new set of Mesa prebuilt binaries, please make
+  sure that there are no new or obvious regressions when we test run
+  CtsGraphicsTestcases, CtsDEQPTestcases and CtsHardwareTestcases on DB845c and
+  RB5 with the new binaries.
+
+  Report any breakages or regressions at https://gitlab.freedesktop.org/mesa/mesa/-/issues
+
+* Copy new Mesa binaries over from AOSP build:
+
+    $ git clone git@gitlab.com:LinaroLtd/linaro-aosp/linaro-vendor-package
+    $ cd linaro-vendor-package/src/db845c/mesa_prebuilt/
+    $ ./copy_bins.sh # This script will copy Mesa prebuilt binaries from \
+                       $ANDROID_PRODUCT_OUT pre-set by "lunch db845c-userdebug" \
+                       or user need to set it explicitly to $AOSP/out/target/product/db845c
+
+  Run "git status" to look for modified binaries. Discard any new *_dri.so in
+  ./lib{,64}/dri/ directory which are usually just a symlink to libgallium_dri.so.
+  Commit the changes with detailed change log and update top-level src/README
+  accordingly.
+
+
+Preparing linaro vendor-package for AOSP:
+-----------------------------------------
+* Follow instructions in src/README_PrepareVendorPackage to prepare linaro
+  vendor-package for AOSP.
+
+
+Troubleshooting:
+----------------
+* Upstream Mesa is/was broken due to deprecated libbacktrace in AOSP
+  https://gitlab.freedesktop.org/mesa/mesa/-/issues/7465,
+  so we may have to use following hack to workaround that build error:
+
+    -- a/src/util/meson.build
+    +++ b/src/util/meson.build
+    @@ -269,7 +269,7 @@ libmesa_util_sse41 = static_library(
+
+     _libmesa_util = static_library(
+       'mesa_util',
+    -  [files_mesa_util, files_debug_stack, format_srgb, u_indices_gen_c, u_unfilled_gen_c],
+    +  [files_mesa_util, format_srgb, u_indices_gen_c, u_unfilled_gen_c],
+       include_directories : [inc_include, inc_src, inc_mapi, inc_mesa, inc_gallium, inc_gallium_aux],
+       dependencies : deps_for_libmesa_util,
+       link_with: [libmesa_format, libmesa_util_sse41],
+
+* Upstream also has a new dependency on meson version >= 0.54 now,
+  and that broke the build on Ubuntu 20.04.5. So update meson by
+  adding the following untrusted PPA:
+
+    $ sudo add-apt-repository ppa:ubuntu-support-team/meson
+    $ sudo apt update
+    $ sudo apt install meson
+
+  h/t: https://launchpad.net/~ubuntu-support-team/+archive/ubuntu/meson