From 91f72975ac1b8e5649322b9750d3aca639af7380 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Marek=20Ol=C5=A1=C3=A1k?= Date: Tue, 27 Jun 2017 20:27:29 +0200 Subject: [PATCH] gallium/radeon: add radeon_winsys::buffer_is_suballocated MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Reviewed-by: Nicolai Hähnle --- 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 @@ -360,6 +360,9 @@ struct radeon_winsys { */ 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. diff --git a/src/gallium/winsys/amdgpu/drm/amdgpu_bo.c b/src/gallium/winsys/amdgpu/drm/amdgpu_bo.c index 4c47f37..d0d8090 100644 --- a/src/gallium/winsys/amdgpu/drm/amdgpu_bo.c +++ b/src/gallium/winsys/amdgpu/drm/amdgpu_bo.c @@ -1410,6 +1410,13 @@ 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; @@ -1426,6 +1433,7 @@ void amdgpu_bo_init_functions(struct amdgpu_winsys *ws) 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; diff --git a/src/gallium/winsys/radeon/drm/radeon_drm_bo.c b/src/gallium/winsys/radeon/drm/radeon_drm_bo.c index aa3fb78..8027a5f 100644 --- a/src/gallium/winsys/radeon/drm/radeon_drm_bo.c +++ b/src/gallium/winsys/radeon/drm/radeon_drm_bo.c @@ -1290,6 +1290,11 @@ 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; @@ -1316,6 +1321,7 @@ void radeon_drm_bo_init_functions(struct radeon_drm_winsys *ws) 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; -- 2.7.4