render: dump preprocessed, but not compiled shaders, do not use line directive

This commit is contained in:
mittorn 2021-02-16 20:38:06 +00:00
parent 42ddf60d26
commit 1a74bf30c8
1 changed files with 15 additions and 4 deletions

View File

@ -491,8 +491,8 @@ static void GL_ParseFile( const char *filename, CVirtualFS *file, CVirtualFS *ou
char line[2048];
// out->Printf( "#file %s\n", filename ); // OpenGL doesn't support #file :-(
out->Printf( "#line 0\n" );
// out->Printf( "#line 0\n" );
out->Printf( "// file %s\n", filename ); // just print file name for now
do
{
ret = file->Gets( line, sizeof( line ));
@ -514,7 +514,7 @@ static void GL_ParseFile( const char *filename, CVirtualFS *file, CVirtualFS *ou
}
GL_ParseFile( incname, &incfile, out );
// out->Printf( "#file %s\n", filename ); // OpenGL doesn't support #file :-(
out->Printf( "#line %i\n", fileline );
// out->Printf( "#line %i\n", fileline ); // Do not print line as we save failed preprocessed shaders
}
else out->Printf( "%s\n", line );
fileline++;
@ -601,6 +601,7 @@ static void GL_LoadGPUShader( glsl_program_t *shader, const char *name, GLenum s
GLcharARB *buffer = (GLcharARB *)source.GetBuffer();
int bufferSize = source.GetSize();
ALERT( at_aiconsole, "loading '%s'\n", filename );
object = pglCreateShaderObjectARB( shaderType );
pglShaderSourceARB( object, GL_TRUE, (const GLcharARB **)&buffer, &bufferSize );
@ -613,6 +614,16 @@ static void GL_LoadGPUShader( glsl_program_t *shader, const char *name, GLenum s
if( !compiled )
{
char name2[256];
COM_FileBase( name, name2 );
FILE *preprocessed = fopen(va("%s_%s.preprocessed.glsl", name2, shaderType == GL_VERTEX_SHADER_ARB ? "vp": "fp" ), "w");
if( preprocessed )
{
fwrite(buffer, 1, bufferSize, preprocessed );
fprintf(preprocessed, "// log: %s\n", GL_PrintInfoLog( object ));
fclose(preprocessed);
}
if( developer_level ) Msg( "%s", GL_PrintInfoLog( object ));
if( developer_level ) Msg( "Shader options:%s\n", GL_PretifyListOptions( defines ));
ALERT( at_error, "Couldn't compile %s\n", filename );
@ -1356,4 +1367,4 @@ void GL_FreeGPUShaders( void )
GL_FreeGPUShader( &glsl_programs[i] );
GL_BindShader( GL_NONE );
}
}