- add cvar r_skipmats - speeds up rendering on slower cards for mods that use a lot of specularity/pbr, effective on both the opengl and vulkan backends

This commit is contained in:
Rachael Alexanderson 2021-10-20 06:49:45 -04:00
parent 2fc1481202
commit bb44f3dcd9
3 changed files with 10 additions and 0 deletions

View file

@ -49,6 +49,8 @@
#include <map> #include <map>
#include <memory> #include <memory>
EXTERN_CVAR(Bool, r_skipmats)
namespace OpenGLRenderer namespace OpenGLRenderer
{ {
@ -729,6 +731,9 @@ FShader *FShaderManager::BindEffect(int effect, EPassType passType)
FShader *FShaderManager::Get(unsigned int eff, bool alphateston, EPassType passType) FShader *FShaderManager::Get(unsigned int eff, bool alphateston, EPassType passType)
{ {
if (r_skipmats && eff >= 3 && eff <= 4)
eff = 0;
if (passType < mPassShaders.Size()) if (passType < mPassShaders.Size())
return mPassShaders[passType]->Get(eff, alphateston); return mPassShaders[passType]->Get(eff, alphateston);
else else

View file

@ -72,6 +72,8 @@ CVAR(Int, win_w, -1, CVAR_ARCHIVE | CVAR_GLOBALCONFIG)
CVAR(Int, win_h, -1, CVAR_ARCHIVE | CVAR_GLOBALCONFIG) CVAR(Int, win_h, -1, CVAR_ARCHIVE | CVAR_GLOBALCONFIG)
CVAR(Bool, win_maximized, false, CVAR_ARCHIVE | CVAR_GLOBALCONFIG | CVAR_NOINITCALL) CVAR(Bool, win_maximized, false, CVAR_ARCHIVE | CVAR_GLOBALCONFIG | CVAR_NOINITCALL)
CVAR(Bool, r_skipmats, false, CVAR_ARCHIVE | CVAR_GLOBALCONFIG | CVAR_NOINITCALL)
// 0 means 'no pipelining' for non GLES2 and 4 elements for GLES2 // 0 means 'no pipelining' for non GLES2 and 4 elements for GLES2
CUSTOM_CVAR(Int, gl_pipeline_depth, 0, CVAR_ARCHIVE | CVAR_GLOBALCONFIG | CVAR_NOINITCALL) CUSTOM_CVAR(Int, gl_pipeline_depth, 0, CVAR_ARCHIVE | CVAR_GLOBALCONFIG | CVAR_NOINITCALL)
{ {

View file

@ -37,6 +37,7 @@
#include "hwrenderer/data/shaderuniforms.h" #include "hwrenderer/data/shaderuniforms.h"
CVAR(Int, vk_submit_size, 1000, 0); CVAR(Int, vk_submit_size, 1000, 0);
EXTERN_CVAR(Bool, r_skipmats)
VkRenderState::VkRenderState() VkRenderState::VkRenderState()
{ {
@ -239,6 +240,8 @@ void VkRenderState::ApplyRenderPass(int dt)
int effectState = mMaterial.mOverrideShader >= 0 ? mMaterial.mOverrideShader : (mMaterial.mMaterial ? mMaterial.mMaterial->GetShaderIndex() : 0); int effectState = mMaterial.mOverrideShader >= 0 ? mMaterial.mOverrideShader : (mMaterial.mMaterial ? mMaterial.mMaterial->GetShaderIndex() : 0);
pipelineKey.SpecialEffect = EFF_NONE; pipelineKey.SpecialEffect = EFF_NONE;
pipelineKey.EffectState = mTextureEnabled ? effectState : SHADER_NoTexture; pipelineKey.EffectState = mTextureEnabled ? effectState : SHADER_NoTexture;
if (r_skipmats && pipelineKey.EffectState >= 3 && pipelineKey.EffectState <= 4)
pipelineKey.EffectState = 0;
pipelineKey.AlphaTest = mAlphaThreshold >= 0.f; pipelineKey.AlphaTest = mAlphaThreshold >= 0.f;
} }