X-Git-Url: http://git.xonotic.org/?a=blobdiff_plain;f=tools%2Fquake3%2Fq3map2%2Flightmaps_ydnar.c;h=2802ecaf4370c223b2d8c3e29ce6b8061154ca9d;hb=414307f1eb6b2f46b87121ea71d63adf973cf571;hp=3c08c8b60d13c1223ba795bdf08a556121300bf1;hpb=2ce2d42b275b2a710227b375e495a817799fe2a6;p=xonotic%2Fnetradiant.git diff --git a/tools/quake3/q3map2/lightmaps_ydnar.c b/tools/quake3/q3map2/lightmaps_ydnar.c index 3c08c8b6..2802ecaf 100644 --- a/tools/quake3/q3map2/lightmaps_ydnar.c +++ b/tools/quake3/q3map2/lightmaps_ydnar.c @@ -2325,6 +2325,16 @@ static int CompareRawLightmap( const void *a, const void *b ){ /* get min number of surfaces */ min = ( alm->numLightSurfaces < blm->numLightSurfaces ? alm->numLightSurfaces : blm->numLightSurfaces ); +//#define allocate_bigger_first +#ifdef allocate_bigger_first + /* compare size, allocate bigger first */ + // fastAllocate commit part: can kick fps by unique lightmap/shader combinations*=~2 + bigger compile time + //return -diff; makes packing faster and rough + diff = ( blm->w * blm->h ) - ( alm->w * alm->h ); + if ( diff != 0 ) { + return diff; + } +#endif /* iterate */ for ( i = 0; i < min; i++ ) { @@ -2346,13 +2356,13 @@ static int CompareRawLightmap( const void *a, const void *b ){ if ( diff ) { return diff; } - +#ifndef allocate_bigger_first /* compare size */ diff = ( blm->w * blm->h ) - ( alm->w * alm->h ); if ( diff != 0 ) { return diff; } - +#endif /* must be equivalent */ return 0; } @@ -2471,15 +2481,13 @@ void FillOutLightmap( outLightmap_t *olm ){ } } - - /* StoreSurfaceLightmaps() stores the surface lightmaps into the bsp as byte rgb triplets */ void StoreSurfaceLightmaps( qboolean fastAllocate, qboolean storeForReal ){ - int i, j, k, x, y, lx, ly, sx, sy, *cluster, mappedSamples; + int i, j, k, x, y, lx, ly, sx, sy, *cluster, mappedSamples, timer_start; int style, size, lightmapNum, lightmapNum2; float *normal, *luxel, *bspLuxel, *bspLuxel2, *radLuxel, samples, occludedSamples; vec3_t sample, occludedSample, dirSample, colorMins, colorMaxs; @@ -2522,6 +2530,8 @@ void StoreSurfaceLightmaps( qboolean fastAllocate, qboolean storeForReal ){ /* note it */ Sys_FPrintf( SYS_VRB, "Subsampling..." ); + timer_start = I_FloatTime(); + /* walk the list of raw lightmaps */ numUsed = 0; numTwins = 0; @@ -2855,6 +2865,8 @@ void StoreSurfaceLightmaps( qboolean fastAllocate, qboolean storeForReal ){ } } + Sys_FPrintf( SYS_VRB, "%d.", (int) ( I_FloatTime() - timer_start ) ); + /* ----------------------------------------------------------------- convert modelspace deluxemaps to tangentspace ----------------------------------------------------------------- */ @@ -2864,6 +2876,8 @@ void StoreSurfaceLightmaps( qboolean fastAllocate, qboolean storeForReal ){ vec3_t worldUp, myNormal, myTangent, myBinormal; float dist; + timer_start = I_FloatTime(); + Sys_Printf( "converting..." ); for ( i = 0; i < numRawLightmaps; i++ ) @@ -2933,6 +2947,8 @@ void StoreSurfaceLightmaps( qboolean fastAllocate, qboolean storeForReal ){ } } } + + Sys_FPrintf( SYS_VRB, "%d.", (int) ( I_FloatTime() - timer_start ) ); } } @@ -2989,6 +3005,8 @@ void StoreSurfaceLightmaps( qboolean fastAllocate, qboolean storeForReal ){ /* note it */ Sys_FPrintf( SYS_VRB, "collapsing..." ); + timer_start = I_FloatTime(); + /* set all twin refs to null */ for ( i = 0; i < numRawLightmaps; i++ ) { @@ -3049,6 +3067,8 @@ void StoreSurfaceLightmaps( qboolean fastAllocate, qboolean storeForReal ){ } } } + + Sys_FPrintf( SYS_VRB, "%d.", (int) ( I_FloatTime() - timer_start ) ); } /* ----------------------------------------------------------------- @@ -3058,6 +3078,8 @@ void StoreSurfaceLightmaps( qboolean fastAllocate, qboolean storeForReal ){ /* note it */ Sys_FPrintf( SYS_VRB, "sorting..." ); + timer_start = I_FloatTime(); + /* allocate a new sorted list */ if ( sortLightmaps == NULL ) { sortLightmaps = safe_malloc( numRawLightmaps * sizeof( int ) ); @@ -3068,6 +3090,8 @@ void StoreSurfaceLightmaps( qboolean fastAllocate, qboolean storeForReal ){ sortLightmaps[ i ] = i; qsort( sortLightmaps, numRawLightmaps, sizeof( int ), CompareRawLightmap ); + Sys_FPrintf( SYS_VRB, "%d.", (int) ( I_FloatTime() - timer_start ) ); + /* ----------------------------------------------------------------- allocate output lightmaps ----------------------------------------------------------------- */ @@ -3076,6 +3100,8 @@ void StoreSurfaceLightmaps( qboolean fastAllocate, qboolean storeForReal ){ /* note it */ Sys_FPrintf( SYS_VRB, "allocating..." ); + timer_start = I_FloatTime(); + /* kill all existing output lightmaps */ if ( outLightmaps != NULL ) { for ( i = 0; i < numOutLightmaps; i++ ) @@ -3123,6 +3149,8 @@ void StoreSurfaceLightmaps( qboolean fastAllocate, qboolean storeForReal ){ } } + Sys_FPrintf( SYS_VRB, "%d.", (int) ( I_FloatTime() - timer_start ) ); + /* ----------------------------------------------------------------- store output lightmaps ----------------------------------------------------------------- */ @@ -3131,6 +3159,8 @@ void StoreSurfaceLightmaps( qboolean fastAllocate, qboolean storeForReal ){ /* note it */ Sys_FPrintf( SYS_VRB, "storing..." ); + timer_start = I_FloatTime(); + /* count the bsp lightmaps and allocate space */ if ( bspLightBytes != NULL ) { free( bspLightBytes ); @@ -3215,6 +3245,8 @@ void StoreSurfaceLightmaps( qboolean fastAllocate, qboolean storeForReal ){ } } + Sys_FPrintf( SYS_VRB, "%d.", (int) ( I_FloatTime() - timer_start ) ); + /* ----------------------------------------------------------------- project the lightmaps onto the bsp surfaces ----------------------------------------------------------------- */ @@ -3223,6 +3255,8 @@ void StoreSurfaceLightmaps( qboolean fastAllocate, qboolean storeForReal ){ /* note it */ Sys_FPrintf( SYS_VRB, "projecting..." ); + timer_start = I_FloatTime(); + /* walk the list of surfaces */ for ( i = 0; i < numBSPDrawSurfaces; i++ ) { @@ -3500,6 +3534,8 @@ void StoreSurfaceLightmaps( qboolean fastAllocate, qboolean storeForReal ){ } } + Sys_FPrintf( SYS_VRB, "%d.", (int) ( I_FloatTime() - timer_start ) ); + /* finish */ Sys_FPrintf( SYS_VRB, "done.\n" );