Mercurial > hg > Members > kono > Cerium
comparison TaskManager/Test/test_render/spe/DrawSpan.cpp @ 156:cd5ad7adc5e1
fix
author | gongo@gendarme.local |
---|---|
date | Thu, 04 Dec 2008 14:25:00 +0900 |
parents | 77dac07efd79 |
children | 1f4c3f3238e6 |
comparison
equal
deleted
inserted
replaced
155:77dac07efd79 | 156:cd5ad7adc5e1 |
---|---|
102 { | 102 { |
103 return (char*)texture_image+(4*((TEXTURE_SPLIT_PIXEL)*ty+tx)); | 103 return (char*)texture_image+(4*((TEXTURE_SPLIT_PIXEL)*ty+tx)); |
104 } | 104 } |
105 | 105 |
106 Uint32 | 106 Uint32 |
107 DrawSpan::get_rgb(int tx, int ty, int tw, int th, void *texture) | 107 DrawSpan::get_rgb(int tx, int ty, void *addr) |
108 { | 108 { |
109 Uint8 red, green, blue, alpha; | 109 Uint8 red, green, blue, alpha; |
110 | |
111 if (tx<0) tx = 0; | |
112 if (tw-1< tx) tx = tw-1 ; | |
113 if (ty<0) ty = 0; | |
114 if (th-1< ty) ty = th-1 ; | |
115 | |
116 void *texture_addr; | |
117 TilePtr tile; | 110 TilePtr tile; |
118 | |
119 #if 0 | |
120 int blockX = tx / TEXTURE_SPLIT_PIXEL; | |
121 int blockY = ty / TEXTURE_SPLIT_PIXEL; | |
122 void** addrList = (void**)global_get(TEXTURE2_ID); | |
123 | |
124 texture_addr = addrList[blockX + (tw/TEXTURE_SPLIT_PIXEL)*blockY]; | |
125 #else | |
126 texture_addr = texture; | |
127 #endif | |
128 | 111 |
129 /** | 112 /** |
130 * get,put はオブジェクト(Hashとか?)を作ってアクセスするかな | 113 * get,put はオブジェクト(Hashとか?)を作ってアクセスするかな |
131 */ | 114 */ |
132 tile = get(texture_addr); | 115 tile = get(addr); |
133 if (tile == NULL) { | 116 if (tile == NULL) { |
134 if (tileList->size >= MAX_TILE) { | 117 if (tileList->size >= MAX_TILE) { |
135 tileList->init(); | 118 tileList->init(); |
136 bzero(hash_table, sizeof(TilePtr)*hashsize); | 119 bzero(hash_table, sizeof(TilePtr)*hashsize); |
137 } | 120 } |
138 | 121 |
139 tile = &tileList->tile[tileList->size]; | 122 tile = &tileList->tile[tileList->size]; |
140 tile->texture_addr = texture_addr; | 123 tile->texture_addr = addr; |
141 | 124 |
142 smanager->dma_load(tile->pixel, (uint32)texture_addr, | 125 smanager->dma_load(tile->pixel, (uint32)addr, |
143 sizeof(uint32)*64, TEX_LOAD); | 126 sizeof(uint32)*64, TEX_LOAD); |
144 | 127 |
145 int index = put(tile->texture_addr, tile); | 128 int index = put(tile->texture_addr, tile); |
146 | 129 |
147 /** | 130 /** |
157 tileList->size++; | 140 tileList->size++; |
158 | 141 |
159 smanager->dma_wait(TEX_LOAD); | 142 smanager->dma_wait(TEX_LOAD); |
160 } | 143 } |
161 | 144 |
162 char *p = get_pixel(tx%TEXTURE_SPLIT_PIXEL, | 145 char *p = get_pixel(tx, ty, tile->pixel); |
163 ty%TEXTURE_SPLIT_PIXEL, tile->pixel); | |
164 | 146 |
165 alpha = 255; | 147 alpha = 255; |
166 red = (Uint8) p[0]; | 148 red = (Uint8) p[0]; |
167 green = (Uint8) p[1]; | 149 green = (Uint8) p[1]; |
168 blue = (Uint8) p[2]; | 150 blue = (Uint8) p[2]; |
252 if (x_len == 1) { | 234 if (x_len == 1) { |
253 if (x < rangex_start || rangex_end < x) { | 235 if (x < rangex_start || rangex_end < x) { |
254 continue; | 236 continue; |
255 } | 237 } |
256 | 238 |
239 #if 1 | |
240 tex_xpos = tilist->tileinfo[0].tix; | |
241 tex_ypos = tilist->tileinfo[0].tiy; | |
242 texture_image = tilist->tileinfo[0].tile; | |
243 #else | |
257 tex_xpos = (int)((span->tex_width-1) * tex1); | 244 tex_xpos = (int)((span->tex_width-1) * tex1); |
258 tex_ypos = (int)((span->tex_height-1) * tey1); | 245 tex_ypos = (int)((span->tex_height-1) * tey1); |
259 tex_zpos = (int)z; | 246 tex_zpos = (int)z; |
260 | 247 #endif |
261 #if 1 | 248 |
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 | |
274 if (zpos < zRow[localx + (rangex * localy)]) { | 249 if (zpos < zRow[localx + (rangex * localy)]) { |
275 rgb = get_rgb(tex_xpos, tex_ypos, span->tex_width, | 250 rgb = get_rgb(tex_xpos, tex_ypos, texture_image); |
276 span->tex_height, texture_image); | |
277 zRow[localx + (rangex * localy)] = zpos; | 251 zRow[localx + (rangex * localy)] = zpos; |
278 linebuf[localy][localx] = rgb; | 252 linebuf[localy][localx] = rgb; |
279 } | 253 } |
280 } else { | 254 } else { |
281 int js = (x < rangex_start) ? rangex_start - x : 0; | 255 int js = (x < rangex_start) ? rangex_start - x : 0; |
328 } | 302 } |
329 | 303 |
330 float tex_x, tex_y, tex_z; | 304 float tex_x, tex_y, tex_z; |
331 | 305 |
332 for (int j = cur_x; j <= cur_x + len; j++) { | 306 for (int j = cur_x; j <= cur_x + len; j++) { |
307 TileInfoPtr tinfo = &tilist->tileinfo[j%MAX_TILE_LIST]; | |
333 localx = getLocalX(x-1+j); | 308 localx = getLocalX(x-1+j); |
334 tex_z = z*(x_len-1-j)/(x_len-1) + zpos*j/(x_len-1); | 309 tex_z = z*(x_len-1-j)/(x_len-1) + zpos*j/(x_len-1); |
335 | 310 |
311 #if 1 | |
312 tex_xpos = tinfo->tix; | |
313 tex_ypos = tinfo->tiy; | |
314 texture_image = tinfo->tile; | |
315 #else | |
336 tex_x = tex1*(x_len-1-j)/(x_len-1) + tex2*j/(x_len-1); | 316 tex_x = tex1*(x_len-1-j)/(x_len-1) + tex2*j/(x_len-1); |
337 tex_y = tey1*(x_len-1-j)/(x_len-1) + tey2*j/(x_len-1); | 317 tex_y = tey1*(x_len-1-j)/(x_len-1) + tey2*j/(x_len-1); |
338 if (tex_x > 1) tex_x = 1; | 318 if (tex_x > 1) tex_x = 1; |
339 if (tex_y > 1) tex_y = 1; | 319 if (tex_y > 1) tex_y = 1; |
340 tex_xpos = (int)((span->tex_width-1) * tex_x); | 320 tex_xpos = (int)((span->tex_width-1) * tex_x); |
341 tex_ypos = (int)((span->tex_height-1) * tex_y); | 321 tex_ypos = (int)((span->tex_height-1) * tex_y); |
342 | 322 #endif |
343 if (tex_xpos != tilist->tileinfo[j%MAX_TILE_LIST].tix | 323 |
344 && tex_xpos != tilist->tileinfo[j%MAX_TILE_LIST].tix) { | |
345 fprintf(stderr, "size = %d\n", tilist->size); | |
346 fprintf(stderr, "(%3d ..%3d) %d, %d %d\n", | |
347 x, x + x_len, js, max_x, j%MAX_TILE_LIST); | |
348 fprintf(stderr, "(%3d, %3d), (%3d, %3d)\n", | |
349 tex_xpos, tex_ypos, | |
350 tilist->tileinfo[j%MAX_TILE_LIST].tix, | |
351 tilist->tileinfo[j%MAX_TILE_LIST].tiy); | |
352 } | |
353 | |
354 tex_xpos = tilist->tileinfo[j%MAX_TILE_LIST].tix; | |
355 tex_ypos = tilist->tileinfo[j%MAX_TILE_LIST].tiy; | |
356 texture_image = tilist->tileinfo[j%MAX_TILE_LIST].tile; | |
357 | |
358 if (tex_z < zRow[localx + (rangex*localy)]) { | 324 if (tex_z < zRow[localx + (rangex*localy)]) { |
359 rgb = get_rgb(tex_xpos, tex_ypos, span->tex_width, | 325 rgb = get_rgb(tex_xpos, tex_ypos, texture_image); |
360 span->tex_height, texture_image); | |
361 zRow[localx + (rangex*localy)] = tex_z; | 326 zRow[localx + (rangex*localy)] = tex_z; |
362 linebuf[localy][localx] = rgb; | 327 linebuf[localy][localx] = rgb; |
363 } | 328 } |
364 } | 329 } |
365 | 330 |