Mercurial > hg > Game > Cerium
changeset 148:74341c8bf935 draft
Span への Texture List の渡し。じゃっかん texture がバグってるので
要チェック
author | gongo@charles.cr.ie.u-ryukyu.ac.jp |
---|---|
date | Tue, 02 Dec 2008 18:49:04 +0900 |
parents | 4636153abc9f |
children | f85ad3769897 |
files | TaskManager/Test/test_render/SceneGraph.cpp TaskManager/Test/test_render/spe/CreateSpan.cpp TaskManager/Test/test_render/spe/DrawSpan.cpp TaskManager/Test/test_render/spe/Makefile TaskManager/Test/test_render/task/CreateSpan.cpp TaskManager/Test/test_render/task/DrawSpan.cpp |
diffstat | 6 files changed, 165 insertions(+), 45 deletions(-) [+] |
line wrap: on
line diff
--- a/TaskManager/Test/test_render/SceneGraph.cpp Tue Dec 02 15:47:25 2008 +0900 +++ b/TaskManager/Test/test_render/SceneGraph.cpp Tue Dec 02 18:49:04 2008 +0900 @@ -8,6 +8,7 @@ #include "sys.h" #include "TextureHash.h" #include "texture.h" +#include "TaskManager.h" using namespace std; @@ -326,12 +327,31 @@ list[id_count-1].t_h = texture_image->h; list[id_count-1].pixels = (Uint32*)texture_image->pixels; + uint32 *tex_dest = (uint32*)manager->malloc(texture_image->w*texture_image->h*4); + + { + int t = 0; + int tex_width = texture_image->w; + int tex_height = texture_image->h; + Uint32 *tex_src = (Uint32*)texture_image->pixels; + + for (int y = 0; y < tex_height; y += TEXTURE_SPLIT_PIXEL) { + for (int x = 0; x < tex_width; x += TEXTURE_SPLIT_PIXEL) { + for (int j = 0; j < TEXTURE_SPLIT_PIXEL; j++) { + for (int i = 0; i < TEXTURE_SPLIT_PIXEL; i++) { + tex_dest[t++] = tex_src[(x+i) + tex_width*(y+j)]; + } + } + } + } + } + texture_id = id_count-1; texture_info.t_w = texture_image->w; texture_info.t_h = texture_image->h; texture_info.pixels_orig = (Uint32*)texture_image->pixels; - texture_info.pixels = NULL; - + texture_info.pixels = tex_dest; + printf("%p\n", tex_dest); //load_texture(image_name); if(unlink(image_name)) {
--- a/TaskManager/Test/test_render/spe/CreateSpan.cpp Tue Dec 02 15:47:25 2008 +0900 +++ b/TaskManager/Test/test_render/spe/CreateSpan.cpp Tue Dec 02 18:49:04 2008 +0900 @@ -122,10 +122,12 @@ tile->tix = tex_xpos; tile->tiy = tex_ypos; + tile->tile = span->tex_addr; + tile->padding = 1; } else { - while (cur_x < span->length_x) { - if (cur_x + MAX_TILE_LIST < span->length_x) { - len = MAX_TILE_LIST; + while (cur_x <= span->length_x) { + if (cur_x + MAX_TILE_LIST - 1 < span->length_x) { + len = MAX_TILE_LIST - 1; smanager->mainMem_alloc(TILE_ALLOCATE, sizeof(TileInfoList)); } else { len = span->length_x - cur_x; @@ -135,21 +137,28 @@ tilelist->init(); - for (int i = cur_x; i < cur_x + len; i++) { - tile = &tilelist->tileinfo[tilelist->size++]; - + for (int i = cur_x; i <= cur_x + len; i++) { tex_x = tex1*(end-1-i)/(end-1) + tex2*i/(end-1); tex_y = tey1*(end-1-i)/(end-1) + tey2*i/(end-1); if (tex_x > 1) tex_x = 1; if (tex_y > 1) tex_y = 1; - tex_xpos = (int)((span->tex_height-1) * tex_x); - tex_ypos = (int)((span->tex_width-1) * tex_y); + tex_xpos = (int)((span->tex_width-1) * tex_x); + tex_ypos = (int)((span->tex_height-1) * tex_y); + tile = &tilelist->tileinfo[tilelist->size++]; tile->tix = tex_xpos; tile->tiy = tex_ypos; + tile->padding = i; + + int blockX = tex_xpos / TEXTURE_SPLIT_PIXEL; + int blockY = tex_ypos / TEXTURE_SPLIT_PIXEL; + int block = blockX + (span->tex_width/TEXTURE_SPLIT_PIXEL)*blockY; + uint32 *addr = (uint32*)span->tex_addr; + tile->tile = (void*)(addr + block*64); + //tile->tile = span->tex_addr; } - if (cur_x + MAX_TILE_LIST < span->length_x) { + if (cur_x + MAX_TILE_LIST - 1 < span->length_x) { TileInfoListPtr tmp = tilelist; tilelist = send_tilelist; send_tilelist = tmp; @@ -165,8 +174,6 @@ smanager->dma_wait(TILE_STORE); smanager->dma_store(send_tilelist, (uint32)send_tilelist_addr, sizeof(TileInfoList), TILE_STORE); - - tilelist->init(); } cur_x += MAX_TILE_LIST;
--- a/TaskManager/Test/test_render/spe/DrawSpan.cpp Tue Dec 02 15:47:25 2008 +0900 +++ b/TaskManager/Test/test_render/spe/DrawSpan.cpp Tue Dec 02 18:49:04 2008 +0900 @@ -114,13 +114,17 @@ if (th-1< ty) ty = th-1 ; void *texture_addr; + TilePtr tile; +#if 0 int blockX = tx / TEXTURE_SPLIT_PIXEL; int blockY = ty / TEXTURE_SPLIT_PIXEL; void** addrList = (void**)global_get(TEXTURE2_ID); - TilePtr tile; texture_addr = addrList[blockX + (tw/TEXTURE_SPLIT_PIXEL)*blockY]; +#else + texture_addr = texture; +#endif /** * get,put ϥ֥(HashȤ)äƥ뤫 @@ -181,7 +185,6 @@ (TileInfoListPtr)smanager->allocate(sizeof(TileInfoList)); TileInfoListPtr next_tilist = (TileInfoListPtr)smanager->allocate(sizeof(TileInfoList)); - TileInfoListPtr tmp_tilist = NULL; TileInfoPtr tinfo; @@ -250,10 +253,24 @@ if (x < rangex_start || rangex_end < x) { continue; } + tex_xpos = (int)((span->tex_width-1) * tex1); tex_ypos = (int)((span->tex_height-1) * tey1); tex_zpos = (int)z; +#if 0 + if (tex_xpos != tilist->tileinfo[0].tix + && tex_xpos != tilist->tileinfo[0].tix) { + fprintf(stderr, "1: (%3d, %3d), (%3d, %3d)\n", + tex_xpos, tex_ypos, tilist->tileinfo[0].tix, + tilist->tileinfo[0].tiy); + } +#endif + + tex_xpos = tilist->tileinfo[0].tix; + tex_ypos = tilist->tileinfo[0].tiy; + texture_image = tilist->tileinfo[0].tile; + if (zpos < zRow[localx + (rangex * localy)]) { rgb = get_rgb(tex_xpos, tex_ypos, span->tex_width, span->tex_height, texture_image); @@ -270,31 +287,38 @@ int max_x = je; int len; + /** + * Span ɽʤϰ([js..je]) TileInfoList + * äƤΤǡФ + */ while (cur_x + MAX_TILE_LIST < js) { + smanager->dma_load(next_tilist, (uint32)tilist->next, + sizeof(TileInfoList), TILE_INFO_LOAD); smanager->dma_wait(TILE_INFO_LOAD); - smanager->dma_load(tilist, (uint32)tilist->next, - sizeof(TileInfoList), TILE_INFO_LOAD); + + TileInfoListPtr tmp = tilist; + tilist = next_tilist; + next_tilist = tmp; + cur_x += MAX_TILE_LIST; } cur_x = js; - while (cur_x < max_x) { - smanager->dma_wait(TILE_INFO_LOAD); - - if (cur_x + MAX_TILE_LIST < max_x) { + while (cur_x <= max_x) { + if (cur_x + MAX_TILE_LIST - 1 < max_x) { smanager->dma_load(next_tilist, (uint32)tilist->next, - sizeof(TileInfoList), TILE_INFO_LOAD); - len = MAX_TILE_LIST; + sizeof(TileInfoList), + TILE_INFO_LOAD); + len = MAX_TILE_LIST - 1; } else { len = max_x - cur_x; } - + float tex_x, tex_y, tex_z; for (int j = cur_x; j <= cur_x + len; j++) { 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); @@ -303,6 +327,23 @@ if (tex_y > 1) tex_y = 1; tex_xpos = (int)((span->tex_width-1) * tex_x); tex_ypos = (int)((span->tex_height-1) * tex_y); + +#if 0 + if (tex_xpos != tilist->tileinfo[j%MAX_TILE_LIST].tix + && tex_xpos != tilist->tileinfo[j%MAX_TILE_LIST].tix) { + fprintf(stderr, "size = %d\n", tilist->size); + fprintf(stderr, "(%3d ..%3d) %d, %d %d\n", + x, x + x_len, js, max_x, j%MAX_TILE_LIST); + fprintf(stderr, "(%3d, %3d), (%3d, %3d)\n", + tex_xpos, tex_ypos, + tilist->tileinfo[j%MAX_TILE_LIST].tix, + tilist->tileinfo[j%MAX_TILE_LIST].tiy); + } +#endif + + tex_xpos = tilist->tileinfo[j%MAX_TILE_LIST].tix; + tex_ypos = tilist->tileinfo[j%MAX_TILE_LIST].tiy; + texture_image = tilist->tileinfo[j%MAX_TILE_LIST].tile; if (tex_z < zRow[localx + (rangex*localy)]) { rgb = get_rgb(tex_xpos, tex_ypos, span->tex_width,
--- a/TaskManager/Test/test_render/spe/Makefile Tue Dec 02 15:47:25 2008 +0900 +++ b/TaskManager/Test/test_render/spe/Makefile Tue Dec 02 18:49:04 2008 +0900 @@ -8,7 +8,7 @@ OBJS = $(SRCS:.cpp=.o) CC = spu-g++ -CFLAGS = -O9 -g -fno-exceptions -fno-rtti #-DDEBUG +CFLAGS = -O0 -g -fno-exceptions -fno-rtti #-DDEBUG INCLUDE = -I$(CERIUM)/include/TaskManager -I. -I.. LIBS = -L$(CERIUM)/TaskManager -lspemanager
--- a/TaskManager/Test/test_render/task/CreateSpan.cpp Tue Dec 02 15:47:25 2008 +0900 +++ b/TaskManager/Test/test_render/task/CreateSpan.cpp Tue Dec 02 18:49:04 2008 +0900 @@ -126,6 +126,7 @@ while (cur_x < span->length_x) { if (cur_x + MAX_TILE_LIST < span->length_x) { len = MAX_TILE_LIST; + smanager->mainMem_alloc(TILE_ALLOCATE, sizeof(TileInfoList)); } else { len = span->length_x - cur_x; } @@ -155,7 +156,6 @@ send_tilelist_addr = tilelist_addr; - smanager->mainMem_alloc(TILE_ALLOCATE, sizeof(TileInfoList)); smanager->mainMem_wait(); tilelist_addr = (TileInfoListPtr)smanager->mainMem_get(TILE_ALLOCATE); @@ -392,7 +392,7 @@ // TilePtr の計算 // tix, tiy (Tile 内での x, y) // - smanager->mainMem_wait(); + //smanager->mainMem_wait(); setTile(span); } }
--- a/TaskManager/Test/test_render/task/DrawSpan.cpp Tue Dec 02 15:47:25 2008 +0900 +++ b/TaskManager/Test/test_render/task/DrawSpan.cpp Tue Dec 02 18:49:04 2008 +0900 @@ -8,6 +8,7 @@ #define SPAN_PACK_LOAD 0 #define TEX_LOAD 1 +#define TILE_INFO_LOAD 2 SchedDefineTask(DrawSpan); @@ -176,6 +177,14 @@ SpanPack *tmp_sp = NULL; Span *span; + TileInfoListPtr tilist = + (TileInfoListPtr)smanager->allocate(sizeof(TileInfoList)); + TileInfoListPtr next_tilist = + (TileInfoListPtr)smanager->allocate(sizeof(TileInfoList)); + TileInfoListPtr tmp_tilist = NULL; + TileInfoPtr tinfo; + + tileList = (TileListPtr)smanager->allocate(sizeof(TileList)); tileList->init(); @@ -214,6 +223,9 @@ for (int t = 0; t < sp->info.size; t++) { span = &sp->span[t]; + smanager->dma_load(tilist, (uint32)span->tilelist, + sizeof(TileInfoList), TILE_INFO_LOAD); + Uint32 rgb = 0x00ff00; float tex1 = span->tex_x1; float tex2 = span->tex_x2; @@ -232,6 +244,8 @@ int localx = getLocalX(x-1); int localy = getLocalY(y-1); + smanager->dma_wait(TILE_INFO_LOAD); + if (x_len == 1) { if (x < rangex_start || rangex_end < x) { continue; @@ -247,32 +261,68 @@ linebuf[localy][localx] = rgb; } } else { - float tex_x, tex_y, tex_z; int js = (x < rangex_start) ? rangex_start - x : 0; int je = (x + x_len > rangex_end) ? rangex_end - x : x_len; - for (int j = js; j <= je; j++) { - localx = getLocalX(x-1+j); + if (js > je) continue; + + int cur_x = 0; + int max_x = je; + int len; - tex_z = z*(x_len-1-j)/(x_len-1) + zpos*j/(x_len-1); + while (cur_x + MAX_TILE_LIST < js) { + smanager->dma_wait(TILE_INFO_LOAD); + smanager->dma_load(tilist, (uint32)tilist->next, + sizeof(TileInfoList), TILE_INFO_LOAD); + cur_x += MAX_TILE_LIST; + } + + cur_x = js; - 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_y > 1) tex_y = 1; - 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)]) { - rgb = get_rgb(tex_xpos, tex_ypos, span->tex_width, - span->tex_height, texture_image); - zRow[localx + (rangex*localy)] = tex_z; - linebuf[localy][localx] = rgb; + while (cur_x < max_x) { + smanager->dma_wait(TILE_INFO_LOAD); + + if (cur_x + MAX_TILE_LIST < max_x) { + smanager->dma_load(next_tilist, (uint32)tilist->next, + sizeof(TileInfoList), TILE_INFO_LOAD); + len = MAX_TILE_LIST; + } else { + len = max_x - cur_x; } + + float tex_x, tex_y, tex_z; + + for (int j = cur_x; j <= cur_x + len; j++) { + 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_y > 1) tex_y = 1; + 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)]) { + rgb = get_rgb(tex_xpos, tex_ypos, span->tex_width, + span->tex_height, texture_image); + zRow[localx + (rangex*localy)] = tex_z; + linebuf[localy][localx] = rgb; + } + } + + smanager->dma_wait(TILE_INFO_LOAD); + + TileInfoListPtr tmp = tilist; + tilist = next_tilist; + next_tilist = tmp; + + cur_x += MAX_TILE_LIST; } } } - + smanager->dma_wait(SPAN_PACK_LOAD); tmp_sp = sp; @@ -284,6 +334,8 @@ free(linebuf); free(zRow); free(tileList); + free(tilist); + free(next_tilist); return 0; }