From b9ecaac78ac4854fa9157ae19cc9b3f83d296a3f Mon Sep 17 00:00:00 2001 From: David Stevens Date: Wed, 23 Oct 2019 16:58:47 +0900 Subject: [PATCH] vrend: skip texture size check for gbm-only resources Gbm-resources can be used for data blobs. These are created with a height of 1 and the required width, which can easily exceed the maximum supported texture width. Signed-off-by: David Stevens Reviewed-by: Gert Wollny --- src/virgl_gbm.c | 9 +++++++++ src/virgl_gbm.h | 3 +++ src/vrend_renderer.c | 10 ++++++++-- 3 files changed, 20 insertions(+), 2 deletions(-) diff --git a/src/virgl_gbm.c b/src/virgl_gbm.c index ef22fa8..2f135eb 100644 --- a/src/virgl_gbm.c +++ b/src/virgl_gbm.c @@ -483,3 +483,12 @@ int virgl_gbm_get_plane_bytes_per_pixel(struct gbm_bo *bo, int plane) { return -1; return layout->bytes_per_pixel[plane]; } + +bool virgl_gbm_external_allocation_preferred(uint32_t flags) { + return (flags & (VIRGL_RES_BIND_SCANOUT | VIRGL_RES_BIND_SHARED)) != 0; +} + +bool virgl_gbm_gpu_import_required(uint32_t flags) { + return !virgl_gbm_external_allocation_preferred(flags) || + (flags & (VIRGL_BIND_RENDER_TARGET | VIRGL_BIND_SAMPLER_VIEW)) != 0; +} diff --git a/src/virgl_gbm.h b/src/virgl_gbm.h index 08469fe..dba7a4d 100644 --- a/src/virgl_gbm.h +++ b/src/virgl_gbm.h @@ -64,4 +64,7 @@ int virgl_gbm_get_plane_width(struct gbm_bo *bo, int plane); int virgl_gbm_get_plane_height(struct gbm_bo *bo, int plane); int virgl_gbm_get_plane_bytes_per_pixel(struct gbm_bo *bo, int plane); +bool virgl_gbm_external_allocation_preferred(uint32_t flags); +bool virgl_gbm_gpu_import_required(uint32_t flags); + #endif diff --git a/src/vrend_renderer.c b/src/vrend_renderer.c index 57ee587..d2e6bc9 100644 --- a/src/vrend_renderer.c +++ b/src/vrend_renderer.c @@ -6203,6 +6203,12 @@ static int check_resource_valid(struct vrend_renderer_resource_create_args *args return -1; } +#ifdef ENABLE_GBM_ALLOCATION + if (!virgl_gbm_gpu_import_required(args->bind)) { + return 0; + } +#endif + if (args->target == PIPE_TEXTURE_2D || args->target == PIPE_TEXTURE_RECT || args->target == PIPE_TEXTURE_CUBE || @@ -6331,7 +6337,7 @@ static void vrend_resource_gbm_init(struct vrend_resource *gr) if (!gbm || !gbm->device || !gbm_format || !gbm_flags) return; - if ((gr->base.bind & (VIRGL_RES_BIND_SCANOUT | VIRGL_RES_BIND_SHARED)) == 0) + if (!virgl_gbm_external_allocation_preferred(gr->base.bind)) return; if (!gbm_device_is_format_supported(gbm->device, gbm_format, gbm_flags)) @@ -6343,7 +6349,7 @@ static void vrend_resource_gbm_init(struct vrend_resource *gr) return; gr->gbm_bo = bo; - if ((gr->base.bind & (VIRGL_BIND_RENDER_TARGET | VIRGL_BIND_SAMPLER_VIEW)) == 0) { + if (!virgl_gbm_gpu_import_required(gr->base.bind)) { gr->storage = VREND_RESOURCE_STORAGE_GBM_ONLY; return; }