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 1017fbc0..8adf22ef 100644 --- a/src/Core/PS4/HLE/Graphics/Objects/video_out_ctx.h +++ b/src/Core/PS4/HLE/Graphics/Objects/video_out_ctx.h @@ -16,6 +16,8 @@ struct VideoConfigInternal { SceVideoOutVblankStatus m_vblank_status; std::vector m_flip_evtEq; int m_flip_rate = 0; + + int buffers_registration_index = 0; }; class FlipQueue { diff --git a/src/Core/PS4/HLE/Graphics/video_out.cpp b/src/Core/PS4/HLE/Graphics/video_out.cpp index 56d006ee..6074bff0 100644 --- a/src/Core/PS4/HLE/Graphics/video_out.cpp +++ b/src/Core/PS4/HLE/Graphics/video_out.cpp @@ -12,6 +12,7 @@ #include "Objects/video_out_ctx.h" #include "Util/Singleton.h" +#include namespace HLE::Libs::Graphics::VideoOut { @@ -155,7 +156,16 @@ s32 PS4_SYSV_ABI sceVideoOutRegisterBuffers(s32 handle, s32 startIndex, void* co LOG_INFO_IF(log_file_videoout, "height = {}\n", attribute->height); LOG_INFO_IF(log_file_videoout, "pitchInPixel = {}\n", attribute->pitchInPixel); LOG_INFO_IF(log_file_videoout, "option = {}\n", attribute->option); - return 0; + + int registration_index = ctx->buffers_registration_index++; + + Emulator::checkAndWaitForGraphicsInit(); + + //try to calculate buffer size + u64 buffer_size = 1280 * 720 * 4; //TODO hardcore value should be redone + u64 buffer_pitch = attribute->pitchInPixel; + + return registration_index; } s32 PS4_SYSV_ABI sceVideoOutSetFlipRate(s32 handle, s32 rate) { PRINT_FUNCTION_NAME(); diff --git a/src/emulator.cpp b/src/emulator.cpp index 0fa5ca5d..98c3dae0 100644 --- a/src/emulator.cpp +++ b/src/emulator.cpp @@ -14,6 +14,13 @@ void emuInit(u32 width, u32 height) { g_window_ctx->m_graphic_ctx.screen_height = height; } +void checkAndWaitForGraphicsInit() { + Lib::LockMutexGuard lock(g_window_ctx->m_mutex); + + while (!g_window_ctx->m_is_graphic_initialized) { + g_window_ctx->m_graphic_initialized_cond.WaitCondVar(&g_window_ctx->m_mutex); + } +} static void CreateSdlWindow(WindowCtx* ctx) { int width = static_cast(ctx->m_graphic_ctx.screen_width); int height = static_cast(ctx->m_graphic_ctx.screen_height); @@ -34,7 +41,6 @@ static void CreateSdlWindow(WindowCtx* ctx) { } SDL_SetWindowResizable(ctx->m_window, SDL_FALSE); // we don't support resizable atm - SDL_ShowWindow(g_window_ctx->m_window); // TODO should be removed just left it over to make it fancy :D } void emuRun() { g_window_ctx->m_mutex.LockMutex(); diff --git a/src/emulator.h b/src/emulator.h index d86b1ef6..975b5330 100644 --- a/src/emulator.h +++ b/src/emulator.h @@ -24,4 +24,5 @@ struct EmuPrivate { }; void emuInit(u32 width, u32 height); void emuRun(); +void checkAndWaitForGraphicsInit(); } // namespace Emulator \ No newline at end of file