r300,r600,radeonsi: read winsys_handle::stride,offset in drivers, not winsyses
authorMarek Olšák <marek.olsak@amd.com>
Tue, 27 Aug 2019 23:35:25 +0000 (19:35 -0400)
committerMarek Olšák <marek.olsak@amd.com>
Tue, 10 Sep 2019 03:43:03 +0000 (23:43 -0400)
Acked-by: Pierre-Eric Pelloux-Prayer <pierre-eric.pelloux-prayer@amd.com>
src/gallium/drivers/r300/r300_texture.c
src/gallium/drivers/r600/r600_texture.c
src/gallium/drivers/radeon/radeon_winsys.h
src/gallium/drivers/radeonsi/si_texture.c
src/gallium/winsys/amdgpu/drm/amdgpu_bo.c
src/gallium/winsys/radeon/drm/radeon_drm_bo.c

index 689341644fd99399d7a1688953917dd3cab5c6b3..737a4f90418db345e82b8909cd1f04e29efd048c 100644 (file)
@@ -36,6 +36,7 @@
 #include "util/u_memory.h"
 
 #include "pipe/p_screen.h"
+#include "state_tracker/winsys_handle.h"
 
 /* These formats are supported by swapping their bytes.
  * The swizzles must be set exactly like their non-swapped counterparts,
@@ -1179,7 +1180,6 @@ struct pipe_resource *r300_texture_from_handle(struct pipe_screen *screen,
     struct r300_screen *rscreen = r300_screen(screen);
     struct radeon_winsys *rws = rscreen->rws;
     struct pb_buffer *buffer;
-    unsigned stride;
     struct radeon_bo_metadata tiling = {};
 
     /* Support only 2D textures without mipmaps */
@@ -1190,7 +1190,7 @@ struct pipe_resource *r300_texture_from_handle(struct pipe_screen *screen,
         return NULL;
     }
 
-    buffer = rws->buffer_from_handle(rws, whandle, 0, &stride, NULL);
+    buffer = rws->buffer_from_handle(rws, whandle, 0);
     if (!buffer)
         return NULL;
 
@@ -1212,7 +1212,7 @@ struct pipe_resource *r300_texture_from_handle(struct pipe_screen *screen,
 
     return (struct pipe_resource*)
            r300_texture_create_object(rscreen, base, tiling.u.legacy.microtile, tiling.u.legacy.macrotile,
-                                      stride, buffer);
+                                      whandle->stride, buffer);
 }
 
 /* Not required to implement u_resource_vtbl, consider moving to another file:
index ddee3d9b83365083a3b70731812f38160ea26c79..03f217b988abfb072ffb03882bebf7a0e5799696 100644 (file)
@@ -33,6 +33,7 @@
 #include "util/u_pack_color.h"
 #include "util/u_surface.h"
 #include "util/os_time.h"
+#include "state_tracker/winsys_handle.h"
 #include <errno.h>
 #include <inttypes.h>
 
@@ -1115,7 +1116,6 @@ static struct pipe_resource *r600_texture_from_handle(struct pipe_screen *screen
 {
        struct r600_common_screen *rscreen = (struct r600_common_screen*)screen;
        struct pb_buffer *buf = NULL;
-       unsigned stride = 0, offset = 0;
        enum radeon_surf_mode array_mode;
        struct radeon_surf surface = {};
        int r;
@@ -1129,8 +1129,7 @@ static struct pipe_resource *r600_texture_from_handle(struct pipe_screen *screen
                return NULL;
 
        buf = rscreen->ws->buffer_from_handle(rscreen->ws, whandle,
-                                             rscreen->info.max_alignment,
-                                             &stride, &offset);
+                                             rscreen->info.max_alignment);
        if (!buf)
                return NULL;
 
@@ -1138,8 +1137,9 @@ static struct pipe_resource *r600_texture_from_handle(struct pipe_screen *screen
        r600_surface_import_metadata(rscreen, &surface, &metadata,
                                     &array_mode, &is_scanout);
 
-       r = r600_init_surface(rscreen, &surface, templ, array_mode, stride,
-                             offset, true, is_scanout, false);
+       r = r600_init_surface(rscreen, &surface, templ, array_mode,
+                             whandle->stride, whandle->offset,
+                             true, is_scanout, false);
        if (r) {
                return NULL;
        }
@@ -1865,14 +1865,12 @@ r600_memobj_from_handle(struct pipe_screen *screen,
        struct r600_common_screen *rscreen = (struct r600_common_screen*)screen;
        struct r600_memory_object *memobj = CALLOC_STRUCT(r600_memory_object);
        struct pb_buffer *buf = NULL;
-       uint32_t stride, offset;
 
        if (!memobj)
                return NULL;
 
        buf = rscreen->ws->buffer_from_handle(rscreen->ws, whandle,
-                                             rscreen->info.max_alignment,
-                                             &stride, &offset);
+                                             rscreen->info.max_alignment);
        if (!buf) {
                free(memobj);
                return NULL;
@@ -1880,8 +1878,8 @@ r600_memobj_from_handle(struct pipe_screen *screen,
 
        memobj->b.dedicated = dedicated;
        memobj->buf = buf;
-       memobj->stride = stride;
-       memobj->offset = offset;
+       memobj->stride = whandle->stride;
+       memobj->offset = whandle->offset;
 
        return (struct pipe_memory_object *)memobj;
 
index 525c28182ed17e9497bc7765adf6c6799340d77d..505b6c9a2cb530b730bfc58b0bbed44580eea5fb 100644 (file)
@@ -378,12 +378,10 @@ struct radeon_winsys {
      * \param ws        The winsys this function is called from.
      * \param whandle   A winsys handle pointer as was received from a state
      *                  tracker.
-     * \param stride    The returned buffer stride in bytes.
      */
     struct pb_buffer *(*buffer_from_handle)(struct radeon_winsys *ws,
                                             struct winsys_handle *whandle,
-                                            unsigned vm_alignment,
-                                            unsigned *stride, unsigned *offset);
+                                            unsigned vm_alignment);
 
     /**
      * Get a winsys buffer from a user pointer. The resulting buffer can't
index cb239c3a6e6e34fc41e791a7d719d0ede6f537c8..a4a08a6e3214cefd1ff1c7ad95b532e61bad1cf6 100644 (file)
@@ -1792,7 +1792,6 @@ 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;
-       unsigned stride = 0, offset = 0;
 
        /* Support only 2D textures without mipmaps */
        if ((templ->target != PIPE_TEXTURE_2D && templ->target != PIPE_TEXTURE_RECT &&
@@ -1801,13 +1800,13 @@ static struct pipe_resource *si_texture_from_handle(struct pipe_screen *screen,
                return NULL;
 
        buf = sscreen->ws->buffer_from_handle(sscreen->ws, whandle,
-                                             sscreen->info.max_alignment,
-                                             &stride, &offset);
+                                             sscreen->info.max_alignment);
        if (!buf)
                return NULL;
 
-       return si_texture_from_winsys_buffer(sscreen, templ, buf, stride,
-                                            offset, usage, true);
+       return si_texture_from_winsys_buffer(sscreen, templ, buf,
+                                            whandle->stride, whandle->offset,
+                                            usage, true);
 }
 
 bool si_init_flushed_depth_texture(struct pipe_context *ctx,
@@ -2614,14 +2613,12 @@ si_memobj_from_handle(struct pipe_screen *screen,
        struct si_screen *sscreen = (struct si_screen*)screen;
        struct si_memory_object *memobj = CALLOC_STRUCT(si_memory_object);
        struct pb_buffer *buf = NULL;
-       uint32_t stride, offset;
 
        if (!memobj)
                return NULL;
 
        buf = sscreen->ws->buffer_from_handle(sscreen->ws, whandle,
-                                             sscreen->info.max_alignment,
-                                             &stride, &offset);
+                                             sscreen->info.max_alignment);
        if (!buf) {
                free(memobj);
                return NULL;
@@ -2629,7 +2626,7 @@ si_memobj_from_handle(struct pipe_screen *screen,
 
        memobj->b.dedicated = dedicated;
        memobj->buf = buf;
-       memobj->stride = stride;
+       memobj->stride = whandle->stride;
 
        return (struct pipe_memory_object *)memobj;
 
index 7ff84cfb175b6f546945eebdc9476fb5232b9171..53f2bd67ea936544382a40c57d9f99b210864f61 100644 (file)
@@ -1408,9 +1408,7 @@ amdgpu_buffer_create(struct radeon_winsys *ws,
 
 static struct pb_buffer *amdgpu_bo_from_handle(struct radeon_winsys *rws,
                                                struct winsys_handle *whandle,
-                                               unsigned vm_alignment,
-                                               unsigned *stride,
-                                               unsigned *offset)
+                                               unsigned vm_alignment)
 {
    struct amdgpu_winsys *ws = amdgpu_winsys(rws);
    struct amdgpu_winsys_bo *bo = NULL;
@@ -1433,11 +1431,6 @@ static struct pb_buffer *amdgpu_bo_from_handle(struct radeon_winsys *rws,
       return NULL;
    }
 
-   if (stride)
-      *stride = whandle->stride;
-   if (offset)
-      *offset = whandle->offset;
-
    r = amdgpu_bo_import(ws->dev, type, whandle->handle, &result);
    if (r)
       return NULL;
index e9e0784e9ab4146c1477480b36a17b06bafc429c..f8a7b89966a3ed7c4fbd6d3befad69fae3c74a44 100644 (file)
@@ -1134,9 +1134,7 @@ static struct pb_buffer *radeon_winsys_bo_from_ptr(struct radeon_winsys *rws,
 
 static struct pb_buffer *radeon_winsys_bo_from_handle(struct radeon_winsys *rws,
                                                       struct winsys_handle *whandle,
-                                                      unsigned vm_alignment,
-                                                      unsigned *stride,
-                                                      unsigned *offset)
+                                                      unsigned vm_alignment)
 {
     struct radeon_drm_winsys *ws = radeon_drm_winsys(rws);
     struct radeon_bo *bo;
@@ -1144,12 +1142,6 @@ static struct pb_buffer *radeon_winsys_bo_from_handle(struct radeon_winsys *rws,
     unsigned handle;
     uint64_t size = 0;
 
-    if (!offset && whandle->offset != 0) {
-        fprintf(stderr, "attempt to import unsupported winsys offset %u\n",
-                whandle->offset);
-        return NULL;
-    }
-
     /* We must maintain a list of pairs <handle, bo>, so that we always return
      * the same BO for one particular handle. If we didn't do that and created
      * more than one BO for the same handle and then relocated them in a CS,
@@ -1232,11 +1224,6 @@ static struct pb_buffer *radeon_winsys_bo_from_handle(struct radeon_winsys *rws,
 done:
     mtx_unlock(&ws->bo_handles_mutex);
 
-    if (stride)
-        *stride = whandle->stride;
-    if (offset)
-        *offset = whandle->offset;
-
     if (ws->info.r600_has_virtual_memory && !bo->va) {
         struct drm_radeon_gem_va va;