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
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
|
#include <dolphin/dolphin.h>
#include <dolphin/gx.h>
#include <dolphin/demo.h>
#include "__demo.h"
u8 DemoStatEnable = 0;
static DemoStatData* DemoStat;
static u32 DemoStatIndx;
static u32 DemoStatMaxIndx;
static u32 DemoStatClocks;
static u32 DemoStatDisp;
static u32 DemoStatStrLen;
static u32 topPixIn;
static u32 topPixOut;
static u32 botPixIn;
static u32 botPixOut;
static u32 clrPixIn;
static u32 copyClks;
static u32 vcCheck;
static u32 vcMiss;
static u32 vcStall;
static u32 cpReq;
static u32 tcReq;
static u32 cpuRdReq;
static u32 cpuWrReq;
static u32 dspReq;
static u32 ioReq;
static u32 viReq;
static u32 peReq;
static u32 rfReq;
static u32 fiReq;
// prototypes
static void DEMOWriteStats(u8 update);
static void DEMOWriteStats(u8 update);
void DEMOSetStats(DemoStatData* stat, u32 nstats, DEMO_STAT_DISP disp) {
if (stat == 0 || nstats == 0) {
DemoStatEnable = FALSE;
} else {
DemoStatEnable = TRUE;
DemoStat = stat;
DemoStatIndx = 0;
DemoStatMaxIndx = nstats;
DemoStatDisp = disp;
DemoStatStrLen = strlen(DemoStat->text);
}
}
static void DEMOWriteStats(u8 update) {
u32 cnt0;
u32 cnt1;
u32 cnt2;
u32 cnt3;
u32 cnt4;
u32 cnt5;
u32 cnt6;
u32 cnt7;
u32 cnt8;
u32 cnt9;
switch (DemoStat[DemoStatIndx].stat_type) {
case DEMO_STAT_GP0:
if (update) {
cnt0 = GXReadGP0Metric();
DemoStat[DemoStatIndx].count = cnt0;
GXSetGPMetric(GX_PERF0_NONE, GX_PERF1_NONE);
} else {
GXSetGPMetric(DemoStat[DemoStatIndx].stat, GX_PERF1_NONE);
GXClearGPMetric();
}
break;
case DEMO_STAT_GP1:
if (update) {
cnt0 = GXReadGP1Metric();
DemoStat[DemoStatIndx].count = cnt0;
GXSetGPMetric(GX_PERF0_NONE, GX_PERF1_NONE);
} else {
GXSetGPMetric(GX_PERF0_NONE, DemoStat[DemoStatIndx].stat);
GXClearGPMetric();
}
break;
case DEMO_STAT_MEM:
if (update) {
GXReadMemMetric(&cnt0, &cnt1, &cnt2, &cnt3, &cnt4, &cnt5, &cnt6, &cnt7, &cnt8, &cnt9);
cpReq = cnt0;
tcReq = cnt1;
cpuRdReq = cnt2;
cpuWrReq = cnt3;
dspReq = cnt4;
ioReq = cnt5;
viReq = cnt6;
peReq = cnt7;
rfReq = cnt8;
fiReq = cnt9;
} else {
GXClearMemMetric();
}
break;
case DEMO_STAT_PIX:
if (update) {
GXReadPixMetric(&cnt0, &cnt1, &cnt2, &cnt3, &cnt4, &cnt5);
topPixIn = cnt0;
topPixOut = cnt1;
botPixIn = cnt2;
botPixOut = cnt3;
clrPixIn = cnt4;
copyClks = cnt5;
} else {
GXClearPixMetric();
}
break;
case DEMO_STAT_VC:
if (update) {
GXReadVCacheMetric(&cnt0, &cnt1, &cnt2);
vcCheck = cnt0;
vcMiss = cnt1;
vcStall = cnt2;
} else {
GXSetVCacheMetric(0);
GXClearVCacheMetric();
}
break;
case DEMO_STAT_FR:
if (update) {
GXReadPixMetric(&cnt0, &cnt1, &cnt2, &cnt3, &cnt4, &cnt5);
topPixIn = cnt0;
topPixOut = cnt1;
botPixIn = cnt2;
botPixOut = cnt3;
clrPixIn = cnt4;
copyClks = cnt5;
DemoStatClocks = GXReadGP0Metric();
GXSetGPMetric(GX_PERF0_NONE, GX_PERF1_NONE);
} else {
GXClearPixMetric();
GXSetGPMetric(GX_PERF0_CLOCKS, GX_PERF1_NONE);
GXClearGPMetric();
}
break;
case DEMO_STAT_TBW:
case DEMO_STAT_TBP:
GXClearPixMetric();
if (update) {
GXReadPixMetric(&cnt0, &cnt1, &cnt2, &cnt3, &cnt4, &cnt5);
topPixIn = cnt0;
topPixOut = cnt1;
botPixIn = cnt2;
botPixOut = cnt3;
clrPixIn = cnt4;
copyClks = cnt5;
DemoStatClocks = GXReadGP0Metric();
GXReadMemMetric(&cnt0, &cnt1, &cnt2, &cnt3, &cnt4, &cnt5, &cnt6, &cnt7, &cnt8, &cnt9);
tcReq = cnt1;
GXSetGPMetric(GX_PERF0_NONE, GX_PERF1_NONE);
} else {
GXClearMemMetric();
GXSetGPMetric(GX_PERF0_CLOCKS, GX_PERF1_NONE);
GXClearGPMetric();
}
break;
case DEMO_STAT_MYC:
case DEMO_STAT_MYR:
break;
default:
OSPanic(__FILE__, 295, "DEMOSetStats: Unknown demo stat type\n");
}
}
void DEMOUpdateStats(u8 inc) {
DEMOWriteStats(inc);
if (inc) {
DemoStatIndx = DemoStatIndx + 1;
if (DemoStatIndx == DemoStatMaxIndx) {
DemoStatIndx = 0;
}
}
}
void DEMOPrintStats(void) {
GXRenderModeObj* rmode;
u32 i;
s16 text_x;
s16 text_y;
s16 text_yinc;
u16 wd;
u16 ht;
f32 rate;
if (DemoStatDisp == DEMO_STAT_IO) {
for (i = 0; i < DemoStatMaxIndx; i++) {
switch (DemoStat[i].stat_type) {
case DEMO_STAT_PIX:
switch (DemoStat[i].stat) {
case 0:
OSReport("%s: %8d\n", DemoStat[i].text, topPixIn);
break;
case 1:
OSReport("%s: %8d\n", DemoStat[i].text, topPixOut);
break;
case 2:
OSReport("%s: %8d\n", DemoStat[i].text, botPixIn);
break;
case 3:
OSReport("%s: %8d\n", DemoStat[i].text, botPixOut);
break;
case 4:
OSReport("%s: %8d\n", DemoStat[i].text, clrPixIn);
break;
case 5:
OSReport("%s: %8d\n", DemoStat[i].text, copyClks);
break;
}
break;
case DEMO_STAT_FR:
rate = 162.0f * (topPixIn + botPixIn) / (f32) (DemoStatClocks - copyClks);
OSReport("%s: %8.2f\n", DemoStat[i].text, rate);
break;
case DEMO_STAT_TBW:
rate = 162.0f * (tcReq << 5) / (f32) (DemoStatClocks - copyClks);
OSReport("%s: %8.2f\n", DemoStat[i].text, rate);
break;
case DEMO_STAT_TBP:
rate = (tcReq << 5) / (f32) (topPixIn + botPixIn);
OSReport("%s: %8.2f\n", DemoStat[i].text, rate);
break;
case DEMO_STAT_VC:
switch (DemoStat[i].stat) {
case 0:
OSReport("%s: %8d\n", DemoStat[i].text, vcCheck);
break;
case 1:
OSReport("%s: %8d\n", DemoStat[i].text, vcMiss);
break;
case 2:
OSReport("%s: %8d\n", DemoStat[i].text, vcStall);
break;
}
break;
case DEMO_STAT_MYR:
rate = DemoStat[i].stat / (f32) DemoStat[i].count;
OSReport("%s: %8.2f\n", DemoStat[i].text, rate);
break;
case DEMO_STAT_MEM:
switch (DemoStat[i].stat) {
case 0:
OSReport("%s: %8d\n", DemoStat[i].text, cpReq);
break;
case 1:
OSReport("%s: %8d\n", DemoStat[i].text, tcReq);
break;
case 2:
OSReport("%s: %8d\n", DemoStat[i].text, cpuRdReq);
break;
case 3:
OSReport("%s: %8d\n", DemoStat[i].text, cpuWrReq);
break;
case 4:
OSReport("%s: %8d\n", DemoStat[i].text, dspReq);
break;
case 5:
OSReport("%s: %8d\n", DemoStat[i].text, ioReq);
break;
case 6:
OSReport("%s: %8d\n", DemoStat[i].text, viReq);
break;
case 7:
OSReport("%s: %8d\n", DemoStat[i].text, peReq);
break;
case 8:
OSReport("%s: %8d\n", DemoStat[i].text, rfReq);
break;
case 9:
OSReport("%s: %8d\n", DemoStat[i].text, fiReq);
break;
}
break;
default:
OSReport("%s: %8d\n", DemoStat[i].text, DemoStat[i].count);
break;
}
}
} else {
rmode = DEMOGetRenderModeObj();
switch (DemoStatDisp) {
case DEMO_STAT_TL:
text_x = 0x10;
text_y = 0x10;
text_yinc = 0xA;
wd = rmode->fbWidth;
ht = rmode->xfbHeight;
break;
case DEMO_STAT_BL:
text_x = 0x10;
text_y = rmode->xfbHeight - 0x18;
text_yinc = -0xA;
wd = rmode->fbWidth;
ht = rmode->xfbHeight;
break;
case DEMO_STAT_TLD:
text_x = 8;
text_y = 8;
text_yinc = 9;
wd = rmode->fbWidth / 2;
ht = rmode->xfbHeight / 2;
break;
case DEMO_STAT_BLD:
text_x = 8;
text_y = (rmode->xfbHeight - 0x18) / 2;
text_yinc = -9;
wd = rmode->fbWidth / 2;
ht = rmode->xfbHeight / 2;
break;
}
DEMOInitCaption(0, wd, ht);
for (i = 0; i < DemoStatMaxIndx; i++) {
switch (DemoStat[i].stat_type) {
case DEMO_STAT_PIX:
switch (DemoStat[i].stat) {
case 0:
DEMOPrintf(text_x, text_y, 0, "%s: %8d\n", DemoStat[i].text, topPixIn);
break;
case 1:
DEMOPrintf(text_x, text_y, 0, "%s: %8d\n", DemoStat[i].text, topPixOut);
break;
case 2:
DEMOPrintf(text_x, text_y, 0, "%s: %8d\n", DemoStat[i].text, botPixIn);
break;
case 3:
DEMOPrintf(text_x, text_y, 0, "%s: %8d\n", DemoStat[i].text, botPixOut);
break;
case 4:
DEMOPrintf(text_x, text_y, 0, "%s: %8d\n", DemoStat[i].text, clrPixIn);
break;
case 5:
DEMOPrintf(text_x, text_y, 0, "%s: %8d\n", DemoStat[i].text, copyClks);
break;
}
break;
case DEMO_STAT_FR:
rate = 162.0f * (topPixIn + botPixIn) / (f32) (DemoStatClocks - copyClks);
DEMOPrintf(text_x, text_y, 0, "%s: %8.2f\n", DemoStat[i].text, rate);
break;
case DEMO_STAT_TBW:
rate = 162.0f * (tcReq << 5) / (f32) (DemoStatClocks - copyClks);
DEMOPrintf(text_x, text_y, 0, "%s: %8.2f\n", DemoStat[i].text, rate);
break;
case DEMO_STAT_TBP:
rate = (tcReq << 5) / (f32) (topPixIn - botPixIn);
DEMOPrintf(text_x, text_y, 0, "%s: %8.3f\n", DemoStat[i].text, rate);
break;
case DEMO_STAT_VC:
switch (DemoStat[i].stat) {
case 0:
DEMOPrintf(text_x, text_y, 0, "%s: %8d\n", DemoStat[i].text, vcCheck);
break;
case 1:
DEMOPrintf(text_x, text_y, 0, "%s: %8d\n", DemoStat[i].text, vcMiss);
break;
case 2:
DEMOPrintf(text_x, text_y, 0, "%s: %8d\n", DemoStat[i].text, vcStall);
break;
}
break;
case DEMO_STAT_MEM:
switch (DemoStat[i].stat) {
case 0:
DEMOPrintf(text_x, text_y, 0, "%s: %8d\n", DemoStat[i].text, cpReq);
break;
case 1:
DEMOPrintf(text_x, text_y, 0, "%s: %8d\n", DemoStat[i].text, tcReq);
break;
case 2:
DEMOPrintf(text_x, text_y, 0, "%s: %8d\n", DemoStat[i].text, cpuRdReq);
break;
case 3:
DEMOPrintf(text_x, text_y, 0, "%s: %8d\n", DemoStat[i].text, cpuWrReq);
break;
case 4:
DEMOPrintf(text_x, text_y, 0, "%s: %8d\n", DemoStat[i].text, dspReq);
break;
case 5:
DEMOPrintf(text_x, text_y, 0, "%s: %8d\n", DemoStat[i].text, ioReq);
break;
case 6:
DEMOPrintf(text_x, text_y, 0, "%s: %8d\n", DemoStat[i].text, viReq);
break;
case 7:
DEMOPrintf(text_x, text_y, 0, "%s: %8d\n", DemoStat[i].text, peReq);
break;
case 8:
DEMOPrintf(text_x, text_y, 0, "%s: %8d\n", DemoStat[i].text, rfReq);
break;
case 9:
DEMOPrintf(text_x, text_y, 0, "%s: %8d\n", DemoStat[i].text, fiReq);
break;
}
break;
case DEMO_STAT_GP0:
case DEMO_STAT_GP1:
case DEMO_STAT_MYC:
DEMOPrintf(text_x, text_y, 0, "%s: %8d", DemoStat[i].text, DemoStat[i].count);
break;
case DEMO_STAT_MYR:
rate = DemoStat[i].stat / (f32) DemoStat[i].count;
DEMOPrintf(text_x, text_y, 0, "%s: %8.3f", DemoStat[i].text, rate);
break;
default:
OSReport("Undefined stat type %d in DEMOPrintStats()\n", DemoStat[i].stat_type);
break;
}
text_y += text_yinc;
}
}
}
|