mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-01-04 22:10:11 +01:00
winsys/amdgpu: add more fence_reference helpers
Reviewed-by: Pierre-Eric Pelloux-Prayer <pierre-eric.pelloux-prayer@amd.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/27060>
This commit is contained in:
parent
a94319d29b
commit
fb3171b653
2 changed files with 32 additions and 10 deletions
|
|
@ -15,6 +15,17 @@
|
|||
|
||||
/* FENCES */
|
||||
|
||||
void amdgpu_fence_destroy(struct amdgpu_fence *fence)
|
||||
{
|
||||
if (amdgpu_fence_is_syncobj(fence))
|
||||
amdgpu_cs_destroy_syncobj(fence->ws->dev, fence->syncobj);
|
||||
else
|
||||
amdgpu_ctx_reference(&fence->ctx, NULL);
|
||||
|
||||
util_queue_fence_destroy(&fence->submitted);
|
||||
FREE(fence);
|
||||
}
|
||||
|
||||
static struct pipe_fence_handle *
|
||||
amdgpu_fence_create(struct amdgpu_cs *cs)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -173,6 +173,8 @@ struct amdgpu_fence {
|
|||
uint_seq_no queue_seq_no; /* winsys-generated sequence number */
|
||||
};
|
||||
|
||||
void amdgpu_fence_destroy(struct amdgpu_fence *fence);
|
||||
|
||||
static inline bool amdgpu_fence_is_syncobj(struct amdgpu_fence *fence)
|
||||
{
|
||||
return fence->ctx == NULL;
|
||||
|
|
@ -197,20 +199,29 @@ static inline void amdgpu_fence_reference(struct pipe_fence_handle **dst,
|
|||
struct amdgpu_fence **adst = (struct amdgpu_fence **)dst;
|
||||
struct amdgpu_fence *asrc = (struct amdgpu_fence *)src;
|
||||
|
||||
if (pipe_reference(&(*adst)->reference, &asrc->reference)) {
|
||||
struct amdgpu_fence *fence = *adst;
|
||||
if (pipe_reference(&(*adst)->reference, &asrc->reference))
|
||||
amdgpu_fence_destroy(*adst);
|
||||
|
||||
if (amdgpu_fence_is_syncobj(fence))
|
||||
amdgpu_cs_destroy_syncobj(fence->ws->dev, fence->syncobj);
|
||||
else
|
||||
amdgpu_ctx_reference(&fence->ctx, NULL);
|
||||
|
||||
util_queue_fence_destroy(&fence->submitted);
|
||||
FREE(fence);
|
||||
}
|
||||
*adst = asrc;
|
||||
}
|
||||
|
||||
/* Same as amdgpu_fence_reference, but ignore the value in *dst. */
|
||||
static inline void amdgpu_fence_set_reference(struct pipe_fence_handle **dst,
|
||||
struct pipe_fence_handle *src)
|
||||
{
|
||||
*dst = src;
|
||||
pipe_reference(NULL, &((struct amdgpu_fence *)src)->reference); /* only increment refcount */
|
||||
}
|
||||
|
||||
/* Unreference dst, but don't assign anything. */
|
||||
static inline void amdgpu_fence_drop_reference(struct pipe_fence_handle *dst)
|
||||
{
|
||||
struct amdgpu_fence *adst = (struct amdgpu_fence *)dst;
|
||||
|
||||
if (pipe_reference(&adst->reference, NULL)) /* only decrement refcount */
|
||||
amdgpu_fence_destroy(adst);
|
||||
}
|
||||
|
||||
struct amdgpu_cs_buffer *
|
||||
amdgpu_lookup_buffer_any_type(struct amdgpu_cs_context *cs, struct amdgpu_winsys_bo *bo);
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue