diff options
Diffstat (limited to 'src/core/hw/gpu.cpp')
| -rw-r--r-- | src/core/hw/gpu.cpp | 27 |
1 files changed, 22 insertions, 5 deletions
diff --git a/src/core/hw/gpu.cpp b/src/core/hw/gpu.cpp index c00be2a83..d94c2329b 100644 --- a/src/core/hw/gpu.cpp +++ b/src/core/hw/gpu.cpp | |||
| @@ -7,7 +7,11 @@ | |||
| 7 | 7 | ||
| 8 | #include "core/core.h" | 8 | #include "core/core.h" |
| 9 | #include "core/mem_map.h" | 9 | #include "core/mem_map.h" |
| 10 | |||
| 11 | #include "core/hle/hle.h" | ||
| 10 | #include "core/hle/kernel/thread.h" | 12 | #include "core/hle/kernel/thread.h" |
| 13 | #include "core/hle/service/gsp.h" | ||
| 14 | |||
| 11 | #include "core/hw/gpu.h" | 15 | #include "core/hw/gpu.h" |
| 12 | 16 | ||
| 13 | #include "video_core/video_core.h" | 17 | #include "video_core/video_core.h" |
| @@ -17,7 +21,8 @@ namespace GPU { | |||
| 17 | 21 | ||
| 18 | RegisterSet<u32, Regs> g_regs; | 22 | RegisterSet<u32, Regs> g_regs; |
| 19 | 23 | ||
| 20 | u64 g_last_ticks = 0; ///< Last CPU ticks | 24 | u32 g_cur_line = 0; ///< Current vertical screen line |
| 25 | u64 g_last_line_ticks = 0; ///< CPU tick count from last vertical screen line | ||
| 21 | 26 | ||
| 22 | /** | 27 | /** |
| 23 | * Sets whether the framebuffers are in the GSP heap (FCRAM) or VRAM | 28 | * Sets whether the framebuffers are in the GSP heap (FCRAM) or VRAM |
| @@ -247,19 +252,31 @@ template void Write<u8>(u32 addr, const u8 data); | |||
| 247 | 252 | ||
| 248 | /// Update hardware | 253 | /// Update hardware |
| 249 | void Update() { | 254 | void Update() { |
| 255 | auto& framebuffer_top = g_regs.Get<Regs::FramebufferTop>(); | ||
| 250 | u64 current_ticks = Core::g_app_core->GetTicks(); | 256 | u64 current_ticks = Core::g_app_core->GetTicks(); |
| 251 | 257 | ||
| 252 | // Fake a vertical blank | 258 | // Synchronize line... |
| 253 | if ((current_ticks - g_last_ticks) >= kFrameTicks) { | 259 | if ((current_ticks - g_last_line_ticks) >= GPU::kFrameTicks / framebuffer_top.height) { |
| 254 | g_last_ticks = current_ticks; | 260 | GSP_GPU::SignalInterrupt(GSP_GPU::InterruptId::PDC0); |
| 261 | g_cur_line++; | ||
| 262 | g_last_line_ticks = current_ticks; | ||
| 263 | } | ||
| 264 | |||
| 265 | // Synchronize frame... | ||
| 266 | if (g_cur_line >= framebuffer_top.height) { | ||
| 267 | g_cur_line = 0; | ||
| 268 | GSP_GPU::SignalInterrupt(GSP_GPU::InterruptId::PDC1); | ||
| 255 | VideoCore::g_renderer->SwapBuffers(); | 269 | VideoCore::g_renderer->SwapBuffers(); |
| 256 | Kernel::WaitCurrentThread(WAITTYPE_VBLANK); | 270 | Kernel::WaitCurrentThread(WAITTYPE_VBLANK); |
| 271 | HLE::Reschedule(__func__); | ||
| 257 | } | 272 | } |
| 258 | } | 273 | } |
| 259 | 274 | ||
| 260 | /// Initialize hardware | 275 | /// Initialize hardware |
| 261 | void Init() { | 276 | void Init() { |
| 262 | g_last_ticks = Core::g_app_core->GetTicks(); | 277 | g_cur_line = 0; |
| 278 | g_last_line_ticks = Core::g_app_core->GetTicks(); | ||
| 279 | |||
| 263 | // SetFramebufferLocation(FRAMEBUFFER_LOCATION_FCRAM); | 280 | // SetFramebufferLocation(FRAMEBUFFER_LOCATION_FCRAM); |
| 264 | SetFramebufferLocation(FRAMEBUFFER_LOCATION_VRAM); | 281 | SetFramebufferLocation(FRAMEBUFFER_LOCATION_VRAM); |
| 265 | 282 | ||