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