mirror of
https://github.com/RPCS3/rpcs3.git
synced 2025-07-07 23:41:26 +12:00
Merge pull request #250 from ItzWarty/cellPngDecDecodeData_optimizations
Optimize cellPngDecDecodeData's CELL_PNGDEC_ARGB case
This commit is contained in:
commit
490d1059ac
4 changed files with 27 additions and 8 deletions
4
.gitignore
vendored
4
.gitignore
vendored
|
@ -45,6 +45,10 @@
|
||||||
/bin/*.exp
|
/bin/*.exp
|
||||||
rpcs3/git-version.h
|
rpcs3/git-version.h
|
||||||
|
|
||||||
|
# Visual Studio Profiler Files
|
||||||
|
*.vspx
|
||||||
|
*.psess
|
||||||
|
|
||||||
# Copyrighted files
|
# Copyrighted files
|
||||||
/bin/data/
|
/bin/data/
|
||||||
/bin/dev_flash/data/font
|
/bin/dev_flash/data/font
|
||||||
|
|
|
@ -457,4 +457,7 @@ Global
|
||||||
{23E1C437-A951-5943-8639-A17F3CF2E606} = {5812E712-6213-4372-B095-9EB9BAA1F2DF}
|
{23E1C437-A951-5943-8639-A17F3CF2E606} = {5812E712-6213-4372-B095-9EB9BAA1F2DF}
|
||||||
{74827EBD-93DC-5110-BA95-3F2AB029B6B0} = {5812E712-6213-4372-B095-9EB9BAA1F2DF}
|
{74827EBD-93DC-5110-BA95-3F2AB029B6B0} = {5812E712-6213-4372-B095-9EB9BAA1F2DF}
|
||||||
EndGlobalSection
|
EndGlobalSection
|
||||||
|
GlobalSection(Performance) = preSolution
|
||||||
|
HasPerformanceSessions = true
|
||||||
|
EndGlobalSection
|
||||||
EndGlobal
|
EndGlobal
|
||||||
|
|
|
@ -333,11 +333,11 @@ public:
|
||||||
return true;
|
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;
|
if (!count) return true;
|
||||||
|
|
||||||
u8* from = (u8*)real;
|
const u8* from = (const u8*)real;
|
||||||
|
|
||||||
if (u32 frag = to & 4095)
|
if (u32 frag = to & 4095)
|
||||||
{
|
{
|
||||||
|
@ -795,6 +795,12 @@ public:
|
||||||
return this->m_addr;
|
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; }
|
u32 Skip(const u32 offset) { return this->m_addr += offset; }
|
||||||
|
|
||||||
operator be_t<T>*() { return GetPtr(); }
|
operator be_t<T>*() { return GetPtr(); }
|
||||||
|
|
|
@ -201,7 +201,7 @@ int cellPngDecDecodeData(u32 mainHandle, u32 subHandle, mem8_ptr_t data, const m
|
||||||
|
|
||||||
case CELL_PNGDEC_ARGB:
|
case CELL_PNGDEC_ARGB:
|
||||||
{
|
{
|
||||||
const char nComponents = 4;
|
const int nComponents = 4;
|
||||||
image_size *= nComponents;
|
image_size *= nComponents;
|
||||||
if (bytesPerLine > width * nComponents || flip) //check if we need padding
|
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
|
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];
|
uint val = *source_current;
|
||||||
data += image.get()[i + 0];
|
*dest_current = (val >> 24) | (val << 8); // set alpha (A8) as leftmost byte
|
||||||
data += image.get()[i + 1];
|
source_current++;
|
||||||
data += image.get()[i + 2];
|
dest_current++;
|
||||||
}
|
}
|
||||||
|
// NOTE: AppendRawBytes has diff side-effect vs Memory.CopyFromReal
|
||||||
|
data.AppendRawBytes((u8*)dest, image_size);
|
||||||
|
delete[] dest;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue