From 0b4497302be978d0733baa2c9d41f01079276dc3 Mon Sep 17 00:00:00 2001 From: wheremyfoodat <44909372+wheremyfoodat@users.noreply.github.com> Date: Fri, 4 Aug 2023 16:36:50 +0300 Subject: [PATCH] [GSP::GPU] Proper type assertions and visibility --- include/renderer_gl/surfaces.hpp | 2 +- include/services/gsp_gpu.hpp | 38 +++++++++++++++++--------------- src/core/services/gsp_gpu.cpp | 2 +- 3 files changed, 22 insertions(+), 20 deletions(-) diff --git a/include/renderer_gl/surfaces.hpp b/include/renderer_gl/surfaces.hpp index 3cfb5ca4..62a3b61f 100644 --- a/include/renderer_gl/surfaces.hpp +++ b/include/renderer_gl/surfaces.hpp @@ -97,7 +97,7 @@ struct ColourBuffer { const u32 startOffset = (inputAddress - location) / sizePerPixel(format); const u32 x0 = (startOffset % (size.x() * 8)) / 8; const u32 y0 = (startOffset / (size.x() * 8)) * 8; - return Math::Rect{x0, size.y() - y0, x0 + width, size.y() - height - y0}; + return Math::Rect{x0, size.y() - y0, x0 + width, size.y() - height - y0}; } bool matches(ColourBuffer& other) { diff --git a/include/services/gsp_gpu.hpp b/include/services/gsp_gpu.hpp index 76793bbc..c9facffb 100644 --- a/include/services/gsp_gpu.hpp +++ b/include/services/gsp_gpu.hpp @@ -18,24 +18,6 @@ enum class GPUInterrupt : u8 { DMA = 6 }; -struct FramebufferInfo { - u32 activeFb; - u32 leftFramebufferVaddr; - u32 rightFramebufferVaddr; - u32 stride; - u32 format; - u32 displayFb; - u32 attribute; -}; - -struct FrameBufferUpdate { - u8 index; - u8 dirtyFlag; - u16 pad0; - std::array framebufferInfo; - u32 pad1; -}; - // More circular dependencies class Kernel; @@ -58,6 +40,26 @@ class GPUService { MAKE_LOG_FUNCTION(log, gspGPULogger) void processCommandBuffer(); + struct FramebufferInfo { + u32 activeFb; + u32 leftFramebufferVaddr; + u32 rightFramebufferVaddr; + u32 stride; + u32 format; + u32 displayFb; + u32 attribute; + }; + static_assert(sizeof(FramebufferInfo) == 28, "GSP::GPU::FramebufferInfo has the wrong size"); + + struct FramebufferUpdate { + u8 index; + u8 dirtyFlag; + u16 pad0; + std::array framebufferInfo; + u32 pad1; + }; + static_assert(sizeof(FramebufferUpdate) == 64, "GSP::GPU::FramebufferUpdate has the wrong size"); + // Service commands void acquireRight(u32 messagePointer); void flushDataCache(u32 messagePointer); diff --git a/src/core/services/gsp_gpu.cpp b/src/core/services/gsp_gpu.cpp index 31b9050f..d9c31ed7 100644 --- a/src/core/services/gsp_gpu.cpp +++ b/src/core/services/gsp_gpu.cpp @@ -128,7 +128,7 @@ void GPUService::requestInterrupt(GPUInterrupt type) { if (type == GPUInterrupt::VBlank0 || type == GPUInterrupt::VBlank1) { int screen = static_cast(type) - static_cast(GPUInterrupt::VBlank0); // 0 for top screen, 1 for bottom // TODO: Offset depends on GSP thread being triggered - FrameBufferUpdate* update = reinterpret_cast(&sharedMem[0x200 + screen * sizeof(FrameBufferUpdate)]); + FramebufferUpdate* update = reinterpret_cast(&sharedMem[0x200 + screen * sizeof(FramebufferUpdate)]); if (update->dirtyFlag & 1) { setBufferSwapImpl(screen, update->framebufferInfo[update->index]);