Skip to content

Commit

Permalink
* (bug #4842) Speedup shader buffer creation (Eugene C.)
Browse files Browse the repository at this point in the history
  • Loading branch information
timangus committed Dec 19, 2010
1 parent 7000b9a commit 35c1e98
Showing 1 changed file with 12 additions and 11 deletions.
23 changes: 12 additions & 11 deletions code/renderer/tr_shader.c
Expand Up @@ -2866,7 +2866,6 @@ void R_ShaderList_f (void) {
ri.Printf (PRINT_ALL, "------------------\n");
}


/*
====================
ScanAndLoadShaderFiles
Expand All @@ -2883,7 +2882,7 @@ static void ScanAndLoadShaderFiles( void )
char *p;
int numShaderFiles;
int i;
char *oldp, *token, *hashMem;
char *oldp, *token, *hashMem, *textEnd;
int shaderTextHashTableSizes[MAX_SHADERTEXT_HASH], hash, size;

long sum = 0, summand;
Expand Down Expand Up @@ -2944,20 +2943,22 @@ static void ScanAndLoadShaderFiles( void )
// build single large buffer
s_shaderText = ri.Hunk_Alloc( sum + numShaderFiles*2, h_low );
s_shaderText[ 0 ] = '\0';

textEnd = s_shaderText;

// free in reverse order, so the temp files are all dumped
for ( i = numShaderFiles - 1; i >= 0 ; i-- )
{
if(buffers[i])
{
p = &s_shaderText[strlen(s_shaderText)];
strcat( s_shaderText, buffers[i] );
ri.FS_FreeFile( buffers[i] );
COM_Compress(p);
strcat( s_shaderText, "\n" );
}
if ( !buffers[i] )
continue;

strcat( textEnd, buffers[i] );
strcat( textEnd, "\n" );
textEnd += strlen( textEnd );
ri.FS_FreeFile( buffers[i] );
}

COM_Compress( s_shaderText );

// free up memory
ri.FS_FreeFileList( shaderFiles );

Expand Down

0 comments on commit 35c1e98

Please sign in to comment.