Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/mesa
Path: blob/21.2-virgl/src/gallium/auxiliary/util/u_async_debug.h
4561 views
1
/*
2
* Copyright 2017 Advanced Micro Devices, Inc.
3
* All Rights Reserved.
4
*
5
* Permission is hereby granted, free of charge, to any person obtaining a
6
* copy of this software and associated documentation files (the "Software"),
7
* to deal in the Software without restriction, including without limitation
8
* on the rights to use, copy, modify, merge, publish, distribute, sub
9
* license, and/or sell copies of the Software, and to permit persons to whom
10
* the Software is furnished to do so, subject to the following conditions:
11
*
12
* The above copyright notice and this permission notice (including the next
13
* paragraph) shall be included in all copies or substantial portions of the
14
* Software.
15
*
16
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18
* FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL
19
* THE AUTHOR(S) AND/OR THEIR SUPPLIERS BE LIABLE FOR ANY CLAIM,
20
* DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
21
* OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
22
* USE OR OTHER DEALINGS IN THE SOFTWARE.
23
*
24
*/
25
26
/**
27
* \file u_async_debug.h
28
* Provides a helper implementation of pipe_debug_callback which allows debug
29
* messages from non-application threads to be passed back to the application
30
* thread.
31
*/
32
33
#ifndef UTIL_ASYNC_DEBUG_H
34
#define UTIL_ASYNC_DEBUG_H
35
36
#include "pipe/p_state.h"
37
#include "util/u_debug.h"
38
#include "util/simple_mtx.h"
39
40
struct util_debug_message {
41
unsigned *id;
42
enum pipe_debug_type type;
43
char *msg;
44
};
45
46
struct util_async_debug_callback {
47
struct pipe_debug_callback base;
48
49
simple_mtx_t lock;
50
unsigned count;
51
unsigned max;
52
struct util_debug_message *messages;
53
};
54
55
void
56
u_async_debug_init(struct util_async_debug_callback *adbg);
57
void
58
u_async_debug_cleanup(struct util_async_debug_callback *adbg);
59
60
void
61
_u_async_debug_drain(struct util_async_debug_callback *adbg,
62
struct pipe_debug_callback *dst);
63
64
static inline void
65
u_async_debug_drain(struct util_async_debug_callback *adbg,
66
struct pipe_debug_callback *dst)
67
{
68
/* Read the count without taking the lock to avoid atomics in the fast path.
69
* We'll re-read the count after taking the lock. */
70
if (adbg->count)
71
_u_async_debug_drain(adbg, dst);
72
}
73
74
#endif /* UTIL_ASYNC_DEBUG_H */
75
76