Skip to content

Commit

Permalink
opengl infos
Browse files Browse the repository at this point in the history
  • Loading branch information
sguionni committed Dec 9, 2024
1 parent 7734492 commit 8124ae7
Show file tree
Hide file tree
Showing 4 changed files with 42 additions and 14 deletions.
32 changes: 31 additions & 1 deletion lib/renderer/include/renderer/context/gl/struct_opengl_infos.hpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#include <array>
#include <string>
#include <util/logger.hpp>
#include <util/string.hpp>

namespace VTX::Renderer::Context::GL
{
Expand Down Expand Up @@ -29,5 +30,34 @@ namespace VTX::Renderer::Context::GL
int glMaxComputeWorkGroupInvocations;

std::array<bool, E_GL_EXTENSIONS::EXTENSIONS_COUNT> glExtensions = { false };

void print()
{
VTX_INFO( "OpenGL infos:" );
VTX_INFO( "Device: {} {}", glVendor, glRenderer );
VTX_INFO( "Version: {}", glVersion );

VTX_TRACE( "GLSL version: {}", glslVersion );
VTX_TRACE( "Max uniform block size: {}", Util::String::memSizeToStr( glMaxUniformBlockSize, false ) );
VTX_TRACE( "Max uniform buffer bindings: {}", glMaxUniformBufferBindings );
VTX_TRACE( "Max shader storage block size: {}", Util::String::memSizeToStr( glMaxShaderStorageBlockSize ) );
VTX_TRACE( "Max shader storage buffer bindings: {}", glMaxShaderStorageBufferBindings );
VTX_TRACE( "Max texture size: {}", glMaxTextureSize );
VTX_TRACE( "Max patch vertices: {}", glMaxPatchVertices );
VTX_TRACE( "Max tess gen level: {}", glMaxTessGenLevel );
VTX_TRACE(
"Max compute work group count: {} {} {}",
glMaxComputeWorkGroupCount[ 0 ],
glMaxComputeWorkGroupCount[ 1 ],
glMaxComputeWorkGroupCount[ 2 ]
);
VTX_TRACE(
"Max compute work group size: {} {} {}",
glMaxComputeWorkGroupSize[ 0 ],
glMaxComputeWorkGroupSize[ 1 ],
glMaxComputeWorkGroupSize[ 2 ]
);
VTX_TRACE( "Max compute work group invocations: {}", glMaxComputeWorkGroupInvocations );
}
};
} // namespace VTX::Renderer::Context::GL
6 changes: 1 addition & 5 deletions lib/renderer/src/renderer/context/opengl_45.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,7 @@ namespace VTX::Renderer::Context
_getOpenglInfos();
}

VTX_INFO( "Device: {} {}", _openglInfos.glVendor, _openglInfos.glRenderer );
VTX_INFO( "OpenGL initialized: {}.{}", GLVersion.major, GLVersion.minor );
_openglInfos.print();

// Program manager.
_programManager = std::make_unique<GL::ProgramManager>( p_shaderPath );
Expand Down Expand Up @@ -1016,7 +1015,6 @@ namespace VTX::Renderer::Context
// Extensions.
GLint numExtensions = 0;
glGetIntegerv( GL_NUM_EXTENSIONS, &numExtensions );
VTX_TRACE( "{} GL extensions", numExtensions );
for ( GLint i = 0; i < numExtensions; ++i )
{
const char * extension = (const char *)glGetStringi( GL_EXTENSIONS, i );
Expand All @@ -1028,8 +1026,6 @@ namespace VTX::Renderer::Context
{
_openglInfos.glExtensions[ GL::E_GL_EXTENSIONS::ATI_meminfo ] = true;
}

// VTX_DEBUG( "GL extension loaded: {}", extension );
}
}

Expand Down
2 changes: 1 addition & 1 deletion lib/util/include/util/string.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ namespace VTX::Util::String
void toUpper( std::string & p_str );
std::string toUpper( const std::string & p_str );
// Memory size to string.
std::string memSizeToStr( const size_t p_size );
std::string memSizeToStr( const size_t p_size, const bool p_isBase10 = true );
// Duration to string.
std::string durationToStr( const float p_durationInMS );

Expand Down
16 changes: 9 additions & 7 deletions lib/util/src/util/string.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -77,26 +77,28 @@ namespace VTX::Util::String
return upcasedStr;
}

std::string memSizeToStr( const size_t p_size )
std::string memSizeToStr( const size_t p_size, const bool p_isBase10 )
{
double size = static_cast<double>( p_size );
std::ostringstream oss;

if ( p_size < 1000 )
const uint base = p_isBase10 ? 1000 : 1024;

if ( p_size < base )
{
oss << size << " B";
}
else if ( p_size < 1000 * 1000 )
else if ( p_size < base * base )
{
oss << std::fixed << std::setprecision( 2 ) << ( size / 1000 ) << " KB";
oss << std::fixed << std::setprecision( 2 ) << ( size / base ) << " KB";
}
else if ( p_size < 1000 * 1000 * 1000 )
else if ( p_size < base * base * base )
{
oss << std::fixed << std::setprecision( 2 ) << ( size / ( 1000 * 1000 ) ) << " MB";
oss << std::fixed << std::setprecision( 2 ) << ( size / ( base * base ) ) << " MB";
}
else
{
oss << std::fixed << std::setprecision( 2 ) << ( size / ( 1000 * 1000 * 1000 ) ) << " GB";
oss << std::fixed << std::setprecision( 2 ) << ( size / ( base * base * base ) ) << " GB";
}

return oss.str();
Expand Down

0 comments on commit 8124ae7

Please sign in to comment.