summaryrefslogtreecommitdiff
path: root/src/gallium/winsys
diff options
context:
space:
mode:
authorMarek Olšák <marek.olsak@amd.com>2021-03-23 01:31:39 -0400
committerMarge Bot <eric+marge@anholt.net>2021-04-06 22:31:15 +0000
commit6c6a39682ebdacbc978bb64467b7c32dab2fb736 (patch)
treeed357ecd025f7b01749cdbf6651a52fc8cfdd9e8 /src/gallium/winsys
parent33b2daab1a15c6acd61f110756ce7b90f4d8f645 (diff)
gallium/pb: pass an optional winsys pointer to the buffer destroy function
This will allow removing the winsys pointer from buffers. Reviewed-by: Zoltán Böszörményi <zboszor@gmail.com> Reviewed-by: Pierre-Eric Pelloux-Prayer <pierre-eric.pelloux-prayer@amd.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/9809>
Diffstat (limited to 'src/gallium/winsys')
-rw-r--r--src/gallium/winsys/amdgpu/drm/amdgpu_bo.c14
-rw-r--r--src/gallium/winsys/amdgpu/drm/amdgpu_bo.h4
-rw-r--r--src/gallium/winsys/amdgpu/drm/amdgpu_winsys.c2
-rw-r--r--src/gallium/winsys/radeon/drm/radeon_drm_bo.c18
-rw-r--r--src/gallium/winsys/radeon/drm/radeon_drm_bo.h4
-rw-r--r--src/gallium/winsys/radeon/drm/radeon_drm_winsys.c2
-rw-r--r--src/gallium/winsys/svga/drm/pb_buffer_simple_fenced.c2
-rw-r--r--src/gallium/winsys/svga/drm/vmw_buffer.c2
8 files changed, 24 insertions, 24 deletions
diff --git a/src/gallium/winsys/amdgpu/drm/amdgpu_bo.c b/src/gallium/winsys/amdgpu/drm/amdgpu_bo.c
index abf1e7d75a9..cd773f3231a 100644
--- a/src/gallium/winsys/amdgpu/drm/amdgpu_bo.c
+++ b/src/gallium/winsys/amdgpu/drm/amdgpu_bo.c
@@ -169,7 +169,7 @@ static void amdgpu_bo_remove_fences(struct amdgpu_winsys_bo *bo)
bo->max_fences = 0;
}
-void amdgpu_bo_destroy(struct pb_buffer *_buf)
+void amdgpu_bo_destroy(void *winsys, struct pb_buffer *_buf)
{
struct amdgpu_winsys_bo *bo = amdgpu_winsys_bo(_buf);
struct amdgpu_screen_winsys *sws_iter;
@@ -231,7 +231,7 @@ void amdgpu_bo_destroy(struct pb_buffer *_buf)
FREE(bo);
}
-static void amdgpu_bo_destroy_or_cache(struct pb_buffer *_buf)
+static void amdgpu_bo_destroy_or_cache(void *winsys, struct pb_buffer *_buf)
{
struct amdgpu_winsys_bo *bo = amdgpu_winsys_bo(_buf);
@@ -240,7 +240,7 @@ static void amdgpu_bo_destroy_or_cache(struct pb_buffer *_buf)
if (bo->u.real.use_reusable_pool)
pb_cache_add_buffer(bo->cache_entry);
else
- amdgpu_bo_destroy(_buf);
+ amdgpu_bo_destroy(winsys, _buf);
}
static void amdgpu_clean_up_buffer_managers(struct amdgpu_winsys *ws)
@@ -620,7 +620,7 @@ error_bo_alloc:
return NULL;
}
-bool amdgpu_bo_can_reclaim(struct pb_buffer *_buf)
+bool amdgpu_bo_can_reclaim(void *winsys, struct pb_buffer *_buf)
{
return amdgpu_bo_wait(_buf, 0, RADEON_USAGE_READWRITE);
}
@@ -629,7 +629,7 @@ bool amdgpu_bo_can_reclaim_slab(void *priv, struct pb_slab_entry *entry)
{
struct amdgpu_winsys_bo *bo = container_of(entry, struct amdgpu_winsys_bo, u.slab.entry);
- return amdgpu_bo_can_reclaim(&bo->base);
+ return amdgpu_bo_can_reclaim(NULL, &bo->base);
}
static struct pb_slabs *get_slabs(struct amdgpu_winsys *ws, uint64_t size,
@@ -658,7 +658,7 @@ static unsigned get_slab_wasted_size(struct amdgpu_winsys_bo *bo)
return bo->u.slab.entry.entry_size - bo->base.size;
}
-static void amdgpu_bo_slab_destroy(struct pb_buffer *_buf)
+static void amdgpu_bo_slab_destroy(void *winsys, struct pb_buffer *_buf)
{
struct amdgpu_winsys_bo *bo = amdgpu_winsys_bo(_buf);
@@ -1090,7 +1090,7 @@ sparse_backing_free(struct amdgpu_winsys_bo *bo,
return true;
}
-static void amdgpu_bo_sparse_destroy(struct pb_buffer *_buf)
+static void amdgpu_bo_sparse_destroy(void *winsys, struct pb_buffer *_buf)
{
struct amdgpu_winsys_bo *bo = amdgpu_winsys_bo(_buf);
int r;
diff --git a/src/gallium/winsys/amdgpu/drm/amdgpu_bo.h b/src/gallium/winsys/amdgpu/drm/amdgpu_bo.h
index cdd0ffda466..9dd5bb6d523 100644
--- a/src/gallium/winsys/amdgpu/drm/amdgpu_bo.h
+++ b/src/gallium/winsys/amdgpu/drm/amdgpu_bo.h
@@ -119,13 +119,13 @@ struct amdgpu_slab {
struct amdgpu_winsys_bo *entries;
};
-bool amdgpu_bo_can_reclaim(struct pb_buffer *_buf);
+bool amdgpu_bo_can_reclaim(void *winsys, struct pb_buffer *_buf);
struct pb_buffer *amdgpu_bo_create(struct amdgpu_winsys *ws,
uint64_t size,
unsigned alignment,
enum radeon_bo_domain domain,
enum radeon_bo_flag flags);
-void amdgpu_bo_destroy(struct pb_buffer *_buf);
+void amdgpu_bo_destroy(void *winsys, struct pb_buffer *_buf);
void *amdgpu_bo_map(struct pb_buffer *buf,
struct radeon_cmdbuf *rcs,
enum pipe_map_flags usage);
diff --git a/src/gallium/winsys/amdgpu/drm/amdgpu_winsys.c b/src/gallium/winsys/amdgpu/drm/amdgpu_winsys.c
index 88bff45f7b6..2f91a377d14 100644
--- a/src/gallium/winsys/amdgpu/drm/amdgpu_winsys.c
+++ b/src/gallium/winsys/amdgpu/drm/amdgpu_winsys.c
@@ -442,7 +442,7 @@ amdgpu_winsys_create(int fd, const struct pipe_screen_config *config,
/* Create managers. */
pb_cache_init(&aws->bo_cache, RADEON_MAX_CACHED_HEAPS,
500000, aws->check_vm ? 1.0f : 2.0f, 0,
- (aws->info.vram_size + aws->info.gart_size) / 8,
+ (aws->info.vram_size + aws->info.gart_size) / 8, NULL,
amdgpu_bo_destroy, amdgpu_bo_can_reclaim);
unsigned min_slab_order = 8; /* 256 bytes */
diff --git a/src/gallium/winsys/radeon/drm/radeon_drm_bo.c b/src/gallium/winsys/radeon/drm/radeon_drm_bo.c
index 22cd399e30c..0ff282e8519 100644
--- a/src/gallium/winsys/radeon/drm/radeon_drm_bo.c
+++ b/src/gallium/winsys/radeon/drm/radeon_drm_bo.c
@@ -350,7 +350,7 @@ out:
mtx_unlock(&heap->mutex);
}
-void radeon_bo_destroy(struct pb_buffer *_buf)
+void radeon_bo_destroy(void *winsys, struct pb_buffer *_buf)
{
struct radeon_bo *bo = radeon_bo(_buf);
struct radeon_drm_winsys *rws = bo->rws;
@@ -419,7 +419,7 @@ void radeon_bo_destroy(struct pb_buffer *_buf)
FREE(bo);
}
-static void radeon_bo_destroy_or_cache(struct pb_buffer *_buf)
+static void radeon_bo_destroy_or_cache(void *winsys, struct pb_buffer *_buf)
{
struct radeon_bo *bo = radeon_bo(_buf);
@@ -428,7 +428,7 @@ static void radeon_bo_destroy_or_cache(struct pb_buffer *_buf)
if (bo->u.real.use_reusable_pool)
pb_cache_add_buffer(&bo->u.real.cache_entry);
else
- radeon_bo_destroy(_buf);
+ radeon_bo_destroy(NULL, _buf);
}
void *radeon_bo_do_map(struct radeon_bo *bo)
@@ -711,7 +711,7 @@ static struct radeon_bo *radeon_create_bo(struct radeon_drm_winsys *rws,
fprintf(stderr, "radeon: alignment : %d bytes\n", alignment);
fprintf(stderr, "radeon: domains : %d\n", args.initial_domain);
fprintf(stderr, "radeon: va : 0x%016llx\n", (unsigned long long)bo->va);
- radeon_bo_destroy(&bo->base);
+ radeon_bo_destroy(NULL, &bo->base);
return NULL;
}
mtx_lock(&rws->bo_handles_mutex);
@@ -737,7 +737,7 @@ static struct radeon_bo *radeon_create_bo(struct radeon_drm_winsys *rws,
return bo;
}
-bool radeon_bo_can_reclaim(struct pb_buffer *_buf)
+bool radeon_bo_can_reclaim(void *winsys, struct pb_buffer *_buf)
{
struct radeon_bo *bo = radeon_bo(_buf);
@@ -751,10 +751,10 @@ bool radeon_bo_can_reclaim_slab(void *priv, struct pb_slab_entry *entry)
{
struct radeon_bo *bo = container_of(entry, struct radeon_bo, u.slab.entry);
- return radeon_bo_can_reclaim(&bo->base);
+ return radeon_bo_can_reclaim(NULL, &bo->base);
}
-static void radeon_bo_slab_destroy(struct pb_buffer *_buf)
+static void radeon_bo_slab_destroy(void *winsys, struct pb_buffer *_buf)
{
struct radeon_bo *bo = radeon_bo(_buf);
@@ -1156,7 +1156,7 @@ static struct pb_buffer *radeon_winsys_bo_from_ptr(struct radeon_winsys *rws,
r = drmCommandWriteRead(ws->fd, DRM_RADEON_GEM_VA, &va, sizeof(va));
if (r && va.operation == RADEON_VA_RESULT_ERROR) {
fprintf(stderr, "radeon: Failed to assign virtual address space\n");
- radeon_bo_destroy(&bo->base);
+ radeon_bo_destroy(NULL, &bo->base);
return NULL;
}
mtx_lock(&ws->bo_handles_mutex);
@@ -1287,7 +1287,7 @@ done:
r = drmCommandWriteRead(ws->fd, DRM_RADEON_GEM_VA, &va, sizeof(va));
if (r && va.operation == RADEON_VA_RESULT_ERROR) {
fprintf(stderr, "radeon: Failed to assign virtual address space\n");
- radeon_bo_destroy(&bo->base);
+ radeon_bo_destroy(NULL, &bo->base);
return NULL;
}
mtx_lock(&ws->bo_handles_mutex);
diff --git a/src/gallium/winsys/radeon/drm/radeon_drm_bo.h b/src/gallium/winsys/radeon/drm/radeon_drm_bo.h
index 906d932d89a..98d1d04b9d9 100644
--- a/src/gallium/winsys/radeon/drm/radeon_drm_bo.h
+++ b/src/gallium/winsys/radeon/drm/radeon_drm_bo.h
@@ -76,8 +76,8 @@ struct radeon_slab {
struct radeon_bo *entries;
};
-void radeon_bo_destroy(struct pb_buffer *_buf);
-bool radeon_bo_can_reclaim(struct pb_buffer *_buf);
+void radeon_bo_destroy(void *winsys, struct pb_buffer *_buf);
+bool radeon_bo_can_reclaim(void *winsys, struct pb_buffer *_buf);
void radeon_drm_bo_init_functions(struct radeon_drm_winsys *ws);
bool radeon_bo_can_reclaim_slab(void *priv, struct pb_slab_entry *entry);
diff --git a/src/gallium/winsys/radeon/drm/radeon_drm_winsys.c b/src/gallium/winsys/radeon/drm/radeon_drm_winsys.c
index 0e96eb37998..7c3e99404f9 100644
--- a/src/gallium/winsys/radeon/drm/radeon_drm_winsys.c
+++ b/src/gallium/winsys/radeon/drm/radeon_drm_winsys.c
@@ -851,7 +851,7 @@ radeon_drm_winsys_create(int fd, const struct pipe_screen_config *config,
pb_cache_init(&ws->bo_cache, RADEON_MAX_CACHED_HEAPS,
500000, ws->check_vm ? 1.0f : 2.0f, 0,
- MIN2(ws->info.vram_size, ws->info.gart_size),
+ MIN2(ws->info.vram_size, ws->info.gart_size), NULL,
radeon_bo_destroy,
radeon_bo_can_reclaim);
diff --git a/src/gallium/winsys/svga/drm/pb_buffer_simple_fenced.c b/src/gallium/winsys/svga/drm/pb_buffer_simple_fenced.c
index 4d8149d4422..7811dfbcfa1 100644
--- a/src/gallium/winsys/svga/drm/pb_buffer_simple_fenced.c
+++ b/src/gallium/winsys/svga/drm/pb_buffer_simple_fenced.c
@@ -501,7 +501,7 @@ fenced_buffer_create_gpu_storage_locked(struct fenced_manager *fenced_mgr,
static void
-fenced_buffer_destroy(struct pb_buffer *buf)
+fenced_buffer_destroy(void *winsys, struct pb_buffer *buf)
{
struct fenced_buffer *fenced_buf = fenced_buffer(buf);
struct fenced_manager *fenced_mgr = fenced_buf->mgr;
diff --git a/src/gallium/winsys/svga/drm/vmw_buffer.c b/src/gallium/winsys/svga/drm/vmw_buffer.c
index 6bc7676c502..4c44cb517e4 100644
--- a/src/gallium/winsys/svga/drm/vmw_buffer.c
+++ b/src/gallium/winsys/svga/drm/vmw_buffer.c
@@ -101,7 +101,7 @@ vmw_gmr_bufmgr(struct pb_manager *mgr)
static void
-vmw_gmr_buffer_destroy(struct pb_buffer *_buf)
+vmw_gmr_buffer_destroy(void *winsys, struct pb_buffer *_buf)
{
struct vmw_gmr_buffer *buf = vmw_gmr_buffer(_buf);