summaryrefslogtreecommitdiffstats
path: root/src/core/hw/gpu.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/core/hw/gpu.cpp')
-rw-r--r--src/core/hw/gpu.cpp24
1 files changed, 13 insertions, 11 deletions
diff --git a/src/core/hw/gpu.cpp b/src/core/hw/gpu.cpp
index e6983a225..8ef1f70df 100644
--- a/src/core/hw/gpu.cpp
+++ b/src/core/hw/gpu.cpp
@@ -8,7 +8,7 @@
#include "core/settings.h"
#include "core/core.h"
-#include "core/mem_map.h"
+#include "core/memory.h"
#include "core/core_timing.h"
#include "core/hle/hle.h"
@@ -29,8 +29,7 @@ namespace GPU {
Regs g_regs;
/// True if the current frame was skipped
-bool g_skip_frame = false;
-
+bool g_skip_frame;
/// 268MHz / gpu_refresh_rate frames per second
static u64 frame_ticks;
/// Event id for CoreTiming
@@ -38,7 +37,7 @@ static int vblank_event;
/// Total number of frames drawn
static u64 frame_count;
/// True if the last frame was skipped
-static bool last_skip_frame = false;
+static bool last_skip_frame;
template <typename T>
inline void Read(T &var, const u32 raw_addr) {
@@ -77,8 +76,8 @@ inline void Write(u32 addr, const T data) {
auto& config = g_regs.memory_fill_config[is_second_filler];
if (config.address_start && config.trigger) {
- u8* start = Memory::GetPointer(Memory::PhysicalToVirtualAddress(config.GetStartAddress()));
- u8* end = Memory::GetPointer(Memory::PhysicalToVirtualAddress(config.GetEndAddress()));
+ u8* start = Memory::GetPhysicalPointer(config.GetStartAddress());
+ u8* end = Memory::GetPhysicalPointer(config.GetEndAddress());
if (config.fill_24bit) {
// fill with 24-bit values
@@ -115,8 +114,8 @@ inline void Write(u32 addr, const T data) {
{
const auto& config = g_regs.display_transfer_config;
if (config.trigger & 1) {
- u8* src_pointer = Memory::GetPointer(Memory::PhysicalToVirtualAddress(config.GetPhysicalInputAddress()));
- u8* dst_pointer = Memory::GetPointer(Memory::PhysicalToVirtualAddress(config.GetPhysicalOutputAddress()));
+ u8* src_pointer = Memory::GetPhysicalPointer(config.GetPhysicalInputAddress());
+ u8* dst_pointer = Memory::GetPhysicalPointer(config.GetPhysicalOutputAddress());
if (config.scaling > config.ScaleXY) {
LOG_CRITICAL(HW_GPU, "Unimplemented display transfer scaling mode %u", config.scaling.Value());
@@ -136,7 +135,7 @@ inline void Write(u32 addr, const T data) {
memcpy(dst_pointer, src_pointer, config.output_width * config.output_height *
GPU::Regs::BytesPerPixel(config.output_format));
- LOG_TRACE(HW_GPU, "DisplayTriggerTransfer: 0x%08x bytes from 0x%08x(%ux%u)-> 0x%08x(%ux%u), flags 0x%08X, Raw copy",
+ LOG_TRACE(HW_GPU, "DisplayTriggerTransfer: 0x%08x bytes from 0x%08x(%ux%u)-> 0x%08x(%ux%u), output format: %x, flags 0x%08X, Raw copy",
config.output_height * output_width * GPU::Regs::BytesPerPixel(config.output_format),
config.GetPhysicalInputAddress(), config.input_width.Value(), config.input_height.Value(),
config.GetPhysicalOutputAddress(), config.output_width.Value(), config.output_height.Value(),
@@ -258,7 +257,7 @@ inline void Write(u32 addr, const T data) {
const auto& config = g_regs.command_processor_config;
if (config.trigger & 1)
{
- u32* buffer = (u32*)Memory::GetPointer(Memory::PhysicalToVirtualAddress(config.GetPhysicalAddress()));
+ u32* buffer = (u32*)Memory::GetPhysicalPointer(config.GetPhysicalAddress());
Pica::CommandProcessor::ProcessCommandList(buffer, config.size);
}
break;
@@ -312,7 +311,7 @@ static void VBlankCallback(u64 userdata, int cycles_late) {
DSP_DSP::SignalInterrupt();
// Check for user input updates
- Service::HID::HIDUpdate();
+ Service::HID::Update();
// Reschedule recurrent event
CoreTiming::ScheduleEvent(frame_ticks - cycles_late, vblank_event);
@@ -320,6 +319,8 @@ static void VBlankCallback(u64 userdata, int cycles_late) {
/// Initialize hardware
void Init() {
+ memset(&g_regs, 0, sizeof(g_regs));
+
auto& framebuffer_top = g_regs.framebuffer_config[0];
auto& framebuffer_sub = g_regs.framebuffer_config[1];
@@ -349,6 +350,7 @@ void Init() {
frame_ticks = 268123480 / Settings::values.gpu_refresh_rate;
last_skip_frame = false;
g_skip_frame = false;
+ frame_count = 0;
vblank_event = CoreTiming::RegisterEvent("GPU::VBlankCallback", VBlankCallback);
CoreTiming::ScheduleEvent(frame_ticks, vblank_event);