exit(0);
}
+static int cmd_log_memory( int argc, const char *argv[] )
+{
+ vg_mem_log( vg_mem.rtmemory, 0, "rtmemory" );
+ return 0;
+}
+
static int cmd_vg_settings_toggle( int argc, const char *argv[] );
void vg_enter( int argc, char *argv[], const char *window_name )
{
vg_console_load_autos();
vg_console_reg_cmd( "vg_settings", cmd_vg_settings_toggle, NULL );
+ vg_console_reg_cmd( "vg_rtmemory", cmd_log_memory, NULL );
_vg_init_window( window_name );
vg_async_init();
}
if( alloc->flags & VG_MEMORY_SYSTEM )
+ {
if( (alloc->allocation_count + 1) > VG_MAX_ALLOCATIONS )
+ {
+ vg_error( "Alloc (%p) allocation count is at the limit of"
+ " %u allocations.\n", alloc, VG_MAX_ALLOCATIONS );
vg_fatal_error( "Max linear allocations reached" );
+ }
+ }
void *data;
vg_fatal_error( "realloc failed" );
alloc->alloc_table[ alloc->allocation_count-1 ].data = data;
+ alloc->alloc_table[ alloc->allocation_count-1 ].size = newsize;
alloc->last_alloc = data;
return data;
}
"Scratch buffer" );
}
+static void vg_mem_print_size( u32 bytes, char buf[32] )
+{
+ if( bytes > 1024*1024 )
+ snprintf( buf, 32, "%umb", bytes/(1024*1024) );
+ else if( bytes > 1024 )
+ snprintf( buf, 32, "%ukb", bytes/1024 );
+ else
+ snprintf( buf, 32, "%ub", bytes );
+}
+
void vg_mem_log( void *lin_alloc, int depth, const char *name )
{
if( vg_mem.use_libc_malloc ){
vg_linear_allocator *alloc = vg_linear_header( lin_alloc );
u32 s = alloc->size;
- f32 p = ((float)alloc->cur / (float)alloc->size) * 100.0f;
+ f32 p = ((float)alloc->cur / (float)s) * 100.0f;
for( int i=0; i<depth; i++ ) printf( " " );
- printf( "LA(%s): %u bytes, %f%% used\n", name, s, p );
+
+ char asize[32];
+ vg_mem_print_size( s, asize );
+ printf( "LA(%s): %s, %f%% used\n", name, asize, p );
if( alloc->flags & VG_MEMORY_SYSTEM ){
for( u32 i=0; i<alloc->allocation_count; i++ ){
if( meta->type == k_allocation_type_block ){
for( int i=0; i<depth+1; i++ ) printf( " " );
- printf( "B(%s): %u bytes\n", meta->name, meta->size );
+ vg_mem_print_size( meta->size, asize );
+ printf( "B(%s): %s\n", meta->name, asize );
}
else{
vg_mem_log( meta->data, depth +1, meta->name );
glBindFramebuffer( GL_FRAMEBUFFER, 0 );
glViewport( 0,0, vg.window_x, vg.window_y );
- glEnable(GL_BLEND);
+ glDisable(GL_BLEND);
glDisable(GL_DEPTH_TEST);
- glBlendFunc(GL_ONE_MINUS_DST_ALPHA, GL_DST_ALPHA);
- glBlendEquation(GL_FUNC_ADD);
v2f inverse;
vg_framebuffer_inverse_ratio( fb, inverse );