commit 0a6fe56204ed5d87f021623c1fab0e5f6bdca9c8 parent 5e53ea1e8ba56994b29a1c896c023c8e69ede909 Author: Michael Savage <mikejsavage@gmail.com> Date: Thu Aug 31 22:54:37 +0300 Small renderer API cleanup Diffstat:
renderer.h | | | 25 | ++++++++----------------- |
diff --git a/renderer.h b/renderer.h @@ -271,39 +271,30 @@ constexpr size_t renderer_ub_alignment() { } template< typename T > -constexpr size_t renderer_ub_size( size_t size ) { +constexpr size_t renderer_uniforms_size( size_t size ) { return sizeof( T ) + align_power_of_2( size, renderer_ubo_alignment< T >() ); } template< typename S, typename T, typename... Rest > -constexpr size_t renderer_ub_size( size_t size ) { - return renderer_ub_size< T, Rest... >( sizeof( S ) + align_power_of_2( size, renderer_ubo_alignment< S >() ) ); +constexpr size_t renderer_uniforms_size( size_t size ) { + return renderer_uniforms_size< T, Rest... >( sizeof( S ) + align_power_of_2( size, renderer_ubo_alignment< S >() ) ); } -inline void renderer_ub_easy_helper( char * buf, size_t len ) { } +inline void renderer_uniforms_copy( char * buf, size_t len ) { } template< typename T, typename... Rest > -inline void renderer_ub_easy_helper( char * buf, size_t len, const T & first, Rest... rest ) { +inline void renderer_uniforms_copy( char * buf, size_t len, const T & first, Rest... rest ) { len = align_power_of_2( len, renderer_ubo_alignment< T >() ); memcpy( buf + len, &first, sizeof( first ) ); - renderer_ub_easy_helper( buf, len + sizeof( first ), rest... ); -} - -template< typename... Rest > -inline void renderer_ub_easy( UB ub, Rest... rest ) { - constexpr size_t buf_size = renderer_ub_size< Rest... >( 0 ); - char buf[ buf_size ]; - memset( buf, 0, sizeof( buf ) ); - renderer_ub_easy_helper( buf, 0, rest... ); - renderer_ub_data( ub, buf, sizeof( buf ) ); + renderer_uniforms_copy( buf, len + sizeof( first ), rest... ); } template< typename... Rest > inline UniformBinding renderer_uniforms( Rest... rest ) { - constexpr size_t buf_size = renderer_ub_size< Rest... >( 0 ); + constexpr size_t buf_size = renderer_uniforms_size< Rest... >( 0 ); constexpr u32 alignment = renderer_ub_alignment< Rest... >(); char buf[ buf_size ]; memset( buf, 0, sizeof( buf ) ); - renderer_ub_easy_helper( buf, 0, rest... ); + renderer_uniforms_copy( buf, 0, rest... ); return renderer_ub_data( buf, sizeof( buf ), alignment ); }