From ec14ffe1cda04cd098ce07f3d3ad96c253e91eed Mon Sep 17 00:00:00 2001 From: bunnei Date: Tue, 22 Jul 2014 22:59:26 -0400 Subject: GSP: Implements preliminary command synchronization via GPU interrupts. Core: Added a comment to explain the logic for the RunLoop iterations. --- src/core/hw/gpu.cpp | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) (limited to 'src/core/hw/gpu.cpp') 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 @@ #include "core/core.h" #include "core/mem_map.h" + +#include "core/hle/hle.h" #include "core/hle/kernel/thread.h" +#include "core/hle/service/gsp.h" + #include "core/hw/gpu.h" #include "video_core/video_core.h" @@ -17,7 +21,8 @@ namespace GPU { RegisterSet g_regs; -u64 g_last_ticks = 0; ///< Last CPU ticks +u32 g_cur_line = 0; ///< Current vertical screen line +u64 g_last_ticks = 0; ///< Last CPU ticks /** * Sets whether the framebuffers are in the GSP heap (FCRAM) or VRAM @@ -249,17 +254,28 @@ template void Write(u32 addr, const u8 data); void Update() { u64 current_ticks = Core::g_app_core->GetTicks(); - // Fake a vertical blank - if ((current_ticks - g_last_ticks) >= kFrameTicks) { + // Synchronize line... + if ((current_ticks - g_last_ticks) >= GPU::kFrameTicks / 400) { + GSP_GPU::SignalInterrupt(GSP_GPU::GXInterruptId::PDC0); + g_cur_line++; g_last_ticks = current_ticks; + } + + // Synchronize frame... + if (g_cur_line >= 400) { + g_cur_line = 0; + GSP_GPU::SignalInterrupt(GSP_GPU::GXInterruptId::PDC1); VideoCore::g_renderer->SwapBuffers(); Kernel::WaitCurrentThread(WAITTYPE_VBLANK); + HLE::Reschedule(__func__); } } /// Initialize hardware void Init() { + g_cur_line = 0; g_last_ticks = Core::g_app_core->GetTicks(); + // SetFramebufferLocation(FRAMEBUFFER_LOCATION_FCRAM); SetFramebufferLocation(FRAMEBUFFER_LOCATION_VRAM); -- cgit v1.2.3 From 4e9f305ed214ef0fbffd83042c86f41cd233ec3b Mon Sep 17 00:00:00 2001 From: bunnei Date: Tue, 22 Jul 2014 23:26:28 -0400 Subject: GSP: Removed dumb GX prefixes to functions/structs in GSP namespace. - Various other cleanups. --- src/core/hw/gpu.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/core/hw/gpu.cpp') diff --git a/src/core/hw/gpu.cpp b/src/core/hw/gpu.cpp index 41976d989..93b871470 100644 --- a/src/core/hw/gpu.cpp +++ b/src/core/hw/gpu.cpp @@ -256,7 +256,7 @@ void Update() { // Synchronize line... if ((current_ticks - g_last_ticks) >= GPU::kFrameTicks / 400) { - GSP_GPU::SignalInterrupt(GSP_GPU::GXInterruptId::PDC0); + GSP_GPU::SignalInterrupt(GSP_GPU::InterruptId::PDC0); g_cur_line++; g_last_ticks = current_ticks; } @@ -264,7 +264,7 @@ void Update() { // Synchronize frame... if (g_cur_line >= 400) { g_cur_line = 0; - GSP_GPU::SignalInterrupt(GSP_GPU::GXInterruptId::PDC1); + GSP_GPU::SignalInterrupt(GSP_GPU::InterruptId::PDC1); VideoCore::g_renderer->SwapBuffers(); Kernel::WaitCurrentThread(WAITTYPE_VBLANK); HLE::Reschedule(__func__); -- cgit v1.2.3 From 7ada2625fe78b7bb75232282ead77786ca215d6e Mon Sep 17 00:00:00 2001 From: bunnei Date: Tue, 5 Aug 2014 23:29:38 -0400 Subject: GPU: Updated horizontal sync line counter to use framebuffer height. --- src/core/hw/gpu.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'src/core/hw/gpu.cpp') diff --git a/src/core/hw/gpu.cpp b/src/core/hw/gpu.cpp index 93b871470..7fb208e57 100644 --- a/src/core/hw/gpu.cpp +++ b/src/core/hw/gpu.cpp @@ -252,17 +252,18 @@ template void Write(u32 addr, const u8 data); /// Update hardware void Update() { + auto& framebuffer_top = g_regs.Get(); u64 current_ticks = Core::g_app_core->GetTicks(); // Synchronize line... - if ((current_ticks - g_last_ticks) >= GPU::kFrameTicks / 400) { + if ((current_ticks - g_last_ticks) >= GPU::kFrameTicks / framebuffer_top.height) { GSP_GPU::SignalInterrupt(GSP_GPU::InterruptId::PDC0); g_cur_line++; g_last_ticks = current_ticks; } // Synchronize frame... - if (g_cur_line >= 400) { + if (g_cur_line >= framebuffer_top.height) { g_cur_line = 0; GSP_GPU::SignalInterrupt(GSP_GPU::InterruptId::PDC1); VideoCore::g_renderer->SwapBuffers(); -- cgit v1.2.3 From 0805ecbaca70159ccc3d43c643b4ade7168795bc Mon Sep 17 00:00:00 2001 From: bunnei Date: Tue, 5 Aug 2014 23:33:26 -0400 Subject: GPU: Updated g_last_ticks variable to be more descriptive (represents CPU tick count of last vertical line). --- src/core/hw/gpu.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'src/core/hw/gpu.cpp') diff --git a/src/core/hw/gpu.cpp b/src/core/hw/gpu.cpp index 7fb208e57..d94c2329b 100644 --- a/src/core/hw/gpu.cpp +++ b/src/core/hw/gpu.cpp @@ -21,8 +21,8 @@ namespace GPU { RegisterSet g_regs; -u32 g_cur_line = 0; ///< Current vertical screen line -u64 g_last_ticks = 0; ///< Last CPU ticks +u32 g_cur_line = 0; ///< Current vertical screen line +u64 g_last_line_ticks = 0; ///< CPU tick count from last vertical screen line /** * Sets whether the framebuffers are in the GSP heap (FCRAM) or VRAM @@ -256,10 +256,10 @@ void Update() { u64 current_ticks = Core::g_app_core->GetTicks(); // Synchronize line... - if ((current_ticks - g_last_ticks) >= GPU::kFrameTicks / framebuffer_top.height) { + if ((current_ticks - g_last_line_ticks) >= GPU::kFrameTicks / framebuffer_top.height) { GSP_GPU::SignalInterrupt(GSP_GPU::InterruptId::PDC0); g_cur_line++; - g_last_ticks = current_ticks; + g_last_line_ticks = current_ticks; } // Synchronize frame... @@ -275,7 +275,7 @@ void Update() { /// Initialize hardware void Init() { g_cur_line = 0; - g_last_ticks = Core::g_app_core->GetTicks(); + g_last_line_ticks = Core::g_app_core->GetTicks(); // SetFramebufferLocation(FRAMEBUFFER_LOCATION_FCRAM); SetFramebufferLocation(FRAMEBUFFER_LOCATION_VRAM); -- cgit v1.2.3