Seregon/ShadPKG

A tool for deriving PKG packet encryption keys for ps4 written in c++

C++/47.3 KB/No license
ps4MEL/ps4_graphics.h
ShadPKG / ps4MEL / ps4_graphics.h
1/*
2 * ╔═══════════════════════════════════════════════════════════════════════════╗
3 * ║ PS4 GRAPHICS STUBS - HEADER ║
4 * ╠═══════════════════════════════════════════════════════════════════════════╣
5 * ║ Emulates sceVideoOut* and sceGnm* graphics functions. ║
6 * ║ These are stubs - no actual rendering occurs. ║
7 * ╚═══════════════════════════════════════════════════════════════════════════╝
8 */
9 
10#pragma once
11 
12#include <cstdint>
13 
14/*
15 * ┌─────────────────────────────────────────────────────────────────┐
16 * │ VIDEO OUTPUT CONSTANTS │
17 * └─────────────────────────────────────────────────────────────────┘
18 */
19 
20#define SCE_VIDEO_OUT_BUS_TYPE_MAIN 0
21#define SCE_VIDEO_OUT_BUS_TYPE_SUB 1
22 
23// Pixel formats
24#define SCE_VIDEO_OUT_PIXEL_FORMAT_A8R8G8B8_SRGB 0x80000000
25#define SCE_VIDEO_OUT_PIXEL_FORMAT_A8B8G8R8_SRGB 0x80002200
26#define SCE_VIDEO_OUT_PIXEL_FORMAT_A2R10G10B10 0x80002100
27 
28// Flip modes
29#define SCE_VIDEO_OUT_FLIP_MODE_VSYNC 1
30#define SCE_VIDEO_OUT_FLIP_MODE_HSYNC 2
31 
32// Resolution
33#define SCE_VIDEO_OUT_RESOLUTION_1920x1080 1
34#define SCE_VIDEO_OUT_RESOLUTION_3840x2160 2
35 
36/*
37 * ┌─────────────────────────────────────────────────────────────────┐
38 * │ GNM DRIVER CONSTANTS │
39 * └─────────────────────────────────────────────────────────────────┘
40 */
41 
42// Submit flags
43#define SCE_GNM_SUBMIT_DEFAULT 0
44#define SCE_GNM_SUBMIT_FLIP 1
45 
46/*
47 * ┌─────────────────────────────────────────────────────────────────┐
48 * │ STRUCTURES │
49 * └─────────────────────────────────────────────────────────────────┘
50 */
51 
52struct SceVideoOutBufferAttribute {
53 int32_t pixelFormat;
54 int32_t tilingMode;
55 int32_t aspectRatio;
56 uint32_t width;
57 uint32_t height;
58 uint32_t pitchInPixel;
59};
60 
61struct SceVideoOutFlipStatus {
62 uint64_t count;
63 uint64_t processTime;
64 uint64_t tsc;
65 int64_t flipArg;
66 uint64_t submitTsc;
67 uint64_t gcQueueNum;
68 uint64_t flipPendingNum;
69 uint64_t currentBuffer;
70};
71 
72struct SceVideoOutResolutionStatus {
73 uint32_t width;
74 uint32_t height;
75 uint32_t paneWidth;
76 uint32_t paneHeight;
77 uint64_t refreshRate;
78 float aspectRatio;
79 uint8_t padding[8];
80};
81 
82/*
83 * ┌─────────────────────────────────────────────────────────────────┐
84 * │ VIDEO OUTPUT FUNCTIONS │
85 * └─────────────────────────────────────────────────────────────────┘
86 */
87 
88extern "C" {
89 
90// ═══════════════════════════════════════════════════════════════════
91// VIDEO OUT
92// ═══════════════════════════════════════════════════════════════════
93int32_t sceVideoOutOpen(int32_t userId, int32_t busType, int32_t index,
94 const void *param);
95int32_t sceVideoOutClose(int32_t handle);
96int32_t sceVideoOutSetFlipRate(int32_t handle, int32_t rate);
97int32_t sceVideoOutRegisterBuffers(int32_t handle, int32_t startIndex,
98 void *const *addresses, int32_t bufferNum,
99 const SceVideoOutBufferAttribute *attr);
100int32_t sceVideoOutSubmitFlip(int32_t handle, int32_t bufferIndex,
101 int32_t flipMode, int64_t flipArg);
102int32_t sceVideoOutGetFlipStatus(int32_t handle, SceVideoOutFlipStatus *status);
103int32_t sceVideoOutGetResolutionStatus(int32_t handle,
104 SceVideoOutResolutionStatus *status);
105void sceVideoOutSetBufferAttribute(SceVideoOutBufferAttribute *attr,
106 int32_t pixelFormat, int32_t tilingMode,
107 int32_t aspectRatio, uint32_t width,
108 uint32_t height, uint32_t pitchInPixel);
109int32_t sceVideoOutWaitVblank(int32_t handle);
110 
111// ═══════════════════════════════════════════════════════════════════
112// GNM DRIVER (GPU COMMAND SUBMISSION)
113// ═══════════════════════════════════════════════════════════════════
114int32_t sceGnmSubmitCommandBuffers(uint32_t count, void *const *dcbGpuAddrs,
115 const uint32_t *dcbSizesInBytes,
116 void *const *ccbGpuAddrs,
117 const uint32_t *ccbSizesInBytes);
118int32_t sceGnmSubmitAndFlipCommandBuffers(
119 uint32_t count, void *const *dcbGpuAddrs, const uint32_t *dcbSizesInBytes,
120 void *const *ccbGpuAddrs, const uint32_t *ccbSizesInBytes,
121 int32_t videoHandle, int32_t bufferIndex, int32_t flipMode,
122 int64_t flipArg);
123void sceGnmFlushGarlic();
124uint32_t sceGnmGetGpuCoreClockFrequency();
125int32_t sceGnmIsUserPaEnabled();
126void *sceGnmGetTheTessellationFactorRingBufferBaseAddress();
127 
128// ═══════════════════════════════════════════════════════════════════
129// PAD (CONTROLLER INPUT)
130// ═══════════════════════════════════════════════════════════════════
131int32_t scePadOpen(int32_t userId, int32_t type, int32_t index,
132 const void *param);
133int32_t scePadClose(int32_t handle);
134int32_t scePadRead(int32_t handle, void *data, int32_t num);
135int32_t scePadReadState(int32_t handle, void *data);
136int32_t scePadSetVibration(int32_t handle, const void *param);
137int32_t scePadResetLightBar(int32_t handle);
138int32_t scePadSetLightBar(int32_t handle, const void *param);
139 
140// ═══════════════════════════════════════════════════════════════════
141// AUDIO OUTPUT
142// ═══════════════════════════════════════════════════════════════════
143int32_t sceAudioOutOpen(int32_t userId, int32_t type, int32_t index,
144 uint32_t len, uint32_t freq, uint32_t param);
145int32_t sceAudioOutClose(int32_t handle);
146int32_t sceAudioOutOutput(int32_t handle, const void *ptr);
147int32_t sceAudioOutSetVolume(int32_t handle, int32_t flag, int32_t *vol);
148 
149} // extern "C"
150