common: Move classes to common namespace

This commit is contained in:
GPUCode 2023-11-05 16:56:28 +02:00
parent 996aa9d17a
commit 303f086b14
21 changed files with 190 additions and 199 deletions

View file

@ -6,13 +6,13 @@
void* GPU::memoryCreateObj(u64 submit_id, HLE::Libs::Graphics::GraphicCtx* ctx, void* todo /*CommandBuffer?*/, u64 virtual_addr, u64 size,
const GPUObject& info) {
auto* gpumemory = singleton<GPUMemory>::instance();
auto* gpumemory = Common::Singleton<GPUMemory>::Instance();
return gpumemory->memoryCreateObj(submit_id, ctx, nullptr, &virtual_addr, &size, 1, info);
}
void GPU::memorySetAllocArea(u64 virtual_addr, u64 size) {
auto* gpumemory = singleton<GPUMemory>::instance();
auto* gpumemory = Common::Singleton<GPUMemory>::Instance();
std::scoped_lock lock{gpumemory->m_mutex};
@ -59,7 +59,7 @@ bool GPU::vulkanAllocateMemory(HLE::Libs::Graphics::GraphicCtx* ctx, HLE::Libs::
}
void GPU::flushGarlic(HLE::Libs::Graphics::GraphicCtx* ctx) {
auto* gpumemory = singleton<GPUMemory>::instance();
auto* gpumemory = Common::Singleton<GPUMemory>::Instance();
gpumemory->flushAllHeaps(ctx);
}
@ -78,7 +78,7 @@ int GPU::GPUMemory::getHeapId(u64 virtual_addr, u64 size) {
void* GPU::GPUMemory::memoryCreateObj(u64 submit_id, HLE::Libs::Graphics::GraphicCtx* ctx, void* todo, const u64* virtual_addr, const u64* size,
int virtual_addr_num, const GPUObject& info) {
auto* gpumemory = singleton<GPUMemory>::instance();
auto* gpumemory = Common::Singleton<GPUMemory>::Instance();
std::scoped_lock lock{gpumemory->m_mutex};

View file

@ -143,7 +143,7 @@ void convertTileToLinear(void* dst, const void* src,u32 width, u32 height, bool
TileManager32 t;
t.Init(width, height, is_neo);
auto* g_TileManager = singleton<TileManager>::instance();
auto* g_TileManager = Common::Singleton<TileManager>::Instance();
std::scoped_lock lock{g_TileManager->m_mutex};
@ -166,4 +166,4 @@ void convertTileToLinear(void* dst, const void* src,u32 width, u32 height, bool
}
}
}
} // namespace GPU
} // namespace GPU

View file

@ -6,7 +6,7 @@
static thread_local GPU::CommandPool g_command_pool;
void GPU::renderCreateCtx() {
auto* render_ctx = singleton<RenderCtx>::instance();
auto* render_ctx = Common::Singleton<RenderCtx>::Instance();
render_ctx->setGraphicCtx(Emu::getGraphicCtx());
}
@ -37,7 +37,7 @@ void GPU::CommandBuffer::freeBuffer() {
}
void GPU::CommandBuffer::waitForFence() {
auto* render_ctx = singleton<RenderCtx>::instance();
auto* render_ctx = Common::Singleton<RenderCtx>::Instance();
if (m_execute) {
auto* device = render_ctx->getGraphicCtx()->m_device;
@ -89,7 +89,7 @@ void GPU::CommandBuffer::executeWithSemaphore() {
submit_info.signalSemaphoreCount = 1;
submit_info.pSignalSemaphores = &m_pool->semaphores[m_index];
auto* render_ctx = singleton<RenderCtx>::instance();
auto* render_ctx = Common::Singleton<RenderCtx>::Instance();
const auto& queue = render_ctx->getGraphicCtx()->queues[m_queue];
auto result = vkQueueSubmit(queue.vk_queue, 1, &submit_info, fence);
@ -115,7 +115,7 @@ void GPU::CommandBuffer::execute() {
submit_info.signalSemaphoreCount = 0;
submit_info.pSignalSemaphores = nullptr;
auto* render_ctx = singleton<RenderCtx>::instance();
auto* render_ctx = Common::Singleton<RenderCtx>::Instance();
const auto& queue = render_ctx->getGraphicCtx()->queues[m_queue];
auto result = vkQueueSubmit(queue.vk_queue, 1, &submit_info, fence);
@ -127,7 +127,7 @@ void GPU::CommandBuffer::execute() {
}
}
void GPU::CommandPool::createPool(int id) {
auto* render_ctx = singleton<RenderCtx>::instance();
auto* render_ctx = Common::Singleton<RenderCtx>::Instance();
auto* ctx = render_ctx->getGraphicCtx();
VkCommandPoolCreateInfo pool_info{};
@ -186,7 +186,7 @@ void GPU::CommandPool::createPool(int id) {
}
void GPU::CommandPool::deleteAllPool() {
auto* render_ctx = singleton<RenderCtx>::instance();
auto* render_ctx = Common::Singleton<RenderCtx>::Instance();
auto* ctx = render_ctx->getGraphicCtx();
for (auto& pool : m_pool) {

View file

@ -24,12 +24,12 @@ namespace HLE::Libs::Graphics::VideoOut {
constexpr bool log_file_videoout = true; // disable it to disable logging
void videoOutInit(u32 width, u32 height) {
auto* videoOut = singleton<HLE::Graphics::Objects::VideoOutCtx>::instance();
auto* videoOut = Common::Singleton<HLE::Graphics::Objects::VideoOutCtx>::Instance();
videoOut->Init(width, height);
}
bool videoOutFlip(u32 micros) {
auto* videoOut = singleton<HLE::Graphics::Objects::VideoOutCtx>::instance();
auto* videoOut = Common::Singleton<HLE::Graphics::Objects::VideoOutCtx>::Instance();
return videoOut->getFlipQueue().flip(micros);
}
@ -87,7 +87,7 @@ static void flip_delete_event_func(LibKernel::EventQueues::SceKernelEqueue eq, H
s32 PS4_SYSV_ABI sceVideoOutAddFlipEvent(LibKernel::EventQueues::SceKernelEqueue eq, s32 handle, void* udata) {
PRINT_FUNCTION_NAME();
auto* videoOut = singleton<HLE::Graphics::Objects::VideoOutCtx>::instance();
auto* videoOut = Common::Singleton<HLE::Graphics::Objects::VideoOutCtx>::Instance();
auto* ctx = videoOut->getCtx(handle);
@ -122,7 +122,7 @@ s32 PS4_SYSV_ABI sceVideoOutAddFlipEvent(LibKernel::EventQueues::SceKernelEqueue
s32 PS4_SYSV_ABI sceVideoOutRegisterBuffers(s32 handle, s32 startIndex, void* const* addresses, s32 bufferNum,
const SceVideoOutBufferAttribute* attribute) {
PRINT_FUNCTION_NAME();
auto* videoOut = singleton<HLE::Graphics::Objects::VideoOutCtx>::instance();
auto* videoOut = Common::Singleton<HLE::Graphics::Objects::VideoOutCtx>::Instance();
auto* ctx = videoOut->getCtx(handle);
if (handle == 1) { // main port
@ -154,7 +154,7 @@ s32 PS4_SYSV_ABI sceVideoOutRegisterBuffers(s32 handle, s32 startIndex, void* co
}
LOG_INFO_IF(log_file_videoout, "startIndex = {}\n", startIndex);
LOG_INFO_IF(log_file_videoout, "bufferNum = {}\n", bufferNum);
LOG_INFO_IF(log_file_videoout, "pixelFormat = {}\n", log_hex_full(attribute->pixelFormat));
LOG_INFO_IF(log_file_videoout, "pixelFormat = {:#x}\n", attribute->pixelFormat);
LOG_INFO_IF(log_file_videoout, "tilingMode = {}\n", attribute->tilingMode);
LOG_INFO_IF(log_file_videoout, "aspectRatio = {}\n", attribute->aspectRatio);
LOG_INFO_IF(log_file_videoout, "width = {}\n", attribute->width);
@ -208,26 +208,26 @@ s32 PS4_SYSV_ABI sceVideoOutRegisterBuffers(s32 handle, s32 startIndex, void* co
ctx->buffers[i + startIndex].buffer_render = static_cast<Graphics::VideoOutVulkanImage*>(
GPU::memoryCreateObj(0, videoOut->getGraphicCtx(), nullptr, reinterpret_cast<uint64_t>(addresses[i]), buffer_size, buffer_info));
LOG_INFO_IF(log_file_videoout, "buffers[{}] = {}\n", i + startIndex, log_hex_full(reinterpret_cast<uint64_t>(addresses[i])));
LOG_INFO_IF(log_file_videoout, "buffers[{}] = {:#x}\n", i + startIndex, reinterpret_cast<u64>(addresses[i]));
}
return registration_index;
}
s32 PS4_SYSV_ABI sceVideoOutSetFlipRate(s32 handle, s32 rate) {
PRINT_FUNCTION_NAME();
auto* videoOut = singleton<HLE::Graphics::Objects::VideoOutCtx>::instance();
auto* videoOut = Common::Singleton<HLE::Graphics::Objects::VideoOutCtx>::Instance();
videoOut->getCtx(handle)->m_flip_rate = rate;
return SCE_OK;
}
s32 PS4_SYSV_ABI sceVideoOutIsFlipPending(s32 handle) {
PRINT_FUNCTION_NAME();
auto* videoOut = singleton<HLE::Graphics::Objects::VideoOutCtx>::instance();
auto* videoOut = Common::Singleton<HLE::Graphics::Objects::VideoOutCtx>::Instance();
s32 pending = videoOut->getCtx(handle)->m_flip_status.flipPendingNum;
return pending;
}
s32 PS4_SYSV_ABI sceVideoOutSubmitFlip(s32 handle, s32 bufferIndex, s32 flipMode, s64 flipArg) {
PRINT_FUNCTION_NAME();
auto* videoOut = singleton<HLE::Graphics::Objects::VideoOutCtx>::instance();
auto* videoOut = Common::Singleton<HLE::Graphics::Objects::VideoOutCtx>::Instance();
auto* ctx = videoOut->getCtx(handle);
if (flipMode != 1) {
@ -254,7 +254,7 @@ s32 PS4_SYSV_ABI sceVideoOutSubmitFlip(s32 handle, s32 bufferIndex, s32 flipMode
}
s32 PS4_SYSV_ABI sceVideoOutGetFlipStatus(s32 handle, SceVideoOutFlipStatus* status) {
PRINT_FUNCTION_NAME();
auto* videoOut = singleton<HLE::Graphics::Objects::VideoOutCtx>::instance();
auto* videoOut = Common::Singleton<HLE::Graphics::Objects::VideoOutCtx>::Instance();
auto* ctx = videoOut->getCtx(handle);
videoOut->getFlipQueue().getFlipStatus(ctx, status);
@ -270,7 +270,7 @@ s32 PS4_SYSV_ABI sceVideoOutGetFlipStatus(s32 handle, SceVideoOutFlipStatus* sta
}
s32 PS4_SYSV_ABI sceVideoOutGetResolutionStatus(s32 handle, SceVideoOutResolutionStatus* status) {
PRINT_FUNCTION_NAME();
auto* videoOut = singleton<HLE::Graphics::Objects::VideoOutCtx>::instance();
auto* videoOut = Common::Singleton<HLE::Graphics::Objects::VideoOutCtx>::Instance();
*status = videoOut->getCtx(handle)->m_resolution;
return SCE_OK;
}
@ -289,7 +289,7 @@ s32 PS4_SYSV_ABI sceVideoOutOpen(SceUserServiceUserId userId, s32 busType, s32 i
if (param != nullptr) {
BREAKPOINT();
}
auto* videoOut = singleton<HLE::Graphics::Objects::VideoOutCtx>::instance();
auto* videoOut = Common::Singleton<HLE::Graphics::Objects::VideoOutCtx>::Instance();
int handle = videoOut->Open();
if (handle < 0) {
@ -300,7 +300,7 @@ s32 PS4_SYSV_ABI sceVideoOutOpen(SceUserServiceUserId userId, s32 busType, s32 i
return handle;
}
s32 PS4_SYSV_ABI sceVideoOutClose(s32 handle) {
auto* videoOut = singleton<HLE::Graphics::Objects::VideoOutCtx>::instance();
auto* videoOut = Common::Singleton<HLE::Graphics::Objects::VideoOutCtx>::Instance();
videoOut->Close(handle);
return SCE_OK;
}
@ -319,4 +319,4 @@ void videoOutRegisterLib(SymbolsResolver* sym) {
LIB_FUNCTION("N5KDtkIjjJ4", "libSceVideoOut", 1, "libSceVideoOut", 0, 0, sceVideoOutUnregisterBuffers);
LIB_FUNCTION("uquVH4-Du78", "libSceVideoOut", 1, "libSceVideoOut", 0, 0, sceVideoOutClose);
}
} // namespace HLE::Libs::Graphics::VideoOut
} // namespace HLE::Libs::Graphics::VideoOut

View file

@ -48,20 +48,20 @@ int PS4_SYSV_ABI sceKernelAllocateDirectMemory(s64 searchStart, s64 searchEnd, u
}
auto memtype = magic_enum::enum_cast<MemoryTypes>(memoryType);
LOG_INFO_IF(log_file_memory, "search_start = {}\n", log_hex_full(searchStart));
LOG_INFO_IF(log_file_memory, "search_end = {}\n", log_hex_full(searchEnd));
LOG_INFO_IF(log_file_memory, "len = {}\n", log_hex_full(len));
LOG_INFO_IF(log_file_memory, "alignment = {}\n", log_hex_full(alignment));
LOG_INFO_IF(log_file_memory, "search_start = {:#x}\n", searchStart);
LOG_INFO_IF(log_file_memory, "search_end = {:#x}\n", searchEnd);
LOG_INFO_IF(log_file_memory, "len = {:#x}\n", len);
LOG_INFO_IF(log_file_memory, "alignment = {:#x}\n", alignment);
LOG_INFO_IF(log_file_memory, "memory_type = {}\n", magic_enum::enum_name(memtype.value()));
u64 physical_addr = 0;
auto* physical_memory = singleton<HLE::Kernel::Objects::PhysicalMemory>::instance();
auto* physical_memory = Common::Singleton<HLE::Kernel::Objects::PhysicalMemory>::Instance();
if (!physical_memory->Alloc(searchStart, searchEnd, len, alignment, &physical_addr, memoryType)) {
LOG_TRACE_IF(log_file_memory, "sceKernelAllocateDirectMemory returned SCE_KERNEL_ERROR_EAGAIN can't allocate physical memory\n");
return SCE_KERNEL_ERROR_EAGAIN;
}
*physAddrOut = static_cast<s64>(physical_addr);
LOG_INFO_IF(true, "physAddrOut = {}\n", log_hex_full(physical_addr));
LOG_INFO_IF(true, "physAddrOut = {:#x}\n", physical_addr);
return SCE_OK;
}
@ -82,11 +82,11 @@ int PS4_SYSV_ABI sceKernelMapDirectMemory(void** addr, u64 len, int prot, int fl
}
}
LOG_INFO_IF(log_file_memory, "len = {}\n", log_hex_full(len));
LOG_INFO_IF(log_file_memory, "prot = {}\n", log_hex_full(prot));
LOG_INFO_IF(log_file_memory, "flags = {}\n", log_hex_full(flags));
LOG_INFO_IF(log_file_memory, "directMemoryStart = {}\n", log_hex_full(directMemoryStart));
LOG_INFO_IF(log_file_memory, "alignment = {}\n", log_hex_full(alignment));
LOG_INFO_IF(log_file_memory, "len = {:#x}\n", len);
LOG_INFO_IF(log_file_memory, "prot = {:#x}\n", prot);
LOG_INFO_IF(log_file_memory, "flags = {:#x}\n", flags);
LOG_INFO_IF(log_file_memory, "directMemoryStart = {:#x}\n", directMemoryStart);
LOG_INFO_IF(log_file_memory, "alignment = {:#x}\n", alignment);
VirtualMemory::MemoryMode cpu_mode = VirtualMemory::MemoryMode::NoAccess;
GPU::MemoryMode gpu_mode = GPU::MemoryMode::NoAccess;
@ -106,8 +106,8 @@ int PS4_SYSV_ABI sceKernelMapDirectMemory(void** addr, u64 len, int prot, int fl
if (flags == 0) {
out_addr = VirtualMemory::memory_alloc_aligned(in_addr, len, cpu_mode, alignment);
}
LOG_INFO_IF(log_file_memory, "in_addr = {}\n", log_hex_full(in_addr));
LOG_INFO_IF(log_file_memory, "out_addr = {}\n", log_hex_full(out_addr));
LOG_INFO_IF(log_file_memory, "in_addr = {:#x}\n", in_addr);
LOG_INFO_IF(log_file_memory, "out_addr = {:#x}\n", out_addr);
*addr = reinterpret_cast<void*>(out_addr); // return out_addr to first functions parameter
@ -115,7 +115,7 @@ int PS4_SYSV_ABI sceKernelMapDirectMemory(void** addr, u64 len, int prot, int fl
return SCE_KERNEL_ERROR_ENOMEM;
}
auto* physical_memory = singleton<HLE::Kernel::Objects::PhysicalMemory>::instance();
auto* physical_memory = Common::Singleton<HLE::Kernel::Objects::PhysicalMemory>::Instance();
if (!physical_memory->Map(out_addr, directMemoryStart, len, prot, cpu_mode, gpu_mode)) {
BREAKPOINT();
}
@ -126,4 +126,4 @@ int PS4_SYSV_ABI sceKernelMapDirectMemory(void** addr, u64 len, int prot, int fl
return SCE_OK;
}
} // namespace HLE::Libs::LibKernel::MemoryManagement
} // namespace HLE::Libs::LibKernel::MemoryManagement

View file

@ -412,7 +412,7 @@ void Linker::LoadSymbols(Module* m)
sym++)
{
std::string id = std::string(m->dynamic_info.str_table + sym->st_name);
auto ids = StringUtil::split_string(id, '#');
const auto ids = Common::SplitString(id, '#');
if (ids.size() == 3)//symbols are 3 parts name , library , module
{
const auto* library = FindLibrary(*m, ids.at(1));
@ -575,9 +575,8 @@ void Linker::Relocate(Module* m)
}
}
void Linker::Resolve(const std::string& name, int Symtype, Module* m, SymbolRecord* return_info) {
auto ids = StringUtil::split_string(name, '#');
void Linker::Resolve(const std::string& name, int Symtype, Module* m, SymbolRecord* return_info) {
const auto ids = Common::SplitString(name, '#');
if (ids.size() == 3) // symbols are 3 parts name , library , module
{
const auto* library = FindLibrary(*m, ids.at(1));

View file

@ -30,7 +30,7 @@ struct CContext {
};
static PS4_SYSV_ABI int __cxa_atexit(void (*func)(void*), void* arg, void* dso_handle) {
auto* cc = singleton<CContext>::instance();
auto* cc = Common::Singleton<CContext>::Instance();
CxaDestructor c{};
c.destructor_func = func;
c.destructor_object = arg;
@ -127,4 +127,4 @@ void libcSymbolsRegister(SymbolsResolver* sym) {
LIB_FUNCTION("zr094EQ39Ww", "libc", 1, "libc", 1, 1, __cxa_pure_virtual);
}
}; // namespace Core::Libraries::LibC
}; // namespace Core::Libraries::LibC

View file

@ -21,7 +21,7 @@ int PS4_SYSV_ABI scePadOpen(Core::Libraries::LibUserService::SceUserServiceUserI
}
int PS4_SYSV_ABI scePadReadState(int32_t handle, ScePadData* pData) {
auto* controller = singleton<Emulator::Host::Controller::GameController>::instance();
auto* controller = Common::Singleton<Emulator::Host::Controller::GameController>::Instance();
int connectedCount = 0;
bool isConnected = false;