Skip to content

Commit 6f3ac3f

Browse files
committed
Additional cleanup after NUKING forward lighting
1 parent 3bfef60 commit 6f3ac3f

File tree

7 files changed

+58
-68
lines changed

7 files changed

+58
-68
lines changed

src/engine/renderer/GeometryOptimiser.cpp

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -58,16 +58,16 @@ static int LeafSurfaceCompare( const void* a, const void* b ) {
5858
}
5959

6060
// sort by leaf
61-
if ( aa->interactionBits < bb->interactionBits ) {
61+
if ( aa->scratch2 < bb->scratch2 ) {
6262
return -1;
63-
} else if ( aa->interactionBits > bb->interactionBits ) {
63+
} else if ( aa->scratch2 > bb->scratch2 ) {
6464
return 1;
6565
}
6666

6767
// sort by leaf marksurfaces index to increase the likelihood of multidraw merging in the backend
68-
if ( aa->lightCount < bb->lightCount ) {
68+
if ( aa->scratch1 < bb->scratch1 ) {
6969
return -1;
70-
} else if ( aa->lightCount > bb->lightCount ) {
70+
} else if ( aa->scratch1 > bb->scratch1 ) {
7171
return 1;
7272
}
7373
return 0;
@@ -147,8 +147,8 @@ static void CoreResetSurfaceViewCounts( bspSurface_t** rendererSurfaces, int num
147147
bspSurface_t* surface = rendererSurfaces[i];
148148

149149
surface->viewCount = -1;
150-
surface->lightCount = -1;
151-
surface->interactionBits = 0;
150+
surface->scratch1 = -1;
151+
surface->scratch2 = 0;
152152
}
153153
}
154154

@@ -175,8 +175,8 @@ void OptimiseMapGeometryCore( world_t* world, bspSurface_t** rendererSurfaces, i
175175
int fogIndex1 = surf1->fogIndex;
176176
int lightMapNum1 = surf1->lightmapNum;
177177
surf1->viewCount = surf1 - world->surfaces;
178-
surf1->lightCount = j;
179-
surf1->interactionBits = i;
178+
surf1->scratch1 = j;
179+
surf1->scratch2 = i;
180180

181181
bool merged = false;
182182
for ( int k = j + 1; k < leaf->numMarkSurfaces; k++ ) {
@@ -198,14 +198,14 @@ void OptimiseMapGeometryCore( world_t* world, bspSurface_t** rendererSurfaces, i
198198
}
199199

200200
surf2->viewCount = surf1->viewCount;
201-
surf2->lightCount = k;
202-
surf2->interactionBits = i;
201+
surf2->scratch1 = k;
202+
surf2->scratch2 = i;
203203
merged = true;
204204
}
205205

206206
if ( !merged ) {
207207
surf1->viewCount = -1;
208-
surf1->lightCount = -1;
208+
surf1->scratch1 = -1;
209209
// don't clear the leaf number so
210210
// surfaces that arn't merged are placed
211211
// closer to other leafs in the vbo

src/engine/renderer/tr_backend.cpp

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2208,8 +2208,8 @@ static void RB_RenderDebugUtils()
22082208
plane_t splitFrustum[ 6 ];
22092209
for ( j = 0; j < 6; j++ )
22102210
{
2211-
VectorCopy( backEnd.viewParms.frustums[ 0 ][ j ].normal, splitFrustum[ j ].normal );
2212-
splitFrustum[ j ].dist = backEnd.viewParms.frustums[ 0 ][ j ].dist;
2211+
VectorCopy( backEnd.viewParms.frustum[ j ].normal, splitFrustum[ j ].normal );
2212+
splitFrustum[ j ].dist = backEnd.viewParms.frustum[ j ].dist;
22132213
}
22142214

22152215
// calculate split frustum corner points
@@ -3170,20 +3170,20 @@ const RenderCommand *SetupLightsCommand::ExecuteSelf( ) const
31703170
GL_MAP_WRITE_BIT | GL_MAP_INVALIDATE_BUFFER_BIT );
31713171

31723172
for( int i = 0, j = 0; i < numLights; i++, j++ ) {
3173-
trRefLight_t *light = &refdef.lights[j];
3173+
refLight_t *light = &refdef.lights[j];
31743174

3175-
VectorCopy( light->l.origin, buffer[i].center );
3176-
buffer[i].radius = light->l.radius;
3177-
VectorScale( light->l.color, 4.0f * light->l.scale, buffer[i].color );
3178-
buffer[i].type = Util::ordinal( light->l.rlType );
3179-
switch( light->l.rlType ) {
3175+
VectorCopy( light->origin, buffer[i].center );
3176+
buffer[i].radius = light->radius;
3177+
VectorScale( light->color, 4.0f * light->scale, buffer[i].color );
3178+
buffer[i].type = Util::ordinal( light->rlType );
3179+
switch( light->rlType ) {
31803180
case refLightType_t::RL_PROJ:
3181-
VectorCopy( light->l.projTarget,
3181+
VectorCopy( light->projTarget,
31823182
buffer[i].direction );
3183-
buffer[i].angle = cosf( atan2f( VectorLength( light->l.projUp), VectorLength( light->l.projTarget ) ) );
3183+
buffer[i].angle = cosf( atan2f( VectorLength( light->projUp), VectorLength( light->projTarget ) ) );
31843184
break;
31853185
case refLightType_t::RL_DIRECTIONAL:
3186-
VectorCopy( light->l.projTarget,
3186+
VectorCopy( light->projTarget,
31873187
buffer[i].direction );
31883188
break;
31893189
default:

src/engine/renderer/tr_bsp.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2757,8 +2757,6 @@ static void R_CreateWorldVBO() {
27572757

27582758
// clear data used for sorting
27592759
surface->viewCount = -1;
2760-
surface->lightCount = -1;
2761-
surface->interactionBits = 0;
27622760
}
27632761

27642762
ri.Hunk_FreeTempMemory( rendererSurfaces );

src/engine/renderer/tr_local.h

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -406,12 +406,6 @@ enum class ssaoMode {
406406
vec3_t projUp;
407407
};
408408

409-
// TODO: remove useless struct
410-
struct trRefLight_t
411-
{
412-
refLight_t l;
413-
};
414-
415409
// a structure matching the GLSL struct shaderLight in std140 layout
416410
struct shaderLight_t {
417411
vec3_t center;
@@ -1391,7 +1385,7 @@ enum class ssaoMode {
13911385
trRefEntity_t *entities;
13921386

13931387
int numLights;
1394-
trRefLight_t *lights;
1388+
refLight_t *lights;
13951389

13961390
int numPolys;
13971391
struct srfPoly_t *polys;
@@ -1482,7 +1476,7 @@ enum class ssaoMode {
14821476
matrix_t projectionMatrixNonPortal; // For skybox rendering in portals
14831477
matrix_t unprojectionMatrix; // transform pixel window space -> world space
14841478

1485-
frustum_t frustums[ 1 ]; // FIXME: need not be array (was for shadowmaps)
1479+
frustum_t frustum;
14861480

14871481
vec3_t visBounds[ 2 ];
14881482
float zNear;
@@ -1737,9 +1731,7 @@ enum class ssaoMode {
17371731
{
17381732
int viewCount; // if == tr.viewCount, already added
17391733

1740-
// FIXME not used for lighting
1741-
int lightCount;
1742-
int interactionBits;
1734+
int scratch1, scratch2;
17431735

17441736
struct shader_t *shader;
17451737

@@ -3741,7 +3733,7 @@ void GLimp_LogComment_( std::string comment );
37413733
{
37423734
drawSurf_t drawSurfs[ MAX_DRAWSURFS ];
37433735

3744-
trRefLight_t lights[ MAX_REF_LIGHTS ];
3736+
refLight_t lights[ MAX_REF_LIGHTS ];
37453737
trRefEntity_t entities[ MAX_REF_ENTITIES ];
37463738

37473739
srfPoly_t *polys; //[MAX_POLYS];

src/engine/renderer/tr_main.cpp

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -349,7 +349,7 @@ cullResult_t R_CullBox( vec3_t worldBounds[ 2 ] )
349349

350350
for ( i = 0; i < FRUSTUM_PLANES; i++ )
351351
{
352-
frust = &tr.viewParms.frustums[ 0 ][ i ];
352+
frust = &tr.viewParms.frustum[ i ];
353353

354354
r = BoxOnPlaneSide( worldBounds[ 0 ], worldBounds[ 1 ], frust );
355355

@@ -426,7 +426,7 @@ cullResult_t R_CullPointAndRadius( vec3_t pt, float radius )
426426
// check against frustum planes
427427
for ( i = 0; i < Util::ordinal(frustumBits_t::FRUSTUM_PLANES); i++ )
428428
{
429-
frust = &tr.viewParms.frustums[ 0 ][ i ];
429+
frust = &tr.viewParms.frustum[ i ];
430430

431431
dist = DotProduct( pt, frust->normal ) - frust->dist;
432432

@@ -878,11 +878,11 @@ static void R_SetupFrustum()
878878

879879
MatrixTransformPlane2(invTransform, plane);
880880

881-
VectorCopy(plane.normal, tr.viewParms.frustums[0][i].normal);
882-
tr.viewParms.frustums[0][i].dist = plane.dist;
881+
VectorCopy(plane.normal, tr.viewParms.frustum[i].normal);
882+
tr.viewParms.frustum[i].dist = plane.dist;
883883

884-
SetPlaneSignbits(&tr.viewParms.frustums[0][i]);
885-
tr.viewParms.frustums[0][i].type = PLANE_NON_AXIAL;
884+
SetPlaneSignbits(&tr.viewParms.frustum[i]);
885+
tr.viewParms.frustum[i].type = PLANE_NON_AXIAL;
886886
}
887887
}
888888
else
@@ -891,36 +891,36 @@ static void R_SetupFrustum()
891891
xs = sinf( ang );
892892
xc = cosf( ang );
893893

894-
VectorScale( tr.viewParms.orientation.axis[ 0 ], xs, tr.viewParms.frustums[ 0 ][ 0 ].normal );
895-
VectorMA( tr.viewParms.frustums[ 0 ][ 0 ].normal, xc, tr.viewParms.orientation.axis[ 1 ], tr.viewParms.frustums[ 0 ][ 0 ].normal );
894+
VectorScale( tr.viewParms.orientation.axis[ 0 ], xs, tr.viewParms.frustum[ 0 ].normal );
895+
VectorMA( tr.viewParms.frustum[ 0 ].normal, xc, tr.viewParms.orientation.axis[ 1 ], tr.viewParms.frustum[ 0 ].normal );
896896

897-
VectorScale( tr.viewParms.orientation.axis[ 0 ], xs, tr.viewParms.frustums[ 0 ][ 1 ].normal );
898-
VectorMA( tr.viewParms.frustums[ 0 ][ 1 ].normal, -xc, tr.viewParms.orientation.axis[ 1 ], tr.viewParms.frustums[ 0 ][ 1 ].normal );
897+
VectorScale( tr.viewParms.orientation.axis[ 0 ], xs, tr.viewParms.frustum[ 1 ].normal );
898+
VectorMA( tr.viewParms.frustum[ 1 ].normal, -xc, tr.viewParms.orientation.axis[ 1 ], tr.viewParms.frustum[ 1 ].normal );
899899

900900
ang = DEG2RAD( tr.viewParms.fovY * 0.5f );
901901
xs = sinf( ang );
902902
xc = cosf( ang );
903903

904-
VectorScale( tr.viewParms.orientation.axis[ 0 ], xs, tr.viewParms.frustums[ 0 ][ 2 ].normal );
905-
VectorMA( tr.viewParms.frustums[ 0 ][ 2 ].normal, xc, tr.viewParms.orientation.axis[ 2 ], tr.viewParms.frustums[ 0 ][ 2 ].normal );
904+
VectorScale( tr.viewParms.orientation.axis[ 0 ], xs, tr.viewParms.frustum[ 2 ].normal );
905+
VectorMA( tr.viewParms.frustum[ 2 ].normal, xc, tr.viewParms.orientation.axis[ 2 ], tr.viewParms.frustum[ 2 ].normal );
906906

907-
VectorScale( tr.viewParms.orientation.axis[ 0 ], xs, tr.viewParms.frustums[ 0 ][ 3 ].normal );
908-
VectorMA( tr.viewParms.frustums[ 0 ][ 3 ].normal, -xc, tr.viewParms.orientation.axis[ 2 ], tr.viewParms.frustums[ 0 ][ 3 ].normal );
907+
VectorScale( tr.viewParms.orientation.axis[ 0 ], xs, tr.viewParms.frustum[ 3 ].normal );
908+
VectorMA( tr.viewParms.frustum[ 3 ].normal, -xc, tr.viewParms.orientation.axis[ 2 ], tr.viewParms.frustum[ 3 ].normal );
909909

910910
for ( int i = 0; i < 4; i++ )
911911
{
912-
tr.viewParms.frustums[ 0 ][ i ].type = PLANE_NON_AXIAL;
913-
tr.viewParms.frustums[ 0 ][ i ].dist = DotProduct( tr.viewParms.orientation.origin, tr.viewParms.frustums[ 0 ][ i ].normal );
914-
SetPlaneSignbits( &tr.viewParms.frustums[ 0 ][ i ] );
912+
tr.viewParms.frustum[ i ].type = PLANE_NON_AXIAL;
913+
tr.viewParms.frustum[ i ].dist = DotProduct( tr.viewParms.orientation.origin, tr.viewParms.frustum[ i ].normal );
914+
SetPlaneSignbits( &tr.viewParms.frustum[ i ] );
915915
}
916916

917917
// Tr3B: set extra near plane which is required by the dynamic occlusion culling
918-
tr.viewParms.frustums[ 0 ][ FRUSTUM_NEAR ].type = PLANE_NON_AXIAL;
919-
VectorCopy( tr.viewParms.orientation.axis[ 0 ], tr.viewParms.frustums[ 0 ][ FRUSTUM_NEAR ].normal );
918+
tr.viewParms.frustum[ FRUSTUM_NEAR ].type = PLANE_NON_AXIAL;
919+
VectorCopy( tr.viewParms.orientation.axis[ 0 ], tr.viewParms.frustum[ FRUSTUM_NEAR ].normal );
920920

921-
VectorMA( tr.viewParms.orientation.origin, r_znear->value, tr.viewParms.frustums[ 0 ][ FRUSTUM_NEAR ].normal, planeOrigin );
922-
tr.viewParms.frustums[ 0 ][ FRUSTUM_NEAR ].dist = DotProduct( planeOrigin, tr.viewParms.frustums[ 0 ][ FRUSTUM_NEAR ].normal );
923-
SetPlaneSignbits( &tr.viewParms.frustums[ 0 ][ FRUSTUM_NEAR ] );
921+
VectorMA( tr.viewParms.orientation.origin, r_znear->value, tr.viewParms.frustum[ FRUSTUM_NEAR ].normal, planeOrigin );
922+
tr.viewParms.frustum[ FRUSTUM_NEAR ].dist = DotProduct( planeOrigin, tr.viewParms.frustum[ FRUSTUM_NEAR ].normal );
923+
SetPlaneSignbits( &tr.viewParms.frustum[ FRUSTUM_NEAR ] );
924924
}
925925
}
926926

@@ -2054,7 +2054,7 @@ void R_RenderView( viewParms_t *parms )
20542054

20552055
if ( glConfig2.usingMaterialSystem && !r_materialSystemSkip.Get() ) {
20562056
tr.viewParms.viewID = tr.viewCount;
2057-
materialSystem.QueueSurfaceCull( tr.viewCount, tr.viewParms.pvsOrigin, (frustum_t*) tr.viewParms.frustums[0] );
2057+
materialSystem.QueueSurfaceCull( tr.viewCount, tr.viewParms.pvsOrigin, (frustum_t*) tr.viewParms.frustum );
20582058
materialSystem.AddAutospriteSurfaces();
20592059
} else {
20602060
R_AddWorldSurfaces();

src/engine/renderer/tr_scene.cpp

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -285,7 +285,7 @@ ydnar: modified dlight system to support separate radius and intensity
285285
*/
286286
void RE_AddDynamicLightToSceneET( const vec3_t org, float radius, float intensity, float r, float g, float b, qhandle_t, int flags )
287287
{
288-
trRefLight_t *light;
288+
refLight_t *light;
289289

290290
if ( !glConfig2.realtimeLighting || !r_drawDynamicLights.Get() )
291291
{
@@ -315,16 +315,16 @@ void RE_AddDynamicLightToSceneET( const vec3_t org, float radius, float intensit
315315

316316
light = &backEndData[ tr.smpFrame ]->lights[ r_numLights++ ];
317317

318-
light->l.rlType = refLightType_t::RL_OMNI;
319-
VectorCopy( org, light->l.origin );
318+
light->rlType = refLightType_t::RL_OMNI;
319+
VectorCopy( org, light->origin );
320320

321-
light->l.radius = radius;
321+
light->radius = radius;
322322

323-
light->l.color[ 0 ] = r;
324-
light->l.color[ 1 ] = g;
325-
light->l.color[ 2 ] = b;
323+
light->color[ 0 ] = r;
324+
light->color[ 1 ] = g;
325+
light->color[ 2 ] = b;
326326

327-
light->l.scale = intensity;
327+
light->scale = intensity;
328328
}
329329

330330
void RE_AddDynamicLightToSceneQ3A( const vec3_t org, float radius, float r, float g, float b )

src/engine/renderer/tr_world.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -297,7 +297,7 @@ static void R_RecursiveWorldNode( bspNode_t *node, int planeBits )
297297
{
298298
if ( planeBits & ( 1 << i ) )
299299
{
300-
r = BoxOnPlaneSide( node->mins, node->maxs, &tr.viewParms.frustums[ 0 ][ i ] );
300+
r = BoxOnPlaneSide( node->mins, node->maxs, &tr.viewParms.frustum[ i ] );
301301

302302
if ( r == 2 )
303303
{

0 commit comments

Comments
 (0)