annotate TaskManager/Test/test_render/spe/DrawSpan.cpp @ 267:7f2b30acf311

merge
author Shinji KONO <kono@ie.u-ryukyu.ac.jp>
date Thu, 04 Jun 2009 00:01:11 +0900
parents 52db409f255a 5c9dbd54cd51
children 06d53c7b87c2
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
109
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
1 #include <stdlib.h>
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
2 #include <string.h>
200
10ad99550ee8 fix run_draw
gongo@localhost.localdomain
parents: 194
diff changeset
3 #include <spu_intrinsics.h>
109
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
4 #include "DrawSpan.h"
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
5 #include "polygon_pack.h"
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
6 #include "texture.h"
5c194c71eca8 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
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
9
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
10 SchedDefineTask(DrawSpan);
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
11
264
a59868d37093 merge 151 263
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 148 122
diff changeset
12 <<<<<<< local
210
204b03ca98f8 fix DrawSpan
gongo@localhost.localdomain
parents: 205
diff changeset
13 #define TEX_LOAD1 0
204b03ca98f8 fix DrawSpan
gongo@localhost.localdomain
parents: 205
diff changeset
14 #define TEX_LOAD2 1
204b03ca98f8 fix DrawSpan
gongo@localhost.localdomain
parents: 205
diff changeset
15 #define SPAN_PACK_LOAD 2
204b03ca98f8 fix DrawSpan
gongo@localhost.localdomain
parents: 205
diff changeset
16 #define FB_STORE 3
267
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 243 266
diff changeset
17 =======
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 243 266
diff changeset
18 <<<<<<< local
167
c8b868871dce DrawSpan で使う Tile の Hash の扱いは class TileHash を生成する事に。
gongo@localhost.localdomain
parents: 166
diff changeset
19 static TileHashPtr hash;
265
d949e590da26 merge 172 264
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 170 264
diff changeset
20 =======
d949e590da26 merge 172 264
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 170 264
diff changeset
21 <<<<<<< local
128
776eca0daa02 texture load use hash table
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents: 126
diff changeset
22 static const int hashsize = 263;
267
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 243 266
diff changeset
23 >>>>>>> other
128
776eca0daa02 texture load use hash table
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents: 126
diff changeset
24
267
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 243 266
diff changeset
25 <<<<<<< local
193
gongo@localhost.localdomain
parents: 192
diff changeset
26 DrawSpan::~DrawSpan(void)
gongo@localhost.localdomain
parents: 192
diff changeset
27 {
gongo@localhost.localdomain
parents: 192
diff changeset
28 smanager->dma_wait(FB_STORE);
gongo@localhost.localdomain
parents: 192
diff changeset
29 free((void*)((int)linebuf*doneWrite));
gongo@localhost.localdomain
parents: 192
diff changeset
30 }
267
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 243 266
diff changeset
31 =======
128
776eca0daa02 texture load use hash table
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents: 126
diff changeset
32 static TilePtr hash_table[hashsize] = {NULL};
267
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 243 266
diff changeset
33 >>>>>>> other
128
776eca0daa02 texture load use hash table
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents: 126
diff changeset
34
267
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 243 266
diff changeset
35 <<<<<<< local
205
gongo@localhost.localdomain
parents: 203
diff changeset
36 inline vector float
gongo@localhost.localdomain
parents: 203
diff changeset
37 spu_re_nrm(vector float a)
gongo@localhost.localdomain
parents: 203
diff changeset
38 {
gongo@localhost.localdomain
parents: 203
diff changeset
39 vector float unit = (vector float){1.0, 1.0, 1.0, 1.0};
gongo@localhost.localdomain
parents: 203
diff changeset
40 vector float approximation;
267
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 243 266
diff changeset
41 =======
128
776eca0daa02 texture load use hash table
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents: 126
diff changeset
42 unsigned short PRIME[8] = {
776eca0daa02 texture load use hash table
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents: 126
diff changeset
43 0x002, 0x065, 0x0c7, 0x133, 0x191, 0x1f3, 0x259, 0x2bd,
776eca0daa02 texture load use hash table
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents: 126
diff changeset
44 };
267
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 243 266
diff changeset
45 >>>>>>> other
128
776eca0daa02 texture load use hash table
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents: 126
diff changeset
46
267
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 243 266
diff changeset
47 <<<<<<< local
205
gongo@localhost.localdomain
parents: 203
diff changeset
48 approximation = spu_re(a);
gongo@localhost.localdomain
parents: 203
diff changeset
49 return spu_madd(spu_nmsub(approximation, a, unit),
gongo@localhost.localdomain
parents: 203
diff changeset
50 approximation, approximation);
gongo@localhost.localdomain
parents: 203
diff changeset
51 }
gongo@localhost.localdomain
parents: 203
diff changeset
52
gongo@localhost.localdomain
parents: 203
diff changeset
53
gongo@localhost.localdomain
parents: 203
diff changeset
54 vector signed int
gongo@localhost.localdomain
parents: 203
diff changeset
55 getLocalPositionVec(vector signed int d, signed int offset)
gongo@localhost.localdomain
parents: 203
diff changeset
56 {
gongo@localhost.localdomain
parents: 203
diff changeset
57 return spu_and(d, spu_splats(offset-1));
gongo@localhost.localdomain
parents: 203
diff changeset
58 }
gongo@localhost.localdomain
parents: 203
diff changeset
59
gongo@localhost.localdomain
parents: 203
diff changeset
60 vector signed int
gongo@localhost.localdomain
parents: 203
diff changeset
61 getLocalXVec(vector signed int x)
gongo@localhost.localdomain
parents: 203
diff changeset
62 {
gongo@localhost.localdomain
parents: 203
diff changeset
63 return getLocalPositionVec(x, split_screen_w);
gongo@localhost.localdomain
parents: 203
diff changeset
64 }
gongo@localhost.localdomain
parents: 203
diff changeset
65
267
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 243 266
diff changeset
66 =======
265
d949e590da26 merge 172 264
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 170 264
diff changeset
67 >>>>>>> other
128
776eca0daa02 texture load use hash table
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents: 126
diff changeset
68 static TileListPtr tileList;
267
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 243 266
diff changeset
69 >>>>>>> other
128
776eca0daa02 texture load use hash table
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents: 126
diff changeset
70
164
38cbb7aecc70 TilePtr は SPE で計算した方がいいと判断して変更。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 161
diff changeset
71 /**
193
gongo@localhost.localdomain
parents: 192
diff changeset
72 * テクスチャは、TEXTURE_SPLIT_PIXEL^2 のブロックに分割する
164
38cbb7aecc70 TilePtr は SPE で計算した方がいいと判断して変更。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 161
diff changeset
73 *
38cbb7aecc70 TilePtr は SPE で計算した方がいいと判断して変更。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 161
diff changeset
74 * +---+---+---+---+---+---+
38cbb7aecc70 TilePtr は SPE で計算した方がいいと判断して変更。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 161
diff changeset
75 * | 0 | 1 | 2 | 3 | 4 | 5 |
38cbb7aecc70 TilePtr は SPE で計算した方がいいと判断して変更。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 161
diff changeset
76 * +---+---+---+---+---+---+
38cbb7aecc70 TilePtr は SPE で計算した方がいいと判断して変更。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 161
diff changeset
77 * | | | | | |11 |
38cbb7aecc70 TilePtr は SPE で計算した方がいいと判断して変更。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 161
diff changeset
78 * +---+---+---+---+---+---+
38cbb7aecc70 TilePtr は SPE で計算した方がいいと判断して変更。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 161
diff changeset
79 * | | | | | |17 |
38cbb7aecc70 TilePtr は SPE で計算した方がいいと判断して変更。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 161
diff changeset
80 * +---+---+---+---+---+---+
38cbb7aecc70 TilePtr は SPE で計算した方がいいと判断して変更。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 161
diff changeset
81 * | | | | | |23 |
38cbb7aecc70 TilePtr は SPE で計算した方がいいと判断して変更。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 161
diff changeset
82 * +---+---+---+---+---+---+
38cbb7aecc70 TilePtr は SPE で計算した方がいいと判断して変更。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 161
diff changeset
83 * | | | | | |29 |
38cbb7aecc70 TilePtr は SPE で計算した方がいいと判断して変更。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 161
diff changeset
84 * +---+---+---+---+---+---+
38cbb7aecc70 TilePtr は SPE で計算した方がいいと判断して変更。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 161
diff changeset
85 * | | | | | |35 |
38cbb7aecc70 TilePtr は SPE で計算した方がいいと判断して変更。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 161
diff changeset
86 * +---+---+---+---+---+---+
38cbb7aecc70 TilePtr は SPE で計算した方がいいと判断して変更。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 161
diff changeset
87 *
193
gongo@localhost.localdomain
parents: 192
diff changeset
88 * 一辺を TEXTURE_SPLIT とする
gongo@localhost.localdomain
parents: 192
diff changeset
89 * 各ブロックの数字がブロックIDとなる。
164
38cbb7aecc70 TilePtr は SPE で計算した方がいいと判断して変更。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 161
diff changeset
90 */
128
776eca0daa02 texture load use hash table
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents: 126
diff changeset
91
164
38cbb7aecc70 TilePtr は SPE で計算した方がいいと判断して変更。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 161
diff changeset
92 /**
193
gongo@localhost.localdomain
parents: 192
diff changeset
93 * テクスチャの座標から、
gongo@localhost.localdomain
parents: 192
diff changeset
94 * テクスチャのどのブロックかを求める
164
38cbb7aecc70 TilePtr は SPE で計算した方がいいと判断して変更。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 161
diff changeset
95 *
38cbb7aecc70 TilePtr は SPE で計算した方がいいと判断して変更。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 161
diff changeset
96 * @param[in] tx X coordinates of texture
38cbb7aecc70 TilePtr は SPE で計算した方がいいと判断して変更。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 161
diff changeset
97 * @param[in] tx Y coordinates of texture
38cbb7aecc70 TilePtr は SPE で計算した方がいいと判断して変更。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 161
diff changeset
98 * @param[in] twidth Width of texture
38cbb7aecc70 TilePtr は SPE で計算した方がいいと判断して変更。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 161
diff changeset
99 * @return block ID
38cbb7aecc70 TilePtr は SPE で計算した方がいいと判断して変更。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 161
diff changeset
100 */
184
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 182
diff changeset
101 int
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 182
diff changeset
102 DrawSpan::getTexBlock(int tx, int ty, int twidth)
164
38cbb7aecc70 TilePtr は SPE で計算した方がいいと判断して変更。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 161
diff changeset
103 {
38cbb7aecc70 TilePtr は SPE で計算した方がいいと判断して変更。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 161
diff changeset
104 int blockX, blockY;
128
776eca0daa02 texture load use hash table
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents: 126
diff changeset
105
164
38cbb7aecc70 TilePtr は SPE で計算した方がいいと判断して変更。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 161
diff changeset
106 blockX = tx / TEXTURE_SPLIT_PIXEL;
38cbb7aecc70 TilePtr は SPE で計算した方がいいと判断して変更。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 161
diff changeset
107 blockY = ty / TEXTURE_SPLIT_PIXEL;
38cbb7aecc70 TilePtr は SPE で計算した方がいいと判断して変更。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 161
diff changeset
108
38cbb7aecc70 TilePtr は SPE で計算した方がいいと判断して変更。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 161
diff changeset
109 return blockX + (twidth/TEXTURE_SPLIT_PIXEL)*blockY;
128
776eca0daa02 texture load use hash table
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents: 126
diff changeset
110 }
776eca0daa02 texture load use hash table
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents: 126
diff changeset
111
164
38cbb7aecc70 TilePtr は SPE で計算した方がいいと判断して変更。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 161
diff changeset
112 /**
193
gongo@localhost.localdomain
parents: 192
diff changeset
113 * block ID と、テクスチャの TOP address から
gongo@localhost.localdomain
parents: 192
diff changeset
114 * (tx,ty) で使われるテクスチャの Tile addres を求める
164
38cbb7aecc70 TilePtr は SPE で計算した方がいいと判断して変更。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 161
diff changeset
115 *
38cbb7aecc70 TilePtr は SPE で計算した方がいいと判断して変更。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 161
diff changeset
116 * @param[in] tx X coordinates of texture
38cbb7aecc70 TilePtr は SPE で計算した方がいいと判断して変更。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 161
diff changeset
117 * @param[in] tx Y coordinates of texture
38cbb7aecc70 TilePtr は SPE で計算した方がいいと判断して変更。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 161
diff changeset
118 * @param[in] tw Width of texture
193
gongo@localhost.localdomain
parents: 192
diff changeset
119 * @param[in] tex_addr_top (tx,ty) で使うテクスチャの先頭address
164
38cbb7aecc70 TilePtr は SPE で計算した方がいいと判断して変更。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 161
diff changeset
120 * @return block ID
38cbb7aecc70 TilePtr は SPE で計算した方がいいと判断して変更。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 161
diff changeset
121 */
184
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 182
diff changeset
122 uint32*
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 182
diff changeset
123 DrawSpan::getTile(int tx, int ty, int tw, uint32 *tex_addr_top)
128
776eca0daa02 texture load use hash table
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents: 126
diff changeset
124 {
184
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 182
diff changeset
125 int block = getTexBlock(tx, ty, tw);
164
38cbb7aecc70 TilePtr は SPE で計算した方がいいと判断して変更。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 161
diff changeset
126 return tex_addr_top + block*TEXTURE_BLOCK_SIZE;
128
776eca0daa02 texture load use hash table
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents: 126
diff changeset
127 }
264
a59868d37093 merge 151 263
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 148 122
diff changeset
128 =======
122
a802b19ab9ae add SceneGraph move
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents: 120
diff changeset
129 static unsigned char *tex;
264
a59868d37093 merge 151 263
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 148 122
diff changeset
130 >>>>>>> other
120
a52e193f9a42 fix Load Texture
gongo@gendarme.local
parents: 109
diff changeset
131
193
gongo@localhost.localdomain
parents: 192
diff changeset
132 /**
gongo@localhost.localdomain
parents: 192
diff changeset
133 * FrameBuffer に書き込む rgb の領域初期化
gongo@localhost.localdomain
parents: 192
diff changeset
134 *
gongo@localhost.localdomain
parents: 192
diff changeset
135 * @param width Width of Buffer
gongo@localhost.localdomain
parents: 192
diff changeset
136 * @param height Height of Buffer
gongo@localhost.localdomain
parents: 192
diff changeset
137 * @param rgb Initial value of RGB at Buffer
gongo@localhost.localdomain
parents: 192
diff changeset
138 * @return Buffer
gongo@localhost.localdomain
parents: 192
diff changeset
139 */
gongo@localhost.localdomain
parents: 192
diff changeset
140 int*
gongo@localhost.localdomain
parents: 192
diff changeset
141 DrawSpan::linebuf_init(int width, int height, int rgb)
109
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
142 {
193
gongo@localhost.localdomain
parents: 192
diff changeset
143 int *buf = (int*)smanager->allocate(sizeof(int)*width*height);
gongo@localhost.localdomain
parents: 192
diff changeset
144
gongo@localhost.localdomain
parents: 192
diff changeset
145 for (int i = 0; i < width*height; i++) {
109
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
146 buf[i] = rgb;
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
147 }
193
gongo@localhost.localdomain
parents: 192
diff changeset
148
gongo@localhost.localdomain
parents: 192
diff changeset
149 return buf;
109
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
150 }
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
151
184
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 182
diff changeset
152 /**
193
gongo@localhost.localdomain
parents: 192
diff changeset
153 * Z-Buffer の初期化
184
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 182
diff changeset
154 *
193
gongo@localhost.localdomain
parents: 192
diff changeset
155 * @param width Width of Z-Buffer
gongo@localhost.localdomain
parents: 192
diff changeset
156 * @param height Height of Z-Buffer
gongo@localhost.localdomain
parents: 192
diff changeset
157 * @return Z-Buffer
gongo@localhost.localdomain
parents: 192
diff changeset
158 */
gongo@localhost.localdomain
parents: 192
diff changeset
159 float*
gongo@localhost.localdomain
parents: 192
diff changeset
160 DrawSpan::zRow_init(int width, int height)
109
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
161 {
193
gongo@localhost.localdomain
parents: 192
diff changeset
162 float *buf = (float*)smanager->allocate(sizeof(float)*width*height);
gongo@localhost.localdomain
parents: 192
diff changeset
163 float def = 65535.0f;
gongo@localhost.localdomain
parents: 192
diff changeset
164
205
gongo@localhost.localdomain
parents: 203
diff changeset
165 #if 0
193
gongo@localhost.localdomain
parents: 192
diff changeset
166 for (int i = 0; i < width*height; i++) {
gongo@localhost.localdomain
parents: 192
diff changeset
167 buf[i] = def;
gongo@localhost.localdomain
parents: 192
diff changeset
168 }
200
10ad99550ee8 fix run_draw
gongo@localhost.localdomain
parents: 194
diff changeset
169 #else
210
204b03ca98f8 fix DrawSpan
gongo@localhost.localdomain
parents: 205
diff changeset
170 vector float init = spu_splats(0.0f);
204b03ca98f8 fix DrawSpan
gongo@localhost.localdomain
parents: 205
diff changeset
171 vector float defi = spu_splats(def);
200
10ad99550ee8 fix run_draw
gongo@localhost.localdomain
parents: 194
diff changeset
172
10ad99550ee8 fix run_draw
gongo@localhost.localdomain
parents: 194
diff changeset
173 for (int i = 0; i < width*height; i += 4) {
10ad99550ee8 fix run_draw
gongo@localhost.localdomain
parents: 194
diff changeset
174 vector float *out = (vector float *)&buf[i];
10ad99550ee8 fix run_draw
gongo@localhost.localdomain
parents: 194
diff changeset
175
10ad99550ee8 fix run_draw
gongo@localhost.localdomain
parents: 194
diff changeset
176 *out = spu_add(init, defi);
10ad99550ee8 fix run_draw
gongo@localhost.localdomain
parents: 194
diff changeset
177 }
10ad99550ee8 fix run_draw
gongo@localhost.localdomain
parents: 194
diff changeset
178 #endif
193
gongo@localhost.localdomain
parents: 192
diff changeset
179
gongo@localhost.localdomain
parents: 192
diff changeset
180 return buf;
gongo@localhost.localdomain
parents: 192
diff changeset
181 }
gongo@localhost.localdomain
parents: 192
diff changeset
182
gongo@localhost.localdomain
parents: 192
diff changeset
183
gongo@localhost.localdomain
parents: 192
diff changeset
184 /**
gongo@localhost.localdomain
parents: 192
diff changeset
185 * Span が使う Texture Tile があるか
gongo@localhost.localdomain
parents: 192
diff changeset
186 *
gongo@localhost.localdomain
parents: 192
diff changeset
187 * @retval != NULL 存在する
gongo@localhost.localdomain
parents: 192
diff changeset
188 * @retval NULL 存在しない
184
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 182
diff changeset
189 */
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 182
diff changeset
190 TilePtr
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 182
diff changeset
191 DrawSpan::isAvailableTile(uint32 *addr)
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 182
diff changeset
192 {
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 182
diff changeset
193 return hash->get(addr);
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 182
diff changeset
194 }
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 182
diff changeset
195
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 182
diff changeset
196 void
210
204b03ca98f8 fix DrawSpan
gongo@localhost.localdomain
parents: 205
diff changeset
197 DrawSpan::set_rgb(uint32 *addr, int tag)
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 TilePtr tile;
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 182
diff changeset
200
210
204b03ca98f8 fix DrawSpan
gongo@localhost.localdomain
parents: 205
diff changeset
201 if (isAvailableTile(addr)) {
204b03ca98f8 fix DrawSpan
gongo@localhost.localdomain
parents: 205
diff changeset
202 return;
204b03ca98f8 fix DrawSpan
gongo@localhost.localdomain
parents: 205
diff changeset
203 }
204b03ca98f8 fix DrawSpan
gongo@localhost.localdomain
parents: 205
diff changeset
204
193
gongo@localhost.localdomain
parents: 192
diff changeset
205 tile = tileList->nextTile();
gongo@localhost.localdomain
parents: 192
diff changeset
206 /**
gongo@localhost.localdomain
parents: 192
diff changeset
207 * FIFO なので、もし前のが残っていれば削除
gongo@localhost.localdomain
parents: 192
diff changeset
208 */
gongo@localhost.localdomain
parents: 192
diff changeset
209 hash->remove(tile->texture_addr);
gongo@localhost.localdomain
parents: 192
diff changeset
210
gongo@localhost.localdomain
parents: 192
diff changeset
211 tile->texture_addr = addr;
gongo@localhost.localdomain
parents: 192
diff changeset
212
243
52db409f255a rm warning
e065746@localhost.localdomain
parents: 233
diff changeset
213 hash->put(tile->texture_addr, tile);
193
gongo@localhost.localdomain
parents: 192
diff changeset
214 smanager->dma_load(tile->pixel, (uint32)addr,
210
204b03ca98f8 fix DrawSpan
gongo@localhost.localdomain
parents: 205
diff changeset
215 sizeof(uint32)*TEXTURE_BLOCK_SIZE, tag);
184
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 182
diff changeset
216 }
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 182
diff changeset
217
210
204b03ca98f8 fix DrawSpan
gongo@localhost.localdomain
parents: 205
diff changeset
218 /**
204b03ca98f8 fix DrawSpan
gongo@localhost.localdomain
parents: 205
diff changeset
219 *
204b03ca98f8 fix DrawSpan
gongo@localhost.localdomain
parents: 205
diff changeset
220 */
184
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 182
diff changeset
221 void
210
204b03ca98f8 fix DrawSpan
gongo@localhost.localdomain
parents: 205
diff changeset
222 DrawSpan::set_rgbs(uint32 *cur_addr, uint32 *max_addr, int wait_tag)
184
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 182
diff changeset
223 {
210
204b03ca98f8 fix DrawSpan
gongo@localhost.localdomain
parents: 205
diff changeset
224 uint32 curp = (uint32)cur_addr;
204b03ca98f8 fix DrawSpan
gongo@localhost.localdomain
parents: 205
diff changeset
225 uint32 maxp = (uint32)max_addr;
204b03ca98f8 fix DrawSpan
gongo@localhost.localdomain
parents: 205
diff changeset
226 uint32 startp = curp;
204b03ca98f8 fix DrawSpan
gongo@localhost.localdomain
parents: 205
diff changeset
227 uint32 diff = sizeof(int)*TEXTURE_BLOCK_SIZE;
204b03ca98f8 fix DrawSpan
gongo@localhost.localdomain
parents: 205
diff changeset
228 int length = (int)maxp-(int)curp;
204b03ca98f8 fix DrawSpan
gongo@localhost.localdomain
parents: 205
diff changeset
229
204b03ca98f8 fix DrawSpan
gongo@localhost.localdomain
parents: 205
diff changeset
230 int cmp = (length < 0);
193
gongo@localhost.localdomain
parents: 192
diff changeset
231
210
204b03ca98f8 fix DrawSpan
gongo@localhost.localdomain
parents: 205
diff changeset
232 #if 1
204b03ca98f8 fix DrawSpan
gongo@localhost.localdomain
parents: 205
diff changeset
233 length += cmp*(-1)*length*2;
204b03ca98f8 fix DrawSpan
gongo@localhost.localdomain
parents: 205
diff changeset
234 startp = cmp*maxp + !cmp*curp;
204b03ca98f8 fix DrawSpan
gongo@localhost.localdomain
parents: 205
diff changeset
235 #else
204b03ca98f8 fix DrawSpan
gongo@localhost.localdomain
parents: 205
diff changeset
236 if (length < 0) {
204b03ca98f8 fix DrawSpan
gongo@localhost.localdomain
parents: 205
diff changeset
237 length = -length;
204b03ca98f8 fix DrawSpan
gongo@localhost.localdomain
parents: 205
diff changeset
238 startp = maxp;
204b03ca98f8 fix DrawSpan
gongo@localhost.localdomain
parents: 205
diff changeset
239 }
204b03ca98f8 fix DrawSpan
gongo@localhost.localdomain
parents: 205
diff changeset
240 #endif
204b03ca98f8 fix DrawSpan
gongo@localhost.localdomain
parents: 205
diff changeset
241
204b03ca98f8 fix DrawSpan
gongo@localhost.localdomain
parents: 205
diff changeset
242 for (int i = 0; i <= length; i += diff) {
204b03ca98f8 fix DrawSpan
gongo@localhost.localdomain
parents: 205
diff changeset
243 set_rgb((uint32*)(startp + i), wait_tag);
109
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
244 }
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
245 }
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
246
193
gongo@localhost.localdomain
parents: 192
diff changeset
247 uint32
166
gongo@localhost.localdomain
parents: 165
diff changeset
248 DrawSpan::get_rgb(int tx, int ty, uint32 *addr)
109
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
249 {
148
9642aeef298d Span への Texture List の渡し。じゃっかん texture がバグってるので
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents: 147
diff changeset
250 TilePtr tile;
109
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
251
167
c8b868871dce DrawSpan で使う Tile の Hash の扱いは class TileHash を生成する事に。
gongo@localhost.localdomain
parents: 166
diff changeset
252 tile = hash->get(addr);
168
cf2aa37d2fe7 Delete DrawSpan::get_pixel().
gongo@localhost.localdomain
parents: 167
diff changeset
253 return tile->pixel[(TEXTURE_SPLIT_PIXEL)*ty+tx];
109
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
254 }
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
255
184
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 182
diff changeset
256 /**
193
gongo@localhost.localdomain
parents: 192
diff changeset
257 * DrawSpan の再起動 (DrawSpanRenew 生成)
184
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 182
diff changeset
258 *
193
gongo@localhost.localdomain
parents: 192
diff changeset
259 * @param[in] spack 現在処理している SpanPack
gongo@localhost.localdomain
parents: 192
diff changeset
260 * @param[in] cur_span_x span->length_x != 1 の時の Span の処理で
gongo@localhost.localdomain
parents: 192
diff changeset
261 * どこまで進んでいるか
184
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 182
diff changeset
262 */
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 182
diff changeset
263 void
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 182
diff changeset
264 DrawSpan::reboot(SpanPackPtr spack, int cur_span_x)
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 182
diff changeset
265 {
193
gongo@localhost.localdomain
parents: 192
diff changeset
266 DrawSpanArgPtr args =
gongo@localhost.localdomain
parents: 192
diff changeset
267 (DrawSpanArgPtr)smanager->allocate(sizeof(DrawSpanArg));
184
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 182
diff changeset
268 TaskPtr renew_task = smanager->create_task(TASK_DRAW_SPAN2);
164
38cbb7aecc70 TilePtr は SPE で計算した方がいいと判断して変更。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 161
diff changeset
269
193
gongo@localhost.localdomain
parents: 192
diff changeset
270 // 数が多いので構造体で渡す
gongo@localhost.localdomain
parents: 192
diff changeset
271 args->display = smanager->get_param(0);
gongo@localhost.localdomain
parents: 192
diff changeset
272 args->screen_width = smanager->get_param(1);
gongo@localhost.localdomain
parents: 192
diff changeset
273 args->rangex_start = smanager->get_param(2);
gongo@localhost.localdomain
parents: 192
diff changeset
274 args->rangex_end = smanager->get_param(3);
gongo@localhost.localdomain
parents: 192
diff changeset
275 args->rangey = smanager->get_param(4);
gongo@localhost.localdomain
parents: 192
diff changeset
276 renew_task->add_param((int)args);
164
38cbb7aecc70 TilePtr は SPE で計算した方がいいと判断して変更。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 161
diff changeset
277
184
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 182
diff changeset
278 /**
193
gongo@localhost.localdomain
parents: 192
diff changeset
279 * SpanPack は続きから開始するので、
gongo@localhost.localdomain
parents: 192
diff changeset
280 * 現在の状態をコピーしておく。
gongo@localhost.localdomain
parents: 192
diff changeset
281 * spack は rbuf から取得してる可能性があり
gongo@localhost.localdomain
parents: 192
diff changeset
282 * rbuf はシステムが自動的に free() するため
gongo@localhost.localdomain
parents: 192
diff changeset
283 * アドレスだけ渡すのはNG
184
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 182
diff changeset
284 */
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 182
diff changeset
285 SpanPackPtr curr = (SpanPackPtr)smanager->allocate(sizeof(SpanPack));
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 182
diff changeset
286 memcpy(curr, spack, sizeof(SpanPack));
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 182
diff changeset
287 renew_task->add_param((int)curr);
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 182
diff changeset
288 renew_task->add_param(cur_span_x);
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 182
diff changeset
289
193
gongo@localhost.localdomain
parents: 192
diff changeset
290 // linebuf と zRow も引き継がせる
gongo@localhost.localdomain
parents: 192
diff changeset
291 renew_task->add_param((int)linebuf);
gongo@localhost.localdomain
parents: 192
diff changeset
292 renew_task->add_param((int)zRow);
gongo@localhost.localdomain
parents: 192
diff changeset
293
184
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 182
diff changeset
294 /**
193
gongo@localhost.localdomain
parents: 192
diff changeset
295 * 再起動したタスクを待つ
184
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 182
diff changeset
296 */
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 182
diff changeset
297 smanager->wait_task(renew_task);
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 182
diff changeset
298
193
gongo@localhost.localdomain
parents: 192
diff changeset
299 // next_spack は free() するので wait する
184
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 182
diff changeset
300 smanager->dma_wait(SPAN_PACK_LOAD);
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 182
diff changeset
301 }
164
38cbb7aecc70 TilePtr は SPE で計算した方がいいと判断して変更。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 161
diff changeset
302
193
gongo@localhost.localdomain
parents: 192
diff changeset
303 void
gongo@localhost.localdomain
parents: 192
diff changeset
304 DrawSpan::writebuffer(unsigned int display, int buf_width, int height,
gongo@localhost.localdomain
parents: 192
diff changeset
305 int screen_width)
gongo@localhost.localdomain
parents: 192
diff changeset
306 {
gongo@localhost.localdomain
parents: 192
diff changeset
307 for (int i = 0; i < height; i++) {
gongo@localhost.localdomain
parents: 192
diff changeset
308 smanager->dma_store(&linebuf[i*buf_width],
gongo@localhost.localdomain
parents: 192
diff changeset
309 display + (sizeof(int)*screen_width*i),
gongo@localhost.localdomain
parents: 192
diff changeset
310 sizeof(int)*buf_width, FB_STORE);
gongo@localhost.localdomain
parents: 192
diff changeset
311 }
gongo@localhost.localdomain
parents: 192
diff changeset
312
gongo@localhost.localdomain
parents: 192
diff changeset
313 doneWrite = 1;
gongo@localhost.localdomain
parents: 192
diff changeset
314 }
gongo@localhost.localdomain
parents: 192
diff changeset
315
205
gongo@localhost.localdomain
parents: 203
diff changeset
316 /**
210
204b03ca98f8 fix DrawSpan
gongo@localhost.localdomain
parents: 205
diff changeset
317 * zRow と Linebuf を更新する
204b03ca98f8 fix DrawSpan
gongo@localhost.localdomain
parents: 205
diff changeset
318 *
204b03ca98f8 fix DrawSpan
gongo@localhost.localdomain
parents: 205
diff changeset
319 * @param zpos 更新する pixel のZ座標
204b03ca98f8 fix DrawSpan
gongo@localhost.localdomain
parents: 205
diff changeset
320 * @param rangex このタスクが処理する描画領域の x の長さ
204b03ca98f8 fix DrawSpan
gongo@localhost.localdomain
parents: 205
diff changeset
321 * @param x pixel の、描画領域内での x 座標
204b03ca98f8 fix DrawSpan
gongo@localhost.localdomain
parents: 205
diff changeset
322 * @param y 〃 の、y 座標
204b03ca98f8 fix DrawSpan
gongo@localhost.localdomain
parents: 205
diff changeset
323 * @param tex_x pixel が使用するテクスチャの、Tile (8x8) 内での x 座標
204b03ca98f8 fix DrawSpan
gongo@localhost.localdomain
parents: 205
diff changeset
324 * @param tex_y 〃 の y 座標
204b03ca98f8 fix DrawSpan
gongo@localhost.localdomain
parents: 205
diff changeset
325 * @param tex_addr テクスチャのアドレス(MainMemory)
204b03ca98f8 fix DrawSpan
gongo@localhost.localdomain
parents: 205
diff changeset
326 */
204b03ca98f8 fix DrawSpan
gongo@localhost.localdomain
parents: 205
diff changeset
327 void
204b03ca98f8 fix DrawSpan
gongo@localhost.localdomain
parents: 205
diff changeset
328 DrawSpan::updateBuffer(float zpos, int rangex, int x, int y,
204b03ca98f8 fix DrawSpan
gongo@localhost.localdomain
parents: 205
diff changeset
329 int tex_x, int tex_y, uint32 *tex_addr)
204b03ca98f8 fix DrawSpan
gongo@localhost.localdomain
parents: 205
diff changeset
330 {
204b03ca98f8 fix DrawSpan
gongo@localhost.localdomain
parents: 205
diff changeset
331 int rgb = get_rgb(tex_x, tex_y, tex_addr);
204b03ca98f8 fix DrawSpan
gongo@localhost.localdomain
parents: 205
diff changeset
332
204b03ca98f8 fix DrawSpan
gongo@localhost.localdomain
parents: 205
diff changeset
333 zRow[x + (rangex*y)] = zpos;
204b03ca98f8 fix DrawSpan
gongo@localhost.localdomain
parents: 205
diff changeset
334 linebuf[x + (rangex*y)] = rgb;
204b03ca98f8 fix DrawSpan
gongo@localhost.localdomain
parents: 205
diff changeset
335 }
204b03ca98f8 fix DrawSpan
gongo@localhost.localdomain
parents: 205
diff changeset
336
204b03ca98f8 fix DrawSpan
gongo@localhost.localdomain
parents: 205
diff changeset
337 /**
205
gongo@localhost.localdomain
parents: 203
diff changeset
338 * 長さが 1 の Span の描画 (要するに 1 pixel)
gongo@localhost.localdomain
parents: 203
diff changeset
339 *
gongo@localhost.localdomain
parents: 203
diff changeset
340 * @param span Span
gongo@localhost.localdomain
parents: 203
diff changeset
341 * @param startx 描画開始範囲
gongo@localhost.localdomain
parents: 203
diff changeset
342 * @param endx 描画終了範囲
gongo@localhost.localdomain
parents: 203
diff changeset
343 */
210
204b03ca98f8 fix DrawSpan
gongo@localhost.localdomain
parents: 205
diff changeset
344 int
204b03ca98f8 fix DrawSpan
gongo@localhost.localdomain
parents: 205
diff changeset
345 DrawSpan::drawDot1(SpanPtr span, int startx, int endx, int wait_tag)
205
gongo@localhost.localdomain
parents: 203
diff changeset
346 {
gongo@localhost.localdomain
parents: 203
diff changeset
347 int rangex = endx - startx + 1;
gongo@localhost.localdomain
parents: 203
diff changeset
348
gongo@localhost.localdomain
parents: 203
diff changeset
349 /* span->x に対応する Texture の座標 (tex_xpos, tex_ypos) */
gongo@localhost.localdomain
parents: 203
diff changeset
350 int tex_xpos, tex_ypos;
gongo@localhost.localdomain
parents: 203
diff changeset
351
gongo@localhost.localdomain
parents: 203
diff changeset
352 // span の始点に対応する Texture の座標 (tex1, tey1)
gongo@localhost.localdomain
parents: 203
diff changeset
353 float tex = span->tex_x1;
gongo@localhost.localdomain
parents: 203
diff changeset
354 float tey = span->tex_y1;
gongo@localhost.localdomain
parents: 203
diff changeset
355
gongo@localhost.localdomain
parents: 203
diff changeset
356 // span の始点に対応する z 座標
gongo@localhost.localdomain
parents: 203
diff changeset
357 float zpos = span->start_z;
gongo@localhost.localdomain
parents: 203
diff changeset
358
gongo@localhost.localdomain
parents: 203
diff changeset
359 /* Tile 内での座標 */
gongo@localhost.localdomain
parents: 203
diff changeset
360 int localx = getLocalX(span->x-1);
gongo@localhost.localdomain
parents: 203
diff changeset
361 int localy = getLocalY(span->y-1);
gongo@localhost.localdomain
parents: 203
diff changeset
362
gongo@localhost.localdomain
parents: 203
diff changeset
363 /**
gongo@localhost.localdomain
parents: 203
diff changeset
364 * (tex_xpos, tex_ypos) の、Tile 内(上の図参照)での座標と
gongo@localhost.localdomain
parents: 203
diff changeset
365 * そのブロックのアドレス(MainMemory)
gongo@localhost.localdomain
parents: 203
diff changeset
366 */
gongo@localhost.localdomain
parents: 203
diff changeset
367 int tex_localx;
gongo@localhost.localdomain
parents: 203
diff changeset
368 int tex_localy;
gongo@localhost.localdomain
parents: 203
diff changeset
369 uint32 *tex_addr;
gongo@localhost.localdomain
parents: 203
diff changeset
370
gongo@localhost.localdomain
parents: 203
diff changeset
371 if (span->x < startx || endx < span->x) {
210
204b03ca98f8 fix DrawSpan
gongo@localhost.localdomain
parents: 205
diff changeset
372 return -1;
205
gongo@localhost.localdomain
parents: 203
diff changeset
373 }
gongo@localhost.localdomain
parents: 203
diff changeset
374
gongo@localhost.localdomain
parents: 203
diff changeset
375 tex_xpos = (int)((span->tex_width-1) * tex);
gongo@localhost.localdomain
parents: 203
diff changeset
376 tex_ypos = (int)((span->tex_height-1) * tey);
gongo@localhost.localdomain
parents: 203
diff changeset
377
gongo@localhost.localdomain
parents: 203
diff changeset
378 if (zpos < zRow[localx + (rangex*localy)]) {
gongo@localhost.localdomain
parents: 203
diff changeset
379 tex_addr = getTile(tex_xpos, tex_ypos,
gongo@localhost.localdomain
parents: 203
diff changeset
380 span->tex_width, span->tex_addr);
gongo@localhost.localdomain
parents: 203
diff changeset
381 tex_localx = tex_xpos % TEXTURE_SPLIT_PIXEL;
gongo@localhost.localdomain
parents: 203
diff changeset
382 tex_localy = tex_ypos % TEXTURE_SPLIT_PIXEL;
gongo@localhost.localdomain
parents: 203
diff changeset
383
gongo@localhost.localdomain
parents: 203
diff changeset
384 if (!isAvailableTile(tex_addr)) {
210
204b03ca98f8 fix DrawSpan
gongo@localhost.localdomain
parents: 205
diff changeset
385 set_rgb(tex_addr, wait_tag);
204b03ca98f8 fix DrawSpan
gongo@localhost.localdomain
parents: 205
diff changeset
386 smanager->dma_wait(wait_tag);
204b03ca98f8 fix DrawSpan
gongo@localhost.localdomain
parents: 205
diff changeset
387 //return startx;
205
gongo@localhost.localdomain
parents: 203
diff changeset
388 }
gongo@localhost.localdomain
parents: 203
diff changeset
389
210
204b03ca98f8 fix DrawSpan
gongo@localhost.localdomain
parents: 205
diff changeset
390 updateBuffer(zpos, rangex, localx, localy,
204b03ca98f8 fix DrawSpan
gongo@localhost.localdomain
parents: 205
diff changeset
391 tex_localx, tex_localy, tex_addr);
205
gongo@localhost.localdomain
parents: 203
diff changeset
392 }
210
204b03ca98f8 fix DrawSpan
gongo@localhost.localdomain
parents: 205
diff changeset
393
204b03ca98f8 fix DrawSpan
gongo@localhost.localdomain
parents: 205
diff changeset
394 return -1;
205
gongo@localhost.localdomain
parents: 203
diff changeset
395 }
gongo@localhost.localdomain
parents: 203
diff changeset
396
gongo@localhost.localdomain
parents: 203
diff changeset
397 void
210
204b03ca98f8 fix DrawSpan
gongo@localhost.localdomain
parents: 205
diff changeset
398 DrawSpan::drawDot2(SpanPtr span, int startx, int end, int js, int wait_tag)
204b03ca98f8 fix DrawSpan
gongo@localhost.localdomain
parents: 205
diff changeset
399 {
204b03ca98f8 fix DrawSpan
gongo@localhost.localdomain
parents: 205
diff changeset
400 //printf("%d\n", js);
204b03ca98f8 fix DrawSpan
gongo@localhost.localdomain
parents: 205
diff changeset
401 }
204b03ca98f8 fix DrawSpan
gongo@localhost.localdomain
parents: 205
diff changeset
402
233
gongo@localhost.localdomain
parents: 213
diff changeset
403 /**
gongo@localhost.localdomain
parents: 213
diff changeset
404 * 長さが 1 より大きい Span の描画
gongo@localhost.localdomain
parents: 213
diff changeset
405 *
gongo@localhost.localdomain
parents: 213
diff changeset
406 * 本来の目的として、この関数(drawLine1) では
gongo@localhost.localdomain
parents: 213
diff changeset
407 * : 既に SPE 上に Tile のある pixel だけ描画
gongo@localhost.localdomain
parents: 213
diff changeset
408 * : それ以外は、ここで予め DMA load しておき、
gongo@localhost.localdomain
parents: 213
diff changeset
409 * : drawLine2 で一気に描画する
gongo@localhost.localdomain
parents: 213
diff changeset
410 * ってものだったんだけど、どうも上手く行かなかったので
gongo@localhost.localdomain
parents: 213
diff changeset
411 * 今は drawLine1 で load -> wait -> rendering を全部やってます
gongo@localhost.localdomain
parents: 213
diff changeset
412 * (rendering といっても、rendering buffer に書き込むだけで
gongo@localhost.localdomain
parents: 213
diff changeset
413 * まだ main memory (frame buffer) に dma store してるわけではない)
gongo@localhost.localdomain
parents: 213
diff changeset
414 *
gongo@localhost.localdomain
parents: 213
diff changeset
415 * @param span Span
gongo@localhost.localdomain
parents: 213
diff changeset
416 * @param startx 描画開始範囲
gongo@localhost.localdomain
parents: 213
diff changeset
417 * @param endx 描画終了範囲
gongo@localhost.localdomain
parents: 213
diff changeset
418 * @return 「span のどの位置まで rendering が終わったか」の x 座標
gongo@localhost.localdomain
parents: 213
diff changeset
419 */
210
204b03ca98f8 fix DrawSpan
gongo@localhost.localdomain
parents: 205
diff changeset
420 int
204b03ca98f8 fix DrawSpan
gongo@localhost.localdomain
parents: 205
diff changeset
421 DrawSpan::drawLine1(SpanPtr span, int startx, int endx, int wait_tag)
205
gongo@localhost.localdomain
parents: 203
diff changeset
422 {
gongo@localhost.localdomain
parents: 203
diff changeset
423 int x = span->x;
gongo@localhost.localdomain
parents: 203
diff changeset
424 int rangex = endx - startx + 1;
gongo@localhost.localdomain
parents: 203
diff changeset
425 int x_len = span->length_x;
gongo@localhost.localdomain
parents: 203
diff changeset
426
gongo@localhost.localdomain
parents: 203
diff changeset
427 int js = (x < startx) ? startx - x : 0;
gongo@localhost.localdomain
parents: 203
diff changeset
428 int je = (x + x_len > endx) ? endx - x : x_len;
gongo@localhost.localdomain
parents: 203
diff changeset
429
gongo@localhost.localdomain
parents: 203
diff changeset
430 /* span->x に対応する Texture の座標 (tex_xpos, tex_ypos) */
gongo@localhost.localdomain
parents: 203
diff changeset
431 int tex_xpos, tex_ypos;
gongo@localhost.localdomain
parents: 203
diff changeset
432
gongo@localhost.localdomain
parents: 203
diff changeset
433 // span の始点に対応する座標 (tex1, tey1)
gongo@localhost.localdomain
parents: 203
diff changeset
434 float tex1 = span->tex_x1;
gongo@localhost.localdomain
parents: 203
diff changeset
435 float tey1 = span->tex_y1;
gongo@localhost.localdomain
parents: 203
diff changeset
436
gongo@localhost.localdomain
parents: 203
diff changeset
437 // span の終点に対応する座標 (tex2, tey2)
gongo@localhost.localdomain
parents: 203
diff changeset
438 float tex2 = span->tex_x2;
gongo@localhost.localdomain
parents: 203
diff changeset
439 float tey2 = span->tex_y2;
gongo@localhost.localdomain
parents: 203
diff changeset
440
gongo@localhost.localdomain
parents: 203
diff changeset
441 // span の始点、終点に対応する z 座標
gongo@localhost.localdomain
parents: 203
diff changeset
442 float zpos1 = span->start_z;
gongo@localhost.localdomain
parents: 203
diff changeset
443 float zpos2 = span->end_z;
gongo@localhost.localdomain
parents: 203
diff changeset
444
gongo@localhost.localdomain
parents: 203
diff changeset
445 // Tile 内での座標
gongo@localhost.localdomain
parents: 203
diff changeset
446 int localx, localy = getLocalY(span->y-1);
gongo@localhost.localdomain
parents: 203
diff changeset
447
210
204b03ca98f8 fix DrawSpan
gongo@localhost.localdomain
parents: 205
diff changeset
448 int ret = je+1;
204b03ca98f8 fix DrawSpan
gongo@localhost.localdomain
parents: 205
diff changeset
449
204b03ca98f8 fix DrawSpan
gongo@localhost.localdomain
parents: 205
diff changeset
450 //for (int j = js; j <= je; j++) {
204b03ca98f8 fix DrawSpan
gongo@localhost.localdomain
parents: 205
diff changeset
451 for (int j = je; j >= js; j--) {
204b03ca98f8 fix DrawSpan
gongo@localhost.localdomain
parents: 205
diff changeset
452 float tex_x, tex_y, tex_z;
204b03ca98f8 fix DrawSpan
gongo@localhost.localdomain
parents: 205
diff changeset
453
204b03ca98f8 fix DrawSpan
gongo@localhost.localdomain
parents: 205
diff changeset
454 localx = getLocalX(x-1+j);
204b03ca98f8 fix DrawSpan
gongo@localhost.localdomain
parents: 205
diff changeset
455
204b03ca98f8 fix DrawSpan
gongo@localhost.localdomain
parents: 205
diff changeset
456 tex_z = zpos1*(x_len-1-j)/(x_len-1) + zpos2*j/(x_len-1);
204b03ca98f8 fix DrawSpan
gongo@localhost.localdomain
parents: 205
diff changeset
457
204b03ca98f8 fix DrawSpan
gongo@localhost.localdomain
parents: 205
diff changeset
458 tex_x = tex1*(x_len-1-j)/(x_len-1) + tex2*j/(x_len-1);
204b03ca98f8 fix DrawSpan
gongo@localhost.localdomain
parents: 205
diff changeset
459 tex_y = tey1*(x_len-1-j)/(x_len-1) + tey2*j/(x_len-1);
204b03ca98f8 fix DrawSpan
gongo@localhost.localdomain
parents: 205
diff changeset
460 if (tex_x > 1) tex_x = 1;
204b03ca98f8 fix DrawSpan
gongo@localhost.localdomain
parents: 205
diff changeset
461 if (tex_x < 0) tex_x = 0;
204b03ca98f8 fix DrawSpan
gongo@localhost.localdomain
parents: 205
diff changeset
462 if (tex_y > 1) tex_y = 1;
204b03ca98f8 fix DrawSpan
gongo@localhost.localdomain
parents: 205
diff changeset
463 if (tex_y < 0) tex_y = 0;
204b03ca98f8 fix DrawSpan
gongo@localhost.localdomain
parents: 205
diff changeset
464 tex_xpos = (int)((span->tex_width-1) * tex_x);
204b03ca98f8 fix DrawSpan
gongo@localhost.localdomain
parents: 205
diff changeset
465 tex_ypos = (int)((span->tex_height-1) * tex_y);
204b03ca98f8 fix DrawSpan
gongo@localhost.localdomain
parents: 205
diff changeset
466
204b03ca98f8 fix DrawSpan
gongo@localhost.localdomain
parents: 205
diff changeset
467 if (tex_z < zRow[localx + (rangex*localy)]) {
204b03ca98f8 fix DrawSpan
gongo@localhost.localdomain
parents: 205
diff changeset
468 // (tex_xpos, tex_ypos) の、Tile 内(上の図参照)での座標と
204b03ca98f8 fix DrawSpan
gongo@localhost.localdomain
parents: 205
diff changeset
469 // そのブロックのアドレス(MainMemory)
204b03ca98f8 fix DrawSpan
gongo@localhost.localdomain
parents: 205
diff changeset
470 uint32 *tex_addr;
204b03ca98f8 fix DrawSpan
gongo@localhost.localdomain
parents: 205
diff changeset
471 int tex_localx;
204b03ca98f8 fix DrawSpan
gongo@localhost.localdomain
parents: 205
diff changeset
472 int tex_localy;
204b03ca98f8 fix DrawSpan
gongo@localhost.localdomain
parents: 205
diff changeset
473
204b03ca98f8 fix DrawSpan
gongo@localhost.localdomain
parents: 205
diff changeset
474 tex_addr = getTile(tex_xpos, tex_ypos,
204b03ca98f8 fix DrawSpan
gongo@localhost.localdomain
parents: 205
diff changeset
475 span->tex_width, span->tex_addr);
204b03ca98f8 fix DrawSpan
gongo@localhost.localdomain
parents: 205
diff changeset
476 tex_localx = tex_xpos % TEXTURE_SPLIT_PIXEL;
204b03ca98f8 fix DrawSpan
gongo@localhost.localdomain
parents: 205
diff changeset
477 tex_localy = tex_ypos % TEXTURE_SPLIT_PIXEL;
204b03ca98f8 fix DrawSpan
gongo@localhost.localdomain
parents: 205
diff changeset
478
204b03ca98f8 fix DrawSpan
gongo@localhost.localdomain
parents: 205
diff changeset
479 if (!isAvailableTile(tex_addr)) {
211
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 210
diff changeset
480 #if 0
233
gongo@localhost.localdomain
parents: 213
diff changeset
481 // span が必要とするであろう tile を予想紙
gongo@localhost.localdomain
parents: 213
diff changeset
482 // set_rgbs で複数同時に load しようとしている図
gongo@localhost.localdomain
parents: 213
diff changeset
483 // まあ上手くいかなかったんだけど。。
210
204b03ca98f8 fix DrawSpan
gongo@localhost.localdomain
parents: 205
diff changeset
484 tex_x = tex1*(x_len-1-js)/(x_len-1) + tex2*js/(x_len-1);
204b03ca98f8 fix DrawSpan
gongo@localhost.localdomain
parents: 205
diff changeset
485 if (tex_x > 1) tex_x = 1;
204b03ca98f8 fix DrawSpan
gongo@localhost.localdomain
parents: 205
diff changeset
486 if (tex_x < 0) tex_x = 0;
204b03ca98f8 fix DrawSpan
gongo@localhost.localdomain
parents: 205
diff changeset
487 tex_xpos = (int)((span->tex_width-1) * tex_x);
204b03ca98f8 fix DrawSpan
gongo@localhost.localdomain
parents: 205
diff changeset
488
204b03ca98f8 fix DrawSpan
gongo@localhost.localdomain
parents: 205
diff changeset
489 uint32 *max_addr = getTile(tex_xpos, tex_ypos,
204b03ca98f8 fix DrawSpan
gongo@localhost.localdomain
parents: 205
diff changeset
490 span->tex_width, span->tex_addr);
204b03ca98f8 fix DrawSpan
gongo@localhost.localdomain
parents: 205
diff changeset
491
204b03ca98f8 fix DrawSpan
gongo@localhost.localdomain
parents: 205
diff changeset
492 set_rgbs(tex_addr, max_addr, wait_tag);
204b03ca98f8 fix DrawSpan
gongo@localhost.localdomain
parents: 205
diff changeset
493 return js;
204b03ca98f8 fix DrawSpan
gongo@localhost.localdomain
parents: 205
diff changeset
494 #else
204b03ca98f8 fix DrawSpan
gongo@localhost.localdomain
parents: 205
diff changeset
495 set_rgb(tex_addr, wait_tag);
212
gongo@localhost.localdomain
parents: 211
diff changeset
496 smanager->dma_wait(wait_tag);
210
204b03ca98f8 fix DrawSpan
gongo@localhost.localdomain
parents: 205
diff changeset
497 #endif
204b03ca98f8 fix DrawSpan
gongo@localhost.localdomain
parents: 205
diff changeset
498 }
204b03ca98f8 fix DrawSpan
gongo@localhost.localdomain
parents: 205
diff changeset
499
204b03ca98f8 fix DrawSpan
gongo@localhost.localdomain
parents: 205
diff changeset
500 updateBuffer(tex_z, rangex, localx, localy,
204b03ca98f8 fix DrawSpan
gongo@localhost.localdomain
parents: 205
diff changeset
501 tex_localx, tex_localy, tex_addr);
204b03ca98f8 fix DrawSpan
gongo@localhost.localdomain
parents: 205
diff changeset
502 }
204b03ca98f8 fix DrawSpan
gongo@localhost.localdomain
parents: 205
diff changeset
503 }
204b03ca98f8 fix DrawSpan
gongo@localhost.localdomain
parents: 205
diff changeset
504
204b03ca98f8 fix DrawSpan
gongo@localhost.localdomain
parents: 205
diff changeset
505 return ret;
204b03ca98f8 fix DrawSpan
gongo@localhost.localdomain
parents: 205
diff changeset
506 }
204b03ca98f8 fix DrawSpan
gongo@localhost.localdomain
parents: 205
diff changeset
507
233
gongo@localhost.localdomain
parents: 213
diff changeset
508 /**
gongo@localhost.localdomain
parents: 213
diff changeset
509 * 長さが 1 より大きい Span の描画 (2段階目)
gongo@localhost.localdomain
parents: 213
diff changeset
510 *
gongo@localhost.localdomain
parents: 213
diff changeset
511 * 上にあるように、drawLine2 は今は動いてないです
gongo@localhost.localdomain
parents: 213
diff changeset
512 * 正確には、js が startx ~ endx 範囲外にあり開始されないってところ
gongo@localhost.localdomain
parents: 213
diff changeset
513 *
gongo@localhost.localdomain
parents: 213
diff changeset
514 * @param span Span
gongo@localhost.localdomain
parents: 213
diff changeset
515 * @param startx 描画開始範囲
gongo@localhost.localdomain
parents: 213
diff changeset
516 * @param endx 描画終了範囲
gongo@localhost.localdomain
parents: 213
diff changeset
517 * @param js 前回(drawLine1) で span のどこまで終わっているか
gongo@localhost.localdomain
parents: 213
diff changeset
518 */
210
204b03ca98f8 fix DrawSpan
gongo@localhost.localdomain
parents: 205
diff changeset
519 void
204b03ca98f8 fix DrawSpan
gongo@localhost.localdomain
parents: 205
diff changeset
520 DrawSpan::drawLine2(SpanPtr span, int startx, int endx, int js, int wait_tag)
204b03ca98f8 fix DrawSpan
gongo@localhost.localdomain
parents: 205
diff changeset
521 {
204b03ca98f8 fix DrawSpan
gongo@localhost.localdomain
parents: 205
diff changeset
522 int x = span->x;
204b03ca98f8 fix DrawSpan
gongo@localhost.localdomain
parents: 205
diff changeset
523 int rangex = endx - startx + 1;
204b03ca98f8 fix DrawSpan
gongo@localhost.localdomain
parents: 205
diff changeset
524 int x_len = span->length_x;
204b03ca98f8 fix DrawSpan
gongo@localhost.localdomain
parents: 205
diff changeset
525
204b03ca98f8 fix DrawSpan
gongo@localhost.localdomain
parents: 205
diff changeset
526 //int js = startx;
204b03ca98f8 fix DrawSpan
gongo@localhost.localdomain
parents: 205
diff changeset
527 int je = (x + x_len > endx) ? endx - x : x_len;
204b03ca98f8 fix DrawSpan
gongo@localhost.localdomain
parents: 205
diff changeset
528
204b03ca98f8 fix DrawSpan
gongo@localhost.localdomain
parents: 205
diff changeset
529 /* span->x に対応する Texture の座標 (tex_xpos, tex_ypos) */
204b03ca98f8 fix DrawSpan
gongo@localhost.localdomain
parents: 205
diff changeset
530 int tex_xpos, tex_ypos;
204b03ca98f8 fix DrawSpan
gongo@localhost.localdomain
parents: 205
diff changeset
531
204b03ca98f8 fix DrawSpan
gongo@localhost.localdomain
parents: 205
diff changeset
532 // span の始点に対応する座標 (tex1, tey1)
204b03ca98f8 fix DrawSpan
gongo@localhost.localdomain
parents: 205
diff changeset
533 float tex1 = span->tex_x1;
204b03ca98f8 fix DrawSpan
gongo@localhost.localdomain
parents: 205
diff changeset
534 float tey1 = span->tex_y1;
204b03ca98f8 fix DrawSpan
gongo@localhost.localdomain
parents: 205
diff changeset
535
204b03ca98f8 fix DrawSpan
gongo@localhost.localdomain
parents: 205
diff changeset
536 // span の終点に対応する座標 (tex2, tey2)
204b03ca98f8 fix DrawSpan
gongo@localhost.localdomain
parents: 205
diff changeset
537 float tex2 = span->tex_x2;
204b03ca98f8 fix DrawSpan
gongo@localhost.localdomain
parents: 205
diff changeset
538 float tey2 = span->tex_y2;
204b03ca98f8 fix DrawSpan
gongo@localhost.localdomain
parents: 205
diff changeset
539
204b03ca98f8 fix DrawSpan
gongo@localhost.localdomain
parents: 205
diff changeset
540 // span の始点、終点に対応する z 座標
204b03ca98f8 fix DrawSpan
gongo@localhost.localdomain
parents: 205
diff changeset
541 float zpos1 = span->start_z;
204b03ca98f8 fix DrawSpan
gongo@localhost.localdomain
parents: 205
diff changeset
542 float zpos2 = span->end_z;
204b03ca98f8 fix DrawSpan
gongo@localhost.localdomain
parents: 205
diff changeset
543
204b03ca98f8 fix DrawSpan
gongo@localhost.localdomain
parents: 205
diff changeset
544 // Tile 内での座標
204b03ca98f8 fix DrawSpan
gongo@localhost.localdomain
parents: 205
diff changeset
545 int localx, localy = getLocalY(span->y-1);
204b03ca98f8 fix DrawSpan
gongo@localhost.localdomain
parents: 205
diff changeset
546
205
gongo@localhost.localdomain
parents: 203
diff changeset
547 // (tex_xpos, tex_ypos) の、Tile 内(上の図参照)での座標と
gongo@localhost.localdomain
parents: 203
diff changeset
548 // そのブロックのアドレス(MainMemory)
gongo@localhost.localdomain
parents: 203
diff changeset
549 int tex_localx;
gongo@localhost.localdomain
parents: 203
diff changeset
550 int tex_localy;
gongo@localhost.localdomain
parents: 203
diff changeset
551 uint32 *tex_addr;
gongo@localhost.localdomain
parents: 203
diff changeset
552
gongo@localhost.localdomain
parents: 203
diff changeset
553 float tex_x, tex_y, tex_z;
gongo@localhost.localdomain
parents: 203
diff changeset
554
210
204b03ca98f8 fix DrawSpan
gongo@localhost.localdomain
parents: 205
diff changeset
555 smanager->dma_wait(wait_tag);
204b03ca98f8 fix DrawSpan
gongo@localhost.localdomain
parents: 205
diff changeset
556
205
gongo@localhost.localdomain
parents: 203
diff changeset
557 for (int j = js; j <= je; j++) {
gongo@localhost.localdomain
parents: 203
diff changeset
558 localx = getLocalX(x-1+j);
gongo@localhost.localdomain
parents: 203
diff changeset
559
gongo@localhost.localdomain
parents: 203
diff changeset
560 tex_z = zpos1*(x_len-1-j)/(x_len-1) + zpos2*j/(x_len-1);
gongo@localhost.localdomain
parents: 203
diff changeset
561
gongo@localhost.localdomain
parents: 203
diff changeset
562 tex_x = tex1*(x_len-1-j)/(x_len-1) + tex2*j/(x_len-1);
gongo@localhost.localdomain
parents: 203
diff changeset
563 tex_y = tey1*(x_len-1-j)/(x_len-1) + tey2*j/(x_len-1);
gongo@localhost.localdomain
parents: 203
diff changeset
564 if (tex_x > 1) tex_x = 1;
gongo@localhost.localdomain
parents: 203
diff changeset
565 if (tex_x < 0) tex_x = 0;
gongo@localhost.localdomain
parents: 203
diff changeset
566 if (tex_y > 1) tex_y = 1;
gongo@localhost.localdomain
parents: 203
diff changeset
567 if (tex_y < 0) tex_y = 0;
gongo@localhost.localdomain
parents: 203
diff changeset
568 tex_xpos = (int)((span->tex_width-1) * tex_x);
gongo@localhost.localdomain
parents: 203
diff changeset
569 tex_ypos = (int)((span->tex_height-1) * tex_y);
210
204b03ca98f8 fix DrawSpan
gongo@localhost.localdomain
parents: 205
diff changeset
570
205
gongo@localhost.localdomain
parents: 203
diff changeset
571 if (tex_z < zRow[localx + (rangex*localy)]) {
gongo@localhost.localdomain
parents: 203
diff changeset
572 tex_addr = getTile(tex_xpos, tex_ypos,
gongo@localhost.localdomain
parents: 203
diff changeset
573 span->tex_width, span->tex_addr);
gongo@localhost.localdomain
parents: 203
diff changeset
574 tex_localx = tex_xpos % TEXTURE_SPLIT_PIXEL;
gongo@localhost.localdomain
parents: 203
diff changeset
575 tex_localy = tex_ypos % TEXTURE_SPLIT_PIXEL;
gongo@localhost.localdomain
parents: 203
diff changeset
576
210
204b03ca98f8 fix DrawSpan
gongo@localhost.localdomain
parents: 205
diff changeset
577 updateBuffer(tex_z, rangex, localx, localy,
204b03ca98f8 fix DrawSpan
gongo@localhost.localdomain
parents: 205
diff changeset
578 tex_localx, tex_localy, tex_addr);
205
gongo@localhost.localdomain
parents: 203
diff changeset
579 }
210
204b03ca98f8 fix DrawSpan
gongo@localhost.localdomain
parents: 205
diff changeset
580 }
205
gongo@localhost.localdomain
parents: 203
diff changeset
581 }
109
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
582
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
583 int
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
584 DrawSpan::run(void *rbuf, void *wbuf)
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
585 {
193
gongo@localhost.localdomain
parents: 192
diff changeset
586 SpanPackPtr spack = (SpanPackPtr)smanager->get_input(0);
gongo@localhost.localdomain
parents: 192
diff changeset
587 SpanPackPtr next_spack = (SpanPackPtr)smanager->allocate(sizeof(SpanPack));
gongo@localhost.localdomain
parents: 192
diff changeset
588 SpanPackPtr free_spack = next_spack; // next_spack の free() 用
109
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
589 Span *span;
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
590
210
204b03ca98f8 fix DrawSpan
gongo@localhost.localdomain
parents: 205
diff changeset
591 Span nop_span;
204b03ca98f8 fix DrawSpan
gongo@localhost.localdomain
parents: 205
diff changeset
592 nop_span.length_x = 1;
204b03ca98f8 fix DrawSpan
gongo@localhost.localdomain
parents: 205
diff changeset
593
204b03ca98f8 fix DrawSpan
gongo@localhost.localdomain
parents: 205
diff changeset
594 int (DrawSpan::*drawFunc1[2])(SpanPtr, int, int, int) = {
204b03ca98f8 fix DrawSpan
gongo@localhost.localdomain
parents: 205
diff changeset
595 &DrawSpan::drawDot1, &DrawSpan::drawLine1
204b03ca98f8 fix DrawSpan
gongo@localhost.localdomain
parents: 205
diff changeset
596 };
204b03ca98f8 fix DrawSpan
gongo@localhost.localdomain
parents: 205
diff changeset
597
204b03ca98f8 fix DrawSpan
gongo@localhost.localdomain
parents: 205
diff changeset
598 void (DrawSpan::*drawFunc2[2])(SpanPtr, int, int, int, int) = {
204b03ca98f8 fix DrawSpan
gongo@localhost.localdomain
parents: 205
diff changeset
599 &DrawSpan::drawDot2, &DrawSpan::drawLine2
205
gongo@localhost.localdomain
parents: 203
diff changeset
600 };
gongo@localhost.localdomain
parents: 203
diff changeset
601
193
gongo@localhost.localdomain
parents: 192
diff changeset
602 uint32 display = smanager->get_param(0);
gongo@localhost.localdomain
parents: 192
diff changeset
603 int screen_width = smanager->get_param(1);
gongo@localhost.localdomain
parents: 192
diff changeset
604 int rangex_start = smanager->get_param(2);
gongo@localhost.localdomain
parents: 192
diff changeset
605 int rangex_end = smanager->get_param(3);
210
204b03ca98f8 fix DrawSpan
gongo@localhost.localdomain
parents: 205
diff changeset
606
193
gongo@localhost.localdomain
parents: 192
diff changeset
607 // このタスクが担当する x の範囲
gongo@localhost.localdomain
parents: 192
diff changeset
608 int rangex = rangex_end - rangex_start + 1;
gongo@localhost.localdomain
parents: 192
diff changeset
609
gongo@localhost.localdomain
parents: 192
diff changeset
610 // y の範囲
gongo@localhost.localdomain
parents: 192
diff changeset
611 int rangey = smanager->get_param(4);
203
5c6c9667ac61 fix CreateSpan::run
gongo@localhost.localdomain
parents: 200
diff changeset
612
167
c8b868871dce DrawSpan で使う Tile の Hash の扱いは class TileHash を生成する事に。
gongo@localhost.localdomain
parents: 166
diff changeset
613 hash = (TileHashPtr)smanager->global_get(GLOBAL_TEXTURE_HASH);
c8b868871dce DrawSpan で使う Tile の Hash の扱いは class TileHash を生成する事に。
gongo@localhost.localdomain
parents: 166
diff changeset
614 tileList = (TileListPtr)smanager->global_get(GLOBAL_TILE_LIST);
109
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
615
193
gongo@localhost.localdomain
parents: 192
diff changeset
616 zRow = zRow_init(rangex, rangey);
213
159519cdca1f add SceneGraph "3D Super-Dandy"
gongo@localhost.localdomain
parents: 212
diff changeset
617 //linebuf = linebuf_init(rangex, rangey, 0x00ffffff);
159519cdca1f add SceneGraph "3D Super-Dandy"
gongo@localhost.localdomain
parents: 212
diff changeset
618 linebuf = linebuf_init(rangex, rangey, 0);
184
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 182
diff changeset
619
193
gongo@localhost.localdomain
parents: 192
diff changeset
620 doneWrite = 0;
182
df3cfc04e796 add get_inputAddr, get_outputAddr
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 180
diff changeset
621
210
204b03ca98f8 fix DrawSpan
gongo@localhost.localdomain
parents: 205
diff changeset
622 int tl_tag[2] = {TEX_LOAD1, TEX_LOAD2};
204b03ca98f8 fix DrawSpan
gongo@localhost.localdomain
parents: 205
diff changeset
623 int tl_tag_flg1 = 0;
204b03ca98f8 fix DrawSpan
gongo@localhost.localdomain
parents: 205
diff changeset
624 int tl_tag_flg2 = 1;
177
e742053c4c87 zRow の生成、初期化の変更
gongo@localhost.localdomain
parents: 174
diff changeset
625
267
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 243 266
diff changeset
626 <<<<<<< local
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 243 266
diff changeset
627 =======
177
e742053c4c87 zRow の生成、初期化の変更
gongo@localhost.localdomain
parents: 174
diff changeset
628 float *zRow = (float*)smanager->get_input(1);
109
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
629 int **linebuf = (int**)smanager->allocate(sizeof(int*)*rangey);
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
630
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
631 for (int i = 0; i < rangey; i++) {
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
632 linebuf[i] = (int*)smanager->get_output(i);
264
a59868d37093 merge 151 263
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 148 122
diff changeset
633 <<<<<<< local
170
d1f2ce3bdb2f fix ViewerSDL
gongo@localhost.localdomain
parents: 168
diff changeset
634 linebuf_init(linebuf[i], rangex, 0xffffffff);
265
d949e590da26 merge 172 264
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 170 264
diff changeset
635 =======
d949e590da26 merge 172 264
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 170 264
diff changeset
636 <<<<<<< local
133
435e0d24db39 DrawSpan のテクスチャ座標を求める部分で、width と height が逆に使われてた。
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents: 131
diff changeset
637 linebuf_init(linebuf[i], rangex, 0xffffff);
264
a59868d37093 merge 151 263
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 148 122
diff changeset
638 =======
122
a802b19ab9ae add SceneGraph move
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents: 120
diff changeset
639 //linebuf_init(linebuf[i], rangex, 0x00ff00ff);
a802b19ab9ae add SceneGraph move
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents: 120
diff changeset
640 linebuf_init(linebuf[i], rangex, 0);
264
a59868d37093 merge 151 263
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 148 122
diff changeset
641 >>>>>>> other
265
d949e590da26 merge 172 264
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 170 264
diff changeset
642 >>>>>>> other
109
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
643 }
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
644
267
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 243 266
diff changeset
645 >>>>>>> other
109
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
646 do {
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
647 /**
193
gongo@localhost.localdomain
parents: 192
diff changeset
648 * SpanPack->next が存在する場合、
gongo@localhost.localdomain
parents: 192
diff changeset
649 * 現在の SpanPack を処理してる間に
gongo@localhost.localdomain
parents: 192
diff changeset
650 * 次の SpanPack の DMA 転送を行う
109
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
651 */
182
df3cfc04e796 add get_inputAddr, get_outputAddr
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 180
diff changeset
652 if (spack->next != NULL) {
df3cfc04e796 add get_inputAddr, get_outputAddr
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 180
diff changeset
653 smanager->dma_load(next_spack, (uint32)spack->next,
109
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
654 sizeof(SpanPack), SPAN_PACK_LOAD);
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
655 } else {
182
df3cfc04e796 add get_inputAddr, get_outputAddr
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 180
diff changeset
656 next_spack = NULL;
109
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
657 }
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
658
267
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 243 266
diff changeset
659 <<<<<<< local
210
204b03ca98f8 fix DrawSpan
gongo@localhost.localdomain
parents: 205
diff changeset
660 SpanPtr resume_span = &nop_span;
204b03ca98f8 fix DrawSpan
gongo@localhost.localdomain
parents: 205
diff changeset
661 int resume_span_x = 0;
109
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
662
182
df3cfc04e796 add get_inputAddr, get_outputAddr
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 180
diff changeset
663 for (int t = 0; t < spack->info.size; t++) {
210
204b03ca98f8 fix DrawSpan
gongo@localhost.localdomain
parents: 205
diff changeset
664 SpanPtr next_span;
204b03ca98f8 fix DrawSpan
gongo@localhost.localdomain
parents: 205
diff changeset
665 int next_span_x;
147
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents: 133
diff changeset
666
267
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 243 266
diff changeset
667 =======
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 243 266
diff changeset
668 for (int t = spack->info.start; t < spack->info.size; t++) {
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 243 266
diff changeset
669 >>>>>>> other
182
df3cfc04e796 add get_inputAddr, get_outputAddr
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 180
diff changeset
670 span = &spack->span[t];
164
38cbb7aecc70 TilePtr は SPE で計算した方がいいと判断して変更。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 161
diff changeset
671
166
gongo@localhost.localdomain
parents: 165
diff changeset
672 /**
233
gongo@localhost.localdomain
parents: 213
diff changeset
673 * span の長さによって、drawLine か drawDot を選択している
gongo@localhost.localdomain
parents: 213
diff changeset
674 */
210
204b03ca98f8 fix DrawSpan
gongo@localhost.localdomain
parents: 205
diff changeset
675 next_span_x
204b03ca98f8 fix DrawSpan
gongo@localhost.localdomain
parents: 205
diff changeset
676 = (this->*drawFunc1[(span->length_x != 1)])(
204b03ca98f8 fix DrawSpan
gongo@localhost.localdomain
parents: 205
diff changeset
677 span, rangex_start, rangex_end, tl_tag[tl_tag_flg1]);
204b03ca98f8 fix DrawSpan
gongo@localhost.localdomain
parents: 205
diff changeset
678 next_span = span;
109
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
679
210
204b03ca98f8 fix DrawSpan
gongo@localhost.localdomain
parents: 205
diff changeset
680 (this->*drawFunc2[(resume_span->length_x != 1)])(
204b03ca98f8 fix DrawSpan
gongo@localhost.localdomain
parents: 205
diff changeset
681 resume_span, rangex_start, rangex_end, resume_span_x,
204b03ca98f8 fix DrawSpan
gongo@localhost.localdomain
parents: 205
diff changeset
682 tl_tag[tl_tag_flg2]);
148
9642aeef298d Span への Texture List の渡し。じゃっかん texture がバグってるので
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents: 147
diff changeset
683
210
204b03ca98f8 fix DrawSpan
gongo@localhost.localdomain
parents: 205
diff changeset
684 resume_span = next_span;
204b03ca98f8 fix DrawSpan
gongo@localhost.localdomain
parents: 205
diff changeset
685 resume_span_x = next_span_x;
204b03ca98f8 fix DrawSpan
gongo@localhost.localdomain
parents: 205
diff changeset
686
204b03ca98f8 fix DrawSpan
gongo@localhost.localdomain
parents: 205
diff changeset
687 //smanager->dma_wait(tl_tag[tl_tag_flg1]);
109
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
688
210
204b03ca98f8 fix DrawSpan
gongo@localhost.localdomain
parents: 205
diff changeset
689 tl_tag_flg1 ^= 1;
204b03ca98f8 fix DrawSpan
gongo@localhost.localdomain
parents: 205
diff changeset
690 tl_tag_flg2 ^= 1;
109
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
691 }
210
204b03ca98f8 fix DrawSpan
gongo@localhost.localdomain
parents: 205
diff changeset
692
233
gongo@localhost.localdomain
parents: 213
diff changeset
693 // 現在 drawLine2、drawDot2 は機能してないので
gongo@localhost.localdomain
parents: 213
diff changeset
694 //(this->*drawFunc2[(resume_span->length_x != 1)])(
gongo@localhost.localdomain
parents: 213
diff changeset
695 //resume_span, rangex_start, rangex_end, resume_span_x,
gongo@localhost.localdomain
parents: 213
diff changeset
696 //tl_tag[tl_tag_flg1]);
147
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents: 133
diff changeset
697
109
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
698 smanager->dma_wait(SPAN_PACK_LOAD);
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
699
184
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 182
diff changeset
700 SpanPackPtr tmp_spack = spack;
182
df3cfc04e796 add get_inputAddr, get_outputAddr
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 180
diff changeset
701 spack = next_spack;
df3cfc04e796 add get_inputAddr, get_outputAddr
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 180
diff changeset
702 next_spack = tmp_spack;
df3cfc04e796 add get_inputAddr, get_outputAddr
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 180
diff changeset
703 } while (spack);
109
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
704
193
gongo@localhost.localdomain
parents: 192
diff changeset
705 writebuffer(display, rangex, rangey, screen_width);
gongo@localhost.localdomain
parents: 192
diff changeset
706
gongo@localhost.localdomain
parents: 192
diff changeset
707 // linebuf は、writebuffer() の dma_store を wait する
gongo@localhost.localdomain
parents: 192
diff changeset
708 // DrawSpan::~DrawSpan() 内で free する。
gongo@localhost.localdomain
parents: 192
diff changeset
709 //free(linebuf);
gongo@localhost.localdomain
parents: 192
diff changeset
710 free(zRow);
184
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 182
diff changeset
711
210
204b03ca98f8 fix DrawSpan
gongo@localhost.localdomain
parents: 205
diff changeset
712 //FINISH:
193
gongo@localhost.localdomain
parents: 192
diff changeset
713 /**
gongo@localhost.localdomain
parents: 192
diff changeset
714 * goto FINISH; の時は reboot なので
gongo@localhost.localdomain
parents: 192
diff changeset
715 * linebuf, zRow は free() しない
gongo@localhost.localdomain
parents: 192
diff changeset
716 */
210
204b03ca98f8 fix DrawSpan
gongo@localhost.localdomain
parents: 205
diff changeset
717
182
df3cfc04e796 add get_inputAddr, get_outputAddr
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 180
diff changeset
718 free(free_spack);
267
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 243 266
diff changeset
719 <<<<<<< local
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 243 266
diff changeset
720 =======
109
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
721 free(linebuf);
266
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 183 265
diff changeset
722 <<<<<<< local
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 183 265
diff changeset
723 =======
109
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
724 free(zRow);
264
a59868d37093 merge 151 263
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 148 122
diff changeset
725 <<<<<<< local
265
d949e590da26 merge 172 264
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 170 264
diff changeset
726 =======
d949e590da26 merge 172 264
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 170 264
diff changeset
727 <<<<<<< local
128
776eca0daa02 texture load use hash table
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents: 126
diff changeset
728 free(tileList);
147
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents: 133
diff changeset
729 free(tilist);
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents: 133
diff changeset
730 free(next_tilist);
265
d949e590da26 merge 172 264
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 170 264
diff changeset
731 >>>>>>> other
266
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 183 265
diff changeset
732 >>>>>>> other
109
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
733
264
a59868d37093 merge 151 263
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 148 122
diff changeset
734 =======
122
a802b19ab9ae add SceneGraph move
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents: 120
diff changeset
735 free(tex);
264
a59868d37093 merge 151 263
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 148 122
diff changeset
736 >>>>>>> other
267
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 243 266
diff changeset
737 >>>>>>> other
109
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
738 return 0;
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
739 }