Skip to content

Commit

Permalink
anv/anroid: Query gralloc for tiling mode
Browse files Browse the repository at this point in the history
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.

Tracked-On: OAM-119908
Signed-off-by: Weifeng Liu <[email protected]>
Reviewed-by: Tapani Pälli <[email protected]>
Reviewed-by: Lionel Landwerlin <[email protected]>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/29185>
  • Loading branch information
phreer authored and celadon committed May 31, 2024
1 parent c4282b8 commit d316935
Showing 1 changed file with 23 additions and 4 deletions.
27 changes: 23 additions & 4 deletions src/intel/vulkan/anv_android.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down

0 comments on commit d316935

Please sign in to comment.