summaryrefslogtreecommitdiffstats
path: root/src/gallium/drivers/lima
diff options
context:
space:
mode:
authorQiang Yu <[email protected]>2020-03-28 14:09:22 +0800
committerMarge Bot <[email protected]>2020-03-31 01:40:29 +0000
commite46b2ef7243a7f916b7d77f3495bea26f4f24d62 (patch)
tree4a0937ff1a09e98ac83c1c89ead06c3dc90bfd03 /src/gallium/drivers/lima
parent02ad147c5c80a124630992ae6c5ae705c6c68bed (diff)
lima: fix buffer import with offset
With EGL_EXT_image_dma_buf_import, user can import dma_buf with offset. This is also used by AOSP GLConsumer::updateTexImage with HAL_PIXEL_FORMAT_YV12 buffer which store YUV planes in the same buffer with offset. Render sample from it using GL_OES_EGL_image_external. This should fix some video display problem when using MediaCodec soft decoding which generates HAL_PIXEL_FORMAT_YV12 buffer and render it on screen. Test program: https://github.com/yuq/gfx/tree/master/yuv2rgb/dma-buf Reviewed-by: Vasily Khoruzhick <[email protected]> Signed-off-by: Qiang Yu <[email protected]> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/4362>
Diffstat (limited to 'src/gallium/drivers/lima')
-rw-r--r--src/gallium/drivers/lima/lima_resource.c19
1 files changed, 15 insertions, 4 deletions
diff --git a/src/gallium/drivers/lima/lima_resource.c b/src/gallium/drivers/lima/lima_resource.c
index bd3549db448..fb416652e53 100644
--- a/src/gallium/drivers/lima/lima_resource.c
+++ b/src/gallium/drivers/lima/lima_resource.c
@@ -291,10 +291,20 @@ lima_resource_from_handle(struct pipe_screen *pscreen,
const struct pipe_resource *templat,
struct winsys_handle *handle, unsigned usage)
{
- struct lima_resource *res;
- struct lima_screen *screen = lima_screen(pscreen);
+ if (templat->bind & (PIPE_BIND_SAMPLER_VIEW |
+ PIPE_BIND_RENDER_TARGET |
+ PIPE_BIND_DEPTH_STENCIL)) {
+ /* sampler hardware need offset alignment 64, while render hardware
+ * need offset alignment 8, but due to render target may be reloaded
+ * which uses the sampler, set alignment requrement to 64 for all
+ */
+ if (handle->offset & 0x3f) {
+ debug_error("import buffer offset not properly aligned\n");
+ return NULL;
+ }
+ }
- res = CALLOC_STRUCT(lima_resource);
+ struct lima_resource *res = CALLOC_STRUCT(lima_resource);
if (!res)
return NULL;
@@ -302,9 +312,10 @@ lima_resource_from_handle(struct pipe_screen *pscreen,
*pres = *templat;
pres->screen = pscreen;
pipe_reference_init(&pres->reference, 1);
- res->levels[0].offset = 0;
+ res->levels[0].offset = handle->offset;
res->levels[0].stride = handle->stride;
+ struct lima_screen *screen = lima_screen(pscreen);
res->bo = lima_bo_import(screen, handle);
if (!res->bo) {
FREE(res);