283
|
1 #ifndef INCLUDED_TAPESTRY
|
|
2 #define INCLUDED_TAPESTRY
|
|
3
|
507
|
4 #include "types.h"
|
|
5 #include "viewer_types.h"
|
|
6 #include "MemorySegment.h"
|
|
7 #include "MemList.h"
|
283
|
8
|
|
9 /**
|
|
10 * image file name と tapestry DB の binary tree
|
|
11 *
|
|
12 * // PPE
|
|
13 * main memory の tapestry DB (Array)
|
507
|
14 * tapestry DB への accessor
|
283
|
15 *
|
|
16 * TapestryPtr getTapestry(int TapestryID);
|
|
17 * TilePtr getTile(TapestryPtr tapsetry, int tx, int ty, int scale);
|
|
18 *
|
|
19 * SPE が生成する tapestry List (in CreateSpan)
|
|
20 * (no texture image)
|
|
21 * @in TapestryDBPtr, Tapestry ID, x, y, tx, ty, px, py
|
|
22 * x, y : polygon の中の平面座標
|
|
23 * tx, ty : texture の座標
|
|
24 * px, py : texture の分割数
|
|
25 *
|
|
26 * @out (TilePtr, tix1, tiy1, tix2, tiy2)*
|
507
|
27 *
|
283
|
28 *
|
|
29 * SPE に渡す tapestry List
|
|
30 * @in Tile
|
|
31 *
|
|
32 * // SPE
|
|
33 * SPE 内部での tapestry DB (Hash)
|
|
34 * TapestryID, scale, TilePtr, Tile
|
|
35 *
|
|
36 *
|
|
37 * SPE 内部での tapestry DB への accessor
|
|
38 * TileEntryPtr getTile(int TapestryID, int tx, int ty, int scale);
|
|
39 *
|
|
40 * if (TileEntry == NULL) {
|
|
41 * DMA read
|
|
42 * }
|
507
|
43 *
|
283
|
44 *
|
|
45 * Rendering
|
|
46 * 1pass Zbuffer と Texture の有無の判定
|
|
47 * if (zbuffer ok) {
|
|
48 * if (texture ある) {
|
|
49 * zbuffer 、linebunf に書き込む
|
|
50 * } else {
|
|
51 * texture の load list に加える
|
|
52 * zbuffer だけ更新しておく
|
|
53 * }
|
|
54 * } else {
|
|
55 * 無視
|
|
56 * }
|
|
57 *
|
|
58 * 1pass で texture が一杯になったら、中断して
|
|
59 * ここまでのを書き込んどけ
|
|
60 *
|
|
61 *
|
|
62 * 2pass rgb の書き込み
|
|
63 *
|
|
64 * if (zbuffer の値が自分と一緒) {
|
|
65 * read した texture みて
|
|
66 * 書き込め!
|
|
67 * }
|
|
68 *
|
|
69 */
|
|
70 struct texture_block {
|
507
|
71
|
283
|
72 };
|
|
73
|
507
|
74 #ifdef USE_MEMLIST
|
|
75 typedef MemorySegment Tile, *TilePtr;
|
|
76 #else
|
283
|
77 typedef struct {
|
507
|
78 uint32 data[TEXTURE_BLOCK_SIZE]; // 8*8
|
|
79 uint32 *address;
|
283
|
80 int pad[3];
|
|
81 } Tile, *TilePtr;
|
507
|
82 #endif
|
283
|
83
|
|
84 #define MAX_TILE 128
|
|
85
|
|
86 /**
|
|
87 * TileList 中の Tile の追い出しは、現在 FIFO で実装している
|
507
|
88 * これは汎用のサイズ別 freelist に置き換える
|
|
89 * freelist は double linked list で、LRU をサポートする
|
|
90 */
|
|
91 #ifdef USE_MEMLIST
|
|
92 class TileList : public MemList {
|
|
93 TileList(MemorySegment* ms) : MemList(ms) {}
|
|
94
|
|
95 /*!
|
|
96 中身は同じ
|
283
|
97 */
|
507
|
98 };
|
|
99 #else
|
283
|
100 class TileList {
|
|
101 public:
|
|
102 int curIndex;
|
|
103 int pad[3];
|
|
104 Tile tile[MAX_TILE];
|
|
105
|
|
106 TileList(void) {
|
507
|
107 curIndex = 0;
|
283
|
108 }
|
|
109
|
|
110 /**
|
|
111 * 次に扱う tile を取得する
|
|
112 *
|
|
113 * @return tile
|
|
114 *
|
|
115 * tile[] をリングバスっぽく扱うことで
|
|
116 * FIFO を実現することに。
|
|
117 */
|
|
118 TilePtr nextTile(void) {
|
507
|
119 TilePtr t = &tile[curIndex];
|
|
120 curIndex = (curIndex + 1) % MAX_TILE;
|
|
121 return t;
|
283
|
122 }
|
|
123
|
|
124 /**
|
|
125 * TileList のクリア
|
|
126 * //tile 自体は clear する必要は無い
|
|
127 * あるかもしれない
|
|
128 */
|
|
129 void clear(void) {
|
507
|
130 curIndex = 0;
|
283
|
131 }
|
|
132 };
|
507
|
133 #endif
|
283
|
134
|
|
135 typedef TileList* TileListPtr;
|
|
136
|
|
137 #endif
|