Skip to content

Commit

Permalink
tr_backend: do not run lightTile code if the tiled renderer is disabl…
Browse files Browse the repository at this point in the history
…ed, save r300 ALU, fix DaemonEngine#344
  • Loading branch information
illwieckz committed Oct 14, 2020
1 parent ced56d8 commit 80b10d5
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 4 deletions.
33 changes: 30 additions & 3 deletions src/engine/renderer/tr_backend.cpp
Expand Up @@ -2758,7 +2758,7 @@ void RB_RunVisTests( )
}
}

void RB_RenderPostDepth()
void RB_RenderPostDepthLightTile()
{
static vec4_t quadVerts[4] = {
{ -1.0f, -1.0f, 0.0f, 1.0f },
Expand All @@ -2769,7 +2769,31 @@ void RB_RenderPostDepth()
vec3_t zParams;
int w, h;

GLimp_LogComment( "--- RB_RenderPostDepth ---\n" );
GLimp_LogComment( "--- RB_RenderPostDepthLightTile ---\n" );

if ( r_dynamicLight->integer != 2 )
{
/* Do not run lightTile code when the tiled renderer is not used.
This computation is part of the tiled dynamic lighting renderer,
it's better to not run it and save CPU cycles when such effects
are disabled.
Disabling this code also make possible to not compile the related
GLSL shaders at all when such effects are disabled.
Not running the related GLSL shaders also helps older hardware to
run the game, for example the Radeon R300 Arithmetic Logic Unit is
too small to run the related GLSL code even if the shader itself
can be compiled. Such GPU are so old and slow that any kind of
dynamic lighting including the tiled implementation is expected to
be disabled anyway. Saving CPU cycles when a feature is not used is
welcome in any case.
See https://github.com/DaemonEngine/Daemon/issues/344 */

return;
}

if ( ( backEnd.refdef.rdflags & RDF_NOWORLDMODEL ) )
{
Expand Down Expand Up @@ -2843,7 +2867,10 @@ void RB_RenderPostDepth()
if( !glConfig2.glCoreProfile )
glEnable( GL_POINT_SPRITE );
glEnable( GL_PROGRAM_POINT_SIZE );

// Radeon R300 small ALU is known to fail on this.
Tess_DrawArrays( GL_POINTS );

glDisable( GL_PROGRAM_POINT_SIZE );
if( !glConfig2.glCoreProfile )
glDisable( GL_POINT_SPRITE );
Expand Down Expand Up @@ -4656,7 +4683,7 @@ static void RB_RenderView( bool depthPass )
if( depthPass ) {
RB_RenderDrawSurfaces( shaderSort_t::SS_DEPTH, shaderSort_t::SS_DEPTH, DRAWSURFACES_ALL );
RB_RunVisTests();
RB_RenderPostDepth();
RB_RenderPostDepthLightTile();
return;
}

Expand Down
14 changes: 13 additions & 1 deletion src/engine/renderer/tr_shade.cpp
Expand Up @@ -342,7 +342,19 @@ void Tess_DrawArrays( GLenum elementType )
return;
}

// move tess data through the GPU, finally
/* Move tess data through the GPU, finally.
Radeon R300 small ALU is known to fail on this glDrawArrays call:
> r300 FP: Compiler Error:
> ../src/gallium/drivers/r300/compiler/r300_fragprog_emit.c::emit_alu(): Too many ALU instructions
> Using a dummy shader instead.
> r300 FP: Compiler Error:
> build_loop_info: Cannot find condition for if
> Using a dummy shader instead.
See https://github.com/DaemonEngine/Daemon/issues/344 */

glDrawArrays( elementType, 0, tess.numVertexes );

backEnd.pc.c_drawElements++;
Expand Down

0 comments on commit 80b10d5

Please sign in to comment.