Mercurial > hg > Members > kono > Cerium
comparison TaskManager/Test/test_render/task/DrawSpan.cc @ 467:44c0bce54dcf
fix all examples. test_render is not working now.
author | Shinji KONO <kono@ie.u-ryukyu.ac.jp> |
---|---|
date | Thu, 01 Oct 2009 19:25:25 +0900 |
parents | a18ded47c5dd |
children | bd5b93d39597 |
comparison
equal
deleted
inserted
replaced
466:4fa8760e18c2 | 467:44c0bce54dcf |
---|---|
13 #define TEX_LOAD1 0 | 13 #define TEX_LOAD1 0 |
14 #define TEX_LOAD2 1 | 14 #define TEX_LOAD2 1 |
15 #define SPAN_PACK_LOAD 2 | 15 #define SPAN_PACK_LOAD 2 |
16 #define FB_STORE 3 | 16 #define FB_STORE 3 |
17 | 17 |
18 /* | |
19 * | |
20 * should be done in some where... | |
18 DrawSpan::~DrawSpan() | 21 DrawSpan::~DrawSpan() |
19 { | 22 { |
20 dma_wait(FB_STORE); | 23 dma_wait(FB_STORE); |
21 free((void*)((int)linebuf*doneWrite)); | 24 free((void*)((int)linebuf*doneWrite)); |
22 } | 25 } |
26 */ | |
23 | 27 |
24 /** | 28 /** |
25 * テクスチャは、TEXTURE_SPLIT_PIXEL^2 のブロックに分割する | 29 * テクスチャは、TEXTURE_SPLIT_PIXEL^2 のブロックに分割する |
26 * | 30 * |
27 * +---+---+---+---+---+---+ | 31 * +---+---+---+---+---+---+ |
49 * @param[in] tx X coordinates of texture | 53 * @param[in] tx X coordinates of texture |
50 * @param[in] tx Y coordinates of texture | 54 * @param[in] tx Y coordinates of texture |
51 * @param[in] twidth Width of texture | 55 * @param[in] twidth Width of texture |
52 * @return block ID | 56 * @return block ID |
53 */ | 57 */ |
54 int | 58 static int |
55 DrawSpan::getTexBlock(int tx, int ty, int twidth) | 59 getTexBlock(int tx, int ty, int twidth) |
56 { | 60 { |
57 int blockX, blockY; | 61 int blockX, blockY; |
58 | 62 |
59 blockX = tx / TEXTURE_SPLIT_PIXEL; | 63 blockX = tx / TEXTURE_SPLIT_PIXEL; |
60 blockY = ty / TEXTURE_SPLIT_PIXEL; | 64 blockY = ty / TEXTURE_SPLIT_PIXEL; |
70 * @param[in] tx Y coordinates of texture | 74 * @param[in] tx Y coordinates of texture |
71 * @param[in] tw Width of texture | 75 * @param[in] tw Width of texture |
72 * @param[in] tex_addr_top (tx,ty) で使うテクスチャの先頭address | 76 * @param[in] tex_addr_top (tx,ty) で使うテクスチャの先頭address |
73 * @return block ID | 77 * @return block ID |
74 */ | 78 */ |
75 memaddr | 79 static memaddr |
76 DrawSpan::getTile(int tx, int ty, int tw, memaddr tex_addr_top) | 80 getTile(int tx, int ty, int tw, memaddr tex_addr_top) |
77 { | 81 { |
78 int block = getTexBlock(tx, ty, tw); | 82 int block = getTexBlock(tx, ty, tw); |
79 return tex_addr_top + block * TEXTURE_BLOCK_SIZE * sizeof(uint32); | 83 return tex_addr_top + block * TEXTURE_BLOCK_SIZE * sizeof(uint32); |
80 } | 84 } |
81 | 85 |
85 * @param width Width of Buffer | 89 * @param width Width of Buffer |
86 * @param height Height of Buffer | 90 * @param height Height of Buffer |
87 * @param rgb Initial value of RGB at Buffer | 91 * @param rgb Initial value of RGB at Buffer |
88 * @return Buffer | 92 * @return Buffer |
89 */ | 93 */ |
90 int* | 94 static int* |
91 DrawSpan::linebuf_init(SchedTask *smanager, int width, int height, int rgb) | 95 linebuf_init(SchedTask *smanager, int width, int height, int rgb) |
92 { | 96 { |
93 int *buf = (int*)smanager->allocate(sizeof(int)*width*height); | 97 int *buf = (int*)smanager->allocate(sizeof(int)*width*height); |
94 | 98 |
95 for (int i = 0; i < width*height; i++) { | 99 for (int i = 0; i < width*height; i++) { |
96 buf[i] = rgb; | 100 buf[i] = rgb; |
104 * | 108 * |
105 * @param width Width of Z-Buffer | 109 * @param width Width of Z-Buffer |
106 * @param height Height of Z-Buffer | 110 * @param height Height of Z-Buffer |
107 * @return Z-Buffer | 111 * @return Z-Buffer |
108 */ | 112 */ |
109 float* | 113 static float* |
110 DrawSpan::zRow_init(SchedTask *smanager, int width, int height) | 114 zRow_init(SchedTask *smanager, int width, int height) |
111 { | 115 { |
112 float *buf = (float*)smanager->allocate(sizeof(float)*width*height); | 116 float *buf = (float*)smanager->allocate(sizeof(float)*width*height); |
113 float def = 65535.0f; | 117 float def = 65535.0f; |
114 | 118 |
115 for (int i = 0; i < width*height; i++) { | 119 for (int i = 0; i < width*height; i++) { |
118 | 122 |
119 return buf; | 123 return buf; |
120 } | 124 } |
121 | 125 |
122 | 126 |
123 uint32 | 127 static uint32 |
124 DrawSpan::get_rgb(int tx, int ty, TilePtr tile) | 128 get_rgb(int tx, int ty, TilePtr tile) |
125 { | 129 { |
126 uint32 *data = (uint32 *)tile->data; | 130 uint32 *data = (uint32 *)tile->data; |
127 return data[(TEXTURE_SPLIT_PIXEL)*ty+tx]; | 131 return data[(TEXTURE_SPLIT_PIXEL)*ty+tx]; |
128 } | 132 } |
129 | 133 |
130 | 134 |
131 void | 135 static void |
132 DrawSpan::writebuffer(SchedTask *smanager, unsigned int display, | 136 writebuffer(SchedTask *smanager, unsigned int display, |
133 int buf_width, int height, int screen_width) | 137 int buf_width, int height, int screen_width) |
134 { | 138 { |
135 for (int i = 0; i < height; i++) { | 139 for (int i = 0; i < height; i++) { |
136 smanager->dma_store(&linebuf[i*buf_width], | 140 smanager->dma_store(&linebuf[i*buf_width], |
137 display + (sizeof(int)*screen_width*i), | 141 display + (sizeof(int)*screen_width*i), |
150 * @param y 〃 の、y 座標 | 154 * @param y 〃 の、y 座標 |
151 * @param tex_x pixel が使用するテクスチャの、Tile (8x8) 内での x 座標 | 155 * @param tex_x pixel が使用するテクスチャの、Tile (8x8) 内での x 座標 |
152 * @param tex_y 〃 の y 座標 | 156 * @param tex_y 〃 の y 座標 |
153 * @param tex_addr テクスチャのアドレス(MainMemory) | 157 * @param tex_addr テクスチャのアドレス(MainMemory) |
154 */ | 158 */ |
155 void | 159 static void |
156 DrawSpan::updateBuffer(float zpos, int rangex, int x, int y, int tex_x, int tex_y, | 160 updateBuffer(float zpos, int rangex, int x, int y, int tex_x, int tex_y, |
157 float normal_x, float normal_y, float normal_z, TilePtr tile) | 161 float normal_x, float normal_y, float normal_z, TilePtr tile) |
158 { | 162 { |
159 | 163 |
160 int color = get_rgb(tex_x, tex_y, tile); | 164 int color = get_rgb(tex_x, tex_y, tile); |
161 /*下位4bitを抽出*/ | 165 /*下位4bitを抽出*/ |
175 * | 179 * |
176 * @param span Span | 180 * @param span Span |
177 * @param startx 描画開始範囲 | 181 * @param startx 描画開始範囲 |
178 * @param endx 描画終了範囲 | 182 * @param endx 描画終了範囲 |
179 */ | 183 */ |
180 int | 184 static int |
181 DrawSpan::drawDot1(SchedTask *smanager, SpanPtr span, int startx, int endx, int wait_tag) | 185 drawDot1(SchedTask *smanager, SpanPtr span, int startx, int endx, int wait_tag) |
182 { | 186 { |
183 int rangex = endx - startx + 1; | 187 int rangex = endx - startx + 1; |
184 | 188 |
185 float normal_x = span->normal_x; | 189 float normal_x = span->normal_x; |
186 float normal_y = span->normal_y; | 190 float normal_y = span->normal_y; |
231 } | 235 } |
232 | 236 |
233 return -1; | 237 return -1; |
234 } | 238 } |
235 | 239 |
236 void | 240 static void |
237 DrawSpan::drawDot2(SchedTask *smanager, SpanPtr span, int startx, int end, int js, int wait_tag) | 241 drawDot2(SchedTask *smanager, SpanPtr span, int startx, int end, int js, int wait_tag) |
238 { | 242 { |
239 //printf("%d\n", js); | 243 //printf("%d\n", js); |
240 } | 244 } |
241 | 245 |
242 /** | 246 /** |
254 * @param span Span | 258 * @param span Span |
255 * @param startx 描画開始範囲 | 259 * @param startx 描画開始範囲 |
256 * @param endx 描画終了範囲 | 260 * @param endx 描画終了範囲 |
257 * @return 「span のどの位置まで rendering が終わったか」の x 座標 | 261 * @return 「span のどの位置まで rendering が終わったか」の x 座標 |
258 */ | 262 */ |
259 int | 263 static int |
260 DrawSpan::drawLine1(SchedTask *smanager, SpanPtr span, int startx, int endx, int wait_tag) | 264 drawLine1(SchedTask *smanager, SpanPtr span, int startx, int endx, int wait_tag) |
261 { | 265 { |
262 int x = span->x; | 266 int x = span->x; |
263 int rangex = endx - startx + 1; | 267 int rangex = endx - startx + 1; |
264 int x_len = span->length_x; | 268 int x_len = span->length_x; |
265 | 269 |
329 } | 333 } |
330 | 334 |
331 return ret; | 335 return ret; |
332 } | 336 } |
333 | 337 |
334 int | 338 static int |
335 DrawSpan::infinity_light_calc(int color,float normal_x, float normal_y, float normal_z) | 339 infinity_light_calc(int color,float normal_x, float normal_y, float normal_z) |
336 { | 340 { |
337 unsigned char rgb[4]; | 341 unsigned char rgb[4]; |
338 int light_rgb; | 342 int light_rgb; |
339 int flag; | 343 int flag; |
340 float normal_vector[4] = {normal_x,normal_y,normal_z,0}; | 344 float normal_vector[4] = {normal_x,normal_y,normal_z,0}; |
363 | 367 |
364 return light_rgb; | 368 return light_rgb; |
365 } | 369 } |
366 | 370 |
367 | 371 |
368 int | 372 static int |
369 DrawSpan::run(SchedTask *smanager, void *rbuf, void *wbuf) | 373 run(SchedTask *smanager, void *rbuf, void *wbuf) |
370 { | 374 { |
371 SpanPackPtr spack = (SpanPackPtr)smanager->get_input(0); | 375 SpanPackPtr spack = (SpanPackPtr)smanager->get_input(0); |
372 SpanPackPtr next_spack = (SpanPackPtr)smanager->allocate(sizeof(SpanPack)); | 376 SpanPackPtr next_spack = (SpanPackPtr)smanager->allocate(sizeof(SpanPack)); |
373 SpanPackPtr free_spack = next_spack; // next_spack の free() 用 | 377 SpanPackPtr free_spack = next_spack; // next_spack の free() 用 |
374 Span *span; | 378 Span *span; |