annotate TaskManager/Test/test_render/task/DrawSpan.cpp @ 387:b6fce69839b5 draft

no compile error but not worked.
author Shinji KONO <kono@ie.u-ryukyu.ac.jp>
date Thu, 06 Aug 2009 22:40:52 +0900
parents da7b1e5b8449
children 492e60453124
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
109
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
1 #include <stdlib.h>
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
2 #include <string.h>
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
3 #include "DrawSpan.h"
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
4 #include "polygon_pack.h"
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
5 #include "texture.h"
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
6 #include "viewer_types.h"
184
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 182
diff changeset
7 #include "Func.h"
315
5ae96eb47e1d add pre light
e065725@yutaka.st.ie.u-ryukyu.ac.jp
parents: 275
diff changeset
8 #include "sys.h"
352
9738837c225c add global_alloc.h
admin@mb22-no-macbook-2.local
parents: 338
diff changeset
9 #include "global_alloc.h"
109
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
10
210
e75f9eb97180 fix DrawSpan
gongo@localhost.localdomain
parents: 193
diff changeset
11 SchedDefineTask(DrawSpan);
109
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
12
210
e75f9eb97180 fix DrawSpan
gongo@localhost.localdomain
parents: 193
diff changeset
13 #define TEX_LOAD1 0
e75f9eb97180 fix DrawSpan
gongo@localhost.localdomain
parents: 193
diff changeset
14 #define TEX_LOAD2 1
e75f9eb97180 fix DrawSpan
gongo@localhost.localdomain
parents: 193
diff changeset
15 #define SPAN_PACK_LOAD 2
e75f9eb97180 fix DrawSpan
gongo@localhost.localdomain
parents: 193
diff changeset
16 #define FB_STORE 3
109
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
17
193
gongo@localhost.localdomain
parents: 189
diff changeset
18 DrawSpan::~DrawSpan(void)
gongo@localhost.localdomain
parents: 189
diff changeset
19 {
gongo@localhost.localdomain
parents: 189
diff changeset
20 smanager->dma_wait(FB_STORE);
gongo@localhost.localdomain
parents: 189
diff changeset
21 free((void*)((int)linebuf*doneWrite));
gongo@localhost.localdomain
parents: 189
diff changeset
22 }
gongo@localhost.localdomain
parents: 189
diff changeset
23
164
dc7d10ae7460 TilePtr は SPE で計算した方がいいと判断して変更。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 161
diff changeset
24 /**
193
gongo@localhost.localdomain
parents: 189
diff changeset
25 * テクスチャは、TEXTURE_SPLIT_PIXEL^2 のブロックに分割する
164
dc7d10ae7460 TilePtr は SPE で計算した方がいいと判断して変更。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 161
diff changeset
26 *
dc7d10ae7460 TilePtr は SPE で計算した方がいいと判断して変更。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 161
diff changeset
27 * +---+---+---+---+---+---+
dc7d10ae7460 TilePtr は SPE で計算した方がいいと判断して変更。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 161
diff changeset
28 * | 0 | 1 | 2 | 3 | 4 | 5 |
dc7d10ae7460 TilePtr は SPE で計算した方がいいと判断して変更。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 161
diff changeset
29 * +---+---+---+---+---+---+
dc7d10ae7460 TilePtr は SPE で計算した方がいいと判断して変更。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 161
diff changeset
30 * | | | | | |11 |
dc7d10ae7460 TilePtr は SPE で計算した方がいいと判断して変更。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 161
diff changeset
31 * +---+---+---+---+---+---+
dc7d10ae7460 TilePtr は SPE で計算した方がいいと判断して変更。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 161
diff changeset
32 * | | | | | |17 |
dc7d10ae7460 TilePtr は SPE で計算した方がいいと判断して変更。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 161
diff changeset
33 * +---+---+---+---+---+---+
dc7d10ae7460 TilePtr は SPE で計算した方がいいと判断して変更。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 161
diff changeset
34 * | | | | | |23 |
dc7d10ae7460 TilePtr は SPE で計算した方がいいと判断して変更。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 161
diff changeset
35 * +---+---+---+---+---+---+
dc7d10ae7460 TilePtr は SPE で計算した方がいいと判断して変更。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 161
diff changeset
36 * | | | | | |29 |
dc7d10ae7460 TilePtr は SPE で計算した方がいいと判断して変更。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 161
diff changeset
37 * +---+---+---+---+---+---+
dc7d10ae7460 TilePtr は SPE で計算した方がいいと判断して変更。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 161
diff changeset
38 * | | | | | |35 |
dc7d10ae7460 TilePtr は SPE で計算した方がいいと判断して変更。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 161
diff changeset
39 * +---+---+---+---+---+---+
dc7d10ae7460 TilePtr は SPE で計算した方がいいと判断して変更。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 161
diff changeset
40 *
193
gongo@localhost.localdomain
parents: 189
diff changeset
41 * 一辺を TEXTURE_SPLIT とする
gongo@localhost.localdomain
parents: 189
diff changeset
42 * 各ブロックの数字がブロックIDとなる。
164
dc7d10ae7460 TilePtr は SPE で計算した方がいいと判断して変更。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 161
diff changeset
43 */
dc7d10ae7460 TilePtr は SPE で計算した方がいいと判断して変更。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 161
diff changeset
44
dc7d10ae7460 TilePtr は SPE で計算した方がいいと判断して変更。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 161
diff changeset
45 /**
193
gongo@localhost.localdomain
parents: 189
diff changeset
46 * テクスチャの座標から、
gongo@localhost.localdomain
parents: 189
diff changeset
47 * テクスチャのどのブロックかを求める
164
dc7d10ae7460 TilePtr は SPE で計算した方がいいと判断して変更。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 161
diff changeset
48 *
dc7d10ae7460 TilePtr は SPE で計算した方がいいと判断して変更。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 161
diff changeset
49 * @param[in] tx X coordinates of texture
dc7d10ae7460 TilePtr は SPE で計算した方がいいと判断して変更。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 161
diff changeset
50 * @param[in] tx Y coordinates of texture
dc7d10ae7460 TilePtr は SPE で計算した方がいいと判断して変更。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 161
diff changeset
51 * @param[in] twidth Width of texture
dc7d10ae7460 TilePtr は SPE で計算した方がいいと判断して変更。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 161
diff changeset
52 * @return block ID
dc7d10ae7460 TilePtr は SPE で計算した方がいいと判断して変更。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 161
diff changeset
53 */
184
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 182
diff changeset
54 int
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 182
diff changeset
55 DrawSpan::getTexBlock(int tx, int ty, int twidth)
164
dc7d10ae7460 TilePtr は SPE で計算した方がいいと判断して変更。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 161
diff changeset
56 {
dc7d10ae7460 TilePtr は SPE で計算した方がいいと判断して変更。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 161
diff changeset
57 int blockX, blockY;
dc7d10ae7460 TilePtr は SPE で計算した方がいいと判断して変更。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 161
diff changeset
58
dc7d10ae7460 TilePtr は SPE で計算した方がいいと判断して変更。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 161
diff changeset
59 blockX = tx / TEXTURE_SPLIT_PIXEL;
dc7d10ae7460 TilePtr は SPE で計算した方がいいと判断して変更。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 161
diff changeset
60 blockY = ty / TEXTURE_SPLIT_PIXEL;
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 return blockX + (twidth/TEXTURE_SPLIT_PIXEL)*blockY;
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
dc7d10ae7460 TilePtr は SPE で計算した方がいいと判断して変更。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 161
diff changeset
65 /**
193
gongo@localhost.localdomain
parents: 189
diff changeset
66 * block ID と、テクスチャの TOP address から
gongo@localhost.localdomain
parents: 189
diff changeset
67 * (tx,ty) で使われるテクスチャの Tile addres を求める
164
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 * @param[in] tx X coordinates of texture
dc7d10ae7460 TilePtr は SPE で計算した方がいいと判断して変更。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 161
diff changeset
70 * @param[in] tx Y coordinates of texture
dc7d10ae7460 TilePtr は SPE で計算した方がいいと判断して変更。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 161
diff changeset
71 * @param[in] tw Width of texture
193
gongo@localhost.localdomain
parents: 189
diff changeset
72 * @param[in] tex_addr_top (tx,ty) で使うテクスチャの先頭address
164
dc7d10ae7460 TilePtr は SPE で計算した方がいいと判断して変更。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 161
diff changeset
73 * @return block ID
dc7d10ae7460 TilePtr は SPE で計算した方がいいと判断して変更。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 161
diff changeset
74 */
373
205e4a4af635 MemList not working
kazz@kazzone.cr.ie.u-ryukyu.ac.jp
parents: 371
diff changeset
75 memaddr
205e4a4af635 MemList not working
kazz@kazzone.cr.ie.u-ryukyu.ac.jp
parents: 371
diff changeset
76 DrawSpan::getTile(int tx, int ty, int tw, memaddr tex_addr_top)
164
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 block = getTexBlock(tx, ty, tw);
373
205e4a4af635 MemList not working
kazz@kazzone.cr.ie.u-ryukyu.ac.jp
parents: 371
diff changeset
79 return tex_addr_top + block * TEXTURE_BLOCK_SIZE * sizeof(uint32);
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
193
gongo@localhost.localdomain
parents: 189
diff changeset
82 /**
gongo@localhost.localdomain
parents: 189
diff changeset
83 * FrameBuffer に書き込む rgb の領域初期化
gongo@localhost.localdomain
parents: 189
diff changeset
84 *
gongo@localhost.localdomain
parents: 189
diff changeset
85 * @param width Width of Buffer
gongo@localhost.localdomain
parents: 189
diff changeset
86 * @param height Height of Buffer
gongo@localhost.localdomain
parents: 189
diff changeset
87 * @param rgb Initial value of RGB at Buffer
gongo@localhost.localdomain
parents: 189
diff changeset
88 * @return Buffer
gongo@localhost.localdomain
parents: 189
diff changeset
89 */
gongo@localhost.localdomain
parents: 189
diff changeset
90 int*
gongo@localhost.localdomain
parents: 189
diff changeset
91 DrawSpan::linebuf_init(int width, int height, int rgb)
109
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
92 {
193
gongo@localhost.localdomain
parents: 189
diff changeset
93 int *buf = (int*)smanager->allocate(sizeof(int)*width*height);
gongo@localhost.localdomain
parents: 189
diff changeset
94
gongo@localhost.localdomain
parents: 189
diff changeset
95 for (int i = 0; i < width*height; i++) {
352
9738837c225c add global_alloc.h
admin@mb22-no-macbook-2.local
parents: 338
diff changeset
96 buf[i] = rgb;
109
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
97 }
193
gongo@localhost.localdomain
parents: 189
diff changeset
98
gongo@localhost.localdomain
parents: 189
diff changeset
99 return buf;
109
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
100 }
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
101
184
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 182
diff changeset
102 /**
193
gongo@localhost.localdomain
parents: 189
diff changeset
103 * Z-Buffer の初期化
184
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 182
diff changeset
104 *
193
gongo@localhost.localdomain
parents: 189
diff changeset
105 * @param width Width of Z-Buffer
gongo@localhost.localdomain
parents: 189
diff changeset
106 * @param height Height of Z-Buffer
gongo@localhost.localdomain
parents: 189
diff changeset
107 * @return Z-Buffer
gongo@localhost.localdomain
parents: 189
diff changeset
108 */
gongo@localhost.localdomain
parents: 189
diff changeset
109 float*
gongo@localhost.localdomain
parents: 189
diff changeset
110 DrawSpan::zRow_init(int width, int height)
gongo@localhost.localdomain
parents: 189
diff changeset
111 {
gongo@localhost.localdomain
parents: 189
diff changeset
112 float *buf = (float*)smanager->allocate(sizeof(float)*width*height);
gongo@localhost.localdomain
parents: 189
diff changeset
113 float def = 65535.0f;
gongo@localhost.localdomain
parents: 189
diff changeset
114
gongo@localhost.localdomain
parents: 189
diff changeset
115 for (int i = 0; i < width*height; i++) {
352
9738837c225c add global_alloc.h
admin@mb22-no-macbook-2.local
parents: 338
diff changeset
116 buf[i] = def;
193
gongo@localhost.localdomain
parents: 189
diff changeset
117 }
gongo@localhost.localdomain
parents: 189
diff changeset
118
gongo@localhost.localdomain
parents: 189
diff changeset
119 return buf;
gongo@localhost.localdomain
parents: 189
diff changeset
120 }
gongo@localhost.localdomain
parents: 189
diff changeset
121
386
da7b1e5b8449 MemHash...
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 379
diff changeset
122 #if !USE_MEMHASH
193
gongo@localhost.localdomain
parents: 189
diff changeset
123 /**
gongo@localhost.localdomain
parents: 189
diff changeset
124 * Span が使う Texture Tile があるか
gongo@localhost.localdomain
parents: 189
diff changeset
125 *
gongo@localhost.localdomain
parents: 189
diff changeset
126 * @retval != NULL 存在する
gongo@localhost.localdomain
parents: 189
diff changeset
127 * @retval NULL 存在しない
184
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 182
diff changeset
128 */
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 182
diff changeset
129 TilePtr
373
205e4a4af635 MemList not working
kazz@kazzone.cr.ie.u-ryukyu.ac.jp
parents: 371
diff changeset
130 DrawSpan::isAvailableTile(memaddr addr)
205e4a4af635 MemList not working
kazz@kazzone.cr.ie.u-ryukyu.ac.jp
parents: 371
diff changeset
131 {
184
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 182
diff changeset
132 return hash->get(addr);
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 182
diff changeset
133 }
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 182
diff changeset
134
360
4430f0bff5cb add vacuum "-sg 16"
aaa
parents: 357
diff changeset
135 TilePtr
373
205e4a4af635 MemList not working
kazz@kazzone.cr.ie.u-ryukyu.ac.jp
parents: 371
diff changeset
136 DrawSpan::set_rgb(memaddr addr, int tag)
184
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 182
diff changeset
137 {
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 182
diff changeset
138 TilePtr tile;
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 182
diff changeset
139
371
d38ac129badd change DrawSpan, #define USE_MEMLIST use MemList(LRU)
aaa
parents: 360
diff changeset
140 #ifdef USE_MEMLIST
d38ac129badd change DrawSpan, #define USE_MEMLIST use MemList(LRU)
aaa
parents: 360
diff changeset
141 tile = tileList->getLast();
379
39fbac49bf60 動いた!
kazz@kazzone.cr.ie.u-ryukyu.ac.jp
parents: 373
diff changeset
142 tileList->moveToFirst(tile);
371
d38ac129badd change DrawSpan, #define USE_MEMLIST use MemList(LRU)
aaa
parents: 360
diff changeset
143 #else
193
gongo@localhost.localdomain
parents: 189
diff changeset
144 tile = tileList->nextTile();
371
d38ac129badd change DrawSpan, #define USE_MEMLIST use MemList(LRU)
aaa
parents: 360
diff changeset
145 #endif
d38ac129badd change DrawSpan, #define USE_MEMLIST use MemList(LRU)
aaa
parents: 360
diff changeset
146
373
205e4a4af635 MemList not working
kazz@kazzone.cr.ie.u-ryukyu.ac.jp
parents: 371
diff changeset
147 memaddr old_addr = tile->address;
205e4a4af635 MemList not working
kazz@kazzone.cr.ie.u-ryukyu.ac.jp
parents: 371
diff changeset
148 smanager->dma_load(tile->data, addr,
205e4a4af635 MemList not working
kazz@kazzone.cr.ie.u-ryukyu.ac.jp
parents: 371
diff changeset
149 sizeof(uint32)*TEXTURE_BLOCK_SIZE, tag);
193
gongo@localhost.localdomain
parents: 189
diff changeset
150 /**
gongo@localhost.localdomain
parents: 189
diff changeset
151 * FIFO なので、もし前のが残っていれば削除
gongo@localhost.localdomain
parents: 189
diff changeset
152 */
360
4430f0bff5cb add vacuum "-sg 16"
aaa
parents: 357
diff changeset
153
4430f0bff5cb add vacuum "-sg 16"
aaa
parents: 357
diff changeset
154 hash->remove(old_addr);
352
9738837c225c add global_alloc.h
admin@mb22-no-macbook-2.local
parents: 338
diff changeset
155
371
d38ac129badd change DrawSpan, #define USE_MEMLIST use MemList(LRU)
aaa
parents: 360
diff changeset
156 tile->address = addr;
352
9738837c225c add global_alloc.h
admin@mb22-no-macbook-2.local
parents: 338
diff changeset
157
371
d38ac129badd change DrawSpan, #define USE_MEMLIST use MemList(LRU)
aaa
parents: 360
diff changeset
158 hash->put(tile->address, tile);
360
4430f0bff5cb add vacuum "-sg 16"
aaa
parents: 357
diff changeset
159
4430f0bff5cb add vacuum "-sg 16"
aaa
parents: 357
diff changeset
160 return tile;
184
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 182
diff changeset
161 }
386
da7b1e5b8449 MemHash...
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 379
diff changeset
162 #endif
184
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 182
diff changeset
163
360
4430f0bff5cb add vacuum "-sg 16"
aaa
parents: 357
diff changeset
164 uint32
4430f0bff5cb add vacuum "-sg 16"
aaa
parents: 357
diff changeset
165 DrawSpan::get_rgb(int tx, int ty, TilePtr tile)
184
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 182
diff changeset
166 {
373
205e4a4af635 MemList not working
kazz@kazzone.cr.ie.u-ryukyu.ac.jp
parents: 371
diff changeset
167 uint32 *data = (uint32 *)tile->data;
205e4a4af635 MemList not working
kazz@kazzone.cr.ie.u-ryukyu.ac.jp
parents: 371
diff changeset
168 return data[(TEXTURE_SPLIT_PIXEL)*ty+tx];
109
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
169 }
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
170
387
b6fce69839b5 no compile error but not worked.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 386
diff changeset
171 #if 0
184
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 182
diff changeset
172 /**
193
gongo@localhost.localdomain
parents: 189
diff changeset
173 * DrawSpan の再起動 (DrawSpanRenew 生成)
184
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 182
diff changeset
174 *
193
gongo@localhost.localdomain
parents: 189
diff changeset
175 * @param[in] spack 現在処理している SpanPack
gongo@localhost.localdomain
parents: 189
diff changeset
176 * @param[in] cur_span_x span->length_x != 1 の時の Span の処理で
gongo@localhost.localdomain
parents: 189
diff changeset
177 * どこまで進んでいるか
184
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 182
diff changeset
178 */
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 182
diff changeset
179 void
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 182
diff changeset
180 DrawSpan::reboot(SpanPackPtr spack, int cur_span_x)
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 182
diff changeset
181 {
193
gongo@localhost.localdomain
parents: 189
diff changeset
182 DrawSpanArgPtr args =
352
9738837c225c add global_alloc.h
admin@mb22-no-macbook-2.local
parents: 338
diff changeset
183 (DrawSpanArgPtr)smanager->allocate(sizeof(DrawSpanArg));
184
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 182
diff changeset
184 TaskPtr renew_task = smanager->create_task(TASK_DRAW_SPAN2);
193
gongo@localhost.localdomain
parents: 189
diff changeset
185
gongo@localhost.localdomain
parents: 189
diff changeset
186 // 数が多いので構造体で渡す
gongo@localhost.localdomain
parents: 189
diff changeset
187 args->display = smanager->get_param(0);
gongo@localhost.localdomain
parents: 189
diff changeset
188 args->screen_width = smanager->get_param(1);
gongo@localhost.localdomain
parents: 189
diff changeset
189 args->rangex_start = smanager->get_param(2);
gongo@localhost.localdomain
parents: 189
diff changeset
190 args->rangex_end = smanager->get_param(3);
gongo@localhost.localdomain
parents: 189
diff changeset
191 args->rangey = smanager->get_param(4);
gongo@localhost.localdomain
parents: 189
diff changeset
192 renew_task->add_param((int)args);
164
dc7d10ae7460 TilePtr は SPE で計算した方がいいと判断して変更。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 161
diff changeset
193
184
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 182
diff changeset
194 /**
193
gongo@localhost.localdomain
parents: 189
diff changeset
195 * SpanPack は続きから開始するので、
gongo@localhost.localdomain
parents: 189
diff changeset
196 * 現在の状態をコピーしておく。
gongo@localhost.localdomain
parents: 189
diff changeset
197 * spack は rbuf から取得してる可能性があり
gongo@localhost.localdomain
parents: 189
diff changeset
198 * rbuf はシステムが自動的に free() するため
gongo@localhost.localdomain
parents: 189
diff changeset
199 * アドレスだけ渡すのはNG
352
9738837c225c add global_alloc.h
admin@mb22-no-macbook-2.local
parents: 338
diff changeset
200 */
184
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 182
diff changeset
201 SpanPackPtr curr = (SpanPackPtr)smanager->allocate(sizeof(SpanPack));
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 182
diff changeset
202 memcpy(curr, spack, sizeof(SpanPack));
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 182
diff changeset
203 renew_task->add_param((int)curr);
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 182
diff changeset
204 renew_task->add_param(cur_span_x);
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 182
diff changeset
205
193
gongo@localhost.localdomain
parents: 189
diff changeset
206 // linebuf と zRow も引き継がせる
gongo@localhost.localdomain
parents: 189
diff changeset
207 renew_task->add_param((int)linebuf);
gongo@localhost.localdomain
parents: 189
diff changeset
208 renew_task->add_param((int)zRow);
gongo@localhost.localdomain
parents: 189
diff changeset
209
184
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 182
diff changeset
210 /**
193
gongo@localhost.localdomain
parents: 189
diff changeset
211 * 再起動したタスクを待つ
352
9738837c225c add global_alloc.h
admin@mb22-no-macbook-2.local
parents: 338
diff changeset
212 */
184
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 182
diff changeset
213 smanager->wait_task(renew_task);
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 182
diff changeset
214
193
gongo@localhost.localdomain
parents: 189
diff changeset
215 // next_spack は free() するので wait する
184
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 182
diff changeset
216 smanager->dma_wait(SPAN_PACK_LOAD);
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 182
diff changeset
217 }
387
b6fce69839b5 no compile error but not worked.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 386
diff changeset
218 #endif
164
dc7d10ae7460 TilePtr は SPE で計算した方がいいと判断して変更。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 161
diff changeset
219
193
gongo@localhost.localdomain
parents: 189
diff changeset
220 void
gongo@localhost.localdomain
parents: 189
diff changeset
221 DrawSpan::writebuffer(unsigned int display, int buf_width, int height,
352
9738837c225c add global_alloc.h
admin@mb22-no-macbook-2.local
parents: 338
diff changeset
222 int screen_width)
193
gongo@localhost.localdomain
parents: 189
diff changeset
223 {
gongo@localhost.localdomain
parents: 189
diff changeset
224 for (int i = 0; i < height; i++) {
352
9738837c225c add global_alloc.h
admin@mb22-no-macbook-2.local
parents: 338
diff changeset
225 smanager->dma_store(&linebuf[i*buf_width],
9738837c225c add global_alloc.h
admin@mb22-no-macbook-2.local
parents: 338
diff changeset
226 display + (sizeof(int)*screen_width*i),
9738837c225c add global_alloc.h
admin@mb22-no-macbook-2.local
parents: 338
diff changeset
227 sizeof(int)*buf_width, FB_STORE);
193
gongo@localhost.localdomain
parents: 189
diff changeset
228 }
gongo@localhost.localdomain
parents: 189
diff changeset
229
gongo@localhost.localdomain
parents: 189
diff changeset
230 doneWrite = 1;
gongo@localhost.localdomain
parents: 189
diff changeset
231 }
gongo@localhost.localdomain
parents: 189
diff changeset
232
210
e75f9eb97180 fix DrawSpan
gongo@localhost.localdomain
parents: 193
diff changeset
233 /**
e75f9eb97180 fix DrawSpan
gongo@localhost.localdomain
parents: 193
diff changeset
234 * zRow と Linebuf を更新する
e75f9eb97180 fix DrawSpan
gongo@localhost.localdomain
parents: 193
diff changeset
235 *
e75f9eb97180 fix DrawSpan
gongo@localhost.localdomain
parents: 193
diff changeset
236 * @param zpos 更新する pixel のZ座標
e75f9eb97180 fix DrawSpan
gongo@localhost.localdomain
parents: 193
diff changeset
237 * @param rangex このタスクが処理する描画領域の x の長さ
e75f9eb97180 fix DrawSpan
gongo@localhost.localdomain
parents: 193
diff changeset
238 * @param x pixel の、描画領域内での x 座標
e75f9eb97180 fix DrawSpan
gongo@localhost.localdomain
parents: 193
diff changeset
239 * @param y 〃 の、y 座標
e75f9eb97180 fix DrawSpan
gongo@localhost.localdomain
parents: 193
diff changeset
240 * @param tex_x pixel が使用するテクスチャの、Tile (8x8) 内での x 座標
e75f9eb97180 fix DrawSpan
gongo@localhost.localdomain
parents: 193
diff changeset
241 * @param tex_y 〃 の y 座標
e75f9eb97180 fix DrawSpan
gongo@localhost.localdomain
parents: 193
diff changeset
242 * @param tex_addr テクスチャのアドレス(MainMemory)
e75f9eb97180 fix DrawSpan
gongo@localhost.localdomain
parents: 193
diff changeset
243 */
e75f9eb97180 fix DrawSpan
gongo@localhost.localdomain
parents: 193
diff changeset
244 void
352
9738837c225c add global_alloc.h
admin@mb22-no-macbook-2.local
parents: 338
diff changeset
245 DrawSpan::updateBuffer(float zpos, int rangex, int x, int y, int tex_x, int tex_y,
360
4430f0bff5cb add vacuum "-sg 16"
aaa
parents: 357
diff changeset
246 float normal_x, float normal_y, float normal_z, TilePtr tile)
210
e75f9eb97180 fix DrawSpan
gongo@localhost.localdomain
parents: 193
diff changeset
247 {
262
0697f31fbd7f Add alpha blending
e065725@yutaka.st.ie.u-ryukyu.ac.jp
parents: 238
diff changeset
248
360
4430f0bff5cb add vacuum "-sg 16"
aaa
parents: 357
diff changeset
249 int color = get_rgb(tex_x, tex_y, tile);
262
0697f31fbd7f Add alpha blending
e065725@yutaka.st.ie.u-ryukyu.ac.jp
parents: 238
diff changeset
250 /*下位4bitを抽出*/
315
5ae96eb47e1d add pre light
e065725@yutaka.st.ie.u-ryukyu.ac.jp
parents: 275
diff changeset
251 int alpha = color & 0x000F;
262
0697f31fbd7f Add alpha blending
e065725@yutaka.st.ie.u-ryukyu.ac.jp
parents: 238
diff changeset
252 /*完全に透けているか判断*/
0697f31fbd7f Add alpha blending
e065725@yutaka.st.ie.u-ryukyu.ac.jp
parents: 238
diff changeset
253 int flag = (alpha != 0);
0697f31fbd7f Add alpha blending
e065725@yutaka.st.ie.u-ryukyu.ac.jp
parents: 238
diff changeset
254
315
5ae96eb47e1d add pre light
e065725@yutaka.st.ie.u-ryukyu.ac.jp
parents: 275
diff changeset
255 color = infinity_light_calc(color,normal_x,normal_y,normal_z);
5ae96eb47e1d add pre light
e065725@yutaka.st.ie.u-ryukyu.ac.jp
parents: 275
diff changeset
256
262
0697f31fbd7f Add alpha blending
e065725@yutaka.st.ie.u-ryukyu.ac.jp
parents: 238
diff changeset
257 zRow[x + (rangex*y)] = zpos*flag + zRow[x + (rangex*y)]*(1-flag);
315
5ae96eb47e1d add pre light
e065725@yutaka.st.ie.u-ryukyu.ac.jp
parents: 275
diff changeset
258 linebuf[x + (rangex*y)] = color*flag + linebuf[x + (rangex*y)]*(1-flag);
262
0697f31fbd7f Add alpha blending
e065725@yutaka.st.ie.u-ryukyu.ac.jp
parents: 238
diff changeset
259
210
e75f9eb97180 fix DrawSpan
gongo@localhost.localdomain
parents: 193
diff changeset
260 }
e75f9eb97180 fix DrawSpan
gongo@localhost.localdomain
parents: 193
diff changeset
261
e75f9eb97180 fix DrawSpan
gongo@localhost.localdomain
parents: 193
diff changeset
262 /**
e75f9eb97180 fix DrawSpan
gongo@localhost.localdomain
parents: 193
diff changeset
263 * 長さが 1 の Span の描画 (要するに 1 pixel)
e75f9eb97180 fix DrawSpan
gongo@localhost.localdomain
parents: 193
diff changeset
264 *
e75f9eb97180 fix DrawSpan
gongo@localhost.localdomain
parents: 193
diff changeset
265 * @param span Span
e75f9eb97180 fix DrawSpan
gongo@localhost.localdomain
parents: 193
diff changeset
266 * @param startx 描画開始範囲
e75f9eb97180 fix DrawSpan
gongo@localhost.localdomain
parents: 193
diff changeset
267 * @param endx 描画終了範囲
e75f9eb97180 fix DrawSpan
gongo@localhost.localdomain
parents: 193
diff changeset
268 */
e75f9eb97180 fix DrawSpan
gongo@localhost.localdomain
parents: 193
diff changeset
269 int
e75f9eb97180 fix DrawSpan
gongo@localhost.localdomain
parents: 193
diff changeset
270 DrawSpan::drawDot1(SpanPtr span, int startx, int endx, int wait_tag)
e75f9eb97180 fix DrawSpan
gongo@localhost.localdomain
parents: 193
diff changeset
271 {
e75f9eb97180 fix DrawSpan
gongo@localhost.localdomain
parents: 193
diff changeset
272 int rangex = endx - startx + 1;
e75f9eb97180 fix DrawSpan
gongo@localhost.localdomain
parents: 193
diff changeset
273
315
5ae96eb47e1d add pre light
e065725@yutaka.st.ie.u-ryukyu.ac.jp
parents: 275
diff changeset
274 float normal_x = span->normal_x;
5ae96eb47e1d add pre light
e065725@yutaka.st.ie.u-ryukyu.ac.jp
parents: 275
diff changeset
275 float normal_y = span->normal_y;
5ae96eb47e1d add pre light
e065725@yutaka.st.ie.u-ryukyu.ac.jp
parents: 275
diff changeset
276 float normal_z = span->normal_z;
5ae96eb47e1d add pre light
e065725@yutaka.st.ie.u-ryukyu.ac.jp
parents: 275
diff changeset
277
5ae96eb47e1d add pre light
e065725@yutaka.st.ie.u-ryukyu.ac.jp
parents: 275
diff changeset
278
210
e75f9eb97180 fix DrawSpan
gongo@localhost.localdomain
parents: 193
diff changeset
279 /* span->x に対応する Texture の座標 (tex_xpos, tex_ypos) */
e75f9eb97180 fix DrawSpan
gongo@localhost.localdomain
parents: 193
diff changeset
280 int tex_xpos, tex_ypos;
e75f9eb97180 fix DrawSpan
gongo@localhost.localdomain
parents: 193
diff changeset
281
e75f9eb97180 fix DrawSpan
gongo@localhost.localdomain
parents: 193
diff changeset
282 // span の始点に対応する Texture の座標 (tex1, tey1)
e75f9eb97180 fix DrawSpan
gongo@localhost.localdomain
parents: 193
diff changeset
283 float tex = span->tex_x1;
e75f9eb97180 fix DrawSpan
gongo@localhost.localdomain
parents: 193
diff changeset
284 float tey = span->tex_y1;
e75f9eb97180 fix DrawSpan
gongo@localhost.localdomain
parents: 193
diff changeset
285
e75f9eb97180 fix DrawSpan
gongo@localhost.localdomain
parents: 193
diff changeset
286 // span の始点に対応する z 座標
e75f9eb97180 fix DrawSpan
gongo@localhost.localdomain
parents: 193
diff changeset
287 float zpos = span->start_z;
e75f9eb97180 fix DrawSpan
gongo@localhost.localdomain
parents: 193
diff changeset
288
e75f9eb97180 fix DrawSpan
gongo@localhost.localdomain
parents: 193
diff changeset
289 /* Tile 内での座標 */
e75f9eb97180 fix DrawSpan
gongo@localhost.localdomain
parents: 193
diff changeset
290 int localx = getLocalX(span->x-1);
e75f9eb97180 fix DrawSpan
gongo@localhost.localdomain
parents: 193
diff changeset
291 int localy = getLocalY(span->y-1);
e75f9eb97180 fix DrawSpan
gongo@localhost.localdomain
parents: 193
diff changeset
292
e75f9eb97180 fix DrawSpan
gongo@localhost.localdomain
parents: 193
diff changeset
293 /**
e75f9eb97180 fix DrawSpan
gongo@localhost.localdomain
parents: 193
diff changeset
294 * (tex_xpos, tex_ypos) の、Tile 内(上の図参照)での座標と
e75f9eb97180 fix DrawSpan
gongo@localhost.localdomain
parents: 193
diff changeset
295 * そのブロックのアドレス(MainMemory)
e75f9eb97180 fix DrawSpan
gongo@localhost.localdomain
parents: 193
diff changeset
296 */
e75f9eb97180 fix DrawSpan
gongo@localhost.localdomain
parents: 193
diff changeset
297 int tex_localx;
e75f9eb97180 fix DrawSpan
gongo@localhost.localdomain
parents: 193
diff changeset
298 int tex_localy;
373
205e4a4af635 MemList not working
kazz@kazzone.cr.ie.u-ryukyu.ac.jp
parents: 371
diff changeset
299 memaddr tex_addr;
210
e75f9eb97180 fix DrawSpan
gongo@localhost.localdomain
parents: 193
diff changeset
300
e75f9eb97180 fix DrawSpan
gongo@localhost.localdomain
parents: 193
diff changeset
301 if (span->x < startx || endx < span->x) {
352
9738837c225c add global_alloc.h
admin@mb22-no-macbook-2.local
parents: 338
diff changeset
302 return -1;
210
e75f9eb97180 fix DrawSpan
gongo@localhost.localdomain
parents: 193
diff changeset
303 }
e75f9eb97180 fix DrawSpan
gongo@localhost.localdomain
parents: 193
diff changeset
304
e75f9eb97180 fix DrawSpan
gongo@localhost.localdomain
parents: 193
diff changeset
305 tex_xpos = (int)((span->tex_width-1) * tex);
e75f9eb97180 fix DrawSpan
gongo@localhost.localdomain
parents: 193
diff changeset
306 tex_ypos = (int)((span->tex_height-1) * tey);
e75f9eb97180 fix DrawSpan
gongo@localhost.localdomain
parents: 193
diff changeset
307
233
gongo@localhost.localdomain
parents: 229
diff changeset
308 if (zpos < zRow[localx + (rangex*localy)]) {
352
9738837c225c add global_alloc.h
admin@mb22-no-macbook-2.local
parents: 338
diff changeset
309 tex_addr = getTile(tex_xpos, tex_ypos,
373
205e4a4af635 MemList not working
kazz@kazzone.cr.ie.u-ryukyu.ac.jp
parents: 371
diff changeset
310 span->tex_width, (memaddr)span->tex_addr);
352
9738837c225c add global_alloc.h
admin@mb22-no-macbook-2.local
parents: 338
diff changeset
311 tex_localx = tex_xpos % TEXTURE_SPLIT_PIXEL;
9738837c225c add global_alloc.h
admin@mb22-no-macbook-2.local
parents: 338
diff changeset
312 tex_localy = tex_ypos % TEXTURE_SPLIT_PIXEL;
210
e75f9eb97180 fix DrawSpan
gongo@localhost.localdomain
parents: 193
diff changeset
313
386
da7b1e5b8449 MemHash...
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 379
diff changeset
314 #if USE_MEMHASH
387
b6fce69839b5 no compile error but not worked.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 386
diff changeset
315 TilePtr tile = smanager->get_segment(tex_addr,tileList);
b6fce69839b5 no compile error but not worked.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 386
diff changeset
316 smanager->wait_segment(tile);
386
da7b1e5b8449 MemHash...
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 379
diff changeset
317 #else
373
205e4a4af635 MemList not working
kazz@kazzone.cr.ie.u-ryukyu.ac.jp
parents: 371
diff changeset
318 TilePtr tile;
205e4a4af635 MemList not working
kazz@kazzone.cr.ie.u-ryukyu.ac.jp
parents: 371
diff changeset
319 if (!(tile = isAvailableTile(tex_addr))) {
360
4430f0bff5cb add vacuum "-sg 16"
aaa
parents: 357
diff changeset
320 tile = set_rgb(tex_addr, wait_tag);
352
9738837c225c add global_alloc.h
admin@mb22-no-macbook-2.local
parents: 338
diff changeset
321 smanager->dma_wait(wait_tag);
9738837c225c add global_alloc.h
admin@mb22-no-macbook-2.local
parents: 338
diff changeset
322 //return startx;
9738837c225c add global_alloc.h
admin@mb22-no-macbook-2.local
parents: 338
diff changeset
323 }
371
d38ac129badd change DrawSpan, #define USE_MEMLIST use MemList(LRU)
aaa
parents: 360
diff changeset
324 #ifdef USE_MEMLIST
373
205e4a4af635 MemList not working
kazz@kazzone.cr.ie.u-ryukyu.ac.jp
parents: 371
diff changeset
325 else {
205e4a4af635 MemList not working
kazz@kazzone.cr.ie.u-ryukyu.ac.jp
parents: 371
diff changeset
326 tileList->moveToFirst(tile);
205e4a4af635 MemList not working
kazz@kazzone.cr.ie.u-ryukyu.ac.jp
parents: 371
diff changeset
327 }
371
d38ac129badd change DrawSpan, #define USE_MEMLIST use MemList(LRU)
aaa
parents: 360
diff changeset
328 #endif
386
da7b1e5b8449 MemHash...
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 379
diff changeset
329 #endif
210
e75f9eb97180 fix DrawSpan
gongo@localhost.localdomain
parents: 193
diff changeset
330
352
9738837c225c add global_alloc.h
admin@mb22-no-macbook-2.local
parents: 338
diff changeset
331 updateBuffer(zpos, rangex, localx, localy,
9738837c225c add global_alloc.h
admin@mb22-no-macbook-2.local
parents: 338
diff changeset
332 tex_localx, tex_localy,
360
4430f0bff5cb add vacuum "-sg 16"
aaa
parents: 357
diff changeset
333 normal_x,normal_y,normal_z,tile);
210
e75f9eb97180 fix DrawSpan
gongo@localhost.localdomain
parents: 193
diff changeset
334 }
e75f9eb97180 fix DrawSpan
gongo@localhost.localdomain
parents: 193
diff changeset
335
e75f9eb97180 fix DrawSpan
gongo@localhost.localdomain
parents: 193
diff changeset
336 return -1;
e75f9eb97180 fix DrawSpan
gongo@localhost.localdomain
parents: 193
diff changeset
337 }
e75f9eb97180 fix DrawSpan
gongo@localhost.localdomain
parents: 193
diff changeset
338
e75f9eb97180 fix DrawSpan
gongo@localhost.localdomain
parents: 193
diff changeset
339 void
e75f9eb97180 fix DrawSpan
gongo@localhost.localdomain
parents: 193
diff changeset
340 DrawSpan::drawDot2(SpanPtr span, int startx, int end, int js, int wait_tag)
e75f9eb97180 fix DrawSpan
gongo@localhost.localdomain
parents: 193
diff changeset
341 {
e75f9eb97180 fix DrawSpan
gongo@localhost.localdomain
parents: 193
diff changeset
342 //printf("%d\n", js);
e75f9eb97180 fix DrawSpan
gongo@localhost.localdomain
parents: 193
diff changeset
343 }
e75f9eb97180 fix DrawSpan
gongo@localhost.localdomain
parents: 193
diff changeset
344
233
gongo@localhost.localdomain
parents: 229
diff changeset
345 /**
gongo@localhost.localdomain
parents: 229
diff changeset
346 * 長さが 1 より大きい Span の描画
gongo@localhost.localdomain
parents: 229
diff changeset
347 *
gongo@localhost.localdomain
parents: 229
diff changeset
348 * 本来の目的として、この関数(drawLine1) では
gongo@localhost.localdomain
parents: 229
diff changeset
349 * : 既に SPE 上に Tile のある pixel だけ描画
gongo@localhost.localdomain
parents: 229
diff changeset
350 * : それ以外は、ここで予め DMA load しておき、
gongo@localhost.localdomain
parents: 229
diff changeset
351 * : drawLine2 で一気に描画する
gongo@localhost.localdomain
parents: 229
diff changeset
352 * ってものだったんだけど、どうも上手く行かなかったので
gongo@localhost.localdomain
parents: 229
diff changeset
353 * 今は drawLine1 で load -> wait -> rendering を全部やってます
gongo@localhost.localdomain
parents: 229
diff changeset
354 * (rendering といっても、rendering buffer に書き込むだけで
gongo@localhost.localdomain
parents: 229
diff changeset
355 * まだ main memory (frame buffer) に dma store してるわけではない)
352
9738837c225c add global_alloc.h
admin@mb22-no-macbook-2.local
parents: 338
diff changeset
356 *
233
gongo@localhost.localdomain
parents: 229
diff changeset
357 * @param span Span
gongo@localhost.localdomain
parents: 229
diff changeset
358 * @param startx 描画開始範囲
gongo@localhost.localdomain
parents: 229
diff changeset
359 * @param endx 描画終了範囲
gongo@localhost.localdomain
parents: 229
diff changeset
360 * @return 「span のどの位置まで rendering が終わったか」の x 座標
gongo@localhost.localdomain
parents: 229
diff changeset
361 */
210
e75f9eb97180 fix DrawSpan
gongo@localhost.localdomain
parents: 193
diff changeset
362 int
e75f9eb97180 fix DrawSpan
gongo@localhost.localdomain
parents: 193
diff changeset
363 DrawSpan::drawLine1(SpanPtr span, int startx, int endx, int wait_tag)
e75f9eb97180 fix DrawSpan
gongo@localhost.localdomain
parents: 193
diff changeset
364 {
e75f9eb97180 fix DrawSpan
gongo@localhost.localdomain
parents: 193
diff changeset
365 int x = span->x;
e75f9eb97180 fix DrawSpan
gongo@localhost.localdomain
parents: 193
diff changeset
366 int rangex = endx - startx + 1;
e75f9eb97180 fix DrawSpan
gongo@localhost.localdomain
parents: 193
diff changeset
367 int x_len = span->length_x;
e75f9eb97180 fix DrawSpan
gongo@localhost.localdomain
parents: 193
diff changeset
368
315
5ae96eb47e1d add pre light
e065725@yutaka.st.ie.u-ryukyu.ac.jp
parents: 275
diff changeset
369 float normal_x = span->normal_x;
5ae96eb47e1d add pre light
e065725@yutaka.st.ie.u-ryukyu.ac.jp
parents: 275
diff changeset
370 float normal_y = span->normal_y;
5ae96eb47e1d add pre light
e065725@yutaka.st.ie.u-ryukyu.ac.jp
parents: 275
diff changeset
371 float normal_z = span->normal_z;
5ae96eb47e1d add pre light
e065725@yutaka.st.ie.u-ryukyu.ac.jp
parents: 275
diff changeset
372
5ae96eb47e1d add pre light
e065725@yutaka.st.ie.u-ryukyu.ac.jp
parents: 275
diff changeset
373
210
e75f9eb97180 fix DrawSpan
gongo@localhost.localdomain
parents: 193
diff changeset
374 int js = (x < startx) ? startx - x : 0;
e75f9eb97180 fix DrawSpan
gongo@localhost.localdomain
parents: 193
diff changeset
375 int je = (x + x_len > endx) ? endx - x : x_len;
e75f9eb97180 fix DrawSpan
gongo@localhost.localdomain
parents: 193
diff changeset
376
e75f9eb97180 fix DrawSpan
gongo@localhost.localdomain
parents: 193
diff changeset
377 /* span->x に対応する Texture の座標 (tex_xpos, tex_ypos) */
e75f9eb97180 fix DrawSpan
gongo@localhost.localdomain
parents: 193
diff changeset
378 int tex_xpos, tex_ypos;
e75f9eb97180 fix DrawSpan
gongo@localhost.localdomain
parents: 193
diff changeset
379
e75f9eb97180 fix DrawSpan
gongo@localhost.localdomain
parents: 193
diff changeset
380 // span の始点に対応する座標 (tex1, tey1)
e75f9eb97180 fix DrawSpan
gongo@localhost.localdomain
parents: 193
diff changeset
381 float tex1 = span->tex_x1;
e75f9eb97180 fix DrawSpan
gongo@localhost.localdomain
parents: 193
diff changeset
382 float tey1 = span->tex_y1;
e75f9eb97180 fix DrawSpan
gongo@localhost.localdomain
parents: 193
diff changeset
383
e75f9eb97180 fix DrawSpan
gongo@localhost.localdomain
parents: 193
diff changeset
384 // span の終点に対応する座標 (tex2, tey2)
e75f9eb97180 fix DrawSpan
gongo@localhost.localdomain
parents: 193
diff changeset
385 float tex2 = span->tex_x2;
e75f9eb97180 fix DrawSpan
gongo@localhost.localdomain
parents: 193
diff changeset
386 float tey2 = span->tex_y2;
e75f9eb97180 fix DrawSpan
gongo@localhost.localdomain
parents: 193
diff changeset
387
e75f9eb97180 fix DrawSpan
gongo@localhost.localdomain
parents: 193
diff changeset
388 // span の始点、終点に対応する z 座標
e75f9eb97180 fix DrawSpan
gongo@localhost.localdomain
parents: 193
diff changeset
389 float zpos1 = span->start_z;
e75f9eb97180 fix DrawSpan
gongo@localhost.localdomain
parents: 193
diff changeset
390 float zpos2 = span->end_z;
e75f9eb97180 fix DrawSpan
gongo@localhost.localdomain
parents: 193
diff changeset
391
e75f9eb97180 fix DrawSpan
gongo@localhost.localdomain
parents: 193
diff changeset
392 // Tile 内での座標
e75f9eb97180 fix DrawSpan
gongo@localhost.localdomain
parents: 193
diff changeset
393 int localx, localy = getLocalY(span->y-1);
e75f9eb97180 fix DrawSpan
gongo@localhost.localdomain
parents: 193
diff changeset
394
e75f9eb97180 fix DrawSpan
gongo@localhost.localdomain
parents: 193
diff changeset
395 int ret = je+1;
e75f9eb97180 fix DrawSpan
gongo@localhost.localdomain
parents: 193
diff changeset
396
e75f9eb97180 fix DrawSpan
gongo@localhost.localdomain
parents: 193
diff changeset
397 //for (int j = js; j <= je; j++) {
e75f9eb97180 fix DrawSpan
gongo@localhost.localdomain
parents: 193
diff changeset
398 for (int j = je; j >= js; j--) {
352
9738837c225c add global_alloc.h
admin@mb22-no-macbook-2.local
parents: 338
diff changeset
399 float tex_x, tex_y, tex_z;
210
e75f9eb97180 fix DrawSpan
gongo@localhost.localdomain
parents: 193
diff changeset
400
352
9738837c225c add global_alloc.h
admin@mb22-no-macbook-2.local
parents: 338
diff changeset
401 localx = getLocalX(x-1+j);
233
gongo@localhost.localdomain
parents: 229
diff changeset
402
352
9738837c225c add global_alloc.h
admin@mb22-no-macbook-2.local
parents: 338
diff changeset
403 tex_z = zpos1*(x_len-1-j)/(x_len-1) + zpos2*j/(x_len-1);
233
gongo@localhost.localdomain
parents: 229
diff changeset
404
352
9738837c225c add global_alloc.h
admin@mb22-no-macbook-2.local
parents: 338
diff changeset
405 tex_x = tex1*(x_len-1-j)/(x_len-1) + tex2*j/(x_len-1);
9738837c225c add global_alloc.h
admin@mb22-no-macbook-2.local
parents: 338
diff changeset
406 tex_y = tey1*(x_len-1-j)/(x_len-1) + tey2*j/(x_len-1);
9738837c225c add global_alloc.h
admin@mb22-no-macbook-2.local
parents: 338
diff changeset
407 if (tex_x > 1) tex_x = 1;
9738837c225c add global_alloc.h
admin@mb22-no-macbook-2.local
parents: 338
diff changeset
408 if (tex_x < 0) tex_x = 0;
9738837c225c add global_alloc.h
admin@mb22-no-macbook-2.local
parents: 338
diff changeset
409 if (tex_y > 1) tex_y = 1;
9738837c225c add global_alloc.h
admin@mb22-no-macbook-2.local
parents: 338
diff changeset
410 if (tex_y < 0) tex_y = 0;
9738837c225c add global_alloc.h
admin@mb22-no-macbook-2.local
parents: 338
diff changeset
411 tex_xpos = (int)((span->tex_width-1) * tex_x);
9738837c225c add global_alloc.h
admin@mb22-no-macbook-2.local
parents: 338
diff changeset
412 tex_ypos = (int)((span->tex_height-1) * tex_y);
9738837c225c add global_alloc.h
admin@mb22-no-macbook-2.local
parents: 338
diff changeset
413
9738837c225c add global_alloc.h
admin@mb22-no-macbook-2.local
parents: 338
diff changeset
414 if (tex_z < zRow[localx + (rangex*localy)]) {
9738837c225c add global_alloc.h
admin@mb22-no-macbook-2.local
parents: 338
diff changeset
415 // (tex_xpos, tex_ypos) の、Tile 内(上の図参照)での座標と
9738837c225c add global_alloc.h
admin@mb22-no-macbook-2.local
parents: 338
diff changeset
416 // そのブロックのアドレス(MainMemory)
373
205e4a4af635 MemList not working
kazz@kazzone.cr.ie.u-ryukyu.ac.jp
parents: 371
diff changeset
417 memaddr tex_addr;
352
9738837c225c add global_alloc.h
admin@mb22-no-macbook-2.local
parents: 338
diff changeset
418 int tex_localx;
9738837c225c add global_alloc.h
admin@mb22-no-macbook-2.local
parents: 338
diff changeset
419 int tex_localy;
210
e75f9eb97180 fix DrawSpan
gongo@localhost.localdomain
parents: 193
diff changeset
420
352
9738837c225c add global_alloc.h
admin@mb22-no-macbook-2.local
parents: 338
diff changeset
421 tex_addr = getTile(tex_xpos, tex_ypos,
373
205e4a4af635 MemList not working
kazz@kazzone.cr.ie.u-ryukyu.ac.jp
parents: 371
diff changeset
422 span->tex_width, (memaddr)span->tex_addr);
352
9738837c225c add global_alloc.h
admin@mb22-no-macbook-2.local
parents: 338
diff changeset
423 tex_localx = tex_xpos % TEXTURE_SPLIT_PIXEL;
9738837c225c add global_alloc.h
admin@mb22-no-macbook-2.local
parents: 338
diff changeset
424 tex_localy = tex_ypos % TEXTURE_SPLIT_PIXEL;
386
da7b1e5b8449 MemHash...
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 379
diff changeset
425 #if USE_MEMHASH
387
b6fce69839b5 no compile error but not worked.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 386
diff changeset
426 TilePtr tile = smanager->get_segment(tex_addr,tileList);
b6fce69839b5 no compile error but not worked.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 386
diff changeset
427 smanager->wait_segment(tile);
386
da7b1e5b8449 MemHash...
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 379
diff changeset
428 #else
373
205e4a4af635 MemList not working
kazz@kazzone.cr.ie.u-ryukyu.ac.jp
parents: 371
diff changeset
429 TilePtr tile;
360
4430f0bff5cb add vacuum "-sg 16"
aaa
parents: 357
diff changeset
430 if (!(tile = isAvailableTile(tex_addr))) {
4430f0bff5cb add vacuum "-sg 16"
aaa
parents: 357
diff changeset
431 tile = set_rgb(tex_addr, wait_tag);
352
9738837c225c add global_alloc.h
admin@mb22-no-macbook-2.local
parents: 338
diff changeset
432 smanager->dma_wait(wait_tag);
9738837c225c add global_alloc.h
admin@mb22-no-macbook-2.local
parents: 338
diff changeset
433 }
371
d38ac129badd change DrawSpan, #define USE_MEMLIST use MemList(LRU)
aaa
parents: 360
diff changeset
434 #ifdef USE_MEMLIST
373
205e4a4af635 MemList not working
kazz@kazzone.cr.ie.u-ryukyu.ac.jp
parents: 371
diff changeset
435 else {
205e4a4af635 MemList not working
kazz@kazzone.cr.ie.u-ryukyu.ac.jp
parents: 371
diff changeset
436 tileList->moveToFirst(tile);
205e4a4af635 MemList not working
kazz@kazzone.cr.ie.u-ryukyu.ac.jp
parents: 371
diff changeset
437 }
371
d38ac129badd change DrawSpan, #define USE_MEMLIST use MemList(LRU)
aaa
parents: 360
diff changeset
438 #endif
386
da7b1e5b8449 MemHash...
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 379
diff changeset
439 #endif
210
e75f9eb97180 fix DrawSpan
gongo@localhost.localdomain
parents: 193
diff changeset
440
352
9738837c225c add global_alloc.h
admin@mb22-no-macbook-2.local
parents: 338
diff changeset
441 updateBuffer(tex_z, rangex, localx, localy,
9738837c225c add global_alloc.h
admin@mb22-no-macbook-2.local
parents: 338
diff changeset
442 tex_localx, tex_localy,
360
4430f0bff5cb add vacuum "-sg 16"
aaa
parents: 357
diff changeset
443 normal_x, normal_y, normal_z, tile);
352
9738837c225c add global_alloc.h
admin@mb22-no-macbook-2.local
parents: 338
diff changeset
444 }
210
e75f9eb97180 fix DrawSpan
gongo@localhost.localdomain
parents: 193
diff changeset
445 }
e75f9eb97180 fix DrawSpan
gongo@localhost.localdomain
parents: 193
diff changeset
446
e75f9eb97180 fix DrawSpan
gongo@localhost.localdomain
parents: 193
diff changeset
447 return ret;
e75f9eb97180 fix DrawSpan
gongo@localhost.localdomain
parents: 193
diff changeset
448 }
e75f9eb97180 fix DrawSpan
gongo@localhost.localdomain
parents: 193
diff changeset
449
109
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
450 int
315
5ae96eb47e1d add pre light
e065725@yutaka.st.ie.u-ryukyu.ac.jp
parents: 275
diff changeset
451 DrawSpan::infinity_light_calc(int color,float normal_x, float normal_y, float normal_z)
5ae96eb47e1d add pre light
e065725@yutaka.st.ie.u-ryukyu.ac.jp
parents: 275
diff changeset
452 {
5ae96eb47e1d add pre light
e065725@yutaka.st.ie.u-ryukyu.ac.jp
parents: 275
diff changeset
453 unsigned char rgb[4];
325
67e82512b15b add inner_product is minus case.
e065725@yutaka.st.ie.u-ryukyu.ac.jp
parents: 321
diff changeset
454 int light_rgb;
315
5ae96eb47e1d add pre light
e065725@yutaka.st.ie.u-ryukyu.ac.jp
parents: 275
diff changeset
455 int flag;
325
67e82512b15b add inner_product is minus case.
e065725@yutaka.st.ie.u-ryukyu.ac.jp
parents: 321
diff changeset
456 float normal_vector[4] = {normal_x,normal_y,normal_z,0};
67e82512b15b add inner_product is minus case.
e065725@yutaka.st.ie.u-ryukyu.ac.jp
parents: 321
diff changeset
457 // 光のベクトル,きめうちしちゃった。どうにかする
338
d2caa52c1828 add normal vector rotate
e065725@yutaka.st.ie.u-ryukyu.ac.jp
parents: 325
diff changeset
458 float light_vector[4] = {0,0,-1,0};
325
67e82512b15b add inner_product is minus case.
e065725@yutaka.st.ie.u-ryukyu.ac.jp
parents: 321
diff changeset
459 float inner_product;
315
5ae96eb47e1d add pre light
e065725@yutaka.st.ie.u-ryukyu.ac.jp
parents: 275
diff changeset
460
325
67e82512b15b add inner_product is minus case.
e065725@yutaka.st.ie.u-ryukyu.ac.jp
parents: 321
diff changeset
461 // 引数で受け取った color の rgb 情報の抜き出し
67e82512b15b add inner_product is minus case.
e065725@yutaka.st.ie.u-ryukyu.ac.jp
parents: 321
diff changeset
462 rgb[0] = (color & 0xff000000) >> 24;
67e82512b15b add inner_product is minus case.
e065725@yutaka.st.ie.u-ryukyu.ac.jp
parents: 321
diff changeset
463 rgb[1] = (color & 0x00ff0000) >> 16;
67e82512b15b add inner_product is minus case.
e065725@yutaka.st.ie.u-ryukyu.ac.jp
parents: 321
diff changeset
464 rgb[2] = (color & 0x0000ff00) >> 8;
67e82512b15b add inner_product is minus case.
e065725@yutaka.st.ie.u-ryukyu.ac.jp
parents: 321
diff changeset
465 rgb[3] = (color & 0x000000ff);
315
5ae96eb47e1d add pre light
e065725@yutaka.st.ie.u-ryukyu.ac.jp
parents: 275
diff changeset
466
325
67e82512b15b add inner_product is minus case.
e065725@yutaka.st.ie.u-ryukyu.ac.jp
parents: 321
diff changeset
467 // 法線ベクトルと光源ベクトルとの内積をとる
315
5ae96eb47e1d add pre light
e065725@yutaka.st.ie.u-ryukyu.ac.jp
parents: 275
diff changeset
468 inner_product = innerProduct(normal_vector,light_vector);
325
67e82512b15b add inner_product is minus case.
e065725@yutaka.st.ie.u-ryukyu.ac.jp
parents: 321
diff changeset
469 // 内積がマイナスの場合は色がない。
67e82512b15b add inner_product is minus case.
e065725@yutaka.st.ie.u-ryukyu.ac.jp
parents: 321
diff changeset
470 flag = (inner_product > 0);
315
5ae96eb47e1d add pre light
e065725@yutaka.st.ie.u-ryukyu.ac.jp
parents: 275
diff changeset
471
325
67e82512b15b add inner_product is minus case.
e065725@yutaka.st.ie.u-ryukyu.ac.jp
parents: 321
diff changeset
472 // 内積を rgb にかけていく
357
6602b9ba4bfd fix spe/DrawSpan.{cpp, h} spe/DrawSpanRenew.cpp
root@henri.cr.ie.u-ryukyu.ac.jp
parents: 356
diff changeset
473 rgb[0] = (unsigned char)(rgb[0]*inner_product*flag);
6602b9ba4bfd fix spe/DrawSpan.{cpp, h} spe/DrawSpanRenew.cpp
root@henri.cr.ie.u-ryukyu.ac.jp
parents: 356
diff changeset
474 rgb[1] = (unsigned char)(rgb[1]*inner_product*flag);
6602b9ba4bfd fix spe/DrawSpan.{cpp, h} spe/DrawSpanRenew.cpp
root@henri.cr.ie.u-ryukyu.ac.jp
parents: 356
diff changeset
475 rgb[2] = (unsigned char)(rgb[2]*inner_product*flag);
352
9738837c225c add global_alloc.h
admin@mb22-no-macbook-2.local
parents: 338
diff changeset
476
325
67e82512b15b add inner_product is minus case.
e065725@yutaka.st.ie.u-ryukyu.ac.jp
parents: 321
diff changeset
477 //計算した rgb を light_rgb にまとめる。
67e82512b15b add inner_product is minus case.
e065725@yutaka.st.ie.u-ryukyu.ac.jp
parents: 321
diff changeset
478 light_rgb = (rgb[0] << 24) + (rgb[1] << 16) + (rgb[2] << 8) + (rgb[3]);
315
5ae96eb47e1d add pre light
e065725@yutaka.st.ie.u-ryukyu.ac.jp
parents: 275
diff changeset
479
5ae96eb47e1d add pre light
e065725@yutaka.st.ie.u-ryukyu.ac.jp
parents: 275
diff changeset
480 return light_rgb;
5ae96eb47e1d add pre light
e065725@yutaka.st.ie.u-ryukyu.ac.jp
parents: 275
diff changeset
481 }
5ae96eb47e1d add pre light
e065725@yutaka.st.ie.u-ryukyu.ac.jp
parents: 275
diff changeset
482
5ae96eb47e1d add pre light
e065725@yutaka.st.ie.u-ryukyu.ac.jp
parents: 275
diff changeset
483
5ae96eb47e1d add pre light
e065725@yutaka.st.ie.u-ryukyu.ac.jp
parents: 275
diff changeset
484 int
109
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
485 DrawSpan::run(void *rbuf, void *wbuf)
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
486 {
193
gongo@localhost.localdomain
parents: 189
diff changeset
487 SpanPackPtr spack = (SpanPackPtr)smanager->get_input(0);
gongo@localhost.localdomain
parents: 189
diff changeset
488 SpanPackPtr next_spack = (SpanPackPtr)smanager->allocate(sizeof(SpanPack));
gongo@localhost.localdomain
parents: 189
diff changeset
489 SpanPackPtr free_spack = next_spack; // next_spack の free() 用
gongo@localhost.localdomain
parents: 189
diff changeset
490 Span *span;
gongo@localhost.localdomain
parents: 189
diff changeset
491
210
e75f9eb97180 fix DrawSpan
gongo@localhost.localdomain
parents: 193
diff changeset
492 Span nop_span;
e75f9eb97180 fix DrawSpan
gongo@localhost.localdomain
parents: 193
diff changeset
493 nop_span.length_x = 1;
e75f9eb97180 fix DrawSpan
gongo@localhost.localdomain
parents: 193
diff changeset
494
e75f9eb97180 fix DrawSpan
gongo@localhost.localdomain
parents: 193
diff changeset
495 int (DrawSpan::*drawFunc1[2])(SpanPtr, int, int, int) = {
352
9738837c225c add global_alloc.h
admin@mb22-no-macbook-2.local
parents: 338
diff changeset
496 &DrawSpan::drawDot1, &DrawSpan::drawLine1
210
e75f9eb97180 fix DrawSpan
gongo@localhost.localdomain
parents: 193
diff changeset
497 };
e75f9eb97180 fix DrawSpan
gongo@localhost.localdomain
parents: 193
diff changeset
498
193
gongo@localhost.localdomain
parents: 189
diff changeset
499 uint32 display = smanager->get_param(0);
gongo@localhost.localdomain
parents: 189
diff changeset
500 int screen_width = smanager->get_param(1);
gongo@localhost.localdomain
parents: 189
diff changeset
501 int rangex_start = smanager->get_param(2);
352
9738837c225c add global_alloc.h
admin@mb22-no-macbook-2.local
parents: 338
diff changeset
502 int rangex_end = smanager->get_param(3);
9738837c225c add global_alloc.h
admin@mb22-no-macbook-2.local
parents: 338
diff changeset
503
193
gongo@localhost.localdomain
parents: 189
diff changeset
504 // このタスクが担当する x の範囲
gongo@localhost.localdomain
parents: 189
diff changeset
505 int rangex = rangex_end - rangex_start + 1;
gongo@localhost.localdomain
parents: 189
diff changeset
506
gongo@localhost.localdomain
parents: 189
diff changeset
507 // y の範囲
gongo@localhost.localdomain
parents: 189
diff changeset
508 int rangey = smanager->get_param(4);
386
da7b1e5b8449 MemHash...
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 379
diff changeset
509 #if !USE_MEMHASH
167
508beb59e0eb DrawSpan で使う Tile の Hash の扱いは class TileHash を生成する事に。
gongo@localhost.localdomain
parents: 166
diff changeset
510 hash = (TileHashPtr)smanager->global_get(GLOBAL_TEXTURE_HASH);
386
da7b1e5b8449 MemHash...
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 379
diff changeset
511 #endif
167
508beb59e0eb DrawSpan で使う Tile の Hash の扱いは class TileHash を生成する事に。
gongo@localhost.localdomain
parents: 166
diff changeset
512 tileList = (TileListPtr)smanager->global_get(GLOBAL_TILE_LIST);
130
40978d4b608a テクスチャの大きさを128x128以外にも使えるように。(若干バグ有り)
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 126
diff changeset
513
193
gongo@localhost.localdomain
parents: 189
diff changeset
514 zRow = zRow_init(rangex, rangey);
233
gongo@localhost.localdomain
parents: 229
diff changeset
515 //linebuf = linebuf_init(rangex, rangey, 0x00ffffff);
229
e6eb4f8d6b0e add Random class
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 221
diff changeset
516 linebuf = linebuf_init(rangex, rangey, 0);
184
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 182
diff changeset
517
193
gongo@localhost.localdomain
parents: 189
diff changeset
518 doneWrite = 0;
184
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 182
diff changeset
519
210
e75f9eb97180 fix DrawSpan
gongo@localhost.localdomain
parents: 193
diff changeset
520 int tl_tag[2] = {TEX_LOAD1, TEX_LOAD2};
e75f9eb97180 fix DrawSpan
gongo@localhost.localdomain
parents: 193
diff changeset
521 int tl_tag_flg1 = 0;
e75f9eb97180 fix DrawSpan
gongo@localhost.localdomain
parents: 193
diff changeset
522 int tl_tag_flg2 = 1;
352
9738837c225c add global_alloc.h
admin@mb22-no-macbook-2.local
parents: 338
diff changeset
523
109
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
524 do {
352
9738837c225c add global_alloc.h
admin@mb22-no-macbook-2.local
parents: 338
diff changeset
525 /**
9738837c225c add global_alloc.h
admin@mb22-no-macbook-2.local
parents: 338
diff changeset
526 * SpanPack->next が存在する場合、
9738837c225c add global_alloc.h
admin@mb22-no-macbook-2.local
parents: 338
diff changeset
527 * 現在の SpanPack を処理してる間に
9738837c225c add global_alloc.h
admin@mb22-no-macbook-2.local
parents: 338
diff changeset
528 * 次の SpanPack の DMA 転送を行う
9738837c225c add global_alloc.h
admin@mb22-no-macbook-2.local
parents: 338
diff changeset
529 */
9738837c225c add global_alloc.h
admin@mb22-no-macbook-2.local
parents: 338
diff changeset
530 if (spack->next != NULL) {
9738837c225c add global_alloc.h
admin@mb22-no-macbook-2.local
parents: 338
diff changeset
531 smanager->dma_load(next_spack, (uint32)spack->next,
9738837c225c add global_alloc.h
admin@mb22-no-macbook-2.local
parents: 338
diff changeset
532 sizeof(SpanPack), SPAN_PACK_LOAD);
9738837c225c add global_alloc.h
admin@mb22-no-macbook-2.local
parents: 338
diff changeset
533 } else {
9738837c225c add global_alloc.h
admin@mb22-no-macbook-2.local
parents: 338
diff changeset
534 next_spack = NULL;
9738837c225c add global_alloc.h
admin@mb22-no-macbook-2.local
parents: 338
diff changeset
535 }
109
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
536
352
9738837c225c add global_alloc.h
admin@mb22-no-macbook-2.local
parents: 338
diff changeset
537 SpanPtr resume_span = &nop_span;
9738837c225c add global_alloc.h
admin@mb22-no-macbook-2.local
parents: 338
diff changeset
538 int resume_span_x = 0;
210
e75f9eb97180 fix DrawSpan
gongo@localhost.localdomain
parents: 193
diff changeset
539
352
9738837c225c add global_alloc.h
admin@mb22-no-macbook-2.local
parents: 338
diff changeset
540 for (int t = 0; t < spack->info.size; t++) {
9738837c225c add global_alloc.h
admin@mb22-no-macbook-2.local
parents: 338
diff changeset
541 SpanPtr next_span;
9738837c225c add global_alloc.h
admin@mb22-no-macbook-2.local
parents: 338
diff changeset
542 int next_span_x;
210
e75f9eb97180 fix DrawSpan
gongo@localhost.localdomain
parents: 193
diff changeset
543
352
9738837c225c add global_alloc.h
admin@mb22-no-macbook-2.local
parents: 338
diff changeset
544 span = &spack->span[t];
109
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
545
352
9738837c225c add global_alloc.h
admin@mb22-no-macbook-2.local
parents: 338
diff changeset
546 /**
9738837c225c add global_alloc.h
admin@mb22-no-macbook-2.local
parents: 338
diff changeset
547 * span の長さによって、drawLine か drawDot を選択している
9738837c225c add global_alloc.h
admin@mb22-no-macbook-2.local
parents: 338
diff changeset
548 */
9738837c225c add global_alloc.h
admin@mb22-no-macbook-2.local
parents: 338
diff changeset
549 next_span_x
9738837c225c add global_alloc.h
admin@mb22-no-macbook-2.local
parents: 338
diff changeset
550 = (this->*drawFunc1[(span->length_x != 1)])(
9738837c225c add global_alloc.h
admin@mb22-no-macbook-2.local
parents: 338
diff changeset
551 span, rangex_start, rangex_end, tl_tag[tl_tag_flg1]);
9738837c225c add global_alloc.h
admin@mb22-no-macbook-2.local
parents: 338
diff changeset
552 next_span = span;
164
dc7d10ae7460 TilePtr は SPE で計算した方がいいと判断して変更。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 161
diff changeset
553
352
9738837c225c add global_alloc.h
admin@mb22-no-macbook-2.local
parents: 338
diff changeset
554 resume_span = next_span;
9738837c225c add global_alloc.h
admin@mb22-no-macbook-2.local
parents: 338
diff changeset
555 resume_span_x = next_span_x;
164
dc7d10ae7460 TilePtr は SPE で計算した方がいいと判断して変更。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 161
diff changeset
556
352
9738837c225c add global_alloc.h
admin@mb22-no-macbook-2.local
parents: 338
diff changeset
557 //smanager->dma_wait(tl_tag[tl_tag_flg1]);
9738837c225c add global_alloc.h
admin@mb22-no-macbook-2.local
parents: 338
diff changeset
558
9738837c225c add global_alloc.h
admin@mb22-no-macbook-2.local
parents: 338
diff changeset
559 tl_tag_flg1 ^= 1;
9738837c225c add global_alloc.h
admin@mb22-no-macbook-2.local
parents: 338
diff changeset
560 tl_tag_flg2 ^= 1;
9738837c225c add global_alloc.h
admin@mb22-no-macbook-2.local
parents: 338
diff changeset
561 }
184
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 182
diff changeset
562
352
9738837c225c add global_alloc.h
admin@mb22-no-macbook-2.local
parents: 338
diff changeset
563 // 現在 drawLine2、drawDot2 は機能してないので
9738837c225c add global_alloc.h
admin@mb22-no-macbook-2.local
parents: 338
diff changeset
564 //(this->*drawFunc2[(resume_span->length_x != 1)])(
9738837c225c add global_alloc.h
admin@mb22-no-macbook-2.local
parents: 338
diff changeset
565 //resume_span, rangex_start, rangex_end, resume_span_x,
9738837c225c add global_alloc.h
admin@mb22-no-macbook-2.local
parents: 338
diff changeset
566 //tl_tag[tl_tag_flg1]);
148
74341c8bf935 Span への Texture List の渡し。じゃっかん texture がバグってるので
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents: 134
diff changeset
567
352
9738837c225c add global_alloc.h
admin@mb22-no-macbook-2.local
parents: 338
diff changeset
568 smanager->dma_wait(SPAN_PACK_LOAD);
109
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
569
352
9738837c225c add global_alloc.h
admin@mb22-no-macbook-2.local
parents: 338
diff changeset
570 SpanPackPtr tmp_spack = spack;
9738837c225c add global_alloc.h
admin@mb22-no-macbook-2.local
parents: 338
diff changeset
571 spack = next_spack;
9738837c225c add global_alloc.h
admin@mb22-no-macbook-2.local
parents: 338
diff changeset
572 next_spack = tmp_spack;
182
8e9ada0c1ed0 add get_inputAddr, get_outputAddr
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 177
diff changeset
573 } while (spack);
109
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
574
193
gongo@localhost.localdomain
parents: 189
diff changeset
575 writebuffer(display, rangex, rangey, screen_width);
gongo@localhost.localdomain
parents: 189
diff changeset
576
gongo@localhost.localdomain
parents: 189
diff changeset
577 // linebuf は、writebuffer() の dma_store を wait する
gongo@localhost.localdomain
parents: 189
diff changeset
578 // DrawSpan::~DrawSpan() 内で free する。
gongo@localhost.localdomain
parents: 189
diff changeset
579 //free(linebuf);
gongo@localhost.localdomain
parents: 189
diff changeset
580 free(zRow);
184
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 182
diff changeset
581
210
e75f9eb97180 fix DrawSpan
gongo@localhost.localdomain
parents: 193
diff changeset
582 //FINISH:
193
gongo@localhost.localdomain
parents: 189
diff changeset
583 /**
gongo@localhost.localdomain
parents: 189
diff changeset
584 * goto FINISH; の時は reboot なので
gongo@localhost.localdomain
parents: 189
diff changeset
585 * linebuf, zRow は free() しない
gongo@localhost.localdomain
parents: 189
diff changeset
586 */
210
e75f9eb97180 fix DrawSpan
gongo@localhost.localdomain
parents: 193
diff changeset
587
182
8e9ada0c1ed0 add get_inputAddr, get_outputAddr
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 177
diff changeset
588 free(free_spack);
109
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
589 return 0;
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
590 }
386
da7b1e5b8449 MemHash...
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 379
diff changeset
591
da7b1e5b8449 MemHash...
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 379
diff changeset
592 /* end */