Seregon/ShadPKG

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

C++/47.3 KB/No license
ps4MEL/gnm_driver.h
ShadPKG / ps4MEL / gnm_driver.h
1/*
2 * ╔═══════════════════════════════════════════════════════════════════════════╗
3 * ║ GNM DRIVER - PS4 Graphics API Layer ║
4 * ╠═══════════════════════════════════════════════════════════════════════════╣
5 * ║ Translates PS4 GNM calls to Vulkan/SDL rendering ║
6 * ╚═══════════════════════════════════════════════════════════════════════════╝
7 */
8 
9#ifndef GNM_DRIVER_H
10#define GNM_DRIVER_H
11 
12#include <cstdint>
13 
14namespace PS4Emu {
15namespace GNM {
16 
17// Initialize GNM driver
18bool Initialize();
19void Shutdown();
20 
21// Command Buffer Submission
22int32_t sceGnmSubmitCommandBuffers(uint32_t count, void** dcbGpuAddrs,
23 uint32_t* dcbSizesInBytes,
24 void** ccbGpuAddrs, uint32_t* ccbSizesInBytes);
25 
26int32_t sceGnmSubmitAndFlipCommandBuffers(uint32_t count, void** dcbGpuAddrs,
27 uint32_t* dcbSizesInBytes,
28 void** ccbGpuAddrs, uint32_t* ccbSizesInBytes,
29 int32_t videoOutHandle, int32_t flipArg,
30 void* flipMode, int64_t flipArg2);
31 
32int32_t sceGnmSubmitDone();
33 
34// Hardware State Initialization
35int32_t sceGnmDrawInitDefaultHardwareState(void* dcb, uint32_t numDwords);
36int32_t sceGnmDrawInitDefaultHardwareState350(void* dcb, uint32_t numDwords);
37int32_t sceGnmDispatchInitDefaultHardwareState(void* dcb, uint32_t numDwords);
38 
39// Draw Commands
40int32_t sceGnmDrawIndex(void* dcb, uint32_t indexCount, void* indexAddr,
41 uint32_t predAndMod, uint32_t inlineMode);
42int32_t sceGnmDrawIndexAuto(void* dcb, uint32_t indexCount, uint32_t predAndMod);
43int32_t sceGnmDrawIndexOffset(void* dcb, uint32_t indexOffset, uint32_t indexCount,
44 uint32_t predAndMod);
45 
46// Shader Setup
47int32_t sceGnmSetVsShader(void* dcb, void* shader, uint32_t shaderModifier);
48int32_t sceGnmSetPsShader(void* dcb, void* shader);
49int32_t sceGnmSetCsShader(void* dcb, void* shader);
50 
51// Resource Binding
52int32_t sceGnmSetVSharpInUserData(void* dcb, uint32_t stage, uint32_t startSlot, void* buffer);
53int32_t sceGnmSetTSharpInUserData(void* dcb, uint32_t stage, uint32_t startSlot, void* texture);
54int32_t sceGnmSetSSharpInUserData(void* dcb, uint32_t stage, uint32_t startSlot, void* sampler);
55 
56// Render Target
57int32_t sceGnmSetRenderTarget(void* dcb, uint32_t rtSlot, void* target);
58int32_t sceGnmSetDepthRenderTarget(void* dcb, void* depthTarget);
59 
60// Video Output
61int32_t sceVideoOutOpen(int32_t userId, int32_t busType, int32_t index, void* param);
62int32_t sceVideoOutClose(int32_t handle);
63int32_t sceVideoOutSetFlipRate(int32_t handle, int32_t rate);
64int32_t sceVideoOutSubmitFlip(int32_t handle, int32_t bufferIndex,
65 uint32_t flipMode, int64_t flipArg);
66int32_t sceVideoOutRegisterBuffers(int32_t handle, int32_t startIndex,
67 void** addresses, int32_t bufferNum,
68 void* attribute);
69 
70// Framebuffer Management
71void SetFramebuffer(uint32_t* pixels, uint32_t width, uint32_t height, uint32_t pitch);
72uint32_t* GetFramebuffer();
73uint32_t GetFramebufferWidth();
74uint32_t GetFramebufferHeight();
75 
76// PM4 Command Buffer Parsing
77void ParseCommandBuffer(const void* dcb, uint32_t sizeInBytes);
78 
79// Software Rendering Primitives
80void ClearRenderTarget(uint8_t r, uint8_t g, uint8_t b, uint8_t a);
81void DrawTriangle(float x0, float y0, float x1, float y1, float x2, float y2, uint32_t color);
82void DrawRect(int x, int y, int w, int h, uint32_t color);
83 
84// Statistics
85void PrintStats();
86uint64_t GetDrawCallCount();
87uint64_t GetFrameCount();
88 
89} // namespace GNM
90} // namespace PS4Emu
91 
92#endif // GNM_DRIVER_H
93