90
|
1 #include <stdio.h>
|
|
2 #include <spu_intrinsics.h>
|
96
|
3 #include <spu_mfcio.h>
|
98
|
4 #include <malloc.h>
|
|
5 #include "CellScheduler.h"
|
90
|
6 #include "Load_Texture.h"
|
|
7 #include "error.h"
|
|
8 #include "SchedTask.h"
|
|
9 #include "SchedTaskList.h"
|
|
10 #include "SchedNop2Ready.h"
|
|
11 #include "DmaManager.h"
|
|
12 #include "TaskManager.h"
|
96
|
13 using namespace std;
|
90
|
14
|
|
15 #define height 128
|
|
16 #define width 128
|
|
17
|
|
18
|
|
19 int
|
|
20 LoadTexture::run(void *rbuf , void *wbuf)
|
|
21 {
|
|
22 //int rgb;
|
96
|
23 __debug("[SchedTask:%s]\n", __FUNCTION__);
|
97
|
24 printf("%x\n",(int)rbuf);
|
96
|
25 printf("run\n");
|
90
|
26 }
|
|
27
|
|
28 // byteperpixel = 3 width = 128 dma_height= 32
|
|
29 #define LOAD_SIZE 3*128*32
|
96
|
30 #define MAX_LOAD_SIZE 16384
|
|
31 #define USE_ARRAY 3
|
90
|
32
|
|
33 void
|
|
34 LoadTexture::read(void)
|
|
35 {
|
|
36 __debug("[SchedTask:%s]\n", __FUNCTION__);
|
96
|
37 #if 1
|
|
38 connector->dma_load(readbuf,task->in_addr,MAX_LOAD_SIZE,DMA_READ);
|
|
39 connector->dma_load((void*)((int)readbuf + MAX_LOAD_SIZE),
|
|
40 task->in_addr + MAX_LOAD_SIZE ,MAX_LOAD_SIZE,DMA_READ + 1);
|
|
41 connector->dma_load((void*)((int)readbuf + MAX_LOAD_SIZE*2) ,
|
|
42 task->in_addr + MAX_LOAD_SIZE * 2,MAX_LOAD_SIZE,DMA_READ + 2);
|
|
43 printf("readbuf: %x\n", readbuf);
|
|
44 printf("readbuf2:%x\n", (int)readbuf + MAX_LOAD_SIZE);
|
|
45 printf("readbuf3:%x\n", (int)readbuf + MAX_LOAD_SIZE*2);
|
|
46 #else
|
|
47 mfc_list_element buf[USE_ARRAY];
|
|
48 for(int i = 0; i < USE_ARRAY; i++) {
|
|
49 buf[i].notify = 0;
|
|
50 buf[i].reserved = 0;
|
|
51 buf[i].size = MAX_LOAD_SIZE;
|
|
52 buf[i].eal = task->in_addr + i*MAX_LOAD_SIZE;
|
|
53 }
|
|
54 printf("set_load_info\n");
|
|
55 connector->dma_load(readbuf, (unsigned int)buf, MAX_LOAD_SIZE, DMA_READ);
|
|
56 printf("dma_load_finish\n");
|
90
|
57
|
96
|
58 #endif
|
90
|
59 }
|
|
60
|
|
61 void
|
|
62 LoadTexture::write(void)
|
|
63 {
|
|
64 __debug("[SchedTask:%s]\n",__FUNCTION__);
|
|
65 connector->dma_wait(DMA_WRITE);
|
|
66 }
|
|
67
|
|
68 /*
|
|
69 Uint32 Polygon::get_rgb(int tx, int ty)
|
|
70 {
|
|
71 SDL_PixelFormat *fmt;
|
|
72 Uint8 red, green, blue;
|
|
73
|
|
74 fmt = texture_image->format;
|
|
75
|
|
76 if (tx<0) tx = 0;
|
|
77 if (texture_image->w-1< tx) tx = texture_image->w-1 ;
|
|
78 if (ty<0) ty = 0;
|
|
79 if (texture_image->h-1< ty) ty = texture_image->h-1 ;
|
|
80
|
|
81
|
|
82
|
|
83 char *p = get_pixel(tx,ty,texture_image);
|
|
84 blue = (Uint8) p[0];
|
|
85 green = (Uint8) p[1];
|
|
86 red = (Uint8) p[2];
|
|
87
|
|
88
|
|
89 SDL_PixelFormat *pf;
|
|
90 pf = viewer->screen->format;
|
|
91
|
|
92 //cout << SDL_MapRGB(pf, red, green, blue) << endl;
|
|
93 return SDL_MapRGB(pf, red, green, blue);
|
|
94 }
|
|
95 */
|
|
96
|
|
97
|
|
98
|
|
99 SchedTask *
|
|
100 createTask_LoadTexture(TaskListPtr _taskList, TaskPtr _task,
|
99
|
101 void *rbuf, void *wbuf, DmaManager *dma) {
|
|
102 CellScheduler::tex = memalign(DEFAULT_ALIGNMENT, DMA_MAX_SIZE*3);
|
|
103 rbuf = CellScheduler::tex;
|
98
|
104
|
99
|
105 return new LoadTexture(_taskList, _task, rbuf, wbuf, dma);
|
90
|
106 }
|