diff TaskManager/Test/test_render/spe/DrawSpan.cpp @ 120:a52e193f9a42

fix Load Texture
author gongo@gendarme.local
date Tue, 25 Nov 2008 00:18:49 +0900
parents 5c194c71eca8
children e92959ebceff a802b19ab9ae
line wrap: on
line diff
--- a/TaskManager/Test/test_render/spe/DrawSpan.cpp	Thu Nov 13 11:12:29 2008 +0900
+++ b/TaskManager/Test/test_render/spe/DrawSpan.cpp	Tue Nov 25 00:18:49 2008 +0900
@@ -7,9 +7,12 @@
 #include "viewer_types.h"
 
 #define SPAN_PACK_LOAD 0
+#define TEX_LOAD 1
 
 SchedDefineTask(DrawSpan);
 
+unsigned char *tex;
+
 void
 DrawSpan::linebuf_init(int *buf, int x, int rgb)
 {
@@ -38,7 +41,11 @@
 char*
 DrawSpan::get_pixel(int tx, int ty, void *texture_image)
 {
+#if 0
     return (char*)texture_image+(3*((128)*ty+tx));
+#else
+    return (char*)texture_image+(4*((8)*ty+tx));
+#endif
 }
 
 Uint32
@@ -51,8 +58,22 @@
     if (ty<0) ty = 0;
     if (128-1< ty) ty = 128-1 ;
 
+#if 0
     char *p = get_pixel(tx,ty,texture);
+#else
+    void *texture_addr;
 
+    int blockX = tx / 8;
+    int blockY = ty / 8;
+    void** addrList = (void**)global_get(TEXTURE2_ID);
+    
+    texture_addr = addrList[blockX + 16*blockY];
+    smanager->dma_load(tex, (uint32)texture_addr, sizeof(uint32)*64, TEX_LOAD);
+    smanager->dma_wait(TEX_LOAD);
+
+    char *p = get_pixel(tx%8, ty%8, tex);
+#endif
+    
     blue  = (Uint8) p[0];
     green = (Uint8) p[1];
     red   = (Uint8) p[2];
@@ -84,6 +105,8 @@
 
     int **linebuf = (int**)smanager->allocate(sizeof(int*)*rangey);
 
+    tex = (unsigned char*)smanager->allocate(sizeof(unsigned char)*64*4);
+
     for (int i = 0; i < rangey; i++) {
 	linebuf[i] = (int*)smanager->get_output(i);
 	linebuf_init(linebuf[i], rangex, 0x00ff00ff);
@@ -169,8 +192,6 @@
 	next_sp = tmp_sp;
     } while (sp);
 
-
-FINISH:
     free(free_sp);
     free(linebuf);
     free(zRow);