Skip to content

Commit 091cfe7

Browse files
cursoragenttimfox
andcommitted
Vulkan: remove dead USE_TESS_NEEDS_* and flatten USE_FOG_COLLAPSE
USE_TESS_NEEDS_NORMAL and USE_TESS_NEEDS_ST2 were never defined in tr_local.h, so guarded tess assignments were dead and surface paths always copied normals and lightmap ST2. Drop the macros, unused shader/tess needsNormal/needsST2 fields, and DetectNeeds(). USE_FOG_COLLAPSE was unconditionally defined; remove the preprocessor wrappers and keep the active fog-collapse path unchanged. Co-authored-by: Tim Fox <timfox@outlook.com>
1 parent 2e197b8 commit 091cfe7

7 files changed

Lines changed: 6 additions & 152 deletions

File tree

src/renderers/vulkan/tr_animation.c

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -411,9 +411,6 @@ void RB_MDRSurfaceAnim( mdrSurface_t *surface )
411411
tempVert[1] += w->boneWeight * ( DotProduct( bone->matrix[1], w->offset ) + bone->matrix[1][3] );
412412
tempVert[2] += w->boneWeight * ( DotProduct( bone->matrix[2], w->offset ) + bone->matrix[2][3] );
413413

414-
#ifdef USE_TESS_NEEDS_NORMAL
415-
if ( tess.needsNormal )
416-
#endif
417414
{
418415
tempNormal[0] += w->boneWeight * DotProduct( bone->matrix[0], v->normal );
419416
tempNormal[1] += w->boneWeight * DotProduct( bone->matrix[1], v->normal );
@@ -425,9 +422,6 @@ void RB_MDRSurfaceAnim( mdrSurface_t *surface )
425422
tess.xyz[baseVertex + j][1] = tempVert[1];
426423
tess.xyz[baseVertex + j][2] = tempVert[2];
427424

428-
#ifdef USE_TESS_NEEDS_NORMAL
429-
if ( tess.needsNormal )
430-
#endif
431425
{
432426
tess.normal[baseVertex + j][0] = tempNormal[0];
433427
tess.normal[baseVertex + j][1] = tempNormal[1];

src/renderers/vulkan/tr_local.h

Lines changed: 1 addition & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
3535
#endif
3636

3737
#define USE_VBO // store static world geometry in VBO
38-
#define USE_FOG_COLLAPSE // not compatible with legacy dlights
38+
/* fog collapse path (not compatible with legacy dlights) */
3939
#define MAX_REAL_DLIGHTS (MAX_DLIGHTS*2)
4040
#define MAX_LITSURFS (MAX_DRAWSURFS)
4141
#define MAX_FLARES 256
@@ -46,9 +46,6 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
4646
#define USE_VBO_GRID /* put SF_GRID to VBO */
4747
#endif
4848

49-
//#define USE_TESS_NEEDS_NORMAL
50-
//#define USE_TESS_NEEDS_ST2
51-
5249
#define SH_COEFF_COUNT 9
5350

5451
#include "../../qcommon/q_shared.h"
@@ -546,11 +543,6 @@ typedef struct shader_s {
546543

547544
fogPass_t fogPass; // draw a blended pass, possibly with depth test equals
548545

549-
qboolean needsNormal; // not all shaders will need all data to be gathered
550-
//qboolean needsST1;
551-
qboolean needsST2;
552-
//qboolean needsColor;
553-
554546
int numDeforms;
555547
deformStage_t deforms[MAX_SHADER_DEFORMS];
556548

@@ -2114,14 +2106,6 @@ typedef struct shaderCommands_s
21142106
#endif
21152107
#endif
21162108

2117-
// info extracted from current shader
2118-
#ifdef USE_TESS_NEEDS_NORMAL
2119-
int needsNormal;
2120-
#endif
2121-
#ifdef USE_TESS_NEEDS_ST2
2122-
int needsST2;
2123-
#endif
2124-
21252109
int numPasses;
21262110
shaderStage_t **xstages;
21272111

src/renderers/vulkan/tr_main.c

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1078,9 +1078,6 @@ static qboolean SurfIsOffscreen( const drawSurf_t *drawSurf, qboolean *isMirror
10781078
RB_BeginSurface( shader, fogNum );
10791079
#ifdef USE_VBO
10801080
tess.allowVBO = qfalse;
1081-
#endif
1082-
#ifdef USE_TESS_NEEDS_NORMAL
1083-
tess.needsNormal = qtrue;
10841081
#endif
10851082
rb_surfaceTable[ *drawSurf->surface ]( drawSurf->surface );
10861083

src/renderers/vulkan/tr_shade.c

Lines changed: 1 addition & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -390,17 +390,6 @@ void RB_BeginSurface( shader_t *shader, int fogNum ) {
390390
tess.dlightUpdateParams = qtrue;
391391
}
392392

393-
#ifdef USE_TESS_NEEDS_NORMAL
394-
tess.needsNormal = state->needsNormal || tess.dlightPass || r_shownormals->integer ||
395-
( backEnd.currentEntity == &tr.worldEntity &&
396-
( ( r_shDebugView && r_shDebugView->integer ) ||
397-
( r_shWorldLighting && r_shWorldLighting->integer && r_shLighting && r_shLighting->integer ) ) );
398-
#endif
399-
400-
#ifdef USE_TESS_NEEDS_ST2
401-
tess.needsST2 = state->needsST2;
402-
#endif
403-
404393
tess.numIndexes = 0;
405394
tess.numVertexes = 0;
406395
tess.sdfUiEdge = -1.0f;
@@ -1289,15 +1278,12 @@ static void RB_IterateStagesGeneric( const shaderCommands_t *input )
12891278

12901279
is_pbr_surface = qfalse;
12911280

1292-
#ifdef USE_FOG_COLLAPSE
12931281
if ( fogCollapse ) {
12941282
VK_SetFogParams( &uniform, &fog_stage );
12951283
VectorCopy( backEnd.or.viewOrigin, uniform.eyePos );
12961284
vk_update_descriptor( VK_DESC_FOG_COLLAPSE, tr.fogImage->descriptor );
12971285
pushUniform = qtrue;
1298-
} else
1299-
#endif
1300-
{
1286+
} else {
13011287
fog_stage = 0;
13021288
if ( tess_flags & TESS_VPOS ) {
13031289
VectorCopy( backEnd.or.viewOrigin, uniform.eyePos );
@@ -1961,9 +1947,7 @@ void RB_StageIteratorGeneric( void )
19611947
return;
19621948
}
19631949

1964-
#ifdef USE_FOG_COLLAPSE
19651950
fogCollapse = tess.fogNum && tess.shader->fogPass && tess.shader->fogCollapse;
1966-
#endif
19671951
worldShOverride = ( r_shDebugView && r_shDebugView->integer == 3 );
19681952

19691953
// call shader function

src/renderers/vulkan/tr_shader.c

Lines changed: 0 additions & 74 deletions
Original file line numberDiff line numberDiff line change
@@ -3888,64 +3888,6 @@ static void InitShader( const char *name, int lightmapIndex ) {
38883888
}
38893889

38903890

3891-
static void DetectNeeds( void )
3892-
{
3893-
int i, n;
3894-
3895-
for ( i = 0; i < MAX_SHADER_STAGES; i++ )
3896-
{
3897-
if ( !stages[i].active )
3898-
break;
3899-
3900-
for ( n = 0; n < NUM_TEXTURE_BUNDLES; n++ ) {
3901-
const texCoordGen_t t = stages[i].bundle[n].tcGen;
3902-
if ( t == TCGEN_LIGHTMAP )
3903-
{
3904-
shader.needsST2 = qtrue;
3905-
}
3906-
if ( t == TCGEN_ENVIRONMENT_MAPPED || t == TCGEN_ENVIRONMENT_MAPPED_FP )
3907-
{
3908-
shader.needsNormal = qtrue;
3909-
}
3910-
if ( stages[i].bundle[n].alphaGen == AGEN_LIGHTING_SPECULAR || stages[i].bundle[n].rgbGen == CGEN_LIGHTING_DIFFUSE )
3911-
{
3912-
shader.needsNormal = qtrue;
3913-
}
3914-
}
3915-
#if 0
3916-
t1 = stages[i].bundle[0].tcGen;
3917-
t2 = stages[i].bundle[1].tcGen;
3918-
3919-
if ( t1 == TCGEN_LIGHTMAP || t2 == TCGEN_LIGHTMAP )
3920-
{
3921-
shader.needsST2 = qtrue;
3922-
}
3923-
if ( t1 == TCGEN_ENVIRONMENT_MAPPED || t1 == TCGEN_ENVIRONMENT_MAPPED_FP )
3924-
{
3925-
shader.needsNormal = qtrue;
3926-
}
3927-
if ( t2 == TCGEN_ENVIRONMENT_MAPPED || t2 == TCGEN_ENVIRONMENT_MAPPED_FP )
3928-
{
3929-
shader.needsNormal = qtrue;
3930-
}
3931-
if ( stages[i].bundle[0].alphaGen == AGEN_LIGHTING_SPECULAR || stages[i].bundle[0].rgbGen == CGEN_LIGHTING_DIFFUSE )
3932-
{
3933-
shader.needsNormal = qtrue;
3934-
}
3935-
#endif
3936-
}
3937-
for ( i = 0; i < shader.numDeforms; i++ )
3938-
{
3939-
if ( shader.deforms[i].deformation == DEFORM_WAVE || shader.deforms[i].deformation == DEFORM_NORMALS || shader.deforms[i].deformation == DEFORM_BULGE ) {
3940-
shader.needsNormal = qtrue;
3941-
}
3942-
if ( shader.deforms[i].deformation >= DEFORM_TEXT0 && shader.deforms[i].deformation <= DEFORM_TEXT7 ) {
3943-
shader.needsNormal = qtrue;
3944-
}
3945-
}
3946-
}
3947-
3948-
39493891
/*
39503892
=========================
39513893
FinishShader
@@ -4104,8 +4046,6 @@ static shader_t *FinishShader( void ) {
41044046
}
41054047
}
41064048

4107-
DetectNeeds();
4108-
41094049
// fix alphaGen flags to avoid redundant comparisons in R_ComputeColors()
41104050
for ( i = 0; i < MAX_SHADER_STAGES; i++ ) {
41114051
shaderStage_t *pStage = &stages[ i ];
@@ -4196,7 +4136,6 @@ static shader_t *FinishShader( void ) {
41964136

41974137
#ifdef USE_VULKAN
41984138

4199-
#ifdef USE_FOG_COLLAPSE
42004139
if ( vk.maxBoundDescriptorSets >= 6 && !(shader.contentFlags & CONTENTS_FOG) && shader.fogPass != FP_NONE ) {
42014140
fogCollapse = qtrue;
42024141
if ( stage == 1 ) {
@@ -4248,7 +4187,6 @@ static shader_t *FinishShader( void ) {
42484187
// if there is no fogs - assume that we can apply all color optimizations without any restrictions
42494188
fogCollapse = qtrue;
42504189
}
4251-
#endif
42524190

42534191
shader.tessFlags = TESS_XYZ;
42544192

@@ -4541,7 +4479,6 @@ static shader_t *FinishShader( void ) {
45414479
}
45424480

45434481

4544-
#ifdef USE_FOG_COLLAPSE
45454482
if ( fogCollapse && tr.numFogs > 0 ) {
45464483
Vk_Pipeline_Def fog_def;
45474484
Vk_Pipeline_Def fog_def_mirror;
@@ -4583,7 +4520,6 @@ static shader_t *FinishShader( void ) {
45834520

45844521
shader.fogCollapse = qtrue;
45854522
}
4586-
#endif
45874523
}
45884524
}
45894525
#endif // USE_VULKAN
@@ -4844,11 +4780,6 @@ shader_t *R_FindShader( const char *name, int lightmapIndex, qboolean mipRawImag
48444780

48454781
InitShader( strippedName, lightmapIndex );
48464782

4847-
/* needsNormal etc. could be set based on stage requirements. */
4848-
//shader.needsST1 = qtrue;
4849-
//shader.needsST2 = qtrue;
4850-
//shader.needsColor = qtrue;
4851-
48524783
//
48534784
// attempt to define shader from an explicit parameter file
48544785
//
@@ -4933,11 +4864,6 @@ qhandle_t RE_RegisterShaderFromImage(const char *name, int lightmapIndex, image_
49334864

49344865
InitShader( name, lightmapIndex );
49354866

4936-
/* needsNormal etc. could be set based on stage requirements. */
4937-
//shader.needsST1 = qtrue;
4938-
//shader.needsST2 = qtrue;
4939-
//shader.needsColor = qtrue;
4940-
49414867
//
49424868
// create the default shading commands
49434869
//

src/renderers/vulkan/tr_surface.c

Lines changed: 4 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -405,9 +405,6 @@ static void RB_SurfaceTriangles( const srfTriangles_t *srf ) {
405405
xyz[1] = dv->xyz[1];
406406
xyz[2] = dv->xyz[2];
407407

408-
#ifdef USE_TESS_NEEDS_NORMAL
409-
if ( tess.needsNormal )
410-
#endif
411408
{
412409
normal[0] = dv->normal[0];
413410
normal[1] = dv->normal[1];
@@ -433,9 +430,6 @@ static void RB_SurfaceTriangles( const srfTriangles_t *srf ) {
433430
texCoords0[0] = dv->st[0];
434431
texCoords0[1] = dv->st[1];
435432

436-
#ifdef USE_TESS_NEEDS_ST2
437-
if ( tess.needsST2 )
438-
#endif
439433
{
440434
texCoords1[0] = dv->lightmap[0];
441435
texCoords1[1] = dv->lightmap[1];
@@ -988,9 +982,6 @@ static void RB_SurfaceFace( const srfSurfaceFace_t *surf ) {
988982

989983
numPoints = surf->numPoints;
990984

991-
#ifdef USE_TESS_NEEDS_NORMAL
992-
if ( tess.needsNormal )
993-
#endif
994985
{
995986
if ( surf->normals ) {
996987
// per-vertex normals for non-coplanar faces
@@ -1017,13 +1008,8 @@ static void RB_SurfaceFace( const srfSurfaceFace_t *surf ) {
10171008
#ifdef USE_VK_PBR
10181009
tess.texCoords[0][ndx][0] = v[6];
10191010
tess.texCoords[0][ndx][1] = v[7];
1020-
#ifdef USE_TESS_NEEDS_ST2
1021-
if ( tess.needsST2 )
1022-
#endif
1023-
{
1024-
tess.texCoords[1][ndx][0] = v[8];
1025-
tess.texCoords[1][ndx][1] = v[9];
1026-
}
1011+
tess.texCoords[1][ndx][0] = v[8];
1012+
tess.texCoords[1][ndx][1] = v[9];
10271013
{
10281014
uint32_t color;
10291015
Com_Memcpy( &color, &v[10], sizeof( color ) );
@@ -1032,13 +1018,8 @@ static void RB_SurfaceFace( const srfSurfaceFace_t *surf ) {
10321018
#else
10331019
tess.texCoords[0][ndx][0] = v[3];
10341020
tess.texCoords[0][ndx][1] = v[4];
1035-
#ifdef USE_TESS_NEEDS_ST2
1036-
if ( tess.needsST2 )
1037-
#endif
1038-
{
1039-
tess.texCoords[1][ndx][0] = v[5];
1040-
tess.texCoords[1][ndx][1] = v[6];
1041-
}
1021+
tess.texCoords[1][ndx][0] = v[5];
1022+
tess.texCoords[1][ndx][1] = v[6];
10421023
{
10431024
uint32_t color;
10441025
Com_Memcpy( &color, &v[7], sizeof( color ) );
@@ -1300,17 +1281,11 @@ static void RB_SurfaceGrid( srfGridMesh_t *cv ) {
13001281
xyz[2] = dv->xyz[2];
13011282
texCoords0[0] = dv->st[0];
13021283
texCoords0[1] = dv->st[1];
1303-
#ifdef USE_TESS_NEEDS_ST2
1304-
if ( tess.needsST2 )
1305-
#endif
13061284
{
13071285
texCoords1[0] = dv->lightmap[0];
13081286
texCoords1[1] = dv->lightmap[1];
13091287
texCoords1 += 2;
13101288
}
1311-
#ifdef USE_TESS_NEEDS_NORMAL
1312-
if ( tess.needsNormal )
1313-
#endif
13141289
{
13151290
normal[0] = dv->normal[0];
13161291
normal[1] = dv->normal[1];

src/renderers/vulkan/vk_vbo.c

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -765,12 +765,6 @@ void R_BuildWorldVBO( msurface_t *surf, int surfCount )
765765
initItem( vbo->items + i + 1 );
766766
RB_BeginSurface( sf->shader, 0 );
767767
tess.allowVBO = qfalse; // block execution of VBO path as we need to tesselate geometry
768-
#ifdef USE_TESS_NEEDS_NORMAL
769-
tess.needsNormal = qtrue;
770-
#endif
771-
#ifdef USE_TESS_NEEDS_ST2
772-
tess.needsST2 = qtrue;
773-
#endif
774768
// tesselate
775769
rb_surfaceTable[ *sf->data ]( sf->data ); // VBO_PushData() may be called multiple times there
776770
// setup colors and texture coordinates

0 commit comments

Comments
 (0)