1
0
Fork 0

Fix: Video PlayBack

AOSP requires lock_ybcr() for video playback or else EGL image wouldn't form(black screen while playing video) and gives error EGLImage: Error: 0x3000 and in some cases, a crash and a surfaceFlinger restart. To resolve this, U_gralloc element needs to be built with -dFlag Imapper4_API and Imapper5.c, which exposes the required API for gralloc to consider video buffer from hwaccel or even swaccel vid decoders.
This commit is contained in:
dvab-sarma 2025-10-20 01:16:05 -05:00
parent 809f6758c3
commit 4f43376654
7 changed files with 4140 additions and 23 deletions

View file

@ -1816,7 +1816,7 @@ cc_library_shared {
"meson_generated/src/panfrost/vulkan/panvk_tracepoints.c",
],
cflags: ["-DVK_USE_PLATFORM_ANDROID_KHR"],
ldflags: ["-Wl,--build-id=sha1"],
ldflags: ["-Wl,--build-id=sha1","-Wl,-Bsymbolic",],
shared_libs: [
"libcutils",
"libdrm",
@ -1824,6 +1824,7 @@ cc_library_shared {
"liblog",
"libnativewindow",
"libsync",
"libui",
"libz",
],
static_libs: [
@ -2135,7 +2136,11 @@ cc_library_static {
cc_library_static {
name: "mesa3d-panfrost_src_util_u_gralloc_lib_mesa_u_gralloc_a",
srcs: ["src/util/u_gralloc/*.c"],
srcs: ["src/util/u_gralloc/*.c",
"src/util/u_gralloc/u_gralloc_imapper5_api.cpp",
],
cflags: ["-DUSE_IMAPPER4_METADATA_API"],
shared_libs: ["libui"],
local_include_dirs: [
"include",
"include/android_stub",
@ -3905,6 +3910,7 @@ cc_library_shared {
"-DHAVE_MINCORE",
"-D_EGL_NATIVE_PLATFORM=_EGL_PLATFORM_ANDROID",
],
ldflags: ["-Wl,-Bsymbolic"],
shared_libs: [
"libcutils",
"libdrm",
@ -3913,6 +3919,7 @@ cc_library_shared {
"liblog",
"libnativewindow",
"libsync",
"libui",
"libz",
],
static_libs: [
@ -3946,7 +3953,9 @@ cc_library_shared {
"meson_generated/src/util",
"meson_generated/src/util/format",
],
relative_install_path: "egl",
header_libs: ["libnativebase_headers"],
defaults: ["mesa3d-desktop-panvk-defaults"],
}
@ -4039,14 +4048,14 @@ cc_defaults {
"-DTHREAD_SANITIZER=0",
"-DUSE_GCC_ATOMIC_BUILTINS",
"-DUSE_LIBGLVND=0",
"-DVIDEO_CODEC_AV1DEC=0",
"-DVIDEO_CODEC_AV1DEC=1",
"-DVIDEO_CODEC_AV1ENC=0",
"-DVIDEO_CODEC_H264DEC=0",
"-DVIDEO_CODEC_H264ENC=0",
"-DVIDEO_CODEC_H265DEC=0",
"-DVIDEO_CODEC_H265ENC=0",
"-DVIDEO_CODEC_VC1DEC=0",
"-DVIDEO_CODEC_VP9DEC=0",
"-DVIDEO_CODEC_VP9DEC=1",
"-D_FILE_OFFSET_BITS=64",
"-D_GNU_SOURCE",
"-D__STDC_CONSTANT_MACROS",

4077
Android.bp.disabled Normal file

File diff suppressed because it is too large Load diff

View file

@ -292,7 +292,8 @@ struct dri2_egl_display {
#ifdef HAVE_ANDROID_PLATFORM
struct u_gralloc *gralloc;
/* gralloc vendor usage bit for front rendering */
uint32_t front_rendering_usage;
//uint32_t front_rendering_usage;
uint64_t front_rendering_usage;
bool has_native_fence_fd;
bool pure_swrast;
#endif
@ -380,7 +381,9 @@ struct dri2_egl_surface {
struct ANativeWindowBuffer *buffer;
int age;
} *color_buffers, *back;
uint32_t gralloc_usage;
//uint32_t gralloc_usage;
uint64_t gralloc_usage;
#endif
/* surfaceless and device */

View file

@ -230,7 +230,7 @@ droid_window_cancel_buffer(struct dri2_egl_surface *dri2_surf)
static bool
droid_set_shared_buffer_mode(_EGLDisplay *disp, _EGLSurface *surf, bool mode)
{
#if ANDROID_API_LEVEL >= 24
// #if ANDROID_API_LEVEL >= 24
struct dri2_egl_display *dri2_dpy = dri2_egl_display(disp);
struct dri2_egl_surface *dri2_surf = dri2_egl_surface(surf);
struct ANativeWindow *window = dri2_surf->window;
@ -261,11 +261,11 @@ droid_set_shared_buffer_mode(_EGLDisplay *disp, _EGLSurface *surf, bool mode)
}
return true;
#else
_eglLog(_EGL_FATAL, "%s:%d: internal error: unreachable", __FILE__,
__LINE__);
return false;
#endif
// #else
// _eglLog(_EGL_FATAL, "%s:%d: internal error: unreachable", __FILE__,
// __LINE__);
// return false;
// #endif
}
static _EGLSurface *
@ -672,6 +672,12 @@ droid_swap_buffers(_EGLDisplay *disp, _EGLSurface *draw)
draw->ActiveRenderBuffer = draw->RequestedRenderBuffer;
}
/* Optimization: Dequeue the buffer for a next frame:
* This reduces CPU time spent by next frame on a road
* from start-of-frame event to GPU job-submit event.
*/
update_buffers(dri2_surf);
return EGL_TRUE;
}
@ -1245,7 +1251,7 @@ dri2_initialize_android(_EGLDisplay *disp)
disp->Extensions.KHR_image = EGL_TRUE;
dri2_dpy->front_rendering_usage = 0;
#if ANDROID_API_LEVEL >= 24
// #if ANDROID_API_LEVEL >= 24
if (!dri2_dpy->swrast_not_kms &&
dri2_dpy->loader_extensions == droid_image_loader_extensions &&
/* In big GL, front rendering is done at the core API level by directly
@ -1259,6 +1265,12 @@ dri2_initialize_android(_EGLDisplay *disp)
*/
(disp->ClientAPIs & ~(EGL_OPENGL_ES_BIT | EGL_OPENGL_ES2_BIT |
EGL_OPENGL_ES3_BIT_KHR)) == 0) {
#if ANDROID_API_LEVEL >= 33
/* align with BufferUsage::FRONT_BUFFER */
dri2_dpy->front_rendering_usage = 1UL << 32;
disp->Extensions.KHR_mutable_render_buffer = EGL_TRUE;
#else
/* For cros gralloc, if the front rendering query is supported, then all
* available window surface configs support front rendering because:
*
@ -1280,8 +1292,9 @@ dri2_initialize_android(_EGLDisplay *disp)
dri2_dpy->front_rendering_usage = front_rendering_usage;
disp->Extensions.KHR_mutable_render_buffer = EGL_TRUE;
}
}
#endif
}
/* Create configs *after* enabling extensions because presence of DRI
* driver extensions can affect the capabilities of EGLConfigs.

View file

@ -262,8 +262,11 @@ struct pan_image_usage {
/* Image frequently updated with host data. */
bool frequent_host_updates;
/* Scanout image. */
bool scanout;
// /* Scanout image. */
//change here
// bool scanout;
bool legacy_scanout;
bool wsi;
};
static inline enum pan_mod_support

View file

@ -248,7 +248,9 @@ pan_mod_afbc_test_props(const struct pan_kmod_dev_props *dprops,
return PAN_MOD_NOT_OPTIMAL;
/* Reserve 32x8 tiles for scanout buffers. */
if (iusage && !iusage->scanout &&
//change here
// if (iusage && !iusage->scanout &&
if(iusage && !iusage->wsi &&
pan_afbc_superblock_width(iprops->modifier) != 16)
return PAN_MOD_NOT_OPTIMAL;
@ -266,12 +268,12 @@ pan_mod_afbc_test_props(const struct pan_kmod_dev_props *dprops,
if (is_tiled && !can_tile)
return PAN_MOD_NOT_SUPPORTED;
/* Prefer tiled headers when the image is big enough. */
bool should_tile =
iprops->extent_px.width >= 128 && iprops->extent_px.height >= 128;
// /* Prefer tiled headers when the image is big enough. */
// bool should_tile =
// iprops->extent_px.width >= 128 && iprops->extent_px.height >= 128;
if (is_tiled != should_tile)
return PAN_MOD_NOT_OPTIMAL;
// if (is_tiled != should_tile)
// return PAN_MOD_NOT_OPTIMAL;
/* Packing/unpacking AFBC payload requires a COMPUTE job which we'd rather
* avoid.

View file

@ -125,7 +125,10 @@ get_iusage(struct panvk_image *image, const VkImageCreateInfo *create_info)
iusage.host_copy =
!!(image->vk.usage & VK_IMAGE_USAGE_HOST_TRANSFER_BIT_EXT);
iusage.scanout = wsi_info && wsi_info->scanout;
//iusage.scanout = wsi_info && wsi_info->scanout;
iusage.legacy_scanout = wsi_info && wsi_info->scanout;
iusage.wsi = wsi_info != NULL;
return iusage;
}
@ -368,6 +371,13 @@ panvk_image_get_mod(struct panvk_image *image,
assert(!"Missing modifier info");
}
//change here
/* legacy scanout (images without any external modifier info) should default to LINEAR. */
if (iusage.legacy_scanout)
return DRM_FORMAT_MOD_LINEAR;
/* Without external dependencies, pick the best modifier that supports the image. */
return panvk_image_get_mod_from_list(image, &iusage, NULL, 0);
}