summaryrefslogtreecommitdiff
path: root/src/core/hw/gpu.cpp
diff options
context:
space:
mode:
authorGravatar bunnei2014-08-06 18:30:01 -0400
committerGravatar bunnei2014-08-06 18:30:01 -0400
commitd0c179485392903fa413543d6b6908d45bc1f0fb (patch)
treea2e85ca4b091042e2e45446fda5b36bf6f62d2b3 /src/core/hw/gpu.cpp
parentMerge pull request #36 from bunnei/fix-memory-unaligned-reads (diff)
parentGPU: Updated g_last_ticks variable to be more descriptive (represents CPU tic... (diff)
downloadyuzu-d0c179485392903fa413543d6b6908d45bc1f0fb.tar.gz
yuzu-d0c179485392903fa413543d6b6908d45bc1f0fb.tar.xz
yuzu-d0c179485392903fa413543d6b6908d45bc1f0fb.zip
Merge pull request #34 from bunnei/gsp-command-synch
Gsp command synch
Diffstat (limited to 'src/core/hw/gpu.cpp')
-rw-r--r--src/core/hw/gpu.cpp27
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
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_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
249void Update() { 254void 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
261void Init() { 276void 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