[Mesa-dev] [PATCH 1/4] gallium/u_inlines: normalize naming, use dst & src, style fixes
Marek Olšák
maraeo at gmail.com
Sat Sep 1 06:54:16 UTC 2018
From: Marek Olšák <marek.olsak at amd.com>
---
src/gallium/auxiliary/util/u_inlines.h | 86 +++++++++++++-------------
1 file changed, 43 insertions(+), 43 deletions(-)
diff --git a/src/gallium/auxiliary/util/u_inlines.h b/src/gallium/auxiliary/util/u_inlines.h
index dee6f8f2d9e..7eb243779f7 100644
--- a/src/gallium/auxiliary/util/u_inlines.h
+++ b/src/gallium/auxiliary/util/u_inlines.h
@@ -45,139 +45,139 @@
extern "C" {
#endif
/*
* Reference counting helper functions.
*/
static inline void
-pipe_reference_init(struct pipe_reference *reference, unsigned count)
+pipe_reference_init(struct pipe_reference *dst, unsigned count)
{
- p_atomic_set(&reference->count, count);
+ p_atomic_set(&dst->count, count);
}
static inline boolean
-pipe_is_referenced(struct pipe_reference *reference)
+pipe_is_referenced(struct pipe_reference *src)
{
- return p_atomic_read(&reference->count) != 0;
+ return p_atomic_read(&src->count) != 0;
}
/**
* Update reference counting.
* The old thing pointed to, if any, will be unreferenced.
* Both 'ptr' and 'reference' may be NULL.
* \return TRUE if the object's refcount hits zero and should be destroyed.
*/
static inline boolean
-pipe_reference_described(struct pipe_reference *ptr,
- struct pipe_reference *reference,
+pipe_reference_described(struct pipe_reference *dst,
+ struct pipe_reference *src,
debug_reference_descriptor get_desc)
{
boolean destroy = FALSE;
- if(ptr != reference) {
+ if (dst != src) {
/* bump the reference.count first */
- if (reference) {
- assert(pipe_is_referenced(reference));
- p_atomic_inc(&reference->count);
- debug_reference(reference, get_desc, 1);
+ if (src) {
+ assert(pipe_is_referenced(src));
+ p_atomic_inc(&src->count);
+ debug_reference(src, get_desc, 1);
}
- if (ptr) {
- assert(pipe_is_referenced(ptr));
- if (p_atomic_dec_zero(&ptr->count)) {
+ if (dst) {
+ assert(pipe_is_referenced(dst));
+ if (p_atomic_dec_zero(&dst->count))
destroy = TRUE;
- }
- debug_reference(ptr, get_desc, -1);
+
+ debug_reference(dst, get_desc, -1);
}
}
return destroy;
}
static inline boolean
-pipe_reference(struct pipe_reference *ptr, struct pipe_reference *reference)
+pipe_reference(struct pipe_reference *dst, struct pipe_reference *src)
{
- return pipe_reference_described(ptr, reference,
+ return pipe_reference_described(dst, src,
(debug_reference_descriptor)
debug_describe_reference);
}
static inline void
-pipe_surface_reference(struct pipe_surface **ptr, struct pipe_surface *surf)
+pipe_surface_reference(struct pipe_surface **dst, struct pipe_surface *src)
{
- struct pipe_surface *old_surf = *ptr;
+ struct pipe_surface *old_dst = *dst;
- if (pipe_reference_described(&(*ptr)->reference, &surf->reference,
+ if (pipe_reference_described(&(*dst)->reference, &src->reference,
(debug_reference_descriptor)
debug_describe_surface))
- old_surf->context->surface_destroy(old_surf->context, old_surf);
- *ptr = surf;
+ old_dst->context->surface_destroy(old_dst->context, old_dst);
+ *dst = src;
}
/**
* Similar to pipe_surface_reference() but always set the pointer to NULL
* and pass in an explicit context. The explicit context avoids the problem
* of using a deleted context's surface_destroy() method when freeing a surface
* that's shared by multiple contexts.
*/
static inline void
pipe_surface_release(struct pipe_context *pipe, struct pipe_surface **ptr)
{
if (pipe_reference_described(&(*ptr)->reference, NULL,
(debug_reference_descriptor)
debug_describe_surface))
pipe->surface_destroy(pipe, *ptr);
*ptr = NULL;
}
static inline void
-pipe_resource_reference(struct pipe_resource **ptr, struct pipe_resource *tex)
+pipe_resource_reference(struct pipe_resource **dst, struct pipe_resource *src)
{
- struct pipe_resource *old_tex = *ptr;
+ struct pipe_resource *old_dst = *dst;
- if (pipe_reference_described(&(*ptr)->reference, &tex->reference,
+ if (pipe_reference_described(&(*dst)->reference, &src->reference,
(debug_reference_descriptor)
debug_describe_resource)) {
/* Avoid recursion, which would prevent inlining this function */
do {
- struct pipe_resource *next = old_tex->next;
+ struct pipe_resource *next = old_dst->next;
- old_tex->screen->resource_destroy(old_tex->screen, old_tex);
- old_tex = next;
- } while (pipe_reference_described(&old_tex->reference, NULL,
+ old_dst->screen->resource_destroy(old_dst->screen, old_dst);
+ old_dst = next;
+ } while (pipe_reference_described(&old_dst->reference, NULL,
(debug_reference_descriptor)
debug_describe_resource));
}
- *ptr = tex;
+ *dst = src;
}
/**
* Set *ptr to \p view with proper reference counting.
*
* The caller must guarantee that \p view and *ptr must have been created in
* the same context (if they exist), and that this must be the current context.
*/
static inline void
-pipe_sampler_view_reference(struct pipe_sampler_view **ptr,
- struct pipe_sampler_view *view)
+pipe_sampler_view_reference(struct pipe_sampler_view **dst,
+ struct pipe_sampler_view *src)
{
- struct pipe_sampler_view *old_view = *ptr;
+ struct pipe_sampler_view *old_dst = *dst;
- if (pipe_reference_described(&(*ptr)->reference, &view->reference,
+ if (pipe_reference_described(&(*dst)->reference, &src->reference,
(debug_reference_descriptor)
debug_describe_sampler_view))
- old_view->context->sampler_view_destroy(old_view->context, old_view);
- *ptr = view;
+ old_dst->context->sampler_view_destroy(old_dst->context, old_dst);
+ *dst = src;
}
/**
* Similar to pipe_sampler_view_reference() but always set the pointer to
* NULL and pass in the current context explicitly.
*
* If *ptr is non-NULL, it may refer to a view that was created in a different
* context (however, that context must still be alive).
*/
static inline void
@@ -186,29 +186,29 @@ pipe_sampler_view_release(struct pipe_context *ctx,
{
struct pipe_sampler_view *old_view = *ptr;
if (pipe_reference_described(&(*ptr)->reference, NULL,
(debug_reference_descriptor)debug_describe_sampler_view)) {
ctx->sampler_view_destroy(ctx, old_view);
}
*ptr = NULL;
}
static inline void
-pipe_so_target_reference(struct pipe_stream_output_target **ptr,
- struct pipe_stream_output_target *target)
+pipe_so_target_reference(struct pipe_stream_output_target **dst,
+ struct pipe_stream_output_target *src)
{
- struct pipe_stream_output_target *old = *ptr;
+ struct pipe_stream_output_target *old_dst = *dst;
- if (pipe_reference_described(&(*ptr)->reference, &target->reference,
+ if (pipe_reference_described(&(*dst)->reference, &src->reference,
(debug_reference_descriptor)debug_describe_so_target))
- old->context->stream_output_target_destroy(old->context, old);
- *ptr = target;
+ old_dst->context->stream_output_target_destroy(old_dst->context, old_dst);
+ *dst = src;
}
static inline void
pipe_vertex_buffer_unreference(struct pipe_vertex_buffer *dst)
{
if (dst->is_user_buffer)
dst->buffer.user = NULL;
else
pipe_resource_reference(&dst->buffer.resource, NULL);
}
--
2.17.1
More information about the mesa-dev
mailing list