-
Notifications
You must be signed in to change notification settings - Fork 35
Description
As explained on discord already, when I did modular renderer + vulkan port.
I noticed something off using renderdoc,.
ISSUE:
Just rendering main menu + open console with minimal content already results in over 450 drawcalls.
vulkan-renderdoc.mp4
Nativly it should merge matching shaders and do it in about 30 drawcalls, this is huge difference.
expected-behaivior.mp4
I have checked this on Vanilla renderer, with the same result.
r_consoleFont being set higher then "0" is what is causing this, Which seem to default to "1".
So for most people it is adding overhead.
vanilla.mp4
REASON:
r_consoleFont is using shader remapping here.
https://github.com/JKSunny/jk2mv/blob/5e9a273895e73342e03221df546a7c6d59812ea4/src/renderer/tr_cmds.cpp#L393-L405
//
// console font stuff
//
if ( r_consoleFont->modified ) {
r_consoleFont->modified = qfalse;
if ( r_consoleFont->integer == 1 )
R_RemapShader("gfx/2d/charsgrid_med", "gfx/2d/code_new_roman", 0);
else if ( r_consoleFont->integer == 2 )
R_RemapShader("gfx/2d/charsgrid_med", "gfx/2d/mplus_1m_bold", 0);
else
R_RemapShader("gfx/2d/charsgrid_med", "gfx/2d/charsgrid_med", 0);
}setting sh->remappedShader pointer.
Then when a character or symbol is processsed for rendering, it starts here:
https://github.com/JKSunny/jk2mv/blob/master/src/renderer/tr_backend.cpp#L885-L892
shader = cmd->shader;
// info
// shader == the orignal shader
// tess.shader == sh->remappedShader. set in tr_shade.cpp:RB_BeginSurface( )
// making this always fire, causing a new drawcall
if ( shader != tess.shader ) {
if ( tess.numIndexes ) {
RB_EndSurface();
}
backEnd.currentEntity = &backEnd.entity2D;
RB_BeginSurface( shader, 0 );
}For my vulkan port I did ad a quick hotfix, more or less to illustrate the problem.
// from:
if ( shader != tess.shader ) {
// to:
if ( shader != tess.shader &&
!( tess.shader && shader->remappedShader && shader->remappedShader == tess.shader ) ) However I think this should be done in an earlier stage.
Likely not using "R_RemapShader" at all.
Anyway, I think this should be enough to picture this.