annotate TaskManager/Test/test_render/spe/DrawSpan.cpp @ 167:c8b868871dce

DrawSpan で使う Tile の Hash の扱いは class TileHash を生成する事に。
author gongo@localhost.localdomain
date Tue, 09 Dec 2008 15:07:31 +0900
parents e297ecaf2b4d
children cf2aa37d2fe7
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
109
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
1 #include <stdlib.h>
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
2 #include <string.h>
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
3 #include "DrawSpan.h"
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
4 #include "polygon_pack.h"
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
5 #include "SpanPack.h"
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
6 #include "texture.h"
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
7 #include "viewer_types.h"
167
c8b868871dce DrawSpan で使う Tile の Hash の扱いは class TileHash を生成する事に。
gongo@localhost.localdomain
parents: 166
diff changeset
8 #include "TileHash.h"
109
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
9
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
10 #define SPAN_PACK_LOAD 0
120
a52e193f9a42 fix Load Texture
gongo@gendarme.local
parents: 109
diff changeset
11 #define TEX_LOAD 1
109
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
12
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
13 SchedDefineTask(DrawSpan);
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
14
167
c8b868871dce DrawSpan で使う Tile の Hash の扱いは class TileHash を生成する事に。
gongo@localhost.localdomain
parents: 166
diff changeset
15 static TileHashPtr hash;
128
776eca0daa02 texture load use hash table
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents: 126
diff changeset
16 static TileListPtr tileList;
776eca0daa02 texture load use hash table
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents: 126
diff changeset
17
164
38cbb7aecc70 TilePtr は SPE で計算した方がいいと判断して変更。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 161
diff changeset
18 /**
38cbb7aecc70 TilePtr は SPE で計算した方がいいと判断して変更。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 161
diff changeset
19 * ƥϡTEXTURE_SPLIT_PIXEL^2 Υ֥åʬ䤹
38cbb7aecc70 TilePtr は SPE で計算した方がいいと判断して変更。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 161
diff changeset
20 *
38cbb7aecc70 TilePtr は SPE で計算した方がいいと判断して変更。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 161
diff changeset
21 * +---+---+---+---+---+---+
38cbb7aecc70 TilePtr は SPE で計算した方がいいと判断して変更。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 161
diff changeset
22 * | 0 | 1 | 2 | 3 | 4 | 5 |
38cbb7aecc70 TilePtr は SPE で計算した方がいいと判断して変更。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 161
diff changeset
23 * +---+---+---+---+---+---+
38cbb7aecc70 TilePtr は SPE で計算した方がいいと判断して変更。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 161
diff changeset
24 * | | | | | |11 |
38cbb7aecc70 TilePtr は SPE で計算した方がいいと判断して変更。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 161
diff changeset
25 * +---+---+---+---+---+---+
38cbb7aecc70 TilePtr は SPE で計算した方がいいと判断して変更。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 161
diff changeset
26 * | | | | | |17 |
38cbb7aecc70 TilePtr は SPE で計算した方がいいと判断して変更。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 161
diff changeset
27 * +---+---+---+---+---+---+
38cbb7aecc70 TilePtr は SPE で計算した方がいいと判断して変更。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 161
diff changeset
28 * | | | | | |23 |
38cbb7aecc70 TilePtr は SPE で計算した方がいいと判断して変更。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 161
diff changeset
29 * +---+---+---+---+---+---+
38cbb7aecc70 TilePtr は SPE で計算した方がいいと判断して変更。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 161
diff changeset
30 * | | | | | |29 |
38cbb7aecc70 TilePtr は SPE で計算した方がいいと判断して変更。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 161
diff changeset
31 * +---+---+---+---+---+---+
38cbb7aecc70 TilePtr は SPE で計算した方がいいと判断して変更。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 161
diff changeset
32 * | | | | | |35 |
38cbb7aecc70 TilePtr は SPE で計算した方がいいと判断して変更。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 161
diff changeset
33 * +---+---+---+---+---+---+
38cbb7aecc70 TilePtr は SPE で計算した方がいいと判断して変更。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 161
diff changeset
34 *
38cbb7aecc70 TilePtr は SPE で計算した方がいいと判断して変更。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 161
diff changeset
35 * դ TEXTURE_SPLIT Ȥ
38cbb7aecc70 TilePtr は SPE で計算した方がいいと判断して変更。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 161
diff changeset
36 * ƥ֥åο֥åIDȤʤ롣
38cbb7aecc70 TilePtr は SPE で計算した方がいいと判断して変更。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 161
diff changeset
37 */
38cbb7aecc70 TilePtr は SPE で計算した方がいいと判断して変更。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 161
diff changeset
38
38cbb7aecc70 TilePtr は SPE で計算した方がいいと判断して変更。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 161
diff changeset
39 /**
38cbb7aecc70 TilePtr は SPE で計算した方がいいと判断して変更。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 161
diff changeset
40 * ƥκɸ顢
38cbb7aecc70 TilePtr は SPE で計算した方がいいと判断して変更。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 161
diff changeset
41 * ƥΤɤΥ֥å
38cbb7aecc70 TilePtr は SPE で計算した方がいいと判断して変更。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 161
diff changeset
42 *
38cbb7aecc70 TilePtr は SPE で計算した方がいいと判断して変更。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 161
diff changeset
43 * @param[in] tx X coordinates of texture
38cbb7aecc70 TilePtr は SPE で計算した方がいいと判断して変更。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 161
diff changeset
44 * @param[in] tx Y coordinates of texture
38cbb7aecc70 TilePtr は SPE で計算した方がいいと判断して変更。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 161
diff changeset
45 * @param[in] twidth Width of texture
38cbb7aecc70 TilePtr は SPE で計算した方がいいと判断して変更。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 161
diff changeset
46 * @return block ID
38cbb7aecc70 TilePtr は SPE で計算した方がいいと判断して変更。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 161
diff changeset
47 */
38cbb7aecc70 TilePtr は SPE で計算した方がいいと判断して変更。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 161
diff changeset
48 static inline int
38cbb7aecc70 TilePtr は SPE で計算した方がいいと判断して変更。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 161
diff changeset
49 get_tex_block(int tx, int ty, int twidth)
38cbb7aecc70 TilePtr は SPE で計算した方がいいと判断して変更。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 161
diff changeset
50 {
38cbb7aecc70 TilePtr は SPE で計算した方がいいと判断して変更。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 161
diff changeset
51 int blockX, blockY;
38cbb7aecc70 TilePtr は SPE で計算した方がいいと判断して変更。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 161
diff changeset
52
38cbb7aecc70 TilePtr は SPE で計算した方がいいと判断して変更。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 161
diff changeset
53 blockX = tx / TEXTURE_SPLIT_PIXEL;
38cbb7aecc70 TilePtr は SPE で計算した方がいいと判断して変更。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 161
diff changeset
54 blockY = ty / TEXTURE_SPLIT_PIXEL;
38cbb7aecc70 TilePtr は SPE で計算した方がいいと判断して変更。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 161
diff changeset
55
38cbb7aecc70 TilePtr は SPE で計算した方がいいと判断して変更。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 161
diff changeset
56 return blockX + (twidth/TEXTURE_SPLIT_PIXEL)*blockY;
38cbb7aecc70 TilePtr は SPE で計算した方がいいと判断して変更。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 161
diff changeset
57 }
38cbb7aecc70 TilePtr は SPE で計算した方がいいと判断して変更。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 161
diff changeset
58
38cbb7aecc70 TilePtr は SPE で計算した方がいいと判断して変更。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 161
diff changeset
59 /**
38cbb7aecc70 TilePtr は SPE で計算した方がいいと判断して変更。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 161
diff changeset
60 * block ID ȡƥ TOP address
38cbb7aecc70 TilePtr は SPE で計算した方がいいと判断して変更。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 161
diff changeset
61 * (tx,ty) ǻȤƥ Tile addres
38cbb7aecc70 TilePtr は SPE で計算した方がいいと判断して変更。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 161
diff changeset
62 *
38cbb7aecc70 TilePtr は SPE で計算した方がいいと判断して変更。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 161
diff changeset
63 * @param[in] tx X coordinates of texture
38cbb7aecc70 TilePtr は SPE で計算した方がいいと判断して変更。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 161
diff changeset
64 * @param[in] tx Y coordinates of texture
38cbb7aecc70 TilePtr は SPE で計算した方がいいと判断して変更。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 161
diff changeset
65 * @param[in] tw Width of texture
38cbb7aecc70 TilePtr は SPE で計算した方がいいと判断して変更。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 161
diff changeset
66 * @param[in] tex_addr_top (tx,ty) ǻȤƥƬaddress
38cbb7aecc70 TilePtr は SPE で計算した方がいいと判断して変更。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 161
diff changeset
67 * @return block ID
38cbb7aecc70 TilePtr は SPE で計算した方がいいと判断して変更。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 161
diff changeset
68 */
38cbb7aecc70 TilePtr は SPE で計算した方がいいと判断して変更。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 161
diff changeset
69 static inline uint32*
38cbb7aecc70 TilePtr は SPE で計算した方がいいと判断して変更。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 161
diff changeset
70 getTile(int tx, int ty, int tw, uint32 *tex_addr_top)
38cbb7aecc70 TilePtr は SPE で計算した方がいいと判断して変更。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 161
diff changeset
71 {
38cbb7aecc70 TilePtr は SPE で計算した方がいいと判断して変更。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 161
diff changeset
72 int block = get_tex_block(tx, ty, tw);
38cbb7aecc70 TilePtr は SPE で計算した方がいいと判断して変更。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 161
diff changeset
73 return tex_addr_top + block*TEXTURE_BLOCK_SIZE;
38cbb7aecc70 TilePtr は SPE で計算した方がいいと判断して変更。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 161
diff changeset
74 }
38cbb7aecc70 TilePtr は SPE で計算した方がいいと判断して変更。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 161
diff changeset
75
109
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
76 void
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
77 DrawSpan::linebuf_init(int *buf, int x, int rgb)
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
78 {
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
79 for (int i = 0; i < x; i++) {
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
80 buf[i] = rgb;
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
81 }
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
82 }
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
83
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
84 float*
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
85 DrawSpan::zRow_init(int w, int h)
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
86 {
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
87 float *zRow = NULL;
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
88 float z = 65535.0f;
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
89 int length = w*h;
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
90
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
91 zRow = (float*)smanager->allocate(sizeof(float)*length);
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
92
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
93 for (int i = 0; i < length; i++) {
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
94 zRow[i] = z;
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
95 }
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
96
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
97 return zRow;
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
98 }
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
99
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
100
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
101 char*
166
gongo@localhost.localdomain
parents: 165
diff changeset
102 DrawSpan::get_pixel(int tx, int ty, uint32 *texture_image)
109
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
103 {
166
gongo@localhost.localdomain
parents: 165
diff changeset
104 return (char*)(texture_image+((TEXTURE_SPLIT_PIXEL)*ty+tx));
109
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
105 }
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
106
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
107 Uint32
166
gongo@localhost.localdomain
parents: 165
diff changeset
108 DrawSpan::get_rgb(int tx, int ty, uint32 *addr)
109
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
109 {
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
110 Uint8 red, green, blue, alpha;
148
9642aeef298d Span への Texture List の渡し。じゃっかん texture がバグってるので
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents: 147
diff changeset
111 TilePtr tile;
109
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
112
131
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents: 128
diff changeset
113 /**
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents: 128
diff changeset
114 * get,put ϥ֥(HashȤ)äƥ뤫
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents: 128
diff changeset
115 */
167
c8b868871dce DrawSpan で使う Tile の Hash の扱いは class TileHash を生成する事に。
gongo@localhost.localdomain
parents: 166
diff changeset
116 tile = hash->get(addr);
128
776eca0daa02 texture load use hash table
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents: 126
diff changeset
117 if (tile == NULL) {
776eca0daa02 texture load use hash table
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents: 126
diff changeset
118 if (tileList->size >= MAX_TILE) {
776eca0daa02 texture load use hash table
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents: 126
diff changeset
119 tileList->init();
167
c8b868871dce DrawSpan で使う Tile の Hash の扱いは class TileHash を生成する事に。
gongo@localhost.localdomain
parents: 166
diff changeset
120 hash->clear();
128
776eca0daa02 texture load use hash table
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents: 126
diff changeset
121 }
776eca0daa02 texture load use hash table
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents: 126
diff changeset
122
776eca0daa02 texture load use hash table
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents: 126
diff changeset
123 tile = &tileList->tile[tileList->size];
156
gongo@gendarme.local
parents: 155
diff changeset
124 tile->texture_addr = addr;
120
a52e193f9a42 fix Load Texture
gongo@gendarme.local
parents: 109
diff changeset
125
156
gongo@gendarme.local
parents: 155
diff changeset
126 smanager->dma_load(tile->pixel, (uint32)addr,
161
1f4c3f3238e6 texture の座標がマイナスになったあと、それを 0 にし忘れてた
gongo@localhost.localdomain
parents: 156
diff changeset
127 sizeof(uint32)*TEXTURE_BLOCK_SIZE, TEX_LOAD);
128
776eca0daa02 texture load use hash table
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents: 126
diff changeset
128
167
c8b868871dce DrawSpan で使う Tile の Hash の扱いは class TileHash を生成する事に。
gongo@localhost.localdomain
parents: 166
diff changeset
129 int index = hash->put(tile->texture_addr, tile);
131
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents: 128
diff changeset
130
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents: 128
diff changeset
131 /**
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents: 128
diff changeset
132 * TODO:
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents: 128
diff changeset
133 * ʤäĤ
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents: 128
diff changeset
134 * ޤǤΤĤ褷Ƥ³򤹤Ȥ
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents: 128
diff changeset
135 */
128
776eca0daa02 texture load use hash table
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents: 126
diff changeset
136 if (index < 0) {
776eca0daa02 texture load use hash table
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents: 126
diff changeset
137 printf("[%p] Can't entry\n", tile);
776eca0daa02 texture load use hash table
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents: 126
diff changeset
138 return 0xff0000;
776eca0daa02 texture load use hash table
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents: 126
diff changeset
139 }
776eca0daa02 texture load use hash table
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents: 126
diff changeset
140
776eca0daa02 texture load use hash table
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents: 126
diff changeset
141 tileList->size++;
776eca0daa02 texture load use hash table
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents: 126
diff changeset
142
776eca0daa02 texture load use hash table
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents: 126
diff changeset
143 smanager->dma_wait(TEX_LOAD);
776eca0daa02 texture load use hash table
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents: 126
diff changeset
144 }
776eca0daa02 texture load use hash table
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents: 126
diff changeset
145
156
gongo@gendarme.local
parents: 155
diff changeset
146 char *p = get_pixel(tx, ty, tile->pixel);
120
a52e193f9a42 fix Load Texture
gongo@gendarme.local
parents: 109
diff changeset
147
126
7635f223fc7d fix RGBA mask (bgr -> rgba)
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents: 123
diff changeset
148 alpha = 255;
7635f223fc7d fix RGBA mask (bgr -> rgba)
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents: 123
diff changeset
149 red = (Uint8) p[0];
109
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
150 green = (Uint8) p[1];
126
7635f223fc7d fix RGBA mask (bgr -> rgba)
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents: 123
diff changeset
151 blue = (Uint8) p[2];
109
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
152
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
153 return (red & 0xff) * 0x10000 + (green & 0xff) * 0x100
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
154 + (blue & 0xff) + (alpha << 24);
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
155 }
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
156
164
38cbb7aecc70 TilePtr は SPE で計算した方がいいと判断して変更。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 161
diff changeset
157
38cbb7aecc70 TilePtr は SPE で計算した方がいいと判断して変更。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 161
diff changeset
158
109
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
159 int
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
160 DrawSpan::run(void *rbuf, void *wbuf)
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
161 {
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
162 SpanPack *sp = (SpanPack*)smanager->get_input(0);
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
163 SpanPack *next_sp =
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
164 (SpanPack*)smanager->allocate(sizeof(SpanPack));
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
165 SpanPack *free_sp = next_sp; // next_sp free()
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
166 SpanPack *tmp_sp = NULL;
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
167 Span *span;
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
168
167
c8b868871dce DrawSpan で使う Tile の Hash の扱いは class TileHash を生成する事に。
gongo@localhost.localdomain
parents: 166
diff changeset
169 hash = (TileHashPtr)smanager->global_get(GLOBAL_TEXTURE_HASH);
c8b868871dce DrawSpan で使う Tile の Hash の扱いは class TileHash を生成する事に。
gongo@localhost.localdomain
parents: 166
diff changeset
170 tileList = (TileListPtr)smanager->global_get(GLOBAL_TILE_LIST);
128
776eca0daa02 texture load use hash table
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents: 126
diff changeset
171
109
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
172 int rangex_start = get_param(0); // Υô x ϰϤλ
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
173 int rangex_end = get_param(1); // (start <= x <= end)
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
174 int rangey = get_param(2); // y ϰ (render_y + rangey - 1)
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
175 int rangex = rangex_end - rangex_start + 1;
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
176
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
177 float *zRow = zRow_init(rangex, rangey);
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
178 int **linebuf = (int**)smanager->allocate(sizeof(int*)*rangey);
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
179
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
180 for (int i = 0; i < rangey; i++) {
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
181 linebuf[i] = (int*)smanager->get_output(i);
133
435e0d24db39 DrawSpan のテクスチャ座標を求める部分で、width と height が逆に使われてた。
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents: 131
diff changeset
182 linebuf_init(linebuf[i], rangex, 0xffffff);
109
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
183 }
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
184
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
185 do {
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
186 /**
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
187 * SpanPack->next ¸ߤ硢
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
188 * ߤ SpanPack Ƥ֤
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
189 * SpanPack DMA žԤ
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
190 */
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
191 if (sp->next != NULL) {
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
192 smanager->dma_load(next_sp, (uint32)sp->next,
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
193 sizeof(SpanPack), SPAN_PACK_LOAD);
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
194 } else {
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
195 next_sp = NULL;
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
196 }
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
197
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
198 for (int t = 0; t < sp->info.size; t++) {
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
199 span = &sp->span[t];
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
200
164
38cbb7aecc70 TilePtr は SPE で計算した方がいいと判断して変更。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 161
diff changeset
201 Uint32 rgb = 0x00ff00;
38cbb7aecc70 TilePtr は SPE で計算した方がいいと判断して変更。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 161
diff changeset
202 float tex1 = span->tex_x1;
38cbb7aecc70 TilePtr は SPE で計算した方がいいと判断して変更。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 161
diff changeset
203 float tex2 = span->tex_x2;
38cbb7aecc70 TilePtr は SPE で計算した方がいいと判断して変更。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 161
diff changeset
204 float tey1 = span->tex_y1;
38cbb7aecc70 TilePtr は SPE で計算した方がいいと判断して変更。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 161
diff changeset
205 float tey2 = span->tex_y2;
147
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents: 133
diff changeset
206
166
gongo@localhost.localdomain
parents: 165
diff changeset
207 /**
gongo@localhost.localdomain
parents: 165
diff changeset
208 * Span 1 pixel
gongo@localhost.localdomain
parents: 165
diff changeset
209 * ƥκɸ
gongo@localhost.localdomain
parents: 165
diff changeset
210 */
109
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
211 int tex_xpos;
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
212 int tex_ypos;
164
38cbb7aecc70 TilePtr は SPE で計算した方がいいと判断して変更。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 161
diff changeset
213
166
gongo@localhost.localdomain
parents: 165
diff changeset
214 /**
gongo@localhost.localdomain
parents: 165
diff changeset
215 * (tex_xpos, tex_ypos) Ρ֥å(ο޻)Ǥκɸ
gongo@localhost.localdomain
parents: 165
diff changeset
216 * Υ֥åΥɥ쥹(MainMemory)
gongo@localhost.localdomain
parents: 165
diff changeset
217 */
164
38cbb7aecc70 TilePtr は SPE で計算した方がいいと判断して変更。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 161
diff changeset
218 int tex_localx;
38cbb7aecc70 TilePtr は SPE で計算した方がいいと判断して変更。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 161
diff changeset
219 int tex_localy;
38cbb7aecc70 TilePtr は SPE で計算した方がいいと判断して変更。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 161
diff changeset
220 uint32 *tex_addr;
38cbb7aecc70 TilePtr は SPE で計算した方がいいと判断して変更。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 161
diff changeset
221
109
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
222 int x = span->x;
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
223 int y = span->y;
133
435e0d24db39 DrawSpan のテクスチャ座標を求める部分で、width と height が逆に使われてた。
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents: 131
diff changeset
224 int x_len = span->length_x;
109
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
225 float z = span->start_z;
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
226 float zpos = span->end_z;
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
227
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
228 // ɸ [0 .. split_screen_w-1] 褦 x,y -1
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
229 int localx = getLocalX(x-1);
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
230 int localy = getLocalY(y-1);
131
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents: 128
diff changeset
231
133
435e0d24db39 DrawSpan のテクスチャ座標を求める部分で、width と height が逆に使われてた。
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents: 131
diff changeset
232 if (x_len == 1) {
109
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
233 if (x < rangex_start || rangex_end < x) {
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
234 continue;
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
235 }
148
9642aeef298d Span への Texture List の渡し。じゃっかん texture がバグってるので
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents: 147
diff changeset
236
164
38cbb7aecc70 TilePtr は SPE で計算した方がいいと判断して変更。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 161
diff changeset
237 tex_xpos = (int)((span->tex_width-1) * tex1);
38cbb7aecc70 TilePtr は SPE で計算した方がいいと判断して変更。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 161
diff changeset
238 tex_ypos = (int)((span->tex_height-1) * tey1);
109
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
239
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
240 if (zpos < zRow[localx + (rangex * localy)]) {
166
gongo@localhost.localdomain
parents: 165
diff changeset
241 tex_addr = getTile(tex_xpos, tex_ypos,
gongo@localhost.localdomain
parents: 165
diff changeset
242 span->tex_width, span->tex_addr);
164
38cbb7aecc70 TilePtr は SPE で計算した方がいいと判断して変更。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 161
diff changeset
243 tex_localx = tex_xpos % TEXTURE_SPLIT_PIXEL;
38cbb7aecc70 TilePtr は SPE で計算した方がいいと判断して変更。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 161
diff changeset
244 tex_localy = tex_ypos % TEXTURE_SPLIT_PIXEL;
166
gongo@localhost.localdomain
parents: 165
diff changeset
245
164
38cbb7aecc70 TilePtr は SPE で計算した方がいいと判断して変更。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 161
diff changeset
246 rgb = get_rgb(tex_localx, tex_localy, tex_addr);
38cbb7aecc70 TilePtr は SPE で計算した方がいいと判断して変更。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 161
diff changeset
247
109
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
248 zRow[localx + (rangex * localy)] = zpos;
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
249 linebuf[localy][localx] = rgb;
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
250 }
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
251 } else {
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
252 int js = (x < rangex_start) ? rangex_start - x : 0;
133
435e0d24db39 DrawSpan のテクスチャ座標を求める部分で、width と height が逆に使われてた。
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents: 131
diff changeset
253 int je = (x + x_len > rangex_end) ? rangex_end - x : x_len;
164
38cbb7aecc70 TilePtr は SPE で計算した方がいいと判断して変更。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 161
diff changeset
254 float tex_x, tex_y, tex_z;
109
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
255
164
38cbb7aecc70 TilePtr は SPE で計算した方がいいと判断して変更。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 161
diff changeset
256 for (int j = js; j <= je; j++) {
38cbb7aecc70 TilePtr は SPE で計算した方がいいと判断して変更。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 161
diff changeset
257 localx = getLocalX(x-1+j);
148
9642aeef298d Span への Texture List の渡し。じゃっかん texture がバグってるので
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents: 147
diff changeset
258
164
38cbb7aecc70 TilePtr は SPE で計算した方がいいと判断して変更。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 161
diff changeset
259 tex_z = z*(x_len-1-j)/(x_len-1) + zpos*j/(x_len-1);
133
435e0d24db39 DrawSpan のテクスチャ座標を求める部分で、width と height が逆に使われてた。
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents: 131
diff changeset
260
164
38cbb7aecc70 TilePtr は SPE で計算した方がいいと判断して変更。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 161
diff changeset
261 tex_x = tex1*(x_len-1-j)/(x_len-1) + tex2*j/(x_len-1);
38cbb7aecc70 TilePtr は SPE で計算した方がいいと判断して変更。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 161
diff changeset
262 tex_y = tey1*(x_len-1-j)/(x_len-1) + tey2*j/(x_len-1);
165
gongo@localhost.localdomain
parents: 164
diff changeset
263 /**
gongo@localhost.localdomain
parents: 164
diff changeset
264 * ʤ󤫤äʤ
gongo@localhost.localdomain
parents: 164
diff changeset
265 */
164
38cbb7aecc70 TilePtr は SPE で計算した方がいいと判断して変更。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 161
diff changeset
266 if (tex_x > 1) tex_x = 1;
165
gongo@localhost.localdomain
parents: 164
diff changeset
267 if (tex_x < 0) tex_x = 0;
164
38cbb7aecc70 TilePtr は SPE で計算した方がいいと判断して変更。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 161
diff changeset
268 if (tex_y > 1) tex_y = 1;
165
gongo@localhost.localdomain
parents: 164
diff changeset
269 if (tex_y < 0) tex_y = 0;
164
38cbb7aecc70 TilePtr は SPE で計算した方がいいと判断して変更。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 161
diff changeset
270 tex_xpos = (int)((span->tex_width-1) * tex_x);
38cbb7aecc70 TilePtr は SPE で計算した方がいいと判断して変更。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 161
diff changeset
271 tex_ypos = (int)((span->tex_height-1) * tex_y);
38cbb7aecc70 TilePtr は SPE で計算した方がいいと判断して変更。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 161
diff changeset
272
38cbb7aecc70 TilePtr は SPE で計算した方がいいと判断して変更。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 161
diff changeset
273 if (tex_z < zRow[localx + (rangex*localy)]) {
166
gongo@localhost.localdomain
parents: 165
diff changeset
274 tex_addr = getTile(tex_xpos, tex_ypos,
gongo@localhost.localdomain
parents: 165
diff changeset
275 span->tex_width, span->tex_addr);
164
38cbb7aecc70 TilePtr は SPE で計算した方がいいと判断して変更。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 161
diff changeset
276 tex_localx = tex_xpos % TEXTURE_SPLIT_PIXEL;
38cbb7aecc70 TilePtr は SPE で計算した方がいいと判断して変更。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 161
diff changeset
277 tex_localy = tex_ypos % TEXTURE_SPLIT_PIXEL;
38cbb7aecc70 TilePtr は SPE で計算した方がいいと判断して変更。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 161
diff changeset
278
38cbb7aecc70 TilePtr は SPE で計算した方がいいと判断して変更。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 161
diff changeset
279 rgb = get_rgb(tex_localx, tex_localy, tex_addr);
148
9642aeef298d Span への Texture List の渡し。じゃっかん texture がバグってるので
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents: 147
diff changeset
280
164
38cbb7aecc70 TilePtr は SPE で計算した方がいいと判断して変更。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 161
diff changeset
281 zRow[localx + (rangex*localy)] = tex_z;
38cbb7aecc70 TilePtr は SPE で計算した方がいいと判断して変更。
gongo@gendarme.cr.ie.u-ryukyu.ac.jp
parents: 161
diff changeset
282 linebuf[localy][localx] = rgb;
147
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents: 133
diff changeset
283 }
109
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
284 }
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
285 }
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
286 }
147
gongo@charles.cr.ie.u-ryukyu.ac.jp
parents: 133
diff changeset
287
109
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
288 smanager->dma_wait(SPAN_PACK_LOAD);
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
289
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
290 tmp_sp = sp;
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
291 sp = next_sp;
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
292 next_sp = tmp_sp;
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
293 } while (sp);
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
294
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
295 free(free_sp);
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
296 free(linebuf);
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
297 free(zRow);
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
298
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
299 return 0;
5c194c71eca8 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
300 }