Mercurial > hg > Game > Cerium
changeset 86:61bacd3b4405
*** empty log message ***
author | gongo |
---|---|
date | Wed, 27 Feb 2008 10:56:09 +0900 |
parents | 9b96b190cb73 |
children | 265fb700dd4c |
files | TaskManager/Test/simple_render/Makefile TaskManager/Test/simple_render/spu_span.h TaskManager/Test/simple_render/task/create_span.cpp TaskManager/Test/simple_render/task/task_init.cpp TaskManager/Test/simple_render/task/update_sgp.cpp TaskManager/Test/simple_render/viewer.cpp TaskManager/kernel/ppe/DmaBuffer.cc TaskManager/kernel/ppe/TaskManagerImpl.cc TaskManager/kernel/schedule/FifoDmaManager.cc TaskManager/kernel/schedule/SchedTask.cc |
diffstat | 10 files changed, 265 insertions(+), 55 deletions(-) [+] |
line wrap: on
line diff
--- a/TaskManager/Test/simple_render/Makefile Wed Feb 27 04:25:04 2008 +0900 +++ b/TaskManager/Test/simple_render/Makefile Wed Feb 27 10:56:09 2008 +0900 @@ -8,7 +8,7 @@ TASK_OBJS = $(TASK_SRCS:.cpp=.o) CC = g++ -CFLAGS = -O9 -g -Wall -DDEBUG +CFLAGS = -g -Wall -DDEBUG INCLUDE = -I../../../include/TaskManager -I. EXTRA_CFLAGS = `sdl-config --cflags` `xml2-config --cflags`\ @@ -16,7 +16,9 @@ #EXTRA_LIBS = -lCellManager -lspe2 -lpthread EXTRA_LIBS = -lFifoManager -LIBS = `sdl-config --libs` -lSDL_image -lGL \ +#LIBS = `sdl-config --libs` -lSDL_image -lGL \ +# `xml2-config --libs` -L../.. $(EXTRA_LIBS) +LIBS = `sdl-config --libs` -lSDL_image -Wl,-framework,OpenGL \ `xml2-config --libs` -L../.. $(EXTRA_LIBS) .SUFFIXES: .cpp .o
--- a/TaskManager/Test/simple_render/spu_span.h Wed Feb 27 04:25:04 2008 +0900 +++ b/TaskManager/Test/simple_render/spu_span.h Wed Feb 27 10:56:09 2008 +0900 @@ -6,14 +6,14 @@ #endif typedef struct SPUSPAN { - int length; - //SPANPACK spp[23]; // window_height = 1080 ( 1080/8/6 = 22.5 ) - SPANPACK spp[10]; // window_height = 480 ( 480/8/6 = 10 ) - //SPUSPAN *next; + int length; + //SPANPACK spp[23]; // window_height = 1080 ( 1080/8/6 = 22.5 ) + SPANPACK spp[10]; // window_height = 480 ( 480/8/6 = 10 ) + //SPUSPAN *next; } SPUSPAN; typedef struct SPUSPANLIST { - SPUSPAN ss[6]; // 6 = number of SPU + SPUSPAN ss[6]; // 6 = number of SPU } SPUSPANLIST; /*
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/TaskManager/Test/simple_render/task/create_span.cpp Wed Feb 27 10:56:09 2008 +0900 @@ -0,0 +1,211 @@ +#include <iostream> +#include <string.h> +#include "polygon_pack.h" +#include "spu_span.h" +#include "error.h" +using namespace std; + + +static float calc(float f1, float f2,int i, float base){ + float ans; + ans = f1/f2*i + base; + return ans; +} + + +static VertexPack +*vMid1(VertexPack *vMid1, VertexPack *vMin, VertexPack *vMid, VertexPack *vMax) +{ + float d,d1; + + d = (int)vMax->y-(int)vMin->y; + d1 = (int)vMid->y - (int)vMin->y; + vMid1->tex_x = calc(vMax->tex_x - vMin->tex_x, d, (int)d1 , vMin->tex_x); + vMid1->tex_y = calc(vMax->tex_y - vMin->tex_y, d, (int)d1 , vMin->tex_y); + vMid1->x = calc(vMax->x - vMin->x, d, (int)d1 , vMin->x); + vMid1->y = vMid->y; + vMid1->z = calc(vMax->z - vMin->z, d, (int)d1 , vMin->z); + //printf("x:%f y:%f z:%f tex_x:%f tex_y:%f\n",vMid1->x,vMid1->y,vMid1->z,vMid1->tex_x, vMid1->tex_y); + + return vMid1; +} + +void +half_triangle(SPUSPANLIST *ssl, long *tex_addr, long tex_width,long tex_height, + VertexPack *vMin, VertexPack *vMid, VertexPack *vMid1) +{ + float tmp_z,tmp_tex1, tmp_tex2 ,tmp_tey1,tmp_tey2; + float tmp_xpos,tmp_end,tmp_zpos; + int i; + float div_y; + float start_z,end_z; + float start_tex_x,end_tex_x,start_tex_y,end_tex_y; + int x,y,length; + int k =0; + int l = 1; + int start_y = (int)vMid->y; + int end_y = (int)vMin->y; + + if (start_y<end_y) { + int i; i=end_y; end_y=start_y; start_y = i; + k = 1; + l = -1; + } + + div_y = start_y - end_y; // > 0 + + for (i = k; i < div_y+1; i++) { + tmp_xpos = calc(vMid1->x - vMin->x ,div_y, i, vMin->x); + tmp_end = calc(vMid->x - vMin->x ,div_y, i, vMin->x); + tmp_z = calc(vMid1->z - vMin->z ,div_y, i, vMin->z); + tmp_zpos = calc(vMid->z - vMin->z ,div_y, i, vMin->z); + + tmp_tex1 =((i/(div_y)) * vMid1->tex_x) + \ + ( ((div_y - i)/(div_y)) * vMin->tex_x); + tmp_tex2 =( (i/(div_y)) * vMid->tex_x) + \ + ( ((div_y - i)/(div_y)) * vMin->tex_x); + + tmp_tey1 =( (i/(div_y)) * vMid1->tex_y) + \ + ( ((div_y - i)/(div_y)) * vMin->tex_y); + tmp_tey2 =( (i/(div_y)) * vMid->tex_y) + \ + ( ((div_y - i)/(div_y)) * vMin->tex_y); + if(tmp_xpos > tmp_end) { + x = (int)tmp_end; + y = (int)vMin->y + i*l; + length = (int)(tmp_xpos)-(int)(tmp_end)+1; + start_z = tmp_zpos; + end_z = tmp_z; + start_tex_x = tmp_tex2; + end_tex_x = tmp_tex1; + start_tex_y = tmp_tey2; + end_tex_y = tmp_tey1; + } else { + x = (int)tmp_xpos; + y = (int)vMin->y + i*l; + length = (int)(tmp_end)-(int)(tmp_xpos)+1; + start_z = tmp_z; + end_z = tmp_zpos; + start_tex_x = tmp_tex1; + end_tex_x = tmp_tex2; + start_tex_y = tmp_tey1; + end_tex_y = tmp_tey2; + } + //printf("x:%d y:%d end:%d z:%f zpos:%f\n",x,y,length,start_z , end_z); + //printf("start_tex_x:%f end_tex_x:%f start_tex_y:%f end_tex_y:%fn",start_tex_x,end_tex_x,start_tex_y,end_tex_y); + + //add(tex_addr,tex_width,tex_height,x,y,length,start_z,end_z,start_tex_x,end_tex_x,start_tex_y,end_tex_y); + + //y += 540; // window_height = 1080 (1080/2 = 540) + y += 240; // window_height = 480 (480/2 = 240) + + int line_set = y/8; + + //y -= 540; // window_height = 1080 (1080/2 = 540) + y -= 240; // window_height = 480 (480/2 = 240) + + int spu_no = line_set%6; + int spp_no = line_set/6; + int span_no = ssl->ss[spu_no].spp[spp_no].info.size; + +#if 0 + ssl->ss[spu_no].spp[spp_no].span[span_no].tex_addr = tex_addr; + ssl->ss[spu_no].spp[spp_no].span[span_no].tex_width = tex_width; + ssl->ss[spu_no].spp[spp_no].span[span_no].tex_height = tex_height; + ssl->ss[spu_no].spp[spp_no].span[span_no].x = x; + ssl->ss[spu_no].spp[spp_no].span[span_no].y = y; + ssl->ss[spu_no].spp[spp_no].span[span_no].length_x = length; + ssl->ss[spu_no].spp[spp_no].span[span_no].start_z = start_z; + ssl->ss[spu_no].spp[spp_no].span[span_no].end_z = end_z; + ssl->ss[spu_no].spp[spp_no].span[span_no].tex_x1 = start_tex_x; + ssl->ss[spu_no].spp[spp_no].span[span_no].tex_x2 = end_tex_x; + ssl->ss[spu_no].spp[spp_no].span[span_no].tex_y1 = start_tex_y; + ssl->ss[spu_no].spp[spp_no].span[span_no].tex_y2 = end_tex_y; +#else + SPNA_PTR span = &ssl->ss[spu_no].spp[spp_no].span[span_no]; + + span->tex_addr = tex_addr; + span->tex_width = tex_width; + span->tex_height = tex_height; + span->x = x; + span->y = y; + span->length_x = length; + span->start_z = start_z; + span->end_z = end_z; + span->tex_x1 = start_tex_x; + span->tex_x2 = end_tex_x; + span->tex_y1 = start_tex_y; + span->tex_y2 = end_tex_y; + +#endif + + ssl->ss[spu_no].spp[spp_no].info.size++; + } +} + + +int +create_span(void *rbuf, void *wbuf) +{ + PolygonPack *polygon = (PolygonPack*)rbuf; + //SPUSPANLIST *ssl = polygon->ssl; + SPUSPANLIST *ssl = (SPUSPANLIST*)wbuf; + VertexPack *vMin, *vMid, *vMax, *vMid10; + VertexPack ver; + vMid10 = &ver; + + __debug("[%s]\n", __FUNCTION__); + + for(int i = 0; i < 6; i++) // 6 = number of SPU + { + ssl->ss[i].length = 0; + for(int t = 0; t < 10; t++) // window_height = 480 (480/8/6 = 10) + { + // wbuf ¤Ï 16KB ¡¢ssl(SPUSPANLIST) ¤Ï 200KB Ķ¤¨¤Æ¤ë¤Î¤Ç + // 16KB°Ê¾å¤Î¾ì½ê¤Ë¥¢¥¯¥»¥¹¤¹¤ë¤È¡¢¤³¤³¤Ç¥¨¥é¡¼¤¬¤Ç¤Þ¤¹ + ssl->ss[i].spp[t].info.size = 0; + } + } + + for (int a = 0; a < polygon->info.size; a++) { + if (polygon->tri[a].ver1.y <= polygon->tri[a].ver2.y) { + if (polygon->tri[a].ver2.y <= polygon->tri[a].ver3.y) { + vMin = &polygon->tri[a].ver1; + vMid = &polygon->tri[a].ver2; + vMax = &polygon->tri[a].ver3; + } else if (polygon->tri[a].ver3.y <= polygon->tri[a].ver1.y) { + vMin = &polygon->tri[a].ver3; + vMid = &polygon->tri[a].ver1; + vMax = &polygon->tri[a].ver2; + } else { + vMin = &polygon->tri[a].ver1; + vMid = &polygon->tri[a].ver3; + vMax = &polygon->tri[a].ver2; + } + } else { + if (polygon->tri[a].ver1.y <= polygon->tri[a].ver3.y) { + vMin = &polygon->tri[a].ver2; + vMid = &polygon->tri[a].ver1; + vMax = &polygon->tri[a].ver3; + } else if (polygon->tri[a].ver3.y <= polygon->tri[a].ver2.y) { + vMin = &polygon->tri[a].ver3; + vMid = &polygon->tri[a].ver2; + vMax = &polygon->tri[a].ver1; + } else { + vMin = &polygon->tri[a].ver2; + vMid = &polygon->tri[a].ver3; + vMax = &polygon->tri[a].ver1; + } + } + + vMid1(vMid10,vMin,vMid,vMax); + + half_triangle(ssl, polygon->tri[a].tex_addr, polygon->tri[a].tex_width, + polygon->tri[a].tex_height, vMin, vMid, vMid10); + half_triangle(ssl, polygon->tri[0].tex_addr, polygon->tri[0].tex_width, + polygon->tri[0].tex_height, vMax, vMid, vMid10); + + return 0; + + //return sizeof(SPUSPANLIST); + } +}
--- a/TaskManager/Test/simple_render/task/task_init.cpp Wed Feb 27 04:25:04 2008 +0900 +++ b/TaskManager/Test/simple_render/task/task_init.cpp Wed Feb 27 10:56:09 2008 +0900 @@ -1,11 +1,17 @@ +#include "polygon.h" #include "scene_graph_pack.h" -#include "polygon.h" +#include "polygon_pack.h" +#include "span_pack.h" #include "TaskManager.h" +#include "spu_span.h" extern TaskManager *manager; extern int create_sgp(Polygon *sg, SceneGraphPack *sgp); extern int update_sgp(SceneGraphPack *sgp, SceneGraphPack *_sgp); extern int create_pp(SceneGraphPack *sgp, PolygonPack *pp); +extern int create_span(void *wbuf, void *rbuf); +//extern int spu_span(SPANPACKLIST *spl, SPUSPANLIST *ssl); +//extern int spu_span(SPLSSL *splssl, SPUSPANLIST *a); void task_initialize() @@ -13,4 +19,6 @@ manager->set_symbol("CreateSGP", (void*)create_sgp); manager->set_symbol("UpdateSGP", (void*)update_sgp); manager->set_symbol("CreatePP", (void*)create_pp); + manager->set_symbol("CreateSP", (void*)create_span); + //manager->set_symbol("SpuSP", (void*)spu_span); }
--- a/TaskManager/Test/simple_render/task/update_sgp.cpp Wed Feb 27 04:25:04 2008 +0900 +++ b/TaskManager/Test/simple_render/task/update_sgp.cpp Wed Feb 27 10:56:09 2008 +0900 @@ -1,4 +1,3 @@ -#include <iostream> #include <math.h> #include "scene_graph_pack.h" #include "sys.h" @@ -43,7 +42,8 @@ // ¤Þ¤¢¤³¤ì¤Ï¿ʬÂÌÌܤʤó¤À¤±¤É¡£ // in/out ¤È update ¤Ïʬ¤±¤ëɬÍפ¢¤ë¡© // ¤½¤ì¤Ï¥æ¡¼¥¶Â¦¤Ç in/out ¤Ë¤Ê¤ë¤è¤¦¤Ë½ñ¤«¤»¤ë¤â¤Î¡© - memcpy(_sgp, sgp, sizeof(SceneGraphPack)); + //memcpy(_sgp, sgp, sizeof(SceneGraphPack)); - return sizeof(SceneGraphPack); + //return sizeof(SceneGraphPack); + return 0; }
--- a/TaskManager/Test/simple_render/viewer.cpp Wed Feb 27 04:25:04 2008 +0900 +++ b/TaskManager/Test/simple_render/viewer.cpp Wed Feb 27 10:56:09 2008 +0900 @@ -30,7 +30,7 @@ exit( 1 ); } -#ifdef _DEBUG +#ifndef _DEBUG screen = SDL_SetVideoMode( width, height, bpp, SDL_HWSURFACE); if (screen == NULL) { fprintf(stderr, "Couldn't set GL mode: %s\n", SDL_GetError()); @@ -211,8 +211,6 @@ } } -// run_arg_t ’¤Ë’½ñ’¤¯’¤Î’¤¬’¤á’¤ó’¤É’¤¤’¤«’¤é’¤Ã’¤Æ -// global ’¤Ë’½ñ’¤¯’¤Î’¤â’¤É’¤¦’¤« int start_time; int this_time; int frames; @@ -224,7 +222,6 @@ //PolygonPack *pp; DmaBuffer *sgp_buff; DmaBuffer *pp_buff; -DmaBuffer *sp_buff; DmaBuffer *ssl_buff; @@ -235,6 +232,9 @@ int fd; SceneGraphPack *sgp; + PolygonPack *pp; + SPUSPANLIST *ssl; + start_time = get_ticks(); this_time = 0; @@ -246,29 +246,23 @@ polygon->set_data("cube.xml"); polygon->viewer = this; -#if 1 sgp_buff = manager->allocate(sizeof(SceneGraphPack)); pp_buff = manager->allocate(sizeof(PolygonPack)); - sp_buff = manager->allocate(sizeof(SPANPACK)); - ssl_buff = manager->allocate(sizeof(SPUSPANLIST)); - sgp_buff->get_buffer(&sgp); - create_sgp(polygon, sgp); - sgp_buff->swap_buffer(); - - sgp_buff->get_buffer(&sgp); - create_sgp(polygon, sgp); - sgp_buff->swap_buffer(); + // DmaBuffer ¤Î½é´ü²½¡¢¤«¤Ã¤³¤¤¤¤ÊýË¡¤Ê¤¤¤« + for (int i = 0; i < 2; i ++) { + sgp_buff->get_buffer(&sgp); + create_sgp(polygon, sgp); + sgp_buff->swap_buffer(); -#else - //sgp = new SceneGraphPack; - posix_memalign((void**)&sgp, DEFAULT_ALIGNMENT, sizeof(SceneGraphPack)); - create_sgp(polygon, sgp); + pp_buff->get_buffer(&pp); + ssl_buff->get_buffer(&ssl); - //pp = new PolygonPack; - posix_memalign((void**)&pp, DEFAULT_ALIGNMENT, sizeof(PolygonPack)); -#endif + pp->ssl = ssl; + pp_buff->swap_buffer(); + ssl_buff->swap_buffer(); + } pixels = new Uint32[width*height]; @@ -289,12 +283,10 @@ HTaskPtr task_update_sgp = NULL; HTaskPtr task_create_pp = NULL; HTaskPtr task_create_sp = NULL; - HTaskPtr task_spu_sp = NULL; HTaskPtr task_finish = NULL; int fd_update_sgp; int fd_create_pp; int fd_create_sp; - int fd_spu_sp; int fd_finish; HTaskPtr task; @@ -319,8 +311,7 @@ fd_update_sgp = manager->open("UpdateSGP"); fd_create_pp = manager->open("CreatePP"); - //fd_create_sp = manager->open("CreateSP"); - //fd_spu_sp = manager->open("SpuSP"); + fd_create_sp = manager->open("CreateSP"); fd = manager->open("ViewerRunDraw"); task_update_sgp @@ -329,16 +320,10 @@ task_create_pp = manager->create_task(fd_create_pp, sizeof(SceneGraphPack), sgp_buff, pp_buff, NULL); -#if 0 task_create_sp = manager->create_task(fd_create_sp, sizeof(SceneGraphPack), - pp_buff, spl_buff, NULL); - task_load_texture - = manager->create_task - task_spu_span - = manager->create_task(fd_create_pp, sizeof(SceneGraphPack), - sgp_buff, pp_buff, NULL); - + pp_buff, ssl_buff, NULL); +#if 0 task_draw_finish = manager->create(); for (int i = 0; i < draw_spe_num; i++) { task_spu_draw[i] @@ -347,19 +332,20 @@ task_spu_draw[i]->set_depend(task_spu_span); task_draw_finish->set_depend(tas_spu_draw[i]); } - #endif task = manager->create_task(fd, 0, 0, 0, NULL); task->set_depend(task_update_sgp); task->set_depend(task_create_pp); - + //task->set_depend(task_create_sp); + //task_create_sp->set_depend(task_create_pp); //task_update_sgp->set_cpu(CPU_SPE); task_create_pp->set_cpu(CPU_SPE); task_update_sgp->spawn(); task_create_pp->spawn(); + //task_create_sp->spawn(); task->spawn(); //sgp_buff->swap_buffer();
--- a/TaskManager/kernel/ppe/DmaBuffer.cc Wed Feb 27 04:25:04 2008 +0900 +++ b/TaskManager/kernel/ppe/DmaBuffer.cc Wed Feb 27 10:56:09 2008 +0900 @@ -5,11 +5,11 @@ DmaBuffer::DmaBuffer(int size) { - //buffer[0] = malloc(size); - //buffer[1] = malloc(size); + buffer[0] = malloc(size); + buffer[1] = malloc(size); - posix_memalign(&buffer[0], DEFAULT_ALIGNMENT, size); - posix_memalign(&buffer[1], DEFAULT_ALIGNMENT, size); + //posix_memalign(&buffer[0], DEFAULT_ALIGNMENT, size); + //posix_memalign(&buffer[1], DEFAULT_ALIGNMENT, size); flag = 0; }
--- a/TaskManager/kernel/ppe/TaskManagerImpl.cc Wed Feb 27 04:25:04 2008 +0900 +++ b/TaskManager/kernel/ppe/TaskManagerImpl.cc Wed Feb 27 10:56:09 2008 +0900 @@ -117,7 +117,7 @@ } else { task->in_addr = 0; } - if (htask->in_addr != 0) { + if (htask->out_addr != 0) { htask->out_addr->get_buffer(&task->out_addr); } else { task->out_addr = 0;
--- a/TaskManager/kernel/schedule/FifoDmaManager.cc Wed Feb 27 04:25:04 2008 +0900 +++ b/TaskManager/kernel/schedule/FifoDmaManager.cc Wed Feb 27 10:56:09 2008 +0900 @@ -5,14 +5,16 @@ void FifoDmaManager::dma_load(void *buf, unsigned int addr, int size, int mask) { - if (buf == NULL || (void*)addr == NULL) return; + //if ((void*)addr == NULL) return; + if (size == 0) return; memcpy(buf, (void*)addr, size); } void FifoDmaManager::dma_store(void *buf, unsigned int addr, int size, int mask) { - if (buf == NULL || (void*)addr == NULL) return; + //if ((void*)addr == NULL) return; + if (size == 0) return; memcpy((void*)addr, buf, size); }
--- a/TaskManager/kernel/schedule/SchedTask.cc Wed Feb 27 04:25:04 2008 +0900 +++ b/TaskManager/kernel/schedule/SchedTask.cc Wed Feb 27 10:56:09 2008 +0900 @@ -48,8 +48,9 @@ // ºÇ½é¤«¤é void* ¤¸¤ã¤Ê¤¯¤Æ ´Ø¿ô¥Ý¥¤¥ó¥¿ ¤È¤·¤Æ¤¤¤ì¤ë¤Ù¤¤«¡© int (*func)(void*, void*) = (int (*)(void*,void*))TaskManager::get_address(task->command); - task->in_size = func(readbuf, writebuf); - connector->dma_store(writebuf, task->out_addr, task->in_size, DMA_WRITE); + //task->in_size = func(readbuf, writebuf); + task->in_size = func((void*)task->in_addr, (void*)task->out_addr); + //connector->dma_store(writebuf, task->out_addr, task->in_size, DMA_WRITE); } void