From ea7880478e878debc5ea1f901930fa7a2c938427 Mon Sep 17 00:00:00 2001 From: Weifeng Liu Date: Tue, 14 May 2024 14:00:08 +0000 Subject: [PATCH] anv/anroid: Query gralloc for tiling mode MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Tiled scan-out buffer works only for those platforms supporting set_tiling/get_tiling ioctl, which is not used for newer platforms (e.g., dGPU). This change switch to querying modifier reliably with gralloc API. Signed-off-by: Weifeng Liu Reviewed-by: Tapani Pälli Reviewed-by: Lionel Landwerlin Part-of: --- src/intel/vulkan/anv_android.c | 27 +++++++++++++++++++++++---- 1 file changed, 23 insertions(+), 4 deletions(-) diff --git a/src/intel/vulkan/anv_android.c b/src/intel/vulkan/anv_android.c index 2cea3fc9f36..b3405f6c96f 100644 --- a/src/intel/vulkan/anv_android.c +++ b/src/intel/vulkan/anv_android.c @@ -359,10 +359,29 @@ anv_image_init_from_gralloc(struct anv_device *device, } enum isl_tiling tiling; - result = anv_device_get_bo_tiling(device, bo, &tiling); - if (result != VK_SUCCESS) { - return vk_errorf(device, result, - "failed to get tiling from VkNativeBufferANDROID"); + if (device->u_gralloc) { + struct u_gralloc_buffer_basic_info buf_info; + struct u_gralloc_buffer_handle gr_handle = { + .handle = gralloc_info->handle, + .hal_format = gralloc_info->format, + .pixel_stride = gralloc_info->stride, + }; + u_gralloc_get_buffer_basic_info(device->u_gralloc, &gr_handle, &buf_info); + const struct isl_drm_modifier_info *mod_info = + isl_drm_modifier_get_info(buf_info.modifier); + if (mod_info) { + tiling = mod_info->tiling; + } else { + return vk_errorf(device, VK_ERROR_INVALID_EXTERNAL_HANDLE, + "unknown modifier of BO from VkNativeBufferANDROID"); + } + } else { + /* Fallback to get_tiling API. */ + result = anv_device_get_bo_tiling(device, bo, &tiling); + if (result != VK_SUCCESS) { + return vk_errorf(device, result, + "failed to get tiling from VkNativeBufferANDROID"); + } } anv_info.isl_tiling_flags = 1u << tiling;