From: Varad Gautam <varadgau...@gmail.com> v2: Rebase and reuse tiling/modifier map. (Daniel Stone)
Signed-off-by: Varad Gautam <varadgau...@gmail.com> Signed-off-by: Daniel Stone <dani...@collabora.com> --- src/mesa/drivers/dri/i965/intel_screen.c | 59 +++++++++++++++++++++++++++++--- 1 file changed, 54 insertions(+), 5 deletions(-) diff --git a/src/mesa/drivers/dri/i965/intel_screen.c b/src/mesa/drivers/dri/i965/intel_screen.c index f366fc4d4d..0c79246311 100644 --- a/src/mesa/drivers/dri/i965/intel_screen.c +++ b/src/mesa/drivers/dri/i965/intel_screen.c @@ -293,6 +293,7 @@ static struct intel_image_format intel_image_formats[] = { static const struct { uint32_t tiling; uint64_t modifier; + unsigned since_gen; unsigned height_align; unsigned aux_w_block; unsigned aux_w_align; @@ -300,13 +301,13 @@ static const struct { unsigned aux_h_align; } tiling_modifier_map[] = { { .tiling = I915_TILING_NONE, .modifier = DRM_FORMAT_MOD_LINEAR, - .height_align = 1 }, + .since_gen = 1, .height_align = 1 }, { .tiling = I915_TILING_X, .modifier = I915_FORMAT_MOD_X_TILED, - .height_align = 8 }, + .since_gen = 1, .height_align = 8 }, { .tiling = I915_TILING_Y, .modifier = I915_FORMAT_MOD_Y_TILED, - .height_align = 32 }, + .since_gen = 9, .height_align = 32 }, { .tiling = I915_TILING_Y, .modifier = /* I915_FORMAT_MOD_Y_TILED_CCS */ fourcc_mod_code(INTEL, 4), - .height_align = 32, .aux_w_block = 32, .aux_w_align = 128, + .since_gen = 9, .height_align = 32, .aux_w_block = 32, .aux_w_align = 128, .aux_h_block = 16, .aux_h_align = 32 }, }; @@ -1113,6 +1114,52 @@ intel_create_image_from_dma_bufs2(__DRIscreen *dri_screen, loaderPrivate); } +static GLboolean +intel_query_dma_buf_formats(__DRIscreen *screen, int max, + int *formats, int *count) +{ + int i, j = 0; + + if (max == 0) { + *count = ARRAY_SIZE(intel_image_formats) - 1; /* not SARGB */ + return true; + } + + for (i = 0; i < (ARRAY_SIZE(intel_image_formats)) && j < max; i++) { + if (intel_image_formats[i].fourcc == __DRI_IMAGE_FOURCC_SARGB8888) + continue; + formats[j++] = intel_image_formats[i].fourcc; + } + + *count = j; + return true; +} + +static GLboolean +intel_query_dma_buf_modifiers(__DRIscreen *_screen, int fourcc, int max, + uint64_t *modifiers, int *count) +{ + struct intel_screen *screen = _screen->driverPrivate; + int num_mods = 0, i; + + if (!intel_image_format_lookup(fourcc)) + return false; + + for (i = 0; i < ARRAY_SIZE(tiling_modifier_map); i++) { + if (screen->devinfo.gen < tiling_modifier_map[i].since_gen) + continue; + + num_mods++; + if (num_mods >= max) + continue; + + modifiers[num_mods] = tiling_modifier_map[i].modifier; + } + + *count = num_mods; + return true; +} + static __DRIimage * intel_from_planar(__DRIimage *parent, int plane, void *loaderPrivate) { @@ -1173,7 +1220,7 @@ intel_from_planar(__DRIimage *parent, int plane, void *loaderPrivate) } static const __DRIimageExtension intelImageExtension = { - .base = { __DRI_IMAGE, 15 }, + .base = { __DRI_IMAGE, 16 }, .createImageFromName = intel_create_image_from_name, .createImageFromRenderbuffer = intel_create_image_from_renderbuffer, @@ -1193,6 +1240,8 @@ static const __DRIimageExtension intelImageExtension = { .unmapImage = NULL, .createImageWithModifiers = intel_create_image_with_modifiers, .createImageFromDmaBufs2 = intel_create_image_from_dma_bufs2, + .queryDmaBufFormats = intel_query_dma_buf_formats, + .queryDmaBufModifiers = intel_query_dma_buf_modifiers, }; static uint64_t -- 2.13.0 _______________________________________________ mesa-dev mailing list mesa-dev@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/mesa-dev