annotate TaskManager/Test/test_render/spe/DrawSpan.cpp @ 203:1eba8570808c draft

fix CreateSpan::run
author gongo@localhost.localdomain
date Mon, 26 Jan 2009 18:30:35 +0900
parents efd7e4712342
children de235e3ef9d3
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
109
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
1 #include <stdlib.h>
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
2 #include <string.h>
200
efd7e4712342 fix run_draw
gongo@localhost.localdomain
parents: 194
diff changeset
3 #include <spu_intrinsics.h>
109
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
4 #include "DrawSpan.h"
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
5 #include "polygon_pack.h"
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
6 #include "texture.h"
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
7 #include "viewer_types.h"
184
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 182
diff changeset
8 #include "Func.h"
109
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
9
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
10 #define SPAN_PACK_LOAD 0
120
13b43de5ef5d fix Load Texture
gongo@gendarme.local
parents: 109
diff changeset
11 #define TEX_LOAD 1
193
gongo@localhost.localdomain
parents: 192
diff changeset
12 #define FB_STORE 2
109
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
13
194
gongo@localhost.localdomain
parents: 193
diff changeset
14 //#define PROFILE
gongo@localhost.localdomain
parents: 193
diff changeset
15
gongo@localhost.localdomain
parents: 193
diff changeset
16 #if defined(PROFILE)
gongo@localhost.localdomain
parents: 193
diff changeset
17 # include <spu_mfcio.h>
gongo@localhost.localdomain
parents: 193
diff changeset
18 #endif
gongo@localhost.localdomain
parents: 193
diff changeset
19
109
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
20 SchedDefineTask(DrawSpan);
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
21
193
gongo@localhost.localdomain
parents: 192
diff changeset
22 DrawSpan::~DrawSpan(void)
gongo@localhost.localdomain
parents: 192
diff changeset
23 {
gongo@localhost.localdomain
parents: 192
diff changeset
24 smanager->dma_wait(FB_STORE);
gongo@localhost.localdomain
parents: 192
diff changeset
25 free((void*)((int)linebuf*doneWrite));
gongo@localhost.localdomain
parents: 192
diff changeset
26 }
gongo@localhost.localdomain
parents: 192
diff changeset
27
164
dc7d10ae7460 TilePtr は SPE で計算した方がいいと判断して変更。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 161
diff changeset
28 /**
193
gongo@localhost.localdomain
parents: 192
diff changeset
29 * テクスチャは、TEXTURE_SPLIT_PIXEL^2 のブロックに分割する
164
dc7d10ae7460 TilePtr は SPE で計算した方がいいと判断して変更。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 161
diff changeset
30 *
dc7d10ae7460 TilePtr は SPE で計算した方がいいと判断して変更。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 161
diff changeset
31 * +---+---+---+---+---+---+
dc7d10ae7460 TilePtr は SPE で計算した方がいいと判断して変更。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 161
diff changeset
32 * | 0 | 1 | 2 | 3 | 4 | 5 |
dc7d10ae7460 TilePtr は SPE で計算した方がいいと判断して変更。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 161
diff changeset
33 * +---+---+---+---+---+---+
dc7d10ae7460 TilePtr は SPE で計算した方がいいと判断して変更。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 161
diff changeset
34 * | | | | | |11 |
dc7d10ae7460 TilePtr は SPE で計算した方がいいと判断して変更。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 161
diff changeset
35 * +---+---+---+---+---+---+
dc7d10ae7460 TilePtr は SPE で計算した方がいいと判断して変更。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 161
diff changeset
36 * | | | | | |17 |
dc7d10ae7460 TilePtr は SPE で計算した方がいいと判断して変更。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 161
diff changeset
37 * +---+---+---+---+---+---+
dc7d10ae7460 TilePtr は SPE で計算した方がいいと判断して変更。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 161
diff changeset
38 * | | | | | |23 |
dc7d10ae7460 TilePtr は SPE で計算した方がいいと判断して変更。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 161
diff changeset
39 * +---+---+---+---+---+---+
dc7d10ae7460 TilePtr は SPE で計算した方がいいと判断して変更。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 161
diff changeset
40 * | | | | | |29 |
dc7d10ae7460 TilePtr は SPE で計算した方がいいと判断して変更。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 161
diff changeset
41 * +---+---+---+---+---+---+
dc7d10ae7460 TilePtr は SPE で計算した方がいいと判断して変更。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 161
diff changeset
42 * | | | | | |35 |
dc7d10ae7460 TilePtr は SPE で計算した方がいいと判断して変更。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 161
diff changeset
43 * +---+---+---+---+---+---+
dc7d10ae7460 TilePtr は SPE で計算した方がいいと判断して変更。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 161
diff changeset
44 *
193
gongo@localhost.localdomain
parents: 192
diff changeset
45 * 一辺を TEXTURE_SPLIT とする
gongo@localhost.localdomain
parents: 192
diff changeset
46 * 各ブロックの数字がブロックIDとなる。
164
dc7d10ae7460 TilePtr は SPE で計算した方がいいと判断して変更。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 161
diff changeset
47 */
dc7d10ae7460 TilePtr は SPE で計算した方がいいと判断して変更。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 161
diff changeset
48
dc7d10ae7460 TilePtr は SPE で計算した方がいいと判断して変更。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 161
diff changeset
49 /**
193
gongo@localhost.localdomain
parents: 192
diff changeset
50 * テクスチャの座標から、
gongo@localhost.localdomain
parents: 192
diff changeset
51 * テクスチャのどのブロックかを求める
164
dc7d10ae7460 TilePtr は SPE で計算した方がいいと判断して変更。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 161
diff changeset
52 *
dc7d10ae7460 TilePtr は SPE で計算した方がいいと判断して変更。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 161
diff changeset
53 * @param[in] tx X coordinates of texture
dc7d10ae7460 TilePtr は SPE で計算した方がいいと判断して変更。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 161
diff changeset
54 * @param[in] tx Y coordinates of texture
dc7d10ae7460 TilePtr は SPE で計算した方がいいと判断して変更。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 161
diff changeset
55 * @param[in] twidth Width of texture
dc7d10ae7460 TilePtr は SPE で計算した方がいいと判断して変更。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 161
diff changeset
56 * @return block ID
dc7d10ae7460 TilePtr は SPE で計算した方がいいと判断して変更。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 161
diff changeset
57 */
184
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 182
diff changeset
58 int
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 182
diff changeset
59 DrawSpan::getTexBlock(int tx, int ty, int twidth)
164
dc7d10ae7460 TilePtr は SPE で計算した方がいいと判断して変更。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 161
diff changeset
60 {
dc7d10ae7460 TilePtr は SPE で計算した方がいいと判断して変更。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 161
diff changeset
61 int blockX, blockY;
dc7d10ae7460 TilePtr は SPE で計算した方がいいと判断して変更。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 161
diff changeset
62
dc7d10ae7460 TilePtr は SPE で計算した方がいいと判断して変更。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 161
diff changeset
63 blockX = tx / TEXTURE_SPLIT_PIXEL;
dc7d10ae7460 TilePtr は SPE で計算した方がいいと判断して変更。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 161
diff changeset
64 blockY = ty / TEXTURE_SPLIT_PIXEL;
dc7d10ae7460 TilePtr は SPE で計算した方がいいと判断して変更。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 161
diff changeset
65
dc7d10ae7460 TilePtr は SPE で計算した方がいいと判断して変更。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 161
diff changeset
66 return blockX + (twidth/TEXTURE_SPLIT_PIXEL)*blockY;
dc7d10ae7460 TilePtr は SPE で計算した方がいいと判断して変更。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 161
diff changeset
67 }
dc7d10ae7460 TilePtr は SPE で計算した方がいいと判断して変更。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 161
diff changeset
68
dc7d10ae7460 TilePtr は SPE で計算した方がいいと判断して変更。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 161
diff changeset
69 /**
193
gongo@localhost.localdomain
parents: 192
diff changeset
70 * block ID と、テクスチャの TOP address から
gongo@localhost.localdomain
parents: 192
diff changeset
71 * (tx,ty) で使われるテクスチャの Tile addres を求める
164
dc7d10ae7460 TilePtr は SPE で計算した方がいいと判断して変更。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 161
diff changeset
72 *
dc7d10ae7460 TilePtr は SPE で計算した方がいいと判断して変更。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 161
diff changeset
73 * @param[in] tx X coordinates of texture
dc7d10ae7460 TilePtr は SPE で計算した方がいいと判断して変更。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 161
diff changeset
74 * @param[in] tx Y coordinates of texture
dc7d10ae7460 TilePtr は SPE で計算した方がいいと判断して変更。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 161
diff changeset
75 * @param[in] tw Width of texture
193
gongo@localhost.localdomain
parents: 192
diff changeset
76 * @param[in] tex_addr_top (tx,ty) で使うテクスチャの先頭address
164
dc7d10ae7460 TilePtr は SPE で計算した方がいいと判断して変更。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 161
diff changeset
77 * @return block ID
dc7d10ae7460 TilePtr は SPE で計算した方がいいと判断して変更。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 161
diff changeset
78 */
184
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 182
diff changeset
79 uint32*
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 182
diff changeset
80 DrawSpan::getTile(int tx, int ty, int tw, uint32 *tex_addr_top)
164
dc7d10ae7460 TilePtr は SPE で計算した方がいいと判断して変更。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 161
diff changeset
81 {
184
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 182
diff changeset
82 int block = getTexBlock(tx, ty, tw);
164
dc7d10ae7460 TilePtr は SPE で計算した方がいいと判断して変更。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 161
diff changeset
83 return tex_addr_top + block*TEXTURE_BLOCK_SIZE;
dc7d10ae7460 TilePtr は SPE で計算した方がいいと判断して変更。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 161
diff changeset
84 }
dc7d10ae7460 TilePtr は SPE で計算した方がいいと判断して変更。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 161
diff changeset
85
193
gongo@localhost.localdomain
parents: 192
diff changeset
86 /**
gongo@localhost.localdomain
parents: 192
diff changeset
87 * FrameBuffer に書き込む rgb の領域初期化
gongo@localhost.localdomain
parents: 192
diff changeset
88 *
gongo@localhost.localdomain
parents: 192
diff changeset
89 * @param width Width of Buffer
gongo@localhost.localdomain
parents: 192
diff changeset
90 * @param height Height of Buffer
gongo@localhost.localdomain
parents: 192
diff changeset
91 * @param rgb Initial value of RGB at Buffer
gongo@localhost.localdomain
parents: 192
diff changeset
92 * @return Buffer
gongo@localhost.localdomain
parents: 192
diff changeset
93 */
gongo@localhost.localdomain
parents: 192
diff changeset
94 int*
gongo@localhost.localdomain
parents: 192
diff changeset
95 DrawSpan::linebuf_init(int width, int height, int rgb)
109
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
96 {
193
gongo@localhost.localdomain
parents: 192
diff changeset
97 int *buf = (int*)smanager->allocate(sizeof(int)*width*height);
gongo@localhost.localdomain
parents: 192
diff changeset
98
gongo@localhost.localdomain
parents: 192
diff changeset
99 for (int i = 0; i < width*height; i++) {
109
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
100 buf[i] = rgb;
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
101 }
193
gongo@localhost.localdomain
parents: 192
diff changeset
102
gongo@localhost.localdomain
parents: 192
diff changeset
103 return buf;
109
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
104 }
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
105
184
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 182
diff changeset
106 /**
193
gongo@localhost.localdomain
parents: 192
diff changeset
107 * Z-Buffer の初期化
184
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 182
diff changeset
108 *
193
gongo@localhost.localdomain
parents: 192
diff changeset
109 * @param width Width of Z-Buffer
gongo@localhost.localdomain
parents: 192
diff changeset
110 * @param height Height of Z-Buffer
gongo@localhost.localdomain
parents: 192
diff changeset
111 * @return Z-Buffer
gongo@localhost.localdomain
parents: 192
diff changeset
112 */
gongo@localhost.localdomain
parents: 192
diff changeset
113 float*
gongo@localhost.localdomain
parents: 192
diff changeset
114 DrawSpan::zRow_init(int width, int height)
gongo@localhost.localdomain
parents: 192
diff changeset
115 {
gongo@localhost.localdomain
parents: 192
diff changeset
116 float *buf = (float*)smanager->allocate(sizeof(float)*width*height);
gongo@localhost.localdomain
parents: 192
diff changeset
117 float def = 65535.0f;
gongo@localhost.localdomain
parents: 192
diff changeset
118
200
efd7e4712342 fix run_draw
gongo@localhost.localdomain
parents: 194
diff changeset
119 #if 1
193
gongo@localhost.localdomain
parents: 192
diff changeset
120 for (int i = 0; i < width*height; i++) {
gongo@localhost.localdomain
parents: 192
diff changeset
121 buf[i] = def;
gongo@localhost.localdomain
parents: 192
diff changeset
122 }
200
efd7e4712342 fix run_draw
gongo@localhost.localdomain
parents: 194
diff changeset
123 #else
efd7e4712342 fix run_draw
gongo@localhost.localdomain
parents: 194
diff changeset
124 vector float init = {0.0f, 0.0f, 0.0f, 0.0f};
efd7e4712342 fix run_draw
gongo@localhost.localdomain
parents: 194
diff changeset
125 vector float defi = {def, def, def, def};
efd7e4712342 fix run_draw
gongo@localhost.localdomain
parents: 194
diff changeset
126
efd7e4712342 fix run_draw
gongo@localhost.localdomain
parents: 194
diff changeset
127 for (int i = 0; i < width*height; i += 4) {
efd7e4712342 fix run_draw
gongo@localhost.localdomain
parents: 194
diff changeset
128 vector float *out = (vector float *)&buf[i];
efd7e4712342 fix run_draw
gongo@localhost.localdomain
parents: 194
diff changeset
129
efd7e4712342 fix run_draw
gongo@localhost.localdomain
parents: 194
diff changeset
130 *out = spu_add(init, defi);
efd7e4712342 fix run_draw
gongo@localhost.localdomain
parents: 194
diff changeset
131 }
efd7e4712342 fix run_draw
gongo@localhost.localdomain
parents: 194
diff changeset
132 #endif
193
gongo@localhost.localdomain
parents: 192
diff changeset
133
gongo@localhost.localdomain
parents: 192
diff changeset
134 return buf;
gongo@localhost.localdomain
parents: 192
diff changeset
135 }
gongo@localhost.localdomain
parents: 192
diff changeset
136
gongo@localhost.localdomain
parents: 192
diff changeset
137
gongo@localhost.localdomain
parents: 192
diff changeset
138 /**
gongo@localhost.localdomain
parents: 192
diff changeset
139 * Span が使う Texture Tile があるか
gongo@localhost.localdomain
parents: 192
diff changeset
140 *
gongo@localhost.localdomain
parents: 192
diff changeset
141 * @retval != NULL 存在する
gongo@localhost.localdomain
parents: 192
diff changeset
142 * @retval NULL 存在しない
184
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 182
diff changeset
143 */
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 182
diff changeset
144 TilePtr
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 182
diff changeset
145 DrawSpan::isAvailableTile(uint32 *addr)
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 182
diff changeset
146 {
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 182
diff changeset
147 return hash->get(addr);
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 182
diff changeset
148 }
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 182
diff changeset
149
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 182
diff changeset
150 void
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 182
diff changeset
151 DrawSpan::set_rgb(uint32 *addr)
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 182
diff changeset
152 {
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 182
diff changeset
153 TilePtr tile;
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 182
diff changeset
154
193
gongo@localhost.localdomain
parents: 192
diff changeset
155 tile = tileList->nextTile();
gongo@localhost.localdomain
parents: 192
diff changeset
156 /**
gongo@localhost.localdomain
parents: 192
diff changeset
157 * FIFO なので、もし前のが残っていれば削除
gongo@localhost.localdomain
parents: 192
diff changeset
158 */
gongo@localhost.localdomain
parents: 192
diff changeset
159 hash->remove(tile->texture_addr);
gongo@localhost.localdomain
parents: 192
diff changeset
160
gongo@localhost.localdomain
parents: 192
diff changeset
161 tile->texture_addr = addr;
gongo@localhost.localdomain
parents: 192
diff changeset
162
gongo@localhost.localdomain
parents: 192
diff changeset
163 hash->put(tile->texture_addr, tile);
gongo@localhost.localdomain
parents: 192
diff changeset
164
gongo@localhost.localdomain
parents: 192
diff changeset
165 smanager->dma_load(tile->pixel, (uint32)addr,
gongo@localhost.localdomain
parents: 192
diff changeset
166 sizeof(uint32)*TEXTURE_BLOCK_SIZE, TEX_LOAD);
184
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 182
diff changeset
167 }
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 182
diff changeset
168
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 182
diff changeset
169 void
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 182
diff changeset
170 DrawSpan::set_rgbs(uint32 *addr, uint32 *max_addr)
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 182
diff changeset
171 {
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 182
diff changeset
172 uint32 start = (uint32)addr;
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 182
diff changeset
173 uint32 end = (uint32)max_addr;
193
gongo@localhost.localdomain
parents: 192
diff changeset
174 int length = (int)end-start;
gongo@localhost.localdomain
parents: 192
diff changeset
175 int diff = sizeof(int)*TEXTURE_BLOCK_SIZE;
gongo@localhost.localdomain
parents: 192
diff changeset
176 int max_tile = 16;
gongo@localhost.localdomain
parents: 192
diff changeset
177
gongo@localhost.localdomain
parents: 192
diff changeset
178 for (int i = 0, j = 0; i <= length && j < max_tile; i += diff, j++) {
184
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 182
diff changeset
179 set_rgb((uint32*)(start + i));
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 182
diff changeset
180 }
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 182
diff changeset
181 }
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 182
diff changeset
182
193
gongo@localhost.localdomain
parents: 192
diff changeset
183 uint32
166
gongo@localhost.localdomain
parents: 165
diff changeset
184 DrawSpan::get_rgb(int tx, int ty, uint32 *addr)
109
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
185 {
148
74341c8bf935 Span への Texture List の渡し。じゃっかん texture がバグってるので
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents: 147
diff changeset
186 TilePtr tile;
109
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
187
167
508beb59e0eb DrawSpan で使う Tile の Hash の扱いは class TileHash を生成する事に。
gongo@localhost.localdomain
parents: 166
diff changeset
188 tile = hash->get(addr);
168
f533a4104d41 Delete DrawSpan::get_pixel().
gongo@localhost.localdomain
parents: 167
diff changeset
189 return tile->pixel[(TEXTURE_SPLIT_PIXEL)*ty+tx];
109
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
190 }
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
191
184
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 182
diff changeset
192 /**
193
gongo@localhost.localdomain
parents: 192
diff changeset
193 * DrawSpan の再起動 (DrawSpanRenew 生成)
184
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 182
diff changeset
194 *
193
gongo@localhost.localdomain
parents: 192
diff changeset
195 * @param[in] spack 現在処理している SpanPack
gongo@localhost.localdomain
parents: 192
diff changeset
196 * @param[in] cur_span_x span->length_x != 1 の時の Span の処理で
gongo@localhost.localdomain
parents: 192
diff changeset
197 * どこまで進んでいるか
184
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 182
diff changeset
198 */
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 182
diff changeset
199 void
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 182
diff changeset
200 DrawSpan::reboot(SpanPackPtr spack, int cur_span_x)
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 182
diff changeset
201 {
193
gongo@localhost.localdomain
parents: 192
diff changeset
202 DrawSpanArgPtr args =
gongo@localhost.localdomain
parents: 192
diff changeset
203 (DrawSpanArgPtr)smanager->allocate(sizeof(DrawSpanArg));
184
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 182
diff changeset
204 TaskPtr renew_task = smanager->create_task(TASK_DRAW_SPAN2);
193
gongo@localhost.localdomain
parents: 192
diff changeset
205
gongo@localhost.localdomain
parents: 192
diff changeset
206 // 数が多いので構造体で渡す
gongo@localhost.localdomain
parents: 192
diff changeset
207 args->display = smanager->get_param(0);
gongo@localhost.localdomain
parents: 192
diff changeset
208 args->screen_width = smanager->get_param(1);
gongo@localhost.localdomain
parents: 192
diff changeset
209 args->rangex_start = smanager->get_param(2);
gongo@localhost.localdomain
parents: 192
diff changeset
210 args->rangex_end = smanager->get_param(3);
gongo@localhost.localdomain
parents: 192
diff changeset
211 args->rangey = smanager->get_param(4);
gongo@localhost.localdomain
parents: 192
diff changeset
212 renew_task->add_param((int)args);
164
dc7d10ae7460 TilePtr は SPE で計算した方がいいと判断して変更。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 161
diff changeset
213
184
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 182
diff changeset
214 /**
193
gongo@localhost.localdomain
parents: 192
diff changeset
215 * SpanPack は続きから開始するので、
gongo@localhost.localdomain
parents: 192
diff changeset
216 * 現在の状態をコピーしておく。
gongo@localhost.localdomain
parents: 192
diff changeset
217 * spack は rbuf から取得してる可能性があり
gongo@localhost.localdomain
parents: 192
diff changeset
218 * rbuf はシステムが自動的に free() するため
gongo@localhost.localdomain
parents: 192
diff changeset
219 * アドレスだけ渡すのはNG
184
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 182
diff changeset
220 */
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 182
diff changeset
221 SpanPackPtr curr = (SpanPackPtr)smanager->allocate(sizeof(SpanPack));
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 182
diff changeset
222 memcpy(curr, spack, sizeof(SpanPack));
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 182
diff changeset
223 renew_task->add_param((int)curr);
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 182
diff changeset
224 renew_task->add_param(cur_span_x);
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 182
diff changeset
225
193
gongo@localhost.localdomain
parents: 192
diff changeset
226 // linebuf と zRow も引き継がせる
gongo@localhost.localdomain
parents: 192
diff changeset
227 renew_task->add_param((int)linebuf);
gongo@localhost.localdomain
parents: 192
diff changeset
228 renew_task->add_param((int)zRow);
gongo@localhost.localdomain
parents: 192
diff changeset
229
184
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 182
diff changeset
230 /**
193
gongo@localhost.localdomain
parents: 192
diff changeset
231 * 再起動したタスクを待つ
184
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 182
diff changeset
232 */
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 182
diff changeset
233 smanager->wait_task(renew_task);
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 182
diff changeset
234
193
gongo@localhost.localdomain
parents: 192
diff changeset
235 // next_spack は free() するので wait する
184
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 182
diff changeset
236 smanager->dma_wait(SPAN_PACK_LOAD);
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 182
diff changeset
237 }
164
dc7d10ae7460 TilePtr は SPE で計算した方がいいと判断して変更。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 161
diff changeset
238
193
gongo@localhost.localdomain
parents: 192
diff changeset
239 void
gongo@localhost.localdomain
parents: 192
diff changeset
240 DrawSpan::writebuffer(unsigned int display, int buf_width, int height,
gongo@localhost.localdomain
parents: 192
diff changeset
241 int screen_width)
gongo@localhost.localdomain
parents: 192
diff changeset
242 {
gongo@localhost.localdomain
parents: 192
diff changeset
243 for (int i = 0; i < height; i++) {
gongo@localhost.localdomain
parents: 192
diff changeset
244 smanager->dma_store(&linebuf[i*buf_width],
gongo@localhost.localdomain
parents: 192
diff changeset
245 display + (sizeof(int)*screen_width*i),
gongo@localhost.localdomain
parents: 192
diff changeset
246 sizeof(int)*buf_width, FB_STORE);
gongo@localhost.localdomain
parents: 192
diff changeset
247 }
gongo@localhost.localdomain
parents: 192
diff changeset
248
gongo@localhost.localdomain
parents: 192
diff changeset
249 doneWrite = 1;
gongo@localhost.localdomain
parents: 192
diff changeset
250 }
gongo@localhost.localdomain
parents: 192
diff changeset
251
194
gongo@localhost.localdomain
parents: 193
diff changeset
252 #define Prof(st,cur) (((st)-(cur))/79800000.0f * 1000.0f)
gongo@localhost.localdomain
parents: 193
diff changeset
253
109
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
254 int
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
255 DrawSpan::run(void *rbuf, void *wbuf)
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
256 {
193
gongo@localhost.localdomain
parents: 192
diff changeset
257 SpanPackPtr spack = (SpanPackPtr)smanager->get_input(0);
gongo@localhost.localdomain
parents: 192
diff changeset
258 SpanPackPtr next_spack = (SpanPackPtr)smanager->allocate(sizeof(SpanPack));
gongo@localhost.localdomain
parents: 192
diff changeset
259 SpanPackPtr free_spack = next_spack; // next_spack の free() 用
gongo@localhost.localdomain
parents: 192
diff changeset
260 Span *span;
gongo@localhost.localdomain
parents: 192
diff changeset
261
gongo@localhost.localdomain
parents: 192
diff changeset
262 uint32 display = smanager->get_param(0);
gongo@localhost.localdomain
parents: 192
diff changeset
263 int screen_width = smanager->get_param(1);
gongo@localhost.localdomain
parents: 192
diff changeset
264 int rangex_start = smanager->get_param(2);
gongo@localhost.localdomain
parents: 192
diff changeset
265 int rangex_end = smanager->get_param(3);
gongo@localhost.localdomain
parents: 192
diff changeset
266
gongo@localhost.localdomain
parents: 192
diff changeset
267 // このタスクが担当する x の範囲
gongo@localhost.localdomain
parents: 192
diff changeset
268 int rangex = rangex_end - rangex_start + 1;
gongo@localhost.localdomain
parents: 192
diff changeset
269
gongo@localhost.localdomain
parents: 192
diff changeset
270 // y の範囲
gongo@localhost.localdomain
parents: 192
diff changeset
271 int rangey = smanager->get_param(4);
203
1eba8570808c fix CreateSpan::run
gongo@localhost.localdomain
parents: 200
diff changeset
272
167
508beb59e0eb DrawSpan で使う Tile の Hash の扱いは class TileHash を生成する事に。
gongo@localhost.localdomain
parents: 166
diff changeset
273 hash = (TileHashPtr)smanager->global_get(GLOBAL_TEXTURE_HASH);
508beb59e0eb DrawSpan で使う Tile の Hash の扱いは class TileHash を生成する事に。
gongo@localhost.localdomain
parents: 166
diff changeset
274 tileList = (TileListPtr)smanager->global_get(GLOBAL_TILE_LIST);
128
95e2046eb46f texture load use hash table
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents: 126
diff changeset
275
193
gongo@localhost.localdomain
parents: 192
diff changeset
276 zRow = zRow_init(rangex, rangey);
gongo@localhost.localdomain
parents: 192
diff changeset
277 linebuf = linebuf_init(rangex, rangey, 0xffffffff);
184
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 182
diff changeset
278
193
gongo@localhost.localdomain
parents: 192
diff changeset
279 doneWrite = 0;
184
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 182
diff changeset
280
194
gongo@localhost.localdomain
parents: 193
diff changeset
281 int tileNum = 0;
gongo@localhost.localdomain
parents: 193
diff changeset
282 int flag = 0;
gongo@localhost.localdomain
parents: 193
diff changeset
283
gongo@localhost.localdomain
parents: 193
diff changeset
284 #if defined(PROFILE)
gongo@localhost.localdomain
parents: 193
diff changeset
285 uint32 profile = spu_read_decrementer();
gongo@localhost.localdomain
parents: 193
diff changeset
286 printf("%d %u DrawSpan start\n", smanager->get_cpuid(), profile);
gongo@localhost.localdomain
parents: 193
diff changeset
287 #endif
109
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
288 do {
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
289 /**
193
gongo@localhost.localdomain
parents: 192
diff changeset
290 * SpanPack->next が存在する場合、
gongo@localhost.localdomain
parents: 192
diff changeset
291 * 現在の SpanPack を処理してる間に
gongo@localhost.localdomain
parents: 192
diff changeset
292 * 次の SpanPack の DMA 転送を行う
109
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
293 */
182
8e9ada0c1ed0 add get_inputAddr, get_outputAddr
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 180
diff changeset
294 if (spack->next != NULL) {
8e9ada0c1ed0 add get_inputAddr, get_outputAddr
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 180
diff changeset
295 smanager->dma_load(next_spack, (uint32)spack->next,
109
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
296 sizeof(SpanPack), SPAN_PACK_LOAD);
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
297 } else {
182
8e9ada0c1ed0 add get_inputAddr, get_outputAddr
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 180
diff changeset
298 next_spack = NULL;
109
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
299 }
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
300
182
8e9ada0c1ed0 add get_inputAddr, get_outputAddr
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 180
diff changeset
301 for (int t = 0; t < spack->info.size; t++) {
8e9ada0c1ed0 add get_inputAddr, get_outputAddr
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 180
diff changeset
302 span = &spack->span[t];
109
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
303
193
gongo@localhost.localdomain
parents: 192
diff changeset
304 uint32 rgb = 0x0000ff00;
164
dc7d10ae7460 TilePtr は SPE で計算した方がいいと判断して変更。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 161
diff changeset
305 float tex1 = span->tex_x1;
dc7d10ae7460 TilePtr は SPE で計算した方がいいと判断して変更。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 161
diff changeset
306 float tex2 = span->tex_x2;
dc7d10ae7460 TilePtr は SPE で計算した方がいいと判断して変更。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 161
diff changeset
307 float tey1 = span->tex_y1;
dc7d10ae7460 TilePtr は SPE で計算した方がいいと判断して変更。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 161
diff changeset
308 float tey2 = span->tex_y2;
147
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents: 133
diff changeset
309
166
gongo@localhost.localdomain
parents: 165
diff changeset
310 /**
193
gongo@localhost.localdomain
parents: 192
diff changeset
311 * Span が持つ 1 pixel 毎の
gongo@localhost.localdomain
parents: 192
diff changeset
312 * テクスチャの座標
166
gongo@localhost.localdomain
parents: 165
diff changeset
313 */
109
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
314 int tex_xpos;
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
315 int tex_ypos;
164
dc7d10ae7460 TilePtr は SPE で計算した方がいいと判断して変更。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 161
diff changeset
316
166
gongo@localhost.localdomain
parents: 165
diff changeset
317 /**
193
gongo@localhost.localdomain
parents: 192
diff changeset
318 * (tex_xpos, tex_ypos) の、ブロック内(上の図参照)での座標と
gongo@localhost.localdomain
parents: 192
diff changeset
319 * そのブロックのアドレス(MainMemory)
166
gongo@localhost.localdomain
parents: 165
diff changeset
320 */
164
dc7d10ae7460 TilePtr は SPE で計算した方がいいと判断して変更。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 161
diff changeset
321 int tex_localx;
dc7d10ae7460 TilePtr は SPE で計算した方がいいと判断して変更。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 161
diff changeset
322 int tex_localy;
dc7d10ae7460 TilePtr は SPE で計算した方がいいと判断して変更。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 161
diff changeset
323 uint32 *tex_addr;
dc7d10ae7460 TilePtr は SPE で計算した方がいいと判断して変更。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 161
diff changeset
324
109
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
325 int x = span->x;
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
326 int y = span->y;
133
8f1419174cdf DrawSpan のテクスチャ座標を求める部分で、width と height が逆に使われてた。
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents: 131
diff changeset
327 int x_len = span->length_x;
109
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
328 float z = span->start_z;
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
329 float zpos = span->end_z;
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
330
193
gongo@localhost.localdomain
parents: 192
diff changeset
331 // 座標が [0 .. split_screen_w-1] に入るように x,y を -1
109
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
332 int localx = getLocalX(x-1);
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
333 int localy = getLocalY(y-1);
131
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents: 128
diff changeset
334
133
8f1419174cdf DrawSpan のテクスチャ座標を求める部分で、width と height が逆に使われてた。
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents: 131
diff changeset
335 if (x_len == 1) {
109
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
336 if (x < rangex_start || rangex_end < x) {
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
337 continue;
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
338 }
148
74341c8bf935 Span への Texture List の渡し。じゃっかん texture がバグってるので
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents: 147
diff changeset
339
194
gongo@localhost.localdomain
parents: 193
diff changeset
340 flag = 1;
164
dc7d10ae7460 TilePtr は SPE で計算した方がいいと判断して変更。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 161
diff changeset
341 tex_xpos = (int)((span->tex_width-1) * tex1);
dc7d10ae7460 TilePtr は SPE で計算した方がいいと判断して変更。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 161
diff changeset
342 tex_ypos = (int)((span->tex_height-1) * tey1);
109
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
343
193
gongo@localhost.localdomain
parents: 192
diff changeset
344 if (zpos < zRow[localx + (rangex*localy)]) {
166
gongo@localhost.localdomain
parents: 165
diff changeset
345 tex_addr = getTile(tex_xpos, tex_ypos,
gongo@localhost.localdomain
parents: 165
diff changeset
346 span->tex_width, span->tex_addr);
164
dc7d10ae7460 TilePtr は SPE で計算した方がいいと判断して変更。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 161
diff changeset
347 tex_localx = tex_xpos % TEXTURE_SPLIT_PIXEL;
dc7d10ae7460 TilePtr は SPE で計算した方がいいと判断して変更。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 161
diff changeset
348 tex_localy = tex_ypos % TEXTURE_SPLIT_PIXEL;
166
gongo@localhost.localdomain
parents: 165
diff changeset
349
184
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 182
diff changeset
350 if (!isAvailableTile(tex_addr)) {
194
gongo@localhost.localdomain
parents: 193
diff changeset
351 # if defined(PROFILE)
gongo@localhost.localdomain
parents: 193
diff changeset
352 printf("%d %u start load tile\n",
gongo@localhost.localdomain
parents: 193
diff changeset
353 smanager->get_cpuid(), spu_read_decrementer());
gongo@localhost.localdomain
parents: 193
diff changeset
354 # endif
192
6694da357750 add example/renew_task
gongo@localhost.localdomain
parents: 188
diff changeset
355 set_rgb(tex_addr);
193
gongo@localhost.localdomain
parents: 192
diff changeset
356 smanager->dma_wait(TEX_LOAD);
194
gongo@localhost.localdomain
parents: 193
diff changeset
357 # if defined(PROFILE)
gongo@localhost.localdomain
parents: 193
diff changeset
358 printf("%d %u end load tile\n",
gongo@localhost.localdomain
parents: 193
diff changeset
359 smanager->get_cpuid(), spu_read_decrementer());
gongo@localhost.localdomain
parents: 193
diff changeset
360 # endif
gongo@localhost.localdomain
parents: 193
diff changeset
361 tileNum++;
184
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 182
diff changeset
362 }
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 182
diff changeset
363
164
dc7d10ae7460 TilePtr は SPE で計算した方がいいと判断して変更。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 161
diff changeset
364 rgb = get_rgb(tex_localx, tex_localy, tex_addr);
dc7d10ae7460 TilePtr は SPE で計算した方がいいと判断して変更。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 161
diff changeset
365
193
gongo@localhost.localdomain
parents: 192
diff changeset
366 zRow[localx + (rangex*localy)] = zpos;
gongo@localhost.localdomain
parents: 192
diff changeset
367 linebuf[localx + (rangex*localy)] = rgb;
109
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
368 }
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
369 } else {
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
370 int js = (x < rangex_start) ? rangex_start - x : 0;
133
8f1419174cdf DrawSpan のテクスチャ座標を求める部分で、width と height が逆に使われてた。
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents: 131
diff changeset
371 int je = (x + x_len > rangex_end) ? rangex_end - x : x_len;
164
dc7d10ae7460 TilePtr は SPE で計算した方がいいと判断して変更。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 161
diff changeset
372 float tex_x, tex_y, tex_z;
109
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
373
164
dc7d10ae7460 TilePtr は SPE で計算した方がいいと判断して変更。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 161
diff changeset
374 for (int j = js; j <= je; j++) {
194
gongo@localhost.localdomain
parents: 193
diff changeset
375 flag = 1;
164
dc7d10ae7460 TilePtr は SPE で計算した方がいいと判断して変更。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 161
diff changeset
376 localx = getLocalX(x-1+j);
148
74341c8bf935 Span への Texture List の渡し。じゃっかん texture がバグってるので
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents: 147
diff changeset
377
164
dc7d10ae7460 TilePtr は SPE で計算した方がいいと判断して変更。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 161
diff changeset
378 tex_z = z*(x_len-1-j)/(x_len-1) + zpos*j/(x_len-1);
133
8f1419174cdf DrawSpan のテクスチャ座標を求める部分で、width と height が逆に使われてた。
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents: 131
diff changeset
379
164
dc7d10ae7460 TilePtr は SPE で計算した方がいいと判断して変更。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 161
diff changeset
380 tex_x = tex1*(x_len-1-j)/(x_len-1) + tex2*j/(x_len-1);
dc7d10ae7460 TilePtr は SPE で計算した方がいいと判断して変更。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 161
diff changeset
381 tex_y = tey1*(x_len-1-j)/(x_len-1) + tey2*j/(x_len-1);
dc7d10ae7460 TilePtr は SPE で計算した方がいいと判断して変更。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 161
diff changeset
382 if (tex_x > 1) tex_x = 1;
165
gongo@localhost.localdomain
parents: 164
diff changeset
383 if (tex_x < 0) tex_x = 0;
164
dc7d10ae7460 TilePtr は SPE で計算した方がいいと判断して変更。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 161
diff changeset
384 if (tex_y > 1) tex_y = 1;
165
gongo@localhost.localdomain
parents: 164
diff changeset
385 if (tex_y < 0) tex_y = 0;
164
dc7d10ae7460 TilePtr は SPE で計算した方がいいと判断して変更。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 161
diff changeset
386 tex_xpos = (int)((span->tex_width-1) * tex_x);
dc7d10ae7460 TilePtr は SPE で計算した方がいいと判断して変更。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 161
diff changeset
387 tex_ypos = (int)((span->tex_height-1) * tex_y);
dc7d10ae7460 TilePtr は SPE で計算した方がいいと判断して変更。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 161
diff changeset
388
dc7d10ae7460 TilePtr は SPE で計算した方がいいと判断して変更。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 161
diff changeset
389 if (tex_z < zRow[localx + (rangex*localy)]) {
166
gongo@localhost.localdomain
parents: 165
diff changeset
390 tex_addr = getTile(tex_xpos, tex_ypos,
gongo@localhost.localdomain
parents: 165
diff changeset
391 span->tex_width, span->tex_addr);
164
dc7d10ae7460 TilePtr は SPE で計算した方がいいと判断して変更。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 161
diff changeset
392 tex_localx = tex_xpos % TEXTURE_SPLIT_PIXEL;
dc7d10ae7460 TilePtr は SPE で計算した方がいいと判断して変更。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 161
diff changeset
393 tex_localy = tex_ypos % TEXTURE_SPLIT_PIXEL;
184
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 182
diff changeset
394
193
gongo@localhost.localdomain
parents: 192
diff changeset
395 /**
gongo@localhost.localdomain
parents: 192
diff changeset
396 * Tile が無い場合、一旦タスクはここで中断し、
gongo@localhost.localdomain
parents: 192
diff changeset
397 * Tile をロードするタスクを走らせた後に再起動する
gongo@localhost.localdomain
parents: 192
diff changeset
398 */
184
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 182
diff changeset
399 if (!isAvailableTile(tex_addr)) {
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 182
diff changeset
400 spack->info.start = t;
194
gongo@localhost.localdomain
parents: 193
diff changeset
401 #if 0
184
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 182
diff changeset
402 set_rgbs(tex_addr,
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 182
diff changeset
403 getTile(span->tex_width-1, tex_ypos,
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 182
diff changeset
404 span->tex_width, span->tex_addr));
193
gongo@localhost.localdomain
parents: 192
diff changeset
405 //smanager->dma_wait(TEX_LOAD);
184
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 182
diff changeset
406 reboot(spack, j);
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 182
diff changeset
407 goto FINISH;
193
gongo@localhost.localdomain
parents: 192
diff changeset
408 #else
194
gongo@localhost.localdomain
parents: 193
diff changeset
409
gongo@localhost.localdomain
parents: 193
diff changeset
410 # if defined(PROFILE)
gongo@localhost.localdomain
parents: 193
diff changeset
411 printf("%d %u start load tile\n",
gongo@localhost.localdomain
parents: 193
diff changeset
412 smanager->get_cpuid(),
gongo@localhost.localdomain
parents: 193
diff changeset
413 spu_read_decrementer());
gongo@localhost.localdomain
parents: 193
diff changeset
414 # endif
gongo@localhost.localdomain
parents: 193
diff changeset
415
193
gongo@localhost.localdomain
parents: 192
diff changeset
416 set_rgb(tex_addr);
gongo@localhost.localdomain
parents: 192
diff changeset
417 smanager->dma_wait(TEX_LOAD);
194
gongo@localhost.localdomain
parents: 193
diff changeset
418 tileNum++;
gongo@localhost.localdomain
parents: 193
diff changeset
419
gongo@localhost.localdomain
parents: 193
diff changeset
420 # if defined(PROFILE)
gongo@localhost.localdomain
parents: 193
diff changeset
421 printf("%d %u end load tile\n",
gongo@localhost.localdomain
parents: 193
diff changeset
422 smanager->get_cpuid(),
gongo@localhost.localdomain
parents: 193
diff changeset
423 spu_read_decrementer());
gongo@localhost.localdomain
parents: 193
diff changeset
424 # endif
193
gongo@localhost.localdomain
parents: 192
diff changeset
425 #endif
184
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 182
diff changeset
426 }
164
dc7d10ae7460 TilePtr は SPE で計算した方がいいと判断して変更。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 161
diff changeset
427
dc7d10ae7460 TilePtr は SPE で計算した方がいいと判断して変更。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 161
diff changeset
428 rgb = get_rgb(tex_localx, tex_localy, tex_addr);
194
gongo@localhost.localdomain
parents: 193
diff changeset
429
164
dc7d10ae7460 TilePtr は SPE で計算した方がいいと判断して変更。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 161
diff changeset
430 zRow[localx + (rangex*localy)] = tex_z;
193
gongo@localhost.localdomain
parents: 192
diff changeset
431 linebuf[localx + (rangex*localy)] = rgb;
147
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents: 133
diff changeset
432 }
109
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
433 }
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
434 }
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
435 }
147
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents: 133
diff changeset
436
200
efd7e4712342 fix run_draw
gongo@localhost.localdomain
parents: 194
diff changeset
437 for (int t = 0; t < spack->info.size; t++) {
efd7e4712342 fix run_draw
gongo@localhost.localdomain
parents: 194
diff changeset
438 span = &spack->span[t];
efd7e4712342 fix run_draw
gongo@localhost.localdomain
parents: 194
diff changeset
439
efd7e4712342 fix run_draw
gongo@localhost.localdomain
parents: 194
diff changeset
440 uint32 rgb = 0x0000ff00;
efd7e4712342 fix run_draw
gongo@localhost.localdomain
parents: 194
diff changeset
441 float tex1 = span->tex_x1;
efd7e4712342 fix run_draw
gongo@localhost.localdomain
parents: 194
diff changeset
442 float tex2 = span->tex_x2;
efd7e4712342 fix run_draw
gongo@localhost.localdomain
parents: 194
diff changeset
443 float tey1 = span->tex_y1;
efd7e4712342 fix run_draw
gongo@localhost.localdomain
parents: 194
diff changeset
444 float tey2 = span->tex_y2;
efd7e4712342 fix run_draw
gongo@localhost.localdomain
parents: 194
diff changeset
445
efd7e4712342 fix run_draw
gongo@localhost.localdomain
parents: 194
diff changeset
446 /**
efd7e4712342 fix run_draw
gongo@localhost.localdomain
parents: 194
diff changeset
447 * Span が持つ 1 pixel 毎の
efd7e4712342 fix run_draw
gongo@localhost.localdomain
parents: 194
diff changeset
448 * テクスチャの座標
efd7e4712342 fix run_draw
gongo@localhost.localdomain
parents: 194
diff changeset
449 */
efd7e4712342 fix run_draw
gongo@localhost.localdomain
parents: 194
diff changeset
450 int tex_xpos;
efd7e4712342 fix run_draw
gongo@localhost.localdomain
parents: 194
diff changeset
451 int tex_ypos;
efd7e4712342 fix run_draw
gongo@localhost.localdomain
parents: 194
diff changeset
452
efd7e4712342 fix run_draw
gongo@localhost.localdomain
parents: 194
diff changeset
453 /**
efd7e4712342 fix run_draw
gongo@localhost.localdomain
parents: 194
diff changeset
454 * (tex_xpos, tex_ypos) の、ブロック内(上の図参照)での座標と
efd7e4712342 fix run_draw
gongo@localhost.localdomain
parents: 194
diff changeset
455 * そのブロックのアドレス(MainMemory)
efd7e4712342 fix run_draw
gongo@localhost.localdomain
parents: 194
diff changeset
456 */
efd7e4712342 fix run_draw
gongo@localhost.localdomain
parents: 194
diff changeset
457 int tex_localx;
efd7e4712342 fix run_draw
gongo@localhost.localdomain
parents: 194
diff changeset
458 int tex_localy;
efd7e4712342 fix run_draw
gongo@localhost.localdomain
parents: 194
diff changeset
459 uint32 *tex_addr;
efd7e4712342 fix run_draw
gongo@localhost.localdomain
parents: 194
diff changeset
460
efd7e4712342 fix run_draw
gongo@localhost.localdomain
parents: 194
diff changeset
461 int x = span->x;
efd7e4712342 fix run_draw
gongo@localhost.localdomain
parents: 194
diff changeset
462 int y = span->y;
efd7e4712342 fix run_draw
gongo@localhost.localdomain
parents: 194
diff changeset
463 int x_len = span->length_x;
efd7e4712342 fix run_draw
gongo@localhost.localdomain
parents: 194
diff changeset
464 float z = span->start_z;
efd7e4712342 fix run_draw
gongo@localhost.localdomain
parents: 194
diff changeset
465 float zpos = span->end_z;
efd7e4712342 fix run_draw
gongo@localhost.localdomain
parents: 194
diff changeset
466
efd7e4712342 fix run_draw
gongo@localhost.localdomain
parents: 194
diff changeset
467 // 座標が [0 .. split_screen_w-1] に入るように x,y を -1
efd7e4712342 fix run_draw
gongo@localhost.localdomain
parents: 194
diff changeset
468 int localx = getLocalX(x-1);
efd7e4712342 fix run_draw
gongo@localhost.localdomain
parents: 194
diff changeset
469 int localy = getLocalY(y-1);
efd7e4712342 fix run_draw
gongo@localhost.localdomain
parents: 194
diff changeset
470
efd7e4712342 fix run_draw
gongo@localhost.localdomain
parents: 194
diff changeset
471 if (x_len == 1) {
efd7e4712342 fix run_draw
gongo@localhost.localdomain
parents: 194
diff changeset
472 if (x < rangex_start || rangex_end < x) {
efd7e4712342 fix run_draw
gongo@localhost.localdomain
parents: 194
diff changeset
473 continue;
efd7e4712342 fix run_draw
gongo@localhost.localdomain
parents: 194
diff changeset
474 }
efd7e4712342 fix run_draw
gongo@localhost.localdomain
parents: 194
diff changeset
475
efd7e4712342 fix run_draw
gongo@localhost.localdomain
parents: 194
diff changeset
476 flag = 1;
efd7e4712342 fix run_draw
gongo@localhost.localdomain
parents: 194
diff changeset
477 tex_xpos = (int)((span->tex_width-1) * tex1);
efd7e4712342 fix run_draw
gongo@localhost.localdomain
parents: 194
diff changeset
478 tex_ypos = (int)((span->tex_height-1) * tey1);
efd7e4712342 fix run_draw
gongo@localhost.localdomain
parents: 194
diff changeset
479
efd7e4712342 fix run_draw
gongo@localhost.localdomain
parents: 194
diff changeset
480 if (zpos < zRow[localx + (rangex*localy)]) {
efd7e4712342 fix run_draw
gongo@localhost.localdomain
parents: 194
diff changeset
481 tex_addr = getTile(tex_xpos, tex_ypos,
efd7e4712342 fix run_draw
gongo@localhost.localdomain
parents: 194
diff changeset
482 span->tex_width, span->tex_addr);
efd7e4712342 fix run_draw
gongo@localhost.localdomain
parents: 194
diff changeset
483 tex_localx = tex_xpos % TEXTURE_SPLIT_PIXEL;
efd7e4712342 fix run_draw
gongo@localhost.localdomain
parents: 194
diff changeset
484 tex_localy = tex_ypos % TEXTURE_SPLIT_PIXEL;
efd7e4712342 fix run_draw
gongo@localhost.localdomain
parents: 194
diff changeset
485
efd7e4712342 fix run_draw
gongo@localhost.localdomain
parents: 194
diff changeset
486 if (!isAvailableTile(tex_addr)) {
efd7e4712342 fix run_draw
gongo@localhost.localdomain
parents: 194
diff changeset
487 # if defined(PROFILE)
efd7e4712342 fix run_draw
gongo@localhost.localdomain
parents: 194
diff changeset
488 printf("%d %u start load tile\n",
efd7e4712342 fix run_draw
gongo@localhost.localdomain
parents: 194
diff changeset
489 smanager->get_cpuid(), spu_read_decrementer());
efd7e4712342 fix run_draw
gongo@localhost.localdomain
parents: 194
diff changeset
490 # endif
efd7e4712342 fix run_draw
gongo@localhost.localdomain
parents: 194
diff changeset
491 set_rgb(tex_addr);
efd7e4712342 fix run_draw
gongo@localhost.localdomain
parents: 194
diff changeset
492 smanager->dma_wait(TEX_LOAD);
efd7e4712342 fix run_draw
gongo@localhost.localdomain
parents: 194
diff changeset
493 # if defined(PROFILE)
efd7e4712342 fix run_draw
gongo@localhost.localdomain
parents: 194
diff changeset
494 printf("%d %u end load tile\n",
efd7e4712342 fix run_draw
gongo@localhost.localdomain
parents: 194
diff changeset
495 smanager->get_cpuid(), spu_read_decrementer());
efd7e4712342 fix run_draw
gongo@localhost.localdomain
parents: 194
diff changeset
496 # endif
efd7e4712342 fix run_draw
gongo@localhost.localdomain
parents: 194
diff changeset
497 tileNum++;
efd7e4712342 fix run_draw
gongo@localhost.localdomain
parents: 194
diff changeset
498 }
efd7e4712342 fix run_draw
gongo@localhost.localdomain
parents: 194
diff changeset
499
efd7e4712342 fix run_draw
gongo@localhost.localdomain
parents: 194
diff changeset
500 rgb = get_rgb(tex_localx, tex_localy, tex_addr);
efd7e4712342 fix run_draw
gongo@localhost.localdomain
parents: 194
diff changeset
501
efd7e4712342 fix run_draw
gongo@localhost.localdomain
parents: 194
diff changeset
502 zRow[localx + (rangex*localy)] = zpos;
efd7e4712342 fix run_draw
gongo@localhost.localdomain
parents: 194
diff changeset
503 linebuf[localx + (rangex*localy)] = rgb;
efd7e4712342 fix run_draw
gongo@localhost.localdomain
parents: 194
diff changeset
504 }
efd7e4712342 fix run_draw
gongo@localhost.localdomain
parents: 194
diff changeset
505 } else {
efd7e4712342 fix run_draw
gongo@localhost.localdomain
parents: 194
diff changeset
506 int js = (x < rangex_start) ? rangex_start - x : 0;
efd7e4712342 fix run_draw
gongo@localhost.localdomain
parents: 194
diff changeset
507 int je = (x + x_len > rangex_end) ? rangex_end - x : x_len;
efd7e4712342 fix run_draw
gongo@localhost.localdomain
parents: 194
diff changeset
508 float tex_x, tex_y, tex_z;
efd7e4712342 fix run_draw
gongo@localhost.localdomain
parents: 194
diff changeset
509
efd7e4712342 fix run_draw
gongo@localhost.localdomain
parents: 194
diff changeset
510 for (int j = js; j <= je; j++) {
efd7e4712342 fix run_draw
gongo@localhost.localdomain
parents: 194
diff changeset
511 flag = 1;
efd7e4712342 fix run_draw
gongo@localhost.localdomain
parents: 194
diff changeset
512 localx = getLocalX(x-1+j);
efd7e4712342 fix run_draw
gongo@localhost.localdomain
parents: 194
diff changeset
513
efd7e4712342 fix run_draw
gongo@localhost.localdomain
parents: 194
diff changeset
514 tex_z = z*(x_len-1-j)/(x_len-1) + zpos*j/(x_len-1);
efd7e4712342 fix run_draw
gongo@localhost.localdomain
parents: 194
diff changeset
515
efd7e4712342 fix run_draw
gongo@localhost.localdomain
parents: 194
diff changeset
516 tex_x = tex1*(x_len-1-j)/(x_len-1) + tex2*j/(x_len-1);
efd7e4712342 fix run_draw
gongo@localhost.localdomain
parents: 194
diff changeset
517 tex_y = tey1*(x_len-1-j)/(x_len-1) + tey2*j/(x_len-1);
efd7e4712342 fix run_draw
gongo@localhost.localdomain
parents: 194
diff changeset
518 if (tex_x > 1) tex_x = 1;
efd7e4712342 fix run_draw
gongo@localhost.localdomain
parents: 194
diff changeset
519 if (tex_x < 0) tex_x = 0;
efd7e4712342 fix run_draw
gongo@localhost.localdomain
parents: 194
diff changeset
520 if (tex_y > 1) tex_y = 1;
efd7e4712342 fix run_draw
gongo@localhost.localdomain
parents: 194
diff changeset
521 if (tex_y < 0) tex_y = 0;
efd7e4712342 fix run_draw
gongo@localhost.localdomain
parents: 194
diff changeset
522 tex_xpos = (int)((span->tex_width-1) * tex_x);
efd7e4712342 fix run_draw
gongo@localhost.localdomain
parents: 194
diff changeset
523 tex_ypos = (int)((span->tex_height-1) * tex_y);
efd7e4712342 fix run_draw
gongo@localhost.localdomain
parents: 194
diff changeset
524
efd7e4712342 fix run_draw
gongo@localhost.localdomain
parents: 194
diff changeset
525 if (tex_z < zRow[localx + (rangex*localy)]) {
efd7e4712342 fix run_draw
gongo@localhost.localdomain
parents: 194
diff changeset
526 tex_addr = getTile(tex_xpos, tex_ypos,
efd7e4712342 fix run_draw
gongo@localhost.localdomain
parents: 194
diff changeset
527 span->tex_width, span->tex_addr);
efd7e4712342 fix run_draw
gongo@localhost.localdomain
parents: 194
diff changeset
528 tex_localx = tex_xpos % TEXTURE_SPLIT_PIXEL;
efd7e4712342 fix run_draw
gongo@localhost.localdomain
parents: 194
diff changeset
529 tex_localy = tex_ypos % TEXTURE_SPLIT_PIXEL;
efd7e4712342 fix run_draw
gongo@localhost.localdomain
parents: 194
diff changeset
530
efd7e4712342 fix run_draw
gongo@localhost.localdomain
parents: 194
diff changeset
531 /**
efd7e4712342 fix run_draw
gongo@localhost.localdomain
parents: 194
diff changeset
532 * Tile が無い場合、一旦タスクはここで中断し、
efd7e4712342 fix run_draw
gongo@localhost.localdomain
parents: 194
diff changeset
533 * Tile をロードするタスクを走らせた後に再起動する
efd7e4712342 fix run_draw
gongo@localhost.localdomain
parents: 194
diff changeset
534 */
efd7e4712342 fix run_draw
gongo@localhost.localdomain
parents: 194
diff changeset
535 if (!isAvailableTile(tex_addr)) {
efd7e4712342 fix run_draw
gongo@localhost.localdomain
parents: 194
diff changeset
536 spack->info.start = t;
efd7e4712342 fix run_draw
gongo@localhost.localdomain
parents: 194
diff changeset
537 #if 0
efd7e4712342 fix run_draw
gongo@localhost.localdomain
parents: 194
diff changeset
538 set_rgbs(tex_addr,
efd7e4712342 fix run_draw
gongo@localhost.localdomain
parents: 194
diff changeset
539 getTile(span->tex_width-1, tex_ypos,
efd7e4712342 fix run_draw
gongo@localhost.localdomain
parents: 194
diff changeset
540 span->tex_width, span->tex_addr));
efd7e4712342 fix run_draw
gongo@localhost.localdomain
parents: 194
diff changeset
541 //smanager->dma_wait(TEX_LOAD);
efd7e4712342 fix run_draw
gongo@localhost.localdomain
parents: 194
diff changeset
542 reboot(spack, j);
efd7e4712342 fix run_draw
gongo@localhost.localdomain
parents: 194
diff changeset
543 goto FINISH;
efd7e4712342 fix run_draw
gongo@localhost.localdomain
parents: 194
diff changeset
544 #else
efd7e4712342 fix run_draw
gongo@localhost.localdomain
parents: 194
diff changeset
545
efd7e4712342 fix run_draw
gongo@localhost.localdomain
parents: 194
diff changeset
546 # if defined(PROFILE)
efd7e4712342 fix run_draw
gongo@localhost.localdomain
parents: 194
diff changeset
547 printf("%d %u start load tile\n",
efd7e4712342 fix run_draw
gongo@localhost.localdomain
parents: 194
diff changeset
548 smanager->get_cpuid(),
efd7e4712342 fix run_draw
gongo@localhost.localdomain
parents: 194
diff changeset
549 spu_read_decrementer());
efd7e4712342 fix run_draw
gongo@localhost.localdomain
parents: 194
diff changeset
550 # endif
efd7e4712342 fix run_draw
gongo@localhost.localdomain
parents: 194
diff changeset
551
efd7e4712342 fix run_draw
gongo@localhost.localdomain
parents: 194
diff changeset
552 set_rgb(tex_addr);
efd7e4712342 fix run_draw
gongo@localhost.localdomain
parents: 194
diff changeset
553 smanager->dma_wait(TEX_LOAD);
efd7e4712342 fix run_draw
gongo@localhost.localdomain
parents: 194
diff changeset
554 tileNum++;
efd7e4712342 fix run_draw
gongo@localhost.localdomain
parents: 194
diff changeset
555
efd7e4712342 fix run_draw
gongo@localhost.localdomain
parents: 194
diff changeset
556 # if defined(PROFILE)
efd7e4712342 fix run_draw
gongo@localhost.localdomain
parents: 194
diff changeset
557 printf("%d %u end load tile\n",
efd7e4712342 fix run_draw
gongo@localhost.localdomain
parents: 194
diff changeset
558 smanager->get_cpuid(),
efd7e4712342 fix run_draw
gongo@localhost.localdomain
parents: 194
diff changeset
559 spu_read_decrementer());
efd7e4712342 fix run_draw
gongo@localhost.localdomain
parents: 194
diff changeset
560 # endif
efd7e4712342 fix run_draw
gongo@localhost.localdomain
parents: 194
diff changeset
561 #endif
efd7e4712342 fix run_draw
gongo@localhost.localdomain
parents: 194
diff changeset
562 }
efd7e4712342 fix run_draw
gongo@localhost.localdomain
parents: 194
diff changeset
563
efd7e4712342 fix run_draw
gongo@localhost.localdomain
parents: 194
diff changeset
564 rgb = get_rgb(tex_localx, tex_localy, tex_addr);
efd7e4712342 fix run_draw
gongo@localhost.localdomain
parents: 194
diff changeset
565
efd7e4712342 fix run_draw
gongo@localhost.localdomain
parents: 194
diff changeset
566 zRow[localx + (rangex*localy)] = tex_z;
efd7e4712342 fix run_draw
gongo@localhost.localdomain
parents: 194
diff changeset
567 linebuf[localx + (rangex*localy)] = rgb;
efd7e4712342 fix run_draw
gongo@localhost.localdomain
parents: 194
diff changeset
568 }
efd7e4712342 fix run_draw
gongo@localhost.localdomain
parents: 194
diff changeset
569 }
efd7e4712342 fix run_draw
gongo@localhost.localdomain
parents: 194
diff changeset
570 }
efd7e4712342 fix run_draw
gongo@localhost.localdomain
parents: 194
diff changeset
571 }
efd7e4712342 fix run_draw
gongo@localhost.localdomain
parents: 194
diff changeset
572
109
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
573 smanager->dma_wait(SPAN_PACK_LOAD);
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
574
184
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 182
diff changeset
575 SpanPackPtr tmp_spack = spack;
182
8e9ada0c1ed0 add get_inputAddr, get_outputAddr
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 180
diff changeset
576 spack = next_spack;
8e9ada0c1ed0 add get_inputAddr, get_outputAddr
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 180
diff changeset
577 next_spack = tmp_spack;
8e9ada0c1ed0 add get_inputAddr, get_outputAddr
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 180
diff changeset
578 } while (spack);
109
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
579
193
gongo@localhost.localdomain
parents: 192
diff changeset
580 writebuffer(display, rangex, rangey, screen_width);
gongo@localhost.localdomain
parents: 192
diff changeset
581
gongo@localhost.localdomain
parents: 192
diff changeset
582 // linebuf は、writebuffer() の dma_store を wait する
gongo@localhost.localdomain
parents: 192
diff changeset
583 // DrawSpan::~DrawSpan() 内で free する。
gongo@localhost.localdomain
parents: 192
diff changeset
584 //free(linebuf);
gongo@localhost.localdomain
parents: 192
diff changeset
585 free(zRow);
184
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 182
diff changeset
586
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 182
diff changeset
587 FINISH:
193
gongo@localhost.localdomain
parents: 192
diff changeset
588 /**
gongo@localhost.localdomain
parents: 192
diff changeset
589 * goto FINISH; の時は reboot なので
gongo@localhost.localdomain
parents: 192
diff changeset
590 * linebuf, zRow は free() しない
gongo@localhost.localdomain
parents: 192
diff changeset
591 */
182
8e9ada0c1ed0 add get_inputAddr, get_outputAddr
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 180
diff changeset
592 free(free_spack);
194
gongo@localhost.localdomain
parents: 193
diff changeset
593
gongo@localhost.localdomain
parents: 193
diff changeset
594 #if defined(PROFILE)
gongo@localhost.localdomain
parents: 193
diff changeset
595 printf("%d %u DrawSpan end\n",
gongo@localhost.localdomain
parents: 193
diff changeset
596 smanager->get_cpuid(), spu_read_decrementer());
gongo@localhost.localdomain
parents: 193
diff changeset
597 if (flag) {
gongo@localhost.localdomain
parents: 193
diff changeset
598 printf("%d %d tileNum\n", smanager->get_cpuid(), tileNum);
gongo@localhost.localdomain
parents: 193
diff changeset
599 }
gongo@localhost.localdomain
parents: 193
diff changeset
600 #endif
109
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
601
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
602 return 0;
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
603 }