radeonsi: support importing arbitrary resources

Reviewed-by: Marek Olšák <marek.olsak@amd.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/21305>
This commit is contained in:
Karol Herbst 2023-09-26 22:21:36 +02:00 committed by Marge Bot
parent 7e031078dd
commit 56f934103d

View file

@ -301,7 +301,7 @@ static int si_init_surface(struct si_screen *sscreen, struct radeon_surf *surfac
if (is_scanout) {
/* This should catch bugs in gallium users setting incorrect flags. */
assert(ptex->nr_samples <= 1 && ptex->array_size == 1 && ptex->depth0 == 1 &&
assert(ptex->nr_samples <= 1 && ptex->depth0 == 1 &&
ptex->last_level == 0 && !(flags & RADEON_SURF_Z_OR_SBUFFER));
flags |= RADEON_SURF_SCANOUT;
@ -1702,18 +1702,15 @@ static struct pipe_resource *si_texture_from_handle(struct pipe_screen *screen,
struct si_screen *sscreen = (struct si_screen *)screen;
struct pb_buffer *buf = NULL;
/* Support only 2D textures without mipmaps */
if ((templ->target != PIPE_TEXTURE_2D && templ->target != PIPE_TEXTURE_RECT &&
templ->target != PIPE_TEXTURE_2D_ARRAY) ||
templ->last_level != 0)
return NULL;
buf = sscreen->ws->buffer_from_handle(sscreen->ws, whandle,
sscreen->info.max_alignment,
templ->bind & PIPE_BIND_PRIME_BLIT_DST);
if (!buf)
return NULL;
if (templ->target == PIPE_BUFFER)
return si_buffer_from_winsys_buffer(screen, templ, buf, 0);
if (whandle->plane >= util_format_get_num_planes(whandle->format)) {
struct si_auxiliary_texture *tex = CALLOC_STRUCT_CL(si_auxiliary_texture);
if (!tex)