From 9bb2a83e0cccca532fe43a22b7520ae9a968bac6 Mon Sep 17 00:00:00 2001 From: VReaperV Date: Thu, 26 Dec 2024 01:44:22 +0300 Subject: [PATCH] Add r_materialSystemSkip This makes debugging issues that are present on material system but no core renderer much faster, since it can be changed without any sort of restart. --- src/engine/renderer/Material.cpp | 4 ++++ src/engine/renderer/tr_backend.cpp | 2 +- src/engine/renderer/tr_init.cpp | 1 + src/engine/renderer/tr_local.h | 1 + src/engine/renderer/tr_main.cpp | 4 ++-- 5 files changed, 9 insertions(+), 3 deletions(-) diff --git a/src/engine/renderer/Material.cpp b/src/engine/renderer/Material.cpp index 796d72b908..ad456ea3b9 100644 --- a/src/engine/renderer/Material.cpp +++ b/src/engine/renderer/Material.cpp @@ -2061,6 +2061,10 @@ void MaterialSystem::RenderMaterials( const shaderSort_t fromSort, const shaderS return; } + if ( r_materialSystemSkip.Get() ) { + return; + } + if ( frameStart ) { renderedMaterials.clear(); UpdateDynamicSurfaces(); diff --git a/src/engine/renderer/tr_backend.cpp b/src/engine/renderer/tr_backend.cpp index 3510cafe5f..09e756be5c 100644 --- a/src/engine/renderer/tr_backend.cpp +++ b/src/engine/renderer/tr_backend.cpp @@ -4767,7 +4767,7 @@ This is done so various debugging facilities will work properly */ static void RB_RenderPostProcess() { - if ( glConfig2.usingMaterialSystem ) { + if ( glConfig2.usingMaterialSystem && !r_materialSystemSkip.Get() ) { // Dispatch the cull compute shaders for queued once we're done with post-processing // We'll only use the results from those shaders in the next frame so we don't block the pipeline materialSystem.CullSurfaces(); diff --git a/src/engine/renderer/tr_init.cpp b/src/engine/renderer/tr_init.cpp index 11a40f9874..6cfe626c12 100644 --- a/src/engine/renderer/tr_init.cpp +++ b/src/engine/renderer/tr_init.cpp @@ -91,6 +91,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA Cvar::Cvar r_materialSystem( "r_materialSystem", "Use Material System", Cvar::NONE, false ); Cvar::Cvar r_gpuFrustumCulling( "r_gpuFrustumCulling", "Use frustum culling on the GPU for the Material System", Cvar::NONE, true ); Cvar::Cvar r_gpuOcclusionCulling( "r_gpuOcclusionCulling", "Use occlusion culling on the GPU for the Material System", Cvar::NONE, false ); + Cvar::Cvar r_materialSystemSkip( "r_materialSystemSkip", "Temporarily skip Material System rendering, using only core renderer instead", Cvar::NONE, false ); cvar_t *r_lightStyles; cvar_t *r_exportTextures; cvar_t *r_heatHaze; diff --git a/src/engine/renderer/tr_local.h b/src/engine/renderer/tr_local.h index 52d810007c..667a2c0852 100644 --- a/src/engine/renderer/tr_local.h +++ b/src/engine/renderer/tr_local.h @@ -2912,6 +2912,7 @@ enum class shaderProfilerRenderSubGroupsMode { extern Cvar::Cvar r_materialSystem; extern Cvar::Cvar r_gpuFrustumCulling; extern Cvar::Cvar r_gpuOcclusionCulling; + extern Cvar::Cvar r_materialSystemSkip; extern cvar_t *r_lightStyles; extern cvar_t *r_exportTextures; extern cvar_t *r_heatHaze; diff --git a/src/engine/renderer/tr_main.cpp b/src/engine/renderer/tr_main.cpp index 1c9e785dbd..2c8ac3d501 100644 --- a/src/engine/renderer/tr_main.cpp +++ b/src/engine/renderer/tr_main.cpp @@ -1999,7 +1999,7 @@ static void R_SortDrawSurfs() // check for any pass through drawing, which // may cause another view to be rendered first // Material system does its own handling of portal surfaces - if ( glConfig2.usingMaterialSystem ) { + if ( glConfig2.usingMaterialSystem && !r_materialSystemSkip.Get() ) { if ( tr.viewParms.portalLevel == 0 ) { materialSystem.AddPortalSurfaces(); currentView = 0; @@ -2524,7 +2524,7 @@ void R_RenderView( viewParms_t *parms ) R_SetupFrustum(); - if ( glConfig2.usingMaterialSystem ) { + if ( glConfig2.usingMaterialSystem && !r_materialSystemSkip.Get() ) { tr.viewParms.viewID = tr.viewCount; materialSystem.QueueSurfaceCull( tr.viewCount, tr.viewParms.pvsOrigin, (frustum_t*) tr.viewParms.frustums[0] ); materialSystem.AddAutospriteSurfaces();