diff TaskManager/Test/test_render/spe/DrawSpan.cpp @ 147:3ecf43bd1a35

fix
author gongo@charles.cr.ie.u-ryukyu.ac.jp
date Tue, 02 Dec 2008 15:47:25 +0900
parents 435e0d24db39
children 9642aeef298d
line wrap: on
line diff
--- a/TaskManager/Test/test_render/spe/DrawSpan.cpp	Tue Dec 02 14:12:01 2008 +0900
+++ b/TaskManager/Test/test_render/spe/DrawSpan.cpp	Tue Dec 02 15:47:25 2008 +0900
@@ -8,6 +8,7 @@
 
 #define SPAN_PACK_LOAD 0
 #define TEX_LOAD 1
+#define TILE_INFO_LOAD 2
 
 SchedDefineTask(DrawSpan);
 
@@ -176,6 +177,14 @@
     SpanPack *tmp_sp = NULL;
     Span *span;
 
+    TileInfoListPtr tilist =
+	(TileInfoListPtr)smanager->allocate(sizeof(TileInfoList));
+    TileInfoListPtr next_tilist =
+	(TileInfoListPtr)smanager->allocate(sizeof(TileInfoList));
+    TileInfoListPtr tmp_tilist = NULL;
+    TileInfoPtr tinfo;
+
+
     tileList = (TileListPtr)smanager->allocate(sizeof(TileList));
     tileList->init();
 
@@ -214,6 +223,9 @@
 	for (int t = 0; t < sp->info.size; t++) {	  
 	    span = &sp->span[t];
 
+	    smanager->dma_load(tilist, (uint32)span->tilelist,
+			       sizeof(TileInfoList), TILE_INFO_LOAD);
+
 	    Uint32 rgb = 0x00ff00;
 	    float tex1 = span->tex_x1;
 	    float tex2 = span->tex_x2;
@@ -232,6 +244,8 @@
 	    int localx = getLocalX(x-1);
 	    int localy = getLocalY(y-1);
 
+	    smanager->dma_wait(TILE_INFO_LOAD);
+
 	    if (x_len == 1) {
 		if (x < rangex_start || rangex_end < x) {
 		    continue;
@@ -247,32 +261,68 @@
 		    linebuf[localy][localx] = rgb;
 		}
 	    } else {
-		float tex_x, tex_y, tex_z;
 		int js = (x < rangex_start) ? rangex_start - x : 0;
 		int je = (x + x_len > rangex_end) ? rangex_end - x : x_len;
 
-		for (int j = js; j <= je; j++) {
-		    localx = getLocalX(x-1+j);
+		if (js > je) continue;
+
+		int cur_x = 0;
+		int max_x = je;
+		int len;
 
-		    tex_z = z*(x_len-1-j)/(x_len-1) + zpos*j/(x_len-1);
+		while (cur_x + MAX_TILE_LIST < js) {
+		    smanager->dma_wait(TILE_INFO_LOAD);
+		    smanager->dma_load(tilist, (uint32)tilist->next,
+				       sizeof(TileInfoList), TILE_INFO_LOAD);
+		    cur_x += MAX_TILE_LIST;
+		}
+
+		cur_x = js;
 
-		    tex_x = tex1*(x_len-1-j)/(x_len-1) + tex2*j/(x_len-1);
-		    tex_y = tey1*(x_len-1-j)/(x_len-1) + tey2*j/(x_len-1);
-		    if (tex_x > 1) tex_x = 1;
-		    if (tex_y > 1) tex_y = 1;
-		    tex_xpos = (int)((span->tex_width-1) * tex_x);
-		    tex_ypos = (int)((span->tex_height-1) * tex_y);
-
-		    if (tex_z < zRow[localx + (rangex*localy)]) {
-			rgb = get_rgb(tex_xpos, tex_ypos, span->tex_width,
-				      span->tex_height, texture_image);
-			zRow[localx + (rangex*localy)] = tex_z;
-			linebuf[localy][localx] = rgb;
+		while (cur_x < max_x) {
+		    smanager->dma_wait(TILE_INFO_LOAD);
+		    
+		    if (cur_x + MAX_TILE_LIST < max_x) {
+			smanager->dma_load(next_tilist, (uint32)tilist->next,
+					   sizeof(TileInfoList), TILE_INFO_LOAD);
+			len = MAX_TILE_LIST;
+		    } else {
+			len = max_x - cur_x;
 		    }
+		    
+		    float tex_x, tex_y, tex_z;
+		    
+		    for (int j = cur_x; j <= cur_x + len; j++) {
+			localx = getLocalX(x-1+j);
+			
+			tex_z = z*(x_len-1-j)/(x_len-1) + zpos*j/(x_len-1);
+			
+			tex_x = tex1*(x_len-1-j)/(x_len-1) + tex2*j/(x_len-1);
+			tex_y = tey1*(x_len-1-j)/(x_len-1) + tey2*j/(x_len-1);
+			if (tex_x > 1) tex_x = 1;
+			if (tex_y > 1) tex_y = 1;
+			tex_xpos = (int)((span->tex_width-1) * tex_x);
+			tex_ypos = (int)((span->tex_height-1) * tex_y);
+			
+			if (tex_z < zRow[localx + (rangex*localy)]) {
+			    rgb = get_rgb(tex_xpos, tex_ypos, span->tex_width,
+					  span->tex_height, texture_image);
+			    zRow[localx + (rangex*localy)] = tex_z;
+			    linebuf[localy][localx] = rgb;
+			}
+		    }
+		    
+		    smanager->dma_wait(TILE_INFO_LOAD);
+		    
+		    TileInfoListPtr tmp = tilist;
+		    tilist = next_tilist;
+		    next_tilist = tmp;
+		    
+		    cur_x += MAX_TILE_LIST;
 		}
 	    }
 	}
- 
+
 	smanager->dma_wait(SPAN_PACK_LOAD);
 
 	tmp_sp = sp;
@@ -284,6 +334,8 @@
     free(linebuf);
     free(zRow);
     free(tileList);
+    free(tilist);
+    free(next_tilist);
 
     return 0;
 }