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

View file

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