summaryrefslogtreecommitdiff
path: root/src/core/hw/gpu.cpp
diff options
context:
space:
mode:
authorGravatar bunnei2014-07-22 22:59:26 -0400
committerGravatar bunnei2014-08-05 23:57:53 -0400
commitec14ffe1cda04cd098ce07f3d3ad96c253e91eed (patch)
treefe459fc75a4ba62ed1a730e8a4ccbdffa2846dca /src/core/hw/gpu.cpp
parentMemMap: Fixed typo with GetPointer to VRAM address. (diff)
downloadyuzu-ec14ffe1cda04cd098ce07f3d3ad96c253e91eed.tar.gz
yuzu-ec14ffe1cda04cd098ce07f3d3ad96c253e91eed.tar.xz
yuzu-ec14ffe1cda04cd098ce07f3d3ad96c253e91eed.zip
GSP: Implements preliminary command synchronization via GPU interrupts.
Core: Added a comment to explain the logic for the RunLoop iterations.
Diffstat (limited to 'src/core/hw/gpu.cpp')
-rw-r--r--src/core/hw/gpu.cpp22
1 files changed, 19 insertions, 3 deletions
diff --git a/src/core/hw/gpu.cpp b/src/core/hw/gpu.cpp
index c00be2a83..41976d989 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
18RegisterSet<u32, Regs> g_regs; 22RegisterSet<u32, Regs> g_regs;
19 23
20u64 g_last_ticks = 0; ///< Last CPU ticks 24u32 g_cur_line = 0; ///< Current vertical screen line
25u64 g_last_ticks = 0; ///< Last CPU ticks
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
@@ -249,17 +254,28 @@ template void Write<u8>(u32 addr, const u8 data);
249void Update() { 254void Update() {
250 u64 current_ticks = Core::g_app_core->GetTicks(); 255 u64 current_ticks = Core::g_app_core->GetTicks();
251 256
252 // Fake a vertical blank 257 // Synchronize line...
253 if ((current_ticks - g_last_ticks) >= kFrameTicks) { 258 if ((current_ticks - g_last_ticks) >= GPU::kFrameTicks / 400) {
259 GSP_GPU::SignalInterrupt(GSP_GPU::GXInterruptId::PDC0);
260 g_cur_line++;
254 g_last_ticks = current_ticks; 261 g_last_ticks = current_ticks;
262 }
263
264 // Synchronize frame...
265 if (g_cur_line >= 400) {
266 g_cur_line = 0;
267 GSP_GPU::SignalInterrupt(GSP_GPU::GXInterruptId::PDC1);
255 VideoCore::g_renderer->SwapBuffers(); 268 VideoCore::g_renderer->SwapBuffers();
256 Kernel::WaitCurrentThread(WAITTYPE_VBLANK); 269 Kernel::WaitCurrentThread(WAITTYPE_VBLANK);
270 HLE::Reschedule(__func__);
257 } 271 }
258} 272}
259 273
260/// Initialize hardware 274/// Initialize hardware
261void Init() { 275void Init() {
276 g_cur_line = 0;
262 g_last_ticks = Core::g_app_core->GetTicks(); 277 g_last_ticks = Core::g_app_core->GetTicks();
278
263// SetFramebufferLocation(FRAMEBUFFER_LOCATION_FCRAM); 279// SetFramebufferLocation(FRAMEBUFFER_LOCATION_FCRAM);
264 SetFramebufferLocation(FRAMEBUFFER_LOCATION_VRAM); 280 SetFramebufferLocation(FRAMEBUFFER_LOCATION_VRAM);
265 281