comparison TaskManager/Test/test_render/spe/DrawSpan.cpp @ 148:74341c8bf935 draft

Span への Texture List の渡し。じゃっかん texture がバグってるので 要チェック
author gongo@charles.cr.ie.u-ryukyu.ac.jp
date Tue, 02 Dec 2008 18:49:04 +0900
parents 4636153abc9f
children 79ded2ad7236 8c9cae96404b
comparison
equal deleted inserted replaced
147:4636153abc9f 148:74341c8bf935
112 if (tw-1< tx) tx = tw-1 ; 112 if (tw-1< tx) tx = tw-1 ;
113 if (ty<0) ty = 0; 113 if (ty<0) ty = 0;
114 if (th-1< ty) ty = th-1 ; 114 if (th-1< ty) ty = th-1 ;
115 115
116 void *texture_addr; 116 void *texture_addr;
117 117 TilePtr tile;
118
119 #if 0
118 int blockX = tx / TEXTURE_SPLIT_PIXEL; 120 int blockX = tx / TEXTURE_SPLIT_PIXEL;
119 int blockY = ty / TEXTURE_SPLIT_PIXEL; 121 int blockY = ty / TEXTURE_SPLIT_PIXEL;
120 void** addrList = (void**)global_get(TEXTURE2_ID); 122 void** addrList = (void**)global_get(TEXTURE2_ID);
121 TilePtr tile;
122 123
123 texture_addr = addrList[blockX + (tw/TEXTURE_SPLIT_PIXEL)*blockY]; 124 texture_addr = addrList[blockX + (tw/TEXTURE_SPLIT_PIXEL)*blockY];
125 #else
126 texture_addr = texture;
127 #endif
124 128
125 /** 129 /**
126 * get,put ϥ֥(HashȤ)äƥ뤫 130 * get,put ϥ֥(HashȤ)äƥ뤫
127 */ 131 */
128 tile = get(texture_addr); 132 tile = get(texture_addr);
179 183
180 TileInfoListPtr tilist = 184 TileInfoListPtr tilist =
181 (TileInfoListPtr)smanager->allocate(sizeof(TileInfoList)); 185 (TileInfoListPtr)smanager->allocate(sizeof(TileInfoList));
182 TileInfoListPtr next_tilist = 186 TileInfoListPtr next_tilist =
183 (TileInfoListPtr)smanager->allocate(sizeof(TileInfoList)); 187 (TileInfoListPtr)smanager->allocate(sizeof(TileInfoList));
184 TileInfoListPtr tmp_tilist = NULL;
185 TileInfoPtr tinfo; 188 TileInfoPtr tinfo;
186 189
187 190
188 tileList = (TileListPtr)smanager->allocate(sizeof(TileList)); 191 tileList = (TileListPtr)smanager->allocate(sizeof(TileList));
189 tileList->init(); 192 tileList->init();
248 251
249 if (x_len == 1) { 252 if (x_len == 1) {
250 if (x < rangex_start || rangex_end < x) { 253 if (x < rangex_start || rangex_end < x) {
251 continue; 254 continue;
252 } 255 }
256
253 tex_xpos = (int)((span->tex_width-1) * tex1); 257 tex_xpos = (int)((span->tex_width-1) * tex1);
254 tex_ypos = (int)((span->tex_height-1) * tey1); 258 tex_ypos = (int)((span->tex_height-1) * tey1);
255 tex_zpos = (int)z; 259 tex_zpos = (int)z;
256 260
261 #if 0
262 if (tex_xpos != tilist->tileinfo[0].tix
263 && tex_xpos != tilist->tileinfo[0].tix) {
264 fprintf(stderr, "1: (%3d, %3d), (%3d, %3d)\n",
265 tex_xpos, tex_ypos, tilist->tileinfo[0].tix,
266 tilist->tileinfo[0].tiy);
267 }
268 #endif
269
270 tex_xpos = tilist->tileinfo[0].tix;
271 tex_ypos = tilist->tileinfo[0].tiy;
272 texture_image = tilist->tileinfo[0].tile;
273
257 if (zpos < zRow[localx + (rangex * localy)]) { 274 if (zpos < zRow[localx + (rangex * localy)]) {
258 rgb = get_rgb(tex_xpos, tex_ypos, span->tex_width, 275 rgb = get_rgb(tex_xpos, tex_ypos, span->tex_width,
259 span->tex_height, texture_image); 276 span->tex_height, texture_image);
260 zRow[localx + (rangex * localy)] = zpos; 277 zRow[localx + (rangex * localy)] = zpos;
261 linebuf[localy][localx] = rgb; 278 linebuf[localy][localx] = rgb;
268 285
269 int cur_x = 0; 286 int cur_x = 0;
270 int max_x = je; 287 int max_x = je;
271 int len; 288 int len;
272 289
290 /**
291 * Span ɽʤϰ([js..je]) TileInfoList
292 * äƤΤǡФ
293 */
273 while (cur_x + MAX_TILE_LIST < js) { 294 while (cur_x + MAX_TILE_LIST < js) {
295 smanager->dma_load(next_tilist, (uint32)tilist->next,
296 sizeof(TileInfoList), TILE_INFO_LOAD);
274 smanager->dma_wait(TILE_INFO_LOAD); 297 smanager->dma_wait(TILE_INFO_LOAD);
275 smanager->dma_load(tilist, (uint32)tilist->next, 298
276 sizeof(TileInfoList), TILE_INFO_LOAD); 299 TileInfoListPtr tmp = tilist;
300 tilist = next_tilist;
301 next_tilist = tmp;
302
277 cur_x += MAX_TILE_LIST; 303 cur_x += MAX_TILE_LIST;
278 } 304 }
279 305
280 cur_x = js; 306 cur_x = js;
281 307
282 while (cur_x < max_x) { 308 while (cur_x <= max_x) {
283 smanager->dma_wait(TILE_INFO_LOAD); 309 if (cur_x + MAX_TILE_LIST - 1 < max_x) {
284
285 if (cur_x + MAX_TILE_LIST < max_x) {
286 smanager->dma_load(next_tilist, (uint32)tilist->next, 310 smanager->dma_load(next_tilist, (uint32)tilist->next,
287 sizeof(TileInfoList), TILE_INFO_LOAD); 311 sizeof(TileInfoList),
288 len = MAX_TILE_LIST; 312 TILE_INFO_LOAD);
313 len = MAX_TILE_LIST - 1;
289 } else { 314 } else {
290 len = max_x - cur_x; 315 len = max_x - cur_x;
291 } 316 }
292 317
293 float tex_x, tex_y, tex_z; 318 float tex_x, tex_y, tex_z;
294 319
295 for (int j = cur_x; j <= cur_x + len; j++) { 320 for (int j = cur_x; j <= cur_x + len; j++) {
296 localx = getLocalX(x-1+j); 321 localx = getLocalX(x-1+j);
297
298 tex_z = z*(x_len-1-j)/(x_len-1) + zpos*j/(x_len-1); 322 tex_z = z*(x_len-1-j)/(x_len-1) + zpos*j/(x_len-1);
299 323
300 tex_x = tex1*(x_len-1-j)/(x_len-1) + tex2*j/(x_len-1); 324 tex_x = tex1*(x_len-1-j)/(x_len-1) + tex2*j/(x_len-1);
301 tex_y = tey1*(x_len-1-j)/(x_len-1) + tey2*j/(x_len-1); 325 tex_y = tey1*(x_len-1-j)/(x_len-1) + tey2*j/(x_len-1);
302 if (tex_x > 1) tex_x = 1; 326 if (tex_x > 1) tex_x = 1;
303 if (tex_y > 1) tex_y = 1; 327 if (tex_y > 1) tex_y = 1;
304 tex_xpos = (int)((span->tex_width-1) * tex_x); 328 tex_xpos = (int)((span->tex_width-1) * tex_x);
305 tex_ypos = (int)((span->tex_height-1) * tex_y); 329 tex_ypos = (int)((span->tex_height-1) * tex_y);
330
331 #if 0
332 if (tex_xpos != tilist->tileinfo[j%MAX_TILE_LIST].tix
333 && tex_xpos != tilist->tileinfo[j%MAX_TILE_LIST].tix) {
334 fprintf(stderr, "size = %d\n", tilist->size);
335 fprintf(stderr, "(%3d ..%3d) %d, %d %d\n",
336 x, x + x_len, js, max_x, j%MAX_TILE_LIST);
337 fprintf(stderr, "(%3d, %3d), (%3d, %3d)\n",
338 tex_xpos, tex_ypos,
339 tilist->tileinfo[j%MAX_TILE_LIST].tix,
340 tilist->tileinfo[j%MAX_TILE_LIST].tiy);
341 }
342 #endif
343
344 tex_xpos = tilist->tileinfo[j%MAX_TILE_LIST].tix;
345 tex_ypos = tilist->tileinfo[j%MAX_TILE_LIST].tiy;
346 texture_image = tilist->tileinfo[j%MAX_TILE_LIST].tile;
306 347
307 if (tex_z < zRow[localx + (rangex*localy)]) { 348 if (tex_z < zRow[localx + (rangex*localy)]) {
308 rgb = get_rgb(tex_xpos, tex_ypos, span->tex_width, 349 rgb = get_rgb(tex_xpos, tex_ypos, span->tex_width,
309 span->tex_height, texture_image); 350 span->tex_height, texture_image);
310 zRow[localx + (rangex*localy)] = tex_z; 351 zRow[localx + (rangex*localy)] = tex_z;