mirror of
https://github.com/RPCS3/rpcs3.git
synced 2025-04-20 11:36:13 +00:00
Copy(To)(From)(Real) elimination
It was nothing but a crutch
This commit is contained in:
parent
021656d821
commit
e7ae71bd73
16 changed files with 75 additions and 268 deletions
|
@ -32,14 +32,9 @@ u64 vfsStreamMemory::Write(const void* src, u64 size)
|
|||
size = GetSize() - Tell();
|
||||
}
|
||||
|
||||
if (!Memory.CopyFromReal(m_addr + Tell(), (void*)src, size))
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
return vfsStream::Write(src, size);
|
||||
}
|
||||
memcpy(Memory + m_addr + Tell(), (void*)src, size);
|
||||
|
||||
return vfsStream::Write(src, size);
|
||||
}
|
||||
|
||||
u64 vfsStreamMemory::Read(void* dst, u64 size)
|
||||
|
@ -49,12 +44,7 @@ u64 vfsStreamMemory::Read(void* dst, u64 size)
|
|||
size = GetSize() - Tell();
|
||||
}
|
||||
|
||||
if (!Memory.CopyToReal(dst, m_addr + Tell(), size))
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
return vfsStream::Read(dst, size);
|
||||
}
|
||||
memcpy(dst, Memory + m_addr + Tell(), size);
|
||||
|
||||
return vfsStream::Read(dst, size);
|
||||
}
|
||||
|
|
|
@ -106,36 +106,6 @@ u64 MemoryBlock::FixAddr(const u64 addr) const
|
|||
return addr - GetStartAddr();
|
||||
}
|
||||
|
||||
bool MemoryBlock::GetMemFromAddr(void* dst, const u64 addr, const u32 size)
|
||||
{
|
||||
if(!IsMyAddress(addr) || FixAddr(addr) + size > GetSize()) return false;
|
||||
|
||||
return Memory.CopyToReal(dst, addr, size);
|
||||
}
|
||||
|
||||
bool MemoryBlock::SetMemFromAddr(void* src, const u64 addr, const u32 size)
|
||||
{
|
||||
if(!IsMyAddress(addr) || FixAddr(addr) + size > GetSize()) return false;
|
||||
|
||||
return Memory.CopyFromReal(addr, src, size);
|
||||
}
|
||||
|
||||
bool MemoryBlock::GetMemFFromAddr(void* dst, const u64 addr)
|
||||
{
|
||||
if(!IsMyAddress(addr)) return false;
|
||||
|
||||
dst = GetMem(FixAddr(addr));
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
u8* MemoryBlock::GetMemFromAddr(const u64 addr)
|
||||
{
|
||||
if(!IsMyAddress(addr) || IsNULL()) return nullptr;
|
||||
|
||||
return GetMem(FixAddr(addr));
|
||||
}
|
||||
|
||||
MemoryBlock* MemoryBlock::SetRange(const u64 start, const u32 size)
|
||||
{
|
||||
if (start + size > 0x100000000) return nullptr;
|
||||
|
|
|
@ -391,20 +391,32 @@ public:
|
|||
}
|
||||
}
|
||||
|
||||
noinline void WriteMMIO32(u32 addr, const u32 data)
|
||||
{
|
||||
{
|
||||
std::lock_guard<std::recursive_mutex> lock(m_mutex);
|
||||
|
||||
if (RawSPUMem[(addr - RAW_SPU_BASE_ADDR) / RAW_SPU_OFFSET] &&
|
||||
RawSPUMem[(addr - RAW_SPU_BASE_ADDR) / RAW_SPU_OFFSET]->Write32(addr, data))
|
||||
{
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
*(u32*)((u8*)GetBaseAddr() + addr) = re32(data); // provoke error
|
||||
}
|
||||
|
||||
template<typename T> void Write32(T addr, const u32 data)
|
||||
{
|
||||
if ((u32)addr == addr)
|
||||
{
|
||||
if (addr < RAW_SPU_BASE_ADDR || (addr % RAW_SPU_OFFSET) < RAW_SPU_PROB_OFFSET || !RawSPUMem[(addr - RAW_SPU_BASE_ADDR) / RAW_SPU_OFFSET])
|
||||
if (addr < RAW_SPU_BASE_ADDR || (addr % RAW_SPU_OFFSET) < RAW_SPU_PROB_OFFSET)
|
||||
{
|
||||
*(u32*)((u8*)GetBaseAddr() + addr) = re32(data);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!RawSPUMem[(addr - RAW_SPU_BASE_ADDR) / RAW_SPU_OFFSET]->Write32(addr, data))
|
||||
{
|
||||
*(u32*)((u8*)GetBaseAddr() + addr) = re32(data);
|
||||
}
|
||||
WriteMMIO32(addr, data);
|
||||
}
|
||||
}
|
||||
else
|
||||
|
@ -466,22 +478,34 @@ public:
|
|||
}
|
||||
}
|
||||
|
||||
noinline u32 ReadMMIO32(u32 addr)
|
||||
{
|
||||
u32 res;
|
||||
{
|
||||
std::lock_guard<std::recursive_mutex> lock(m_mutex);
|
||||
|
||||
if (RawSPUMem[(addr - RAW_SPU_BASE_ADDR) / RAW_SPU_OFFSET] &&
|
||||
RawSPUMem[(addr - RAW_SPU_BASE_ADDR) / RAW_SPU_OFFSET]->Read32(addr, &res))
|
||||
{
|
||||
return res;
|
||||
}
|
||||
}
|
||||
|
||||
res = re32(*(u32*)((u8*)GetBaseAddr() + addr)); // provoke error
|
||||
return res;
|
||||
}
|
||||
|
||||
template<typename T> u32 Read32(T addr)
|
||||
{
|
||||
if ((u32)addr == addr)
|
||||
{
|
||||
if (addr < RAW_SPU_BASE_ADDR || (addr % RAW_SPU_OFFSET) < RAW_SPU_PROB_OFFSET || !RawSPUMem[(addr - RAW_SPU_BASE_ADDR) / RAW_SPU_OFFSET])
|
||||
if (addr < RAW_SPU_BASE_ADDR || (addr % RAW_SPU_OFFSET) < RAW_SPU_PROB_OFFSET)
|
||||
{
|
||||
return re32(*(u32*)((u8*)GetBaseAddr() + addr));
|
||||
}
|
||||
else
|
||||
{
|
||||
u32 res;
|
||||
if (!RawSPUMem[(addr - RAW_SPU_BASE_ADDR) / RAW_SPU_OFFSET]->Read32(addr, &res))
|
||||
{
|
||||
res = re32(*(u32*)((u8*)GetBaseAddr() + addr));
|
||||
}
|
||||
return res;
|
||||
return ReadMMIO32(addr);
|
||||
}
|
||||
}
|
||||
else
|
||||
|
@ -517,33 +541,6 @@ public:
|
|||
}
|
||||
}
|
||||
|
||||
template<typename T> bool CopyToReal(void* real, T from, u32 count)
|
||||
{
|
||||
if (!IsGoodAddr<T>(from, count)) return false; // TODO: eliminate
|
||||
|
||||
memcpy(real, GetMemFromAddr<T>(from), count);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
template<typename T> bool CopyFromReal(T to, const void* real, u32 count)
|
||||
{
|
||||
if (!IsGoodAddr<T>(to, count)) return false; // TODO: eliminate
|
||||
|
||||
memcpy(GetMemFromAddr<T>(to), real, count);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
template<typename T1, typename T2> bool Copy(T1 to, T2 from, u32 count)
|
||||
{
|
||||
if (!IsGoodAddr<T1>(to, count) || !IsGoodAddr<T2>(from, count)) return false; // TODO: eliminate
|
||||
|
||||
memmove(GetMemFromAddr<T1>(to), GetMemFromAddr<T2>(from), count);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void ReadLeft(u8* dst, const u64 addr, const u32 size)
|
||||
{
|
||||
for (u32 i = 0; i < size; ++i) dst[size - 1 - i] = Read8(addr + i);
|
||||
|
|
|
@ -283,11 +283,6 @@ public:
|
|||
|
||||
u64 FixAddr(const u64 addr) const;
|
||||
|
||||
bool GetMemFromAddr(void* dst, const u64 addr, const u32 size);
|
||||
bool SetMemFromAddr(void* src, const u64 addr, const u32 size);
|
||||
bool GetMemFFromAddr(void* dst, const u64 addr);
|
||||
u8* GetMemFromAddr(const u64 addr);
|
||||
|
||||
virtual MemoryBlock* SetRange(const u64 start, const u32 size);
|
||||
virtual bool IsMyAddress(const u64 addr);
|
||||
virtual bool IsLocked(const u64 addr) { return false; }
|
||||
|
|
|
@ -50,12 +50,7 @@ next:
|
|||
break;
|
||||
case adecDecodeAu:
|
||||
{
|
||||
if (!Memory.CopyToReal(buf, adec.reader.addr, adec.reader.size))
|
||||
{
|
||||
LOG_ERROR(HLE, "adecRawRead(): data reading failed (reader.size=0x%x)", adec.reader.size);
|
||||
Emu.Pause();
|
||||
return 0;
|
||||
}
|
||||
memcpy(buf, Memory + adec.reader.addr, adec.reader.size);
|
||||
|
||||
buf += adec.reader.size;
|
||||
buf_size -= adec.reader.size;
|
||||
|
@ -86,14 +81,10 @@ next:
|
|||
{
|
||||
return res;
|
||||
}
|
||||
else if (!Memory.CopyToReal(buf, adec.reader.addr, buf_size))
|
||||
{
|
||||
LOG_ERROR(HLE, "adecRawRead(): data reading failed (buf_size=0x%x)", buf_size);
|
||||
Emu.Pause();
|
||||
return 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
memcpy(buf, Memory + adec.reader.addr, buf_size);
|
||||
|
||||
adec.reader.addr += buf_size;
|
||||
adec.reader.size -= buf_size;
|
||||
return res + buf_size;
|
||||
|
@ -691,28 +682,17 @@ int cellAdecGetPcm(u32 handle, u32 outBuffer_addr)
|
|||
return CELL_OK;
|
||||
}
|
||||
|
||||
// copy data
|
||||
u8* out = (u8*)calloc(1, af.size);
|
||||
|
||||
// reverse byte order, extract data:
|
||||
float* in_f[2];
|
||||
in_f[0] = (float*)frame->extended_data[0];
|
||||
in_f[1] = (float*)frame->extended_data[1];
|
||||
be_t<float>* out_f = (be_t<float>*)out;
|
||||
be_t<float>* out_f = (be_t<float>*)Memory.GetMemFromAddr(outBuffer_addr);
|
||||
for (u32 i = 0; i < af.size / 8; i++)
|
||||
{
|
||||
out_f[i*2] = in_f[0][i];
|
||||
out_f[i*2+1] = in_f[1][i];
|
||||
}
|
||||
|
||||
if (!Memory.CopyFromReal(outBuffer_addr, out, af.size))
|
||||
{
|
||||
LOG_ERROR(HLE, "cellAdecGetPcm(%d): data copying failed (addr=0x%x)", handle, outBuffer_addr);
|
||||
Emu.Pause();
|
||||
}
|
||||
|
||||
free(out);
|
||||
|
||||
if (af.data)
|
||||
{
|
||||
av_frame_unref(af.data);
|
||||
|
|
|
@ -632,12 +632,7 @@ public:
|
|||
|
||||
u32 data_addr = put + 128 + size;
|
||||
size += sz;
|
||||
if (!Memory.Copy(data_addr, stream.addr, sz))
|
||||
{
|
||||
LOG_ERROR(HLE, "es::push(): data copying failed");
|
||||
Emu.Pause();
|
||||
return;
|
||||
}
|
||||
memcpy(Memory + data_addr, Memory + stream.addr, sz);
|
||||
stream.skip(sz);
|
||||
|
||||
mem_ptr_t<CellDmuxAuInfoEx> info(put);
|
||||
|
|
|
@ -461,12 +461,8 @@ s32 cellGcmSetPrepareFlip(mem_ptr_t<CellGcmContextData> ctxt, u32 id)
|
|||
|
||||
const s32 res = ctxt->current - ctxt->begin - ctrl.put;
|
||||
|
||||
if (res > 0 && !Memory.Copy(ctxt->begin, ctxt->current - res, res))
|
||||
{
|
||||
cellGcmSys->Error("cellGcmSetPrepareFlip(): Memory.Copy(0x%x, 0x%x, 0x%x) failed", (u32)ctxt->begin, (u32)ctxt->current - res, res);
|
||||
Emu.Pause();
|
||||
return CELL_EFAULT;
|
||||
}
|
||||
memmove(Memory + ctxt->begin, Memory + ctxt->current - res, res);
|
||||
|
||||
ctxt->current = ctxt->begin + res;
|
||||
|
||||
//InterlockedExchange64((volatile long long*)((u8*)&ctrl + offsetof(CellGcmControl, put)), (u64)(u32)re(res));
|
||||
|
@ -1119,12 +1115,7 @@ int cellGcmCallback(u32 context_addr, u32 count)
|
|||
|
||||
const s32 res = ctx.current - ctx.begin - ctrl.put;
|
||||
|
||||
if (res > 0 && !Memory.Copy(ctx.begin, ctx.current - res, res))
|
||||
{
|
||||
cellGcmSys->Error("cellGcmCallback(): Memory.Copy(0x%x, 0x%x, 0x%x) failed", (u32)ctx.begin, (u32)ctx.current - res, res);
|
||||
Emu.Pause();
|
||||
return CELL_EFAULT;
|
||||
}
|
||||
memmove(Memory + ctx.begin, Memory + ctx.current - res, res);
|
||||
|
||||
ctx.current = ctx.begin + res;
|
||||
|
||||
|
|
|
@ -75,10 +75,7 @@ int cellGifDecReadHeader(u32 mainHandle, u32 subHandle, mem_ptr_t<CellGifDecInfo
|
|||
switch(subHandle_data->src.srcSelect.ToBE())
|
||||
{
|
||||
case se32(CELL_GIFDEC_BUFFER):
|
||||
if (!Memory.Copy(buffer.GetAddr(), subHandle_data->src.streamPtr.ToLE(), buffer.GetSize())) {
|
||||
cellGifDec->Error("cellGifDecReadHeader() failed ()");
|
||||
return CELL_EFAULT;
|
||||
}
|
||||
memmove(Memory + buffer.GetAddr(), Memory + subHandle_data->src.streamPtr.ToLE(), buffer.GetSize());
|
||||
break;
|
||||
|
||||
case se32(CELL_GIFDEC_FILE):
|
||||
|
@ -154,10 +151,7 @@ int cellGifDecDecodeData(u32 mainHandle, u32 subHandle, mem8_ptr_t data, const m
|
|||
switch(subHandle_data->src.srcSelect.ToBE())
|
||||
{
|
||||
case se32(CELL_GIFDEC_BUFFER):
|
||||
if (!Memory.Copy(gif.GetAddr(), subHandle_data->src.streamPtr.ToLE(), gif.GetSize())) {
|
||||
cellGifDec->Error("cellGifDecDecodeData() failed (I)");
|
||||
return CELL_EFAULT;
|
||||
}
|
||||
memmove(Memory + gif.GetAddr(), Memory + subHandle_data->src.streamPtr.ToLE(), gif.GetSize());
|
||||
break;
|
||||
|
||||
case se32(CELL_GIFDEC_FILE):
|
||||
|
@ -192,20 +186,12 @@ int cellGifDecDecodeData(u32 mainHandle, u32 subHandle, mem8_ptr_t data, const m
|
|||
{
|
||||
const int dstOffset = i * bytesPerLine;
|
||||
const int srcOffset = width * nComponents * i;
|
||||
if (!Memory.CopyFromReal(data.GetAddr() + dstOffset, &image.get()[srcOffset], linesize))
|
||||
{
|
||||
cellGifDec->Error("cellGifDecDecodeData() failed (II)");
|
||||
return CELL_EFAULT;
|
||||
}
|
||||
memcpy(Memory + data.GetAddr() + dstOffset, &image.get()[srcOffset], linesize);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!Memory.CopyFromReal(data.GetAddr(), image.get(), image_size))
|
||||
{
|
||||
cellGifDec->Error("cellGifDecDecodeData() failed (III)");
|
||||
return CELL_EFAULT;
|
||||
}
|
||||
memcpy(Memory + data.GetAddr(), image.get(), image_size);
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
@ -228,11 +214,7 @@ int cellGifDecDecodeData(u32 mainHandle, u32 subHandle, mem8_ptr_t data, const m
|
|||
output[j + 2] = image.get()[srcOffset + j + 1];
|
||||
output[j + 3] = image.get()[srcOffset + j + 2];
|
||||
}
|
||||
if (!Memory.CopyFromReal(data.GetAddr() + dstOffset, output, linesize))
|
||||
{
|
||||
cellGifDec->Error("cellGifDecDecodeData() failed (IV)");
|
||||
return CELL_EFAULT;
|
||||
}
|
||||
memcpy(Memory + data.GetAddr() + dstOffset, output, linesize);
|
||||
}
|
||||
free(output);
|
||||
}
|
||||
|
|
|
@ -96,10 +96,7 @@ int cellJpgDecReadHeader(u32 mainHandle, u32 subHandle, mem_ptr_t<CellJpgDecInfo
|
|||
switch(subHandle_data->src.srcSelect.ToBE())
|
||||
{
|
||||
case se32(CELL_JPGDEC_BUFFER):
|
||||
if (!Memory.Copy(buffer.GetAddr(), subHandle_data->src.streamPtr.ToLE(), buffer.GetSize())) {
|
||||
cellJpgDec->Error("cellJpgDecReadHeader() failed ()");
|
||||
return CELL_EFAULT;
|
||||
}
|
||||
memmove(Memory + buffer.GetAddr(), Memory + subHandle_data->src.streamPtr.ToLE(), buffer.GetSize());
|
||||
break;
|
||||
|
||||
case se32(CELL_JPGDEC_FILE):
|
||||
|
@ -165,10 +162,7 @@ int cellJpgDecDecodeData(u32 mainHandle, u32 subHandle, mem8_ptr_t data, const m
|
|||
switch(subHandle_data->src.srcSelect.ToBE())
|
||||
{
|
||||
case se32(CELL_JPGDEC_BUFFER):
|
||||
if (!Memory.Copy(jpg.GetAddr(), subHandle_data->src.streamPtr.ToLE(), jpg.GetSize())) {
|
||||
cellJpgDec->Error("cellJpgDecDecodeData() failed (I)");
|
||||
return CELL_EFAULT;
|
||||
}
|
||||
memmove(Memory + jpg.GetAddr(), Memory + subHandle_data->src.streamPtr.ToLE(), jpg.GetSize());
|
||||
break;
|
||||
|
||||
case se32(CELL_JPGDEC_FILE):
|
||||
|
@ -206,20 +200,12 @@ int cellJpgDecDecodeData(u32 mainHandle, u32 subHandle, mem8_ptr_t data, const m
|
|||
{
|
||||
const int dstOffset = i * bytesPerLine;
|
||||
const int srcOffset = width * nComponents * (flip ? height - i - 1 : i);
|
||||
if (!Memory.CopyFromReal(data.GetAddr() + dstOffset, &image.get()[srcOffset], linesize))
|
||||
{
|
||||
cellJpgDec->Error("cellJpgDecDecodeData() failed (II)");
|
||||
return CELL_EFAULT;
|
||||
}
|
||||
memcpy(Memory + data.GetAddr() + dstOffset, &image.get()[srcOffset], linesize);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!Memory.CopyFromReal(data.GetAddr(), image.get(), image_size))
|
||||
{
|
||||
cellJpgDec->Error("cellJpgDecDecodeData() failed (III)");
|
||||
return CELL_EFAULT;
|
||||
}
|
||||
memcpy(Memory + data.GetAddr(), image.get(), image_size);
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
@ -244,11 +230,7 @@ int cellJpgDecDecodeData(u32 mainHandle, u32 subHandle, mem8_ptr_t data, const m
|
|||
output[j + 2] = image.get()[srcOffset + j + 1];
|
||||
output[j + 3] = image.get()[srcOffset + j + 2];
|
||||
}
|
||||
if (!Memory.CopyFromReal(data.GetAddr() + dstOffset, output, linesize))
|
||||
{
|
||||
cellJpgDec->Error("cellJpgDecDecodeData() failed (IV)");
|
||||
return CELL_EFAULT;
|
||||
}
|
||||
memcpy(Memory + data.GetAddr() + dstOffset, output, linesize);
|
||||
}
|
||||
free(output);
|
||||
}
|
||||
|
|
|
@ -139,11 +139,7 @@ int cellPngDecReadHeader(u32 mainHandle, u32 subHandle, mem_ptr_t<CellPngDecInfo
|
|||
switch(subHandle_data->src.srcSelect.ToBE())
|
||||
{
|
||||
case se32(CELL_PNGDEC_BUFFER):
|
||||
if (!Memory.Copy(buffer.GetAddr(), subHandle_data->src.streamPtr.ToLE(), buffer.GetSize()))
|
||||
{
|
||||
cellPngDec->Error("cellPngDecReadHeader() failed ()");
|
||||
return CELL_EFAULT;
|
||||
}
|
||||
memmove(Memory + buffer.GetAddr(), Memory + subHandle_data->src.streamPtr.ToLE(), buffer.GetSize());
|
||||
break;
|
||||
case se32(CELL_PNGDEC_FILE):
|
||||
cellFsLseek(fd, 0, CELL_SEEK_SET, pos.GetAddr());
|
||||
|
@ -205,10 +201,7 @@ int cellPngDecDecodeData(u32 mainHandle, u32 subHandle, mem8_ptr_t data, const m
|
|||
switch(subHandle_data->src.srcSelect.ToBE())
|
||||
{
|
||||
case se32(CELL_PNGDEC_BUFFER):
|
||||
if (!Memory.Copy(png.GetAddr(), subHandle_data->src.streamPtr.ToLE(), png.GetSize())) {
|
||||
cellPngDec->Error("cellPngDecDecodeData() failed (I)");
|
||||
return CELL_EFAULT;
|
||||
}
|
||||
memmove(Memory + png.GetAddr(), Memory + subHandle_data->src.streamPtr.ToLE(), png.GetSize());
|
||||
break;
|
||||
|
||||
case se32(CELL_PNGDEC_FILE):
|
||||
|
@ -244,20 +237,12 @@ int cellPngDecDecodeData(u32 mainHandle, u32 subHandle, mem8_ptr_t data, const m
|
|||
{
|
||||
const int dstOffset = i * bytesPerLine;
|
||||
const int srcOffset = width * nComponents * (flip ? height - i - 1 : i);
|
||||
if (!Memory.CopyFromReal(data.GetAddr() + dstOffset, &image.get()[srcOffset], linesize))
|
||||
{
|
||||
cellPngDec->Error("cellPngDecDecodeData() failed (II)");
|
||||
return CELL_EFAULT;
|
||||
}
|
||||
memcpy(Memory + data.GetAddr() + dstOffset, &image.get()[srcOffset], linesize);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!Memory.CopyFromReal(data.GetAddr(), image.get(), image_size))
|
||||
{
|
||||
cellPngDec->Error("cellPngDecDecodeData() failed (III)");
|
||||
return CELL_EFAULT;
|
||||
}
|
||||
memcpy(Memory + data.GetAddr(), image.get(), image_size);
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
@ -282,11 +267,7 @@ int cellPngDecDecodeData(u32 mainHandle, u32 subHandle, mem8_ptr_t data, const m
|
|||
output[j + 2] = image.get()[srcOffset + j + 1];
|
||||
output[j + 3] = image.get()[srcOffset + j + 2];
|
||||
}
|
||||
if (!Memory.CopyFromReal(data.GetAddr() + dstOffset, output, linesize))
|
||||
{
|
||||
cellPngDec->Error("cellPngDecDecodeData() failed (IV)");
|
||||
return CELL_EFAULT;
|
||||
}
|
||||
memcpy(Memory + data.GetAddr() + dstOffset, output, linesize);
|
||||
}
|
||||
free(output);
|
||||
}
|
||||
|
|
|
@ -49,12 +49,7 @@ next:
|
|||
break;
|
||||
case vdecDecodeAu:
|
||||
{
|
||||
if (!Memory.CopyToReal(buf, vdec.reader.addr, vdec.reader.size))
|
||||
{
|
||||
LOG_ERROR(HLE, "vdecRead(): data reading failed (reader.size=0x%x)", vdec.reader.size);
|
||||
Emu.Pause();
|
||||
return 0;
|
||||
}
|
||||
memcpy(buf, Memory + vdec.reader.addr, vdec.reader.size);
|
||||
|
||||
buf += vdec.reader.size;
|
||||
buf_size -= vdec.reader.size;
|
||||
|
@ -89,14 +84,10 @@ next:
|
|||
{
|
||||
return res;
|
||||
}
|
||||
else if (!Memory.CopyToReal(buf, vdec.reader.addr, buf_size))
|
||||
{
|
||||
LOG_ERROR(HLE, "vdecRead(): data reading failed (buf_size=0x%x)", buf_size);
|
||||
Emu.Pause();
|
||||
return 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
memcpy(buf, Memory + vdec.reader.addr, buf_size);
|
||||
|
||||
vdec.reader.addr += buf_size;
|
||||
vdec.reader.size -= buf_size;
|
||||
return res + buf_size;
|
||||
|
@ -596,26 +587,17 @@ int cellVdecGetPicture(u32 handle, const mem_ptr_t<CellVdecPicFormat> format, u3
|
|||
|
||||
AVFrame& frame = *vf.data;
|
||||
|
||||
u8* buf = (u8*)malloc(buf_size);
|
||||
|
||||
// TODO: zero padding bytes
|
||||
|
||||
int err = av_image_copy_to_buffer(buf, buf_size, frame.data, frame.linesize, vdec->ctx->pix_fmt, frame.width, frame.height, 1);
|
||||
int err = av_image_copy_to_buffer(Memory + out_addr, buf_size, frame.data, frame.linesize, vdec->ctx->pix_fmt, frame.width, frame.height, 1);
|
||||
if (err < 0)
|
||||
{
|
||||
cellVdec->Error("cellVdecGetPicture: av_image_copy_to_buffer failed(%d)", err);
|
||||
Emu.Pause();
|
||||
}
|
||||
|
||||
if (!Memory.CopyFromReal(out_addr, buf, buf_size))
|
||||
{
|
||||
cellVdec->Error("cellVdecGetPicture: data copying failed");
|
||||
Emu.Pause();
|
||||
}
|
||||
|
||||
av_frame_unref(vf.data);
|
||||
av_frame_free(&vf.data);
|
||||
free(buf);
|
||||
}
|
||||
|
||||
return CELL_OK;
|
||||
|
|
|
@ -128,29 +128,7 @@ int cellVpostExec(u32 handle, const u32 inPicBuff_addr, const mem_ptr_t<CellVpos
|
|||
picInfo->reserved2 = 0;
|
||||
|
||||
u64 stamp0 = get_system_time();
|
||||
std::unique_ptr<u8[]> pY(new u8[w*h]); // color planes
|
||||
std::unique_ptr<u8[]> pU(new u8[w*h/4]);
|
||||
std::unique_ptr<u8[]> pV(new u8[w*h/4]);
|
||||
std::unique_ptr<u8[]> pA(new u8[w*h]);
|
||||
std::unique_ptr<u32[]> res(new u32[ow*oh*4]); // RGBA interleaved output
|
||||
|
||||
if (!Memory.CopyToReal(pY.get(), inPicBuff_addr, w*h))
|
||||
{
|
||||
cellVpost->Error("cellVpostExec: data copying failed(pY)");
|
||||
Emu.Pause();
|
||||
}
|
||||
|
||||
if (!Memory.CopyToReal(pU.get(), inPicBuff_addr + w*h, w*h/4))
|
||||
{
|
||||
cellVpost->Error("cellVpostExec: data copying failed(pU)");
|
||||
Emu.Pause();
|
||||
}
|
||||
|
||||
if (!Memory.CopyToReal(pV.get(), inPicBuff_addr + w*h + w*h/4, w*h/4))
|
||||
{
|
||||
cellVpost->Error("cellVpostExec: data copying failed(pV)");
|
||||
Emu.Pause();
|
||||
}
|
||||
|
||||
memset(pA.get(), (const u8)ctrlParam->outAlpha, w*h);
|
||||
|
||||
|
@ -160,22 +138,16 @@ int cellVpostExec(u32 handle, const u32 inPicBuff_addr, const mem_ptr_t<CellVpos
|
|||
|
||||
u64 stamp2 = get_system_time();
|
||||
|
||||
u8* in_data[4] = { pY.get(), pU.get(), pV.get(), pA.get() };
|
||||
u8* in_data[4] = { Memory.GetMemFromAddr(inPicBuff_addr), Memory.GetMemFromAddr(inPicBuff_addr + w*h), Memory.GetMemFromAddr(inPicBuff_addr + w*h + w*h / 4), pA.get() };
|
||||
int in_line[4] = { w, w/2, w/2, w };
|
||||
u8* out_data[4] = { (u8*)res.get(), NULL, NULL, NULL };
|
||||
u8* out_data[4] = { Memory.GetMemFromAddr(outPicBuff_addr), NULL, NULL, NULL };
|
||||
int out_line[4] = { static_cast<int>(ow*4), 0, 0, 0 };
|
||||
|
||||
sws_scale(sws, in_data, in_line, 0, h, out_data, out_line);
|
||||
|
||||
sws_freeContext(sws);
|
||||
|
||||
u64 stamp3 = get_system_time();
|
||||
|
||||
if (!Memory.CopyFromReal(outPicBuff_addr, res.get(), ow*oh*4))
|
||||
{
|
||||
cellVpost->Error("cellVpostExec: data copying failed(result)");
|
||||
Emu.Pause();
|
||||
}
|
||||
sws_freeContext(sws);
|
||||
|
||||
//ConLog.Write("cellVpostExec() perf (access=%d, getContext=%d, scale=%d, finalize=%d)",
|
||||
//stamp1 - stamp0, stamp2 - stamp1, stamp3 - stamp2, get_system_time() - stamp3);
|
||||
|
|
|
@ -149,11 +149,7 @@ int sys_raw_spu_image_load(int id, mem_ptr_t<sys_spu_image> img)
|
|||
{
|
||||
sysPrxForUser->Warning("sys_raw_spu_image_load(id=0x%x, img_addr=0x%x)", id, img.GetAddr());
|
||||
|
||||
if (!Memory.Copy(RAW_SPU_BASE_ADDR + RAW_SPU_OFFSET * id, (u32)img->segs_addr, 256 * 1024))
|
||||
{
|
||||
sysPrxForUser->Error("sys_raw_spu_image_load() failed");
|
||||
return CELL_EFAULT;
|
||||
}
|
||||
memcpy(Memory + RAW_SPU_BASE_ADDR + RAW_SPU_OFFSET * id, Memory + (u32)img->segs_addr, 256 * 1024);
|
||||
Memory.Write32(RAW_SPU_BASE_ADDR + RAW_SPU_OFFSET * id + RAW_SPU_PROB_OFFSET + SPU_NPC_offs, (u32)img->entry_point);
|
||||
|
||||
return CELL_OK;
|
||||
|
|
|
@ -353,9 +353,6 @@ s32 cellFsUnlink(u32 path_addr)
|
|||
const std::string& ps3_path = Memory.ReadString(path_addr);
|
||||
sys_fs->Warning("cellFsUnlink(path=\"%s\")", ps3_path.c_str());
|
||||
|
||||
if (ps3_path.empty())
|
||||
return CELL_EFAULT;
|
||||
|
||||
if (Emu.GetVFS().ExistsDir(ps3_path))
|
||||
return CELL_EISDIR;
|
||||
|
||||
|
|
|
@ -82,7 +82,7 @@ s32 sys_memory_free(u32 start_addr)
|
|||
|
||||
// Release the allocated memory.
|
||||
if(!Memory.Free(start_addr))
|
||||
return CELL_EFAULT;
|
||||
return CELL_EINVAL;
|
||||
|
||||
return CELL_OK;
|
||||
}
|
||||
|
|
|
@ -86,10 +86,7 @@ s32 sys_spu_thread_initialize(mem32_t thread, u32 group, u32 spu_num, mem_ptr_t<
|
|||
|
||||
//copy SPU image:
|
||||
auto spu_offset = Memory.MainMem.AllocAlign(256 * 1024);
|
||||
if (!Memory.Copy(spu_offset, (u32)img->segs_addr, 256 * 1024))
|
||||
{
|
||||
return CELL_EFAULT;
|
||||
}
|
||||
memcpy(Memory + spu_offset, Memory + (u32)img->segs_addr, 256 * 1024);
|
||||
|
||||
CPUThread& new_thread = Emu.GetCPU().AddThread(CPU_THREAD_SPU);
|
||||
//initialize from new place:
|
||||
|
|
Loading…
Add table
Reference in a new issue