# HG changeset patch # User gongo@localhost.localdomain # Date 1232947665 -32400 # Node ID 10ad99550ee830d41a8008d927d6081a205d629c # Parent eb20274baa7c434d36420d955d9623ec58926124 fix run_draw diff -r eb20274baa7c -r 10ad99550ee8 TaskManager/Cell/spe/main.cc --- a/TaskManager/Cell/spe/main.cc Mon Jan 26 14:02:45 2009 +0900 +++ b/TaskManager/Cell/spe/main.cc Mon Jan 26 14:27:45 2009 +0900 @@ -28,8 +28,8 @@ manager->run(); prof -= spu_read_decrementer(); - printf("%f\n", prof/79800000.0f*1000.0f); - + //printf("%f\n", prof/79800000.0f*1000.0f); + manager->finish(); return 0; diff -r eb20274baa7c -r 10ad99550ee8 TaskManager/Test/test_render/ChangeLog --- a/TaskManager/Test/test_render/ChangeLog Mon Jan 26 14:02:45 2009 +0900 +++ b/TaskManager/Test/test_render/ChangeLog Mon Jan 26 14:27:45 2009 +0900 @@ -1,5 +1,17 @@ 2009-01-26 Wataru MIYAGUNI + * viewer.cpp (Viewer::run_draw): fix + Spanの無い部分を塗りつぶす処理はタスクを走らせず、 + そのまま memset とかの方が早い。 + まとめてするタスクを立ち上げるってのもいいかもしれない。 + あと、memsetで指定する値が、0xFF と 0x00 とで速度が違う。 + universe だと、 + + 0xFF 24fps + 0x00 30fps + + なんだろう。0x00 だと、ただのクリアになるから速いってことかな。 + * Camera.h (class Camera): add とりあえず Camera を作って、これを SceneGraph の Top にした。 diff -r eb20274baa7c -r 10ad99550ee8 TaskManager/Test/test_render/Makefile.def --- a/TaskManager/Test/test_render/Makefile.def Mon Jan 26 14:02:45 2009 +0900 +++ b/TaskManager/Test/test_render/Makefile.def Mon Jan 26 14:27:45 2009 +0900 @@ -3,16 +3,16 @@ # include/library path # ex: macosx #CERIUM = /Users/gongo/Source/Concurrency/Game_project/Cerium -CERIUM = /Users/gongo/Source/hg/Cerium +#CERIUM = /Users/gongo/Source/hg/Cerium # ex: linux/ps3 -#CERIUM = /home/gongo/Cerium +CERIUM = /home/gongo/Cerium #CERIUM = /Users/tkaito/hg/Game/Cerium #CERIUM = ../../.. CC = g++ -CFLAGS = -O0 -g -Wall# -DDEBUG +CFLAGS = -O9 -g -Wall# -DDEBUG INCLUDE = -I$(CERIUM)/include/TaskManager -I. LIBS = -L$(CERIUM)/TaskManager \ No newline at end of file diff -r eb20274baa7c -r 10ad99550ee8 TaskManager/Test/test_render/spe/DrawSpan.cpp --- a/TaskManager/Test/test_render/spe/DrawSpan.cpp Mon Jan 26 14:02:45 2009 +0900 +++ b/TaskManager/Test/test_render/spe/DrawSpan.cpp Mon Jan 26 14:27:45 2009 +0900 @@ -1,5 +1,6 @@ #include #include +#include #include "DrawSpan.h" #include "polygon_pack.h" #include "texture.h" @@ -115,9 +116,20 @@ float *buf = (float*)smanager->allocate(sizeof(float)*width*height); float def = 65535.0f; +#if 1 for (int i = 0; i < width*height; i++) { buf[i] = def; } +#else + vector float init = {0.0f, 0.0f, 0.0f, 0.0f}; + vector float defi = {def, def, def, def}; + + for (int i = 0; i < width*height; i += 4) { + vector float *out = (vector float *)&buf[i]; + + *out = spu_add(init, defi); + } +#endif return buf; } @@ -422,6 +434,143 @@ } } + for (int t = 0; t < spack->info.size; t++) { + span = &spack->span[t]; + + uint32 rgb = 0x0000ff00; + float tex1 = span->tex_x1; + float tex2 = span->tex_x2; + float tey1 = span->tex_y1; + float tey2 = span->tex_y2; + + /** + * Span が持つ 1 pixel 毎の + * テクスチャの座標 + */ + int tex_xpos; + int tex_ypos; + + /** + * (tex_xpos, tex_ypos) の、ブロック内(上の図参照)での座標と + * そのブロックのアドレス(MainMemory) + */ + int tex_localx; + int tex_localy; + uint32 *tex_addr; + + int x = span->x; + int y = span->y; + int x_len = span->length_x; + float z = span->start_z; + float zpos = span->end_z; + + // 座標が [0 .. split_screen_w-1] に入るように x,y を -1 + int localx = getLocalX(x-1); + int localy = getLocalY(y-1); + + if (x_len == 1) { + if (x < rangex_start || rangex_end < x) { + continue; + } + + flag = 1; + tex_xpos = (int)((span->tex_width-1) * tex1); + tex_ypos = (int)((span->tex_height-1) * tey1); + + if (zpos < zRow[localx + (rangex*localy)]) { + tex_addr = getTile(tex_xpos, tex_ypos, + span->tex_width, span->tex_addr); + tex_localx = tex_xpos % TEXTURE_SPLIT_PIXEL; + tex_localy = tex_ypos % TEXTURE_SPLIT_PIXEL; + + if (!isAvailableTile(tex_addr)) { +# if defined(PROFILE) + printf("%d %u start load tile\n", + smanager->get_cpuid(), spu_read_decrementer()); +# endif + set_rgb(tex_addr); + smanager->dma_wait(TEX_LOAD); +# if defined(PROFILE) + printf("%d %u end load tile\n", + smanager->get_cpuid(), spu_read_decrementer()); +# endif + tileNum++; + } + + rgb = get_rgb(tex_localx, tex_localy, tex_addr); + + zRow[localx + (rangex*localy)] = zpos; + linebuf[localx + (rangex*localy)] = rgb; + } + } else { + int js = (x < rangex_start) ? rangex_start - x : 0; + int je = (x + x_len > rangex_end) ? rangex_end - x : x_len; + float tex_x, tex_y, tex_z; + + for (int j = js; j <= je; j++) { + flag = 1; + localx = getLocalX(x-1+j); + + tex_z = z*(x_len-1-j)/(x_len-1) + zpos*j/(x_len-1); + + tex_x = tex1*(x_len-1-j)/(x_len-1) + tex2*j/(x_len-1); + tex_y = tey1*(x_len-1-j)/(x_len-1) + tey2*j/(x_len-1); + if (tex_x > 1) tex_x = 1; + if (tex_x < 0) tex_x = 0; + if (tex_y > 1) tex_y = 1; + if (tex_y < 0) tex_y = 0; + tex_xpos = (int)((span->tex_width-1) * tex_x); + tex_ypos = (int)((span->tex_height-1) * tex_y); + + if (tex_z < zRow[localx + (rangex*localy)]) { + tex_addr = getTile(tex_xpos, tex_ypos, + span->tex_width, span->tex_addr); + tex_localx = tex_xpos % TEXTURE_SPLIT_PIXEL; + tex_localy = tex_ypos % TEXTURE_SPLIT_PIXEL; + + /** + * Tile が無い場合、一旦タスクはここで中断し、 + * Tile をロードするタスクを走らせた後に再起動する + */ + if (!isAvailableTile(tex_addr)) { + spack->info.start = t; +#if 0 + set_rgbs(tex_addr, + getTile(span->tex_width-1, tex_ypos, + span->tex_width, span->tex_addr)); + //smanager->dma_wait(TEX_LOAD); + reboot(spack, j); + goto FINISH; +#else + +# if defined(PROFILE) + printf("%d %u start load tile\n", + smanager->get_cpuid(), + spu_read_decrementer()); +# endif + + set_rgb(tex_addr); + smanager->dma_wait(TEX_LOAD); + tileNum++; + +# if defined(PROFILE) + printf("%d %u end load tile\n", + smanager->get_cpuid(), + spu_read_decrementer()); +# endif +#endif + } + + rgb = get_rgb(tex_localx, tex_localy, tex_addr); + + zRow[localx + (rangex*localy)] = tex_z; + linebuf[localx + (rangex*localy)] = rgb; + } + } + } + } + + smanager->dma_wait(SPAN_PACK_LOAD); SpanPackPtr tmp_spack = spack; diff -r eb20274baa7c -r 10ad99550ee8 TaskManager/Test/test_render/task/CreatePolygonFromSceneGraph.cpp --- a/TaskManager/Test/test_render/task/CreatePolygonFromSceneGraph.cpp Mon Jan 26 14:02:45 2009 +0900 +++ b/TaskManager/Test/test_render/task/CreatePolygonFromSceneGraph.cpp Mon Jan 26 14:27:45 2009 +0900 @@ -34,10 +34,46 @@ } } +static void +apply_matrix(float *xyz, float *mat) +{ + float tmp[4]; + + tmp[0] = xyz[0]; + tmp[1] = xyz[1]; + tmp[2] = xyz[2]; + tmp[3] = xyz[3]; + + for (int i = 0; i < 4; i++) { + xyz[i] = tmp[0]*mat[i*4+0] + tmp[1]*mat[i*4+1] + + tmp[2]*mat[i*4+2] + tmp[3]*mat[i*4+3]; + } +} + +float fx = 1.0f; +float fy = 1.0f; +float fz = 0.9f; +float fd = 0.05f; + int CreatePolygonFromSceneGraph::run(void *rbuf, void *wbuf) { float xyz1[4], xyz2[4], xyz3[4]; + float mat[16] = {fx, 0, 0, 0, 0, fy, 0, 0, 0, 0, 1.0f, 1.0f, 20.0f, 30.0f, 0, 0}; + + //fx -= fd; + //fy -= fd; + + if (fx < 0.0f) { + fx = 0.0f; + fy = 0.0f; + fd = -fd; + } else if (fx > 1.0f) { + fx = 1.0f; + fy = 1.0f; + fd = -fd; + } + SceneGraphPtr sg_top = (SceneGraphPtr)smanager->get_param(0); SceneGraphPtr sg = sg_top; @@ -98,6 +134,10 @@ rotate(xyz1, sg->matrix); rotate(xyz2, sg->matrix); rotate(xyz3, sg->matrix); + + apply_matrix(xyz1, mat); + apply_matrix(xyz2, mat); + apply_matrix(xyz3, mat); triangle->ver1.x = xyz1[0]; triangle->ver1.y = xyz1[1]; diff -r eb20274baa7c -r 10ad99550ee8 TaskManager/Test/test_render/tools/create_sglist.pl --- a/TaskManager/Test/test_render/tools/create_sglist.pl Mon Jan 26 14:02:45 2009 +0900 +++ b/TaskManager/Test/test_render/tools/create_sglist.pl Mon Jan 26 14:27:45 2009 +0900 @@ -1,4 +1,4 @@ -#!/opt/local/bin/perl +#!/usr/bin/perl # TODO # 同じ名前の SceneGraph が来た時の処理 diff -r eb20274baa7c -r 10ad99550ee8 TaskManager/Test/test_render/viewer.cpp --- a/TaskManager/Test/test_render/viewer.cpp Mon Jan 26 14:02:45 2009 +0900 +++ b/TaskManager/Test/test_render/viewer.cpp Mon Jan 26 14:27:45 2009 +0900 @@ -218,7 +218,7 @@ return; } - clean_pixels(); + //clean_pixels(); for (int i = 1; i <= spackList_length; i++) { spackList[i-1].reinit(i*split_screen_h); @@ -251,7 +251,6 @@ #else // SceneGraph(木構造) -> PolygonPack task_create_pp = manager->create_task(TASK_CREATE_PP2); - //task_create_pp->add_param((uint32)scene_graph_viewer); task_create_pp->add_param((uint32)sgroot->getDrawSceneGraph()); task_create_pp->add_param((uint32)ppack); #endif @@ -307,7 +306,7 @@ task_next->set_post(post2runLoop, NULL); ppack->clear(); - + int hoge = 0; for (int i = 0; i < spackList_length; i++) { SpanPack *spack = &spackList[i]; int startx = 1; @@ -328,7 +327,8 @@ (uint32)&pixels[(startx-1) + this->width*(starty-1)]); task_draw->add_param(this->width); } else { - //break; +#if 0 + break; // Draw Background (現在は塗りつぶし) task_draw = manager->create_task(TASK_DRAW_BACK); task_draw->add_param(0xffffffff); @@ -338,6 +338,11 @@ &pixels[(startx-1)+this->width*(k+starty-1)], (endx - startx + 1)*sizeof(int)); } +#else + memset(&pixels[(startx-1)+this->width*(starty-1)], + 0xFF, (this->width)*sizeof(int)*rangey); + break; +#endif } task_draw->add_param(startx); diff -r eb20274baa7c -r 10ad99550ee8 TaskManager/Test/test_render/viewerFB.cpp --- a/TaskManager/Test/test_render/viewerFB.cpp Mon Jan 26 14:02:45 2009 +0900 +++ b/TaskManager/Test/test_render/viewerFB.cpp Mon Jan 26 14:27:45 2009 +0900 @@ -8,7 +8,6 @@ ViewerFB::video_init(void) { Uint32 sdl_flag = default_sdl_flag | SDL_INIT_VIDEO; - //Uint32 sdl_flag = default_sdl_flag; if (SDL_Init(sdl_flag) < 0) { fprintf(stderr,"Couldn't initialize SDL: %s\n",SDL_GetError()); @@ -26,4 +25,5 @@ ViewerFB::clean_pixels() { //bzero(pixels, sizeof(int)*width*height); + memset(pixels, 0xFF, sizeof(int)*width*height); }