annotate old/simple_render/spe/Load_Texture.cpp @ 539:3bc98f6d31ff draft

Reorganization..
author Shinji KONO <kono@ie.u-ryukyu.ac.jp>
date Mon, 12 Oct 2009 09:39:35 +0900
parents TaskManager/Test/simple_render/spe/Load_Texture.cpp@028ffc9c0375
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
100
9f8b53beef7e *** empty log message ***
gongo
parents:
diff changeset
1 #include <malloc.h>
9f8b53beef7e *** empty log message ***
gongo
parents:
diff changeset
2 #include "CellScheduler.h"
9f8b53beef7e *** empty log message ***
gongo
parents:
diff changeset
3 #include "Load_Texture.h"
9f8b53beef7e *** empty log message ***
gongo
parents:
diff changeset
4 #include "error.h"
9f8b53beef7e *** empty log message ***
gongo
parents:
diff changeset
5 #include "SchedTask.h"
9f8b53beef7e *** empty log message ***
gongo
parents:
diff changeset
6 #include "TaskManager.h"
9f8b53beef7e *** empty log message ***
gongo
parents:
diff changeset
7 using namespace std;
9f8b53beef7e *** empty log message ***
gongo
parents:
diff changeset
8
9f8b53beef7e *** empty log message ***
gongo
parents:
diff changeset
9 #define height 128
9f8b53beef7e *** empty log message ***
gongo
parents:
diff changeset
10 #define width 128
9f8b53beef7e *** empty log message ***
gongo
parents:
diff changeset
11
9f8b53beef7e *** empty log message ***
gongo
parents:
diff changeset
12
9f8b53beef7e *** empty log message ***
gongo
parents:
diff changeset
13 int
9f8b53beef7e *** empty log message ***
gongo
parents:
diff changeset
14 LoadTexture::run(void *rbuf , void *wbuf)
9f8b53beef7e *** empty log message ***
gongo
parents:
diff changeset
15 {
9f8b53beef7e *** empty log message ***
gongo
parents:
diff changeset
16 //int rgb;
9f8b53beef7e *** empty log message ***
gongo
parents:
diff changeset
17 __debug("[LoadTexture:%s]\n", __FUNCTION__);
102
62679f4cae18 tag:first_render_with_spe fix
gongo
parents: 100
diff changeset
18 __debug("%x\n",(int)rbuf);
62679f4cae18 tag:first_render_with_spe fix
gongo
parents: 100
diff changeset
19 __debug("run\n");
100
9f8b53beef7e *** empty log message ***
gongo
parents:
diff changeset
20
9f8b53beef7e *** empty log message ***
gongo
parents:
diff changeset
21 return 0;
9f8b53beef7e *** empty log message ***
gongo
parents:
diff changeset
22 }
9f8b53beef7e *** empty log message ***
gongo
parents:
diff changeset
23
9f8b53beef7e *** empty log message ***
gongo
parents:
diff changeset
24 // byteperpixel = 3 width = 128 dma_height= 32
9f8b53beef7e *** empty log message ***
gongo
parents:
diff changeset
25 #define LOAD_SIZE 3*128*32
9f8b53beef7e *** empty log message ***
gongo
parents:
diff changeset
26 #define MAX_LOAD_SIZE 16384
9f8b53beef7e *** empty log message ***
gongo
parents:
diff changeset
27 #define USE_ARRAY 3
9f8b53beef7e *** empty log message ***
gongo
parents:
diff changeset
28
9f8b53beef7e *** empty log message ***
gongo
parents:
diff changeset
29 void
9f8b53beef7e *** empty log message ***
gongo
parents:
diff changeset
30 LoadTexture::read(void)
9f8b53beef7e *** empty log message ***
gongo
parents:
diff changeset
31 {
9f8b53beef7e *** empty log message ***
gongo
parents:
diff changeset
32 __debug("[LoadTexture:%s]\n", __FUNCTION__);
9f8b53beef7e *** empty log message ***
gongo
parents:
diff changeset
33 #if 1
9f8b53beef7e *** empty log message ***
gongo
parents:
diff changeset
34 connector->dma_load(readbuf,task->in_addr,MAX_LOAD_SIZE,DMA_READ);
9f8b53beef7e *** empty log message ***
gongo
parents:
diff changeset
35 connector->dma_load((void*)((int)readbuf + MAX_LOAD_SIZE),
9f8b53beef7e *** empty log message ***
gongo
parents:
diff changeset
36 task->in_addr + MAX_LOAD_SIZE, MAX_LOAD_SIZE,DMA_READ + 1);
9f8b53beef7e *** empty log message ***
gongo
parents:
diff changeset
37 connector->dma_load((void*)((int)readbuf + MAX_LOAD_SIZE*2) ,
9f8b53beef7e *** empty log message ***
gongo
parents:
diff changeset
38 task->in_addr + MAX_LOAD_SIZE * 2,MAX_LOAD_SIZE,DMA_READ + 2);
102
62679f4cae18 tag:first_render_with_spe fix
gongo
parents: 100
diff changeset
39 __debug("readbuf: %x\n", (uint32)readbuf);
62679f4cae18 tag:first_render_with_spe fix
gongo
parents: 100
diff changeset
40 __debug("readbuf2:%x\n", (int)readbuf + MAX_LOAD_SIZE);
62679f4cae18 tag:first_render_with_spe fix
gongo
parents: 100
diff changeset
41 __debug("readbuf3:%x\n", (int)readbuf + MAX_LOAD_SIZE*2);
100
9f8b53beef7e *** empty log message ***
gongo
parents:
diff changeset
42 #else
9f8b53beef7e *** empty log message ***
gongo
parents:
diff changeset
43 mfc_list_element buf[USE_ARRAY];
9f8b53beef7e *** empty log message ***
gongo
parents:
diff changeset
44 for(int i = 0; i < USE_ARRAY; i++) {
9f8b53beef7e *** empty log message ***
gongo
parents:
diff changeset
45 buf[i].notify = 0;
9f8b53beef7e *** empty log message ***
gongo
parents:
diff changeset
46 buf[i].reserved = 0;
9f8b53beef7e *** empty log message ***
gongo
parents:
diff changeset
47 buf[i].size = MAX_LOAD_SIZE;
9f8b53beef7e *** empty log message ***
gongo
parents:
diff changeset
48 buf[i].eal = task->in_addr + i*MAX_LOAD_SIZE;
9f8b53beef7e *** empty log message ***
gongo
parents:
diff changeset
49 }
102
62679f4cae18 tag:first_render_with_spe fix
gongo
parents: 100
diff changeset
50 __debug("set_load_info\n");
100
9f8b53beef7e *** empty log message ***
gongo
parents:
diff changeset
51 connector->dma_load(readbuf, (unsigned int)buf, MAX_LOAD_SIZE, DMA_READ);
102
62679f4cae18 tag:first_render_with_spe fix
gongo
parents: 100
diff changeset
52 __debug("dma_load_finish\n");
100
9f8b53beef7e *** empty log message ***
gongo
parents:
diff changeset
53
9f8b53beef7e *** empty log message ***
gongo
parents:
diff changeset
54 #endif
9f8b53beef7e *** empty log message ***
gongo
parents:
diff changeset
55 }
9f8b53beef7e *** empty log message ***
gongo
parents:
diff changeset
56
9f8b53beef7e *** empty log message ***
gongo
parents:
diff changeset
57 void
9f8b53beef7e *** empty log message ***
gongo
parents:
diff changeset
58 LoadTexture::write(void)
9f8b53beef7e *** empty log message ***
gongo
parents:
diff changeset
59 {
9f8b53beef7e *** empty log message ***
gongo
parents:
diff changeset
60 __debug("[LoadTexture:%s]\n",__FUNCTION__);
9f8b53beef7e *** empty log message ***
gongo
parents:
diff changeset
61 connector->dma_wait(DMA_WRITE);
9f8b53beef7e *** empty log message ***
gongo
parents:
diff changeset
62 connector->mail_write((uint32)task->self);
9f8b53beef7e *** empty log message ***
gongo
parents:
diff changeset
63 }
9f8b53beef7e *** empty log message ***
gongo
parents:
diff changeset
64
9f8b53beef7e *** empty log message ***
gongo
parents:
diff changeset
65 /*
9f8b53beef7e *** empty log message ***
gongo
parents:
diff changeset
66 Uint32 Polygon::get_rgb(int tx, int ty)
9f8b53beef7e *** empty log message ***
gongo
parents:
diff changeset
67 {
9f8b53beef7e *** empty log message ***
gongo
parents:
diff changeset
68 SDL_PixelFormat *fmt;
9f8b53beef7e *** empty log message ***
gongo
parents:
diff changeset
69 Uint8 red, green, blue;
9f8b53beef7e *** empty log message ***
gongo
parents:
diff changeset
70
9f8b53beef7e *** empty log message ***
gongo
parents:
diff changeset
71 fmt = texture_image->format;
9f8b53beef7e *** empty log message ***
gongo
parents:
diff changeset
72
9f8b53beef7e *** empty log message ***
gongo
parents:
diff changeset
73 if (tx<0) tx = 0;
9f8b53beef7e *** empty log message ***
gongo
parents:
diff changeset
74 if (texture_image->w-1< tx) tx = texture_image->w-1 ;
9f8b53beef7e *** empty log message ***
gongo
parents:
diff changeset
75 if (ty<0) ty = 0;
9f8b53beef7e *** empty log message ***
gongo
parents:
diff changeset
76 if (texture_image->h-1< ty) ty = texture_image->h-1 ;
9f8b53beef7e *** empty log message ***
gongo
parents:
diff changeset
77
9f8b53beef7e *** empty log message ***
gongo
parents:
diff changeset
78
9f8b53beef7e *** empty log message ***
gongo
parents:
diff changeset
79
9f8b53beef7e *** empty log message ***
gongo
parents:
diff changeset
80 char *p = get_pixel(tx,ty,texture_image);
9f8b53beef7e *** empty log message ***
gongo
parents:
diff changeset
81 blue = (Uint8) p[0];
9f8b53beef7e *** empty log message ***
gongo
parents:
diff changeset
82 green = (Uint8) p[1];
9f8b53beef7e *** empty log message ***
gongo
parents:
diff changeset
83 red = (Uint8) p[2];
9f8b53beef7e *** empty log message ***
gongo
parents:
diff changeset
84
9f8b53beef7e *** empty log message ***
gongo
parents:
diff changeset
85
9f8b53beef7e *** empty log message ***
gongo
parents:
diff changeset
86 SDL_PixelFormat *pf;
9f8b53beef7e *** empty log message ***
gongo
parents:
diff changeset
87 pf = viewer->screen->format;
9f8b53beef7e *** empty log message ***
gongo
parents:
diff changeset
88
9f8b53beef7e *** empty log message ***
gongo
parents:
diff changeset
89 //cout << SDL_MapRGB(pf, red, green, blue) << endl;
9f8b53beef7e *** empty log message ***
gongo
parents:
diff changeset
90 return SDL_MapRGB(pf, red, green, blue);
9f8b53beef7e *** empty log message ***
gongo
parents:
diff changeset
91 }
9f8b53beef7e *** empty log message ***
gongo
parents:
diff changeset
92 */
9f8b53beef7e *** empty log message ***
gongo
parents:
diff changeset
93
9f8b53beef7e *** empty log message ***
gongo
parents:
diff changeset
94 SchedTask *
9f8b53beef7e *** empty log message ***
gongo
parents:
diff changeset
95 createTask_LoadTexture(TaskListPtr _taskList, TaskPtr _task,
9f8b53beef7e *** empty log message ***
gongo
parents:
diff changeset
96 void *rbuf, void *wbuf, DmaManager *dma) {
9f8b53beef7e *** empty log message ***
gongo
parents:
diff changeset
97 CellScheduler::tex = memalign(DEFAULT_ALIGNMENT, DMA_MAX_SIZE*3);
9f8b53beef7e *** empty log message ***
gongo
parents:
diff changeset
98 rbuf = CellScheduler::tex;
9f8b53beef7e *** empty log message ***
gongo
parents:
diff changeset
99
9f8b53beef7e *** empty log message ***
gongo
parents:
diff changeset
100 return new LoadTexture(_taskList, _task, rbuf, wbuf, dma);
9f8b53beef7e *** empty log message ***
gongo
parents:
diff changeset
101 }