diff --git a/CMakeLists.txt b/CMakeLists.txt index 169cedcf..c6dd4c53 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -47,7 +47,7 @@ add_subdirectory(third_party/cryptopp) if (CMAKE_SYSTEM_PROCESSOR STREQUAL "AMD64" OR CMAKE_SYSTEM_PROCESSOR STREQUAL "x86-64" OR CMAKE_SYSTEM_PROCESSOR STREQUAL "x86_64") set(HOST_X64 TRUE) add_subdirectory(third_party/xbyak) # Add xbyak submodule for x86 JITs - include_directories(third_party/xbyak/xbyak) + include_directories(third_party/xbyak) add_compile_definitions(PANDA3DS_DYNAPICA_SUPPORTED) add_compile_definitions(PANDA3DS_X64_HOST) else() @@ -119,6 +119,7 @@ set(HEADER_FILES include/emulator.hpp include/helpers.hpp include/opengl.hpp inc include/renderer_gl/textures.hpp include/colour.hpp include/services/y2r.hpp include/services/cam.hpp include/services/ldr_ro.hpp include/ipc.hpp include/services/act.hpp include/services/nfc.hpp include/system_models.hpp include/services/dlp_srvr.hpp include/PICA/dynapica/pica_recs.hpp + include/PICA/dynapica/x64_regs.hpp include/PICA/dynapica/vertex_loader_rec.hpp ) set(THIRD_PARTY_SOURCE_FILES third_party/imgui/imgui.cpp diff --git a/include/PICA/dynapica/pica_recs.hpp b/include/PICA/dynapica/pica_recs.hpp index 89daae3a..acfd226e 100644 --- a/include/PICA/dynapica/pica_recs.hpp +++ b/include/PICA/dynapica/pica_recs.hpp @@ -1,6 +1,13 @@ #pragma once #include "helpers.hpp" +#include "vertex_loader_rec.hpp" + +// Common file for our PICA JITs (From vertex config -> CPU assembly and from PICA shader -> CPU assembly) namespace Dynapica { - +#ifdef PANDA3DS_DYNAPICA_SUPPORTED + static constexpr bool supported() { return true; } +#else + static constexpr bool supported() { return false; } +#endif } \ No newline at end of file diff --git a/include/PICA/dynapica/vertex_loader_rec.hpp b/include/PICA/dynapica/vertex_loader_rec.hpp new file mode 100644 index 00000000..e69de29b diff --git a/include/PICA/dynapica/x64_regs.hpp b/include/PICA/dynapica/x64_regs.hpp new file mode 100644 index 00000000..47bcec7d --- /dev/null +++ b/include/PICA/dynapica/x64_regs.hpp @@ -0,0 +1,39 @@ +#pragma once + +#ifdef PANDA3DS_X64_HOST +#include "xbyak/xbyak.h" +using namespace Xbyak; +using namespace Xbyak::util; + +#if defined(WIN32) || defined(_WIN32) || defined(__WIN32) && !defined(__CYGWIN__) +constexpr Reg32 arg1 = ecx; // register where first arg is stored +constexpr Reg32 arg2 = edx; // register where second arg is stored +constexpr Reg32 arg3 = r8d; // register where third arg is stored +constexpr Reg32 arg4 = r9d; // register where fourth arg is stored + +// Similar for floating point and vector arguemnts. +constexpr Xmm arg1f = xmm0; +constexpr Xmm arg2f = xmm1; +constexpr Xmm arg3f = xmm2; +constexpr Xmm arg4f = xmm3; + +constexpr bool isWindows() { return true; } + +#else // System V calling convention +constexpr Reg32 arg1 = edi; +constexpr Reg32 arg2 = esi; +constexpr Reg32 arg3 = edx; +constexpr Reg32 arg4 = ecx; + +constexpr Xmm arg1f = xmm0; +constexpr Xmm arg2f = xmm1; +constexpr Xmm arg3f = xmm2; +constexpr Xmm arg4f = xmm3; +constexpr Xmm arg5f = xmm4; +constexpr Xmm arg6f = xmm5; +constexpr Xmm arg7f = xmm6; +constexpr Xmm arg8f = xmm7; + +constexpr bool isWindows() { return false; } +#endif +#endif // PANDA3DS_X64_HOST \ No newline at end of file