From 266f57e8a56999dacfd1dc7637760c6dc003681d Mon Sep 17 00:00:00 2001 From: Ivan Avdeev Date: Tue, 7 Nov 2023 11:59:12 -0500 Subject: [PATCH] vk: make `vk_debug_log` a command, not a cvar This makes it easily switchable at any point in time. Still not sure how to properly manage log verbosity cvars: - cvars are loaded after initialization and map load, so we can't really depend on saved cvar values. - reloading cvars each frame cancels `-vkverboselogs` arg that is supposed to work around the above limitation --- ref/vk/TODO.md | 9 +++++++++ ref/vk/vk_core.c | 1 - ref/vk/vk_cvar.c | 12 +++++++++++- ref/vk/vk_logs.c | 4 ++-- ref/vk/vk_logs.h | 3 +-- 5 files changed, 23 insertions(+), 6 deletions(-) diff --git a/ref/vk/TODO.md b/ref/vk/TODO.md index 814518f5..40be9cb1 100644 --- a/ref/vk/TODO.md +++ b/ref/vk/TODO.md @@ -1,3 +1,12 @@ +# 2023-11-07 E326 +- [x] list supported arguments for `rt_debug_display_only` cvar +- [x] make vk_debug_log a command +- [ ] remove stvecs from patches -- not used, inconvenient +- [ ] patch texture coordinates by matrices + - [ ] add support for matrices to mapents + - [ ] convert old direct scale/offset patches to matrices and check that they work + - [ ] remove old direct scale/offset patches + # 2023-11-06 E325 - [x] fix material asserts and inherit - [x] fixup -vkverboselogs diff --git a/ref/vk/vk_core.c b/ref/vk/vk_core.c index 135376a3..d1957a0c 100644 --- a/ref/vk/vk_core.c +++ b/ref/vk/vk_core.c @@ -701,7 +701,6 @@ qboolean R_VkInit( void ) vk_core.rtx = false; VK_LoadCvars(); - VK_LogsReadCvar(); // Force extremely verbose logs at startup. // This is instrumental in some investigations, because the usual "vk_debug_log" cvar is not set diff --git a/ref/vk/vk_cvar.c b/ref/vk/vk_cvar.c index 8ede348a..64e4e0c9 100644 --- a/ref/vk/vk_cvar.c +++ b/ref/vk/vk_cvar.c @@ -1,6 +1,7 @@ #include "vk_cvar.h" #include "vk_common.h" #include "vk_core.h" +#include "vk_logs.h" #define NONEXTERN_CVAR(cvar) cvar_t *cvar; DECLARE_CVAR(NONEXTERN_CVAR) @@ -8,6 +9,13 @@ DECLARE_CVAR(NONEXTERN_CVAR) DEFINE_ENGINE_SHARED_CVAR_LIST() +static void setDebugLog( void ) { + const int argc = gEngine.Cmd_Argc(); + const char *const modules = argc > 1 ? gEngine.Cmd_Argv(1) : ""; + gEngine.Cvar_Set("vk_debug_log_", modules); + R_LogSetVerboseModules( modules ); +} + void VK_LoadCvars( void ) { #define gEngfuncs gEngine // ... @@ -20,7 +28,9 @@ void VK_LoadCvars( void ) rt_force_disable = gEngine.Cvar_Get( "rt_force_disable", "0", FCVAR_GLCONFIG, "Force disable Ray Tracing" ); vk_device_target_id = gEngine.Cvar_Get( "vk_device_target_id", "", FCVAR_GLCONFIG, "Selected video device id" ); - vk_debug_log = gEngine.Cvar_Get("vk_debug_log", "", FCVAR_GLCONFIG, "List of modules to enable debug logs for"); + vk_debug_log = gEngine.Cvar_Get("vk_debug_log_", "", FCVAR_GLCONFIG | FCVAR_READ_ONLY, ""); + + gEngine.Cmd_AddCommand("vk_debug_log", setDebugLog, "Set modules to enable debug logs for"); } void VK_LoadCvarsAfterInit( void ) diff --git a/ref/vk/vk_logs.c b/ref/vk/vk_logs.c index af5603e4..51a2bc55 100644 --- a/ref/vk/vk_logs.c +++ b/ref/vk/vk_logs.c @@ -20,9 +20,8 @@ static const struct log_pair_t { {"sprite", LogModule_Sprite}, }; -void VK_LogsReadCvar(void) { +void R_LogSetVerboseModules( const char *p ) { g_log_debug_bits = 0; - const char *p = vk_debug_log->string; while (*p) { const char *next = Q_strchrnul(p, ','); const const_string_view_t name = {p, next - p}; @@ -31,6 +30,7 @@ void VK_LogsReadCvar(void) { for (int i = 0; i < COUNTOF(g_log_module_pairs); ++i) { const struct log_pair_t *const pair = g_log_module_pairs + i; if (stringViewCmp(name, pair->name) == 0) { + gEngine.Con_Reportf("Enabling verbose logs for module \"%.*s\"\n", name.len, name.s); bit = pair->bit; break; } diff --git a/ref/vk/vk_logs.h b/ref/vk/vk_logs.h index ae2d7c7a..ea473215 100644 --- a/ref/vk/vk_logs.h +++ b/ref/vk/vk_logs.h @@ -77,5 +77,4 @@ extern uint32_t g_log_debug_bits; ++called; \ } while(0) -// Read debug-enabled modules from cvar -void VK_LogsReadCvar(void); +void R_LogSetVerboseModules( const char *modules );