Mercurial > hg > Game > Cerium
comparison TaskManager/Test/test_render/spe/DrawSpan.cpp @ 182:8e9ada0c1ed0 draft
add get_inputAddr, get_outputAddr
author | gongo@gendarme.cr.ie.u-ryukyu.ac.jp |
---|---|
date | Tue, 23 Dec 2008 16:27:07 +0900 |
parents | e3b7776b1420 |
children | 90dcdc080e9d a19d3ed4ce5b |
comparison
equal
deleted
inserted
replaced
181:f5f814194c4c | 182:8e9ada0c1ed0 |
---|---|
121 | 121 |
122 | 122 |
123 int | 123 int |
124 DrawSpan::run(void *rbuf, void *wbuf) | 124 DrawSpan::run(void *rbuf, void *wbuf) |
125 { | 125 { |
126 SpanPack *sp = (SpanPack*)smanager->get_input(0); | 126 SpanPack *spack = (SpanPack*)smanager->get_input(0); |
127 SpanPack *next_sp = | 127 SpanPack *next_spack = |
128 (SpanPack*)smanager->allocate(sizeof(SpanPack)); | 128 (SpanPack*)smanager->allocate(sizeof(SpanPack)); |
129 SpanPack *free_sp = next_sp; // next_sp の free() 用 | 129 SpanPack *free_spack = next_spack; // next_spack の free() 用 |
130 SpanPack *tmp_sp = NULL; | |
131 Span *span; | 130 Span *span; |
132 | 131 |
133 hash = (TileHashPtr)smanager->global_get(GLOBAL_TEXTURE_HASH); | 132 hash = (TileHashPtr)smanager->global_get(GLOBAL_TEXTURE_HASH); |
134 tileList = (TileListPtr)smanager->global_get(GLOBAL_TILE_LIST); | 133 tileList = (TileListPtr)smanager->global_get(GLOBAL_TILE_LIST); |
135 | 134 |
136 int rangex_start = get_param(0); // このタスクが担当する x の範囲の始点 | 135 int rangex_start = smanager->get_param(0); |
137 int rangex_end = get_param(1); // 終点 (start <= x <= end) | 136 int rangex_end = smanager->get_param(1); |
138 int rangey = get_param(2); // y の範囲 (render_y + rangey - 1) | 137 |
138 // このタスクが担当する x の範囲 | |
139 int rangex = rangex_end - rangex_start + 1; | 139 int rangex = rangex_end - rangex_start + 1; |
140 | |
141 // y の範囲 (render_y + rangey - 1) | |
142 int rangey = smanager->get_param(2); | |
140 | 143 |
141 float *zRow = (float*)smanager->get_input(1); | 144 float *zRow = (float*)smanager->get_input(1); |
142 int **linebuf = (int**)smanager->allocate(sizeof(int*)*rangey); | 145 int **linebuf = (int**)smanager->allocate(sizeof(int*)*rangey); |
143 | 146 |
144 for (int i = 0; i < rangey; i++) { | 147 for (int i = 0; i < rangey; i++) { |
150 /** | 153 /** |
151 * SpanPack->next が存在する場合、 | 154 * SpanPack->next が存在する場合、 |
152 * 現在の SpanPack を処理してる間に | 155 * 現在の SpanPack を処理してる間に |
153 * 次の SpanPack の DMA 転送を行う | 156 * 次の SpanPack の DMA 転送を行う |
154 */ | 157 */ |
155 if (sp->next != NULL) { | 158 if (spack->next != NULL) { |
156 smanager->dma_load(next_sp, (uint32)sp->next, | 159 smanager->dma_load(next_spack, (uint32)spack->next, |
157 sizeof(SpanPack), SPAN_PACK_LOAD); | 160 sizeof(SpanPack), SPAN_PACK_LOAD); |
158 } else { | 161 } else { |
159 next_sp = NULL; | 162 next_spack = NULL; |
160 } | 163 } |
161 | 164 |
162 for (int t = sp->info.start; t < sp->info.size; t++) { | 165 for (int t = 0; t < spack->info.size; t++) { |
163 span = &sp->span[t]; | 166 span = &spack->span[t]; |
164 | 167 |
165 Uint32 rgb = 0x00ff00; | 168 Uint32 rgb = 0x00ff00; |
166 float tex1 = span->tex_x1; | 169 float tex1 = span->tex_x1; |
167 float tex2 = span->tex_x2; | 170 float tex2 = span->tex_x2; |
168 float tey1 = span->tex_y1; | 171 float tey1 = span->tex_y1; |
222 | 225 |
223 tex_z = z*(x_len-1-j)/(x_len-1) + zpos*j/(x_len-1); | 226 tex_z = z*(x_len-1-j)/(x_len-1) + zpos*j/(x_len-1); |
224 | 227 |
225 tex_x = tex1*(x_len-1-j)/(x_len-1) + tex2*j/(x_len-1); | 228 tex_x = tex1*(x_len-1-j)/(x_len-1) + tex2*j/(x_len-1); |
226 tex_y = tey1*(x_len-1-j)/(x_len-1) + tey2*j/(x_len-1); | 229 tex_y = tey1*(x_len-1-j)/(x_len-1) + tey2*j/(x_len-1); |
227 /** | |
228 * ・・・なんかかっこいい書き方ないかな | |
229 */ | |
230 if (tex_x > 1) tex_x = 1; | 230 if (tex_x > 1) tex_x = 1; |
231 if (tex_x < 0) tex_x = 0; | 231 if (tex_x < 0) tex_x = 0; |
232 if (tex_y > 1) tex_y = 1; | 232 if (tex_y > 1) tex_y = 1; |
233 if (tex_y < 0) tex_y = 0; | 233 if (tex_y < 0) tex_y = 0; |
234 tex_xpos = (int)((span->tex_width-1) * tex_x); | 234 tex_xpos = (int)((span->tex_width-1) * tex_x); |
249 } | 249 } |
250 } | 250 } |
251 | 251 |
252 smanager->dma_wait(SPAN_PACK_LOAD); | 252 smanager->dma_wait(SPAN_PACK_LOAD); |
253 | 253 |
254 tmp_sp = sp; | 254 SpanPack *tmp_spack = spack; |
255 sp = next_sp; | 255 spack = next_spack; |
256 next_sp = tmp_sp; | 256 next_spack = tmp_spack; |
257 } while (sp); | 257 } while (spack); |
258 | 258 |
259 free(free_sp); | 259 free(free_spack); |
260 free(linebuf); | 260 free(linebuf); |
261 | 261 |
262 return 0; | 262 return 0; |
263 } | 263 } |