Module: Mesa
Branch: main
Commit: 56f934103dcaebe00522d15584f2396811c51b1a
URL:    
http://cgit.freedesktop.org/mesa/mesa/commit/?id=56f934103dcaebe00522d15584f2396811c51b1a

Author: Karol Herbst <[email protected]>
Date:   Tue Sep 26 22:21:36 2023 +0200

radeonsi: support importing arbitrary resources

Reviewed-by: Marek Olšák <[email protected]>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/21305>

---

 src/gallium/drivers/radeonsi/si_texture.c | 11 ++++-------
 1 file changed, 4 insertions(+), 7 deletions(-)

diff --git a/src/gallium/drivers/radeonsi/si_texture.c 
b/src/gallium/drivers/radeonsi/si_texture.c
index 16948db41a7..ebd4d8c07ae 100644
--- a/src/gallium/drivers/radeonsi/si_texture.c
+++ b/src/gallium/drivers/radeonsi/si_texture.c
@@ -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)

Reply via email to