From 8a648619c4d55a0e9003973a1fa064d589f4229d Mon Sep 17 00:00:00 2001 From: Ivan Avdeev Date: Mon, 29 Apr 2024 18:28:28 -0400 Subject: [PATCH] vk: revert -nort commit `rt_force_disable` is perfectly fine, it just needs to be written into either `vk.cfg` or `video.cfg` to work. Other configs are read *after* `R_VkInit()` function get called. --- ref/vk/NOTES.md | 6 ++++++ ref/vk/TODO.md | 2 +- ref/vk/vk_core.c | 15 +++++++++------ ref/vk/vk_cvar.c | 1 + ref/vk/vk_cvar.h | 1 + ref/vk/vk_logs.h | 1 + 6 files changed, 19 insertions(+), 7 deletions(-) diff --git a/ref/vk/NOTES.md b/ref/vk/NOTES.md index 6c77c109..39ca3684 100644 --- a/ref/vk/NOTES.md +++ b/ref/vk/NOTES.md @@ -1,3 +1,9 @@ +# cvars +## `rt_force_disable` +On GPUs that support ray tracing forcefully disables it as if it wasn't supported at all. I.e. no RT extensions and modules are initialized. Useful for testing sometimes. +Note: this cvar is read early in `R_VkInit()`, which gets executed before `autoexec.cfg`, `config.cfg`, etc are read. So putting it there will not work. +`video.cfg` and `vk.cfg` are read before Vk initialization, so this cvar should go there. + # Frame structure wrt calls from the engine - (eng) SCR_UpdateScreen() - (eng) V_PreRender() diff --git a/ref/vk/TODO.md b/ref/vk/TODO.md index 5b0a01f9..9876cb01 100644 --- a/ref/vk/TODO.md +++ b/ref/vk/TODO.md @@ -3,7 +3,7 @@ - [ ] performance profiling and comparison ## 2024-04-12 E374 -- [x] `-vknort` arg to force-disable RT at init time +- [x] ~~`-vknort` arg to force-disable RT at init time~~ -- reverted on 2024-04-29 ## 2024-03-21 E372: agonizig over agenda ### Player-visible essentials and blockers. Big projects. diff --git a/ref/vk/vk_core.c b/ref/vk/vk_core.c index e892430b..dac3e185 100644 --- a/ref/vk/vk_core.c +++ b/ref/vk/vk_core.c @@ -41,6 +41,8 @@ #include #include +#define LOG_MODULE core + #define NULLINST_FUNCS(X) \ X(vkEnumerateInstanceVersion) \ X(vkCreateInstance) \ @@ -495,7 +497,7 @@ static void devicePrintMemoryInfo(const VkPhysicalDeviceMemoryProperties *props, } } -static qboolean createDevice( qboolean vk_no_rt ) { +static qboolean createDevice( void ) { void *head = NULL; vk_available_device_t *available_devices; const int num_available_devices = enumerateDevices( &available_devices ); @@ -518,8 +520,11 @@ static qboolean createDevice( qboolean vk_no_rt ) { is_target_device_found = true; } - if (candidate_device->ray_tracing && !vk_no_rt) { - vk_core.rtx = true; + if (candidate_device->ray_tracing) { + const qboolean force_disabled = CVAR_TO_BOOL(rt_force_disable); + if (force_disabled) + WARN("GPU[%d] supports ray tracing, but rt_force_disable is set, force-disabling ray tracing support", i); + vk_core.rtx = !force_disabled; } VkPhysicalDeviceAccelerationStructureFeaturesKHR accel_feature = { @@ -729,8 +734,6 @@ qboolean R_VkInit( void ) vk_core.debug = vk_core.validate || !!(gEngine.Sys_CheckParm("-vkdebug") || gEngine.Sys_CheckParm("-gldebug")); vk_core.rtx = false; - const qboolean vk_no_rt = gEngine.Sys_CheckParm("-vknort"); - VK_LoadCvars(); // Force extremely verbose logs at startup. @@ -785,7 +788,7 @@ qboolean R_VkInit( void ) } #endif - if (!createDevice(vk_no_rt)) + if (!createDevice()) return false; VK_LoadCvarsAfterInit(); diff --git a/ref/vk/vk_cvar.c b/ref/vk/vk_cvar.c index daa127e0..64e4e0c9 100644 --- a/ref/vk/vk_cvar.c +++ b/ref/vk/vk_cvar.c @@ -25,6 +25,7 @@ void VK_LoadCvars( void ) cl_lightstyle_lerping = gEngine.pfnGetCvarPointer( "cl_lightstyle_lerping", 0 ); r_lightmap = gEngine.Cvar_Get( "r_lightmap", "0", FCVAR_CHEAT, "lightmap debugging tool" ); r_infotool = gEngine.Cvar_Get( "r_infotool", "0", FCVAR_CHEAT, "DEBUG: print entity info under crosshair" ); + 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 | FCVAR_READ_ONLY, ""); diff --git a/ref/vk/vk_cvar.h b/ref/vk/vk_cvar.h index cfb03e02..c15f2f86 100644 --- a/ref/vk/vk_cvar.h +++ b/ref/vk/vk_cvar.h @@ -23,6 +23,7 @@ void VK_LoadCvarsAfterInit( void ); X(vk_device_target_id) \ X(vk_debug_log) \ X(rt_capable) \ + X(rt_force_disable) \ X(rt_enable) \ X(rt_bounces) \ diff --git a/ref/vk/vk_logs.h b/ref/vk/vk_logs.h index cfbe51cc..8f427776 100644 --- a/ref/vk/vk_logs.h +++ b/ref/vk/vk_logs.h @@ -3,6 +3,7 @@ #include "vk_common.h" #define LIST_LOG_MODULES(X) \ + X(core) \ X(misc) \ X(tex) \ X(brush) \