annotate Renderer/Engine/task/DrawSpan.cc @ 1277:4ba9b622073d draft

merge
author Yutaka_Kinjyo <yutaka@cr.ie.u-ryukyu.ac.jp>
date Tue, 22 Nov 2011 19:40:47 +0900
parents e92f00ed2fc0 880f989ce52a
children 90efd2aac2cb
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
539
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1 #include <stdlib.h>
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
2 #include <string.h>
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
3 #include "DrawSpan.h"
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
4 #include "polygon_pack.h"
860
63a08f3a468a Still on the way
yutaka@localhost.localdomain
parents: 855
diff changeset
5 #include "task_texture.h"
539
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
6 #include "viewer_types.h"
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
7 #include "Func.h"
616
350b9b8c985f First addOutput rendering try failed.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 615
diff changeset
8 #include "SchedTask.h"
350b9b8c985f First addOutput rendering try failed.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 615
diff changeset
9 #include "Tapestry.h"
350b9b8c985f First addOutput rendering try failed.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 615
diff changeset
10 #include "SpanPack.h"
1050
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1047
diff changeset
11 #include "matrix_calc.h"
616
350b9b8c985f First addOutput rendering try failed.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 615
diff changeset
12
623
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 622
diff changeset
13 #if (__LITTLE_ENDIAN__)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 622
diff changeset
14 #define LITTLEENDIAN 1
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 622
diff changeset
15 #else
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 622
diff changeset
16 #define LITTLEENDIAN 0
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 622
diff changeset
17 #endif
539
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
18
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
19 SchedDefineTask(DrawSpan);
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
20
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
21 #define TEX_LOAD1 0
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
22 #define TEX_LOAD2 1
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
23 #define SPAN_PACK_LOAD 2
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
24 #define FB_STORE 3
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
25
616
350b9b8c985f First addOutput rendering try failed.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 615
diff changeset
26 typedef struct {
350b9b8c985f First addOutput rendering try failed.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 615
diff changeset
27 int **linebuf;
350b9b8c985f First addOutput rendering try failed.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 615
diff changeset
28 float *zRow;
350b9b8c985f First addOutput rendering try failed.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 615
diff changeset
29 TileListPtr tileList;
350b9b8c985f First addOutput rendering try failed.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 615
diff changeset
30 int doneWrite;
350b9b8c985f First addOutput rendering try failed.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 615
diff changeset
31 } G, *Gptr;
603
57ec231bc8ac long -> memaddr (64 or 32)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 602
diff changeset
32
1158
bfc2c6628fef not yet
Yutaka_Kinjyo
parents: 1157
diff changeset
33 /*double buffering するために、保持すべき状態*/
bfc2c6628fef not yet
Yutaka_Kinjyo
parents: 1157
diff changeset
34 typedef struct DrawParam {
bfc2c6628fef not yet
Yutaka_Kinjyo
parents: 1157
diff changeset
35
bfc2c6628fef not yet
Yutaka_Kinjyo
parents: 1157
diff changeset
36 float tex_z;
bfc2c6628fef not yet
Yutaka_Kinjyo
parents: 1157
diff changeset
37 int localx;
bfc2c6628fef not yet
Yutaka_Kinjyo
parents: 1157
diff changeset
38 int tex_localx;
bfc2c6628fef not yet
Yutaka_Kinjyo
parents: 1157
diff changeset
39 int tex_localy;
bfc2c6628fef not yet
Yutaka_Kinjyo
parents: 1157
diff changeset
40 TilePtr tile;
bfc2c6628fef not yet
Yutaka_Kinjyo
parents: 1157
diff changeset
41 float world_z;
1159
42f5958ab74e not yet....
Yutaka_Kinjyo
parents: 1158
diff changeset
42 int x;
1158
bfc2c6628fef not yet
Yutaka_Kinjyo
parents: 1157
diff changeset
43 int display; //他のオブジェクトの裏にいて表示するかしないかのflag
bfc2c6628fef not yet
Yutaka_Kinjyo
parents: 1157
diff changeset
44
bfc2c6628fef not yet
Yutaka_Kinjyo
parents: 1157
diff changeset
45 } DrawParam, *DrawParamPtr;
bfc2c6628fef not yet
Yutaka_Kinjyo
parents: 1157
diff changeset
46
bfc2c6628fef not yet
Yutaka_Kinjyo
parents: 1157
diff changeset
47
616
350b9b8c985f First addOutput rendering try failed.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 615
diff changeset
48 static int** linebuf_init(SchedTask *smanager, int width, int height, int rgb);
350b9b8c985f First addOutput rendering try failed.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 615
diff changeset
49 static float* zRow_init(SchedTask *smanager, int width, int height);
350b9b8c985f First addOutput rendering try failed.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 615
diff changeset
50 // static TilePtr set_rgb(memaddr addr, int wait_tag);
350b9b8c985f First addOutput rendering try failed.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 615
diff changeset
51 // static void set_rgbs(memaddr addr, uint32 *max_addr, int wait_tag);
350b9b8c985f First addOutput rendering try failed.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 615
diff changeset
52 static uint32 get_rgb(int tx, int ty, TilePtr tile);
350b9b8c985f First addOutput rendering try failed.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 615
diff changeset
53 // static TilePtr isAvailableTile(memaddr addr);
350b9b8c985f First addOutput rendering try failed.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 615
diff changeset
54 static memaddr getTile(int tx, int ty, int tw, memaddr tex_addr_top);
350b9b8c985f First addOutput rendering try failed.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 615
diff changeset
55 static int getTexBlock(int tx, int ty, int twidth);
350b9b8c985f First addOutput rendering try failed.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 615
diff changeset
56
738
yutaka@localhost.localdomain
parents: 625
diff changeset
57 static void updateBuffer(Gptr g, float zpos, int rangex, int loaclx, int localy,
yutaka@localhost.localdomain
parents: 625
diff changeset
58 int tex_x, int tex_y, float normal_x, float nomral_x, float normal_z,
yutaka@localhost.localdomain
parents: 625
diff changeset
59 TilePtr tile, int world_x, int world_y, float world_z,SchedTask *smanager);
616
350b9b8c985f First addOutput rendering try failed.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 615
diff changeset
60
350b9b8c985f First addOutput rendering try failed.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 615
diff changeset
61 // static void reboot(SpanPackPtr spack, int cur_span_x);
350b9b8c985f First addOutput rendering try failed.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 615
diff changeset
62
350b9b8c985f First addOutput rendering try failed.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 615
diff changeset
63 static int drawDot1(SchedTask *smanager, Gptr g, SpanPtr span, int startx, int endx, int wait_tag);
350b9b8c985f First addOutput rendering try failed.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 615
diff changeset
64 //static void drawDot2(SchedTask *smanager, SpanPtr span, int startx, int endx, int js, int wait_tag);
350b9b8c985f First addOutput rendering try failed.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 615
diff changeset
65 static int drawLine1(SchedTask *smanager, Gptr g, SpanPtr span, int startx, int endx, int wait_tag);
350b9b8c985f First addOutput rendering try failed.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 615
diff changeset
66 // static void drawLine2(SchedTask *smanager, SpanPtr span, int startx, int endx, int js, int wait_tag);
738
yutaka@localhost.localdomain
parents: 625
diff changeset
67
1256
880f989ce52a fix rsync
Yuhi TOMARI <e095740@ie.u-ryukyu.ac.jp>
parents: 1163
diff changeset
68 //static int getDrawParam(SchedTask *smanager, Gptr g, SpanPtr span, int localy, int startx, int endx, int index, int j, DrawParamPtr param);
1157
ea68d54411a7 not yet
Yutaka_Kinjyo
parents: 1145
diff changeset
69
738
yutaka@localhost.localdomain
parents: 625
diff changeset
70 static int infinity_light_calc(int color,float normal_x, float normal_y, float normal_z,
yutaka@localhost.localdomain
parents: 625
diff changeset
71 SchedTask *smanager,int x, int y, float z, int world_x, int world_y, float world_z);
yutaka@localhost.localdomain
parents: 625
diff changeset
72
616
350b9b8c985f First addOutput rendering try failed.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 615
diff changeset
73
1157
ea68d54411a7 not yet
Yutaka_Kinjyo
parents: 1145
diff changeset
74
ea68d54411a7 not yet
Yutaka_Kinjyo
parents: 1145
diff changeset
75
621
64e05530e333 Cell fix
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 619
diff changeset
76 static float
64e05530e333 Cell fix
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 619
diff changeset
77 innerProduct1(float *v0, float *v1)
64e05530e333 Cell fix
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 619
diff changeset
78 {
845
71afabd4ba5c light bug fix.
Yutaka_Kinjyo
parents: 838
diff changeset
79 return (v0[0]*v1[0] + v0[1]*v1[1] + v0[2]*v1[2]);
621
64e05530e333 Cell fix
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 619
diff changeset
80 }
64e05530e333 Cell fix
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 619
diff changeset
81
539
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
82
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
83 /**
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
84 * テクスチャは、TEXTURE_SPLIT_PIXEL^2 のブロックに分割する
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
85 *
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
86 * +---+---+---+---+---+---+
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
87 * | 0 | 1 | 2 | 3 | 4 | 5 |
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
88 * +---+---+---+---+---+---+
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
89 * | | | | | |11 |
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
90 * +---+---+---+---+---+---+
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
91 * | | | | | |17 |
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
92 * +---+---+---+---+---+---+
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
93 * | | | | | |23 |
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
94 * +---+---+---+---+---+---+
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
95 * | | | | | |29 |
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
96 * +---+---+---+---+---+---+
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
97 * | | | | | |35 |
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
98 * +---+---+---+---+---+---+
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
99 *
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
100 * 一辺を TEXTURE_SPLIT とする
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
101 * 各ブロックの数字がブロックIDとなる。
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
102 */
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
103
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
104 /**
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
105 * テクスチャの座標から、
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
106 * テクスチャのどのブロックかを求める
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
107 *
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
108 * @param[in] tx X coordinates of texture
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
109 * @param[in] tx Y coordinates of texture
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
110 * @param[in] twidth Width of texture
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
111 * @return block ID
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
112 */
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
113 static int
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
114 getTexBlock(int tx, int ty, int twidth)
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
115 {
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
116 int blockX, blockY;
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
117
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
118 blockX = tx / TEXTURE_SPLIT_PIXEL;
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
119 blockY = ty / TEXTURE_SPLIT_PIXEL;
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
120
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
121 return blockX + (twidth/TEXTURE_SPLIT_PIXEL)*blockY;
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
122 }
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
123
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
124 /**
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
125 * block ID と、テクスチャの TOP address から
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
126 * (tx,ty) で使われるテクスチャの Tile addres を求める
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
127 *
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
128 * @param[in] tx X coordinates of texture
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
129 * @param[in] tx Y coordinates of texture
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
130 * @param[in] tw Width of texture
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
131 * @param[in] tex_addr_top (tx,ty) で使うテクスチャの先頭address
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
132 * @return block ID
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
133 */
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
134 static memaddr
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
135 getTile(int tx, int ty, int tw, memaddr tex_addr_top)
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
136 {
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
137 int block = getTexBlock(tx, ty, tw);
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
138 return tex_addr_top + block * TEXTURE_BLOCK_SIZE * sizeof(uint32);
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
139 }
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
140
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
141 /**
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
142 * FrameBuffer に書き込む rgb の領域初期化
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
143 *
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
144 * @param width Width of Buffer
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
145 * @param height Height of Buffer
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
146 * @param rgb Initial value of RGB at Buffer
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
147 * @return Buffer
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
148 */
616
350b9b8c985f First addOutput rendering try failed.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 615
diff changeset
149 static int **
539
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
150 linebuf_init(SchedTask *smanager, int width, int height, int rgb)
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
151 {
616
350b9b8c985f First addOutput rendering try failed.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 615
diff changeset
152 int **linebuf = (int**)smanager->allocate(height*sizeof(int*));
350b9b8c985f First addOutput rendering try failed.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 615
diff changeset
153 for(int h = 0;h<height;h++) {
617
df618a956eb9 Rendering not yet worked.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 616
diff changeset
154 int *buf = linebuf[h] = (int*)smanager->get_output(h);
df618a956eb9 Rendering not yet worked.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 616
diff changeset
155 for (int i = 0; i < width; i++) {
616
350b9b8c985f First addOutput rendering try failed.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 615
diff changeset
156 buf[i] = rgb;
350b9b8c985f First addOutput rendering try failed.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 615
diff changeset
157 }
539
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
158 }
616
350b9b8c985f First addOutput rendering try failed.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 615
diff changeset
159 return linebuf;
539
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
160 }
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
161
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
162 /**
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
163 * Z-Buffer の初期化
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
164 *
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
165 * @param width Width of Z-Buffer
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
166 * @param height Height of Z-Buffer
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
167 * @return Z-Buffer
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
168 */
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
169 static float*
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
170 zRow_init(SchedTask *smanager, int width, int height)
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
171 {
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
172 float *buf = (float*)smanager->allocate(sizeof(float)*width*height);
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
173 float def = 65535.0f;
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
174
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
175 for (int i = 0; i < width*height; i++) {
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
176 buf[i] = def;
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
177 }
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
178
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
179 return buf;
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
180 }
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
181
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
182
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
183 static uint32
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
184 get_rgb(int tx, int ty, TilePtr tile)
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
185 {
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
186 uint32 *data = (uint32 *)tile->data;
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
187 return data[(TEXTURE_SPLIT_PIXEL)*ty+tx];
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
188 }
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
189
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
190
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
191
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
192 /**
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
193 * zRow と Linebuf を更新する
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
194 *
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
195 * @param zpos 更新する pixel のZ座標
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
196 * @param rangex このタスクが処理する描画領域の x の長さ
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
197 * @param x pixel の、描画領域内での x 座標
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
198 * @param y 〃 の、y 座標
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
199 * @param tex_x pixel が使用するテクスチャの、Tile (8x8) 内での x 座標
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
200 * @param tex_y 〃 の y 座標
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
201 * @param tex_addr テクスチャのアドレス(MainMemory)
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
202 */
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
203 static void
738
yutaka@localhost.localdomain
parents: 625
diff changeset
204 updateBuffer(Gptr g, float zpos, int rangex, int localx, int localy, int tex_x, int tex_y,
yutaka@localhost.localdomain
parents: 625
diff changeset
205 float normal_x, float normal_y, float normal_z, TilePtr tile,
yutaka@localhost.localdomain
parents: 625
diff changeset
206 int world_x, int world_y, float world_z, SchedTask *smanager)
539
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
207 {
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
208
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
209 int color = get_rgb(tex_x, tex_y, tile);
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
210 /*下位4bitを抽出*/
623
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 622
diff changeset
211 #if LITTLEENDIAN
599
9e288ef22377 change alpha
yutaka@henri.cr.ie.u-ryukyu.ac.jp
parents: 539
diff changeset
212 int alpha = color & 0x000000ff;
619
278db3ca751d RenewTask removal
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 617
diff changeset
213 #else
278db3ca751d RenewTask removal
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 617
diff changeset
214 int alpha = color & 0xff000000;
278db3ca751d RenewTask removal
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 617
diff changeset
215 #endif
845
71afabd4ba5c light bug fix.
Yutaka_Kinjyo
parents: 838
diff changeset
216
1054
ab16fc9a6570 light fix..?
Yutaka_Kinjyo
parents: 1050
diff changeset
217
ab16fc9a6570 light fix..?
Yutaka_Kinjyo
parents: 1050
diff changeset
218 //完全に透けているか判断
1031
92185a81e94b OpenGL mode fix
Yutaka_Kinjyo
parents: 914
diff changeset
219 int flag = (alpha != 0);
1054
ab16fc9a6570 light fix..?
Yutaka_Kinjyo
parents: 1050
diff changeset
220 int *light_sysswitch = (int*)smanager->global_get(LightSysSwitch);
ab16fc9a6570 light fix..?
Yutaka_Kinjyo
parents: 1050
diff changeset
221 //smanager->printf("sys %d\n",light_sysswitch);
539
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
222
1054
ab16fc9a6570 light fix..?
Yutaka_Kinjyo
parents: 1050
diff changeset
223 if ( *light_sysswitch == 1 && flag) {
ab16fc9a6570 light fix..?
Yutaka_Kinjyo
parents: 1050
diff changeset
224 color = infinity_light_calc(color,normal_x,normal_y,normal_z,
ab16fc9a6570 light fix..?
Yutaka_Kinjyo
parents: 1050
diff changeset
225 smanager,localx,localy,zpos,
ab16fc9a6570 light fix..?
Yutaka_Kinjyo
parents: 1050
diff changeset
226 world_x,world_y,world_z);
855
641451e6a95b light fix--
Yutaka_Kinjyo
parents: 846
diff changeset
227 }
539
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
228
738
yutaka@localhost.localdomain
parents: 625
diff changeset
229 g->zRow[localx + (rangex*localy)] = zpos*flag + g->zRow[localx + (rangex*localy)]*(1-flag);
1054
ab16fc9a6570 light fix..?
Yutaka_Kinjyo
parents: 1050
diff changeset
230 int *point = &g->linebuf[localy][localx];
616
350b9b8c985f First addOutput rendering try failed.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 615
diff changeset
231 *point = color*flag + *point *(1-flag);
539
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
232
1054
ab16fc9a6570 light fix..?
Yutaka_Kinjyo
parents: 1050
diff changeset
233
539
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
234 }
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
235
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
236 /**
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
237 * 長さが 1 の Span の描画 (要するに 1 pixel)
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
238 *
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
239 * @param span Span
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
240 * @param startx 描画開始範囲
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
241 * @param endx 描画終了範囲
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
242 */
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
243 static int
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
244 drawDot1(SchedTask *smanager, Gptr g, SpanPtr span, int startx, int endx, int wait_tag)
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
245 {
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
246 int rangex = endx - startx + 1;
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
247
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
248 float normal_x = span->normal_x;
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
249 float normal_y = span->normal_y;
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
250 float normal_z = span->normal_z;
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
251
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
252
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
253 /* span->x に対応する Texture の座標 (tex_xpos, tex_ypos) */
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
254 int tex_xpos, tex_ypos;
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
255
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
256 // span の始点に対応する Texture の座標 (tex1, tey1)
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
257 float tex = span->tex_x1;
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
258 float tey = span->tex_y1;
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
259
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
260 // span の始点に対応する z 座標
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
261 float zpos = span->start_z;
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
262
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
263 /* Tile 内での座標 */
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
264 int localx = getLocalX(span->x-1);
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
265 int localy = getLocalY(span->y-1);
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
266
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
267 /**
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
268 * (tex_xpos, tex_ypos) の、Tile 内(上の図参照)での座標と
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
269 * そのブロックのアドレス(MainMemory)
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
270 */
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
271 int tex_localx;
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
272 int tex_localy;
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
273 memaddr tex_addr;
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
274
1092
b99abedb5523 fix h w in makeTapestry
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 1054
diff changeset
275 if (span->x < startx || endx < span->x || ! span->tex_addr) {
539
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
276 return -1;
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
277 }
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
278
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
279 tex_xpos = (int)((span->tex_width-1) * tex);
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
280 tex_ypos = (int)((span->tex_height-1) * tey);
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
281
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
282 if (zpos < g->zRow[localx + (rangex*localy)]) {
1157
ea68d54411a7 not yet
Yutaka_Kinjyo
parents: 1145
diff changeset
283
539
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
284 tex_addr = getTile(tex_xpos, tex_ypos,
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
285 span->tex_width, (memaddr)span->tex_addr);
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
286 tex_localx = tex_xpos % TEXTURE_SPLIT_PIXEL;
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
287 tex_localy = tex_ypos % TEXTURE_SPLIT_PIXEL;
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
288
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
289 TilePtr tile = smanager->get_segment(tex_addr,g->tileList);
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
290 smanager->wait_segment(tile);
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
291
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
292 updateBuffer(g, zpos, rangex, localx, localy,
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
293 tex_localx, tex_localy,
738
yutaka@localhost.localdomain
parents: 625
diff changeset
294 normal_x,normal_y,normal_z,tile,
yutaka@localhost.localdomain
parents: 625
diff changeset
295 span->x, span->y, zpos, smanager);
539
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
296 }
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
297
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
298 return -1;
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
299 }
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
300
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
301 #if 0
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
302 static void
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
303 drawDot2(SchedTask *smanager, SpanPtr span, int startx, int end, int js, int wait_tag)
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
304 {
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
305 //printf("%d\n", js);
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
306 }
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
307 #endif
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
308
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
309 /**
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
310 * 長さが 1 より大きい Span の描画
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
311 *
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
312 * 本来の目的として、この関数(drawLine1) では
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
313 * : 既に SPE 上に Tile のある pixel だけ描画
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
314 * : それ以外は、ここで予め DMA load しておき、
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
315 * : drawLine2 で一気に描画する
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
316 * ってものだったんだけど、どうも上手く行かなかったので
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
317 * 今は drawLine1 で load -> wait -> rendering を全部やってます
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
318 * (rendering といっても、rendering buffer に書き込むだけで
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
319 * まだ main memory (frame buffer) に dma store してるわけではない)
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
320 *
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
321 * @param span Span
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
322 * @param startx 描画開始範囲
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
323 * @param endx 描画終了範囲
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
324 * @return 「span のどの位置まで rendering が終わったか」の x 座標
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
325 */
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
326 static int
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
327 drawLine1(SchedTask *smanager, Gptr g, SpanPtr span, int startx, int endx, int wait_tag)
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
328 {
1157
ea68d54411a7 not yet
Yutaka_Kinjyo
parents: 1145
diff changeset
329
1163
b417abf82193 use Segment API for spackload
Yutaka_Kinjyo
parents: 1159
diff changeset
330
b417abf82193 use Segment API for spackload
Yutaka_Kinjyo
parents: 1159
diff changeset
331 #ifdef PIPE_TILE
b417abf82193 use Segment API for spackload
Yutaka_Kinjyo
parents: 1159
diff changeset
332
1157
ea68d54411a7 not yet
Yutaka_Kinjyo
parents: 1145
diff changeset
333 int cur = 0;
1159
42f5958ab74e not yet....
Yutaka_Kinjyo
parents: 1158
diff changeset
334 DrawParam param[2];
539
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
335
1158
bfc2c6628fef not yet
Yutaka_Kinjyo
parents: 1157
diff changeset
336 int rangex = endx - startx + 1;
539
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
337
1158
bfc2c6628fef not yet
Yutaka_Kinjyo
parents: 1157
diff changeset
338 int js = (span->x < startx) ? startx - span->x : 0;
bfc2c6628fef not yet
Yutaka_Kinjyo
parents: 1157
diff changeset
339 int je = (span->x + span->length_x > endx) ? endx - span->x : span->length_x;
539
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
340
1157
ea68d54411a7 not yet
Yutaka_Kinjyo
parents: 1145
diff changeset
341 int localy = getLocalY(span->y-1);
539
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
342
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
343 int ret = je+1;
1159
42f5958ab74e not yet....
Yutaka_Kinjyo
parents: 1158
diff changeset
344 int index = 1;
539
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
345
1163
b417abf82193 use Segment API for spackload
Yutaka_Kinjyo
parents: 1159
diff changeset
346
1158
bfc2c6628fef not yet
Yutaka_Kinjyo
parents: 1157
diff changeset
347 getDrawParam(smanager, g, span, localy, startx, endx, index, je, &param[cur]);
1157
ea68d54411a7 not yet
Yutaka_Kinjyo
parents: 1145
diff changeset
348
1158
bfc2c6628fef not yet
Yutaka_Kinjyo
parents: 1157
diff changeset
349 //for (int j = je; j >= js; j--) { <-もとはこうで、一度先にtextureをloadしておくから、je-1にしてる
1157
ea68d54411a7 not yet
Yutaka_Kinjyo
parents: 1145
diff changeset
350 for (int j = je-1; j >= js; j--) {
539
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
351
1158
bfc2c6628fef not yet
Yutaka_Kinjyo
parents: 1157
diff changeset
352 index += 1;
1157
ea68d54411a7 not yet
Yutaka_Kinjyo
parents: 1145
diff changeset
353
1158
bfc2c6628fef not yet
Yutaka_Kinjyo
parents: 1157
diff changeset
354 getDrawParam(smanager, g, span, localy, startx, endx, index, j, &param[cur^1]); //次のループで使用するtexture
1157
ea68d54411a7 not yet
Yutaka_Kinjyo
parents: 1145
diff changeset
355
1158
bfc2c6628fef not yet
Yutaka_Kinjyo
parents: 1157
diff changeset
356 if (param[cur].display) {
bfc2c6628fef not yet
Yutaka_Kinjyo
parents: 1157
diff changeset
357 smanager->wait_segment(param[cur].tile); // 前でload命令を出しておいたtextureを待つ。
1157
ea68d54411a7 not yet
Yutaka_Kinjyo
parents: 1145
diff changeset
358
1158
bfc2c6628fef not yet
Yutaka_Kinjyo
parents: 1157
diff changeset
359 updateBuffer(g, param[cur].tex_z, rangex, param[cur].localx, localy,
bfc2c6628fef not yet
Yutaka_Kinjyo
parents: 1157
diff changeset
360 param[cur].tex_localx, param[cur].tex_localy,
bfc2c6628fef not yet
Yutaka_Kinjyo
parents: 1157
diff changeset
361 span->normal_x, span->normal_y, span->normal_z, param[cur].tile,
1159
42f5958ab74e not yet....
Yutaka_Kinjyo
parents: 1158
diff changeset
362 param[cur].x, span->y, param[cur].world_z, smanager);
1157
ea68d54411a7 not yet
Yutaka_Kinjyo
parents: 1145
diff changeset
363 }
ea68d54411a7 not yet
Yutaka_Kinjyo
parents: 1145
diff changeset
364
ea68d54411a7 not yet
Yutaka_Kinjyo
parents: 1145
diff changeset
365 cur ^= 1;
539
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
366
1157
ea68d54411a7 not yet
Yutaka_Kinjyo
parents: 1145
diff changeset
367 }
1159
42f5958ab74e not yet....
Yutaka_Kinjyo
parents: 1158
diff changeset
368 /*
1158
bfc2c6628fef not yet
Yutaka_Kinjyo
parents: 1157
diff changeset
369 if (param[cur].display) {
bfc2c6628fef not yet
Yutaka_Kinjyo
parents: 1157
diff changeset
370 smanager->wait_segment(param[cur].tile);
bfc2c6628fef not yet
Yutaka_Kinjyo
parents: 1157
diff changeset
371
bfc2c6628fef not yet
Yutaka_Kinjyo
parents: 1157
diff changeset
372 updateBuffer(g, param[cur].tex_z, rangex, param[cur].localx, localy,
bfc2c6628fef not yet
Yutaka_Kinjyo
parents: 1157
diff changeset
373 param[cur].tex_localx, param[cur].tex_localy,
bfc2c6628fef not yet
Yutaka_Kinjyo
parents: 1157
diff changeset
374 span->normal_x, span->normal_y, span->normal_z, param[cur].tile,
1159
42f5958ab74e not yet....
Yutaka_Kinjyo
parents: 1158
diff changeset
375 param[cur].x, span->y, param[cur].world_z, smanager);
1158
bfc2c6628fef not yet
Yutaka_Kinjyo
parents: 1157
diff changeset
376
bfc2c6628fef not yet
Yutaka_Kinjyo
parents: 1157
diff changeset
377 }
1159
42f5958ab74e not yet....
Yutaka_Kinjyo
parents: 1158
diff changeset
378 */
1158
bfc2c6628fef not yet
Yutaka_Kinjyo
parents: 1157
diff changeset
379
1163
b417abf82193 use Segment API for spackload
Yutaka_Kinjyo
parents: 1159
diff changeset
380
b417abf82193 use Segment API for spackload
Yutaka_Kinjyo
parents: 1159
diff changeset
381 #else
b417abf82193 use Segment API for spackload
Yutaka_Kinjyo
parents: 1159
diff changeset
382
b417abf82193 use Segment API for spackload
Yutaka_Kinjyo
parents: 1159
diff changeset
383
b417abf82193 use Segment API for spackload
Yutaka_Kinjyo
parents: 1159
diff changeset
384 int x = span->x;
b417abf82193 use Segment API for spackload
Yutaka_Kinjyo
parents: 1159
diff changeset
385 int rangex = endx - startx + 1;
b417abf82193 use Segment API for spackload
Yutaka_Kinjyo
parents: 1159
diff changeset
386 int x_len = span->length_x;
b417abf82193 use Segment API for spackload
Yutaka_Kinjyo
parents: 1159
diff changeset
387
b417abf82193 use Segment API for spackload
Yutaka_Kinjyo
parents: 1159
diff changeset
388 float normal_x = span->normal_x;
b417abf82193 use Segment API for spackload
Yutaka_Kinjyo
parents: 1159
diff changeset
389 float normal_y = span->normal_y;
b417abf82193 use Segment API for spackload
Yutaka_Kinjyo
parents: 1159
diff changeset
390 float normal_z = span->normal_z;
b417abf82193 use Segment API for spackload
Yutaka_Kinjyo
parents: 1159
diff changeset
391
b417abf82193 use Segment API for spackload
Yutaka_Kinjyo
parents: 1159
diff changeset
392 int js = (x < startx) ? startx - x : 0;
b417abf82193 use Segment API for spackload
Yutaka_Kinjyo
parents: 1159
diff changeset
393 int je = (x + x_len > endx) ? endx - x : x_len;
b417abf82193 use Segment API for spackload
Yutaka_Kinjyo
parents: 1159
diff changeset
394
b417abf82193 use Segment API for spackload
Yutaka_Kinjyo
parents: 1159
diff changeset
395 // span の始点に対応する座標 (tex1, tey1)
b417abf82193 use Segment API for spackload
Yutaka_Kinjyo
parents: 1159
diff changeset
396 float tex1 = span->tex_x1;
b417abf82193 use Segment API for spackload
Yutaka_Kinjyo
parents: 1159
diff changeset
397 float tey1 = span->tex_y1;
b417abf82193 use Segment API for spackload
Yutaka_Kinjyo
parents: 1159
diff changeset
398
b417abf82193 use Segment API for spackload
Yutaka_Kinjyo
parents: 1159
diff changeset
399 // span の終点に対応する座標 (tex2, tey2)
b417abf82193 use Segment API for spackload
Yutaka_Kinjyo
parents: 1159
diff changeset
400 float tex2 = span->tex_x2;
b417abf82193 use Segment API for spackload
Yutaka_Kinjyo
parents: 1159
diff changeset
401 float tey2 = span->tex_y2;
b417abf82193 use Segment API for spackload
Yutaka_Kinjyo
parents: 1159
diff changeset
402
b417abf82193 use Segment API for spackload
Yutaka_Kinjyo
parents: 1159
diff changeset
403 // span の始点、終点に対応する z 座標
b417abf82193 use Segment API for spackload
Yutaka_Kinjyo
parents: 1159
diff changeset
404 float zpos1 = span->start_z;
b417abf82193 use Segment API for spackload
Yutaka_Kinjyo
parents: 1159
diff changeset
405 float zpos2 = span->end_z;
b417abf82193 use Segment API for spackload
Yutaka_Kinjyo
parents: 1159
diff changeset
406
b417abf82193 use Segment API for spackload
Yutaka_Kinjyo
parents: 1159
diff changeset
407 //spanを右から左に見ていくうちに、zが下がるのか、上がっていくのか。
b417abf82193 use Segment API for spackload
Yutaka_Kinjyo
parents: 1159
diff changeset
408 float z_inclination = (zpos2 - zpos1) / x_len;
b417abf82193 use Segment API for spackload
Yutaka_Kinjyo
parents: 1159
diff changeset
409 float world_z = zpos2;
b417abf82193 use Segment API for spackload
Yutaka_Kinjyo
parents: 1159
diff changeset
410
b417abf82193 use Segment API for spackload
Yutaka_Kinjyo
parents: 1159
diff changeset
411 // Tile 内での座標
b417abf82193 use Segment API for spackload
Yutaka_Kinjyo
parents: 1159
diff changeset
412 int localx, localy = getLocalY(span->y-1);
b417abf82193 use Segment API for spackload
Yutaka_Kinjyo
parents: 1159
diff changeset
413
b417abf82193 use Segment API for spackload
Yutaka_Kinjyo
parents: 1159
diff changeset
414 int ret = je+1;
b417abf82193 use Segment API for spackload
Yutaka_Kinjyo
parents: 1159
diff changeset
415
b417abf82193 use Segment API for spackload
Yutaka_Kinjyo
parents: 1159
diff changeset
416 //for (int j = js; j <= je; j++) {
b417abf82193 use Segment API for spackload
Yutaka_Kinjyo
parents: 1159
diff changeset
417 for (int j = je; j >= js; j--) {
b417abf82193 use Segment API for spackload
Yutaka_Kinjyo
parents: 1159
diff changeset
418
b417abf82193 use Segment API for spackload
Yutaka_Kinjyo
parents: 1159
diff changeset
419 float tex_z;
b417abf82193 use Segment API for spackload
Yutaka_Kinjyo
parents: 1159
diff changeset
420
b417abf82193 use Segment API for spackload
Yutaka_Kinjyo
parents: 1159
diff changeset
421 world_z -= z_inclination;
b417abf82193 use Segment API for spackload
Yutaka_Kinjyo
parents: 1159
diff changeset
422 localx = getLocalX(x-1+j);
b417abf82193 use Segment API for spackload
Yutaka_Kinjyo
parents: 1159
diff changeset
423 tex_z = zpos1*(x_len-1-j)/(x_len-1) + zpos2*j/(x_len-1);
b417abf82193 use Segment API for spackload
Yutaka_Kinjyo
parents: 1159
diff changeset
424
b417abf82193 use Segment API for spackload
Yutaka_Kinjyo
parents: 1159
diff changeset
425 if (tex_z < g->zRow[localx + (rangex*localy)]) {
b417abf82193 use Segment API for spackload
Yutaka_Kinjyo
parents: 1159
diff changeset
426
b417abf82193 use Segment API for spackload
Yutaka_Kinjyo
parents: 1159
diff changeset
427 float tex_x, tex_y;
b417abf82193 use Segment API for spackload
Yutaka_Kinjyo
parents: 1159
diff changeset
428
b417abf82193 use Segment API for spackload
Yutaka_Kinjyo
parents: 1159
diff changeset
429 tex_x = tex1*(x_len-1-j)/(x_len-1) + tex2*j/(x_len-1);
b417abf82193 use Segment API for spackload
Yutaka_Kinjyo
parents: 1159
diff changeset
430 tex_y = tey1*(x_len-1-j)/(x_len-1) + tey2*j/(x_len-1);
b417abf82193 use Segment API for spackload
Yutaka_Kinjyo
parents: 1159
diff changeset
431
b417abf82193 use Segment API for spackload
Yutaka_Kinjyo
parents: 1159
diff changeset
432 if (tex_x > 1) tex_x = 1;
b417abf82193 use Segment API for spackload
Yutaka_Kinjyo
parents: 1159
diff changeset
433 if (tex_x < 0) tex_x = 0;
b417abf82193 use Segment API for spackload
Yutaka_Kinjyo
parents: 1159
diff changeset
434 if (tex_y > 1) tex_y = 1;
b417abf82193 use Segment API for spackload
Yutaka_Kinjyo
parents: 1159
diff changeset
435 if (tex_y < 0) tex_y = 0;
b417abf82193 use Segment API for spackload
Yutaka_Kinjyo
parents: 1159
diff changeset
436
b417abf82193 use Segment API for spackload
Yutaka_Kinjyo
parents: 1159
diff changeset
437 /* span->x に対応する Texture の座標 (tex_xpos, tex_ypos) */
b417abf82193 use Segment API for spackload
Yutaka_Kinjyo
parents: 1159
diff changeset
438 int tex_xpos, tex_ypos;
b417abf82193 use Segment API for spackload
Yutaka_Kinjyo
parents: 1159
diff changeset
439
b417abf82193 use Segment API for spackload
Yutaka_Kinjyo
parents: 1159
diff changeset
440 tex_xpos = (int)((span->tex_width-1) * tex_x);
b417abf82193 use Segment API for spackload
Yutaka_Kinjyo
parents: 1159
diff changeset
441 tex_ypos = (int)((span->tex_height-1) * tex_y);
b417abf82193 use Segment API for spackload
Yutaka_Kinjyo
parents: 1159
diff changeset
442
b417abf82193 use Segment API for spackload
Yutaka_Kinjyo
parents: 1159
diff changeset
443 // (tex_xpos, tex_ypos) の、Tile 内(上の図参照)での座標と
b417abf82193 use Segment API for spackload
Yutaka_Kinjyo
parents: 1159
diff changeset
444 // そのブロックのアドレス(MainMemory)
b417abf82193 use Segment API for spackload
Yutaka_Kinjyo
parents: 1159
diff changeset
445 memaddr tex_addr;
b417abf82193 use Segment API for spackload
Yutaka_Kinjyo
parents: 1159
diff changeset
446 int tex_localx;
b417abf82193 use Segment API for spackload
Yutaka_Kinjyo
parents: 1159
diff changeset
447 int tex_localy;
b417abf82193 use Segment API for spackload
Yutaka_Kinjyo
parents: 1159
diff changeset
448
b417abf82193 use Segment API for spackload
Yutaka_Kinjyo
parents: 1159
diff changeset
449 if (!span->tex_addr) return -1; // broken case, I'd like to write some thing...
b417abf82193 use Segment API for spackload
Yutaka_Kinjyo
parents: 1159
diff changeset
450 tex_addr = getTile(tex_xpos, tex_ypos,
b417abf82193 use Segment API for spackload
Yutaka_Kinjyo
parents: 1159
diff changeset
451 span->tex_width, (memaddr)span->tex_addr);
b417abf82193 use Segment API for spackload
Yutaka_Kinjyo
parents: 1159
diff changeset
452 tex_localx = tex_xpos % TEXTURE_SPLIT_PIXEL;
b417abf82193 use Segment API for spackload
Yutaka_Kinjyo
parents: 1159
diff changeset
453 tex_localy = tex_ypos % TEXTURE_SPLIT_PIXEL;
b417abf82193 use Segment API for spackload
Yutaka_Kinjyo
parents: 1159
diff changeset
454
b417abf82193 use Segment API for spackload
Yutaka_Kinjyo
parents: 1159
diff changeset
455 TilePtr tile = smanager->get_segment(tex_addr,g->tileList);
b417abf82193 use Segment API for spackload
Yutaka_Kinjyo
parents: 1159
diff changeset
456 smanager->wait_segment(tile);
b417abf82193 use Segment API for spackload
Yutaka_Kinjyo
parents: 1159
diff changeset
457
b417abf82193 use Segment API for spackload
Yutaka_Kinjyo
parents: 1159
diff changeset
458 updateBuffer(g, tex_z, rangex, localx, localy,
b417abf82193 use Segment API for spackload
Yutaka_Kinjyo
parents: 1159
diff changeset
459 tex_localx, tex_localy,
b417abf82193 use Segment API for spackload
Yutaka_Kinjyo
parents: 1159
diff changeset
460 normal_x, normal_y, normal_z, tile,
b417abf82193 use Segment API for spackload
Yutaka_Kinjyo
parents: 1159
diff changeset
461 span->x+j, span->y, world_z, smanager);
b417abf82193 use Segment API for spackload
Yutaka_Kinjyo
parents: 1159
diff changeset
462 }
b417abf82193 use Segment API for spackload
Yutaka_Kinjyo
parents: 1159
diff changeset
463 }
b417abf82193 use Segment API for spackload
Yutaka_Kinjyo
parents: 1159
diff changeset
464
b417abf82193 use Segment API for spackload
Yutaka_Kinjyo
parents: 1159
diff changeset
465
b417abf82193 use Segment API for spackload
Yutaka_Kinjyo
parents: 1159
diff changeset
466
b417abf82193 use Segment API for spackload
Yutaka_Kinjyo
parents: 1159
diff changeset
467 #endif
b417abf82193 use Segment API for spackload
Yutaka_Kinjyo
parents: 1159
diff changeset
468
1157
ea68d54411a7 not yet
Yutaka_Kinjyo
parents: 1145
diff changeset
469 return ret;
ea68d54411a7 not yet
Yutaka_Kinjyo
parents: 1145
diff changeset
470 }
1256
880f989ce52a fix rsync
Yuhi TOMARI <e095740@ie.u-ryukyu.ac.jp>
parents: 1163
diff changeset
471 #if 0
1158
bfc2c6628fef not yet
Yutaka_Kinjyo
parents: 1157
diff changeset
472 static int
bfc2c6628fef not yet
Yutaka_Kinjyo
parents: 1157
diff changeset
473 getDrawParam(SchedTask *smanager, Gptr g, SpanPtr span, int localy, int startx, int endx, int index, int j, DrawParamPtr param) {
1157
ea68d54411a7 not yet
Yutaka_Kinjyo
parents: 1145
diff changeset
474
ea68d54411a7 not yet
Yutaka_Kinjyo
parents: 1145
diff changeset
475 int x = span->x;
ea68d54411a7 not yet
Yutaka_Kinjyo
parents: 1145
diff changeset
476 int rangex = endx - startx + 1;
ea68d54411a7 not yet
Yutaka_Kinjyo
parents: 1145
diff changeset
477 int x_len = span->length_x;
ea68d54411a7 not yet
Yutaka_Kinjyo
parents: 1145
diff changeset
478
ea68d54411a7 not yet
Yutaka_Kinjyo
parents: 1145
diff changeset
479 /* span->x に対応する Texture の座標 (tex_xpos, tex_ypos) */
ea68d54411a7 not yet
Yutaka_Kinjyo
parents: 1145
diff changeset
480 int tex_xpos, tex_ypos;
ea68d54411a7 not yet
Yutaka_Kinjyo
parents: 1145
diff changeset
481
ea68d54411a7 not yet
Yutaka_Kinjyo
parents: 1145
diff changeset
482 // span の始点に対応する座標 (tex1, tey1)
ea68d54411a7 not yet
Yutaka_Kinjyo
parents: 1145
diff changeset
483 float tex1 = span->tex_x1;
ea68d54411a7 not yet
Yutaka_Kinjyo
parents: 1145
diff changeset
484 float tey1 = span->tex_y1;
539
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
485
1157
ea68d54411a7 not yet
Yutaka_Kinjyo
parents: 1145
diff changeset
486 // span の終点に対応する座標 (tex2, tey2)
ea68d54411a7 not yet
Yutaka_Kinjyo
parents: 1145
diff changeset
487 float tex2 = span->tex_x2;
ea68d54411a7 not yet
Yutaka_Kinjyo
parents: 1145
diff changeset
488 float tey2 = span->tex_y2;
ea68d54411a7 not yet
Yutaka_Kinjyo
parents: 1145
diff changeset
489
ea68d54411a7 not yet
Yutaka_Kinjyo
parents: 1145
diff changeset
490 // span の始点、終点に対応する z 座標
ea68d54411a7 not yet
Yutaka_Kinjyo
parents: 1145
diff changeset
491 float zpos1 = span->start_z;
ea68d54411a7 not yet
Yutaka_Kinjyo
parents: 1145
diff changeset
492 float zpos2 = span->end_z;
ea68d54411a7 not yet
Yutaka_Kinjyo
parents: 1145
diff changeset
493
ea68d54411a7 not yet
Yutaka_Kinjyo
parents: 1145
diff changeset
494 //spanを右から左に見ていくうちに、zが下がるのか、上がっていくのか。
ea68d54411a7 not yet
Yutaka_Kinjyo
parents: 1145
diff changeset
495 float z_inclination = (zpos1 - zpos2) / x_len;
1159
42f5958ab74e not yet....
Yutaka_Kinjyo
parents: 1158
diff changeset
496 param->world_z = zpos2 + (z_inclination*index);
42f5958ab74e not yet....
Yutaka_Kinjyo
parents: 1158
diff changeset
497 param->x = x + j;
1158
bfc2c6628fef not yet
Yutaka_Kinjyo
parents: 1157
diff changeset
498 param->tex_z = zpos1*(x_len-1-j)/(x_len-1) + zpos2*j/(x_len-1);
bfc2c6628fef not yet
Yutaka_Kinjyo
parents: 1157
diff changeset
499 param->localx = getLocalX(x-1+j);
1157
ea68d54411a7 not yet
Yutaka_Kinjyo
parents: 1145
diff changeset
500
1159
42f5958ab74e not yet....
Yutaka_Kinjyo
parents: 1158
diff changeset
501
1158
bfc2c6628fef not yet
Yutaka_Kinjyo
parents: 1157
diff changeset
502 if (param->tex_z < g->zRow[param->localx + (rangex*localy)]) {
1157
ea68d54411a7 not yet
Yutaka_Kinjyo
parents: 1145
diff changeset
503
ea68d54411a7 not yet
Yutaka_Kinjyo
parents: 1145
diff changeset
504 float tex_x, tex_y;
ea68d54411a7 not yet
Yutaka_Kinjyo
parents: 1145
diff changeset
505
539
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
506 tex_x = tex1*(x_len-1-j)/(x_len-1) + tex2*j/(x_len-1);
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
507 tex_y = tey1*(x_len-1-j)/(x_len-1) + tey2*j/(x_len-1);
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
508 if (tex_x > 1) tex_x = 1;
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
509 if (tex_x < 0) tex_x = 0;
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
510 if (tex_y > 1) tex_y = 1;
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
511 if (tex_y < 0) tex_y = 0;
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
512 tex_xpos = (int)((span->tex_width-1) * tex_x);
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
513 tex_ypos = (int)((span->tex_height-1) * tex_y);
1157
ea68d54411a7 not yet
Yutaka_Kinjyo
parents: 1145
diff changeset
514
ea68d54411a7 not yet
Yutaka_Kinjyo
parents: 1145
diff changeset
515 // (tex_xpos, tex_ypos) の、Tile 内(上の図参照)での座標と
ea68d54411a7 not yet
Yutaka_Kinjyo
parents: 1145
diff changeset
516 // そのブロックのアドレス(MainMemory)
ea68d54411a7 not yet
Yutaka_Kinjyo
parents: 1145
diff changeset
517 memaddr tex_addr;
ea68d54411a7 not yet
Yutaka_Kinjyo
parents: 1145
diff changeset
518
1158
bfc2c6628fef not yet
Yutaka_Kinjyo
parents: 1157
diff changeset
519 if (!span->tex_addr) return -1; // broken case, I'd like to write some thing...
1157
ea68d54411a7 not yet
Yutaka_Kinjyo
parents: 1145
diff changeset
520 tex_addr = getTile(tex_xpos, tex_ypos,
ea68d54411a7 not yet
Yutaka_Kinjyo
parents: 1145
diff changeset
521 span->tex_width, (memaddr)span->tex_addr);
ea68d54411a7 not yet
Yutaka_Kinjyo
parents: 1145
diff changeset
522
1158
bfc2c6628fef not yet
Yutaka_Kinjyo
parents: 1157
diff changeset
523 param->tex_localx = tex_xpos % TEXTURE_SPLIT_PIXEL;
bfc2c6628fef not yet
Yutaka_Kinjyo
parents: 1157
diff changeset
524 param->tex_localy = tex_xpos % TEXTURE_SPLIT_PIXEL;
bfc2c6628fef not yet
Yutaka_Kinjyo
parents: 1157
diff changeset
525
1159
42f5958ab74e not yet....
Yutaka_Kinjyo
parents: 1158
diff changeset
526 param->tile = smanager->get_segment(tex_addr, g->tileList);
1158
bfc2c6628fef not yet
Yutaka_Kinjyo
parents: 1157
diff changeset
527
1159
42f5958ab74e not yet....
Yutaka_Kinjyo
parents: 1158
diff changeset
528 param->display = 1; // z軸の一番まえだから表示されるよ
1158
bfc2c6628fef not yet
Yutaka_Kinjyo
parents: 1157
diff changeset
529
bfc2c6628fef not yet
Yutaka_Kinjyo
parents: 1157
diff changeset
530 return 1; //
539
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
531 }
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
532
1158
bfc2c6628fef not yet
Yutaka_Kinjyo
parents: 1157
diff changeset
533 param->display = 0; //z軸の前に他のオブジェクトがあるので、計算しなくていい。
bfc2c6628fef not yet
Yutaka_Kinjyo
parents: 1157
diff changeset
534
bfc2c6628fef not yet
Yutaka_Kinjyo
parents: 1157
diff changeset
535 return 1;
1157
ea68d54411a7 not yet
Yutaka_Kinjyo
parents: 1145
diff changeset
536
539
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
537 }
1256
880f989ce52a fix rsync
Yuhi TOMARI <e095740@ie.u-ryukyu.ac.jp>
parents: 1163
diff changeset
538 #endif
539
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
539
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
540 static int
738
yutaka@localhost.localdomain
parents: 625
diff changeset
541 infinity_light_calc(int color,float normal_x, float normal_y,
yutaka@localhost.localdomain
parents: 625
diff changeset
542 float normal_z, SchedTask *smanager, int x, int y, float z,
yutaka@localhost.localdomain
parents: 625
diff changeset
543 int world_x, int world_y, float world_z)
yutaka@localhost.localdomain
parents: 625
diff changeset
544
539
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
545 {
765
be8ffe653840 task/DrawSpan fix
yutaka@henri.cr.ie.u-ryukyu.ac.jp
parents: 738
diff changeset
546
539
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
547 unsigned char rgb[4];
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
548 int light_rgb;
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
549 float normal_vector[4] = {normal_x,normal_y,normal_z,0};
765
be8ffe653840 task/DrawSpan fix
yutaka@henri.cr.ie.u-ryukyu.ac.jp
parents: 738
diff changeset
550 float light_vector[4];
be8ffe653840 task/DrawSpan fix
yutaka@henri.cr.ie.u-ryukyu.ac.jp
parents: 738
diff changeset
551 float *light_xyz = (float*)smanager->global_get(Light);
be8ffe653840 task/DrawSpan fix
yutaka@henri.cr.ie.u-ryukyu.ac.jp
parents: 738
diff changeset
552
1276
e92f00ed2fc0 apply view matrix to normal vector
Yutaka_Kinjyo <yutaka@cr.ie.u-ryukyu.ac.jp>
parents: 1163
diff changeset
553 //normalize(normal_vector, normal_vector);
539
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
554
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
555 // 引数で受け取った color の rgb 情報の抜き出し
623
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 622
diff changeset
556 #if LITTLEENDIAN
539
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
557 rgb[0] = (color & 0xff000000) >> 24;
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
558 rgb[1] = (color & 0x00ff0000) >> 16;
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
559 rgb[2] = (color & 0x0000ff00) >> 8;
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
560 rgb[3] = (color & 0x000000ff);
619
278db3ca751d RenewTask removal
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 617
diff changeset
561 #else
278db3ca751d RenewTask removal
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 617
diff changeset
562 rgb[3] = (color & 0xff000000) >> 24;
278db3ca751d RenewTask removal
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 617
diff changeset
563 rgb[2] = (color & 0x00ff0000) >> 16;
278db3ca751d RenewTask removal
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 617
diff changeset
564 rgb[1] = (color & 0x0000ff00) >> 8;
278db3ca751d RenewTask removal
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 617
diff changeset
565 rgb[0] = (color & 0x000000ff);
278db3ca751d RenewTask removal
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 617
diff changeset
566 #endif
539
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
567
765
be8ffe653840 task/DrawSpan fix
yutaka@henri.cr.ie.u-ryukyu.ac.jp
parents: 738
diff changeset
568 int tmp_rgb[3] = {0,0,0};
be8ffe653840 task/DrawSpan fix
yutaka@henri.cr.ie.u-ryukyu.ac.jp
parents: 738
diff changeset
569 int light_num = 4;
1276
e92f00ed2fc0 apply view matrix to normal vector
Yutaka_Kinjyo <yutaka@cr.ie.u-ryukyu.ac.jp>
parents: 1163
diff changeset
570 //float inner_product = 0.2; // 0.2 は環境光ってことにしてみた。
e92f00ed2fc0 apply view matrix to normal vector
Yutaka_Kinjyo <yutaka@cr.ie.u-ryukyu.ac.jp>
parents: 1163
diff changeset
571 float inner_product = 0; // 0.2 は環境光ってことにしてみた。
765
be8ffe653840 task/DrawSpan fix
yutaka@henri.cr.ie.u-ryukyu.ac.jp
parents: 738
diff changeset
572 for (int i = 0; i < light_num; i++) {
be8ffe653840 task/DrawSpan fix
yutaka@henri.cr.ie.u-ryukyu.ac.jp
parents: 738
diff changeset
573
be8ffe653840 task/DrawSpan fix
yutaka@henri.cr.ie.u-ryukyu.ac.jp
parents: 738
diff changeset
574 light_vector[0] = world_x - light_xyz[i*4];
be8ffe653840 task/DrawSpan fix
yutaka@henri.cr.ie.u-ryukyu.ac.jp
parents: 738
diff changeset
575 light_vector[1] = world_y - light_xyz[i*4+1];
be8ffe653840 task/DrawSpan fix
yutaka@henri.cr.ie.u-ryukyu.ac.jp
parents: 738
diff changeset
576 light_vector[2] = light_xyz[i*4+2] - world_z;
be8ffe653840 task/DrawSpan fix
yutaka@henri.cr.ie.u-ryukyu.ac.jp
parents: 738
diff changeset
577 light_vector[3] = light_xyz[i*4+3];
be8ffe653840 task/DrawSpan fix
yutaka@henri.cr.ie.u-ryukyu.ac.jp
parents: 738
diff changeset
578
be8ffe653840 task/DrawSpan fix
yutaka@henri.cr.ie.u-ryukyu.ac.jp
parents: 738
diff changeset
579 normalize(light_vector, light_vector);
be8ffe653840 task/DrawSpan fix
yutaka@henri.cr.ie.u-ryukyu.ac.jp
parents: 738
diff changeset
580
1144
e068c1269292 light fix
Yutaka_Kinjyo
parents: 1092
diff changeset
581 float tmp_inner_product = 0;
e068c1269292 light fix
Yutaka_Kinjyo
parents: 1092
diff changeset
582
765
be8ffe653840 task/DrawSpan fix
yutaka@henri.cr.ie.u-ryukyu.ac.jp
parents: 738
diff changeset
583 // 法線ベクトルと光源ベクトルとの内積をとる
1144
e068c1269292 light fix
Yutaka_Kinjyo
parents: 1092
diff changeset
584 tmp_inner_product = innerProduct1(normal_vector,light_vector);
539
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
585
765
be8ffe653840 task/DrawSpan fix
yutaka@henri.cr.ie.u-ryukyu.ac.jp
parents: 738
diff changeset
586 // 内積がマイナスの場合は色がない。
1144
e068c1269292 light fix
Yutaka_Kinjyo
parents: 1092
diff changeset
587 if (inner_product < tmp_inner_product) {
e068c1269292 light fix
Yutaka_Kinjyo
parents: 1092
diff changeset
588 inner_product = tmp_inner_product;
e068c1269292 light fix
Yutaka_Kinjyo
parents: 1092
diff changeset
589 }
765
be8ffe653840 task/DrawSpan fix
yutaka@henri.cr.ie.u-ryukyu.ac.jp
parents: 738
diff changeset
590
be8ffe653840 task/DrawSpan fix
yutaka@henri.cr.ie.u-ryukyu.ac.jp
parents: 738
diff changeset
591 // 内積を rgb にかけていく
845
71afabd4ba5c light bug fix.
Yutaka_Kinjyo
parents: 838
diff changeset
592
1144
e068c1269292 light fix
Yutaka_Kinjyo
parents: 1092
diff changeset
593 tmp_rgb[0] = (unsigned char)(rgb[0]*inner_product);
e068c1269292 light fix
Yutaka_Kinjyo
parents: 1092
diff changeset
594 tmp_rgb[1] = (unsigned char)(rgb[1]*inner_product);
e068c1269292 light fix
Yutaka_Kinjyo
parents: 1092
diff changeset
595 tmp_rgb[2] = (unsigned char)(rgb[2]*inner_product);
765
be8ffe653840 task/DrawSpan fix
yutaka@henri.cr.ie.u-ryukyu.ac.jp
parents: 738
diff changeset
596
be8ffe653840 task/DrawSpan fix
yutaka@henri.cr.ie.u-ryukyu.ac.jp
parents: 738
diff changeset
597 }
be8ffe653840 task/DrawSpan fix
yutaka@henri.cr.ie.u-ryukyu.ac.jp
parents: 738
diff changeset
598
be8ffe653840 task/DrawSpan fix
yutaka@henri.cr.ie.u-ryukyu.ac.jp
parents: 738
diff changeset
599 int rgb_flag[3];
be8ffe653840 task/DrawSpan fix
yutaka@henri.cr.ie.u-ryukyu.ac.jp
parents: 738
diff changeset
600 for (int i = 0; i < 3; i++) {
be8ffe653840 task/DrawSpan fix
yutaka@henri.cr.ie.u-ryukyu.ac.jp
parents: 738
diff changeset
601 rgb_flag[i] = (tmp_rgb[i] > 255);
be8ffe653840 task/DrawSpan fix
yutaka@henri.cr.ie.u-ryukyu.ac.jp
parents: 738
diff changeset
602 }
be8ffe653840 task/DrawSpan fix
yutaka@henri.cr.ie.u-ryukyu.ac.jp
parents: 738
diff changeset
603
be8ffe653840 task/DrawSpan fix
yutaka@henri.cr.ie.u-ryukyu.ac.jp
parents: 738
diff changeset
604 rgb[0] = tmp_rgb[0]*(1 - rgb_flag[0]) + 255*(rgb_flag[0]);
be8ffe653840 task/DrawSpan fix
yutaka@henri.cr.ie.u-ryukyu.ac.jp
parents: 738
diff changeset
605 rgb[1] = tmp_rgb[1]*(1 - rgb_flag[1]) + 255*(rgb_flag[1]);
be8ffe653840 task/DrawSpan fix
yutaka@henri.cr.ie.u-ryukyu.ac.jp
parents: 738
diff changeset
606 rgb[2] = tmp_rgb[2]*(1 - rgb_flag[2]) + 255*(rgb_flag[2]);
be8ffe653840 task/DrawSpan fix
yutaka@henri.cr.ie.u-ryukyu.ac.jp
parents: 738
diff changeset
607
539
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
608
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
609 //計算した rgb を light_rgb にまとめる。
623
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 622
diff changeset
610 #if LITTLEENDIAN
539
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
611 light_rgb = (rgb[0] << 24) + (rgb[1] << 16) + (rgb[2] << 8) + (rgb[3]);
619
278db3ca751d RenewTask removal
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 617
diff changeset
612 #else
278db3ca751d RenewTask removal
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 617
diff changeset
613 light_rgb = (rgb[3] << 24) + (rgb[2] << 16) + (rgb[1] << 8) + (rgb[0]);
278db3ca751d RenewTask removal
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 617
diff changeset
614 #endif
539
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
615
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
616 return light_rgb;
765
be8ffe653840 task/DrawSpan fix
yutaka@henri.cr.ie.u-ryukyu.ac.jp
parents: 738
diff changeset
617
539
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
618 }
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
619
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
620
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
621 static int
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
622 run(SchedTask *smanager, void *rbuf, void *wbuf)
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
623 {
838
92bf8fc6a2a9 Draw Span Task -> Task Array
Yutaka_Kinjyo
parents: 801
diff changeset
624
845
71afabd4ba5c light bug fix.
Yutaka_Kinjyo
parents: 838
diff changeset
625 //get_param(5) is spack->info.size
846
74e9b78cfda8 fix 64bit mode
tkaito
parents: 845
diff changeset
626 if ((long)smanager->get_param(5) == 0) {
838
92bf8fc6a2a9 Draw Span Task -> Task Array
Yutaka_Kinjyo
parents: 801
diff changeset
627
92bf8fc6a2a9 Draw Span Task -> Task Array
Yutaka_Kinjyo
parents: 801
diff changeset
628 int rangex_start = (long)smanager->get_param(2);
92bf8fc6a2a9 Draw Span Task -> Task Array
Yutaka_Kinjyo
parents: 801
diff changeset
629 int rangex_end = (long)smanager->get_param(3);
92bf8fc6a2a9 Draw Span Task -> Task Array
Yutaka_Kinjyo
parents: 801
diff changeset
630
92bf8fc6a2a9 Draw Span Task -> Task Array
Yutaka_Kinjyo
parents: 801
diff changeset
631 int rangex = rangex_end - rangex_start + 1;
92bf8fc6a2a9 Draw Span Task -> Task Array
Yutaka_Kinjyo
parents: 801
diff changeset
632 int rangey = (long)smanager->get_param(4);
92bf8fc6a2a9 Draw Span Task -> Task Array
Yutaka_Kinjyo
parents: 801
diff changeset
633
914
6286b3baf744 0 is filled on the spe side.
yutaka@localhost.localdomain
parents: 882
diff changeset
634 for(int h = 0; h < rangey; h++) {
6286b3baf744 0 is filled on the spe side.
yutaka@localhost.localdomain
parents: 882
diff changeset
635 int *buf = (int*)smanager->get_output(h);
6286b3baf744 0 is filled on the spe side.
yutaka@localhost.localdomain
parents: 882
diff changeset
636 for (int i = 0; i < rangex; i++) {
6286b3baf744 0 is filled on the spe side.
yutaka@localhost.localdomain
parents: 882
diff changeset
637 buf[i] = 0;
6286b3baf744 0 is filled on the spe side.
yutaka@localhost.localdomain
parents: 882
diff changeset
638 }
6286b3baf744 0 is filled on the spe side.
yutaka@localhost.localdomain
parents: 882
diff changeset
639 }
838
92bf8fc6a2a9 Draw Span Task -> Task Array
Yutaka_Kinjyo
parents: 801
diff changeset
640
92bf8fc6a2a9 Draw Span Task -> Task Array
Yutaka_Kinjyo
parents: 801
diff changeset
641 return 0;
92bf8fc6a2a9 Draw Span Task -> Task Array
Yutaka_Kinjyo
parents: 801
diff changeset
642
92bf8fc6a2a9 Draw Span Task -> Task Array
Yutaka_Kinjyo
parents: 801
diff changeset
643 }
92bf8fc6a2a9 Draw Span Task -> Task Array
Yutaka_Kinjyo
parents: 801
diff changeset
644
92bf8fc6a2a9 Draw Span Task -> Task Array
Yutaka_Kinjyo
parents: 801
diff changeset
645
623
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 622
diff changeset
646 G g0;
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 622
diff changeset
647 Gptr g = &g0;
539
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
648
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
649 SpanPackPtr spack = (SpanPackPtr)smanager->get_input(0);
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
650 SpanPackPtr next_spack = (SpanPackPtr)smanager->allocate(sizeof(SpanPack));
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
651 SpanPackPtr free_spack = next_spack; // next_spack の free() 用
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
652 Span *span;
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
653
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
654 Span nop_span;
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
655 nop_span.length_x = 1;
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
656
738
yutaka@localhost.localdomain
parents: 625
diff changeset
657 // uint32 display = (long)smanager->get_param(0);
yutaka@localhost.localdomain
parents: 625
diff changeset
658 // int screen_width = (long)smanager->get_param(1);
625
94d82f2c842f 64bit mode worked on Mac OS X.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 623
diff changeset
659 int rangex_start = (long)smanager->get_param(2);
94d82f2c842f 64bit mode worked on Mac OS X.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 623
diff changeset
660 int rangex_end = (long)smanager->get_param(3);
539
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
661
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
662 // このタスクが担当する x の範囲
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
663 int rangex = rangex_end - rangex_start + 1;
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
664
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
665 // y の範囲
625
94d82f2c842f 64bit mode worked on Mac OS X.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 623
diff changeset
666 int rangey = (long)smanager->get_param(4);
539
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
667 g->tileList = (TileListPtr)smanager->global_get(GLOBAL_TILE_LIST);
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
668
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
669 g->zRow = zRow_init(smanager, rangex, rangey);
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
670 g->linebuf = linebuf_init(smanager, rangex, rangey, 0);
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
671
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
672 int tl_tag[2] = {TEX_LOAD1, TEX_LOAD2};
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
673 int tl_tag_flg1 = 0;
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
674 int tl_tag_flg2 = 1;
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
675
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
676 do {
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
677 /**
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
678 * SpanPack->next が存在する場合、
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
679 * 現在の SpanPack を処理してる間に
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
680 * 次の SpanPack の DMA 転送を行う
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
681 */
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
682 if (spack->next != NULL) {
603
57ec231bc8ac long -> memaddr (64 or 32)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 602
diff changeset
683 smanager->dma_load(next_spack, (memaddr)spack->next,
539
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
684 sizeof(SpanPack), SPAN_PACK_LOAD);
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
685 } else {
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
686 next_spack = NULL;
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
687 }
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
688
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
689 SpanPtr resume_span = &nop_span;
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
690
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
691 for (int t = 0; t < spack->info.size; t++) {
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
692 SpanPtr next_span;
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
693
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
694 span = &spack->span[t];
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
695
622
911050e9f99d remove non relocatable funcion call.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 621
diff changeset
696 if (span->length_x != 1) {
1159
42f5958ab74e not yet....
Yutaka_Kinjyo
parents: 1158
diff changeset
697 drawLine1(
845
71afabd4ba5c light bug fix.
Yutaka_Kinjyo
parents: 838
diff changeset
698 smanager, g,
71afabd4ba5c light bug fix.
Yutaka_Kinjyo
parents: 838
diff changeset
699 span, rangex_start, rangex_end, tl_tag[tl_tag_flg1]);
622
911050e9f99d remove non relocatable funcion call.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 621
diff changeset
700 } else {
1159
42f5958ab74e not yet....
Yutaka_Kinjyo
parents: 1158
diff changeset
701 drawDot1(
845
71afabd4ba5c light bug fix.
Yutaka_Kinjyo
parents: 838
diff changeset
702 smanager, g,
71afabd4ba5c light bug fix.
Yutaka_Kinjyo
parents: 838
diff changeset
703 span, rangex_start, rangex_end, tl_tag[tl_tag_flg1]);
622
911050e9f99d remove non relocatable funcion call.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 621
diff changeset
704 }
539
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
705 next_span = span;
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
706
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
707 resume_span = next_span;
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
708
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
709 tl_tag_flg1 ^= 1;
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
710 tl_tag_flg2 ^= 1;
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
711 }
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
712
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
713 smanager->dma_wait(SPAN_PACK_LOAD);
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
714
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
715 SpanPackPtr tmp_spack = spack;
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
716 spack = next_spack;
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
717 next_spack = tmp_spack;
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
718 } while (spack);
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
719
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
720
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
721 free(g->zRow);
616
350b9b8c985f First addOutput rendering try failed.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 615
diff changeset
722 free(g->linebuf);
539
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
723
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
724 //FINISH:
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
725 /**
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
726 * goto FINISH; の時は reboot なので
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
727 * linebuf, zRow は free() しない
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
728 */
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
729
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
730 free(free_spack);
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
731
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
732
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
733 return 0;
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
734 }
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
735
3bc98f6d31ff Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
736 /* end */