clray
diff src/rt.cc @ 32:4cf4919c3812
performance sucks
author | John Tsiombikas <nuclear@member.fsf.org> |
---|---|
date | Tue, 24 Aug 2010 05:43:57 +0100 |
parents | 353d80127627 |
children | 7d77ded5f890 |
line diff
1.1 --- a/src/rt.cc Sun Aug 22 00:50:47 2010 +0100 1.2 +++ b/src/rt.cc Tue Aug 24 05:43:57 2010 +0100 1.3 @@ -5,6 +5,7 @@ 1.4 #include "ogl.h" 1.5 #include "ocl.h" 1.6 #include "scene.h" 1.7 +#include "timer.h" 1.8 1.9 // kernel arguments 1.10 enum { 1.11 @@ -90,6 +91,7 @@ 1.12 fprintf(stderr, "failed to create kdtree buffer\n"); 1.13 return false; 1.14 } 1.15 + // XXX now we can actually destroy the original kdtree and keep only the GPU version 1.16 1.17 /* setup argument buffers */ 1.18 prog->set_arg_buffer(KARG_FRAMEBUFFER, ARG_WR, xsz * ysz * 4 * sizeof(float)); 1.19 @@ -123,10 +125,14 @@ 1.20 1.21 bool render() 1.22 { 1.23 + long tm0 = get_msec(); 1.24 + 1.25 if(!prog->run(1, global_size)) { 1.26 return false; 1.27 } 1.28 1.29 + long tm_run = get_msec() - tm0; 1.30 + 1.31 CLMemBuffer *mbuf = prog->get_arg_buffer(KARG_FRAMEBUFFER); 1.32 void *fb = map_mem_buffer(mbuf, MAP_RD); 1.33 if(!fb) { 1.34 @@ -134,14 +140,12 @@ 1.35 return false; 1.36 } 1.37 1.38 - static int foo = 0; 1.39 - if(!foo++) { 1.40 - bool write_ppm(const char *fname, float *fb, int xsz, int ysz); 1.41 - write_ppm("foo.ppm", (float*)fb, rinf.xsz, rinf.ysz); 1.42 - } 1.43 - 1.44 glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, rinf.xsz, rinf.ysz, GL_RGBA, GL_FLOAT, fb); 1.45 unmap_mem_buffer(mbuf); 1.46 + 1.47 + long tm_upd = get_msec() - tm0 - tm_run; 1.48 + 1.49 + printf("render %ld msec (%ld run, %ld upd)\n", tm_run + tm_upd, tm_run, tm_upd); 1.50 return true; 1.51 } 1.52