Mesa (main): venus: refactor to add struct vn_env
GitLab Mirror
gitlab-mirror at kemper.freedesktop.org
Tue Apr 26 23:56:20 UTC 2022
Module: Mesa
Branch: main
Commit: 4ab640852b86911407e6aeb7aea0e47db914bd3f
URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=4ab640852b86911407e6aeb7aea0e47db914bd3f
Author: Yiwei Zhang <zzyiwei at chromium.org>
Date: Tue Apr 26 18:26:16 2022 +0000
venus: refactor to add struct vn_env
This is to prepare for adding perf options.
Signed-off-by: Yiwei Zhang <zzyiwei at chromium.org>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/16110>
---
src/virtio/vulkan/vn_common.c | 11 ++++++-----
src/virtio/vulkan/vn_common.h | 9 ++++++---
src/virtio/vulkan/vn_icd.c | 2 +-
src/virtio/vulkan/vn_instance.c | 2 +-
4 files changed, 14 insertions(+), 10 deletions(-)
diff --git a/src/virtio/vulkan/vn_common.c b/src/virtio/vulkan/vn_common.c
index b74b2384dd5..1c23cbb87f3 100644
--- a/src/virtio/vulkan/vn_common.c
+++ b/src/virtio/vulkan/vn_common.c
@@ -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
diff --git a/src/virtio/vulkan/vn_common.h b/src/virtio/vulkan/vn_common.h
index a12ecf64692..00c5d215f1e 100644
--- a/src/virtio/vulkan/vn_common.h
+++ b/src/virtio/vulkan/vn_common.h
@@ -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);
diff --git a/src/virtio/vulkan/vn_icd.c b/src/virtio/vulkan/vn_icd.c
index 68db22cdd56..430663af234 100644
--- a/src/virtio/vulkan/vn_icd.c
+++ b/src/virtio/vulkan/vn_icd.c
@@ -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);
diff --git a/src/virtio/vulkan/vn_instance.c b/src/virtio/vulkan/vn_instance.c
index 844df289080..464abc7c4e0 100644
--- a/src/virtio/vulkan/vn_instance.c
+++ b/src/virtio/vulkan/vn_instance.c
@@ -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,
More information about the mesa-commit
mailing list