VERY experimental Nintendo Switch 2 emulator
C++
Merge branch 'threading' of https://github.com/bunnei/citra
bunnei004df767953a
diff --cc src/core/CMakeLists.txtindex 1c1a2eeb39,7236033c4e..7116b88e90--- a/src/core/CMakeLists.txt+++ b/src/core/CMakeLists.txt@@@ -40,56 -41,11 +41,57 @@@ set(SRCS core.cphle/service/apt.cpphle/service/gsp.cpphle/service/hid.cpp+ hle/service/ndm.cpphle/service/service.cpphle/service/srv.cpp+ hw/gpu.cpphw/hw.cpp- hw/lcd.cpphw/ndma.cpp)-add_library(core STATIC ${SRCS})+set(HEADERS core.h+ core_timing.h+ loader.h+ mem_map.h+ system.h+ arm/disassembler/arm_disasm.h+ arm/disassembler/load_symbol_map.h+ arm/interpreter/arm_interpreter.h+ arm/interpreter/arm_regformat.h+ arm/interpreter/armcpu.h+ arm/interpreter/armdefs.h+ arm/interpreter/armemu.h+ arm/interpreter/armmmu.h+ arm/interpreter/armos.h+ arm/interpreter/skyeye_defs.h+ arm/interpreter/mmu/arm1176jzf_s_mmu.h+ arm/interpreter/mmu/cache.h+ arm/interpreter/mmu/rb.h+ arm/interpreter/mmu/sa_mmu.h+ arm/interpreter/mmu/tlb.h+ arm/interpreter/mmu/wb.h+ arm/interpreter/vfp/asm_vfp.h+ arm/interpreter/vfp/vfp.h+ arm/interpreter/vfp/vfp_helper.h+ elf/elf_reader.h+ elf/elf_types.h+ file_sys/directory_file_system.h+ file_sys/file_sys.h+ file_sys/meta_file_system.h+ hle/config_mem.h+ hle/coprocessor.h+ hle/hle.h+ hle/svc.h+ hle/kernel/kernel.h+ hle/kernel/mutex.h+ hle/kernel/thread.h+ hle/function_wrappers.h+ hle/service/apt.h+ hle/service/gsp.h+ hle/service/hid.h+ hle/service/service.h+ hle/service/srv.h+ hw/gpu.h+ hw/hw.h+ hw/ndma.h)++add_library(core STATIC ${SRCS} ${HEADERS})diff --cc src/core/core.cppindex f88bcd704e,d366498a52..7dc0809d05--- a/src/core/core.cpp+++ b/src/core/core.cpp@@@ -9,6 -9,7 +9,7 @@@#include "core/core.h"#include "core/mem_map.h"#include "core/hw/hw.h"-#include "core/hw/lcd.h"++#include "core/hw/gpu.h"#include "core/arm/disassembler/arm_disasm.h"#include "core/arm/interpreter/arm_interpreter.h"@@@ -23,7 -26,7 +26,7 @@@ ARM_Interface* g_sys_core = nullp/// Run the core CPU loopvoid RunLoop() {for (;;){- g_app_core->Run(100);- g_app_core->Run(LCD::kFrameTicks);++ g_app_core->Run(GPU::kFrameTicks);HW::Update();Kernel::Reschedule();}@@@ -32,8 -35,14 +35,14 @@@/// Step the CPU one instructionvoid SingleStep() {g_app_core->Step();- HW::Update();- Kernel::Reschedule();++ // Update and reschedule after approx. 1 frame+ u64 current_ticks = Core::g_app_core->GetTicks();- if ((current_ticks - g_last_ticks) >= LCD::kFrameTicks || HLE::g_reschedule) {++ if ((current_ticks - g_last_ticks) >= GPU::kFrameTicks || HLE::g_reschedule) {+ g_last_ticks = current_ticks;+ HW::Update();+ Kernel::Reschedule();+ }}/// Halt the corediff --cc src/core/hle/service/gsp.cppindex aabcb48db8,f31e7d86dc..f75ba75c28--- a/src/core/hle/service/gsp.cpp+++ b/src/core/hle/service/gsp.cpp@@@ -8,11 -8,10 +8,12 @@@#include "core/mem_map.h"#include "core/hle/hle.h"+ #include "core/hle/kernel/event.h"#include "core/hle/service/gsp.h"-#include "core/hw/lcd.h"+#include "core/hw/gpu.h"++#include "video_core/gpu_debugger.h"////////////////////////////////////////////////////////////////////////////////////////////////////@@@ -60,8 -53,13 +61,9 @@@ void GX_FinishCommand(u32 thread_id)namespace GSP_GPU {+ Handle g_event_handle = 0;u32 g_thread_id = 0;-enum {- CMD_GX_REQUEST_DMA = 0x00000000,-};-enum {REG_FRAMEBUFFER_1 = 0x00400468,REG_FRAMEBUFFER_2 = 0x00400494,@@@ -122,37 -131,10 +136,37 @@@ void TriggerCmdReqQueue(Service::Interfmemcpy(Memory::GetPointer(cmd_buff[2]), Memory::GetPointer(cmd_buff[1]), cmd_buff[3]);break;+ case GXCommandId::SET_COMMAND_LIST_LAST:+ GPU::Write<u32>(GPU::Registers::CommandListAddress, cmd_buff[1] >> 3);+ GPU::Write<u32>(GPU::Registers::CommandListSize, cmd_buff[2] >> 3);+ GPU::Write<u32>(GPU::Registers::ProcessCommandList, 1); // TODO: Not sure if we are supposed to always write this++ // TODO: Move this to GPU+ // TODO: Not sure what units the size is measured in+ g_debugger.CommandListCalled(cmd_buff[1], (u32*)Memory::GetPointer(cmd_buff[1]), cmd_buff[2]);+ break;++ case GXCommandId::SET_MEMORY_FILL:+ break;++ case GXCommandId::SET_DISPLAY_TRANSFER:+ break;++ case GXCommandId::SET_TEXTURE_COPY:+ break;++ case GXCommandId::SET_COMMAND_LIST_FIRST:+ {+ //u32* buf0_data = (u32*)Memory::GetPointer(cmd_buff[1]);+ //u32* buf1_data = (u32*)Memory::GetPointer(cmd_buff[3]);+ //u32* buf2_data = (u32*)Memory::GetPointer(cmd_buff[5]);+ break;+ }+default:- ERROR_LOG(GSP, "TriggerCmdReqQueue unknown command 0x%08X", cmd_buff[0]);+ ERROR_LOG(GSP, "unknown command 0x%08X", cmd_buff[0]);}-+GX_FinishCommand(g_thread_id);}diff --cc src/core/hw/gpu.hindex f26f25e988,7484f8f667..3314ba9892--- a/src/core/hw/gpu.h+++ b/src/core/hw/gpu.h@@@ -6,24 -6,12 +6,27 @@@#include "common/common_types.h"-namespace LCD {+namespace GPU {+ static const u32 kFrameCycles = 268123480 / 60; ///< 268MHz / 60 frames per second+ static const u32 kFrameTicks = kFrameCycles / 3; ///< Approximate number of instructions/frame+struct Registers {+ enum Id : u32 {+ FramebufferTopLeft1 = 0x1EF00468, // Main LCD, first framebuffer for 3D left+ FramebufferTopLeft2 = 0x1EF0046C, // Main LCD, second framebuffer for 3D left+ FramebufferTopRight1 = 0x1EF00494, // Main LCD, first framebuffer for 3D right+ FramebufferTopRight2 = 0x1EF00498, // Main LCD, second framebuffer for 3D right+ FramebufferSubLeft1 = 0x1EF00568, // Sub LCD, first framebuffer+ FramebufferSubLeft2 = 0x1EF0056C, // Sub LCD, second framebuffer+ FramebufferSubRight1 = 0x1EF00594, // Sub LCD, unused first framebuffer+ FramebufferSubRight2 = 0x1EF00598, // Sub LCD, unused second framebuffer++ CommandListSize = 0x1EF018E0,+ CommandListAddress = 0x1EF018E8,+ ProcessCommandList = 0x1EF018F0,+ };+u32 framebuffer_top_left_1;u32 framebuffer_top_left_2;u32 framebuffer_top_right_1;