Mercurial > hg > Game > Cerium
changeset 100:9f8b53beef7e
*** empty log message ***
author | gongo |
---|---|
date | Fri, 29 Feb 2008 05:43:43 +0900 |
parents | 57bac9e07662 |
children | c31499d11926 |
files | TaskManager/Test/simple_render/spe/Load_Texture.cpp TaskManager/Test/simple_render/spe/Load_Texture.h TaskManager/Test/simple_render/spe/SpuDraw.cpp |
diffstat | 3 files changed, 133 insertions(+), 3 deletions(-) [+] |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/TaskManager/Test/simple_render/spe/Load_Texture.cpp Fri Feb 29 05:43:43 2008 +0900 @@ -0,0 +1,107 @@ +//#include <stdio.h> +//#include <spu_intrinsics.h> +//#include <spu_mfcio.h> +#include <malloc.h> +#include "CellScheduler.h" +#include "Load_Texture.h" +#include "error.h" +#include "SchedTask.h" +//#include "SchedTaskList.h" +//#include "SchedNop2Ready.h" +//#include "DmaManager.h" +#include "TaskManager.h" +using namespace std; + +#define height 128 +#define width 128 + + +int +LoadTexture::run(void *rbuf , void *wbuf) +{ + //int rgb; + __debug("[LoadTexture:%s]\n", __FUNCTION__); + printf("%x\n",(int)rbuf); + printf("run\n"); + + return 0; +} + +// byteperpixel = 3 width = 128 dma_height= 32 +#define LOAD_SIZE 3*128*32 +#define MAX_LOAD_SIZE 16384 +#define USE_ARRAY 3 + +void +LoadTexture::read(void) +{ + __debug("[LoadTexture:%s]\n", __FUNCTION__); +#if 1 + connector->dma_load(readbuf,task->in_addr,MAX_LOAD_SIZE,DMA_READ); + connector->dma_load((void*)((int)readbuf + MAX_LOAD_SIZE), + task->in_addr + MAX_LOAD_SIZE, MAX_LOAD_SIZE,DMA_READ + 1); + connector->dma_load((void*)((int)readbuf + MAX_LOAD_SIZE*2) , + task->in_addr + MAX_LOAD_SIZE * 2,MAX_LOAD_SIZE,DMA_READ + 2); + printf("readbuf: %x\n", (uint32)readbuf); + printf("readbuf2:%x\n", (int)readbuf + MAX_LOAD_SIZE); + printf("readbuf3:%x\n", (int)readbuf + MAX_LOAD_SIZE*2); +#else + mfc_list_element buf[USE_ARRAY]; + for(int i = 0; i < USE_ARRAY; i++) { + buf[i].notify = 0; + buf[i].reserved = 0; + buf[i].size = MAX_LOAD_SIZE; + buf[i].eal = task->in_addr + i*MAX_LOAD_SIZE; + } + printf("set_load_info\n"); + connector->dma_load(readbuf, (unsigned int)buf, MAX_LOAD_SIZE, DMA_READ); + printf("dma_load_finish\n"); + +#endif +} + +void +LoadTexture::write(void) +{ + __debug("[LoadTexture:%s]\n",__FUNCTION__); + connector->dma_wait(DMA_WRITE); + connector->mail_write((uint32)task->self); +} + +/* +Uint32 Polygon::get_rgb(int tx, int ty) +{ +SDL_PixelFormat *fmt; +Uint8 red, green, blue; + +fmt = texture_image->format; + +if (tx<0) tx = 0; +if (texture_image->w-1< tx) tx = texture_image->w-1 ; +if (ty<0) ty = 0; +if (texture_image->h-1< ty) ty = texture_image->h-1 ; + + + +char *p = get_pixel(tx,ty,texture_image); +blue = (Uint8) p[0]; +green = (Uint8) p[1]; +red = (Uint8) p[2]; + + +SDL_PixelFormat *pf; +pf = viewer->screen->format; + +//cout << SDL_MapRGB(pf, red, green, blue) << endl; +return SDL_MapRGB(pf, red, green, blue); +} +*/ + +SchedTask * +createTask_LoadTexture(TaskListPtr _taskList, TaskPtr _task, + void *rbuf, void *wbuf, DmaManager *dma) { + CellScheduler::tex = memalign(DEFAULT_ALIGNMENT, DMA_MAX_SIZE*3); + rbuf = CellScheduler::tex; + + return new LoadTexture(_taskList, _task, rbuf, wbuf, dma); +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/TaskManager/Test/simple_render/spe/Load_Texture.h Fri Feb 29 05:43:43 2008 +0900 @@ -0,0 +1,21 @@ +#ifndef INCLUDED_TASK_LOAD_TEXTURE +#define INCLUDED_TASK_LOAD_TEXTURE + + +#ifndef INCLUDED_SCHED_TASK +#include "SchedTask.h" +#endif + +#define LOAD_TEXTURE 2 + +class LoadTexture: public SchedTask { +public: + LoadTexture(TaskListPtr _tlist, TaskPtr _task, + void* _rbuf, void* _wbuf, DmaManager* _con) + :SchedTask(_tlist, _task, _rbuf, _wbuf, _con) {} + int run(void *readbuf, void *writebuf); + void read(void); + void write(void); +}; + +#endif
--- a/TaskManager/Test/simple_render/spe/SpuDraw.cpp Fri Feb 29 05:20:23 2008 +0900 +++ b/TaskManager/Test/simple_render/spe/SpuDraw.cpp Fri Feb 29 05:43:43 2008 +0900 @@ -110,7 +110,9 @@ pf.BytesPerPixel = 4; alpha = 255; - return SDL_MapRGB(&pf, red, green, blue); + return (red & 0xff) * 0x10000 + (green & 0xff) * 0x100 + (blue & 0xff) + + (alpha << 24); + //return SDL_MapRGB(&pf, red, green, blue); #else return 0x900000; #endif @@ -164,7 +166,7 @@ tex_zpos = (int)z; if (z < zRow[x + (width*(y%8))]) { - //rgb = get_rgb(tex_xpos, tex_ypos, CellScheduler::tex); + rgb = get_rgb(tex_xpos, tex_ypos, CellScheduler::tex); zRow[x + (width*(y%8))] = z; linebuf[(width*(y%8)) + x] = rgb; //viewer->write_pixel(x,y,zpos,rgb); @@ -181,7 +183,7 @@ if (z < zRow[x + j + (width*(y%8))]) { //__debug("x = %d, y = %d, width = %d, end = %d\n", x, y, width, end); - //rgb = get_rgb(tex_xpos,tex_ypos,CellScheduler::tex); + rgb = get_rgb(tex_xpos,tex_ypos,CellScheduler::tex); zRow[j + x + (width*(y%8))] = z; linebuf[j + (width*(y%8)) + x] = rgb; //viewer->write_pixel(j+x,y,tex_z,rgb);