Shader code - list of files + missing/found

This commit is contained in:
Emmanuel BENOîT 2017-10-03 16:25:46 +02:00
parent 8eefe21aae
commit 7a7ff88ac6
2 changed files with 13 additions and 2 deletions

View file

@ -171,6 +171,7 @@ bool T_ShaderCodeLoader::load(
T_ShaderInput const* const main( getInput( name ) ); T_ShaderInput const* const main( getInput( name ) );
if ( !main ) { if ( !main ) {
code.files.emplace( name , false );
return false; return false;
} }
if ( main->type == E_ShaderInput::LIBRARY if ( main->type == E_ShaderInput::LIBRARY
@ -218,6 +219,7 @@ bool T_ShaderCodeLoader::load(
} else if ( libraries.find( nname ) == libraries.end( ) ) { } else if ( libraries.find( nname ) == libraries.end( ) ) {
// Load it unless it's a library that's already included // Load it unless it's a library that's already included
T_ShaderInput const* const isi( getInput( nname ) ); T_ShaderInput const* const isi( getInput( nname ) );
code.files.emplace( nname , isi != nullptr );
if ( isi && ( isi->type == E_ShaderInput::CHUNK if ( isi && ( isi->type == E_ShaderInput::CHUNK
|| isi->type == E_ShaderInput::LIBRARY ) ) { || isi->type == E_ShaderInput::LIBRARY ) ) {
// Ok, let's do this // Ok, let's do this
@ -292,9 +294,17 @@ void testLoadShaderFile( )
T_Frankenshader code; T_Frankenshader code;
if ( loader.load( source , code ) ) { if ( loader.load( source , code ) ) {
printf( "SUCCESS! TYPE = %d\n" , int( code.type ) ); printf( "SUCCESS! TYPE = %d\n" , int( code.type ) );
printf( "FILES:\n" );
for ( auto const& e : code.files ) {
printf( " -> %s (%s)\n" , e.first.c_str( ) ,
e.second ? "found" : "missing" );
}
if ( code.errors.size( ) ) {
printf( "ERRORS:\n" );
for ( auto const& err : code.errors ) { for ( auto const& err : code.errors ) {
printf( "%s:%d: %s\n" , err.source.c_str( ) , err.line , err.error.c_str( ) ); printf( "%s:%d: %s\n" , err.source.c_str( ) , err.line , err.error.c_str( ) );
} }
}
} else { } else {
printf( "fail :'(\n" ); printf( "fail :'(\n" );
} }

View file

@ -79,6 +79,7 @@ struct T_Frankenshader
std::vector< std::string > sources; // Chunk source files std::vector< std::string > sources; // Chunk source files
std::string code; std::string code;
std::vector< T_ShaderError > errors; std::vector< T_ShaderError > errors;
std::map< std::string , bool > files;
}; };
using P_Frankenshader = std::unique_ptr< T_Frankenshader >; using P_Frankenshader = std::unique_ptr< T_Frankenshader >;