Path: blob/21.2-virgl/src/gallium/auxiliary/util/u_async_debug.h
4561 views
/*1* Copyright 2017 Advanced Micro Devices, Inc.2* All Rights Reserved.3*4* Permission is hereby granted, free of charge, to any person obtaining a5* copy of this software and associated documentation files (the "Software"),6* to deal in the Software without restriction, including without limitation7* on the rights to use, copy, modify, merge, publish, distribute, sub8* license, and/or sell copies of the Software, and to permit persons to whom9* the Software is furnished to do so, subject to the following conditions:10*11* The above copyright notice and this permission notice (including the next12* paragraph) shall be included in all copies or substantial portions of the13* Software.14*15* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR16* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,17* FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL18* THE AUTHOR(S) AND/OR THEIR SUPPLIERS BE LIABLE FOR ANY CLAIM,19* DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR20* OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE21* USE OR OTHER DEALINGS IN THE SOFTWARE.22*23*/2425/**26* \file u_async_debug.h27* Provides a helper implementation of pipe_debug_callback which allows debug28* messages from non-application threads to be passed back to the application29* thread.30*/3132#ifndef UTIL_ASYNC_DEBUG_H33#define UTIL_ASYNC_DEBUG_H3435#include "pipe/p_state.h"36#include "util/u_debug.h"37#include "util/simple_mtx.h"3839struct util_debug_message {40unsigned *id;41enum pipe_debug_type type;42char *msg;43};4445struct util_async_debug_callback {46struct pipe_debug_callback base;4748simple_mtx_t lock;49unsigned count;50unsigned max;51struct util_debug_message *messages;52};5354void55u_async_debug_init(struct util_async_debug_callback *adbg);56void57u_async_debug_cleanup(struct util_async_debug_callback *adbg);5859void60_u_async_debug_drain(struct util_async_debug_callback *adbg,61struct pipe_debug_callback *dst);6263static inline void64u_async_debug_drain(struct util_async_debug_callback *adbg,65struct pipe_debug_callback *dst)66{67/* Read the count without taking the lock to avoid atomics in the fast path.68* We'll re-read the count after taking the lock. */69if (adbg->count)70_u_async_debug_drain(adbg, dst);71}7273#endif /* UTIL_ASYNC_DEBUG_H */747576