diff --git a/rpcs3/Emu/Memory/atomic.h b/rpcs3/Emu/Memory/atomic.h index 48fd65d3d7..181398d0f6 100644 --- a/rpcs3/Emu/Memory/atomic.h +++ b/rpcs3/Emu/Memory/atomic.h @@ -180,7 +180,8 @@ public: write_relaxed(sub_data, to_subtype(value)); } - // perform an atomic operation on data (callable object version, first arg is a reference to atomic type) + // perform an atomic operation on data (func is either pointer to member function or callable object with a T& first arg); + // returns the result of the callable object call or previous (old) value of the atomic variable if the return type is void template> auto atomic_op(F func, Args&&... args) volatile -> decltype(atomic_op_result_t::result) { while (true) diff --git a/rpcs3/Emu/Memory/vm.cpp b/rpcs3/Emu/Memory/vm.cpp index 88938355f5..d408a794d0 100644 --- a/rpcs3/Emu/Memory/vm.cpp +++ b/rpcs3/Emu/Memory/vm.cpp @@ -228,14 +228,12 @@ namespace vm catch (...) { // capture any exception possibly thrown by predicate - auto exception = std::current_exception(); - - // set new predicate that will throw this exception from the original thread - pred = [exception]() -> bool + pred = [exception = std::current_exception()] { + // new predicate will throw the captured exception from the original thread std::rethrow_exception(exception); - // dummy return value + // dummy return value, remove when std::rethrow_exception gains [[noreturn]] attribute in MSVC return true; }; } @@ -282,6 +280,9 @@ namespace vm void _notify_at(u32 addr, u32 size) { + // skip notification if no waiters available + if (_mm_mfence(), !g_waiter_max) return; + std::lock_guard lock(g_waiter_list_mutex); const u32 mask = ~(size - 1); diff --git a/rpcs3/Emu/RSX/RSXThread.cpp b/rpcs3/Emu/RSX/RSXThread.cpp index d3cd7129a4..e7cc9cdc12 100644 --- a/rpcs3/Emu/RSX/RSXThread.cpp +++ b/rpcs3/Emu/RSX/RSXThread.cpp @@ -249,12 +249,11 @@ void RSXThread::DoCmd(const u32 fcmd, const u32 cmd, const u32 args_addr, const m_read_buffer = true; m_flip_status = 0; - if (m_flip_handler) + if (auto cb = m_flip_handler) { - auto cb = m_flip_handler; - Emu.GetCallbackManager().Async([=](CPUThread& CPU) + Emu.GetCallbackManager().Async([=](CPUThread& cpu) { - cb(static_cast(CPU), 1); + cb(static_cast(cpu), 1); }); } @@ -2311,11 +2310,19 @@ void RSXThread::DoCmd(const u32 fcmd, const u32 cmd, const u32 args_addr, const case GCM_SET_USER_COMMAND: { const u32 cause = ARGS(0); - auto cb = m_user_handler; - Emu.GetCallbackManager().Async([=](CPUThread& CPU) + + if (auto cb = m_user_handler) { - cb(static_cast(CPU), cause); - }); + Emu.GetCallbackManager().Async([=](CPUThread& cpu) + { + cb(static_cast(cpu), cause); + }); + } + else + { + throw EXCEPTION("User handler not set"); + } + break; } @@ -2477,9 +2484,9 @@ void RSXThread::Task() if (auto cb = m_vblank_handler) { - Emu.GetCallbackManager().Async([=](CPUThread& CPU) + Emu.GetCallbackManager().Async([=](CPUThread& cpu) { - cb(static_cast(CPU), 1); + cb(static_cast(cpu), 1); }); } } @@ -2544,10 +2551,7 @@ void RSXThread::Task() if (cmd == 0) //nop { - m_ctrl->get.atomic_op([](be_t& value) - { - value += 4; - }); + m_ctrl->get += 4; continue; } @@ -2560,10 +2564,7 @@ void RSXThread::Task() DoCmd(cmd, cmd & 0x3ffff, args.addr(), count); - m_ctrl->get.atomic_op([count](be_t& value) - { - value += (count + 1) * 4; - }); + m_ctrl->get += (count + 1) * 4; } OnExitThread(); diff --git a/rpcs3/Emu/SysCalls/Modules/cellCamera.cpp b/rpcs3/Emu/SysCalls/Modules/cellCamera.cpp index bb3ca59368..7d91dff15f 100644 --- a/rpcs3/Emu/SysCalls/Modules/cellCamera.cpp +++ b/rpcs3/Emu/SysCalls/Modules/cellCamera.cpp @@ -310,7 +310,7 @@ Module cellCamera("cellCamera", []() REG_FUNC(cellCamera, cellCameraInit); REG_FUNC(cellCamera, cellCameraEnd); - REG_FUNC(cellCamera, cellCameraOpen); + REG_FUNC(cellCamera, cellCameraOpen); // was "renamed", but exists REG_FUNC(cellCamera, cellCameraOpenEx); REG_FUNC(cellCamera, cellCameraClose); @@ -323,7 +323,7 @@ Module cellCamera("cellCamera", []() REG_FUNC(cellCamera, cellCameraGetAttribute); REG_FUNC(cellCamera, cellCameraSetAttribute); REG_FUNC(cellCamera, cellCameraGetBufferSize); - REG_FUNC(cellCamera, cellCameraGetBufferInfo); + REG_FUNC(cellCamera, cellCameraGetBufferInfo); // was "renamed", but exists REG_FUNC(cellCamera, cellCameraGetBufferInfoEx); REG_FUNC(cellCamera, cellCameraPrepExtensionUnit); diff --git a/rpcs3/Emu/SysCalls/Modules/cellFont.cpp b/rpcs3/Emu/SysCalls/Modules/cellFont.cpp index 7433d187fc..8da8291a84 100644 --- a/rpcs3/Emu/SysCalls/Modules/cellFont.cpp +++ b/rpcs3/Emu/SysCalls/Modules/cellFont.cpp @@ -48,17 +48,6 @@ s32 cellFontGetRevisionFlags(vm::ptr revisionFlags) return CELL_OK; } -s32 cellFontInit(PPUThread& ppu, vm::ptr config) -{ - cellFont.Warning("cellFontInit(config=*0x%x)", config); - - vm::stackvar> revisionFlags(ppu); - revisionFlags.value() = 0; - cellFontGetRevisionFlags(revisionFlags); - - return cellFontInitializeWithRevision(revisionFlags.value(), config); -} - s32 cellFontEnd() { cellFont.Warning("cellFontEnd()"); @@ -632,11 +621,176 @@ s32 cellFontGetCharGlyphMetricsVertical() return CELL_OK; } +s32 cellFontGetRenderEffectWeight() +{ + throw EXCEPTION(""); +} + +s32 cellFontGraphicsGetDrawType() +{ + throw EXCEPTION(""); +} + +s32 cellFontGetKerning() +{ + throw EXCEPTION(""); +} + +s32 cellFontGetRenderScaledKerning() +{ + throw EXCEPTION(""); +} + +s32 cellFontGetRenderScalePixel() +{ + throw EXCEPTION(""); +} + +s32 cellFontGlyphGetScalePixel() +{ + throw EXCEPTION(""); +} + +s32 cellFontGlyphGetHorizontalShift() +{ + throw EXCEPTION(""); +} + +s32 cellFontRenderCharGlyphImageHorizontal() +{ + throw EXCEPTION(""); +} + +s32 cellFontGetEffectWeight() +{ + throw EXCEPTION(""); +} + +s32 cellFontGetScalePixel() +{ + throw EXCEPTION(""); +} + +s32 cellFontClearFileCache() +{ + throw EXCEPTION(""); +} + +s32 cellFontAdjustFontScaling() +{ + throw EXCEPTION(""); +} + +s32 cellFontSetupRenderScalePoint() +{ + throw EXCEPTION(""); +} + +s32 cellFontGlyphGetVerticalShift() +{ + throw EXCEPTION(""); +} + +s32 cellFontGetGlyphExpandBufferInfo() +{ + throw EXCEPTION(""); +} + +s32 cellFontGetLibrary() +{ + throw EXCEPTION(""); +} + +s32 cellFontVertexesGlyphRelocate() +{ + throw EXCEPTION(""); +} + +s32 cellFontGetInitializedRevisionFlags() +{ + throw EXCEPTION(""); +} + +s32 cellFontGetResolutionDpi() +{ + throw EXCEPTION(""); +} + +s32 cellFontGlyphRenderImageVertical() +{ + throw EXCEPTION(""); +} + +s32 cellFontGlyphRenderImageHorizontal() +{ + throw EXCEPTION(""); +} + +s32 cellFontAdjustGlyphExpandBuffer() +{ + throw EXCEPTION(""); +} + +s32 cellFontGetRenderScalePoint() +{ + throw EXCEPTION(""); +} + +s32 cellFontGraphicsGetFontRGBA() +{ + throw EXCEPTION(""); +} + +s32 cellFontGlyphGetOutlineVertexes() +{ + throw EXCEPTION(""); +} + +s32 cellFontDelete() +{ + throw EXCEPTION(""); +} + +s32 cellFontPatchWorks() +{ + throw EXCEPTION(""); +} + +s32 cellFontGlyphRenderImage() +{ + throw EXCEPTION(""); +} + +s32 cellFontGetBindingRenderer() +{ + throw EXCEPTION(""); +} + +s32 cellFontGenerateCharGlyphVertical() +{ + throw EXCEPTION(""); +} + +s32 cellFontGetRenderEffectSlant() +{ + throw EXCEPTION(""); +} + +s32 cellFontGetScalePoint() +{ + throw EXCEPTION(""); +} + +s32 cellFontGraphicsGetLineRGBA() +{ + throw EXCEPTION(""); +} + + Module cellFont("cellFont", []() { g_font.init = false; - REG_FUNC(cellFont, cellFontInit); REG_FUNC(cellFont, cellFontSetFontsetOpenMode); REG_FUNC(cellFont, cellFontSetFontOpenMode); REG_FUNC(cellFont, cellFontCreateRenderer); @@ -685,5 +839,38 @@ Module cellFont("cellFont", []() REG_FUNC(cellFont, cellFontSetResolutionDpi); REG_FUNC(cellFont, cellFontGetCharGlyphMetricsVertical); REG_FUNC(cellFont, cellFontUnbindRenderer); - REG_FUNC(cellFont, cellFontGetRevisionFlags); + REG_FUNC(cellFont, cellFontGetRevisionFlags); + REG_FUNC(cellFont, cellFontGetRenderEffectWeight); + REG_FUNC(cellFont, cellFontGraphicsGetDrawType); + REG_FUNC(cellFont, cellFontGetKerning); + REG_FUNC(cellFont, cellFontGetRenderScaledKerning); + REG_FUNC(cellFont, cellFontGetRenderScalePixel); + REG_FUNC(cellFont, cellFontGlyphGetScalePixel); + REG_FUNC(cellFont, cellFontGlyphGetHorizontalShift); + REG_FUNC(cellFont, cellFontRenderCharGlyphImageHorizontal); + REG_FUNC(cellFont, cellFontGetEffectWeight); + REG_FUNC(cellFont, cellFontGetScalePixel); + REG_FUNC(cellFont, cellFontClearFileCache); + REG_FUNC(cellFont, cellFontAdjustFontScaling); + REG_FUNC(cellFont, cellFontSetupRenderScalePoint); + REG_FUNC(cellFont, cellFontGlyphGetVerticalShift); + REG_FUNC(cellFont, cellFontGetGlyphExpandBufferInfo); + REG_FUNC(cellFont, cellFontGetLibrary); + REG_FUNC(cellFont, cellFontVertexesGlyphRelocate); + REG_FUNC(cellFont, cellFontGetInitializedRevisionFlags); + REG_FUNC(cellFont, cellFontGetResolutionDpi); + REG_FUNC(cellFont, cellFontGlyphRenderImageVertical); + REG_FUNC(cellFont, cellFontGlyphRenderImageHorizontal); + REG_FUNC(cellFont, cellFontAdjustGlyphExpandBuffer); + REG_FUNC(cellFont, cellFontGetRenderScalePoint); + REG_FUNC(cellFont, cellFontGraphicsGetFontRGBA); + REG_FUNC(cellFont, cellFontGlyphGetOutlineVertexes); + REG_FUNC(cellFont, cellFontDelete); + REG_FUNC(cellFont, cellFontPatchWorks); + REG_FUNC(cellFont, cellFontGlyphRenderImage); + REG_FUNC(cellFont, cellFontGetBindingRenderer); + REG_FUNC(cellFont, cellFontGenerateCharGlyphVertical); + REG_FUNC(cellFont, cellFontGetRenderEffectSlant); + REG_FUNC(cellFont, cellFontGetScalePoint); + REG_FUNC(cellFont, cellFontGraphicsGetLineRGBA); }); diff --git a/rpcs3/Emu/SysCalls/Modules/cellFs.cpp b/rpcs3/Emu/SysCalls/Modules/cellFs.cpp index 478c7c80c6..88466404ae 100644 --- a/rpcs3/Emu/SysCalls/Modules/cellFs.cpp +++ b/rpcs3/Emu/SysCalls/Modules/cellFs.cpp @@ -978,6 +978,72 @@ s32 cellFsSetIoBufferFromDefaultContainer(u32 fd, u32 buffer_size, u32 page_type return CELL_OK; } +s32 cellFsUtime() +{ + throw EXCEPTION(""); +} + +s32 cellFsArcadeHddSerialNumber() +{ + throw EXCEPTION(""); +} + +s32 cellFsAllocateFileAreaWithInitialData() +{ + throw EXCEPTION(""); +} + +s32 cellFsAllocateFileAreaByFdWithoutZeroFill() +{ + throw EXCEPTION(""); +} + +s32 cellFsSetIoBuffer() +{ + throw EXCEPTION(""); +} + +s32 cellFsAllocateFileAreaByFdWithInitialData() +{ + throw EXCEPTION(""); +} + +s32 cellFsTruncate2() +{ + throw EXCEPTION(""); +} + +s32 cellFsChangeFileSizeWithoutAllocation() +{ + throw EXCEPTION(""); +} + +s32 cellFsAllocateFileAreaWithoutZeroFill() +{ + throw EXCEPTION(""); +} + +s32 cellFsChangeFileSizeByFdWithoutAllocation() +{ + throw EXCEPTION(""); +} + +s32 cellFsSetDiscReadRetrySetting() +{ + throw EXCEPTION(""); +} + +s32 cellFsRegisterConversionCallback() +{ + throw EXCEPTION(""); +} + +s32 cellFsUnregisterL10nCallbacks() +{ + throw EXCEPTION(""); +} + + Module cellFs("cellFs", []() { g_fs_aio_id = 1; @@ -1027,4 +1093,17 @@ Module cellFs("cellFs", []() REG_FUNC(cellFs, cellFsStReadWaitCallback); REG_FUNC(cellFs, cellFsSetDefaultContainer); REG_FUNC(cellFs, cellFsSetIoBufferFromDefaultContainer); + REG_FUNC(cellFs, cellFsUtime); + REG_FUNC(cellFs, cellFsArcadeHddSerialNumber); + REG_FUNC(cellFs, cellFsAllocateFileAreaWithInitialData); + REG_FUNC(cellFs, cellFsAllocateFileAreaByFdWithoutZeroFill); + REG_FUNC(cellFs, cellFsSetIoBuffer); + REG_FUNC(cellFs, cellFsAllocateFileAreaByFdWithInitialData); + REG_FUNC(cellFs, cellFsTruncate2); + REG_FUNC(cellFs, cellFsChangeFileSizeWithoutAllocation); + REG_FUNC(cellFs, cellFsAllocateFileAreaWithoutZeroFill); + REG_FUNC(cellFs, cellFsChangeFileSizeByFdWithoutAllocation); + REG_FUNC(cellFs, cellFsSetDiscReadRetrySetting); + REG_FUNC(cellFs, cellFsRegisterConversionCallback); + REG_FUNC(cellFs, cellFsUnregisterL10nCallbacks); }); diff --git a/rpcs3/Emu/SysCalls/Modules/cellGcmSys.cpp b/rpcs3/Emu/SysCalls/Modules/cellGcmSys.cpp index e4b4cf1ffc..c3c3768147 100644 --- a/rpcs3/Emu/SysCalls/Modules/cellGcmSys.cpp +++ b/rpcs3/Emu/SysCalls/Modules/cellGcmSys.cpp @@ -588,6 +588,11 @@ void cellGcmSetUserHandler(vm::ptr handler) Emu.GetGSManager().GetRender().m_user_handler = handler; } +s32 cellGcmSetUserCommand() +{ + throw EXCEPTION(""); +} + void cellGcmSetVBlankHandler(vm::ptr handler) { cellGcmSys.Warning("cellGcmSetVBlankHandler(handler=*0x%x)", handler); @@ -604,6 +609,11 @@ s32 cellGcmSetWaitFlip(vm::ptr ctxt) return CELL_OK; } +s32 cellGcmSetWaitFlipUnsafe() +{ + throw EXCEPTION(""); +} + s32 cellGcmSetZcull(u8 index, u32 offset, u32 width, u32 height, u32 cullStart, u32 zFormat, u32 aaFormat, u32 zCullDir, u32 zCullFormat, u32 sFunc, u32 sRef, u32 sMask) { cellGcmSys.Todo("cellGcmSetZcull(index=%d, offset=0x%x, width=%d, height=%d, cullStart=0x%x, zFormat=0x%x, aaFormat=0x%x, zCullDir=0x%x, zCullFormat=0x%x, sFunc=0x%x, sRef=0x%x, sMask=0x%x)", @@ -702,6 +712,11 @@ s32 cellGcmSetInvalidateTile() return CELL_OK; } +s32 cellGcmTerminate() +{ + throw EXCEPTION(""); +} + s32 cellGcmDumpGraphicsError() { UNIMPLEMENTED_FUNC(cellGcmSys); @@ -734,6 +749,11 @@ u64 cellGcmGetVBlankCount() return Emu.GetGSManager().GetRender().m_vblank_count; } +s32 cellGcmSysGetLastVBlankTime() +{ + throw EXCEPTION(""); +} + s32 cellGcmInitSystemMode(u64 mode) { cellGcmSys.Log("cellGcmInitSystemMode(mode=0x%x)", mode); @@ -1085,6 +1105,11 @@ void cellGcmSetDefaultCommandBuffer() vm::write32(Emu.GetGSManager().GetRender().m_ctxt_addr, gcm_info.context_addr); } +s32 cellGcmSetDefaultCommandBufferAndSegmentWordSize() +{ + throw EXCEPTION(""); +} + //------------------------------------------------------------------------ // Other //------------------------------------------------------------------------ @@ -1147,6 +1172,47 @@ s32 cellGcmSetTile(u8 index, u8 location, u32 offset, u32 size, u32 pitch, u8 co return CELL_OK; } +s32 _cellGcmFunc2() +{ + throw EXCEPTION(""); +} + +s32 _cellGcmFunc3() +{ + throw EXCEPTION(""); +} + +s32 _cellGcmFunc4() +{ + throw EXCEPTION(""); +} + +s32 _cellGcmFunc13() +{ + throw EXCEPTION(""); +} + +s32 _cellGcmFunc38() +{ + throw EXCEPTION(""); +} + +s32 cellGcmGpadGetStatus() +{ + throw EXCEPTION(""); +} + +s32 cellGcmGpadNotifyCaptureSurface() +{ + throw EXCEPTION(""); +} + +s32 cellGcmGpadCaptureSnapshot() +{ + throw EXCEPTION(""); +} + + //---------------------------------------------------------------------------- @@ -1250,12 +1316,6 @@ Module cellGcmSys("cellGcmSys", []() REG_FUNC(cellGcmSys, cellGcmGetDefaultSegmentWordSize); REG_FUNC(cellGcmSys, cellGcmInitDefaultFifoMode); REG_FUNC(cellGcmSys, cellGcmSetDefaultFifoSize); - //cellGcmSys.AddFunc(, cellGcmReserveMethodSize); - //cellGcmSys.AddFunc(, cellGcmResetDefaultCommandBuffer); - //cellGcmSys.AddFunc(, cellGcmSetupContextData); - //cellGcmSys.AddFunc(, cellGcmCallbackForSnc); - //cellGcmSys.AddFunc(, cellGcmFinish); - //cellGcmSys.AddFunc(, cellGcmFlush); // Hardware Resource Management REG_FUNC(cellGcmSys, cellGcmBindTile); @@ -1268,6 +1328,7 @@ Module cellGcmSys("cellGcmSys", []() REG_FUNC(cellGcmSys, cellGcmGetLastSecondVTime); REG_FUNC(cellGcmSys, cellGcmGetTiledPitchSize); REG_FUNC(cellGcmSys, cellGcmGetVBlankCount); + REG_FUNC(cellGcmSys, cellGcmSysGetLastVBlankTime); REG_FUNC(cellGcmSys, _cellGcmFunc1); REG_FUNC(cellGcmSys, _cellGcmFunc15); REG_FUNC(cellGcmSys, _cellGcmInitBody); @@ -1275,7 +1336,7 @@ Module cellGcmSys("cellGcmSys", []() REG_FUNC(cellGcmSys, cellGcmResetFlipStatus); REG_FUNC(cellGcmSys, cellGcmSetDebugOutputLevel); REG_FUNC(cellGcmSys, cellGcmSetDisplayBuffer); - REG_FUNC(cellGcmSys, cellGcmSetFlip); + REG_FUNC(cellGcmSys, cellGcmSetFlip); // REG_FUNC(cellGcmSys, cellGcmSetFlipHandler); REG_FUNC(cellGcmSys, cellGcmSetFlipImmediate); REG_FUNC(cellGcmSys, cellGcmSetFlipMode); @@ -1287,9 +1348,11 @@ Module cellGcmSys("cellGcmSys", []() REG_FUNC(cellGcmSys, cellGcmSetSecondVHandler); REG_FUNC(cellGcmSys, cellGcmSetTileInfo); REG_FUNC(cellGcmSys, cellGcmSetUserHandler); + REG_FUNC(cellGcmSys, cellGcmSetUserCommand); // REG_FUNC(cellGcmSys, cellGcmSetVBlankFrequency); REG_FUNC(cellGcmSys, cellGcmSetVBlankHandler); - REG_FUNC(cellGcmSys, cellGcmSetWaitFlip); + REG_FUNC(cellGcmSys, cellGcmSetWaitFlip); // + REG_FUNC(cellGcmSys, cellGcmSetWaitFlipUnsafe); // REG_FUNC(cellGcmSys, cellGcmSetZcull); REG_FUNC(cellGcmSys, cellGcmSortRemapEaIoAddress); REG_FUNC(cellGcmSys, cellGcmUnbindTile); @@ -1299,7 +1362,7 @@ Module cellGcmSys("cellGcmSys", []() REG_FUNC(cellGcmSys, cellGcmGetDisplayInfo); REG_FUNC(cellGcmSys, cellGcmGetCurrentDisplayBufferId); REG_FUNC(cellGcmSys, cellGcmSetInvalidateTile); - //cellGcmSys.AddFunc(, cellGcmSetFlipWithWaitLabel); + REG_FUNC(cellGcmSys, cellGcmTerminate); // Memory Mapping REG_FUNC(cellGcmSys, cellGcmAddressToOffset); @@ -1325,13 +1388,20 @@ Module cellGcmSys("cellGcmSys", []() // Functions for Maintaining Compatibility REG_FUNC(cellGcmSys, cellGcmSetDefaultCommandBuffer); - //cellGcmSys.AddFunc(, cellGcmGetCurrentBuffer); - //cellGcmSys.AddFunc(, cellGcmSetCurrentBuffer); - //cellGcmSys.AddFunc(, cellGcmSetDefaultCommandBufferAndSegmentWordSize); - //cellGcmSys.AddFunc(, cellGcmSetUserCallback); + REG_FUNC(cellGcmSys, cellGcmSetDefaultCommandBufferAndSegmentWordSize); // Other REG_FUNC(cellGcmSys, _cellGcmSetFlipCommand); REG_FUNC(cellGcmSys, _cellGcmSetFlipCommandWithWaitLabel); REG_FUNC(cellGcmSys, cellGcmSetTile); + REG_FUNC(cellGcmSys, _cellGcmFunc2); + REG_FUNC(cellGcmSys, _cellGcmFunc3); + REG_FUNC(cellGcmSys, _cellGcmFunc4); + REG_FUNC(cellGcmSys, _cellGcmFunc13); + REG_FUNC(cellGcmSys, _cellGcmFunc38); + + // GPAD + REG_FUNC(cellGcmSys, cellGcmGpadGetStatus); + REG_FUNC(cellGcmSys, cellGcmGpadNotifyCaptureSurface); + REG_FUNC(cellGcmSys, cellGcmGpadCaptureSnapshot); });