From be347863baa8de0ed47da0ad4f85ad9c255ca5c5 Mon Sep 17 00:00:00 2001 From: Gurchetan Singh Date: Mon, 13 Jan 2020 16:07:38 -0800 Subject: [PATCH] st/dri: track if image is created by a dmabuf MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Will be used by EXT_EGL_image_storage later. Acked-by: Marek Olšák Part-of: --- src/gallium/include/state_tracker/st_api.h | 2 ++ src/gallium/state_trackers/dri/dri2.c | 1 + src/gallium/state_trackers/dri/dri_screen.c | 8 ++++++++ src/gallium/state_trackers/dri/dri_screen.h | 1 + 4 files changed, 12 insertions(+) diff --git a/src/gallium/include/state_tracker/st_api.h b/src/gallium/include/state_tracker/st_api.h index 258da8fdeaf..0b953d6fb38 100644 --- a/src/gallium/include/state_tracker/st_api.h +++ b/src/gallium/include/state_tracker/st_api.h @@ -182,6 +182,8 @@ struct st_egl_image unsigned level; unsigned layer; + /* GL internal format. */ + unsigned internalformat; }; /** diff --git a/src/gallium/state_trackers/dri/dri2.c b/src/gallium/state_trackers/dri/dri2.c index 490c4b16f03..54a05c916f1 100644 --- a/src/gallium/state_trackers/dri/dri2.c +++ b/src/gallium/state_trackers/dri/dri2.c @@ -938,6 +938,7 @@ dri2_create_image_from_fd(__DRIscreen *_screen, img->dri_components = map->dri_components; img->dri_fourcc = fourcc; img->dri_format = map->dri_format; + img->imported_dmabuf = TRUE; exit: if (error) diff --git a/src/gallium/state_trackers/dri/dri_screen.c b/src/gallium/state_trackers/dri/dri_screen.c index 8600ce029f0..5a9acd818d0 100644 --- a/src/gallium/state_trackers/dri/dri_screen.c +++ b/src/gallium/state_trackers/dri/dri_screen.c @@ -473,6 +473,14 @@ dri_get_egl_image(struct st_manager *smapi, stimg->level = img->level; stimg->layer = img->layer; + if (img->imported_dmabuf && map) { + /* Guess sized internal format for dma-bufs. Could be used + * by EXT_EGL_image_storage. + */ + mesa_format mesa_format = driImageFormatToGLFormat(map->dri_format); + stimg->internalformat = driGLFormatToSizedInternalGLFormat(mesa_format); + } + return TRUE; } diff --git a/src/gallium/state_trackers/dri/dri_screen.h b/src/gallium/state_trackers/dri/dri_screen.h index 4a80d96df95..1586439bba3 100644 --- a/src/gallium/state_trackers/dri/dri_screen.h +++ b/src/gallium/state_trackers/dri/dri_screen.h @@ -109,6 +109,7 @@ struct __DRIimageRec { void *loader_private; + boolean imported_dmabuf; /** * Provided by EGL_EXT_image_dma_buf_import. */ -- 2.30.2