-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathgraphics.c
executable file
·755 lines (678 loc) · 27.5 KB
/
graphics.c
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
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
#include <vitasdk.h>
#include <taihen.h>
#include "osd.h"
#include "main.h"
#define MAX_RENDER_TARGETS 64
#define MAX_COLOR_SURFACES 64
#define MAX_DEPTH_STENCIL_SURFACES 64
#define MAX_TEXTURES 64
typedef struct {
uint8_t active;
SceGxmRenderTarget *ptr;
SceGxmRenderTargetParams params;
SceUID driverMemBlockBeforeCreate;
} VGi_RenderTarget;
typedef struct {
SceGxmColorSurface *surface;
SceGxmColorFormat colorFormat;
SceGxmColorSurfaceType surfaceType;
SceGxmColorSurfaceScaleMode scaleMode;
SceGxmOutputRegisterSize outputRegisterSize;
unsigned int width;
unsigned int height;
unsigned int strideInPixels;
void *data;
} VGi_ColorSurface;
typedef struct {
SceGxmDepthStencilSurface *surface;
SceGxmDepthStencilFormat depthStencilFormat;
SceGxmDepthStencilSurfaceType surfaceType;
unsigned int strideInSamples;
void *depthData;
void *stencilData;
} VGi_DepthStencilSurface;
typedef enum {
TEXTURE_LINEAR,
TEXTURE_LINEAR_STRIDED,
TEXTURE_SWIZZLED,
TEXTURE_TILED,
TEXTURE_CUBE
} VGi_TextureType;
typedef struct {
SceGxmTexture *texture;
VGi_TextureType type;
const void *data;
SceGxmTextureFormat texFormat;
unsigned int width;
unsigned int height;
unsigned int mipCount;
unsigned int byteStride;
} VGi_Texture;
static uint8_t sceDisplayGetRefreshRate_used = 0;
static uint8_t sceDisplayGetVcount_used = 0;
static uint8_t sceDisplayWaitVblankStart_used = 0;
static uint8_t sceDisplayWaitVblankStartCB_used = 0;
static uint8_t sceDisplayWaitVblankStartMulti_used = 0;
static uint8_t sceDisplayWaitVblankStartMultiCB_used = 0;
static uint8_t sceDisplayWaitSetFrameBuf_used = 0;
static uint8_t sceDisplayWaitSetFrameBufCB_used = 0;
static uint8_t sceDisplayWaitSetFrameBufMulti_used = 0;
static uint8_t sceDisplayWaitSetFrameBufMultiCB_used = 0;
static uint8_t sceDisplayWaitVblankStartMulti_vcount = 0;
static uint8_t sceDisplayWaitVblankStartMultiCB_vcount = 0;
static uint8_t sceDisplayWaitSetFrameBufMulti_vcount = 0;
static uint8_t sceDisplayWaitSetFrameBufMultiCB_vcount = 0;
static VGi_RenderTarget g_renderTargets[MAX_RENDER_TARGETS] = {0};
static uint32_t g_renderTargetsCount = 0;
static VGi_ColorSurface g_colorSurfaces[MAX_COLOR_SURFACES] = {0};
static uint32_t g_colorSurfacesCount = 0;
static VGi_DepthStencilSurface g_depthStencilSurfaces[MAX_DEPTH_STENCIL_SURFACES] = {0};
static uint32_t g_depthStencilSurfacesCount = 0;
static VGi_Texture g_textures[MAX_TEXTURES] = {0};
static uint32_t g_texturesCount = 0;
static SceGxmInitializeParams g_gxmInitializeParams = {0};
static int sceGxmCreateRenderTarget_patched(const SceGxmRenderTargetParams *params, SceGxmRenderTarget *renderTarget) {
SceUID dmb = params->driverMemBlock;
int ret = TAI_CONTINUE(int, g_hookrefs[11], params, renderTarget);
for (int i = 0; i < MAX_RENDER_TARGETS; i++) {
if (!g_renderTargets[i].active) {
g_renderTargets[i].active = 1;
g_renderTargets[i].ptr = renderTarget;
g_renderTargets[i].driverMemBlockBeforeCreate = dmb;
memcpy(&(g_renderTargets[i].params), params, sizeof(SceGxmRenderTargetParams));
goto RET;
}
}
RET:
g_renderTargetsCount++;
return ret;
}
static int sceGxmDestroyRenderTarget_patched(SceGxmRenderTarget *renderTarget) {
for (int i = 0; i < MAX_RENDER_TARGETS; i++) {
if (g_renderTargets[i].ptr == renderTarget && g_renderTargets[i].active) {
g_renderTargets[i].active = 0;
goto RET;
}
}
RET:
g_renderTargetsCount--;
return TAI_CONTINUE(int, g_hookrefs[12], renderTarget);
}
static int sceDisplayGetRefreshRate_patched(float *pFps) {
sceDisplayGetRefreshRate_used = 1;
return TAI_CONTINUE(int, g_hookrefs[1], pFps);
}
static int sceDisplayGetVcount_patched() {
sceDisplayGetVcount_used = 1;
return TAI_CONTINUE(int, g_hookrefs[2]);
}
static int sceDisplayWaitVblankStart_patched() {
sceDisplayWaitVblankStart_used = 1;
if (g_vsyncKillswitch == 2)
return 0;
return TAI_CONTINUE(int, g_hookrefs[3]);
}
static int sceDisplayWaitVblankStartCB_patched() {
sceDisplayWaitVblankStartCB_used = 1;
if (g_vsyncKillswitch == 2)
return 0;
return TAI_CONTINUE(int, g_hookrefs[4]);
}
static int sceDisplayWaitVblankStartMulti_patched(unsigned int vcount) {
sceDisplayWaitVblankStartMulti_used = 1;
sceDisplayWaitVblankStartMulti_vcount = vcount;
if (g_vsyncKillswitch == 2)
return 0;
if (g_vsyncKillswitch == 1)
vcount = 1;
return TAI_CONTINUE(int, g_hookrefs[5], vcount);
}
static int sceDisplayWaitVblankStartMultiCB_patched(unsigned int vcount) {
sceDisplayWaitVblankStartMultiCB_used = 1;
sceDisplayWaitVblankStartMultiCB_vcount = vcount;
if (g_vsyncKillswitch == 2)
return 0;
if (g_vsyncKillswitch == 1)
vcount = 1;
return TAI_CONTINUE(int, g_hookrefs[6], vcount);
}
static int sceDisplayWaitSetFrameBuf_patched() {
sceDisplayWaitSetFrameBuf_used = 1;
if (g_vsyncKillswitch == 2)
return 0;
return TAI_CONTINUE(int, g_hookrefs[7]);
}
static int sceDisplayWaitSetFrameBufCB_patched() {
sceDisplayWaitSetFrameBufCB_used = 1;
if (g_vsyncKillswitch == 2)
return 0;
return TAI_CONTINUE(int, g_hookrefs[8]);
}
static int sceDisplayWaitSetFrameBufMulti_patched(unsigned int vcount) {
sceDisplayWaitSetFrameBufMulti_used = 1;
sceDisplayWaitSetFrameBufMulti_vcount = vcount;
if (g_vsyncKillswitch == 2)
return 0;
if (g_vsyncKillswitch == 1)
vcount = 1;
return TAI_CONTINUE(int, g_hookrefs[9], vcount);
}
static int sceDisplayWaitSetFrameBufMultiCB_patched(unsigned int vcount) {
sceDisplayWaitSetFrameBufMultiCB_used = 1;
sceDisplayWaitSetFrameBufMultiCB_vcount = vcount;
if (g_vsyncKillswitch == 2)
return 0;
if (g_vsyncKillswitch == 1)
vcount = 1;
return TAI_CONTINUE(int, g_hookrefs[10], vcount);
}
static int sceGxmColorSurfaceInit_patched(
SceGxmColorSurface *surface,
SceGxmColorFormat colorFormat,
SceGxmColorSurfaceType surfaceType,
SceGxmColorSurfaceScaleMode scaleMode,
SceGxmOutputRegisterSize outputRegisterSize,
unsigned int width,
unsigned int height,
unsigned int strideInPixels,
void *data) {
int ret = TAI_CONTINUE(int, g_hookrefs[22], surface, colorFormat, surfaceType,
scaleMode, outputRegisterSize, width, height, strideInPixels, data);
int i = 0;
for (i = 0; i < MAX_COLOR_SURFACES; i++) {
if (g_colorSurfaces[i].surface == surface) {
goto RET_EXISTING;
}
}
for (i = 0; i < MAX_COLOR_SURFACES; i++) {
if (!g_colorSurfaces[i].surface) {
goto RET_NEW;
}
}
return ret;
RET_NEW:
g_colorSurfacesCount++;
RET_EXISTING:
g_colorSurfaces[i].surface = surface;
g_colorSurfaces[i].colorFormat = colorFormat;
g_colorSurfaces[i].surfaceType = surfaceType;
g_colorSurfaces[i].scaleMode = scaleMode;
g_colorSurfaces[i].outputRegisterSize = outputRegisterSize;
g_colorSurfaces[i].width = width;
g_colorSurfaces[i].height = height;
g_colorSurfaces[i].strideInPixels = strideInPixels;
g_colorSurfaces[i].data = data;
return ret;
}
static int sceGxmInitialize_patched(const SceGxmInitializeParams *params) {
memcpy(&g_gxmInitializeParams, params, sizeof(SceGxmInitializeParams));
return TAI_CONTINUE(int, g_hookrefs[25], params);
}
static int sceGxmDepthStencilSurfaceInit_patched(
SceGxmDepthStencilSurface *surface,
SceGxmDepthStencilFormat depthStencilFormat,
SceGxmDepthStencilSurfaceType surfaceType,
unsigned int strideInSamples,
void *depthData,
void *stencilData) {
int ret = TAI_CONTINUE(int, g_hookrefs[27], surface, depthStencilFormat, surfaceType,
strideInSamples, depthData, stencilData);
int i = 0;
for (i = 0; i < MAX_DEPTH_STENCIL_SURFACES; i++) {
if (g_depthStencilSurfaces[i].surface == surface) {
goto RET_EXISTING;
}
}
for (i = 0; i < MAX_DEPTH_STENCIL_SURFACES; i++) {
if (!g_depthStencilSurfaces[i].surface) {
goto RET_NEW;
}
}
return ret;
RET_NEW:
g_depthStencilSurfacesCount++;
RET_EXISTING:
g_depthStencilSurfaces[i].surface = surface;
g_depthStencilSurfaces[i].depthStencilFormat = depthStencilFormat;
g_depthStencilSurfaces[i].surfaceType = surfaceType;
g_depthStencilSurfaces[i].strideInSamples = strideInSamples;
g_depthStencilSurfaces[i].depthData = depthData;
g_depthStencilSurfaces[i].stencilData = stencilData;
return ret;
}
static void addTexture(
VGi_TextureType type,
SceGxmTexture *texture,
const void *data,
SceGxmTextureFormat texFormat,
unsigned int width,
unsigned int height,
unsigned int mipCount,
unsigned int byteStride) {
int i = 0;
for (i = 0; i < MAX_TEXTURES; i++) {
if (g_textures[i].texture == texture) {
goto RET_EXISTING;
}
if (g_textures[i].texture &&
g_textures[i].width == width &&
g_textures[i].height == height) {
goto RET_SKIP;
}
}
for (i = 0; i < MAX_TEXTURES; i++) {
if (!g_textures[i].texture) {
goto RET_NEW;
}
}
RET_NEW:
g_texturesCount++;
RET_EXISTING:
g_textures[i].texture = texture;
g_textures[i].type = type;
g_textures[i].data = data;
g_textures[i].texFormat = texFormat;
g_textures[i].width = width;
g_textures[i].height = height;
g_textures[i].mipCount = mipCount;
g_textures[i].byteStride = byteStride;
return;
RET_SKIP:
g_texturesCount++;
return;
}
static int sceGxmTextureInitSwizzled_patched(
SceGxmTexture *texture,
const void *data,
SceGxmTextureFormat texFormat,
unsigned int width,
unsigned int height,
unsigned int mipCount) {
int ret = TAI_CONTINUE(int, g_hookrefs[28], texture, data, texFormat,
width, height, mipCount);
addTexture(TEXTURE_SWIZZLED, texture, data, texFormat, width, height, mipCount, 0);
return ret;
}
static int sceGxmTextureInitLinear_patched(
SceGxmTexture *texture,
const void *data,
SceGxmTextureFormat texFormat,
unsigned int width,
unsigned int height,
unsigned int mipCount) {
int ret = TAI_CONTINUE(int, g_hookrefs[29], texture, data, texFormat,
width, height, mipCount);
addTexture(TEXTURE_LINEAR, texture, data, texFormat, width, height, mipCount, 0);
return ret;
}
static int sceGxmTextureInitLinearStrided_patched(
SceGxmTexture *texture,
const void *data,
SceGxmTextureFormat texFormat,
unsigned int width,
unsigned int height,
unsigned int byteStride) {
int ret = TAI_CONTINUE(int, g_hookrefs[30], texture, data, texFormat,
width, height, byteStride);
addTexture(TEXTURE_LINEAR_STRIDED, texture, data, texFormat, width, height, 0, byteStride);
return ret;
}
static int sceGxmTextureInitTiled_patched(
SceGxmTexture *texture,
const void *data,
SceGxmTextureFormat texFormat,
unsigned int width,
unsigned int height,
unsigned int mipCount) {
int ret = TAI_CONTINUE(int, g_hookrefs[31], texture, data, texFormat,
width, height, mipCount);
addTexture(TEXTURE_TILED, texture, data, texFormat, width, height, mipCount, 0);
return ret;
}
static int sceGxmTextureInitCube_patched(
SceGxmTexture *texture,
const void *data,
SceGxmTextureFormat texFormat,
unsigned int width,
unsigned int height,
unsigned int mipCount) {
int ret = TAI_CONTINUE(int, g_hookrefs[32], texture, data, texFormat,
width, height, mipCount);
addTexture(TEXTURE_CUBE, texture, data, texFormat, width, height, mipCount, 0);
return ret;
}
static const char *getTextureTypeString(VGi_TextureType type) {
switch (type) {
case TEXTURE_LINEAR:
return "LINEAR";
case TEXTURE_LINEAR_STRIDED:
return "LINEAR_S";
case TEXTURE_SWIZZLED:
return "SWIZZLED";
case TEXTURE_TILED:
return "TILED";
case TEXTURE_CUBE:
return "CUBE";
default:
return "?";
}
}
void drawGraphicsMenu(const SceDisplayFrameBuf *pParam) {
osdSetTextScale(2);
osdDrawStringF((pParam->width / 2) - osdGetTextWidth(MENU_TITLE_GRAPHICS) / 2, 5, MENU_TITLE_GRAPHICS);
osdSetTextScale(1);
osdDrawStringF(10, 60, "Framebuffer: %dx%d, stride = %d", pParam->width, pParam->height, pParam->pitch);
osdDrawStringF(10, 82, "Max Pending Swaps: %d", g_gxmInitializeParams.displayQueueMaxPendingCount);
osdDrawStringF(10, 104, "DQ Callback: 0x%X", g_gxmInitializeParams.displayQueueCallback);
osdDrawStringF(10, 126, "Param. buf. size: %d B", g_gxmInitializeParams.parameterBufferSize);
osdDrawStringF(10, 170, "VSync mechanisms:");
if (!g_vsyncKillswitch) {
osdSetTextColor(150, 255, 150, 255);
osdDrawStringF(pParam->width - osdGetTextWidth("DEFAULT (O)") - 10, 170, "DEFAULT (O)");
} else if (g_vsyncKillswitch == 1) {
osdSetTextColor(255, 255, 150, 255);
osdDrawStringF(pParam->width - osdGetTextWidth("ALLOW 1 (O)") - 10, 170, "ALLOW 1 (O)");
} else if (g_vsyncKillswitch == 2) {
osdSetTextColor(255, 150, 150, 255);
osdDrawStringF(pParam->width - osdGetTextWidth("DROP ALL (O)") - 10, 170, "DROP ALL (O)");
}
osdSetTextColor(255, 255, 255, 255);
int x = 30, y = 192;
if (sceDisplayGetRefreshRate_used)
osdDrawStringF(x, y += 22, "sceDisplayGetRefreshRate()");
if (sceDisplayGetVcount_used)
osdDrawStringF(x, y += 22, "sceDisplayGetVcount()");
if (sceDisplayWaitVblankStart_used)
osdDrawStringF(x, y += 22, "sceDisplayWaitVblankStart()");
if (sceDisplayWaitVblankStartCB_used)
osdDrawStringF(x, y += 22, "sceDisplayWaitVblankStartCB()");
if (sceDisplayWaitVblankStartMulti_used)
osdDrawStringF(x, y += 22, "sceDisplayWaitVblankStartMulti( %d )", sceDisplayWaitVblankStartMulti_vcount);
if (sceDisplayWaitVblankStartMultiCB_used)
osdDrawStringF(x, y += 22, "sceDisplayWaitVblankStartMultiCB( %d )", sceDisplayWaitVblankStartMultiCB_vcount);
if (sceDisplayWaitSetFrameBuf_used)
osdDrawStringF(x, y += 22, "sceDisplayWaitSetFrameBuf()");
if (sceDisplayWaitSetFrameBufCB_used)
osdDrawStringF(x, y += 22, "sceDisplayWaitSetFrameBufCB()");
if (sceDisplayWaitSetFrameBufMulti_used)
osdDrawStringF(x, y += 22, "sceDisplayWaitSetFrameBufMulti( %d )", sceDisplayWaitSetFrameBufMulti_vcount);
if (sceDisplayWaitSetFrameBufMultiCB_used)
osdDrawStringF(x, y += 22, "sceDisplayWaitSetFrameBufMultiCB( %d )", sceDisplayWaitSetFrameBufMultiCB_vcount);
}
void drawGraphics2Menu(const SceDisplayFrameBuf *pParam) {
osdSetTextScale(2);
osdDrawStringF((pParam->width / 2) - osdGetTextWidth(MENU_TITLE_GRAPHICS_2) / 2, 5, MENU_TITLE_GRAPHICS_2);
// Header
osdSetTextScale(1);
osdDrawStringF(10, 60, "Active Render Targets (%d):", g_renderTargetsCount);
if (g_renderTargetsCount > MAX_RENDER_TARGETS) {
char buf[32];
snprintf(buf, 32, "!! > %d", MAX_RENDER_TARGETS);
osdDrawStringF(pParam->width - osdGetTextWidth(buf), 60, buf);
}
osdDrawStringF(30, 93, " WxH MSAA scenesPF memBlockUID");
// Scrollable section
int x = 30, y = 104;
if (g_menuScroll > 0) {
// Draw scroll indicator
osdDrawStringF(pParam->width - 24 - 5, y + 22, "/\\");
osdDrawStringF(pParam->width - 24 - 5, y + 44, "%2d", g_menuScroll);
}
for (int i = g_menuScroll; i < MAX_RENDER_TARGETS; i++) {
if (g_renderTargets[i].active) {
osdDrawStringF(x, y += 22, "%4dx%-10d %-8s %-8d 0x%08X %s",
g_renderTargets[i].params.width,
g_renderTargets[i].params.height,
g_renderTargets[i].params.multisampleMode == SCE_GXM_MULTISAMPLE_4X ? "4x" :
(g_renderTargets[i].params.multisampleMode == SCE_GXM_MULTISAMPLE_2X ? "2x" : ""),
g_renderTargets[i].params.scenesPerFrame,
g_renderTargets[i].params.driverMemBlock,
g_renderTargets[i].driverMemBlockBeforeCreate == 0xFFFFFFFF ? "(A)" : "");
}
// Do not draw out of screen
if (y > pParam->height - 72) {
// Draw scroll indicator
osdDrawStringF(pParam->width - 24 - 5, pParam->height - 72, "%2d", MIN(g_renderTargetsCount, MAX_RENDER_TARGETS) - i);
osdDrawStringF(pParam->width - 24 - 5, pParam->height - 50, "\\/");
break;
}
}
}
void drawGraphics3Menu(const SceDisplayFrameBuf *pParam) {
osdSetTextScale(2);
osdDrawStringF((pParam->width / 2) - osdGetTextWidth(MENU_TITLE_GRAPHICS_3) / 2, 5, MENU_TITLE_GRAPHICS_3);
// Header
osdSetTextScale(1);
osdDrawStringF(10, 60, "Color Surfaces (%d):", g_colorSurfacesCount);
if (g_colorSurfacesCount > MAX_COLOR_SURFACES) {
char buf[32];
snprintf(buf, 32, "!! > %d", MAX_COLOR_SURFACES);
osdDrawStringF(pParam->width - osdGetTextWidth(buf), 60, buf);
}
osdDrawStringF(30, 93, " WxH stride MSAA colorFormat surfaceType");
// Scrollable section
int x = 30, y = 104;
if (g_menuScroll > 0) {
// Draw scroll indicator
osdDrawStringF(pParam->width - 24 - 5, y + 22, "/\\");
osdDrawStringF(pParam->width - 24 - 5, y + 44, "%2d", g_menuScroll);
}
for (int i = g_menuScroll; i < MAX_COLOR_SURFACES; i++) {
if (g_colorSurfaces[i].surface) {
osdDrawStringF(x, y += 22, "%4dx%-7d %-8d %-6s 0x%-10X 0x%X",
g_colorSurfaces[i].width,
g_colorSurfaces[i].height,
g_colorSurfaces[i].strideInPixels,
g_colorSurfaces[i].scaleMode == SCE_GXM_COLOR_SURFACE_SCALE_MSAA_DOWNSCALE ? "DS" : "",
g_colorSurfaces[i].colorFormat,
g_colorSurfaces[i].surfaceType);
}
// Do not draw out of screen
if (y > pParam->height - 72) {
// Draw scroll indicator
osdDrawStringF(pParam->width - 24 - 5, pParam->height - 72, "%2d", MIN(g_colorSurfacesCount, MAX_COLOR_SURFACES) - i);
osdDrawStringF(pParam->width - 24 - 5, pParam->height - 50, "\\/");
break;
}
}
}
void drawGraphics4Menu(const SceDisplayFrameBuf *pParam) {
osdSetTextScale(2);
osdDrawStringF((pParam->width / 2) - osdGetTextWidth(MENU_TITLE_GRAPHICS_4) / 2, 5, MENU_TITLE_GRAPHICS_4);
// Header
osdSetTextScale(1);
osdDrawStringF(10, 60, "Depth/Stencil Surfaces (%d):", g_depthStencilSurfacesCount);
if (g_depthStencilSurfacesCount > MAX_DEPTH_STENCIL_SURFACES) {
char buf[32];
snprintf(buf, 32, "!! > %d", MAX_DEPTH_STENCIL_SURFACES);
osdDrawStringF(pParam->width - osdGetTextWidth(buf), 60, buf);
}
osdDrawStringF(30, 93, "strideSamples surface depth stencil format type");
// Scrollable section
int x = 30, y = 104;
if (g_menuScroll > 0) {
// Draw scroll indicator
osdDrawStringF(pParam->width - 24 - 5, y + 22, "/\\");
osdDrawStringF(pParam->width - 24 - 5, y + 44, "%2d", g_menuScroll);
}
for (int i = g_menuScroll; i < MAX_DEPTH_STENCIL_SURFACES; i++) {
if (g_depthStencilSurfaces[i].surface) {
osdDrawStringF(x, y += 22, " %-9d 0x%-9X 0x%-9X 0x%-9X 0x%-9X 0x%-9X",
g_depthStencilSurfaces[i].strideInSamples,
g_depthStencilSurfaces[i].surface,
g_depthStencilSurfaces[i].depthData,
g_depthStencilSurfaces[i].stencilData,
g_depthStencilSurfaces[i].depthStencilFormat,
g_depthStencilSurfaces[i].surfaceType);
}
// Do not draw out of screen
if (y > pParam->height - 72) {
// Draw scroll indicator
osdDrawStringF(pParam->width - 24 - 5, pParam->height - 72, "%2d", MIN(g_depthStencilSurfacesCount, MAX_DEPTH_STENCIL_SURFACES) - i);
osdDrawStringF(pParam->width - 24 - 5, pParam->height - 50, "\\/");
break;
}
}
}
void drawGraphics5Menu(const SceDisplayFrameBuf *pParam) {
osdSetTextScale(2);
osdDrawStringF((pParam->width / 2) - osdGetTextWidth(MENU_TITLE_GRAPHICS_5) / 2, 5, MENU_TITLE_GRAPHICS_5);
// Header
osdSetTextScale(1);
osdDrawStringF(10, 60, "Textures (showing only 1 per size):");
if (g_texturesCount > MAX_TEXTURES) {
char buf[32];
snprintf(buf, 32, "!! > %d", MAX_TEXTURES);
osdDrawStringF(pParam->width - osdGetTextWidth(buf), 60, buf);
}
osdDrawStringF(30, 93, " size type ptr data format mipCount byteStride");
// Scrollable section
int x = 30, y = 104;
if (g_menuScroll > 0) {
// Draw scroll indicator
osdDrawStringF(pParam->width - 24 - 5, y + 22, "/\\");
osdDrawStringF(pParam->width - 24 - 5, y + 44, "%2d", g_menuScroll);
}
for (int i = g_menuScroll; i < MAX_TEXTURES; i++) {
if (g_textures[i].texture) {
osdDrawStringF(x, y += 22, "%4dx%-5d %-9s 0x%-9X 0x%-9X 0x%-9X %-6d %d",
g_textures[i].width,
g_textures[i].height,
getTextureTypeString(g_textures[i].type),
g_textures[i].texture,
g_textures[i].data,
g_textures[i].texFormat,
g_textures[i].mipCount,
g_textures[i].byteStride);
}
// Do not draw out of screen
if (y > pParam->height - 72) {
// Draw scroll indicator
osdDrawStringF(pParam->width - 24 - 5, pParam->height - 72, "%2d", MIN(g_texturesCount, MAX_TEXTURES) - i);
osdDrawStringF(pParam->width - 24 - 5, pParam->height - 50, "\\/");
break;
}
}
}
void setupGraphicsMenu() {
g_hooks[1] = taiHookFunctionImport(
&g_hookrefs[1],
TAI_MAIN_MODULE,
TAI_ANY_LIBRARY,
0xA08CA60D,
sceDisplayGetRefreshRate_patched);
g_hooks[2] = taiHookFunctionImport(
&g_hookrefs[2],
TAI_MAIN_MODULE,
TAI_ANY_LIBRARY,
0xB6FDE0BA,
sceDisplayGetVcount_patched);
g_hooks[3] = taiHookFunctionImport(
&g_hookrefs[3],
TAI_MAIN_MODULE,
TAI_ANY_LIBRARY,
0x5795E898,
sceDisplayWaitVblankStart_patched);
g_hooks[4] = taiHookFunctionImport(
&g_hookrefs[4],
TAI_MAIN_MODULE,
TAI_ANY_LIBRARY,
0x78B41B92,
sceDisplayWaitVblankStartCB_patched);
g_hooks[5] = taiHookFunctionImport(
&g_hookrefs[5],
TAI_MAIN_MODULE,
TAI_ANY_LIBRARY,
0xDD0A13B8,
sceDisplayWaitVblankStartMulti_patched);
g_hooks[6] = taiHookFunctionImport(
&g_hookrefs[6],
TAI_MAIN_MODULE,
TAI_ANY_LIBRARY,
0x05F27764,
sceDisplayWaitVblankStartMultiCB_patched);
g_hooks[7] = taiHookFunctionImport(
&g_hookrefs[7],
TAI_MAIN_MODULE,
TAI_ANY_LIBRARY,
0x9423560C,
sceDisplayWaitSetFrameBuf_patched);
g_hooks[8] = taiHookFunctionImport(
&g_hookrefs[8],
TAI_MAIN_MODULE,
TAI_ANY_LIBRARY,
0x814C90AF,
sceDisplayWaitSetFrameBufCB_patched);
g_hooks[9] = taiHookFunctionImport(
&g_hookrefs[9],
TAI_MAIN_MODULE,
TAI_ANY_LIBRARY,
0x7D9864A8,
sceDisplayWaitSetFrameBufMulti_patched);
g_hooks[10] = taiHookFunctionImport(
&g_hookrefs[10],
TAI_MAIN_MODULE,
TAI_ANY_LIBRARY,
0x3E796EF5,
sceDisplayWaitSetFrameBufMultiCB_patched);
g_hooks[11] = taiHookFunctionImport(
&g_hookrefs[11],
TAI_MAIN_MODULE,
TAI_ANY_LIBRARY,
0x207AF96B,
sceGxmCreateRenderTarget_patched);
g_hooks[12] = taiHookFunctionImport(
&g_hookrefs[12],
TAI_MAIN_MODULE,
TAI_ANY_LIBRARY,
0x0B94C50A,
sceGxmDestroyRenderTarget_patched);
g_hooks[22] = taiHookFunctionImport(
&g_hookrefs[22],
TAI_MAIN_MODULE,
TAI_ANY_LIBRARY,
0xED0F6E25,
sceGxmColorSurfaceInit_patched);
g_hooks[25] = taiHookFunctionImport(
&g_hookrefs[25],
TAI_MAIN_MODULE,
TAI_ANY_LIBRARY,
0xB0F1E4EC,
sceGxmInitialize_patched);
g_hooks[27] = taiHookFunctionImport(
&g_hookrefs[27],
TAI_MAIN_MODULE,
TAI_ANY_LIBRARY,
0xCA9D41D1,
sceGxmDepthStencilSurfaceInit_patched);
g_hooks[28] = taiHookFunctionImport(
&g_hookrefs[28],
TAI_MAIN_MODULE,
TAI_ANY_LIBRARY,
0xD572D547,
sceGxmTextureInitSwizzled_patched);
g_hooks[29] = taiHookFunctionImport(
&g_hookrefs[29],
TAI_MAIN_MODULE,
TAI_ANY_LIBRARY,
0x4811AECB,
sceGxmTextureInitLinear_patched);
g_hooks[30] = taiHookFunctionImport(
&g_hookrefs[30],
TAI_MAIN_MODULE,
TAI_ANY_LIBRARY,
0x6679BEF0,
sceGxmTextureInitLinearStrided_patched);
g_hooks[31] = taiHookFunctionImport(
&g_hookrefs[31],
TAI_MAIN_MODULE,
TAI_ANY_LIBRARY,
0xE6F0DB27,
sceGxmTextureInitTiled_patched);
g_hooks[32] = taiHookFunctionImport(
&g_hookrefs[32],
TAI_MAIN_MODULE,
TAI_ANY_LIBRARY,
0x11DC8DC9,
sceGxmTextureInitCube_patched);
}