commit
13709121ac
|
@ -34,17 +34,24 @@ set(USERSERVICE_SOURCES src/Emulator/HLE/Libraries/LibUserService/user_service.c
|
|||
|
||||
set(PAD_SOURCES src/Emulator/HLE/Libraries/LibPad/pad.cpp
|
||||
src/Emulator/HLE/Libraries/LibPad/pad.h
|
||||
src/Emulator/HLE/Libraries/LibPad/controller.cpp
|
||||
src/Emulator/HLE/Libraries/LibPad/controller.h
|
||||
|
||||
)
|
||||
|
||||
set(SYSTEMSERVICE_SOURCES src/Emulator/HLE/Libraries/LibSystemService/system_service.cpp
|
||||
src/Emulator/HLE/Libraries/LibSystemService/system_service.h
|
||||
)
|
||||
|
||||
set(UTIL_SOURCES src/Emulator/Util/singleton.h
|
||||
)
|
||||
|
||||
add_executable(shadps4
|
||||
${LIBC_SOURCES}
|
||||
${USERSERVICE_SOURCES}
|
||||
${PAD_SOURCES}
|
||||
${SYSTEMSERVICE_SOURCES}
|
||||
${UTIL_SOURCES}
|
||||
src/main.cpp
|
||||
src/types.h
|
||||
src/Core/FsFile.cpp
|
||||
|
|
|
@ -78,7 +78,7 @@ bool FlipQueue::flip(u32 micros) {
|
|||
|
||||
auto* buffer = request.cfg->buffers[request.index].buffer_render;
|
||||
|
||||
Emulator::DrawBuffer(buffer);
|
||||
Emu::DrawBuffer(buffer);
|
||||
|
||||
m_mutex.LockMutex();
|
||||
|
||||
|
|
|
@ -64,7 +64,7 @@ class VideoOutCtx {
|
|||
Lib::LockMutexGuard lock(m_mutex);
|
||||
|
||||
if (m_graphic_ctx == nullptr) {
|
||||
m_graphic_ctx = Emulator::getGraphicCtx();
|
||||
m_graphic_ctx = Emu::getGraphicCtx();
|
||||
}
|
||||
|
||||
return m_graphic_ctx;
|
||||
|
|
|
@ -8,7 +8,7 @@ static thread_local GPU::CommandPool g_command_pool;
|
|||
void GPU::renderCreateCtx() {
|
||||
auto* render_ctx = Singleton<RenderCtx>::Instance();
|
||||
|
||||
render_ctx->setGraphicCtx(Emulator::getGraphicCtx());
|
||||
render_ctx->setGraphicCtx(Emu::getGraphicCtx());
|
||||
}
|
||||
|
||||
void GPU::CommandBuffer::allocateBuffer() {
|
||||
|
|
|
@ -164,7 +164,7 @@ s32 PS4_SYSV_ABI sceVideoOutRegisterBuffers(s32 handle, s32 startIndex, void* co
|
|||
|
||||
int registration_index = ctx->buffers_registration_index++;
|
||||
|
||||
Emulator::checkAndWaitForGraphicsInit();
|
||||
Emu::checkAndWaitForGraphicsInit();
|
||||
GPU::renderCreateCtx();
|
||||
|
||||
// try to calculate buffer size
|
||||
|
|
|
@ -91,7 +91,7 @@ namespace HLE::Libs::LibSceGnmDriver {
|
|||
void sceGnmDriverTriggerCapture(){}
|
||||
void sceGnmEndWorkload(){}
|
||||
void sceGnmFlushGarlic() { PRINT_FUNCTION_NAME();
|
||||
GPU::flushGarlic(Emulator::getGraphicCtx());
|
||||
GPU::flushGarlic(Emu::getGraphicCtx());
|
||||
}
|
||||
void sceGnmGetEqEventType(){}
|
||||
void sceGnmGetEqTimeStamp(){}
|
||||
|
|
|
@ -0,0 +1,51 @@
|
|||
#include "controller.h"
|
||||
|
||||
namespace Emulator::Host::Controller {
|
||||
GameController::GameController() { m_states_num = 0;
|
||||
m_last_state = State();
|
||||
}
|
||||
void GameController::readState(State* state, bool* isConnected, int* connectedCount) {
|
||||
Lib::LockMutexGuard lock(m_mutex);
|
||||
|
||||
*isConnected = m_connected;
|
||||
*connectedCount = m_connected_count;
|
||||
*state = getLastState();
|
||||
}
|
||||
|
||||
State GameController::getLastState() const {
|
||||
if (m_states_num == 0) {
|
||||
return m_last_state;
|
||||
}
|
||||
|
||||
auto last = (m_first_state + m_states_num - 1) % MAX_STATES;
|
||||
|
||||
return m_states[last];
|
||||
}
|
||||
|
||||
void GameController::addState(const State& state) {
|
||||
if (m_states_num >= MAX_STATES) {
|
||||
m_states_num = MAX_STATES - 1;
|
||||
m_first_state = (m_first_state + 1) % MAX_STATES;
|
||||
}
|
||||
|
||||
auto index = (m_first_state + m_states_num) % MAX_STATES;
|
||||
|
||||
m_states[index] = state;
|
||||
m_last_state = state;
|
||||
|
||||
m_states_num++;
|
||||
}
|
||||
|
||||
void GameController::checKButton(int id, u32 button, bool isPressed) {
|
||||
Lib::LockMutexGuard lock(m_mutex);
|
||||
auto state = getLastState();
|
||||
if (isPressed) {
|
||||
state.buttonsState |= button;
|
||||
} else {
|
||||
state.buttonsState &= ~button;
|
||||
}
|
||||
|
||||
addState(state);
|
||||
}
|
||||
|
||||
} // namespace Emulator::Host::Controller
|
|
@ -0,0 +1,33 @@
|
|||
#pragma once
|
||||
#include <types.h>
|
||||
#include "Lib/Threads.h"
|
||||
|
||||
namespace Emulator::Host::Controller {
|
||||
struct State {
|
||||
u32 buttonsState =0;
|
||||
};
|
||||
|
||||
constexpr u32 MAX_STATES = 64;
|
||||
|
||||
class GameController {
|
||||
public:
|
||||
GameController();
|
||||
virtual ~GameController() = default;
|
||||
|
||||
void readState(State* state, bool* isConnected, int* connectedCount);
|
||||
State getLastState() const;
|
||||
void checKButton(int id, u32 button, bool isPressed);
|
||||
void addState(const State& state);
|
||||
|
||||
|
||||
private:
|
||||
Lib::Mutex m_mutex;
|
||||
bool m_connected = false;
|
||||
State m_last_state;
|
||||
int m_connected_count = 0;
|
||||
u32 m_states_num = 0;
|
||||
u32 m_first_state = 0;
|
||||
State m_states[MAX_STATES];
|
||||
};
|
||||
|
||||
} // namespace Emulator::HLE::Libraries::Controller
|
|
@ -3,15 +3,46 @@
|
|||
#include <Core/PS4/HLE/ErrorCodes.h>
|
||||
#include <Core/PS4/HLE/Libs.h>
|
||||
|
||||
#include "Util/Singleton.h"
|
||||
#include "controller.h"
|
||||
#include <debug.h>
|
||||
#include <Util/log.h>
|
||||
|
||||
namespace Emulator::HLE::Libraries::LibPad {
|
||||
|
||||
constexpr bool log_file_pad = true; // disable it to disable logging
|
||||
|
||||
int PS4_SYSV_ABI scePadInit() { return SCE_OK; }
|
||||
|
||||
int PS4_SYSV_ABI scePadOpen(/* SceUserServiceUserId userId, int32_t type, int32_t index, const ScePadOpenParam* pParam*/) {
|
||||
int PS4_SYSV_ABI scePadOpen(Emulator::HLE::Libraries::LibUserService::SceUserServiceUserId userId, s32 type, s32 index,
|
||||
const ScePadOpenParam* pParam) {
|
||||
return 1; // dummy
|
||||
}
|
||||
|
||||
int PS4_SYSV_ABI scePadReadState(int32_t handle, ScePadData* pData) {
|
||||
pData->connected = true; // make it think it is connected
|
||||
auto* controller = Singleton<Emulator::Host::Controller::GameController>::Instance();
|
||||
|
||||
int connectedCount = 0;
|
||||
bool isConnected = false;
|
||||
Emulator::Host::Controller::State state;
|
||||
|
||||
controller->readState(&state, &isConnected, &connectedCount);
|
||||
pData->buttons = state.buttonsState;
|
||||
pData->leftStick.x = 128; // dummy
|
||||
pData->leftStick.y = 128; // dummy
|
||||
pData->rightStick.x = 0; // dummy
|
||||
pData->rightStick.y = 0; // dummy
|
||||
pData->analogButtons.r2 = 0;//dummy
|
||||
pData->analogButtons.l2 = 0;//dummy
|
||||
pData->orientation.x = 0;
|
||||
pData->orientation.y = 0;
|
||||
pData->orientation.z = 0;
|
||||
pData->orientation.w = 0;
|
||||
|
||||
pData->connected = true; // isConnected; //TODO fix me proper
|
||||
pData->connectedCount = 1;//connectedCount;
|
||||
pData->deviceUniqueDataLen = 0;
|
||||
|
||||
return SCE_OK;
|
||||
}
|
||||
|
||||
|
|
|
@ -1,51 +1,98 @@
|
|||
#pragma once
|
||||
#include <Emulator/HLE/Libraries/LibUserService/user_service.h>
|
||||
#include <types.h>
|
||||
|
||||
#include "Core/PS4/Loader/SymbolsResolver.h"
|
||||
|
||||
namespace Emulator::HLE::Libraries::LibPad {
|
||||
|
||||
typedef enum : u32 {
|
||||
SCE_PAD_BUTTON_L3 = 0x00000002,
|
||||
SCE_PAD_BUTTON_R3 = 0x00000004,
|
||||
SCE_PAD_BUTTON_OPTIONS = 0x00000008,
|
||||
SCE_PAD_BUTTON_UP = 0x00000010,
|
||||
SCE_PAD_BUTTON_RIGHT = 0x00000020,
|
||||
SCE_PAD_BUTTON_DOWN = 0x00000040,
|
||||
SCE_PAD_BUTTON_LEFT = 0x00000080,
|
||||
SCE_PAD_BUTTON_L2 = 0x00000100,
|
||||
SCE_PAD_BUTTON_R2 = 0x00000200,
|
||||
SCE_PAD_BUTTON_L1 = 0x00000400,
|
||||
SCE_PAD_BUTTON_R1 = 0x00000800,
|
||||
SCE_PAD_BUTTON_TRIANGLE = 0x00001000,
|
||||
SCE_PAD_BUTTON_CIRCLE = 0x00002000,
|
||||
SCE_PAD_BUTTON_CROSS = 0x00004000,
|
||||
SCE_PAD_BUTTON_SQUARE = 0x00008000,
|
||||
SCE_PAD_BUTTON_TOUCH_PAD = 0x00100000,
|
||||
SCE_PAD_BUTTON_INTERCEPTED = 0x80000000,
|
||||
} ScePadButton;
|
||||
|
||||
struct ScePadOpenParam {
|
||||
u08 reserve[8];
|
||||
};
|
||||
|
||||
struct ScePadAnalogStick {
|
||||
u08 x;
|
||||
u08 y;
|
||||
};
|
||||
struct ScePadAnalogButtons {
|
||||
u08 l2;
|
||||
u08 r2;
|
||||
u08 padding[2];
|
||||
};
|
||||
|
||||
struct SceFQuaternion {
|
||||
float x, y, z, w;
|
||||
};
|
||||
|
||||
struct SceFVector3 {
|
||||
float x, y, z;
|
||||
};
|
||||
|
||||
struct ScePadTouch {
|
||||
u16 x;
|
||||
u16 y;
|
||||
u08 id;
|
||||
u08 reserve[3];
|
||||
};
|
||||
|
||||
constexpr int SCE_PAD_MAX_TOUCH_NUM = 2;
|
||||
|
||||
typedef struct ScePadTouchData {
|
||||
u08 touchNum;
|
||||
u08 reserve[3];
|
||||
u32 reserve1;
|
||||
ScePadTouch touch[SCE_PAD_MAX_TOUCH_NUM];
|
||||
} ScePadTouchData;
|
||||
|
||||
struct ScePadExtensionUnitData {
|
||||
u32 extensionUnitId;
|
||||
u08 reserve[1];
|
||||
u08 dataLength;
|
||||
u08 data[10];
|
||||
};
|
||||
|
||||
struct ScePadData {
|
||||
u32 buttons;
|
||||
u08 left_stick_x;
|
||||
u08 left_stick_y;
|
||||
u08 right_stick_x;
|
||||
u08 right_stick_y;
|
||||
u08 analog_buttons_l2;
|
||||
u08 analog_buttons_r2;
|
||||
u08 padding[2];
|
||||
float orientation_x;
|
||||
float orientation_y;
|
||||
float orientation_z;
|
||||
float orientation_w;
|
||||
float acceleration_x;
|
||||
float acceleration_y;
|
||||
float acceleration_z;
|
||||
float angular_velocity_x;
|
||||
float angular_velocity_y;
|
||||
float angular_velocity_z;
|
||||
u08 touch_data_touch_num;
|
||||
u08 touch_data_reserve[3];
|
||||
u32 touch_data_reserve1;
|
||||
u16 touch_data_touch0_x;
|
||||
u16 touch_data_touch0_y;
|
||||
u08 touch_data_touch0_id;
|
||||
u08 touch_data_touch0_reserve[3];
|
||||
u16 touch_data_touch1_x;
|
||||
u16 touch_data_touch1_y;
|
||||
u08 touch_data_touch1_id;
|
||||
u08 touch_data_touch1_reserve[3];
|
||||
ScePadAnalogStick leftStick;
|
||||
ScePadAnalogStick rightStick;
|
||||
ScePadAnalogButtons analogButtons;
|
||||
SceFQuaternion orientation;
|
||||
SceFVector3 acceleration;
|
||||
SceFVector3 angularVelocity;
|
||||
ScePadTouchData touchData;
|
||||
bool connected;
|
||||
u64 timestamp;
|
||||
u32 extension_unit_data_extension_unit_id;
|
||||
u08 extension_unit_data_reserve[1];
|
||||
u08 extension_unit_data_data_length;
|
||||
u08 extension_unit_data_data[10];
|
||||
u08 connected_count;
|
||||
u08 reserve[2];
|
||||
u08 device_unique_data_len;
|
||||
u08 device_unique_data[12];
|
||||
ScePadExtensionUnitData extensionUnitData;
|
||||
uint8_t connectedCount;
|
||||
uint8_t reserve[2];
|
||||
uint8_t deviceUniqueDataLen;
|
||||
uint8_t deviceUniqueData[12];
|
||||
};
|
||||
// hle functions
|
||||
int PS4_SYSV_ABI scePadInit();
|
||||
int PS4_SYSV_ABI scePadOpen(Emulator::HLE::Libraries::LibUserService::SceUserServiceUserId userId, s32 type, s32 index,
|
||||
const ScePadOpenParam* pParam);
|
||||
int PS4_SYSV_ABI scePadReadState(int32_t handle, ScePadData* pData);
|
||||
|
||||
void libPad_Register(SymbolsResolver* sym);
|
||||
}; // namespace Emulator::HLE::Libraries::LibPad
|
|
@ -3,6 +3,8 @@
|
|||
|
||||
namespace Emulator::HLE::Libraries::LibUserService {
|
||||
|
||||
using SceUserServiceUserId = s32;
|
||||
|
||||
struct SceUserServiceInitializeParams {
|
||||
s32 priority;
|
||||
};
|
||||
|
|
|
@ -0,0 +1,24 @@
|
|||
#pragma once
|
||||
|
||||
#include <cstdlib>
|
||||
#include <new>
|
||||
|
||||
template <class T>
|
||||
class singleton {
|
||||
public:
|
||||
static T* instance() {
|
||||
if (!m_instance) {
|
||||
m_instance = static_cast<T*>(std::malloc(sizeof(T)));
|
||||
new (m_instance) T;
|
||||
}
|
||||
|
||||
return m_instance;
|
||||
}
|
||||
|
||||
protected:
|
||||
singleton();
|
||||
~singleton();
|
||||
|
||||
private:
|
||||
static inline T* m_instance = nullptr;
|
||||
};
|
|
@ -1,25 +1,27 @@
|
|||
#include "emulator.h"
|
||||
|
||||
#include <Core/PS4/HLE/Graphics/graphics_render.h>
|
||||
#include <Emulator/HLE/Libraries/LibPad/controller.h>
|
||||
#include <Util/Singleton.h>
|
||||
#include <vulkan_util.h>
|
||||
|
||||
#include "Core/PS4/HLE/Graphics/video_out.h"
|
||||
#include "Emulator/HLE/Libraries/LibPad/pad.h"
|
||||
#include "version.h"
|
||||
|
||||
namespace Emulator {
|
||||
namespace Emu {
|
||||
|
||||
bool m_emu_needs_exit = false;
|
||||
|
||||
void emuInit(u32 width, u32 height) {
|
||||
auto* window_ctx = Singleton<Emulator::WindowCtx>::Instance();
|
||||
auto* window_ctx = Singleton<Emu::WindowCtx>::Instance();
|
||||
|
||||
window_ctx->m_graphic_ctx.screen_width = width;
|
||||
window_ctx->m_graphic_ctx.screen_height = height;
|
||||
}
|
||||
|
||||
void checkAndWaitForGraphicsInit() {
|
||||
auto* window_ctx = Singleton<Emulator::WindowCtx>::Instance();
|
||||
auto* window_ctx = Singleton<Emu::WindowCtx>::Instance();
|
||||
Lib::LockMutexGuard lock(window_ctx->m_mutex);
|
||||
|
||||
while (!window_ctx->m_is_graphic_initialized) {
|
||||
|
@ -48,7 +50,7 @@ static void CreateSdlWindow(WindowCtx* ctx) {
|
|||
SDL_SetWindowResizable(ctx->m_window, SDL_FALSE); // we don't support resizable atm
|
||||
}
|
||||
void emuRun() {
|
||||
auto* window_ctx = Singleton<Emulator::WindowCtx>::Instance();
|
||||
auto* window_ctx = Singleton<Emu::WindowCtx>::Instance();
|
||||
window_ctx->m_mutex.LockMutex();
|
||||
{
|
||||
// init window and wait until init finishes
|
||||
|
@ -82,7 +84,7 @@ void emuRun() {
|
|||
case SDL_EVENT_DID_ENTER_FOREGROUND: break;
|
||||
|
||||
case SDL_EVENT_KEY_DOWN:
|
||||
case SDL_EVENT_KEY_UP: break;
|
||||
case SDL_EVENT_KEY_UP: keyboardEvent(&event); break;
|
||||
}
|
||||
continue;
|
||||
}
|
||||
|
@ -96,14 +98,14 @@ void emuRun() {
|
|||
}
|
||||
|
||||
HLE::Libs::Graphics::GraphicCtx* getGraphicCtx() {
|
||||
auto* window_ctx = Singleton<Emulator::WindowCtx>::Instance();
|
||||
auto* window_ctx = Singleton<Emu::WindowCtx>::Instance();
|
||||
Lib::LockMutexGuard lock(window_ctx->m_mutex);
|
||||
|
||||
return &window_ctx->m_graphic_ctx;
|
||||
}
|
||||
|
||||
void DrawBuffer(HLE::Libs::Graphics::VideoOutVulkanImage* image) {
|
||||
auto* window_ctx = Singleton<Emulator::WindowCtx>::Instance();
|
||||
auto* window_ctx = Singleton<Emu::WindowCtx>::Instance();
|
||||
if (window_ctx->is_window_hidden) {
|
||||
SDL_ShowWindow(window_ctx->m_window);
|
||||
window_ctx->is_window_hidden = false;
|
||||
|
@ -198,4 +200,29 @@ void DrawBuffer(HLE::Libs::Graphics::VideoOutVulkanImage* image) {
|
|||
}
|
||||
}
|
||||
|
||||
} // namespace Emulator
|
||||
void keyboardEvent(SDL_Event* event) {
|
||||
using Emulator::HLE::Libraries::LibPad::ScePadButton;
|
||||
|
||||
if (event->type == SDL_EVENT_KEY_DOWN || event->type == SDL_EVENT_KEY_UP) {
|
||||
u32 button = 0;
|
||||
switch (event->key.keysym.sym) {
|
||||
case SDLK_UP: button = ScePadButton::SCE_PAD_BUTTON_UP; break;
|
||||
case SDLK_DOWN: button = ScePadButton::SCE_PAD_BUTTON_DOWN; break;
|
||||
case SDLK_LEFT: button = ScePadButton::SCE_PAD_BUTTON_LEFT; break;
|
||||
case SDLK_RIGHT: button = ScePadButton::SCE_PAD_BUTTON_RIGHT; break;
|
||||
case SDLK_KP_8: button = ScePadButton ::SCE_PAD_BUTTON_TRIANGLE; break;
|
||||
case SDLK_KP_6: button = ScePadButton ::SCE_PAD_BUTTON_CIRCLE; break;
|
||||
case SDLK_KP_2: button = ScePadButton ::SCE_PAD_BUTTON_CROSS; break;
|
||||
case SDLK_KP_4: button = ScePadButton ::SCE_PAD_BUTTON_SQUARE; break;
|
||||
case SDLK_RETURN: button = ScePadButton ::SCE_PAD_BUTTON_OPTIONS; break;
|
||||
|
||||
default: break;
|
||||
}
|
||||
if (button != 0) {
|
||||
auto* controller = Singleton<Emulator::Host::Controller::GameController>::Instance();
|
||||
controller->checKButton(0, button, event->type == SDL_EVENT_KEY_DOWN);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace Emu
|
|
@ -5,7 +5,7 @@
|
|||
|
||||
#include <vector>
|
||||
|
||||
namespace Emulator {
|
||||
namespace Emu {
|
||||
|
||||
struct VulkanExt {
|
||||
bool enable_validation_layers = false;
|
||||
|
@ -81,4 +81,5 @@ void emuRun();
|
|||
void checkAndWaitForGraphicsInit();
|
||||
HLE::Libs::Graphics::GraphicCtx* getGraphicCtx();
|
||||
void DrawBuffer(HLE::Libs::Graphics::VideoOutVulkanImage* image);
|
||||
void keyboardEvent(SDL_Event* event);
|
||||
} // namespace Emulator
|
45
src/main.cpp
45
src/main.cpp
|
@ -3,41 +3,43 @@
|
|||
// If you are new to Dear ImGui, read documentation from the docs/ folder + read the top of imgui.cpp.
|
||||
// Read online: https://github.com/ocornut/imgui/tree/master/docs
|
||||
|
||||
#include "imgui.h"
|
||||
#include "imgui_impl_sdl3.h"
|
||||
#include "imgui_impl_opengl3.h"
|
||||
#include <stdio.h>
|
||||
#include <SDL3/SDL.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#include "imgui.h"
|
||||
#include "imgui_impl_opengl3.h"
|
||||
#include "imgui_impl_sdl3.h"
|
||||
#if defined(IMGUI_IMPL_OPENGL_ES2)
|
||||
#include <SDL3/SDL_opengles2.h>
|
||||
#else
|
||||
#include <SDL3/SDL_opengl.h>
|
||||
#endif
|
||||
|
||||
#include <Util/log.h>
|
||||
|
||||
#include "GUI/ElfViewer.h"
|
||||
#include "spdlog/spdlog.h"
|
||||
#include "types.h"
|
||||
#include "GUI/ElfViewer.h"
|
||||
#include <Util/log.h>
|
||||
|
||||
// This example can also compile and run with Emscripten! See 'Makefile.emscripten' for details.
|
||||
#ifdef __EMSCRIPTEN__
|
||||
#include "../libs/emscripten/emscripten_mainloop_stub.h"
|
||||
#endif
|
||||
#include "Core/PS4/Linker.h"
|
||||
#include "Util/Singleton.h"
|
||||
#include <stdio.h>
|
||||
#include <inttypes.h>
|
||||
#include <Zydis/Zydis.h>
|
||||
#include "Core/PS4/HLE/Libs.h"
|
||||
#include "Lib/Threads.h"
|
||||
#include <emulator.h>
|
||||
#include "discord.h"
|
||||
#include <Util/config.h>
|
||||
#include <Core/PS4/HLE/Graphics/video_out.h>
|
||||
#include <Util/config.h>
|
||||
#include <Zydis/Zydis.h>
|
||||
#include <emulator.h>
|
||||
#include <inttypes.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#include "Core/PS4/HLE/Libs.h"
|
||||
#include "Core/PS4/Linker.h"
|
||||
#include "Lib/Threads.h"
|
||||
#include "Util/Singleton.h"
|
||||
#include "discord.h"
|
||||
|
||||
// Main code
|
||||
int main(int argc, char* argv[])
|
||||
{
|
||||
int main(int argc, char* argv[]) {
|
||||
if (argc == 1) {
|
||||
printf("Usage: %s <elf or eboot.bin path>\n", argv[0]);
|
||||
return -1;
|
||||
|
@ -46,7 +48,7 @@ int main(int argc, char* argv[])
|
|||
logging::init(true); // init logging
|
||||
auto width = Config::getScreenWidth();
|
||||
auto height = Config::getScreenHeight();
|
||||
Emulator::emuInit(width, height);
|
||||
Emu::emuInit(width, height);
|
||||
HLE::Libs::Graphics::VideoOut::videoOutInit(width, height);
|
||||
Lib::InitThreads();
|
||||
|
||||
|
@ -65,12 +67,9 @@ int main(int argc, char* argv[])
|
|||
Discord::RPC discordRPC;
|
||||
discordRPC.init();
|
||||
discordRPC.update(Discord::RPCStatus::Idling, "");
|
||||
Emulator::emuRun();
|
||||
Emu::emuRun();
|
||||
mainthread.JoinThread();
|
||||
|
||||
|
||||
|
||||
|
||||
#if 0
|
||||
// Setup SDL
|
||||
if (SDL_Init(SDL_INIT_VIDEO | SDL_INIT_TIMER | SDL_INIT_GAMEPAD) != 0)
|
||||
|
|
|
@ -12,8 +12,8 @@
|
|||
|
||||
constexpr bool log_file_vulkanutil = true; // disable it to disable logging
|
||||
|
||||
void Graphics::Vulkan::vulkanCreate(Emulator::WindowCtx* ctx) {
|
||||
Emulator::VulkanExt ext;
|
||||
void Graphics::Vulkan::vulkanCreate(Emu::WindowCtx* ctx) {
|
||||
Emu::VulkanExt ext;
|
||||
vulkanGetInstanceExtensions(&ext);
|
||||
|
||||
VkApplicationInfo app_info{};
|
||||
|
@ -53,8 +53,8 @@ void Graphics::Vulkan::vulkanCreate(Emulator::WindowCtx* ctx) {
|
|||
std::vector<const char*> device_extensions = {VK_KHR_SWAPCHAIN_EXTENSION_NAME, VK_EXT_DEPTH_CLIP_ENABLE_EXTENSION_NAME,
|
||||
VK_EXT_COLOR_WRITE_ENABLE_EXTENSION_NAME, "VK_KHR_maintenance1"};
|
||||
|
||||
ctx->m_surface_capabilities = new Emulator::VulkanSurfaceCapabilities{};
|
||||
Emulator::VulkanQueues queues;
|
||||
ctx->m_surface_capabilities = new Emu::VulkanSurfaceCapabilities{};
|
||||
Emu::VulkanQueues queues;
|
||||
|
||||
vulkanFindCompatiblePhysicalDevice(ctx->m_graphic_ctx.m_instance, ctx->m_surface, device_extensions, ctx->m_surface_capabilities,
|
||||
&ctx->m_graphic_ctx.m_physical_device, &queues);
|
||||
|
@ -79,11 +79,11 @@ void Graphics::Vulkan::vulkanCreate(Emulator::WindowCtx* ctx) {
|
|||
ctx->swapchain = vulkanCreateSwapchain(&ctx->m_graphic_ctx, 2);
|
||||
}
|
||||
|
||||
Emulator::VulkanSwapchain* Graphics::Vulkan::vulkanCreateSwapchain(HLE::Libs::Graphics::GraphicCtx* ctx, u32 image_count) {
|
||||
auto* window_ctx = Singleton<Emulator::WindowCtx>::Instance();
|
||||
Emu::VulkanSwapchain* Graphics::Vulkan::vulkanCreateSwapchain(HLE::Libs::Graphics::GraphicCtx* ctx, u32 image_count) {
|
||||
auto* window_ctx = Singleton<Emu::WindowCtx>::Instance();
|
||||
Lib::LockMutexGuard lock(window_ctx->m_mutex);
|
||||
|
||||
auto* s = new Emulator::VulkanSwapchain;
|
||||
auto* s = new Emu::VulkanSwapchain;
|
||||
|
||||
VkExtent2D extent{};
|
||||
extent.width = clamp(ctx->screen_width, window_ctx->m_surface_capabilities->capabilities.minImageExtent.width,
|
||||
|
@ -183,8 +183,8 @@ Emulator::VulkanSwapchain* Graphics::Vulkan::vulkanCreateSwapchain(HLE::Libs::Gr
|
|||
return s;
|
||||
}
|
||||
|
||||
void Graphics::Vulkan::vulkanCreateQueues(HLE::Libs::Graphics::GraphicCtx* ctx, const Emulator::VulkanQueues& queues) {
|
||||
auto get_queue = [ctx](int id, const Emulator::VulkanQueueInfo& info, bool with_mutex = false) {
|
||||
void Graphics::Vulkan::vulkanCreateQueues(HLE::Libs::Graphics::GraphicCtx* ctx, const Emu::VulkanQueues& queues) {
|
||||
auto get_queue = [ctx](int id, const Emu::VulkanQueueInfo& info, bool with_mutex = false) {
|
||||
ctx->queues[id].family = info.family;
|
||||
ctx->queues[id].index = info.index;
|
||||
vkGetDeviceQueue(ctx->m_device, ctx->queues[id].family, ctx->queues[id].index, &ctx->queues[id].vk_queue);
|
||||
|
@ -203,8 +203,8 @@ void Graphics::Vulkan::vulkanCreateQueues(HLE::Libs::Graphics::GraphicCtx* ctx,
|
|||
}
|
||||
}
|
||||
|
||||
VkDevice Graphics::Vulkan::vulkanCreateDevice(VkPhysicalDevice physical_device, VkSurfaceKHR surface, const Emulator::VulkanExt* r,
|
||||
const Emulator::VulkanQueues& queues, const std::vector<const char*>& device_extensions) {
|
||||
VkDevice Graphics::Vulkan::vulkanCreateDevice(VkPhysicalDevice physical_device, VkSurfaceKHR surface, const Emu::VulkanExt* r,
|
||||
const Emu::VulkanQueues& queues, const std::vector<const char*>& device_extensions) {
|
||||
std::vector<VkDeviceQueueCreateInfo> queue_create_info(queues.family_count);
|
||||
std::vector<std::vector<float>> queue_priority(queues.family_count);
|
||||
uint32_t queue_create_info_num = 0;
|
||||
|
@ -247,7 +247,7 @@ VkDevice Graphics::Vulkan::vulkanCreateDevice(VkPhysicalDevice physical_device,
|
|||
|
||||
return device;
|
||||
}
|
||||
void Graphics::Vulkan::vulkanGetInstanceExtensions(Emulator::VulkanExt* ext) {
|
||||
void Graphics::Vulkan::vulkanGetInstanceExtensions(Emu::VulkanExt* ext) {
|
||||
u32 required_extensions_count = 0;
|
||||
u32 available_extensions_count = 0;
|
||||
u32 available_layers_count = 0;
|
||||
|
@ -283,8 +283,8 @@ void Graphics::Vulkan::vulkanGetInstanceExtensions(Emulator::VulkanExt* ext) {
|
|||
|
||||
void Graphics::Vulkan::vulkanFindCompatiblePhysicalDevice(VkInstance instance, VkSurfaceKHR surface,
|
||||
const std::vector<const char*>& device_extensions,
|
||||
Emulator::VulkanSurfaceCapabilities* out_capabilities, VkPhysicalDevice* out_device,
|
||||
Emulator::VulkanQueues* out_queues) {
|
||||
Emu::VulkanSurfaceCapabilities* out_capabilities, VkPhysicalDevice* out_device,
|
||||
Emu::VulkanQueues* out_queues) {
|
||||
u32 count_devices = 0;
|
||||
vkEnumeratePhysicalDevices(instance, &count_devices, nullptr);
|
||||
|
||||
|
@ -292,7 +292,7 @@ void Graphics::Vulkan::vulkanFindCompatiblePhysicalDevice(VkInstance instance, V
|
|||
vkEnumeratePhysicalDevices(instance, &count_devices, devices.data());
|
||||
|
||||
VkPhysicalDevice found_best_device = nullptr;
|
||||
Emulator::VulkanQueues found_best_queues;
|
||||
Emu::VulkanQueues found_best_queues;
|
||||
|
||||
for (const auto& device : devices) {
|
||||
VkPhysicalDeviceProperties device_properties{};
|
||||
|
@ -316,8 +316,8 @@ void Graphics::Vulkan::vulkanFindCompatiblePhysicalDevice(VkInstance instance, V
|
|||
*out_queues = found_best_queues;
|
||||
}
|
||||
|
||||
Emulator::VulkanQueues Graphics::Vulkan::vulkanFindQueues(VkPhysicalDevice device, VkSurfaceKHR surface) {
|
||||
Emulator::VulkanQueues qs;
|
||||
Emu::VulkanQueues Graphics::Vulkan::vulkanFindQueues(VkPhysicalDevice device, VkSurfaceKHR surface) {
|
||||
Emu::VulkanQueues qs;
|
||||
|
||||
u32 queue_family_count = 0;
|
||||
vkGetPhysicalDeviceQueueFamilyProperties(device, &queue_family_count, nullptr);
|
||||
|
@ -334,7 +334,7 @@ Emulator::VulkanQueues Graphics::Vulkan::vulkanFindQueues(VkPhysicalDevice devic
|
|||
LOG_INFO_IF(log_file_vulkanutil, "queue family: {}, count = {}, present = {}\n", string_VkQueueFlags(f.queueFlags).c_str(), f.queueCount,
|
||||
(presentation_supported == VK_TRUE ? "true" : "false"));
|
||||
for (uint32_t i = 0; i < f.queueCount; i++) {
|
||||
Emulator::VulkanQueueInfo info;
|
||||
Emu::VulkanQueueInfo info;
|
||||
info.family = family;
|
||||
info.index = i;
|
||||
info.is_graphics = (f.queueFlags & VK_QUEUE_GRAPHICS_BIT) != 0;
|
||||
|
@ -401,7 +401,7 @@ Emulator::VulkanQueues Graphics::Vulkan::vulkanFindQueues(VkPhysicalDevice devic
|
|||
}
|
||||
|
||||
void Graphics::Vulkan::vulkanGetSurfaceCapabilities(VkPhysicalDevice physical_device, VkSurfaceKHR surface,
|
||||
Emulator::VulkanSurfaceCapabilities* surfaceCap) {
|
||||
Emu::VulkanSurfaceCapabilities* surfaceCap) {
|
||||
vkGetPhysicalDeviceSurfaceCapabilitiesKHR(physical_device, surface, &surfaceCap->capabilities);
|
||||
|
||||
uint32_t formats_count = 0;
|
||||
|
@ -488,7 +488,7 @@ static void set_image_layout(VkCommandBuffer buffer, HLE::Libs::Graphics::Vulkan
|
|||
}
|
||||
|
||||
void Graphics::Vulkan::vulkanBlitImage(GPU::CommandBuffer* buffer, HLE::Libs::Graphics::VulkanImage* src_image,
|
||||
Emulator::VulkanSwapchain* dst_swapchain) {
|
||||
Emu::VulkanSwapchain* dst_swapchain) {
|
||||
auto* vk_buffer = buffer->getPool()->buffers[buffer->getIndex()];
|
||||
|
||||
HLE::Libs::Graphics::VulkanImage swapchain_image(HLE::Libs::Graphics::VulkanImageType::Unknown);
|
||||
|
|
|
@ -26,18 +26,18 @@ const T& clamp(const T& x, const T& min, const T& max) {
|
|||
return x;
|
||||
}
|
||||
|
||||
void vulkanCreate(Emulator::WindowCtx* ctx);
|
||||
void vulkanGetInstanceExtensions(Emulator::VulkanExt* ext);
|
||||
void vulkanCreate(Emu::WindowCtx* ctx);
|
||||
void vulkanGetInstanceExtensions(Emu::VulkanExt* ext);
|
||||
void vulkanFindCompatiblePhysicalDevice(VkInstance instance, VkSurfaceKHR surface, const std::vector<const char*>& device_extensions,
|
||||
Emulator::VulkanSurfaceCapabilities* out_capabilities, VkPhysicalDevice* out_device,
|
||||
Emulator::VulkanQueues* out_queues);
|
||||
VkDevice vulkanCreateDevice(VkPhysicalDevice physical_device, VkSurfaceKHR surface, const Emulator::VulkanExt* r,
|
||||
const Emulator::VulkanQueues& queues, const std::vector<const char*>& device_extensions);
|
||||
Emulator::VulkanQueues vulkanFindQueues(VkPhysicalDevice device, VkSurfaceKHR surface);
|
||||
void vulkanGetSurfaceCapabilities(VkPhysicalDevice physical_device, VkSurfaceKHR surface, Emulator::VulkanSurfaceCapabilities* surfaceCap);
|
||||
void vulkanCreateQueues(HLE::Libs::Graphics::GraphicCtx* ctx, const Emulator::VulkanQueues& queues);
|
||||
Emulator::VulkanSwapchain* vulkanCreateSwapchain(HLE::Libs::Graphics::GraphicCtx* ctx, u32 image_count);
|
||||
void vulkanBlitImage(GPU::CommandBuffer* buffer, HLE::Libs::Graphics::VulkanImage* src_image, Emulator::VulkanSwapchain* dst_swapchain);
|
||||
Emu::VulkanSurfaceCapabilities* out_capabilities, VkPhysicalDevice* out_device,
|
||||
Emu::VulkanQueues* out_queues);
|
||||
VkDevice vulkanCreateDevice(VkPhysicalDevice physical_device, VkSurfaceKHR surface, const Emu::VulkanExt* r,
|
||||
const Emu::VulkanQueues& queues, const std::vector<const char*>& device_extensions);
|
||||
Emu::VulkanQueues vulkanFindQueues(VkPhysicalDevice device, VkSurfaceKHR surface);
|
||||
void vulkanGetSurfaceCapabilities(VkPhysicalDevice physical_device, VkSurfaceKHR surface, Emu::VulkanSurfaceCapabilities* surfaceCap);
|
||||
void vulkanCreateQueues(HLE::Libs::Graphics::GraphicCtx* ctx, const Emu::VulkanQueues& queues);
|
||||
Emu::VulkanSwapchain* vulkanCreateSwapchain(HLE::Libs::Graphics::GraphicCtx* ctx, u32 image_count);
|
||||
void vulkanBlitImage(GPU::CommandBuffer* buffer, HLE::Libs::Graphics::VulkanImage* src_image, Emu::VulkanSwapchain* dst_swapchain);
|
||||
void vulkanFillImage(HLE::Libs::Graphics::GraphicCtx* ctx, HLE::Libs::Graphics::VulkanImage* dst_image, const void* src_data, u64 size, u32 src_pitch,
|
||||
u64 dst_layout);
|
||||
void vulkanBufferToImage(GPU::CommandBuffer* buffer, HLE::Libs::Graphics::VulkanBuffer* src_buffer, u32 src_pitch,
|
||||
|
|
Loading…
Reference in New Issue