sm8x50: Add Mesa (zink+turnip) support am: e4d2a6165f

Original change: https://android-review.googlesource.com/c/device/linaro/dragonboard/+/3026224

Change-Id: I449c6f76922992633ecb7310a065589fa12f3977
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
diff --git a/shared/graphics/mesa/BoardConfig.mk b/shared/graphics/mesa/BoardConfig.mk
index 8836060..e05a372 100644
--- a/shared/graphics/mesa/BoardConfig.mk
+++ b/shared/graphics/mesa/BoardConfig.mk
@@ -17,7 +17,7 @@
 BOARD_GPU_DRIVERS := freedreno
 ifeq ($(TARGET_BUILD_MESA),true)
 BOARD_MESA3D_USES_MESON_BUILD := true
-BOARD_MESA3D_GALLIUM_DRIVERS := freedreno
+BOARD_MESA3D_GALLIUM_DRIVERS := freedreno zink
 BOARD_MESA3D_VULKAN_DRIVERS := freedreno
 else
 BOARD_USE_CUSTOMIZED_MESA := true
diff --git a/sm8x50/BoardConfig.mk b/sm8x50/BoardConfig.mk
index 9015b1c..4995b75 100644
--- a/sm8x50/BoardConfig.mk
+++ b/sm8x50/BoardConfig.mk
@@ -48,5 +48,9 @@
 
 # Graphics
 include device/linaro/dragonboard/shared/graphics/drm_hwcomposer/BoardConfig.mk
+ifeq ($(TARGET_USES_SWR), true)
 BOARD_SEPOLICY_DIRS += device/linaro/dragonboard/shared/graphics/swangle/sepolicy
+else
+include device/linaro/dragonboard/shared/graphics/mesa/BoardConfig.mk
+endif
 BOARD_SEPOLICY_DIRS += device/linaro/dragonboard/shared/graphics/minigbm_msm/sepolicy
diff --git a/sm8x50/init.environ.rc b/sm8x50/init.environ.rc
new file mode 100644
index 0000000..bd44494
--- /dev/null
+++ b/sm8x50/init.environ.rc
@@ -0,0 +1,3 @@
+# set up the global environment
+on early-init
+    export MESA_LOADER_DRIVER_OVERRIDE zink
diff --git a/sm8x50/sm8x50.mk b/sm8x50/sm8x50.mk
index 79d5441..55f8476 100644
--- a/sm8x50/sm8x50.mk
+++ b/sm8x50/sm8x50.mk
@@ -2,10 +2,17 @@
 $(call inherit-product, $(SRC_TARGET_DIR)/product/core_64_bit_only.mk)
 $(call inherit-product, $(SRC_TARGET_DIR)/product/full_base.mk)
 
-# Target boots with software rendering
-TARGET_USES_SWR := true
+# Target boots with software rendering by default
+TARGET_USES_SWR ?= true
 $(call inherit-product, device/linaro/dragonboard/shared/graphics/drm_hwcomposer/device.mk)
-$(call inherit-product, device/linaro/dragonboard/shared/graphics/swangle/device.mk)
+ifeq ($(TARGET_USES_SWR), true)
+  $(call inherit-product, device/linaro/dragonboard/shared/graphics/swangle/device.mk)
+else
+  $(call inherit-product, device/linaro/dragonboard/shared/graphics/mesa/device.mk)
+  TARGET_USES_VULKAN := true
+  PRODUCT_VENDOR_PROPERTIES += debug.hwui.renderer=skiagl
+  PRODUCT_COPY_FILES += $(LOCAL_PATH)/init.environ.rc:$(TARGET_COPY_OUT_VENDOR)/etc/init/init.environ.rc
+endif
 $(call inherit-product, device/linaro/dragonboard/shared/graphics/minigbm_msm/device.mk)
 
 $(call inherit-product, device/linaro/dragonboard/sm8x50/device.mk)