diff --git a/rpcs3/Emu/Cell/SPURecompiler.h b/rpcs3/Emu/Cell/SPURecompiler.h index 82c2c287f6..ee7cd7d883 100644 --- a/rpcs3/Emu/Cell/SPURecompiler.h +++ b/rpcs3/Emu/Cell/SPURecompiler.h @@ -631,7 +631,7 @@ private: } LOG_OPCODE(); } - void ROTH(u32 rt, u32 ra, u32 rb) + void ROTH(u32 rt, u32 ra, u32 rb) //nf { XmmInvalidate(rt); for (u32 i = 0; i < 8; i++) @@ -3472,6 +3472,16 @@ private: } WRAPPER_END(rc, rt, ra, rb);*/ + // hypothetical AVX-512 implementation: + // VPXORD mask, rc, [byte:0x0f] // 15 - rc (only for index bits) + // VPSHUFB res {k0}, ra, mask + // VPTESTMB k1 {k0}, rc, [byte:0x10] + // VPSHUFB res {k1}, rb, mask + // VPCMPNLTUB k1 {k0}, mask, [byte:0xc0] + // VPADDB res {k1}, res, [byte:0xff] + // VPCMPNLTUB k1 {k1}, mask, [byte:0xe0] + // VPSUBB res {k1}, res, [byte:0x7f] + const XmmLink& v0 = XmmGet(rc); // v0 = mask const XmmLink& v1 = XmmAlloc(); const XmmLink& v2 = XmmCopy(v0); // v2 = mask diff --git a/rpcs3/Emu/SysCalls/Modules/cellAdec.cpp b/rpcs3/Emu/SysCalls/Modules/cellAdec.cpp index 64774cc762..28605b2ee7 100644 --- a/rpcs3/Emu/SysCalls/Modules/cellAdec.cpp +++ b/rpcs3/Emu/SysCalls/Modules/cellAdec.cpp @@ -27,7 +27,6 @@ AudioDecoder::AudioDecoder(AudioCodecType type, u32 addr, u32 size, vm::ptrWarning("adecEndSeq:"); adec.cbFunc.call(*adec.adecCb, adec.id, CELL_ADEC_MSG_TYPE_SEQDONE, CELL_OK, adec.cbArg); - adec.is_running = false; adec.just_finished = true; } break; @@ -722,7 +719,7 @@ int cellAdecGetPcm(u32 handle, vm::ptr outBuffer) AdecFrame af; if (!adec->frames.Pop(af, &sq_no_wait)) { - std::this_thread::sleep_for(std::chrono::milliseconds(1)); // hack + //std::this_thread::sleep_for(std::chrono::milliseconds(1)); // hack return CELL_ADEC_ERROR_EMPTY; } @@ -765,7 +762,7 @@ int cellAdecGetPcmItem(u32 handle, vm::ptr pcmItem_ptr) AdecFrame af; if (!adec->frames.Peek(af, &sq_no_wait)) { - std::this_thread::sleep_for(std::chrono::milliseconds(1)); // hack + //std::this_thread::sleep_for(std::chrono::milliseconds(1)); // hack return CELL_ADEC_ERROR_EMPTY; } diff --git a/rpcs3/Emu/SysCalls/Modules/cellAdec.h b/rpcs3/Emu/SysCalls/Modules/cellAdec.h index f751f0cfba..7249fd411e 100644 --- a/rpcs3/Emu/SysCalls/Modules/cellAdec.h +++ b/rpcs3/Emu/SysCalls/Modules/cellAdec.h @@ -1073,7 +1073,6 @@ class AudioDecoder public: SQueue job; u32 id; - volatile bool is_running; volatile bool is_closed; volatile bool is_finished; bool just_started; diff --git a/rpcs3/Emu/SysCalls/Modules/cellDmux.cpp b/rpcs3/Emu/SysCalls/Modules/cellDmux.cpp index dccb5c3d74..0c8704c934 100644 --- a/rpcs3/Emu/SysCalls/Modules/cellDmux.cpp +++ b/rpcs3/Emu/SysCalls/Modules/cellDmux.cpp @@ -326,7 +326,7 @@ u32 dmuxOpen(Demuxer* data) cellDmux->Notice("Demuxer thread started (mem=0x%x, size=0x%x, cb=0x%x, arg=0x%x)", dmux.memAddr, dmux.memSize, dmux.cbFunc, dmux.cbArg); DemuxerTask task; - DemuxerStream stream; + DemuxerStream stream = {}; ElementaryStream* esALL[192]; memset(esALL, 0, sizeof(esALL)); ElementaryStream** esAVC = &esALL[0]; // AVC (max 16) ElementaryStream** esM2V = &esALL[16]; // MPEG-2 (max 16) @@ -337,9 +337,6 @@ u32 dmuxOpen(Demuxer* data) u32 cb_add = 0; - u32 updates_count = 0; - u32 updates_signaled = 0; - while (true) { if (Emu.IsStopped() || dmux.is_closed) @@ -347,7 +344,7 @@ u32 dmuxOpen(Demuxer* data) break; } - if (!dmux.job.Peek(task, &sq_no_wait) && dmux.is_running) + if (!dmux.job.Peek(task, &sq_no_wait) && dmux.is_running && stream.addr) { // default task (demuxing) (if there is no other work) be_t code; @@ -356,14 +353,13 @@ u32 dmuxOpen(Demuxer* data) if (!stream.peek(code)) { - dmux.is_running = false; // demuxing finished auto dmuxMsg = vm::ptr::make(a128(dmux.memAddr) + (cb_add ^= 16)); dmuxMsg->msgType = CELL_DMUX_MSG_TYPE_DEMUX_DONE; dmuxMsg->supplementalInfo = stream.userdata; dmux.cbFunc.call(*dmux.dmuxCb, dmux.id, dmuxMsg, dmux.cbArg); - updates_signaled++; + dmux.is_running = false; } else switch (code.ToLE()) { @@ -425,13 +421,6 @@ u32 dmuxOpen(Demuxer* data) continue; } - /*if (es.hasunseen()) // hack, probably useless - { - stream = backup; - std::this_thread::sleep_for(std::chrono::milliseconds(1)); - continue; - }*/ - stream.skip(4); len -= 4; @@ -480,12 +469,6 @@ u32 dmuxOpen(Demuxer* data) if (pes.new_au && es.hasdata()) // new AU detected { - /*if (es.hasunseen()) // hack, probably useless - { - stream = backup; - std::this_thread::sleep_for(std::chrono::milliseconds(1)); - continue; - }*/ es.finish(stream); // callback auto esMsg = vm::ptr::make(a128(dmux.memAddr) + (cb_add ^= 16)); @@ -572,24 +555,11 @@ u32 dmuxOpen(Demuxer* data) esALL[i]->reset(); } } - updates_count = 0; - updates_signaled = 0; } - if (updates_count != updates_signaled) - { - cellDmux->Error("dmuxSetStream: stream update inconsistency (input=%d, signaled=%d)", updates_count, updates_signaled); - Emu.Pause(); - return; - } - - updates_count++; stream = task.stream; //LOG_NOTICE(HLE, "*** stream updated(addr=0x%x, size=0x%x, discont=%d, userdata=0x%llx)", //stream.addr, stream.size, stream.discontinuity, stream.userdata); - - dmux.is_running = true; - dmux.fbSetStream.Push(task.stream.addr, &dmux.is_closed); // feedback } break; @@ -601,12 +571,11 @@ u32 dmuxOpen(Demuxer* data) dmuxMsg->supplementalInfo = stream.userdata; dmux.cbFunc.call(*dmux.dmuxCb, dmux.id, dmuxMsg, dmux.cbArg); - updates_signaled++; + stream = {}; dmux.is_running = false; - if (task.type == dmuxResetStreamAndWaitDone) - { - dmux.fbSetStream.Push(0, &dmux.is_closed); - } + //if (task.type == dmuxResetStreamAndWaitDone) + //{ + //} } break; @@ -825,14 +794,9 @@ int cellDmuxSetStream(u32 demuxerHandle, const u32 streamAddress, u32 streamSize return CELL_DMUX_ERROR_ARG; } - if (dmux->is_running) + if (dmux->is_running.exchange(true)) { - if (Emu.IsStopped()) - { - cellDmux->Warning("cellDmuxSetStream(%d) aborted (waiting)", demuxerHandle); - return CELL_OK; - } - std::this_thread::sleep_for(std::chrono::milliseconds(1)); + //std::this_thread::sleep_for(std::chrono::milliseconds(1)); // hack return CELL_DMUX_ERROR_BUSY; } @@ -844,18 +808,6 @@ int cellDmuxSetStream(u32 demuxerHandle, const u32 streamAddress, u32 streamSize info.userdata = userData; dmux->job.Push(task, &dmux->is_closed); - - u32 addr; - if (!dmux->fbSetStream.Pop(addr, &dmux->is_closed)) - { - cellDmux->Warning("cellDmuxSetStream(%d) aborted (fbSetStream.Pop())", demuxerHandle); - return CELL_OK; - } - if (addr != info.addr) - { - cellDmux->Error("cellDmuxSetStream(%d): wrong stream queued (right=0x%x, queued=0x%x)", demuxerHandle, info.addr, addr); - Emu.Pause(); - } return CELL_OK; } @@ -870,7 +822,6 @@ int cellDmuxResetStream(u32 demuxerHandle) } dmux->job.Push(DemuxerTask(dmuxResetStream), &dmux->is_closed); - return CELL_OK; } @@ -885,17 +836,14 @@ int cellDmuxResetStreamAndWaitDone(u32 demuxerHandle) } dmux->job.Push(DemuxerTask(dmuxResetStreamAndWaitDone), &dmux->is_closed); - - u32 addr; - if (!dmux->fbSetStream.Pop(addr, &dmux->is_closed)) + while (dmux->is_running && !dmux->is_closed) // TODO: ensure that it is safe { - cellDmux->Warning("cellDmuxResetStreamAndWaitDone(%d) aborted (fbSetStream.Pop())", demuxerHandle); - return CELL_OK; - } - if (addr != 0) - { - cellDmux->Error("cellDmuxResetStreamAndWaitDone(%d): wrong stream queued (0x%x)", demuxerHandle, addr); - Emu.Pause(); + if (Emu.IsStopped()) + { + cellDmux->Warning("cellDmuxResetStreamAndWaitDone(%d) aborted", demuxerHandle); + return CELL_OK; + } + std::this_thread::sleep_for(std::chrono::milliseconds(1)); } return CELL_OK; } @@ -912,7 +860,6 @@ int cellDmuxQueryEsAttr(vm::ptr demuxerType, vm::ptr demuxerType2, vm::ptrstreamSpecificInfo_addr, esFilterId, esSpecificInfo_addr, esAttr); return CELL_OK; } diff --git a/rpcs3/Emu/SysCalls/Modules/cellDmux.h b/rpcs3/Emu/SysCalls/Modules/cellDmux.h index 053a776d5d..0eca5daef0 100644 --- a/rpcs3/Emu/SysCalls/Modules/cellDmux.h +++ b/rpcs3/Emu/SysCalls/Modules/cellDmux.h @@ -408,7 +408,6 @@ class Demuxer { public: SQueue job; - SQueue fbSetStream; const u32 memAddr; const u32 memSize; const vm::ptr cbFunc; @@ -416,7 +415,7 @@ public: u32 id; volatile bool is_finished; volatile bool is_closed; - volatile bool is_running; + std::atomic is_running; PPUThread* dmuxCb; diff --git a/rpcs3/Emu/SysCalls/Modules/cellVdec.cpp b/rpcs3/Emu/SysCalls/Modules/cellVdec.cpp index b2751d7561..55f4b9c2ec 100644 --- a/rpcs3/Emu/SysCalls/Modules/cellVdec.cpp +++ b/rpcs3/Emu/SysCalls/Modules/cellVdec.cpp @@ -29,7 +29,6 @@ VideoDecoder::VideoDecoder(CellVdecCodecType type, u32 profile, u32 addr, u32 si , cbArg(arg) , is_finished(false) , is_closed(false) - , is_running(false) , just_started(false) , just_finished(false) , ctx(nullptr) @@ -225,9 +224,7 @@ u32 vdecOpen(VideoDecoder* data) // TODO: reset data cellVdec->Warning("vdecStartSeq:"); - vdec.reader.addr = 0; - vdec.reader.size = 0; - vdec.is_running = true; + vdec.reader = {}; vdec.just_started = true; } break; @@ -239,7 +236,6 @@ u32 vdecOpen(VideoDecoder* data) vdec.cbFunc.call(*vdec.vdecCb, vdec.id, CELL_VDEC_MSG_TYPE_SEQDONE, CELL_OK, vdec.cbArg); - vdec.is_running = false; vdec.just_finished = true; } break; @@ -595,7 +591,7 @@ int cellVdecGetPicture(u32 handle, vm::ptr format, vm:: VdecFrame vf; if (!vdec->frames.Pop(vf, &sq_no_wait)) { - std::this_thread::sleep_for(std::chrono::milliseconds(1)); // hack + //std::this_thread::sleep_for(std::chrono::milliseconds(1)); // hack return CELL_VDEC_ERROR_EMPTY; } @@ -651,7 +647,7 @@ int cellVdecGetPicItem(u32 handle, vm::ptr picItem_ptr) VdecFrame vf; if (!vdec->frames.Peek(vf, &sq_no_wait)) { - std::this_thread::sleep_for(std::chrono::milliseconds(1)); // hack + //std::this_thread::sleep_for(std::chrono::milliseconds(1)); // hack return CELL_VDEC_ERROR_EMPTY; } diff --git a/rpcs3/Emu/SysCalls/Modules/cellVdec.h b/rpcs3/Emu/SysCalls/Modules/cellVdec.h index 5a6c276636..144c0766ad 100644 --- a/rpcs3/Emu/SysCalls/Modules/cellVdec.h +++ b/rpcs3/Emu/SysCalls/Modules/cellVdec.h @@ -694,7 +694,6 @@ class VideoDecoder public: SQueue job; u32 id; - volatile bool is_running; volatile bool is_closed; volatile bool is_finished; bool just_started;