diff options
author | Varad Gautam <[email protected]> | 2017-05-30 17:23:47 +0530 |
---|---|---|
committer | Emil Velikov <[email protected]> | 2017-06-09 14:12:37 +0100 |
commit | f84bb6a9d91521de6da4c3d1ddd8de456761efaa (patch) | |
tree | 502684b9c50e877c825fcec95b5243de79149d70 /src/gallium/state_trackers | |
parent | e0965a2c8e0b6ed7de23ce359af14ad74c670e8f (diff) |
st/dri: support format modifier queries
ask the driver for supported modifiers for a given format.
v2: move to __DRIimageExtension v16.
v3: fail if the supplied format is not supported by driver.
v4: purge PIPE_CAP_QUERY_DMABUF_ATTRIBS.
v5:
- move to __DRIimageExtension v15, pass external_only to the driver.
Signed-off-by: Varad Gautam <[email protected]>
Reviewed-by: Lucas Stach <[email protected]> (v4)
Cc: Lucas Stach <[email protected]>
Diffstat (limited to 'src/gallium/state_trackers')
-rw-r--r-- | src/gallium/state_trackers/dri/dri2.c | 24 |
1 files changed, 23 insertions, 1 deletions
diff --git a/src/gallium/state_trackers/dri/dri2.c b/src/gallium/state_trackers/dri/dri2.c index b839f8b7cc1..c5e69d639b1 100644 --- a/src/gallium/state_trackers/dri/dri2.c +++ b/src/gallium/state_trackers/dri/dri2.c @@ -1437,6 +1437,25 @@ dri2_query_dma_buf_formats(__DRIscreen *_screen, int max, int *formats, return true; } +static boolean +dri2_query_dma_buf_modifiers(__DRIscreen *_screen, int fourcc, int max, + uint64_t *modifiers, unsigned int *external_only, + int *count) +{ + struct dri_screen *screen = dri_screen(_screen); + struct pipe_screen *pscreen = screen->base.screen; + enum pipe_format format = fourcc_to_pipe_format(fourcc); + const unsigned usage = PIPE_BIND_RENDER_TARGET | PIPE_BIND_SAMPLER_VIEW; + + if (pscreen->query_dmabuf_modifiers != NULL && + pscreen->is_format_supported(pscreen, format, screen->target, 0, usage)) { + pscreen->query_dmabuf_modifiers(pscreen, format, max, modifiers, + external_only, count); + return true; + } + return false; +} + static __DRIimage * dri2_from_dma_bufs(__DRIscreen *screen, int width, int height, int fourcc, @@ -1603,7 +1622,7 @@ dri2_get_capabilities(__DRIscreen *_screen) /* The extension is modified during runtime if DRI_PRIME is detected */ static __DRIimageExtension dri2ImageExtension = { - .base = { __DRI_IMAGE, 14 }, + .base = { __DRI_IMAGE, 15 }, .createImageFromName = dri2_create_image_from_name, .createImageFromRenderbuffer = dri2_create_image_from_renderbuffer, @@ -2033,6 +2052,8 @@ dri2_init_screen(__DRIscreen * sPriv) dri2ImageExtension.createImageFromDmaBufs = dri2_from_dma_bufs; dri2ImageExtension.createImageFromDmaBufs2 = dri2_from_dma_bufs2; dri2ImageExtension.queryDmaBufFormats = dri2_query_dma_buf_formats; + dri2ImageExtension.queryDmaBufModifiers = + dri2_query_dma_buf_modifiers; } } @@ -2111,6 +2132,7 @@ dri_kms_init_screen(__DRIscreen * sPriv) dri2ImageExtension.createImageFromDmaBufs = dri2_from_dma_bufs; dri2ImageExtension.createImageFromDmaBufs2 = dri2_from_dma_bufs2; dri2ImageExtension.queryDmaBufFormats = dri2_query_dma_buf_formats; + dri2ImageExtension.queryDmaBufModifiers = dri2_query_dma_buf_modifiers; } sPriv->extensions = dri_screen_extensions; |