mirror of
https://github.com/RPCSX/rpcsx.git
synced 2026-04-04 14:08:37 +00:00
moved tsc and asm utilities to rx
This commit is contained in:
parent
bd215fab92
commit
640df36c48
121 changed files with 706 additions and 1225 deletions
|
|
@ -1,4 +1,6 @@
|
|||
#include "stdafx.h"
|
||||
|
||||
#include "rx/align.hpp"
|
||||
#include "Emu/perf_meter.hpp"
|
||||
#include "Emu/Cell/PPUModule.h"
|
||||
#include "cellos/sys_sync.h"
|
||||
|
|
@ -9,7 +11,7 @@
|
|||
#include "cellAdec.h"
|
||||
|
||||
#include "util/simd.hpp"
|
||||
#include "util/asm.hpp"
|
||||
#include "rx/asm.hpp"
|
||||
|
||||
LOG_CHANNEL(cellAdec);
|
||||
|
||||
|
|
@ -415,7 +417,7 @@ void LpcmDecContext::exec(ppu_thread& ppu)
|
|||
be_t<f32>* const _output = std::assume_aligned<0x80>(output.get_ptr());
|
||||
s64 output_size = cmd.au_size;
|
||||
|
||||
s32 sample_num = static_cast<s32>(utils::align(+lpcm_param->audioPayloadSize, 0x10));
|
||||
s32 sample_num = static_cast<s32>(rx::alignUp(+lpcm_param->audioPayloadSize, 0x10));
|
||||
s32 channel_num = 0;
|
||||
|
||||
if (!dvd_packing)
|
||||
|
|
@ -860,11 +862,11 @@ error_code _CellAdecCoreOpGetMemSize_lpcm(vm::ptr<CellAdecAttr> attr)
|
|||
cellAdec.notice("_CellAdecCoreOpGetMemSize_lpcm(attr=*0x%x)", attr);
|
||||
|
||||
constexpr u32 mem_size =
|
||||
utils::align(static_cast<u32>(sizeof(LpcmDecContext)), 0x80) + utils::align(static_cast<u32>(sizeof(CellAdecParamLpcm)), 0x80) + 0x100 // Command data for Spurs task
|
||||
+ LPCM_DEC_OUTPUT_BUFFER_SIZE + 0x2900 // sizeof(CellSpurs) + sizeof(CellSpursTaskset)
|
||||
+ 0x3b400 // Spurs context
|
||||
+ 0x300 // (sizeof(CellSpursQueue) + 0x80 + queue buffer) * 2
|
||||
+ 0x855; // Unused
|
||||
rx::alignUp(static_cast<u32>(sizeof(LpcmDecContext)), 0x80) + rx::alignUp(static_cast<u32>(sizeof(CellAdecParamLpcm)), 0x80) + 0x100 // Command data for Spurs task
|
||||
+ LPCM_DEC_OUTPUT_BUFFER_SIZE + 0x2900 // sizeof(CellSpurs) + sizeof(CellSpursTaskset)
|
||||
+ 0x3b400 // Spurs context
|
||||
+ 0x300 // (sizeof(CellSpursQueue) + 0x80 + queue buffer) * 2
|
||||
+ 0x855; // Unused
|
||||
|
||||
static_assert(mem_size == 0x7ebd5);
|
||||
|
||||
|
|
@ -883,7 +885,7 @@ error_code _CellAdecCoreOpOpenExt_lpcm(ppu_thread& ppu, vm::ptr<LpcmDecContext>
|
|||
ensure(handle.aligned(0x80)); // LLE doesn't check the alignment or aligns the address itself
|
||||
ensure(!!notifyAuDone && !!notifyAuDoneArg && !!notifyPcmOut && !!notifyPcmOutArg && !!notifyError && !!notifyErrorArg && !!notifySeqDone && !!notifySeqDoneArg); // These should always be set
|
||||
|
||||
const u32 end_of_context_addr = handle.addr() + utils::align(static_cast<u32>(sizeof(LpcmDecContext)), 0x80);
|
||||
const u32 end_of_context_addr = handle.addr() + rx::alignUp(static_cast<u32>(sizeof(LpcmDecContext)), 0x80);
|
||||
|
||||
handle->cmd_queue.front = 0;
|
||||
handle->cmd_queue.back = 0;
|
||||
|
|
@ -1587,10 +1589,10 @@ error_code adecOpen(ppu_thread& ppu, vm::ptr<CellAdecType> type, vm::cptr<CellAd
|
|||
const s32 pcm_handle_num = core_ops->getPcmHandleNum(ppu);
|
||||
const u32 bitstream_info_size = core_ops->getBsiInfoSize(ppu);
|
||||
|
||||
const auto _this = vm::ptr<AdecContext>::make(utils::align(+res->startAddr, 0x80));
|
||||
const auto _this = vm::ptr<AdecContext>::make(rx::alignUp(+res->startAddr, 0x80));
|
||||
const auto frames = vm::ptr<AdecFrame>::make(_this.addr() + sizeof(AdecContext));
|
||||
const u32 bitstream_infos_addr = frames.addr() + pcm_handle_num * sizeof(AdecFrame);
|
||||
const auto core_handle = vm::ptr<void>::make(utils::align(bitstream_infos_addr + bitstream_info_size * pcm_handle_num, 0x80));
|
||||
const auto core_handle = vm::ptr<void>::make(rx::alignUp(bitstream_infos_addr + bitstream_info_size * pcm_handle_num, 0x80));
|
||||
|
||||
if (type->audioCodecType == CELL_ADEC_TYPE_LPCM_DVD)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -1,11 +1,13 @@
|
|||
#include "stdafx.h"
|
||||
|
||||
#include "rx/align.hpp"
|
||||
#include "Emu/perf_meter.hpp"
|
||||
#include "Emu/Cell/PPUModule.h"
|
||||
#include "cellos/sys_sync.h"
|
||||
#include "cellos/sys_ppu_thread.h"
|
||||
#include "Emu/savestate_utils.hpp"
|
||||
#include "sysPrxForUser.h"
|
||||
#include "util/asm.hpp"
|
||||
#include "rx/asm.hpp"
|
||||
#include "util/media_utils.h"
|
||||
|
||||
#include "cellAtracXdec.h"
|
||||
|
|
@ -182,7 +184,7 @@ error_code AtracXdecDecoder::set_config_info(u32 sampling_freq, u32 ch_config_id
|
|||
this->sampling_freq = sampling_freq;
|
||||
this->ch_config_idx = ch_config_idx;
|
||||
this->nbytes = nbytes;
|
||||
this->nbytes_128_aligned = utils::align(nbytes, 0x80);
|
||||
this->nbytes_128_aligned = rx::alignUp(nbytes, 0x80);
|
||||
this->nch_in = ch_config_idx <= 4 ? ch_config_idx : ch_config_idx + 1;
|
||||
|
||||
if (ch_config_idx > 7u)
|
||||
|
|
@ -741,7 +743,7 @@ error_code _CellAdecCoreOpGetMemSize_atracx(vm::ptr<CellAdecAttr> attr)
|
|||
constexpr u32 mem_size =
|
||||
sizeof(AtracXdecContext) + 0x7f + ATXDEC_SPURS_STRUCTS_SIZE + 0x1d8 + atracXdecGetSpursMemSize(nch_in) + ATXDEC_SAMPLES_PER_FRAME * sizeof(f32) * nch_in;
|
||||
|
||||
attr->workMemSize = utils::align(mem_size, 0x80);
|
||||
attr->workMemSize = rx::alignUp(mem_size, 0x80);
|
||||
|
||||
return CELL_OK;
|
||||
}
|
||||
|
|
@ -765,7 +767,7 @@ error_code _CellAdecCoreOpOpenExt_atracx(ppu_thread& ppu, vm::ptr<AtracXdecConte
|
|||
ensure(!!notifyAuDone && !!notifyAuDoneArg && !!notifyPcmOut && !!notifyPcmOutArg && !!notifyError && !!notifyErrorArg && !!notifySeqDone && !!notifySeqDoneArg); // These should always be set by cellAdec
|
||||
|
||||
write_to_ptr(handle.get_ptr(), AtracXdecContext(notifyAuDone, notifyAuDoneArg, notifyPcmOut, notifyPcmOutArg, notifyError, notifyErrorArg, notifySeqDone, notifySeqDoneArg,
|
||||
vm::bptr<u8>::make(handle.addr() + utils::align(static_cast<u32>(sizeof(AtracXdecContext)), 0x80) + ATXDEC_SPURS_STRUCTS_SIZE)));
|
||||
vm::bptr<u8>::make(handle.addr() + rx::alignUp(static_cast<u32>(sizeof(AtracXdecContext)), 0x80) + ATXDEC_SPURS_STRUCTS_SIZE)));
|
||||
|
||||
const vm::var<sys_mutex_attribute_t> mutex_attr{{SYS_SYNC_PRIORITY, SYS_SYNC_NOT_RECURSIVE, SYS_SYNC_NOT_PROCESS_SHARED, SYS_SYNC_NOT_ADAPTIVE, 0, 0, 0, {"_atd001"_u64}}};
|
||||
const vm::var<sys_cond_attribute_t> cond_attr{{SYS_SYNC_NOT_PROCESS_SHARED, 0, 0, {"_atd002"_u64}}};
|
||||
|
|
|
|||
|
|
@ -1,4 +1,6 @@
|
|||
#include "stdafx.h"
|
||||
|
||||
#include "rx/align.hpp"
|
||||
#include "Emu/System.h"
|
||||
#include "Emu/IdManager.h"
|
||||
#include "Emu/Cell/PPUModule.h"
|
||||
|
|
@ -7,7 +9,7 @@
|
|||
#include "cellPamf.h"
|
||||
#include "cellDmux.h"
|
||||
|
||||
#include "util/asm.hpp"
|
||||
#include "rx/asm.hpp"
|
||||
|
||||
#include <thread>
|
||||
|
||||
|
|
@ -765,7 +767,7 @@ PesHeader::PesHeader(DemuxerStream& stream)
|
|||
}
|
||||
|
||||
ElementaryStream::ElementaryStream(Demuxer* dmux, u32 addr, u32 size, u32 fidMajor, u32 fidMinor, u32 sup1, u32 sup2, vm::ptr<CellDmuxCbEsMsg> cbFunc, u32 cbArg, u32 spec)
|
||||
: put(utils::align(addr, 128)), dmux(dmux), memAddr(utils::align(addr, 128)), memSize(size - (addr - memAddr)), fidMajor(fidMajor), fidMinor(fidMinor), sup1(sup1), sup2(sup2), cbFunc(cbFunc), cbArg(cbArg), spec(spec)
|
||||
: put(rx::alignUp(addr, 128)), dmux(dmux), memAddr(rx::alignUp(addr, 128)), memSize(size - (addr - memAddr)), fidMajor(fidMajor), fidMinor(fidMinor), sup1(sup1), sup2(sup2), cbFunc(cbFunc), cbArg(cbArg), spec(spec)
|
||||
{
|
||||
}
|
||||
|
||||
|
|
@ -849,7 +851,7 @@ void ElementaryStream::push_au(u32 size, u64 dts, u64 pts, u64 userdata, bool ra
|
|||
|
||||
addr = put;
|
||||
|
||||
put = utils::align(put + 128 + size, 128);
|
||||
put = rx::alignUp(put + 128 + size, 128);
|
||||
|
||||
put_count++;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -18,7 +18,7 @@
|
|||
#include "Crypto/utils.h"
|
||||
#include "Loader/PSF.h"
|
||||
#include "util/StrUtil.h"
|
||||
#include "util/asm.hpp"
|
||||
#include "rx/asm.hpp"
|
||||
#include "util/init_mutex.hpp"
|
||||
|
||||
#include <span>
|
||||
|
|
@ -691,7 +691,7 @@ error_code cellHddGameGetSizeKB(ppu_thread& ppu, vm::ptr<u32> size)
|
|||
// This function is very slow by nature
|
||||
// TODO: Check if after first use the result is being cached so the sleep can
|
||||
// be reduced in this case
|
||||
lv2_sleep(utils::sub_saturate<u64>(dirsz == umax ? 2000 : 200000,
|
||||
lv2_sleep(rx::sub_saturate<u64>(dirsz == umax ? 2000 : 200000,
|
||||
get_guest_system_time() - start_sleep),
|
||||
&ppu);
|
||||
|
||||
|
|
@ -757,7 +757,7 @@ error_code cellGameDataGetSizeKB(ppu_thread& ppu, vm::ptr<u32> size)
|
|||
// This function is very slow by nature
|
||||
// TODO: Check if after first use the result is being cached so the sleep can
|
||||
// be reduced in this case
|
||||
lv2_sleep(utils::sub_saturate<u64>(dirsz == umax ? 2000 : 200000,
|
||||
lv2_sleep(rx::sub_saturate<u64>(dirsz == umax ? 2000 : 200000,
|
||||
get_guest_system_time() - start_sleep),
|
||||
&ppu);
|
||||
|
||||
|
|
@ -1127,7 +1127,7 @@ cellGameContentPermit(ppu_thread& ppu,
|
|||
}
|
||||
|
||||
// This function is very slow by nature
|
||||
lv2_sleep(utils::sub_saturate<u64>(
|
||||
lv2_sleep(rx::sub_saturate<u64>(
|
||||
!perm.temp.empty() || perm.can_create ? 200000 : 2000,
|
||||
get_guest_system_time() - start_sleep),
|
||||
&ppu);
|
||||
|
|
@ -1886,7 +1886,7 @@ error_code cellGameGetSizeKB(ppu_thread& ppu, vm::ptr<s32> size)
|
|||
// This function is very slow by nature
|
||||
// TODO: Check if after first use the result is being cached so the sleep can
|
||||
// be reduced in this case
|
||||
lv2_sleep(utils::sub_saturate<u64>(dirsz == umax ? 1000 : 200000,
|
||||
lv2_sleep(rx::sub_saturate<u64>(dirsz == umax ? 1000 : 200000,
|
||||
get_guest_system_time() - start_sleep),
|
||||
&ppu);
|
||||
|
||||
|
|
|
|||
|
|
@ -1,3 +1,5 @@
|
|||
#include "stdafx.h"
|
||||
|
||||
#include "cellSysutil.h"
|
||||
#include "cellUserInfo.h"
|
||||
#include "Emu/Cell/PPUModule.h"
|
||||
|
|
@ -12,7 +14,6 @@
|
|||
#include "Emu/localized_string.h"
|
||||
#include "Emu/savestate_utils.hpp"
|
||||
#include "Emu/system_config.h"
|
||||
#include "stdafx.h"
|
||||
|
||||
#include "cellMsgDialog.h"
|
||||
#include "cellSaveData.h"
|
||||
|
|
@ -26,7 +27,9 @@
|
|||
#include <mutex>
|
||||
#include <span>
|
||||
|
||||
#include "util/asm.hpp"
|
||||
#include "rx/asm.hpp"
|
||||
#include "rx/align.hpp"
|
||||
#include "rx/types.hpp"
|
||||
|
||||
LOG_CHANNEL(cellSaveData);
|
||||
|
||||
|
|
@ -65,11 +68,11 @@ std::string SaveDataEntry::date() const
|
|||
std::string SaveDataEntry::data_size() const
|
||||
{
|
||||
std::string metric = "KB";
|
||||
u64 sz = utils::aligned_div(size, 1000);
|
||||
u64 sz = rx::aligned_div(size, 1000);
|
||||
if (sz > 1000)
|
||||
{
|
||||
metric = "MB";
|
||||
sz = utils::aligned_div(sz, 1000);
|
||||
sz = rx::aligned_div(sz, 1000);
|
||||
}
|
||||
return fmt::format("%lu %s", sz, metric);
|
||||
}
|
||||
|
|
@ -1286,7 +1289,7 @@ savedata_op(ppu_thread& ppu, u32 operation, u32 version, vm::cptr<char> dirName,
|
|||
{
|
||||
if (!file.is_directory)
|
||||
{
|
||||
size_bytes += utils::align(file.size, 1024);
|
||||
size_bytes += rx::alignUp(file.size, 1024);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -1728,7 +1731,7 @@ savedata_op(ppu_thread& ppu, u32 operation, u32 version, vm::cptr<char> dirName,
|
|||
statGet->fileNum++;
|
||||
|
||||
size_bytes +=
|
||||
utils::align(entry.size, 1024); // firmware rounds this value up
|
||||
rx::alignUp(entry.size, 1024); // firmware rounds this value up
|
||||
|
||||
if (statGet->fileListNum >= setBuf->fileListMax)
|
||||
continue;
|
||||
|
|
@ -2345,7 +2348,7 @@ savedata_op(ppu_thread& ppu, u32 operation, u32 version, vm::cptr<char> dirName,
|
|||
final_blist = fmt::merge(blist, "/");
|
||||
psf::assign(
|
||||
psf, "RPCS3_BLIST",
|
||||
psf::string(utils::align(::size32(final_blist) + 1, 4), final_blist));
|
||||
psf::string(rx::alignUp(::size32(final_blist) + 1, 4), final_blist));
|
||||
|
||||
// Write all files in temporary directory
|
||||
auto& fsfo = all_files["PARAM.SFO"];
|
||||
|
|
|
|||
|
|
@ -15,7 +15,7 @@
|
|||
#include "sysPrxForUser.h"
|
||||
#include "cellSpurs.h"
|
||||
|
||||
#include "util/asm.hpp"
|
||||
#include "rx/asm.hpp"
|
||||
#include "util/v128.hpp"
|
||||
#include "util/simd.hpp"
|
||||
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@
|
|||
#include "Emu/Cell/SPURecompiler.h"
|
||||
#include "cellSpurs.h"
|
||||
|
||||
#include "util/asm.hpp"
|
||||
#include "rx/asm.hpp"
|
||||
#include "util/v128.hpp"
|
||||
#include "util/simd.hpp"
|
||||
|
||||
|
|
|
|||
|
|
@ -1,7 +1,9 @@
|
|||
#include "stdafx.h"
|
||||
|
||||
#include "Emu/Cell/PPUModule.h"
|
||||
#include "Emu/IdManager.h"
|
||||
#include "util/asm.hpp"
|
||||
#include "rx/align.hpp"
|
||||
#include "rx/asm.hpp"
|
||||
|
||||
#include "sceNp.h"
|
||||
#include "sceNp2.h"
|
||||
|
|
@ -946,7 +948,7 @@ error_code cellSysutilAvc2Load_shared(SceNpMatching2ContextId /*ctx_id*/, u32 /*
|
|||
window_count++;
|
||||
}
|
||||
|
||||
total_bitrate = utils::align<u32>(window_count * bitrate, 0x100000) + 0x100000;
|
||||
total_bitrate = rx::alignUp<u32>(window_count * bitrate, 0x100000) + 0x100000;
|
||||
}
|
||||
|
||||
settings.video_stream_sharing = init_param->video_param.video_stream_sharing;
|
||||
|
|
|
|||
|
|
@ -1,3 +1,5 @@
|
|||
#include "stdafx.h"
|
||||
|
||||
#include "Emu/Cell/PPUModule.h"
|
||||
#include "cellos/sys_ppu_thread.h"
|
||||
#include "cellos/sys_process.h"
|
||||
|
|
@ -5,7 +7,7 @@
|
|||
#include "Emu/IdManager.h"
|
||||
#include "Emu/perf_meter.hpp"
|
||||
#include "Emu/savestate_utils.hpp"
|
||||
#include "stdafx.h"
|
||||
#include "rx/align.hpp"
|
||||
#include "sysPrxForUser.h"
|
||||
#include "util/media_utils.h"
|
||||
|
||||
|
|
@ -32,7 +34,7 @@ extern "C"
|
|||
#include "cellPamf.h"
|
||||
#include "cellVdec.h"
|
||||
|
||||
#include "util/asm.hpp"
|
||||
#include "rx/asm.hpp"
|
||||
#include "util/lockless.h"
|
||||
#include <cmath>
|
||||
#include <mutex>
|
||||
|
|
@ -1660,7 +1662,7 @@ error_code cellVdecGetPicItem(ppu_thread& ppu, u32 handle,
|
|||
const int buffer_size = av_image_get_buffer_size(
|
||||
vdec->ctx->pix_fmt, vdec->ctx->width, vdec->ctx->height, 1);
|
||||
ensure(buffer_size >= 0);
|
||||
info->size = utils::align<u32>(buffer_size, 128);
|
||||
info->size = rx::alignUp<u32>(buffer_size, 128);
|
||||
info->auNum = 1;
|
||||
info->auPts[0].lower = static_cast<u32>(pts);
|
||||
info->auPts[0].upper = static_cast<u32>(pts >> 32);
|
||||
|
|
|
|||
|
|
@ -20,7 +20,7 @@
|
|||
#include "cellos/sys_event.h"
|
||||
#include "cellos/sys_fs.h"
|
||||
|
||||
#include "util/asm.hpp"
|
||||
#include "rx/asm.hpp"
|
||||
#include <algorithm>
|
||||
#include <functional>
|
||||
#include <shared_mutex>
|
||||
|
|
@ -1490,7 +1490,7 @@ error_code sceNpTrophyGetGameProgress(u32 context, u32 handle,
|
|||
const u32 trp_count = ctxt->tropusr->GetTrophiesCount();
|
||||
|
||||
// Round result to nearest (TODO: Check 0 trophies)
|
||||
*percentage = trp_count ? utils::rounded_div(unlocked * 100, trp_count) : 0;
|
||||
*percentage = trp_count ? rx::rounded_div(unlocked * 100, trp_count) : 0;
|
||||
|
||||
if (trp_count == 0 || trp_count > 128)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@
|
|||
#include "cellos/sys_mutex.h"
|
||||
#include "sysPrxForUser.h"
|
||||
|
||||
#include "util/asm.hpp"
|
||||
#include "rx/asm.hpp"
|
||||
|
||||
LOG_CHANNEL(sysPrxForUser);
|
||||
|
||||
|
|
@ -151,7 +151,7 @@ error_code sys_lwmutex_lock(ppu_thread& ppu, vm::ptr<sys_lwmutex_t> lwmutex, u64
|
|||
|
||||
for (u32 i = 0; i < 10; i++)
|
||||
{
|
||||
busy_wait();
|
||||
rx::busy_wait();
|
||||
|
||||
if (lwmutex->vars.owner.load() == lwmutex_free)
|
||||
{
|
||||
|
|
@ -210,7 +210,7 @@ error_code sys_lwmutex_lock(ppu_thread& ppu, vm::ptr<sys_lwmutex_t> lwmutex, u64
|
|||
{
|
||||
for (u32 i = 0; i < 10; i++)
|
||||
{
|
||||
busy_wait();
|
||||
rx::busy_wait();
|
||||
|
||||
if (lwmutex->vars.owner.load() == lwmutex_free)
|
||||
{
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue