mirror of
https://github.com/shadps4-emu/shadPS4.git
synced 2025-05-24 04:15:01 +00:00
refactoring singleton class
This commit is contained in:
parent
0f80805d69
commit
58721d84a0
12 changed files with 44 additions and 71 deletions
|
@ -2,17 +2,17 @@
|
|||
|
||||
#include <xxhash/xxh3.h>
|
||||
|
||||
#include "Util/Singleton.h"
|
||||
#include "Emulator/Util/singleton.h"
|
||||
|
||||
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 = 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 = singleton<GPUMemory>::instance();
|
||||
|
||||
Lib::LockMutexGuard 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 = 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 = singleton<GPUMemory>::instance();
|
||||
|
||||
Lib::LockMutexGuard lock(gpumemory->m_mutex);
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
#include "tile_manager.h"
|
||||
#include "Lib/Threads.h"
|
||||
#include "Util/Singleton.h"
|
||||
#include "Emulator/Util/singleton.h"
|
||||
|
||||
namespace GPU {
|
||||
|
||||
|
@ -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 = singleton<TileManager>::instance();
|
||||
|
||||
Lib::LockMutexGuard lock(g_TileManager->m_mutex);
|
||||
|
||||
|
|
|
@ -1,12 +1,12 @@
|
|||
#include "graphics_render.h"
|
||||
|
||||
#include "Util/Singleton.h"
|
||||
#include "Emulator/Util/singleton.h"
|
||||
#include "emulator.h"
|
||||
|
||||
static thread_local GPU::CommandPool g_command_pool;
|
||||
|
||||
void GPU::renderCreateCtx() {
|
||||
auto* render_ctx = Singleton<RenderCtx>::Instance();
|
||||
auto* render_ctx = 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 = 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 = singleton<RenderCtx>::instance();
|
||||
const auto& queue = render_ctx->getGraphicCtx()->queues[m_queue];
|
||||
|
||||
if (queue.mutex != nullptr) {
|
||||
|
@ -124,7 +124,7 @@ void GPU::CommandBuffer::execute() {
|
|||
submit_info.signalSemaphoreCount = 0;
|
||||
submit_info.pSignalSemaphores = nullptr;
|
||||
|
||||
auto* render_ctx = Singleton<RenderCtx>::Instance();
|
||||
auto* render_ctx = singleton<RenderCtx>::instance();
|
||||
const auto& queue = render_ctx->getGraphicCtx()->queues[m_queue];
|
||||
|
||||
if (queue.mutex != nullptr) {
|
||||
|
@ -145,7 +145,7 @@ void GPU::CommandBuffer::execute() {
|
|||
}
|
||||
}
|
||||
void GPU::CommandPool::createPool(int id) {
|
||||
auto* render_ctx = Singleton<RenderCtx>::Instance();
|
||||
auto* render_ctx = singleton<RenderCtx>::instance();
|
||||
auto* ctx = render_ctx->getGraphicCtx();
|
||||
|
||||
m_pool[id] = new HLE::Libs::Graphics::VulkanCommandPool;
|
||||
|
@ -206,7 +206,7 @@ void GPU::CommandPool::createPool(int id) {
|
|||
}
|
||||
|
||||
void GPU::CommandPool::deleteAllPool() {
|
||||
auto* render_ctx = Singleton<RenderCtx>::Instance();
|
||||
auto* render_ctx = singleton<RenderCtx>::instance();
|
||||
auto* ctx = render_ctx->getGraphicCtx();
|
||||
|
||||
for (auto& pool : m_pool) {
|
||||
|
|
|
@ -15,7 +15,7 @@
|
|||
#include <string>
|
||||
|
||||
#include "Objects/video_out_ctx.h"
|
||||
#include "Util/Singleton.h"
|
||||
#include "Emulator/Util/singleton.h"
|
||||
#include "emulator.h"
|
||||
#include "graphics_render.h"
|
||||
|
||||
|
@ -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 = singleton<HLE::Graphics::Objects::VideoOutCtx>::instance();
|
||||
videoOut->Init(width, height);
|
||||
}
|
||||
|
||||
bool videoOutFlip(u32 micros) {
|
||||
auto* videoOut = Singleton<HLE::Graphics::Objects::VideoOutCtx>::Instance();
|
||||
auto* videoOut = 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 = 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 = singleton<HLE::Graphics::Objects::VideoOutCtx>::instance();
|
||||
auto* ctx = videoOut->getCtx(handle);
|
||||
|
||||
if (handle == 1) { // main port
|
||||
|
@ -215,19 +215,19 @@ s32 PS4_SYSV_ABI sceVideoOutRegisterBuffers(s32 handle, s32 startIndex, void* co
|
|||
}
|
||||
s32 PS4_SYSV_ABI sceVideoOutSetFlipRate(s32 handle, s32 rate) {
|
||||
PRINT_FUNCTION_NAME();
|
||||
auto* videoOut = Singleton<HLE::Graphics::Objects::VideoOutCtx>::Instance();
|
||||
auto* videoOut = 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 = 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 = 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 = 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 = 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 = singleton<HLE::Graphics::Objects::VideoOutCtx>::instance();
|
||||
int handle = videoOut->Open();
|
||||
|
||||
if (handle < 0) {
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
#include <bit>
|
||||
#include <magic_enum.hpp>
|
||||
|
||||
#include "../../../../Util/Singleton.h"
|
||||
#include "Emulator/Util/singleton.h"
|
||||
#include "../ErrorCodes.h"
|
||||
#include "../Libs.h"
|
||||
#include "Objects/physical_memory.h"
|
||||
|
@ -55,7 +55,7 @@ int PS4_SYSV_ABI sceKernelAllocateDirectMemory(s64 searchStart, s64 searchEnd, u
|
|||
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 = 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;
|
||||
|
@ -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 = singleton<HLE::Kernel::Objects::PhysicalMemory>::instance();
|
||||
if (!physical_memory->Map(out_addr, directMemoryStart, len, prot, cpu_mode, gpu_mode)) {
|
||||
BREAKPOINT();
|
||||
}
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
#include <Util/log.h>
|
||||
#include <debug.h>
|
||||
|
||||
#include "../../../Util/Singleton.h"
|
||||
#include "Emulator/Util/singleton.h"
|
||||
#include "../Loader/Elf.h"
|
||||
#include "Kernel/Objects/physical_memory.h"
|
||||
#include "Kernel/cpu_management.h"
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue