Skip to content

Commit fe20e6c

Browse files
committed
Additional cleanup after NUKING forward lighting
1 parent 220c330 commit fe20e6c

File tree

9 files changed

+58
-71
lines changed

9 files changed

+58
-71
lines changed

src/engine/renderer/GeometryOptimiser.cpp

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

6363
// sort by leaf
64-
if ( aa->interactionBits < bb->interactionBits ) {
64+
if ( aa->scratch2 < bb->scratch2 ) {
6565
return -1;
66-
} else if ( aa->interactionBits > bb->interactionBits ) {
66+
} else if ( aa->scratch2 > bb->scratch2 ) {
6767
return 1;
6868
}
6969

7070
// sort by leaf marksurfaces index to increase the likelihood of multidraw merging in the backend
71-
if ( aa->lightCount < bb->lightCount ) {
71+
if ( aa->scratch1 < bb->scratch1 ) {
7272
return -1;
73-
} else if ( aa->lightCount > bb->lightCount ) {
73+
} else if ( aa->scratch1 > bb->scratch1 ) {
7474
return 1;
7575
}
7676
return 0;
@@ -150,8 +150,8 @@ static void CoreResetSurfaceViewCounts( bspSurface_t** rendererSurfaces, int num
150150
bspSurface_t* surface = rendererSurfaces[i];
151151

152152
surface->viewCount = -1;
153-
surface->lightCount = -1;
154-
surface->interactionBits = 0;
153+
surface->scratch1 = -1;
154+
surface->scratch2 = 0;
155155
}
156156
}
157157

@@ -178,8 +178,8 @@ void OptimiseMapGeometryCore( world_t* world, bspSurface_t** rendererSurfaces, i
178178
int fogIndex1 = surf1->fogIndex;
179179
int lightMapNum1 = surf1->lightmapNum;
180180
surf1->viewCount = surf1 - world->surfaces;
181-
surf1->lightCount = j;
182-
surf1->interactionBits = i;
181+
surf1->scratch1 = j;
182+
surf1->scratch2 = i;
183183

184184
bool merged = false;
185185
for ( int k = j + 1; k < leaf->numMarkSurfaces; k++ ) {
@@ -201,14 +201,14 @@ void OptimiseMapGeometryCore( world_t* world, bspSurface_t** rendererSurfaces, i
201201
}
202202

203203
surf2->viewCount = surf1->viewCount;
204-
surf2->lightCount = k;
205-
surf2->interactionBits = i;
204+
surf2->scratch1 = k;
205+
surf2->scratch2 = i;
206206
merged = true;
207207
}
208208

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

src/engine/renderer/gl_shader.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1326,8 +1326,6 @@ void GLShaderManager::InitShader( GLShader* shader ) {
13261326
continue;
13271327
}
13281328

1329-
shader->BuildShaderCompileMacros( compileMacros );
1330-
13311329
const uint32_t uniqueMacros = shader->GetUniqueCompileMacros( i, shaderType.type );
13321330

13331331
ShaderDescriptor* desc = FindShader( shader->_name, shaderType.mainText, shaderType.GLType, shaderType.headers,

src/engine/renderer/gl_shader.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,6 @@ class GLShader {
181181
void PostProcessUniforms();
182182
uint32_t GetUniqueCompileMacros( size_t permutation, const int type ) const;
183183
bool GetCompileMacrosString( size_t permutation, std::string &compileMacrosOut, const int type ) const;
184-
virtual void BuildShaderCompileMacros( std::string& /*vertexInlines*/ ) { };
185184
virtual void SetShaderProgramUniforms( ShaderProgramDescriptor* /*shaderProgram*/ ) { };
186185
int SelectProgram();
187186
public:

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
@@ -2753,8 +2753,6 @@ static void R_CreateWorldVBO() {
27532753

27542754
// clear data used for sorting
27552755
surface->viewCount = -1;
2756-
surface->lightCount = -1;
2757-
surface->interactionBits = 0;
27582756
}
27592757

27602758
ri.Hunk_FreeTempMemory( rendererSurfaces );

src/engine/renderer/tr_local.h

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

407-
// TODO: remove useless struct
408-
struct trRefLight_t
409-
{
410-
refLight_t l;
411-
};
412-
413407
// a structure matching the GLSL struct shaderLight in std140 layout
414408
struct shaderLight_t {
415409
vec3_t center;
@@ -1387,7 +1381,7 @@ enum class ssaoMode {
13871381
trRefEntity_t *entities;
13881382

13891383
int numLights;
1390-
trRefLight_t *lights;
1384+
refLight_t *lights;
13911385

13921386
int numPolys;
13931387
struct srfPoly_t *polys;
@@ -1467,7 +1461,7 @@ enum class ssaoMode {
14671461
matrix_t projectionMatrixNonPortal; // For skybox rendering in portals
14681462
matrix_t unprojectionMatrix; // transform pixel window space -> world space
14691463

1470-
frustum_t frustums[ 1 ]; // FIXME: need not be array (was for shadowmaps)
1464+
frustum_t frustum;
14711465

14721466
vec3_t visBounds[ 2 ];
14731467
float zNear;
@@ -1721,9 +1715,7 @@ enum class ssaoMode {
17211715
{
17221716
int viewCount; // if == tr.viewCount, already added
17231717

1724-
// FIXME not used for lighting
1725-
int lightCount;
1726-
int interactionBits;
1718+
int scratch1, scratch2;
17271719

17281720
struct shader_t *shader;
17291721

@@ -3721,7 +3713,7 @@ void GLimp_LogComment_( std::string comment );
37213713
{
37223714
drawSurf_t drawSurfs[ MAX_DRAWSURFS ];
37233715

3724-
trRefLight_t lights[ MAX_REF_LIGHTS ];
3716+
refLight_t lights[ MAX_REF_LIGHTS ];
37253717
trRefEntity_t entities[ MAX_REF_ENTITIES ];
37263718

37273719
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)