gfx.c
4.82 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
/*====================================================================
* gfx.c
*
* Audio performance monitoring tool graphics routines
*
* Copyright 1995, Silicon Graphics, Inc.
* All Rights Reserved.
*
* This is UNPUBLISHED PROPRIETARY SOURCE CODE of Silicon Graphics,
* Inc.; the contents of this file may not be disclosed to third
* parties, copied or duplicated in any form, in whole or in part,
* without the prior written permission of Silicon Graphics, Inc.
*
* RESTRICTED RIGHTS LEGEND:
* Use, duplication or disclosure by the Government is subject to
* restrictions as set forth in subdivision (c)(1)(ii) of the Rights
* in Technical Data and Computer Software clause at DFARS
* 252.227-7013, and/or in similar or successor clauses in the FAR,
* DOD or NASA FAR Supplement. Unpublished - rights reserved under the
* Copyright Laws of the United States.
*====================================================================*/
#include <ultralog.h>
#include <ramrom.h>
#include <assert.h>
#include <sched.h>
#include "misc.h"
#include "audiotest.h"
#include "audio.h"
u8 *staticSegment = 0;
u64 dram_stack[SP_DRAM_STACK_SIZE64];
Gfx *glistp;
extern GFXInfo gInfo[];
extern OSMesgQueue gfxFrameMsgQ;
extern OSMesg gfxFrameMsgBuf[MAX_MESGS];
extern OSSched sc;
void
initGFX()
{
int len = _staticSegmentRomEnd - _staticSegmentRomStart;
staticSegment = _yieldSegmentEnd;
romCopy(_staticSegmentRomStart, staticSegment, len);
gInfo[0].msg.gen.type = OS_SC_DONE_MSG;
gInfo[0].cfb = cfb_16_a;
gInfo[1].msg.gen.type = OS_SC_DONE_MSG;
gInfo[1].cfb = cfb_16_b;
}
void
createGfxTask(GFXInfo *i)
{
u32 clearcolor;
Dynamic *dynamicp;
OSScTask *t;
Gfx *glistpBegin;
/**** pointers to build the display list. ****/
dynamicp = &i->dp;
glistp = i->dp.glist;
glistpBegin = glistp;
/**** Tell RCP where each segment is *****/
gSPSegment(glistp++, 0, 0);
gSPSegment(glistp++, STATIC_SEGMENT, osVirtualToPhysical(staticSegment));
gSPSegment(glistp++, DYNAMIC_SEGMENT, osVirtualToPhysical(dynamicp));
/**** Graphics pipeline state initialization ****/
gSPDisplayList(glistp++, setup_rspstate);
gSPDisplayList(glistp++, setup_rdpstate);
gDPSetDepthImage(glistp++, osVirtualToPhysical(zbuffer));
/**** clear z, z = max z, dz = 0 ****/
gDPPipeSync(glistp++);
gDPSetCycleType(glistp++, G_CYC_FILL);
gDPSetColorImage(glistp++, G_IM_FMT_RGBA, G_IM_SIZ_16b, SCREEN_WD,
osVirtualToPhysical(zbuffer));
gDPSetFillColor(glistp++, GPACK_ZDZ(G_MAXFBZ,0) << 16 |
GPACK_ZDZ(G_MAXFBZ,0));
gDPFillRectangle(glistp++, 0, 0, SCREEN_WD-1, SCREEN_HT-1);
/**** Clear framebuffer cvg = FULL or 1 ****/
gDPPipeSync(glistp++);
gDPSetColorImage(glistp++, G_IM_FMT_RGBA, G_IM_SIZ_16b, SCREEN_WD,
osVirtualToPhysical(i->cfb));
clearcolor = GPACK_RGBA5551(76, 76, 76, 1) << 16 |
GPACK_RGBA5551(76, 76, 76, 1);
gDPSetFillColor(glistp++, clearcolor);
gDPFillRectangle(glistp++, 0, 0, SCREEN_WD-1, SCREEN_HT-1);
gDPPipeSync(glistp++);
gDPSetCycleType(glistp++, G_CYC_1CYCLE);
assert((void *)glistp < (void *)&i->msg);
/* Draw music objects. */
gSPDisplayList(glistp++,onetri_dl);
/**** Force top-level display list to have an END. ****/
gDPFullSync(glistp++);
gSPEndDisplayList(glistp++);
assert (glistp - glistpBegin < NUM_GFX_CMDS);
/* Flush the dynamic segment */
osWritebackDCache(&i->dp, (int)glistp - (int)&i->dp);
/* build graphics task */
t = &i->task;
t->list.t.type = M_GFXTASK;
t->list.t.flags = 0x0;
t->list.t.ucode_boot = (u64 *)rspbootTextStart;
t->list.t.ucode_boot_size =
((int) rspbootTextEnd - (int) rspbootTextStart);
t->list.t.ucode = (u64 *) gspFast3DTextStart;
t->list.t.ucode_size = 0;
t->list.t.ucode_data = (u64 *) gspFast3DDataStart;
t->list.t.ucode_data_size = 2048;
t->list.t.dram_stack = (u64 *) dram_stack;
t->list.t.dram_stack_size = SP_DRAM_STACK_SIZE8;
t->list.t.output_buff = (u64 *) 0x0;
t->list.t.output_buff_size = (u64 *) 0x0;
t->list.t.data_ptr = (u64 *) dynamicp->glist;
t->list.t.data_size = (int)(glistp - dynamicp->glist) * sizeof (Gfx);
t->list.t.yield_data_ptr = (u64 *) gfxYieldBuf;
t->list.t.yield_data_size = OS_YIELD_DATA_SIZE;
t->next = 0; /* paranoia */
t->flags = OS_SC_NEEDS_RSP | OS_SC_NEEDS_RDP | OS_SC_LAST_TASK |
OS_SC_SWAPBUFFER;
t->msgQ = &gfxFrameMsgQ; /* reply to when finished */
t->msg = (OSMesg)&i->msg; /* reply with this message */
t->framebuffer = (void *)i->cfb;
assert(t->list.t.data_size < NUM_GFX_CMDS*sizeof(Gfx));
osSendMesg(osScGetCmdQ(&sc), (OSMesg) t, OS_MESG_BLOCK);
}