A tool for deriving PKG packet encryption keys for ps4 written in c++
| 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 | |
| 14 | namespace PS4Emu { |
| 15 | namespace GNM { |
| 16 | |
| 17 | // Initialize GNM driver |
| 18 | bool Initialize(); |
| 19 | void Shutdown(); |
| 20 | |
| 21 | // Command Buffer Submission |
| 22 | int32_t sceGnmSubmitCommandBuffers(uint32_t count, void** dcbGpuAddrs, |
| 23 | uint32_t* dcbSizesInBytes, |
| 24 | void** ccbGpuAddrs, uint32_t* ccbSizesInBytes); |
| 25 | |
| 26 | int32_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 | |
| 32 | int32_t sceGnmSubmitDone(); |
| 33 | |
| 34 | // Hardware State Initialization |
| 35 | int32_t sceGnmDrawInitDefaultHardwareState(void* dcb, uint32_t numDwords); |
| 36 | int32_t sceGnmDrawInitDefaultHardwareState350(void* dcb, uint32_t numDwords); |
| 37 | int32_t sceGnmDispatchInitDefaultHardwareState(void* dcb, uint32_t numDwords); |
| 38 | |
| 39 | // Draw Commands |
| 40 | int32_t sceGnmDrawIndex(void* dcb, uint32_t indexCount, void* indexAddr, |
| 41 | uint32_t predAndMod, uint32_t inlineMode); |
| 42 | int32_t sceGnmDrawIndexAuto(void* dcb, uint32_t indexCount, uint32_t predAndMod); |
| 43 | int32_t sceGnmDrawIndexOffset(void* dcb, uint32_t indexOffset, uint32_t indexCount, |
| 44 | uint32_t predAndMod); |
| 45 | |
| 46 | // Shader Setup |
| 47 | int32_t sceGnmSetVsShader(void* dcb, void* shader, uint32_t shaderModifier); |
| 48 | int32_t sceGnmSetPsShader(void* dcb, void* shader); |
| 49 | int32_t sceGnmSetCsShader(void* dcb, void* shader); |
| 50 | |
| 51 | // Resource Binding |
| 52 | int32_t sceGnmSetVSharpInUserData(void* dcb, uint32_t stage, uint32_t startSlot, void* buffer); |
| 53 | int32_t sceGnmSetTSharpInUserData(void* dcb, uint32_t stage, uint32_t startSlot, void* texture); |
| 54 | int32_t sceGnmSetSSharpInUserData(void* dcb, uint32_t stage, uint32_t startSlot, void* sampler); |
| 55 | |
| 56 | // Render Target |
| 57 | int32_t sceGnmSetRenderTarget(void* dcb, uint32_t rtSlot, void* target); |
| 58 | int32_t sceGnmSetDepthRenderTarget(void* dcb, void* depthTarget); |
| 59 | |
| 60 | // Video Output |
| 61 | int32_t sceVideoOutOpen(int32_t userId, int32_t busType, int32_t index, void* param); |
| 62 | int32_t sceVideoOutClose(int32_t handle); |
| 63 | int32_t sceVideoOutSetFlipRate(int32_t handle, int32_t rate); |
| 64 | int32_t sceVideoOutSubmitFlip(int32_t handle, int32_t bufferIndex, |
| 65 | uint32_t flipMode, int64_t flipArg); |
| 66 | int32_t sceVideoOutRegisterBuffers(int32_t handle, int32_t startIndex, |
| 67 | void** addresses, int32_t bufferNum, |
| 68 | void* attribute); |
| 69 | |
| 70 | // Framebuffer Management |
| 71 | void SetFramebuffer(uint32_t* pixels, uint32_t width, uint32_t height, uint32_t pitch); |
| 72 | uint32_t* GetFramebuffer(); |
| 73 | uint32_t GetFramebufferWidth(); |
| 74 | uint32_t GetFramebufferHeight(); |
| 75 | |
| 76 | // PM4 Command Buffer Parsing |
| 77 | void ParseCommandBuffer(const void* dcb, uint32_t sizeInBytes); |
| 78 | |
| 79 | // Software Rendering Primitives |
| 80 | void ClearRenderTarget(uint8_t r, uint8_t g, uint8_t b, uint8_t a); |
| 81 | void DrawTriangle(float x0, float y0, float x1, float y1, float x2, float y2, uint32_t color); |
| 82 | void DrawRect(int x, int y, int w, int h, uint32_t color); |
| 83 | |
| 84 | // Statistics |
| 85 | void PrintStats(); |
| 86 | uint64_t GetDrawCallCount(); |
| 87 | uint64_t GetFrameCount(); |
| 88 | |
| 89 | } // namespace GNM |
| 90 | } // namespace PS4Emu |
| 91 | |
| 92 | #endif // GNM_DRIVER_H |
| 93 |