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