annotate TaskManager/Test/test_render/task/DrawSpan.cpp @ 210:e75f9eb97180 draft

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