From 809f843759dd66052520956e122b33e71a6631f9 Mon Sep 17 00:00:00 2001 From: Peter Yoon Date: Wed, 13 Jan 2021 00:07:15 +0900 Subject: [PATCH 1/4] support v3dv Change-Id: Ib054804437aa4606abb3eba99b940b8e52961d59 --- src/broadcom/vulkan/meson.build | 6 + src/broadcom/vulkan/v3dv_android.c | 442 +++++++++++++++++++++++++++++ src/broadcom/vulkan/v3dv_device.c | 3 + src/broadcom/vulkan/v3dv_image.c | 52 +++- src/broadcom/vulkan/v3dv_private.h | 17 ++ 5 files changed, 510 insertions(+), 10 deletions(-) create mode 100644 src/broadcom/vulkan/v3dv_android.c diff --git a/src/broadcom/vulkan/meson.build b/src/broadcom/vulkan/meson.build index a1cc58637644..44fcacb05aa4 100644 --- a/src/broadcom/vulkan/meson.build +++ b/src/broadcom/vulkan/meson.build @@ -97,6 +97,12 @@ if with_platform_wayland libv3dv_files += [wayland_drm_client_protocol_h, wayland_drm_protocol_c] endif +if with_platform_android + v3dv_deps += dep_android + v3dv_flags += '-DVK_USE_PLATFORM_ANDROID_KHR' + libv3dv_files += files('v3dv_android.c') +endif + per_version_libs = [] foreach ver : v3d_versions per_version_libs += static_library( diff --git a/src/broadcom/vulkan/v3dv_android.c b/src/broadcom/vulkan/v3dv_android.c new file mode 100644 index 000000000000..0646310f5f40 --- /dev/null +++ b/src/broadcom/vulkan/v3dv_android.c @@ -0,0 +1,442 @@ +/* + * Copyright © 2017, Google Inc. + * + * 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 +#include + +#include +#include + +#include +#include + +#include "drm-uapi/drm_fourcc.h" + +#include "util/libsync.h" +#include "util/log.h" +#include "util/os_file.h" + +#include "v3dv_private.h" + +static int v3dv_hal_open(const struct hw_module_t *mod, const char *id, struct hw_device_t **dev); +static int v3dv_hal_close(struct hw_device_t *dev); + +static void UNUSED +static_asserts(void) +{ + STATIC_ASSERT(HWVULKAN_DISPATCH_MAGIC == ICD_LOADER_MAGIC); +} + +PUBLIC struct hwvulkan_module_t HAL_MODULE_INFO_SYM = { + .common = + { + .tag = HARDWARE_MODULE_TAG, + .module_api_version = HWVULKAN_MODULE_API_VERSION_0_1, + .hal_api_version = HARDWARE_MAKE_API_VERSION(1, 0), + .id = HWVULKAN_HARDWARE_MODULE_ID, + .name = "Broadcom Vulkan HAL", + .author = "Broadcom", + .methods = + &(hw_module_methods_t) { + .open = v3dv_hal_open, + }, + }, +}; + +/* If any bits in test_mask are set, then unset them and return true. */ +static inline bool +unmask32(uint32_t *inout_mask, uint32_t test_mask) +{ + uint32_t orig_mask = *inout_mask; + *inout_mask &= ~test_mask; + return *inout_mask != orig_mask; +} + +static int +v3dv_hal_open(const struct hw_module_t *mod, + const char *id, + struct hw_device_t **dev) +{ + assert(mod == &HAL_MODULE_INFO_SYM.common); + assert(strcmp(id, HWVULKAN_DEVICE_0) == 0); + + hwvulkan_device_t *hal_dev = malloc(sizeof(*hal_dev)); + if (!hal_dev) + return -1; + + *hal_dev = (hwvulkan_device_t){ + .common = + { + .tag = HARDWARE_DEVICE_TAG, + .version = HWVULKAN_DEVICE_API_VERSION_0_1, + .module = &HAL_MODULE_INFO_SYM.common, + .close = v3dv_hal_close, + }, + .EnumerateInstanceExtensionProperties = v3dv_EnumerateInstanceExtensionProperties, + .CreateInstance = v3dv_CreateInstance, + .GetInstanceProcAddr = v3dv_GetInstanceProcAddr, + }; + + *dev = &hal_dev->common; + return 0; +} + +static int +v3dv_hal_close(struct hw_device_t *dev) +{ + /* hwvulkan.h claims that hw_device_t::close() is never called. */ + return -1; +} + +/* get dma-buf and modifier from gralloc info */ +VkResult +v3dv_gralloc_info(struct v3dv_device *device, + const VkNativeBufferANDROID *gralloc_info, + int *dma_buf, + uint64_t *modifier) +{ + const uint32_t *handle_fds = (uint32_t *)gralloc_info->handle->data; + const uint32_t *handle_data = &handle_fds[gralloc_info->handle->numFds]; + + if (gralloc_info->handle->numFds == 1) { + /* gbm_gralloc. TODO: modifiers support */ + *dma_buf = handle_fds[0]; + } else { + return vk_errorf(device, VK_ERROR_INVALID_EXTERNAL_HANDLE, + "VkNativeBufferANDROID::handle::numFds is %d, expected 1", + gralloc_info->handle->numFds); + } + + *modifier = DRM_FORMAT_MOD_LINEAR; + return VK_SUCCESS; +} + +/** + * Creates the VkImage using the gralloc handle in *gralloc_info. + */ +VkResult +v3dv_import_memory_from_gralloc_handle(VkDevice device_h, + int dma_buf, + const VkAllocationCallbacks *alloc, + VkImage image_h) +{ + struct v3dv_image *image = NULL; + VkResult result; + + image = v3dv_image_from_handle(image_h); + + VkDeviceMemory memory_h; + + const VkMemoryDedicatedAllocateInfo ded_alloc = { + .sType = VK_STRUCTURE_TYPE_MEMORY_DEDICATED_ALLOCATE_INFO, + .pNext = NULL, + .buffer = VK_NULL_HANDLE, + .image = image_h + }; + + const VkImportMemoryFdInfoKHR import_info = { + .sType = VK_STRUCTURE_TYPE_IMPORT_MEMORY_FD_INFO_KHR, + .pNext = &ded_alloc, + .handleType = VK_EXTERNAL_MEMORY_HANDLE_TYPE_OPAQUE_FD_BIT, + .fd = os_dupfd_cloexec(dma_buf), + }; + + result = + v3dv_AllocateMemory(device_h, + &(VkMemoryAllocateInfo) { + .sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO, + .pNext = &import_info, + .allocationSize = image->size, + .memoryTypeIndex = 0, + }, + alloc, &memory_h); + if (result != VK_SUCCESS) + goto fail_create_image; + + VkBindImageMemoryInfo bind_info = { + .sType = VK_STRUCTURE_TYPE_BIND_IMAGE_MEMORY_INFO, + .image = image_h, + .memory = memory_h, + .memoryOffset = 0, + }; + v3dv_BindImageMemory2(device_h, 1, &bind_info); + + image->owned_memory = memory_h; + + return VK_SUCCESS; + +fail_create_image: + v3dv_DestroyImage(device_h, image_h, alloc); + + return result; +} + +static VkResult +format_supported_with_usage(VkDevice device_h, VkFormat format, + VkImageUsageFlags imageUsage) +{ + V3DV_FROM_HANDLE(v3dv_device, device, device_h); + struct v3dv_physical_device *phys_dev = &device->instance->physicalDevice; + VkPhysicalDevice phys_dev_h = v3dv_physical_device_to_handle(phys_dev); + VkResult result; + + const VkPhysicalDeviceImageFormatInfo2 image_format_info = { + .sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_IMAGE_FORMAT_INFO_2, + .format = format, + .type = VK_IMAGE_TYPE_2D, + .tiling = VK_IMAGE_TILING_OPTIMAL, + .usage = imageUsage, + }; + + VkImageFormatProperties2 image_format_props = { + .sType = VK_STRUCTURE_TYPE_IMAGE_FORMAT_PROPERTIES_2, + }; + + /* Check that requested format and usage are supported. */ + result = v3dv_GetPhysicalDeviceImageFormatProperties2( + phys_dev_h, &image_format_info, &image_format_props); + if (result != VK_SUCCESS) { + return vk_errorf(device, result, + "v3dv_GetPhysicalDeviceImageFormatProperties2 failed " + "inside %s", + __func__); + } + + return VK_SUCCESS; +} + +static VkResult +setup_gralloc0_usage(struct v3dv_device *device, VkFormat format, + VkImageUsageFlags imageUsage, int *grallocUsage) +{ + if (unmask32(&imageUsage, VK_IMAGE_USAGE_TRANSFER_DST_BIT | + VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT)) + *grallocUsage |= GRALLOC_USAGE_HW_RENDER; + + if (unmask32(&imageUsage, VK_IMAGE_USAGE_TRANSFER_SRC_BIT | + VK_IMAGE_USAGE_SAMPLED_BIT | + VK_IMAGE_USAGE_STORAGE_BIT | + VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT)) + *grallocUsage |= GRALLOC_USAGE_HW_TEXTURE; + + /* All VkImageUsageFlags not explicitly checked here are unsupported for + * gralloc swapchains. + */ + if (imageUsage != 0) { + return vk_errorf(device, VK_ERROR_FORMAT_NOT_SUPPORTED, + "unsupported VkImageUsageFlags(0x%x) for gralloc " + "swapchain", imageUsage); + } + + /* The below formats support GRALLOC_USAGE_HW_FB (that is, display + * scanout). This short list of formats is univserally supported on Intel + * but is incomplete. The full set of supported formats is dependent on + * kernel and hardware. + * + * FINISHME: Advertise all display-supported formats. + */ + switch (format) { + case VK_FORMAT_R5G6B5_UNORM_PACK16: + case VK_FORMAT_R8G8B8A8_UNORM: + case VK_FORMAT_R8G8B8A8_SRGB: + *grallocUsage |= GRALLOC_USAGE_HW_FB | + GRALLOC_USAGE_HW_COMPOSER | + GRALLOC_USAGE_EXTERNAL_DISP; + break; + default: + mesa_logw("%s: unsupported format=%d", __func__, format); + } + + if (*grallocUsage == 0) + return VK_ERROR_FORMAT_NOT_SUPPORTED; + + return VK_SUCCESS; +} + +VKAPI_ATTR VkResult VKAPI_CALL +v3dv_GetSwapchainGrallocUsageANDROID(VkDevice device_h, + VkFormat format, + VkImageUsageFlags imageUsage, + int *grallocUsage) +{ + V3DV_FROM_HANDLE(v3dv_device, device, device_h); + VkResult result; + + result = format_supported_with_usage(device_h, format, imageUsage); + if (result != VK_SUCCESS) + return result; + + *grallocUsage = 0; + return setup_gralloc0_usage(device, format, imageUsage, grallocUsage); +} + +VKAPI_ATTR VkResult VKAPI_CALL +v3dv_GetSwapchainGrallocUsage2ANDROID(VkDevice device_h, + VkFormat format, + VkImageUsageFlags imageUsage, + VkSwapchainImageUsageFlagsANDROID swapchainImageUsage, + uint64_t *grallocConsumerUsage, + uint64_t *grallocProducerUsage) +{ + V3DV_FROM_HANDLE(v3dv_device, device, device_h); + VkResult result; + + *grallocConsumerUsage = 0; + *grallocProducerUsage = 0; + mesa_logd("%s: format=%d, usage=0x%x", __func__, format, imageUsage); + + result = format_supported_with_usage(device_h, format, imageUsage); + if (result != VK_SUCCESS) + return result; + + int32_t grallocUsage = 0; + result = setup_gralloc0_usage(device, format, imageUsage, &grallocUsage); + if (result != VK_SUCCESS) + return result; + + /* Setup gralloc1 usage flags from gralloc0 flags. */ + + if (grallocUsage & GRALLOC_USAGE_HW_RENDER) { + *grallocProducerUsage |= GRALLOC1_PRODUCER_USAGE_GPU_RENDER_TARGET; + *grallocConsumerUsage |= GRALLOC1_CONSUMER_USAGE_CLIENT_TARGET; + } + + if (grallocUsage & GRALLOC_USAGE_HW_TEXTURE) { + *grallocConsumerUsage |= GRALLOC1_CONSUMER_USAGE_GPU_TEXTURE; + } + + if (grallocUsage & (GRALLOC_USAGE_HW_FB | + GRALLOC_USAGE_HW_COMPOSER | + GRALLOC_USAGE_EXTERNAL_DISP)) { + *grallocProducerUsage |= GRALLOC1_PRODUCER_USAGE_GPU_RENDER_TARGET; + *grallocConsumerUsage |= GRALLOC1_CONSUMER_USAGE_HWCOMPOSER; + } + + return VK_SUCCESS; +} + +VKAPI_ATTR VkResult VKAPI_CALL +v3dv_AcquireImageANDROID(VkDevice _device, + VkImage image_h, + int nativeFenceFd, + VkSemaphore semaphore_h, + VkFence fence_h) +{ + V3DV_FROM_HANDLE(v3dv_device, device, _device); + VkResult result = VK_SUCCESS; + + if (nativeFenceFd != -1) { + /* As a simple, firstpass implementation of VK_ANDROID_native_buffer, we + * block on the nativeFenceFd. This may introduce latency and is + * definitiely inefficient, yet it's correct. + * + * FINISHME(chadv): Import the nativeFenceFd into the VkSemaphore and + * VkFence. + */ + if (sync_wait(nativeFenceFd, /*timeout*/ -1) < 0) { + result = vk_errorf(device, VK_ERROR_DEVICE_LOST, + "%s: failed to wait on nativeFenceFd=%d", + __func__, nativeFenceFd); + } + + /* From VK_ANDROID_native_buffer's pseudo spec + * (https://source.android.com/devices/graphics/implement-vulkan): + * + * The driver takes ownership of the fence fd and is responsible for + * closing it [...] even if vkAcquireImageANDROID fails and returns + * an error. + */ + close(nativeFenceFd); + + if (result != VK_SUCCESS) + return result; + } + + if (semaphore_h || fence_h) { + /* Thanks to implicit sync, the image is ready for GPU access. But we + * must still put the semaphore into the "submit" state; otherwise the + * client may get unexpected behavior if the client later uses it as + * a wait semaphore. + * + * Because we blocked above on the nativeFenceFd, the image is also + * ready for foreign-device access (including CPU access). But we must + * still signal the fence; otherwise the client may get unexpected + * behavior if the client later waits on it. + * + * For some values of anv_semaphore_type, we must submit the semaphore + * to execbuf in order to signal it. Likewise for anv_fence_type. + * Instead of open-coding here the signal operation for each + * anv_semaphore_type and anv_fence_type, we piggy-back on + * vkQueueSubmit. + */ + const VkSubmitInfo submit = { + .sType = VK_STRUCTURE_TYPE_SUBMIT_INFO, + .waitSemaphoreCount = 0, + .commandBufferCount = 0, + .signalSemaphoreCount = (semaphore_h ? 1 : 0), + .pSignalSemaphores = &semaphore_h, + }; + + result = v3dv_QueueSubmit(v3dv_queue_to_handle(&device->queue), 1, + &submit, fence_h); + if (result != VK_SUCCESS) { + return vk_errorf(device, result, + "anv_QueueSubmit failed inside %s", __func__); + } + } + + return VK_SUCCESS; +} + +VkResult +v3dv_QueueSignalReleaseImageANDROID(VkQueue queue, + uint32_t waitSemaphoreCount, + const VkSemaphore* pWaitSemaphores, + VkImage image, + int* pNativeFenceFd) +{ + VkResult result; + + if (waitSemaphoreCount == 0) + goto done; + + result = v3dv_QueueSubmit(queue, 1, + &(VkSubmitInfo) { + .sType = VK_STRUCTURE_TYPE_SUBMIT_INFO, + .waitSemaphoreCount = 1, + .pWaitSemaphores = pWaitSemaphores, + }, + (VkFence) VK_NULL_HANDLE); + if (result != VK_SUCCESS) + return result; + + done: + if (pNativeFenceFd) { + /* We can rely implicit on sync because above we submitted all + * semaphores to the queue. + */ + *pNativeFenceFd = -1; + } + + return VK_SUCCESS; +} diff --git a/src/broadcom/vulkan/v3dv_device.c b/src/broadcom/vulkan/v3dv_device.c index de085bf092a7..f1628d19a2c3 100644 --- a/src/broadcom/vulkan/v3dv_device.c +++ b/src/broadcom/vulkan/v3dv_device.c @@ -152,6 +152,9 @@ get_device_extensions(const struct v3dv_physical_device *device, .EXT_private_data = true, .EXT_provoking_vertex = true, .EXT_vertex_attribute_divisor = true, +#ifdef ANDROID + .ANDROID_native_buffer = true, +#endif }; } diff --git a/src/broadcom/vulkan/v3dv_image.c b/src/broadcom/vulkan/v3dv_image.c index d03814d986d4..ae6944444079 100644 --- a/src/broadcom/vulkan/v3dv_image.c +++ b/src/broadcom/vulkan/v3dv_image.c @@ -244,11 +244,12 @@ v3dv_layer_offset(const struct v3dv_image *image, uint32_t level, uint32_t layer } static VkResult -create_image(struct v3dv_device *device, +create_image(VkDevice _device, const VkImageCreateInfo *pCreateInfo, const VkAllocationCallbacks *pAllocator, VkImage *pImage) { + V3DV_FROM_HANDLE(v3dv_device, device, _device); struct v3dv_image *image = NULL; image = vk_image_create(&device->vk, pCreateInfo, pAllocator, sizeof(*image)); @@ -292,11 +293,34 @@ create_image(struct v3dv_device *device, } assert(modifier == DRM_FORMAT_MOD_LINEAR || modifier == DRM_FORMAT_MOD_BROADCOM_UIF); - } else if (pCreateInfo->imageType == VK_IMAGE_TYPE_1D || - image->vk.wsi_legacy_scanout) { - tiling = VK_IMAGE_TILING_LINEAR; + } else { + const struct wsi_image_create_info *wsi_info = + vk_find_struct_const(pCreateInfo->pNext, WSI_IMAGE_CREATE_INFO_MESA); + if (wsi_info && wsi_info->scanout) + modifier = DRM_FORMAT_MOD_LINEAR; } +#ifdef ANDROID + const VkNativeBufferANDROID *gralloc_info = + vk_find_struct_const(pCreateInfo->pNext, NATIVE_BUFFER_ANDROID); + int dma_buf; + if (gralloc_info) { + VkResult result = v3dv_gralloc_info(device, gralloc_info, &dma_buf, &modifier); + if (result != VK_SUCCESS) + return result; + } +#endif + + /* 1D and 1D_ARRAY textures are always raster-order */ + if (pCreateInfo->imageType == VK_IMAGE_TYPE_1D) + tiling = VK_IMAGE_TILING_LINEAR; + else if (modifier == DRM_FORMAT_MOD_INVALID) + tiling = pCreateInfo->tiling; + else if (modifier == DRM_FORMAT_MOD_BROADCOM_UIF) + tiling = VK_IMAGE_TILING_OPTIMAL; + else + tiling = VK_IMAGE_TILING_LINEAR; + const struct v3dv_format *format = v3dv_X(device, get_format)(pCreateInfo->format); v3dv_assert(format != NULL && format->supported); @@ -323,11 +347,16 @@ create_image(struct v3dv_device *device, *pImage = v3dv_image_to_handle(image); +#ifdef ANDROID + if (gralloc_info) + return v3dv_import_memory_from_gralloc_handle(_device, dma_buf, pAllocator, *pImage); +#endif + return VK_SUCCESS; } static VkResult -create_image_from_swapchain(struct v3dv_device *device, +create_image_from_swapchain(VkDevice _device, const VkImageCreateInfo *pCreateInfo, const VkImageSwapchainCreateInfoKHR *swapchain_info, const VkAllocationCallbacks *pAllocator, @@ -370,7 +399,7 @@ create_image_from_swapchain(struct v3dv_device *device, assert((swapchain_image->vk.usage & local_create_info.usage) == local_create_info.usage); - return create_image(device, &local_create_info, pAllocator, pImage); + return create_image(_device, &local_create_info, pAllocator, pImage); } VKAPI_ATTR VkResult VKAPI_CALL @@ -379,15 +408,13 @@ v3dv_CreateImage(VkDevice _device, const VkAllocationCallbacks *pAllocator, VkImage *pImage) { - V3DV_FROM_HANDLE(v3dv_device, device, _device); - const VkImageSwapchainCreateInfoKHR *swapchain_info = vk_find_struct_const(pCreateInfo->pNext, IMAGE_SWAPCHAIN_CREATE_INFO_KHR); if (swapchain_info && swapchain_info->swapchain != VK_NULL_HANDLE) - return create_image_from_swapchain(device, pCreateInfo, swapchain_info, + return create_image_from_swapchain(_device, pCreateInfo, swapchain_info, pAllocator, pImage); - return create_image(device, pCreateInfo, pAllocator, pImage); + return create_image(_device, pCreateInfo, pAllocator, pImage); } VKAPI_ATTR void VKAPI_CALL @@ -436,6 +463,11 @@ v3dv_DestroyImage(VkDevice _device, if (image == NULL) return; +#ifdef ANDROID + if (image->owned_memory != VK_NULL_HANDLE) + v3dv_FreeMemory(_device, image->owned_memory, pAllocator); +#endif + vk_image_destroy(&device->vk, pAllocator, &image->vk); } diff --git a/src/broadcom/vulkan/v3dv_private.h b/src/broadcom/vulkan/v3dv_private.h index d3c07c649c1f..53ad5509f226 100644 --- a/src/broadcom/vulkan/v3dv_private.h +++ b/src/broadcom/vulkan/v3dv_private.h @@ -535,6 +535,11 @@ struct v3dv_image { struct v3dv_device_memory *mem; VkDeviceSize mem_offset; uint32_t alignment; + +#ifdef ANDROID + /* For VK_ANDROID_native_buffer, the WSI image owns the memory, */ + VkDeviceMemory owned_memory; +#endif }; VkImageViewType v3dv_image_type_to_view_type(VkImageType type); @@ -2150,4 +2155,16 @@ u64_compare(const void *key1, const void *key2) # undef v3dX #endif +VkResult +v3dv_gralloc_info(struct v3dv_device *device, + const VkNativeBufferANDROID *gralloc_info, + int *dma_buf, + uint64_t *modifier); + +VkResult +v3dv_import_memory_from_gralloc_handle(VkDevice device_h, + int dma_buf, + const VkAllocationCallbacks *alloc, + VkImage image_h); + #endif /* V3DV_PRIVATE_H */ From 507ba630cbfbb10f1dc3bb8b45bd00494c913cfd Mon Sep 17 00:00:00 2001 From: Roman Stratiienko Date: Mon, 31 May 2021 19:16:37 +0300 Subject: [PATCH 2/4] android: Add Android.bp for libgbm_mesa Future integration with minigbm require this library in a Soong Blueprint format. Starting from Android S 'libgbm' module name is occupied by minigbm and used by other ChromeOS components. Using 'libgbm_mesa' name was suggested by Google instead. Signed-off-by: Roman Stratiienko --- Android.bp | 58 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 58 insertions(+) create mode 100644 Android.bp diff --git a/Android.bp b/Android.bp new file mode 100644 index 000000000000..ed3c13d9fce6 --- /dev/null +++ b/Android.bp @@ -0,0 +1,58 @@ +// Mesa 3-D graphics library +// +// Copyright (C) 2021 GlobalLogic Ukraine +// Copyright (C) 2021 Roman Stratiienko (r.stratiienko@gmail.com) +// +// 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. + +cc_library_static { + name: "libgbm_mesa", + vendor: true, + srcs: [ + "src/gbm/main/backend.c", + "src/gbm/main/gbm.c", + "src/gbm/backends/dri/gbm_dri.c", + "src/util/debug.c", + "src/loader/loader.c", + "src/loader/pci_id_driver_map.c", + "src/loader/loader_dri_helper.c", + ], + + export_include_dirs: ["src/gbm/main"], + + local_include_dirs: [ + "include", + "src/loader", + "src/util", + "src", + ], + + shared_libs: ["libdrm"], + cflags: [ + "-DHAVE_TIMESPEC_GET", + "-DHAVE_LIBDRM", + "-Wno-missing-field-initializers", + "-Wno-sign-compare", + "-DHAVE_PTHREAD=1", + "-Wno-unused-parameter", + "-Wno-missing-field-initializers", + "-DDEFAULT_DRIVER_DIR=\"/vendor/lib64/dri\"", + "-DDEFAULT_BACKENDS_PATH=\"/vendor/lib64/gbm\"", + ], +} From b2d0409678f23835b273477b97fc2743d9453ce9 Mon Sep 17 00:00:00 2001 From: Peter Yoon Date: Tue, 11 Jan 2022 18:28:42 +0900 Subject: [PATCH 3/4] support android-rpi --- src/egl/drivers/dri2/platform_android.c | 4 ++-- src/gbm/main/backend.c | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/egl/drivers/dri2/platform_android.c b/src/egl/drivers/dri2/platform_android.c index 36cce501f412..b9e9da1c1bbd 100644 --- a/src/egl/drivers/dri2/platform_android.c +++ b/src/egl/drivers/dri2/platform_android.c @@ -239,7 +239,7 @@ get_yuv_buffer_info(struct dri2_egl_display *dri2_dpy, .drm_fourcc = drm_fourcc, .num_planes = ycbcr.chroma_step == 2 ? 2 : 3, .fds = { -1, -1, -1, -1 }, - .modifier = DRM_FORMAT_MOD_INVALID, + .modifier = DRM_FORMAT_MOD_LINEAR, .yuv_color_space = EGL_ITU_REC601_EXT, .sample_range = EGL_YUV_NARROW_RANGE_EXT, .horizontal_siting = EGL_YUV_CHROMA_SITING_0_EXT, @@ -337,7 +337,7 @@ native_window_buffer_get_buffer_info(struct dri2_egl_display *dri2_dpy, .drm_fourcc = drm_fourcc, .num_planes = num_planes, .fds = { fds[0], -1, -1, -1 }, - .modifier = DRM_FORMAT_MOD_INVALID, + .modifier = DRM_FORMAT_MOD_LINEAR, .offsets = { 0, 0, 0, 0 }, .pitches = { pitch, 0, 0, 0 }, .yuv_color_space = EGL_ITU_REC601_EXT, diff --git a/src/gbm/main/backend.c b/src/gbm/main/backend.c index 974d0a76a4ea..337e9bb13f2f 100644 --- a/src/gbm/main/backend.c +++ b/src/gbm/main/backend.c @@ -198,13 +198,13 @@ backend_from_driver_name(int fd) if (!v) return NULL; - lib = loader_open_driver_lib(v->name, BACKEND_LIB_SUFFIX, + lib = loader_open_driver_lib("kmsro", BACKEND_LIB_SUFFIX, backend_search_path_vars, DEFAULT_BACKENDS_PATH, false); if (lib) - dev = load_backend(lib, fd, v->name); + dev = load_backend(lib, fd, "kmsro"); drmFreeVersion(v); From 79a6a24f8063e7ba7ab6348bfa5014c589acf875 Mon Sep 17 00:00:00 2001 From: Einar Arnason Date: Sun, 6 Feb 2022 12:50:01 +0000 Subject: [PATCH 4/4] Explicitly disable lmsensors in build --- meson_options.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/meson_options.txt b/meson_options.txt index 32c7593ee8e5..a56584491563 100644 --- a/meson_options.txt +++ b/meson_options.txt @@ -367,7 +367,7 @@ option( option( 'lmsensors', type : 'combo', - value : 'auto', + value : 'false', choices : ['auto', 'true', 'false', 'enabled', 'disabled'], description : 'Enable HUD lmsensors support.' )