mirror of https://gitlab.freedesktop.org/mesa/mesa
Both EGL and Vulkan implementations require obtaining buffer metadata, e.g., format, modifier, offsets, strides, etc. Currently, mesa3d doesn't have a generic solution, and every Vulkan implementation uses its getters. Most of the getters rely on kernel metadata storage that is available for x86-based GPU drivers. ARM-based Vulkan drivers rely on userspace metadata sharing, making it important to use advanced metadata API. Otherwise, the driver will work with limited functionality (no YUV, lack of support for modifiers, etc.) Current EGL buffer getter implementation is advanced enough and used as a base for a common Android buffer-getter logic. Use example: void android_buffer_test(android_handle_type *a_handle) { // First, get the gralloc object. It will be created if it doesn't // exist. Use U_GRALLOC_TYPE_AUTO to let the implementation choose // the best gralloc struct u_gralloc *gralloc = u_gralloc_create(U_GRALLOC_TYPE_AUTO); // Prepare the internal handle structure (hal_format and // pixel_stride are required for the fallback implementation). // Both Vulkan and EGL clients expose HAL format / pixel stride // in their structures. u_gralloc_buffer_handle hnd = { .handle = a_handle->native_handle, .hal_format = a_handle->hal_format, .pixel_stride = a_handle->pixel_stride, }; // Get the basic buffer info u_gralloc_buffer_basic_info basic_info; int ret = u_gralloc_get_buffer_basic_info(gralloc, &hnd, &basic_info); if (ret) { // Handle the error } // Get the color info u_gralloc_buffer_color_info color_info; ret = u_gralloc_get_buffer_color_info(gralloc, &hnd, &color_info); if (ret) { // Handle the error } // unref the gralloc object u_gralloc_destroy(&gralloc); } Signed-off-by: Roman Stratiienko <r.stratiienko@gmail.com> Reviewed-by: Chia-I Wu <olvaffe@gmail.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/18215> |
||
---|---|---|
.. | ||
meson.build | ||
u_gralloc.c | ||
u_gralloc.h | ||
u_gralloc_cros_api.c | ||
u_gralloc_fallback.c | ||
u_gralloc_imapper4_api.cpp | ||
u_gralloc_internal.h |