diff TaskManager/Test/test_render/spe/DrawSpan.cpp @ 194:b56fb6ac2fc4 draft

fix
author gongo@localhost.localdomain
date Tue, 20 Jan 2009 14:50:41 +0900
parents 1ff24ca2f016
children efd7e4712342
line wrap: on
line diff
--- a/TaskManager/Test/test_render/spe/DrawSpan.cpp	Tue Jan 13 19:06:13 2009 +0900
+++ b/TaskManager/Test/test_render/spe/DrawSpan.cpp	Tue Jan 20 14:50:41 2009 +0900
@@ -1,6 +1,5 @@
 #include <stdlib.h>
 #include <string.h>
-#include <spu_mfcio.h>
 #include "DrawSpan.h"
 #include "polygon_pack.h"
 #include "texture.h"
@@ -11,6 +10,12 @@
 #define TEX_LOAD 1
 #define FB_STORE 2
 
+//#define PROFILE
+
+#if defined(PROFILE)
+#  include <spu_mfcio.h>
+#endif
+
 SchedDefineTask(DrawSpan);
 
 DrawSpan::~DrawSpan(void)
@@ -210,8 +215,6 @@
     renew_task->add_param((int)linebuf);
     renew_task->add_param((int)zRow);
 
-    //fprintf(stderr, "[%p] start %u\n", curr, spu_readch(SPU_RdDec));
-
     /**
      * 再起動したタスクを待つ
      */ 
@@ -234,6 +237,8 @@
     doneWrite = 1;
 }
 
+#define Prof(st,cur) (((st)-(cur))/79800000.0f * 1000.0f)
+
 int
 DrawSpan::run(void *rbuf, void *wbuf)
 {
@@ -261,6 +266,13 @@
 
     doneWrite = 0;
 
+    int tileNum = 0;
+    int flag = 0;
+    
+#if defined(PROFILE)
+    uint32 profile = spu_read_decrementer();
+    printf("%d %u DrawSpan start\n", smanager->get_cpuid(), profile);
+#endif
     do {
 	/**
 	 * SpanPack->next が存在する場合、
@@ -313,6 +325,7 @@
 		    continue;
 		}
 
+		flag = 1;
 		tex_xpos = (int)((span->tex_width-1) * tex1);
 		tex_ypos = (int)((span->tex_height-1) * tey1);
 
@@ -323,8 +336,17 @@
 		    tex_localy = tex_ypos % TEXTURE_SPLIT_PIXEL;
 		    
 		    if (!isAvailableTile(tex_addr)) {
+#  if defined(PROFILE)
+			printf("%d %u start load tile\n",
+			       smanager->get_cpuid(), spu_read_decrementer());
+#  endif
 			set_rgb(tex_addr);
 			smanager->dma_wait(TEX_LOAD);
+#  if defined(PROFILE)
+			printf("%d %u end load tile\n",
+			       smanager->get_cpuid(), spu_read_decrementer());
+#  endif
+			tileNum++;
 		    }
 
 		    rgb = get_rgb(tex_localx, tex_localy, tex_addr);
@@ -338,6 +360,7 @@
 		float tex_x, tex_y, tex_z;
 
 		for (int j = js; j <= je; j++) {
+		    flag = 1;
 		    localx = getLocalX(x-1+j);
 
 		    tex_z = z*(x_len-1-j)/(x_len-1) + zpos*j/(x_len-1);
@@ -363,7 +386,7 @@
 			 */
 			if (!isAvailableTile(tex_addr)) {
 			    spack->info.start = t;
-#if 1
+#if 0
 			    set_rgbs(tex_addr,
 				     getTile(span->tex_width-1, tex_ypos,
 					     span->tex_width, span->tex_addr));
@@ -371,13 +394,27 @@
 			    reboot(spack, j);
 			    goto FINISH;
 #else
+
+#  if defined(PROFILE)
+			    printf("%d %u start load tile\n",
+				   smanager->get_cpuid(), 
+				   spu_read_decrementer());
+#  endif
+
 			    set_rgb(tex_addr);
 			    smanager->dma_wait(TEX_LOAD);
+			    tileNum++;
+
+#  if defined(PROFILE)
+			    printf("%d %u end load tile\n",
+				   smanager->get_cpuid(),
+				   spu_read_decrementer());
+#  endif
 #endif
 			}
 			
 			rgb = get_rgb(tex_localx, tex_localy, tex_addr);
-		    
+
 			zRow[localx + (rangex*localy)] = tex_z;
 			linebuf[localx + (rangex*localy)] = rgb;
 		    }
@@ -405,6 +442,14 @@
      * linebuf, zRow は free() しない
      */
     free(free_spack);
+    
+#if defined(PROFILE)
+    printf("%d %u DrawSpan end\n",
+	   smanager->get_cpuid(), spu_read_decrementer());
+    if (flag) {
+	printf("%d %d tileNum\n", smanager->get_cpuid(), tileNum);
+    }
+#endif
 
     return 0;
 }