annotate Renderer/Engine/task/Draw.cc @ 1013:34a9ba655fbe

spe/CreatePolygonFromSceneGraph add. not done.
author tkaito
date Fri, 05 Nov 2010 01:05:39 +0900
parents f525427ae30f
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
752
5d23ffea34e3 rendering, move_coll parallel running
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents: 507
diff changeset
1 //#include "RunDraw.h"
5d23ffea34e3 rendering, move_coll parallel running
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents: 507
diff changeset
2 #include "SchedTask.h"
507
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
3
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
4 SchedDefineTask(Draw);
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
5
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
6 static int
752
5d23ffea34e3 rendering, move_coll parallel running
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents: 507
diff changeset
7 run(SchedTask *smanager, void *rbuf, void *wbuf)
507
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
8 {
752
5d23ffea34e3 rendering, move_coll parallel running
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents: 507
diff changeset
9 #if 0
5d23ffea34e3 rendering, move_coll parallel running
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents: 507
diff changeset
10 PolygonPack *pp = (PolygonPack*)smanager->get_input(rbuf, 0);
5d23ffea34e3 rendering, move_coll parallel running
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents: 507
diff changeset
11 PolygonPack *next_pp =
5d23ffea34e3 rendering, move_coll parallel running
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents: 507
diff changeset
12 (PolygonPack*)smanager->allocate(sizeof(PolygonPack));
5d23ffea34e3 rendering, move_coll parallel running
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents: 507
diff changeset
13 PolygonPack *free_pp = next_pp;
5d23ffea34e3 rendering, move_coll parallel running
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents: 507
diff changeset
14 PolygonPack *tmp_pp;
5d23ffea34e3 rendering, move_coll parallel running
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents: 507
diff changeset
15
5d23ffea34e3 rendering, move_coll parallel running
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents: 507
diff changeset
16 TrianglePackPtr triPack;
5d23ffea34e3 rendering, move_coll parallel running
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents: 507
diff changeset
17 VertexPackPtr vMin, vMid, vMax;
5d23ffea34e3 rendering, move_coll parallel running
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents: 507
diff changeset
18 VertexPackPtr vMid10
5d23ffea34e3 rendering, move_coll parallel running
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents: 507
diff changeset
19 = (VertexPackPtr)smanager->allocate(sizeof(VertexPack));
5d23ffea34e3 rendering, move_coll parallel running
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents: 507
diff changeset
20 NormalPackPtr normal1,normal2, normal3;
5d23ffea34e3 rendering, move_coll parallel running
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents: 507
diff changeset
21 SpanPackPtr *spackList = (SpanPackPtr*)smanager->get_input(rbuf, 1);
5d23ffea34e3 rendering, move_coll parallel running
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents: 507
diff changeset
22 spack = (SpanPackPtr)smanager->get_input(rbuf, 2);
5d23ffea34e3 rendering, move_coll parallel running
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents: 507
diff changeset
23 send_spack = (SpanPackPtr)smanager->allocate(sizeof(SpanPack));
5d23ffea34e3 rendering, move_coll parallel running
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents: 507
diff changeset
24 prev_index = (long)smanager->get_param(0);
5d23ffea34e3 rendering, move_coll parallel running
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents: 507
diff changeset
25
5d23ffea34e3 rendering, move_coll parallel running
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents: 507
diff changeset
26 // spack と send_spack は swap しながら DMA を繰り返すので
5d23ffea34e3 rendering, move_coll parallel running
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents: 507
diff changeset
27 // 自分で allocate した send_spack を覚えてないといけない
5d23ffea34e3 rendering, move_coll parallel running
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents: 507
diff changeset
28 SpanPackPtr free_spack = send_spack;
5d23ffea34e3 rendering, move_coll parallel running
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents: 507
diff changeset
29
5d23ffea34e3 rendering, move_coll parallel running
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents: 507
diff changeset
30 int charge_y_top = (long)smanager->get_param(1);
5d23ffea34e3 rendering, move_coll parallel running
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents: 507
diff changeset
31 int charge_y_end = (long)smanager->get_param(2);
5d23ffea34e3 rendering, move_coll parallel running
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents: 507
diff changeset
32
5d23ffea34e3 rendering, move_coll parallel running
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents: 507
diff changeset
33 do {
5d23ffea34e3 rendering, move_coll parallel running
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents: 507
diff changeset
34 if (pp->next != NULL) {
5d23ffea34e3 rendering, move_coll parallel running
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents: 507
diff changeset
35 smanager->dma_load(next_pp, (memaddr)pp->next,
5d23ffea34e3 rendering, move_coll parallel running
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents: 507
diff changeset
36 sizeof(PolygonPack), POLYGON_PACK_LOAD);
5d23ffea34e3 rendering, move_coll parallel running
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents: 507
diff changeset
37 } else {
5d23ffea34e3 rendering, move_coll parallel running
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents: 507
diff changeset
38 next_pp = NULL;
5d23ffea34e3 rendering, move_coll parallel running
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents: 507
diff changeset
39 }
5d23ffea34e3 rendering, move_coll parallel running
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents: 507
diff changeset
40
5d23ffea34e3 rendering, move_coll parallel running
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents: 507
diff changeset
41 for (int i = 0; i < pp->info.size; i++) {
5d23ffea34e3 rendering, move_coll parallel running
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents: 507
diff changeset
42 triPack = &pp->tri[i];
5d23ffea34e3 rendering, move_coll parallel running
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents: 507
diff changeset
43
5d23ffea34e3 rendering, move_coll parallel running
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents: 507
diff changeset
44 TriangleTexInfoPtr tri_tex_info = &triPack->tex_info;
5d23ffea34e3 rendering, move_coll parallel running
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents: 507
diff changeset
45
5d23ffea34e3 rendering, move_coll parallel running
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents: 507
diff changeset
46 make_vertex(triPack, &vMin, &vMid, &vMax, &normal1, &normal2, &normal3);
5d23ffea34e3 rendering, move_coll parallel running
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents: 507
diff changeset
47 make_vMid10(vMid10, vMin, vMid, vMax);
5d23ffea34e3 rendering, move_coll parallel running
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents: 507
diff changeset
48
5d23ffea34e3 rendering, move_coll parallel running
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents: 507
diff changeset
49 /**
5d23ffea34e3 rendering, move_coll parallel running
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents: 507
diff changeset
50 * ポリゴンを、x軸に水平に分割して二つの三角形を作り、
5d23ffea34e3 rendering, move_coll parallel running
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents: 507
diff changeset
51 * それぞれから Span を求める
5d23ffea34e3 rendering, move_coll parallel running
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents: 507
diff changeset
52 *
5d23ffea34e3 rendering, move_coll parallel running
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents: 507
diff changeset
53 * vMax
5d23ffea34e3 rendering, move_coll parallel running
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents: 507
diff changeset
54 * |\
5d23ffea34e3 rendering, move_coll parallel running
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents: 507
diff changeset
55 * | \
5d23ffea34e3 rendering, move_coll parallel running
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents: 507
diff changeset
56 * | \
5d23ffea34e3 rendering, move_coll parallel running
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents: 507
diff changeset
57 * | \
5d23ffea34e3 rendering, move_coll parallel running
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents: 507
diff changeset
58 * vMid10 ------ vMid
5d23ffea34e3 rendering, move_coll parallel running
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents: 507
diff changeset
59 * | /
5d23ffea34e3 rendering, move_coll parallel running
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents: 507
diff changeset
60 * | /
5d23ffea34e3 rendering, move_coll parallel running
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents: 507
diff changeset
61 * | /
5d23ffea34e3 rendering, move_coll parallel running
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents: 507
diff changeset
62 * |/
5d23ffea34e3 rendering, move_coll parallel running
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents: 507
diff changeset
63 * vMin
5d23ffea34e3 rendering, move_coll parallel running
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents: 507
diff changeset
64 *
5d23ffea34e3 rendering, move_coll parallel running
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents: 507
diff changeset
65 * (vMax, vMid, vMin) という triangle を
5d23ffea34e3 rendering, move_coll parallel running
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents: 507
diff changeset
66 * (vMax, vMid, vMid10) (vMin, vMid, vMid10) という
5d23ffea34e3 rendering, move_coll parallel running
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents: 507
diff changeset
67 * 二つの Triangle に分けている
5d23ffea34e3 rendering, move_coll parallel running
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents: 507
diff changeset
68 */
5d23ffea34e3 rendering, move_coll parallel running
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents: 507
diff changeset
69 half_triangle(smanager, spackList, charge_y_top, charge_y_end,
5d23ffea34e3 rendering, move_coll parallel running
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents: 507
diff changeset
70 tri_tex_info, vMin, vMid, vMid10,
5d23ffea34e3 rendering, move_coll parallel running
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents: 507
diff changeset
71 normal1,normal2,normal3,
5d23ffea34e3 rendering, move_coll parallel running
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents: 507
diff changeset
72 (int)(vMax->y - vMin->y), vMax->tex_y - vMin->tex_y);
5d23ffea34e3 rendering, move_coll parallel running
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents: 507
diff changeset
73 half_triangle(smanager, spackList, charge_y_top, charge_y_end,
5d23ffea34e3 rendering, move_coll parallel running
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents: 507
diff changeset
74 tri_tex_info, vMax, vMid, vMid10,
5d23ffea34e3 rendering, move_coll parallel running
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents: 507
diff changeset
75 normal1,normal2,normal3,
5d23ffea34e3 rendering, move_coll parallel running
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents: 507
diff changeset
76 (int)(vMax->y - vMin->y), vMax->tex_y - vMin->tex_y);
5d23ffea34e3 rendering, move_coll parallel running
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents: 507
diff changeset
77 }
5d23ffea34e3 rendering, move_coll parallel running
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents: 507
diff changeset
78
5d23ffea34e3 rendering, move_coll parallel running
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents: 507
diff changeset
79 smanager->dma_wait(POLYGON_PACK_LOAD);
5d23ffea34e3 rendering, move_coll parallel running
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents: 507
diff changeset
80
5d23ffea34e3 rendering, move_coll parallel running
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents: 507
diff changeset
81 tmp_pp = pp;
5d23ffea34e3 rendering, move_coll parallel running
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents: 507
diff changeset
82 pp = next_pp;
5d23ffea34e3 rendering, move_coll parallel running
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents: 507
diff changeset
83 next_pp = tmp_pp;
5d23ffea34e3 rendering, move_coll parallel running
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents: 507
diff changeset
84 } while (pp);
5d23ffea34e3 rendering, move_coll parallel running
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents: 507
diff changeset
85
5d23ffea34e3 rendering, move_coll parallel running
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents: 507
diff changeset
86 smanager->dma_wait(SPAN_PACK_STORE);
5d23ffea34e3 rendering, move_coll parallel running
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents: 507
diff changeset
87 smanager->dma_store(spack, (memaddr)spackList[prev_index],
5d23ffea34e3 rendering, move_coll parallel running
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents: 507
diff changeset
88 sizeof(SpanPack), SPAN_PACK_STORE);
5d23ffea34e3 rendering, move_coll parallel running
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents: 507
diff changeset
89 smanager->dma_wait(SPAN_PACK_STORE);
5d23ffea34e3 rendering, move_coll parallel running
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents: 507
diff changeset
90
5d23ffea34e3 rendering, move_coll parallel running
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents: 507
diff changeset
91 free(free_pp);
5d23ffea34e3 rendering, move_coll parallel running
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents: 507
diff changeset
92 free(free_spack);
5d23ffea34e3 rendering, move_coll parallel running
hiroki@henri.cr.ie.u-ryukyu.ac.jp
parents: 507
diff changeset
93 free(vMid10);
882
f525427ae30f SceneGraphRoot::set_move_task add.
tkaito
parents: 752
diff changeset
94 #endif
507
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
95 return 0;
735f76483bb2 Reorganization..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
96 }