void vsx_widget_profiler_plot::update_vbo() { draw_bucket_a.vertices.reset_used(); draw_bucket_a.faces.reset_used(); draw_bucket_b.vertices.reset_used(); draw_bucket_b.faces.reset_used(); vsx_printf("time scale: %f\n", time_scale::get_instance()->time_scale_x); switch (plot_type) { case v_t: update_plot_v_t(); break; case x_y: update_plot_x_y(); break; } time_scale::get_instance()->one_div_chunk_time_end = 1.0 / time_scale::get_instance()->chunk_time_end; time_scale::get_instance()->one_div_time_size_x = 1.0 / time_scale::get_instance()->time_size_x; draw_bucket_a.invalidate_vertices(); draw_bucket_a.invalidate_colors(); draw_bucket_a.update(); draw_bucket_b.invalidate_vertices(); draw_bucket_b.invalidate_colors(); draw_bucket_b.update(); set_size(vsx_vector3<>(20.0f,0.3f)); }
void vsx_widget_profiler_plot::update_plot_v_t() { vsx_printf(L"time scale: %f\n", time_scale::get_instance()->time_scale_x); draw_bucket_a.vertices.reset_used(); draw_bucket_a.faces.reset_used(); for (size_t i = 0; i < consumer_chunks.size(); i++) { vsx_profiler_consumer_plot& plot = consumer_chunks[i]; double ct = (plot.time ) * time_scale::get_instance()->time_scale_x; ct += time_scale::get_instance()->time_offset; if (ct < -15.0) continue; if (ct > 15.0) continue; draw_bucket_a.vertices.push_back( vsx_vector3<>( ct, plot.v.x ) ); draw_bucket_a.vertex_colors.push_back( vsx_color<>(1.0, 0.5, 0.5, 0.5) ); vsx_face1 idx; idx.a = draw_bucket_a.vertices.size() - 1; draw_bucket_a.faces.push_back( idx ); } draw_bucket_b.vertices.reset_used(); draw_bucket_b.faces.reset_used(); for (size_t i = 0; i < consumer_chunks.size(); i++) { vsx_profiler_consumer_plot& plot = consumer_chunks[i]; double ct = (plot.time ) * time_scale::get_instance()->time_scale_x; ct += time_scale::get_instance()->time_offset; if (ct < -15.0) continue; if (ct > 15.0) continue; draw_bucket_b.vertices.push_back( vsx_vector3<>( ct, plot.v.y ) ); draw_bucket_b.vertex_colors.push_back( vsx_color<>(0.5, 0.5, 1.0, 0.5) ); vsx_face1 idx; idx.a = draw_bucket_b.vertices.size() - 1; draw_bucket_b.faces.push_back( idx ); } }
int main() { int procs = 0; int i; pthread_t *thrs; // Getting number of CPUs procs = (int)sysconf( _SC_NPROCESSORS_ONLN ); if (procs < 0) { perror( "sysconf" ); return -1; } typedef char tag[36]; vsx_printf("This system has %d cores available\n", procs); thrs = (pthread_t*)malloc( sizeof( pthread_t ) * procs ); if (thrs == NULL) { perror( "malloc" ); return -1; } pthread_create( &thrs[0], NULL, thread_producer, 0x0 ); pthread_create( &thrs[1], NULL, thread_producer2, 0x0 ); sleep( 20 ); __sync_fetch_and_sub( &run_threads, 1); for (i = 0; i < 2; i++) { pthread_join( thrs[i], NULL ); } free( thrs ); return 0; }
void vsx_widget_profiler_plot::event_mouse_double_click(vsx_widget_distance distance,vsx_widget_coords coords,int button) { VSX_UNUSED(distance); VSX_UNUSED(coords); VSX_UNUSED(button); if (!selected_chunk) return; double tdiff = selected_chunk->time_end - selected_chunk->time_start; vsx_printf("tdiff. %f\n", tdiff); time_scale::get_instance()->time_scale_x = 0.5 / (tdiff) ; time_scale::get_instance()->time_offset = -time_scale::get_instance()->time_scale_x * (selected_chunk->time_start + 0.5 * tdiff); camera.set_pos( vsx_vector3<>(0.0, 0.0, 1.9) ); update_vbo(); }
void myErrorCallback ( GLenum _source, GLenum _type, GLuint _id, GLenum _severity, GLsizei _length, const char* _message, void* _user_param ) { VSX_UNUSED(_source); VSX_UNUSED(_type); VSX_UNUSED(_severity); VSX_UNUSED(_length); VSX_UNUSED(_user_param); VSX_UNUSED(_id); vsx_printf("GLDEBUG: %s\n", _message); }
void *thread_producer2( void *arg ) { VSX_UNUSED(arg); vsx_profiler* p = vsx_profiler_manager::get_instance()->get_profiler(); while ( __sync_fetch_and_add( &run_threads, 0) ) { p->maj_begin(); p->sub_begin("2 test1"); usleep(100); p->sub_begin("2 test2"); usleep(300); p->sub_end(); usleep(50); p->sub_end(); p->maj_end(); } vsx_printf("exiting p2\n"); pthread_exit(0); return NULL; }
void log(vsx_string<>message, int level) { #if PLATFORM_FAMILY == PLATFORM_FAMILY_UNIX openlog ("vsx_engine", LOG_CONS | LOG_PID | LOG_NDELAY, LOG_LOCAL1); syslog(LOG_ERR,"%d: %s", level, message.c_str()); #else vsx_printf(L"VSX_LOG: %hs\n", message.c_str() ); /* if (log_level < level) return; printf("%s\n",message.c_str()); FILE* fpo = 0; if (first) { fpo = fopen((log_dir+"vsx_engine.debug.log").c_str(),"w"); first = 0; } else fpo = fopen((log_dir+"vsx_engine.debug.log").c_str(),"a"); if (!fpo) return; fprintf(fpo, "%s\n", message.c_str() ); fclose(fpo);*/ #endif }
void vsx_widget_profiler_thread::event_mouse_down(vsx_widget_distance distance,vsx_widget_coords coords,int button) { double x = coords.world_global.x; double factor = time_scale::get_instance()->world_to_time_factor(x); // decide which way to iterate // long index = (long)(factor * consumer_chunks.size()); selected_chunk = 0x0; int mouse_depth = depth_from_mouse_position(); vsx_printf(L"mouse depth: %d\n", mouse_depth); if (mouse_depth < 0) { vsx_widget::event_mouse_down(distance, coords, button); return; } for (size_t i = 0; i < consumer_chunks.size(); i++) { if ( factor < consumer_chunks[i].time_end * time_scale::get_instance()->one_div_chunk_time_end && factor > consumer_chunks[i].time_start * time_scale::get_instance()->one_div_chunk_time_end && mouse_depth == (int)consumer_chunks[i].depth ) { selected_chunk = &consumer_chunks[i]; return; } } vsx_widget::event_mouse_down(distance, coords, button); }
void GLFWCALL window_size( int width, int height ) { vsx_printf("change viewport %d %d\n", width, height); gl_state.viewport_change(0,0,width, height); }
void vsx_widget_profiler_plot::load_plot(uint64_t id) { vsx_printf("load profile plot %ld\n", id); vsx_profiler_consumer::get_instance()->get_plot( id, consumer_chunks); update(); }
void vsx_widget_profiler_thread::update_vbo() { draw_bucket.vertices.reset_used(); draw_bucket.faces.reset_used(); vsx_printf(L"time scale: %f\n", time_scale::get_instance()->time_scale_x); size_t max_depth = 1; for (size_t i = 0; i < consumer_chunks.size(); i++) { vsx_profiler_consumer_chunk& chunk = consumer_chunks[i]; double cts = (chunk.time_start ) * time_scale::get_instance()->time_scale_x; double cte = (chunk.time_end ) * time_scale::get_instance()->time_scale_x; if (chunk.depth > max_depth) max_depth = chunk.depth; float depth = -(chunk.depth + 1.0) * chunk_height; cts += time_scale::get_instance()->time_offset; cte += time_scale::get_instance()->time_offset; if (cte < -15.0 && cts < -15.0) continue; if (cte > 15.0 && cts > 15.0) continue; if (cte - cts < 0.002) continue; draw_bucket.vertices.push_back( vsx_vector3<>( cts, depth ) ); draw_bucket.vertices.push_back( vsx_vector3<>( cts, depth - chunk_height ) ); draw_bucket.vertices.push_back( vsx_vector3<>( cte, depth - chunk_height ) ); draw_bucket.vertices.push_back( vsx_vector3<>( cte, depth ) ); draw_bucket.vertex_colors.push_back( vsx_color<>(1.0, 1.0, 1.0, 0.5) ); draw_bucket.vertex_colors.push_back( vsx_color<>(1.0, 1.0, 1.0, 0.5) ); draw_bucket.vertex_colors.push_back( vsx_color<>(1.0, 1.0, 1.0, 0.5) ); draw_bucket.vertex_colors.push_back( vsx_color<>(1.0, 1.0, 1.0, 0.5) ); time_scale::get_instance()->chunk_time_end = chunk.time_end; time_scale::get_instance()->time_size_x = chunk.time_end * time_scale::get_instance()->time_scale_x; line_index idx; idx.a = draw_bucket.vertices.size() - 4; idx.b = draw_bucket.vertices.size() - 3; draw_bucket.faces.push_back( idx ); idx.a = draw_bucket.vertices.size() - 3; idx.b = draw_bucket.vertices.size() - 2; draw_bucket.faces.push_back( idx ); idx.a = draw_bucket.vertices.size() - 2; idx.b = draw_bucket.vertices.size() - 1; draw_bucket.faces.push_back( idx ); } time_scale::get_instance()->one_div_chunk_time_end = 1.0 / time_scale::get_instance()->chunk_time_end; time_scale::get_instance()->one_div_time_size_x = 1.0 / time_scale::get_instance()->time_size_x; draw_bucket.invalidate_vertices(); draw_bucket.invalidate_colors(); draw_bucket.update(); set_size(vsx_vector3<>(20.0f,chunk_height * (float)(max_depth+3))); }
void vsx_widget_profiler_thread::load_thread(uint64_t id) { vsx_printf(L"load profile thread %ld\n", id); vsx_profiler_consumer::get_instance()->get_thread(0.0, 5.0, id, consumer_chunks); update(); }