venus: refactor to add struct vn_env

This is to prepare for adding perf options.

Signed-off-by: Yiwei Zhang <zzyiwei@chromium.org>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/16110>
This commit is contained in:
Yiwei Zhang 2022-04-26 18:26:16 +00:00 committed by Marge Bot
parent e24d8760e9
commit 4ab640852b
4 changed files with 14 additions and 10 deletions

View File

@ -27,19 +27,20 @@ static const struct debug_control vn_debug_options[] = {
{ NULL, 0 },
};
uint64_t vn_debug;
struct vn_env vn_env;
static void
vn_debug_init_once(void)
vn_env_init_once(void)
{
vn_debug = parse_debug_string(os_get_option("VN_DEBUG"), vn_debug_options);
vn_env.debug =
parse_debug_string(os_get_option("VN_DEBUG"), vn_debug_options);
}
void
vn_debug_init(void)
vn_env_init(void)
{
static once_flag once = ONCE_FLAG_INIT;
call_once(&once, vn_debug_init_once);
call_once(&once, vn_env_init_once);
}
void

View File

@ -44,7 +44,7 @@
#define VN_DEFAULT_ALIGN 8
#define VN_DEBUG(category) (unlikely(vn_debug & VN_DEBUG_##category))
#define VN_DEBUG(category) (unlikely(vn_env.debug & VN_DEBUG_##category))
#define vn_error(instance, error) \
(VN_DEBUG(RESULT) ? vn_log_result((instance), (error), __func__) : (error))
@ -171,10 +171,13 @@ struct vn_refcount {
atomic_int count;
};
extern uint64_t vn_debug;
struct vn_env {
uint64_t debug;
};
extern struct vn_env vn_env;
void
vn_debug_init(void);
vn_env_init(void);
void
vn_trace_init(void);

View File

@ -18,7 +18,7 @@ static uint32_t vn_icd_version = 5;
VkResult
vk_icdNegotiateLoaderICDInterfaceVersion(uint32_t *pSupportedVersion)
{
vn_debug_init();
vn_env_init();
vn_trace_init();
vn_icd_version = MIN2(vn_icd_version, *pSupportedVersion);

View File

@ -692,7 +692,7 @@ vn_CreateInstance(const VkInstanceCreateInfo *pCreateInfo,
struct vn_instance *instance;
VkResult result;
vn_debug_init();
vn_env_init();
vn_trace_init();
instance = vk_zalloc(alloc, sizeof(*instance), VN_DEFAULT_ALIGN,