mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2025-12-20 11:40:10 +01:00
anv/android: query and use explicit layout for ahb resolve
When available, query and use explicit layout info otherwise fallback to implicit layout with tiling query. This fixes aligned layouts of multi-planar formats that were getting misaligned when adding surfaces with implicit layouts. Signed-off-by: Juston Li <justonli@google.com> Reviewed-by: Yiwei Zhang <zzyiwei@chromium.org> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/38039>
This commit is contained in:
parent
c36f0e73ba
commit
cf5c294df4
1 changed files with 38 additions and 23 deletions
|
|
@ -39,6 +39,7 @@
|
||||||
#include "av1_tables.h"
|
#include "av1_tables.h"
|
||||||
|
|
||||||
#define ANV_OFFSET_IMPLICIT UINT64_MAX
|
#define ANV_OFFSET_IMPLICIT UINT64_MAX
|
||||||
|
#define ANV_MAX_PLANES 4
|
||||||
|
|
||||||
static const enum isl_surf_dim
|
static const enum isl_surf_dim
|
||||||
vk_to_isl_surf_dim[] = {
|
vk_to_isl_surf_dim[] = {
|
||||||
|
|
@ -1813,6 +1814,8 @@ anv_image_init(struct anv_device *device, struct anv_image *image,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
image->n_planes = anv_get_format_planes(device->physical, image->vk.format);
|
||||||
|
|
||||||
/* In case of AHardwareBuffer import, we don't know the layout yet */
|
/* In case of AHardwareBuffer import, we don't know the layout yet */
|
||||||
if (image->vk.external_handle_types &
|
if (image->vk.external_handle_types &
|
||||||
VK_EXTERNAL_MEMORY_HANDLE_TYPE_ANDROID_HARDWARE_BUFFER_BIT_ANDROID) {
|
VK_EXTERNAL_MEMORY_HANDLE_TYPE_ANDROID_HARDWARE_BUFFER_BIT_ANDROID) {
|
||||||
|
|
@ -1822,8 +1825,6 @@ anv_image_init(struct anv_device *device, struct anv_image *image,
|
||||||
return VK_SUCCESS;
|
return VK_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
image->n_planes = anv_get_format_planes(device->physical, image->vk.format);
|
|
||||||
|
|
||||||
#ifdef VK_USE_PLATFORM_ANDROID_KHR
|
#ifdef VK_USE_PLATFORM_ANDROID_KHR
|
||||||
/* In the case of gralloc-backed swap chain image, we don't know the
|
/* In the case of gralloc-backed swap chain image, we don't know the
|
||||||
* layout yet.
|
* layout yet.
|
||||||
|
|
@ -2363,31 +2364,45 @@ resolve_ahb_image(struct anv_device *device,
|
||||||
{
|
{
|
||||||
#if DETECT_OS_ANDROID && ANDROID_API_LEVEL >= 26
|
#if DETECT_OS_ANDROID && ANDROID_API_LEVEL >= 26
|
||||||
assert(mem->vk.ahardware_buffer);
|
assert(mem->vk.ahardware_buffer);
|
||||||
AHardwareBuffer_Desc desc;
|
|
||||||
AHardwareBuffer_describe(mem->vk.ahardware_buffer, &desc);
|
|
||||||
VkResult result;
|
VkResult result;
|
||||||
|
|
||||||
/* Check tiling. */
|
VkImageDrmFormatModifierExplicitCreateInfoEXT mod_explicit_info;
|
||||||
enum isl_tiling tiling;
|
VkSubresourceLayout layouts[ANV_MAX_PLANES];
|
||||||
const native_handle_t *handle =
|
result = vk_android_get_ahb_layout(mem->vk.ahardware_buffer,
|
||||||
AHardwareBuffer_getNativeHandle(mem->vk.ahardware_buffer);
|
&mod_explicit_info,
|
||||||
struct u_gralloc_buffer_handle gr_handle = {
|
layouts,
|
||||||
.handle = handle,
|
ANV_MAX_PLANES);
|
||||||
.hal_format = desc.format,
|
if (result == VK_SUCCESS &&
|
||||||
.pixel_stride = desc.stride,
|
mod_explicit_info.drmFormatModifier != DRM_FORMAT_MOD_INVALID) {
|
||||||
};
|
const struct isl_drm_modifier_info *isl_mod_info =
|
||||||
result = anv_android_get_tiling(device, &gr_handle, &tiling);
|
isl_drm_modifier_get_info(mod_explicit_info.drmFormatModifier);
|
||||||
assert(result == VK_SUCCESS);
|
assert(isl_mod_info);
|
||||||
isl_tiling_flags_t isl_tiling_flags = (1u << tiling);
|
isl_tiling_flags_t isl_tiling_flags = (1u << isl_mod_info->tiling);
|
||||||
|
|
||||||
/* Now we are able to fill anv_image fields properly and create
|
result = add_all_surfaces_explicit_layout(device, image, NULL, &mod_explicit_info,
|
||||||
* isl_surface for it.
|
isl_tiling_flags,
|
||||||
*/
|
ISL_SURF_USAGE_DISABLE_AUX_BIT);
|
||||||
image->n_planes = anv_get_format_planes(device->physical, image->vk.format);
|
} else {
|
||||||
|
/* Fall back to implicit layout with tiling query. */
|
||||||
|
AHardwareBuffer_Desc desc;
|
||||||
|
AHardwareBuffer_describe(mem->vk.ahardware_buffer, &desc);
|
||||||
|
enum isl_tiling tiling;
|
||||||
|
const native_handle_t *handle =
|
||||||
|
AHardwareBuffer_getNativeHandle(mem->vk.ahardware_buffer);
|
||||||
|
|
||||||
result = add_all_surfaces_implicit_layout(device, image, NULL, desc.stride,
|
struct u_gralloc_buffer_handle gr_handle = {
|
||||||
isl_tiling_flags,
|
.handle = handle,
|
||||||
ISL_SURF_USAGE_DISABLE_AUX_BIT);
|
.hal_format = desc.format,
|
||||||
|
.pixel_stride = desc.stride,
|
||||||
|
};
|
||||||
|
result = anv_android_get_tiling(device, &gr_handle, &tiling);
|
||||||
|
assert(result == VK_SUCCESS);
|
||||||
|
isl_tiling_flags_t isl_tiling_flags = (1u << tiling);
|
||||||
|
|
||||||
|
result = add_all_surfaces_implicit_layout(device, image, NULL, desc.stride,
|
||||||
|
isl_tiling_flags,
|
||||||
|
ISL_SURF_USAGE_DISABLE_AUX_BIT);
|
||||||
|
}
|
||||||
assert(result == VK_SUCCESS);
|
assert(result == VK_SUCCESS);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue