Push offset down to drivers when importing dmabuf. This is needed to more fully support EGL_EXT_image_dma_buf_import when a non-zero offset is specified.
Signed-off-by: Rob Clark <robcl...@freedesktop.org> Signed-off-by: Stanimir Varbanov <stanimir.varba...@linaro.org> --- src/gallium/drivers/i915/i915_resource.c | 4 ++++ src/gallium/drivers/ilo/ilo_resource.c | 4 ++++ src/gallium/drivers/llvmpipe/lp_texture.c | 5 ++++- src/gallium/drivers/nouveau/nv30/nv30_resource.c | 4 ++++ src/gallium/drivers/nouveau/nv50/nv50_resource.c | 4 ++++ src/gallium/drivers/nouveau/nvc0/nvc0_resource.c | 4 ++++ src/gallium/drivers/r300/r300_texture.c | 4 ++++ src/gallium/drivers/radeon/r600_texture.c | 4 ++++ src/gallium/drivers/softpipe/sp_texture.c | 4 ++++ src/gallium/drivers/svga/svga_resource.c | 4 ++++ src/gallium/drivers/vc4/vc4_resource.c | 4 ++++ src/gallium/state_trackers/dri/dri2.c | 6 +----- 12 files changed, 45 insertions(+), 6 deletions(-) diff --git a/src/gallium/drivers/i915/i915_resource.c b/src/gallium/drivers/i915/i915_resource.c index 3ffb0b7a5d23..80e49c218bbd 100644 --- a/src/gallium/drivers/i915/i915_resource.c +++ b/src/gallium/drivers/i915/i915_resource.c @@ -1,4 +1,5 @@ #include "util/u_debug.h" +#include "state_tracker/drm_driver.h" #include "i915_resource.h" #include "i915_context.h" @@ -26,6 +27,9 @@ i915_resource_from_handle(struct pipe_screen * screen, struct winsys_handle *whandle, unsigned usage) { + if (whandle->offset != 0) + return NULL; + if (template->target == PIPE_BUFFER) return NULL; else diff --git a/src/gallium/drivers/ilo/ilo_resource.c b/src/gallium/drivers/ilo/ilo_resource.c index 0afbfc69ee06..3d2db2edc6b3 100644 --- a/src/gallium/drivers/ilo/ilo_resource.c +++ b/src/gallium/drivers/ilo/ilo_resource.c @@ -28,6 +28,7 @@ #include "core/ilo_state_vf.h" #include "core/ilo_state_sol.h" #include "core/ilo_state_surface.h" +#include "state_tracker/drm_driver.h" #include "ilo_screen.h" #include "ilo_format.h" @@ -717,6 +718,9 @@ ilo_resource_from_handle(struct pipe_screen *screen, struct winsys_handle *handle, unsigned usage) { + if (handle->offset != 0) + return NULL; + if (templ->target == PIPE_BUFFER) return NULL; else diff --git a/src/gallium/drivers/llvmpipe/lp_texture.c b/src/gallium/drivers/llvmpipe/lp_texture.c index ee419481d5d8..0b2c10f4e7e5 100644 --- a/src/gallium/drivers/llvmpipe/lp_texture.c +++ b/src/gallium/drivers/llvmpipe/lp_texture.c @@ -52,7 +52,7 @@ #include "lp_rast.h" #include "state_tracker/sw_winsys.h" - +#include "state_tracker/drm_driver.h" #ifdef DEBUG static struct llvmpipe_resource resource_list; @@ -440,6 +440,9 @@ llvmpipe_resource_from_handle(struct pipe_screen *screen, struct sw_winsys *winsys = llvmpipe_screen(screen)->winsys; struct llvmpipe_resource *lpr; + if (whandle->offset != 0) + return NULL; + /* XXX Seems like from_handled depth textures doesn't work that well */ lpr = CALLOC_STRUCT(llvmpipe_resource); diff --git a/src/gallium/drivers/nouveau/nv30/nv30_resource.c b/src/gallium/drivers/nouveau/nv30/nv30_resource.c index 4d215d2e6166..74b8738637a0 100644 --- a/src/gallium/drivers/nouveau/nv30/nv30_resource.c +++ b/src/gallium/drivers/nouveau/nv30/nv30_resource.c @@ -25,6 +25,7 @@ #include "util/u_format.h" #include "util/u_inlines.h" +#include "state_tracker/drm_driver.h" #include "nv30/nv30_screen.h" #include "nv30/nv30_context.h" @@ -69,6 +70,9 @@ nv30_resource_from_handle(struct pipe_screen *pscreen, struct winsys_handle *handle, unsigned usage) { + if (handle->offset != 0) + return NULL; + if (tmpl->target == PIPE_BUFFER) return NULL; else diff --git a/src/gallium/drivers/nouveau/nv50/nv50_resource.c b/src/gallium/drivers/nouveau/nv50/nv50_resource.c index b090a30aed6b..19827ae0fe64 100644 --- a/src/gallium/drivers/nouveau/nv50/nv50_resource.c +++ b/src/gallium/drivers/nouveau/nv50/nv50_resource.c @@ -2,6 +2,7 @@ #include "pipe/p_context.h" #include "util/u_inlines.h" #include "util/u_format.h" +#include "state_tracker/drm_driver.h" #include "nouveau_screen.h" @@ -25,6 +26,9 @@ nv50_resource_from_handle(struct pipe_screen * screen, struct winsys_handle *whandle, unsigned usage) { + if (whandle->offset != 0) + return NULL; + if (templ->target == PIPE_BUFFER) return NULL; else diff --git a/src/gallium/drivers/nouveau/nvc0/nvc0_resource.c b/src/gallium/drivers/nouveau/nvc0/nvc0_resource.c index 0aee5890fd88..7ec5778d39ed 100644 --- a/src/gallium/drivers/nouveau/nvc0/nvc0_resource.c +++ b/src/gallium/drivers/nouveau/nvc0/nvc0_resource.c @@ -1,5 +1,6 @@ #include "pipe/p_context.h" +#include "state_tracker/drm_driver.h" #include "nvc0/nvc0_resource.h" #include "nouveau_screen.h" @@ -22,6 +23,9 @@ nvc0_resource_from_handle(struct pipe_screen * screen, struct winsys_handle *whandle, unsigned usage) { + if (whandle->offset != 0) + return NULL; + if (templ->target == PIPE_BUFFER) { return NULL; } else { diff --git a/src/gallium/drivers/r300/r300_texture.c b/src/gallium/drivers/r300/r300_texture.c index 14372da62e42..c30a43eab052 100644 --- a/src/gallium/drivers/r300/r300_texture.c +++ b/src/gallium/drivers/r300/r300_texture.c @@ -37,6 +37,7 @@ #include "util/u_mm.h" #include "pipe/p_screen.h" +#include "state_tracker/drm_driver.h" /* These formats are supported by swapping their bytes. * The swizzles must be set exactly like their non-swapped counterparts, @@ -1174,6 +1175,9 @@ struct pipe_resource *r300_texture_from_handle(struct pipe_screen *screen, unsigned stride; struct radeon_bo_metadata tiling = {}; + if (whandle->offset != 0) + return NULL; + /* Support only 2D textures without mipmaps */ if ((base->target != PIPE_TEXTURE_2D && base->target != PIPE_TEXTURE_RECT) || diff --git a/src/gallium/drivers/radeon/r600_texture.c b/src/gallium/drivers/radeon/r600_texture.c index 773d67a2f04f..e02a997eb9a7 100644 --- a/src/gallium/drivers/radeon/r600_texture.c +++ b/src/gallium/drivers/radeon/r600_texture.c @@ -29,6 +29,7 @@ #include "util/u_format.h" #include "util/u_memory.h" #include "util/u_pack_color.h" +#include "state_tracker/drm_driver.h" #include <errno.h> #include <inttypes.h> @@ -1113,6 +1114,9 @@ static struct pipe_resource *r600_texture_from_handle(struct pipe_screen *screen struct radeon_bo_metadata metadata = {}; struct r600_texture *rtex; + if (whandle->offset != 0) + return NULL; + /* Support only 2D textures without mipmaps */ if ((templ->target != PIPE_TEXTURE_2D && templ->target != PIPE_TEXTURE_RECT) || templ->depth0 != 1 || templ->last_level != 0) diff --git a/src/gallium/drivers/softpipe/sp_texture.c b/src/gallium/drivers/softpipe/sp_texture.c index 64666fee03f8..dccbf608a381 100644 --- a/src/gallium/drivers/softpipe/sp_texture.c +++ b/src/gallium/drivers/softpipe/sp_texture.c @@ -37,6 +37,7 @@ #include "util/u_math.h" #include "util/u_memory.h" #include "util/u_transfer.h" +#include "state_tracker/drm_driver.h" #include "sp_context.h" #include "sp_flush.h" @@ -226,6 +227,9 @@ softpipe_resource_from_handle(struct pipe_screen *screen, if (!spr) return NULL; + if (whandle->offset != 0) + return NULL; + spr->base = *templat; pipe_reference_init(&spr->base.reference, 1); spr->base.screen = screen; diff --git a/src/gallium/drivers/svga/svga_resource.c b/src/gallium/drivers/svga/svga_resource.c index 264ac335405b..be49396b329e 100644 --- a/src/gallium/drivers/svga/svga_resource.c +++ b/src/gallium/drivers/svga/svga_resource.c @@ -24,6 +24,7 @@ **********************************************************/ #include "util/u_debug.h" +#include "state_tracker/drm_driver.h" #include "svga_resource.h" #include "svga_resource_buffer.h" @@ -50,6 +51,9 @@ svga_resource_from_handle(struct pipe_screen * screen, struct winsys_handle *whandle, unsigned usage) { + if (whandle->offset != 0) + return NULL; + if (template->target == PIPE_BUFFER) return NULL; else diff --git a/src/gallium/drivers/vc4/vc4_resource.c b/src/gallium/drivers/vc4/vc4_resource.c index a360e192b3f4..94b5cabe4c51 100644 --- a/src/gallium/drivers/vc4/vc4_resource.c +++ b/src/gallium/drivers/vc4/vc4_resource.c @@ -28,6 +28,7 @@ #include "util/u_inlines.h" #include "util/u_surface.h" #include "util/u_upload_mgr.h" +#include "state_tracker/drm_driver.h" #include "vc4_screen.h" #include "vc4_context.h" @@ -537,6 +538,9 @@ vc4_resource_from_handle(struct pipe_screen *pscreen, uint32_t expected_stride = align(prsc->width0 / rsc->cpp, vc4_utile_width(rsc->cpp)); + if (handle->offset != 0) + return NULL; + if (!rsc) return NULL; diff --git a/src/gallium/state_trackers/dri/dri2.c b/src/gallium/state_trackers/dri/dri2.c index 78b1b86515e0..457d40eadd93 100644 --- a/src/gallium/state_trackers/dri/dri2.c +++ b/src/gallium/state_trackers/dri/dri2.c @@ -790,8 +790,6 @@ dri2_create_image_from_winsys(__DRIscreen *_screen, templ.depth0 = 1; templ.array_size = 1; - whandle->offset = 0; - img->texture = screen->base.screen->resource_from_handle(screen->base.screen, &templ, whandle, PIPE_HANDLE_USAGE_READ_WRITE); if (!img->texture) { @@ -841,7 +839,7 @@ dri2_create_image_from_fd(__DRIscreen *_screen, int format; __DRIimage *img; - if (num_fds != 1 || offsets[0] != 0) { + if (num_fds != 1) { *error = __DRI_IMAGE_ERROR_BAD_MATCH; return NULL; } @@ -1051,8 +1049,6 @@ dri2_from_names(__DRIscreen *screen, int width, int height, int format, if (num_names != 1) return NULL; - if (offsets[0] != 0) - return NULL; format = convert_fourcc(format, &dri_components); if (format == -1) -- 2.7.4 _______________________________________________ mesa-dev mailing list mesa-dev@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/mesa-dev