[Mesa-dev] [PATCH 06/16] dri: Add createImageWithModifiers2 to DRIimageExtension
Jason Ekstrand
jason at jlekstrand.net
Fri Feb 9 23:53:53 UTC 2018
On Fri, Feb 9, 2018 at 3:43 PM, Jason Ekstrand <jason at jlekstrand.net> wrote:
> From: Louis-Francis Ratté-Boulianne <lfrb at collabora.com>
>
> It does the same as createImagewithModifiers but allow multiple
> modifiers set to be given. The modifier used to create the image
> should be selected from the first tranche if possible. If not,
> then the subsequent tranches should be used.
>
> Signed-off-by: Louis-Francis Ratté-Boulianne <lfrb at collabora.com>
> ---
> include/GL/internal/dri_interface.h | 19 +++++++++++++++-
> src/mesa/drivers/dri/i965/intel_screen.c | 38
> ++++++++++++++++++++++++--------
> 2 files changed, 47 insertions(+), 10 deletions(-)
>
> diff --git a/include/GL/internal/dri_interface.h
> b/include/GL/internal/dri_interface.h
> index be12918..11a64f0 100644
> --- a/include/GL/internal/dri_interface.h
> +++ b/include/GL/internal/dri_interface.h
> @@ -1220,7 +1220,7 @@ struct __DRIdri2ExtensionRec {
> * extensions.
> */
> #define __DRI_IMAGE "DRI_IMAGE"
> -#define __DRI_IMAGE_VERSION 18
> +#define __DRI_IMAGE_VERSION 19
>
> /**
> * These formats correspond to the similarly named MESA_FORMAT_*
> @@ -1699,6 +1699,23 @@ struct __DRIimageExtensionRec {
> * \since 18
> */
> void (*suppressImplicitSync)(__DRIimage *image);
> +
> +
> + /**
> + * Like createImageWithModifiers, but can take multiple tranches/sets
> of
> + * modifiers according to the priority for which they should be
> selected.
> + *
> + * Modifier should be selected from the first tranche, from the second
> + * one if not possible, etc.
> + *
> + * \since 19
> + */
> + __DRIimage *(*createImageWithModifiers2)(__DRIscreen *screen,
> + int width, int height, int
> format,
> + const uint64_t **modifiers,
> + const unsigned int *counts,
> + const unsigned tranches_count,
> + void *loaderPrivate);
>
I don't think this is really needed. We have queryDmaBufModifiers so the
user of the DRI interface could call that, determine which of the trances
is the first with a supported modifier, and then just call it it with a
single modifier list. Given that this is on the image create path, the
extra time it takes to make a quick list isn't bad. This is what I did for
the Vulkan version and it worked out ok.
> };
>
>
> diff --git a/src/mesa/drivers/dri/i965/intel_screen.c
> b/src/mesa/drivers/dri/i965/intel_screen.c
> index 9a54f27..131bffe 100644
> --- a/src/mesa/drivers/dri/i965/intel_screen.c
> +++ b/src/mesa/drivers/dri/i965/intel_screen.c
> @@ -647,20 +647,22 @@ static __DRIimage *
> intel_create_image_common(__DRIscreen *dri_screen,
> int width, int height, int format,
> unsigned int use,
> - const uint64_t *modifiers,
> - unsigned count,
> + const uint64_t **modifiers,
> + const unsigned *counts,
> + const unsigned tranches_count,
> void *loaderPrivate)
> {
> __DRIimage *image;
> struct intel_screen *screen = dri_screen->driverPrivate;
> uint64_t modifier = DRM_FORMAT_MOD_INVALID;
> bool ok;
> + int i;
>
> /* Callers of this may specify a modifier, or a dri usage, but not
> both. The
> * newer modifier interface deprecates the older usage flags newer
> modifier
> * interface deprecates the older usage flags.
> */
> - assert(!(use && count));
> + assert(!(use && tranches_count));
>
> if (use & __DRI_IMAGE_USE_CURSOR) {
> if (width != 64 || height != 64)
> @@ -672,10 +674,14 @@ intel_create_image_common(__DRIscreen *dri_screen,
> modifier = DRM_FORMAT_MOD_LINEAR;
>
> if (modifier == DRM_FORMAT_MOD_INVALID) {
> - if (modifiers) {
> + if (tranches_count > 0 && counts && modifiers && modifiers[0]) {
> /* User requested specific modifiers */
> - modifier = select_best_modifier(&screen->devinfo, format,
> - modifiers, count);
> + for (i = 0; i < tranches_count; i++) {
> + modifier = select_best_modifier(&screen->devinfo, format,
> + modifiers[i], counts[i]);
> + if (modifier != DRM_FORMAT_MOD_INVALID)
> + break;
> + }
> if (modifier == DRM_FORMAT_MOD_INVALID)
> return NULL;
> } else {
> @@ -761,7 +767,7 @@ intel_create_image(__DRIscreen *dri_screen,
> unsigned int use,
> void *loaderPrivate)
> {
> - return intel_create_image_common(dri_screen, width, height, format,
> use, NULL, 0,
> + return intel_create_image_common(dri_screen, width, height, format,
> use, NULL, NULL, 0,
> loaderPrivate);
> }
>
> @@ -834,7 +840,20 @@ intel_create_image_with_modifiers(__DRIscreen
> *dri_screen,
> void *loaderPrivate)
> {
> return intel_create_image_common(dri_screen, width, height, format, 0,
> - modifiers, count, loaderPrivate);
> + &modifiers, &count, 1, loaderPrivate);
> +}
> +
> +static __DRIimage *
> +intel_create_image_with_modifiers2(__DRIscreen *dri_screen,
> + int width, int height, int format,
> + const uint64_t **modifiers,
> + const unsigned *counts,
> + const unsigned tranches_count,
> + void *loaderPrivate)
> +{
> + return intel_create_image_common(dri_screen, width, height, format, 0,
> + modifiers, counts, tranches_count,
> + loaderPrivate);
> }
>
> static GLboolean
> @@ -1376,7 +1395,7 @@ intel_image_suppress_implicit_sync(__DRIimage
> *image)
> }
>
> static __DRIimageExtension intelImageExtension = {
> - .base = { __DRI_IMAGE, 18 },
> + .base = { __DRI_IMAGE, 19 },
>
> .createImageFromName = intel_create_image_from_name,
> .createImageFromRenderbuffer = intel_create_image_from_
> renderbuffer,
> @@ -1401,6 +1420,7 @@ static __DRIimageExtension intelImageExtension = {
> .queryDmaBufFormatModifierAttribs = intel_query_format_modifier_
> attribs,
> .createImageFromRenderbuffer2 = NULL,
> .suppressImplicitSync = NULL,
> + .createImageWithModifiers2 = intel_create_image_with_
> modifiers2,
> };
>
> static uint64_t
> --
> 2.5.0.400.gff86faf
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.freedesktop.org/archives/mesa-dev/attachments/20180209/5dbead13/attachment-0001.html>
More information about the mesa-dev
mailing list