Merge pull request #250 from ItzWarty/cellPngDecDecodeData_optimizations

Optimize cellPngDecDecodeData's CELL_PNGDEC_ARGB case
This commit is contained in:
Hykem 2014-05-24 17:23:17 +01:00
commit 490d1059ac
4 changed files with 27 additions and 8 deletions

4
.gitignore vendored
View File

@ -45,6 +45,10 @@
/bin/*.exp
rpcs3/git-version.h
# Visual Studio Profiler Files
*.vspx
*.psess
# Copyrighted files
/bin/data/
/bin/dev_flash/data/font

View File

@ -457,4 +457,7 @@ Global
{23E1C437-A951-5943-8639-A17F3CF2E606} = {5812E712-6213-4372-B095-9EB9BAA1F2DF}
{74827EBD-93DC-5110-BA95-3F2AB029B6B0} = {5812E712-6213-4372-B095-9EB9BAA1F2DF}
EndGlobalSection
GlobalSection(Performance) = preSolution
HasPerformanceSessions = true
EndGlobalSection
EndGlobal

View File

@ -333,11 +333,11 @@ public:
return true;
}
bool CopyFromReal(u32 to, void* real, u32 count) // (4K pages) copy from real to virtual memory
bool CopyFromReal(u32 to, const void* real, u32 count) // (4K pages) copy from real to virtual memory
{
if (!count) return true;
u8* from = (u8*)real;
const u8* from = (const u8*)real;
if (u32 frag = to & 4095)
{
@ -795,6 +795,12 @@ public:
return this->m_addr;
}
u32 AppendRawBytes(const u8 * bytes, size_t count) {
Memory.CopyFromReal(this->m_addr, bytes, count);
this->m_addr += count;
return this->m_addr;
}
u32 Skip(const u32 offset) { return this->m_addr += offset; }
operator be_t<T>*() { return GetPtr(); }

View File

@ -201,7 +201,7 @@ int cellPngDecDecodeData(u32 mainHandle, u32 subHandle, mem8_ptr_t data, const m
case CELL_PNGDEC_ARGB:
{
const char nComponents = 4;
const int nComponents = 4;
image_size *= nComponents;
if (bytesPerLine > width * nComponents || flip) //check if we need padding
{
@ -225,13 +225,19 @@ int cellPngDecDecodeData(u32 mainHandle, u32 subHandle, mem8_ptr_t data, const m
}
else
{
for (uint i = 0; i < image_size; i += nComponents)
uint* dest = (uint*)new char[image_size];
uint* source_current = (uint*)&(image.get()[0]);
uint* dest_current = dest;
for (uint i = 0; i < image_size / nComponents; i++)
{
data += image.get()[i + 3];
data += image.get()[i + 0];
data += image.get()[i + 1];
data += image.get()[i + 2];
uint val = *source_current;
*dest_current = (val >> 24) | (val << 8); // set alpha (A8) as leftmost byte
source_current++;
dest_current++;
}
// NOTE: AppendRawBytes has diff side-effect vs Memory.CopyFromReal
data.AppendRawBytes((u8*)dest, image_size);
delete[] dest;
}
}
break;