Skip to content

Commit

Permalink
FIx unnecessary generic shader permutations
Browse files Browse the repository at this point in the history
NUKE the GENERIC_2D macro and add `trGlobals_t::skipSubgroupProfiler` to skip the subgroup profiler instead.
  • Loading branch information
VReaperV committed Jan 9, 2025
1 parent 5f50300 commit cafe99a
Show file tree
Hide file tree
Showing 6 changed files with 9 additions and 29 deletions.
3 changes: 1 addition & 2 deletions src/engine/renderer/gl_shader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2193,8 +2193,7 @@ GLShader_generic::GLShader_generic( GLShaderManager *manager ) :
GLCompileMacro_USE_VERTEX_ANIMATION( this ),
GLCompileMacro_USE_TCGEN_ENVIRONMENT( this ),
GLCompileMacro_USE_TCGEN_LIGHTMAP( this ),
GLCompileMacro_USE_DEPTH_FADE( this ),
GLCompileMacro_GENERIC_2D( this )
GLCompileMacro_USE_DEPTH_FADE( this )
{
}

Expand Down
23 changes: 1 addition & 22 deletions src/engine/renderer/gl_shader.h
Original file line number Diff line number Diff line change
Expand Up @@ -2111,26 +2111,6 @@ class GLCompileMacro_USE_DEPTH_FADE :
}
};

class GLCompileMacro_GENERIC_2D :
GLCompileMacro {
public:
GLCompileMacro_GENERIC_2D( GLShader* shader ) :
GLCompileMacro( shader ) {
}

const char* GetName() const override {
return "GENERIC_2D";
}

EGLCompileMacro GetType() const override {
return EGLCompileMacro::GENERIC_2D;
}

void SetGeneric2D( bool enable ) {
SetMacro( enable );
}
};

class GLCompileMacro_USE_PHYSICAL_MAPPING :
GLCompileMacro
{
Expand Down Expand Up @@ -3961,8 +3941,7 @@ class GLShader_generic :
public GLCompileMacro_USE_VERTEX_ANIMATION,
public GLCompileMacro_USE_TCGEN_ENVIRONMENT,
public GLCompileMacro_USE_TCGEN_LIGHTMAP,
public GLCompileMacro_USE_DEPTH_FADE,
public GLCompileMacro_GENERIC_2D
public GLCompileMacro_USE_DEPTH_FADE
{
public:
GLShader_generic( GLShaderManager *manager );
Expand Down
2 changes: 1 addition & 1 deletion src/engine/renderer/glsl_source/shaderProfiler_fp.glsl
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

/* shaderProfiler_fp.glsl */

#if defined(r_profilerRenderSubGroups) && !defined(GENERIC_2D) && defined(HAVE_KHR_shader_subgroup_basic) && defined(HAVE_KHR_shader_subgroup_arithmetic)
#if defined(r_profilerRenderSubGroups) && defined(HAVE_KHR_shader_subgroup_basic) && defined(HAVE_KHR_shader_subgroup_arithmetic)
uniform float u_ProfilerZero;
uniform uint u_ProfilerRenderSubGroups;
IN(flat) float var_SubGroupCount;
Expand Down
2 changes: 1 addition & 1 deletion src/engine/renderer/glsl_source/shaderProfiler_vp.glsl
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

/* shaderProfiler_vp.glsl */

#if defined(r_profilerRenderSubGroups) && !defined(GENERIC_2D) && defined(HAVE_KHR_shader_subgroup_basic) && defined(HAVE_KHR_shader_subgroup_arithmetic)
#if defined(r_profilerRenderSubGroups) && defined(HAVE_KHR_shader_subgroup_basic) && defined(HAVE_KHR_shader_subgroup_arithmetic)
uniform uint u_ProfilerRenderSubGroups;
OUT(flat) float var_SubGroupCount;

Expand Down
2 changes: 2 additions & 0 deletions src/engine/renderer/tr_local.h
Original file line number Diff line number Diff line change
Expand Up @@ -2791,6 +2791,8 @@ enum class shaderProfilerRenderSubGroupsMode {
frontEndCounters_t pc;
int frontEndMsec; // not in pc due to clearing issue

bool skipSubgroupProfiler = false;

vec4_t clipRegion; // 2D clipping region

//
Expand Down
6 changes: 3 additions & 3 deletions src/engine/renderer/tr_shade.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -905,7 +905,7 @@ void Render_generic3D( shaderStage_t *pStage )
);
}

if ( r_profilerRenderSubGroups.Get() && !( pStage->stateBits & GLS_DEPTHMASK_TRUE ) ) {
if ( r_profilerRenderSubGroups.Get() && !( pStage->stateBits & GLS_DEPTHMASK_TRUE ) && !tr.skipSubgroupProfiler ) {
const uint mode = GetShaderProfilerRenderSubGroupsMode( pStage->stateBits );
if( mode == 0 ) {
return;
Expand All @@ -929,12 +929,12 @@ void Render_generic( shaderStage_t *pStage )
if ( backEnd.projection2D )
{
glState.glStateBitsMask = ~uint32_t( GLS_DEPTHMASK_TRUE ) | GLS_DEPTHTEST_DISABLE;
gl_genericShader->SetGeneric2D( true );
tr.skipSubgroupProfiler = true;

Render_generic3D( pStage );

glState.glStateBitsMask = 0;
gl_genericShader->SetGeneric2D( false );
tr.skipSubgroupProfiler = false;
return;
}

Expand Down

0 comments on commit cafe99a

Please sign in to comment.