From f916fd48b02109d629409f07da140890d9d20e07 Mon Sep 17 00:00:00 2001 From: georgemoralis Date: Mon, 16 Oct 2023 14:34:12 +0300 Subject: [PATCH] sceVideoOutClose implementation (partial) --- .../HLE/Graphics/Objects/video_out_ctx.cpp | 25 +++++++++++++++++++ .../PS4/HLE/Graphics/Objects/video_out_ctx.h | 1 + src/Core/PS4/HLE/Graphics/video_out.cpp | 6 +++++ src/Core/PS4/HLE/Graphics/video_out.h | 2 +- 4 files changed, 33 insertions(+), 1 deletion(-) diff --git a/src/Core/PS4/HLE/Graphics/Objects/video_out_ctx.cpp b/src/Core/PS4/HLE/Graphics/Objects/video_out_ctx.cpp index 4beca2de..2de9139b 100644 --- a/src/Core/PS4/HLE/Graphics/Objects/video_out_ctx.cpp +++ b/src/Core/PS4/HLE/Graphics/Objects/video_out_ctx.cpp @@ -1,6 +1,7 @@ #include "video_out_ctx.h" #include +#include namespace HLE::Graphics::Objects { @@ -28,6 +29,30 @@ int VideoOutCtx::Open() { return handle; } +void VideoOutCtx::Close(s32 handle) { + Lib::LockMutexGuard lock(m_mutex); + + m_video_out_ctx.isOpened = false; + + if (m_video_out_ctx.m_flip_evtEq.size() > 0) + { + BREAKPOINT(); //we need to clear all events if they have been created + } + + m_video_out_ctx.m_flip_rate = 0; + + // clear buffers + for (auto& buffer : m_video_out_ctx.buffers) { + buffer.buffer = nullptr; + buffer.buffer_render = nullptr; + buffer.buffer_size = 0; + buffer.set_id = 0; + } + + m_video_out_ctx.buffers_sets.clear(); + + m_video_out_ctx.buffers_registration_index = 0; +} VideoConfigInternal* VideoOutCtx::getCtx(int handle) { if (handle != 1) return nullptr; diff --git a/src/Core/PS4/HLE/Graphics/Objects/video_out_ctx.h b/src/Core/PS4/HLE/Graphics/Objects/video_out_ctx.h index 7c2f93d6..3aec2d5a 100644 --- a/src/Core/PS4/HLE/Graphics/Objects/video_out_ctx.h +++ b/src/Core/PS4/HLE/Graphics/Objects/video_out_ctx.h @@ -58,6 +58,7 @@ class VideoOutCtx { virtual ~VideoOutCtx() {} void Init(u32 width, u32 height); int Open(); + void Close(s32 handle); VideoConfigInternal* getCtx(int handle); FlipQueue& getFlipQueue() { return m_flip_queue; } HLE::Libs::Graphics::GraphicCtx* getGraphicCtx() { diff --git a/src/Core/PS4/HLE/Graphics/video_out.cpp b/src/Core/PS4/HLE/Graphics/video_out.cpp index 6feccb20..a51e2c6e 100644 --- a/src/Core/PS4/HLE/Graphics/video_out.cpp +++ b/src/Core/PS4/HLE/Graphics/video_out.cpp @@ -299,6 +299,11 @@ s32 PS4_SYSV_ABI sceVideoOutOpen(SceUserServiceUserId userId, s32 busType, s32 i return handle; } +s32 PS4_SYSV_ABI sceVideoOutClose(s32 handle) { + auto* videoOut = singleton::instance(); + videoOut->Close(handle); + return SCE_OK; +} s32 PS4_SYSV_ABI sceVideoOutUnregisterBuffers(s32 handle, s32 attributeIndex) { BREAKPOINT(); } void videoOutRegisterLib(SymbolsResolver* sym) { @@ -312,5 +317,6 @@ void videoOutRegisterLib(SymbolsResolver* sym) { LIB_FUNCTION("Up36PTk687E", "libSceVideoOut", 1, "libSceVideoOut", 0, 0, sceVideoOutOpen); LIB_FUNCTION("zgXifHT9ErY", "libSceVideoOut", 1, "libSceVideoOut", 0, 0, sceVideoOutIsFlipPending); LIB_FUNCTION("N5KDtkIjjJ4", "libSceVideoOut", 1, "libSceVideoOut", 0, 0, sceVideoOutUnregisterBuffers); + LIB_FUNCTION("uquVH4-Du78", "libSceVideoOut", 1, "libSceVideoOut", 0, 0, sceVideoOutClose); } } // namespace HLE::Libs::Graphics::VideoOut \ No newline at end of file diff --git a/src/Core/PS4/HLE/Graphics/video_out.h b/src/Core/PS4/HLE/Graphics/video_out.h index c3250891..9db9299d 100644 --- a/src/Core/PS4/HLE/Graphics/video_out.h +++ b/src/Core/PS4/HLE/Graphics/video_out.h @@ -110,5 +110,5 @@ s32 PS4_SYSV_ABI sceVideoOutSubmitFlip(s32 handle, s32 bufferIndex, s32 flipMode s32 PS4_SYSV_ABI sceVideoOutGetFlipStatus(s32 handle, SceVideoOutFlipStatus* status); s32 PS4_SYSV_ABI sceVideoOutGetResolutionStatus(s32 handle, SceVideoOutResolutionStatus* status); s32 PS4_SYSV_ABI sceVideoOutOpen(SceUserServiceUserId userId, s32 busType, s32 index, const void* param); - +s32 PS4_SYSV_ABI sceVideoOutClose(s32 handle); } // namespace HLE::Libs::Graphics::VideoOut \ No newline at end of file