[Mesa-dev] [PATCH 11/14] gallium/radeon: add radeon_winsys::buffer_is_suballocated

Marek Olšák maraeo at gmail.com
Thu Jun 29 19:47:46 UTC 2017


From: Marek Olšák <marek.olsak at amd.com>

---
 src/gallium/drivers/radeon/radeon_winsys.h    | 3 +++
 src/gallium/winsys/amdgpu/drm/amdgpu_bo.c     | 8 ++++++++
 src/gallium/winsys/radeon/drm/radeon_drm_bo.c | 6 ++++++
 3 files changed, 17 insertions(+)

diff --git a/src/gallium/drivers/radeon/radeon_winsys.h b/src/gallium/drivers/radeon/radeon_winsys.h
index 239b6ab..b37af91 100644
--- a/src/gallium/drivers/radeon/radeon_winsys.h
+++ b/src/gallium/drivers/radeon/radeon_winsys.h
@@ -353,20 +353,23 @@ struct radeon_winsys {
                                          void *pointer, uint64_t size);
 
     /**
      * Whether the buffer was created from a user pointer.
      *
      * \param buf       A winsys buffer object
      * \return          whether \p buf was created via buffer_from_ptr
      */
     bool (*buffer_is_user_ptr)(struct pb_buffer *buf);
 
+    /** Whether the buffer was suballocated. */
+    bool (*buffer_is_suballocated)(struct pb_buffer *buf);
+
     /**
      * Get a winsys handle from a winsys buffer. The internal structure
      * of the handle is platform-specific and only a winsys should access it.
      *
      * \param buf       A winsys buffer object to get the handle from.
      * \param whandle   A winsys handle pointer.
      * \param stride    A stride of the buffer in bytes, for texturing.
      * \return          true on success.
      */
     bool (*buffer_get_handle)(struct pb_buffer *buf,
diff --git a/src/gallium/winsys/amdgpu/drm/amdgpu_bo.c b/src/gallium/winsys/amdgpu/drm/amdgpu_bo.c
index d512f7b..5943576 100644
--- a/src/gallium/winsys/amdgpu/drm/amdgpu_bo.c
+++ b/src/gallium/winsys/amdgpu/drm/amdgpu_bo.c
@@ -1404,31 +1404,39 @@ error_va_alloc:
 error:
     FREE(bo);
     return NULL;
 }
 
 static bool amdgpu_bo_is_user_ptr(struct pb_buffer *buf)
 {
    return ((struct amdgpu_winsys_bo*)buf)->user_ptr != NULL;
 }
 
+static bool amdgpu_bo_is_suballocated(struct pb_buffer *buf)
+{
+   struct amdgpu_winsys_bo *bo = (struct amdgpu_winsys_bo*)buf;
+
+   return !bo->bo && !bo->sparse;
+}
+
 static uint64_t amdgpu_bo_get_va(struct pb_buffer *buf)
 {
    return ((struct amdgpu_winsys_bo*)buf)->va;
 }
 
 void amdgpu_bo_init_functions(struct amdgpu_winsys *ws)
 {
    ws->base.buffer_set_metadata = amdgpu_buffer_set_metadata;
    ws->base.buffer_get_metadata = amdgpu_buffer_get_metadata;
    ws->base.buffer_map = amdgpu_bo_map;
    ws->base.buffer_unmap = amdgpu_bo_unmap;
    ws->base.buffer_wait = amdgpu_bo_wait;
    ws->base.buffer_create = amdgpu_bo_create;
    ws->base.buffer_from_handle = amdgpu_bo_from_handle;
    ws->base.buffer_from_ptr = amdgpu_bo_from_ptr;
    ws->base.buffer_is_user_ptr = amdgpu_bo_is_user_ptr;
+   ws->base.buffer_is_suballocated = amdgpu_bo_is_suballocated;
    ws->base.buffer_get_handle = amdgpu_bo_get_handle;
    ws->base.buffer_commit = amdgpu_bo_sparse_commit;
    ws->base.buffer_get_virtual_address = amdgpu_bo_get_va;
    ws->base.buffer_get_initial_domain = amdgpu_bo_get_initial_domain;
 }
diff --git a/src/gallium/winsys/radeon/drm/radeon_drm_bo.c b/src/gallium/winsys/radeon/drm/radeon_drm_bo.c
index bbdb60d..b82b984 100644
--- a/src/gallium/winsys/radeon/drm/radeon_drm_bo.c
+++ b/src/gallium/winsys/radeon/drm/radeon_drm_bo.c
@@ -1282,20 +1282,25 @@ static bool radeon_winsys_bo_get_handle(struct pb_buffer *buffer,
     whandle->offset += slice_size * whandle->layer;
 
     return true;
 }
 
 static bool radeon_winsys_bo_is_user_ptr(struct pb_buffer *buf)
 {
    return ((struct radeon_bo*)buf)->user_ptr != NULL;
 }
 
+static bool radeon_winsys_bo_is_suballocated(struct pb_buffer *buf)
+{
+   return !((struct radeon_bo*)buf)->handle;
+}
+
 static uint64_t radeon_winsys_bo_va(struct pb_buffer *buf)
 {
     return ((struct radeon_bo*)buf)->va;
 }
 
 static unsigned radeon_winsys_bo_get_reloc_offset(struct pb_buffer *buf)
 {
     struct radeon_bo *bo = radeon_bo(buf);
 
     if (bo->handle)
@@ -1308,15 +1313,16 @@ void radeon_drm_bo_init_functions(struct radeon_drm_winsys *ws)
 {
     ws->base.buffer_set_metadata = radeon_bo_set_metadata;
     ws->base.buffer_get_metadata = radeon_bo_get_metadata;
     ws->base.buffer_map = radeon_bo_map;
     ws->base.buffer_unmap = radeon_bo_unmap;
     ws->base.buffer_wait = radeon_bo_wait;
     ws->base.buffer_create = radeon_winsys_bo_create;
     ws->base.buffer_from_handle = radeon_winsys_bo_from_handle;
     ws->base.buffer_from_ptr = radeon_winsys_bo_from_ptr;
     ws->base.buffer_is_user_ptr = radeon_winsys_bo_is_user_ptr;
+    ws->base.buffer_is_suballocated = radeon_winsys_bo_is_suballocated;
     ws->base.buffer_get_handle = radeon_winsys_bo_get_handle;
     ws->base.buffer_get_virtual_address = radeon_winsys_bo_va;
     ws->base.buffer_get_reloc_offset = radeon_winsys_bo_get_reloc_offset;
     ws->base.buffer_get_initial_domain = radeon_bo_get_initial_domain;
 }
-- 
2.7.4



More information about the mesa-dev mailing list