Shader status window

This commit is contained in:
Emmanuel BENOîT 2017-10-06 18:42:51 +02:00
parent af53c19949
commit ee023c7fe8
3 changed files with 93 additions and 4 deletions

View file

@ -175,10 +175,10 @@ void T_Main::makeUI( )
ImGui::SetNextWindowPos( ImVec2( ) , ImGuiSetCond_Once );
ImGui::Begin( "Tools" );
ImGui::Checkbox( "Demo controls" , &demoCtrl_ );
ImGui::Checkbox( "Profiler" , &Globals::Profiler( ).uiEnabled( ) );
ImGui::Checkbox( "Output debugger" ,
&Globals::ODbg( ).uiEnabled( ) );
ImGui::Checkbox( "Demo controls" , &demoCtrl_ );
ImGui::Checkbox( "Profiler" , &Globals::Profiler( ).uiEnabled( ) );
ImGui::Checkbox( "Output debugger" , &Globals::ODbg( ).uiEnabled( ) );
ImGui::Checkbox( "Shaders" , &Globals::Shaders( ).uiEnabled( ) );
ImGui::End( );
@ -188,6 +188,7 @@ void T_Main::makeUI( )
Globals::Profiler( ).makeUI( );
Globals::ODbg( ).makeUI( );
Globals::Shaders( ).makeUI( );
}
void T_Main::render( )

View file

@ -476,6 +476,7 @@ T_ShaderPipeline T_ShaderManager::pipeline(
return T_ShaderPipeline{ int32_t( index ) };
}
/*----------------------------------------------------------------------------*/
void T_ShaderManager::update( )
{
@ -834,3 +835,84 @@ void T_ShaderManager::resetProgram(
}
}
}
/*----------------------------------------------------------------------------*/
void T_ShaderManager::makeUI( )
{
if ( !uiEnabled_ ) {
return;
}
auto const& dspSize( ImGui::GetIO( ).DisplaySize );
ImGui::SetNextWindowSize( ImVec2( dspSize.x , 150 ) ,
ImGuiSetCond_Once );
ImGui::SetNextWindowPos( ImVec2( 0 , dspSize.y - 150 ) ,
ImGuiSetCond_Once );
ImGui::Begin( "Shaders" );
const auto n( std::count_if( programs_.begin( ) , programs_.end( ) ,
[]( auto const& p ) { return !p.references.empty( ); } ) );
std::vector< size_t > indices;
const auto rn = programs_.size( );
for ( auto i = 0u ; i < rn ; i ++ ) {
if ( !programs_[ i ].references.empty( ) ) {
indices.push_back( i );
}
}
std::sort( indices.begin( ) , indices.end( ) ,
[this]( size_t a , size_t b ) {
auto const& pa( programs_[ a ] );
auto const& pb( programs_[ b ] );
if ( pa.code.errors.size( ) != pb.code.errors.size( ) ) {
return pa.code.errors.size( ) > pb.code.errors.size( );
}
if ( pa.references.size( ) != pb.references.size( ) ) {
return pa.references.size( ) > pb.references.size( );
}
return programs_[ a ].name < programs_[ b ].name;
} );
for ( auto i = 0u ; i < n ; i ++ ) {
auto const& program( programs_[ indices[ i ] ] );
const auto nErrors( program.code.errors.size( ) );
const bool open( nErrors
? ImGui::TreeNodeEx( &program , ImGuiTreeNodeFlags_OpenOnArrow
| ImGuiTreeNodeFlags_OpenOnDoubleClick , "%s" ,
program.name.c_str( ) )
: false );
if ( !nErrors ) {
ImGui::Text( "%s" , program.name.c_str( ) );
}
ImGui::SameLine( 400 );
ImGui::Text( "Usage: %zu" , program.references.size( ) );
ImGui::SameLine( 550 );
if ( program.code.errors.empty( ) ) {
ImGui::PushStyleColor( ImGuiCol_Text , ImVec4( .6 , 1 , .6 , 1 ) );
ImGui::Text( "No errors" );
} else {
ImGui::PushStyleColor( ImGuiCol_Text , ImVec4( 1 , .6 , .6 , 1 ) );
ImGui::Text( "%zu error%s" , nErrors , nErrors > 1 ? "s" : "" );
}
ImGui::PopStyleColor( );
if ( open ) {
for ( auto const& err : program.code.errors ) {
ImGui::NewLine( );
ImGui::SameLine( 50 );
ImGui::Text( "%s" , err.source.c_str( ) );
ImGui::SameLine( 250 );
ImGui::Text( "line %d" , err.line );
ImGui::SameLine( 370 );
ImGui::Text( "%s" , err.error.c_str( ) );
}
ImGui::TreePop( );
}
}
ImGui::End( );
}

View file

@ -117,6 +117,10 @@ struct T_ShaderManager
void update( );
void makeUI( );
bool& uiEnabled( )
{ return uiEnabled_; }
private:
struct T_Pipeline_
{
@ -135,6 +139,8 @@ struct T_ShaderManager
std::unique_ptr< T_WatchedFiles > watch;
};
bool uiEnabled_ = false;
std::vector< T_Pipeline_ > pipelines_;
std::map< std::string , uint32_t > pipelineIndex_;