]> de.git.xonotic.org Git - xonotic/netradiant.git/blobdiff - tools/quake3/q3map2/lightmaps_ydnar.c
Merge commit 'aa4bc3893f6c0c360c91896eba46631e53b2f0d1' into master-merge
[xonotic/netradiant.git] / tools / quake3 / q3map2 / lightmaps_ydnar.c
index 3c08c8b60d13c1223ba795bdf08a556121300bf1..2802ecaf4370c223b2d8c3e29ce6b8061154ca9d 100644 (file)
@@ -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" );