Skip to content

Commit 0d0e60b

Browse files
committed
Split RB_RenderPostDepthLightTile into 2 functions
Also reuse FBO width/height instead of calculating it.
1 parent 3cd5d86 commit 0d0e60b

File tree

1 file changed

+27
-28
lines changed

1 file changed

+27
-28
lines changed

src/engine/renderer/tr_backend.cpp

Lines changed: 27 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1210,38 +1210,18 @@ void RB_RunVisTests( )
12101210
}
12111211
}
12121212

1213-
void RB_RenderPostDepthLightTile()
1213+
static void RenderDepthTiles()
12141214
{
1215-
if ( !glConfig2.realtimeLighting )
1216-
{
1217-
return;
1218-
}
1219-
1220-
if ( !backEnd.refdef.numLights ) {
1221-
return;
1222-
}
1223-
1224-
vec3_t zParams;
1225-
int w, h;
1226-
1227-
if ( ( backEnd.refdef.rdflags & RDF_NOWORLDMODEL ) )
1228-
{
1229-
return;
1230-
}
1231-
1232-
GLIMP_LOGCOMMENT( "--- RB_RenderPostDepthLightTile ---" );
1233-
12341215
// 1st step
12351216
GL_State( GLS_DEPTHTEST_DISABLE );
12361217
GL_Cull( CT_TWO_SIDED );
12371218

12381219
R_BindFBO( tr.depthtile1FBO );
1239-
w = (glConfig.vidWidth + TILE_SIZE_STEP1 - 1) >> TILE_SHIFT_STEP1;
1240-
h = (glConfig.vidHeight + TILE_SIZE_STEP1 - 1) >> TILE_SHIFT_STEP1;
1241-
GL_Viewport( 0, 0, w, h );
1242-
GL_Scissor( 0, 0, w, h );
1220+
GL_Viewport( 0, 0, tr.depthtile1FBO->width, tr.depthtile1FBO->height );
1221+
GL_Scissor( 0, 0, tr.depthtile1FBO->width, tr.depthtile1FBO->height );
12431222
gl_depthtile1Shader->BindProgram( 0 );
12441223

1224+
vec3_t zParams;
12451225
zParams[ 0 ] = 2.0f * tanf( DEG2RAD( backEnd.refdef.fov_x * 0.5f) ) / glConfig.vidWidth;
12461226
zParams[ 1 ] = 2.0f * tanf( DEG2RAD( backEnd.refdef.fov_y * 0.5f) ) / glConfig.vidHeight;
12471227
zParams[ 2 ] = backEnd.viewParms.zFar;
@@ -1268,17 +1248,36 @@ void RB_RenderPostDepthLightTile()
12681248
// 2nd step
12691249
R_BindFBO( tr.depthtile2FBO );
12701250

1271-
w = (glConfig.vidWidth + TILE_SIZE - 1) >> TILE_SHIFT;
1272-
h = (glConfig.vidHeight + TILE_SIZE - 1) >> TILE_SHIFT;
1273-
GL_Viewport( 0, 0, w, h );
1274-
GL_Scissor( 0, 0, w, h );
1251+
GL_Viewport( 0, 0, tr.depthtile2FBO->width, tr.depthtile2FBO->height );
1252+
GL_Scissor( 0, 0, tr.depthtile2FBO->width, tr.depthtile2FBO->height );
12751253
gl_depthtile2Shader->BindProgram( 0 );
12761254

12771255
gl_depthtile2Shader->SetUniform_DepthTile1Bindless(
12781256
GL_BindToTMU( 0, tr.depthtile1RenderImage )
12791257
);
12801258

12811259
Tess_InstantScreenSpaceQuad();
1260+
}
1261+
1262+
void RB_RenderPostDepthLightTile()
1263+
{
1264+
if ( !glConfig2.realtimeLighting )
1265+
{
1266+
return;
1267+
}
1268+
1269+
if ( !backEnd.refdef.numLights ) {
1270+
return;
1271+
}
1272+
1273+
if ( ( backEnd.refdef.rdflags & RDF_NOWORLDMODEL ) )
1274+
{
1275+
return;
1276+
}
1277+
1278+
GLIMP_LOGCOMMENT( "--- RB_RenderPostDepthLightTile ---" );
1279+
1280+
RenderDepthTiles();
12821281

12831282
vec3_t projToViewParams;
12841283
projToViewParams[0] = tanf(DEG2RAD(backEnd.refdef.fov_x * 0.5f)) * backEnd.viewParms.zFar;

0 commit comments

Comments
 (0)