annotate TaskManager/Test/test_render/spe/DrawSpan.cpp @ 193:1ff24ca2f016 draft

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