[Mesa-dev] [PATCH 1/2] gallium/util: move conditional from _pipe_debug_message() to macro
Ilia Mirkin
imirkin at alum.mit.edu
Fri Dec 4 18:17:48 PST 2015
Actually nouveau can, in some situations, pass in a null debug object.
I have a thing in the fence wait to say how long it waited, which can
be invoked without a pipe_context, and hence no debug object. Other
(most) times it will be invoked with a pipe_context in hand and be
able to log the messages.
Oh, but perhaps for other reasons nouveau actually checks if it's null
before calling pipe_debug_message. Either way, I think it's a nice
property that the object is allowed to be null... I'd rather keep that
option open.
-ilia
On Fri, Dec 4, 2015 at 7:52 PM, Brian Paul <brianp at vmware.com> wrote:
> To avoid function calls when the pointer is null.
>
> Also, assert that the pipe_debug_callback object is non-null. It looks
> like all the drivers which use this feature never pass a non-null pointer.
> ---
> src/gallium/auxiliary/util/u_debug.c | 3 +--
> src/gallium/auxiliary/util/u_debug.h | 9 ++++++---
> 2 files changed, 7 insertions(+), 5 deletions(-)
>
> diff --git a/src/gallium/auxiliary/util/u_debug.c b/src/gallium/auxiliary/util/u_debug.c
> index 7029536..c42505d 100644
> --- a/src/gallium/auxiliary/util/u_debug.c
> +++ b/src/gallium/auxiliary/util/u_debug.c
> @@ -79,8 +79,7 @@ _pipe_debug_message(
> {
> va_list args;
> va_start(args, fmt);
> - if (cb && cb->debug_message)
> - cb->debug_message(cb->data, id, type, fmt, args);
> + cb->debug_message(cb->data, id, type, fmt, args);
> va_end(args);
> }
>
> diff --git a/src/gallium/auxiliary/util/u_debug.h b/src/gallium/auxiliary/util/u_debug.h
> index 9900703..4cc3d63 100644
> --- a/src/gallium/auxiliary/util/u_debug.h
> +++ b/src/gallium/auxiliary/util/u_debug.h
> @@ -268,9 +268,12 @@ void _debug_assert_fail(const char *expr,
> */
> #define pipe_debug_message(cb, type, fmt, ...) do { \
> static unsigned id = 0; \
> - _pipe_debug_message(cb, &id, \
> - PIPE_DEBUG_TYPE_ ## type, \
> - fmt, ##__VA_ARGS__); \
> + assert(cb); \
> + if ((cb)->debug_message) { \
> + _pipe_debug_message(cb, &id, \
> + PIPE_DEBUG_TYPE_ ## type, \
> + fmt, ##__VA_ARGS__); \
> + } \
> } while (0)
>
> struct pipe_debug_callback;
> --
> 1.9.1
>
More information about the mesa-dev
mailing list