mirror of
https://github.com/RPCS3/rpcs3.git
synced 2025-07-06 06:51:26 +12:00
rsx: Fix texture transfer when pitch does not match exactly
This commit is contained in:
parent
612160a8ff
commit
3a4083263e
2 changed files with 26 additions and 1 deletions
|
@ -1397,8 +1397,32 @@ namespace rsx
|
||||||
const auto valid_offset = valid_range.start - get_section_base();
|
const auto valid_offset = valid_range.start - get_section_base();
|
||||||
AUDIT(valid_length > 0);
|
AUDIT(valid_length > 0);
|
||||||
|
|
||||||
|
// In case of pitch mismatch, match the offset point to the correct point
|
||||||
|
u32 mapped_offset, mapped_length;
|
||||||
|
if (real_pitch != rsx_pitch)
|
||||||
|
{
|
||||||
|
if (LIKELY(!valid_offset))
|
||||||
|
{
|
||||||
|
mapped_offset = 0;
|
||||||
|
}
|
||||||
|
else if (valid_offset)
|
||||||
|
{
|
||||||
|
const u32 offset_in_x = valid_offset % rsx_pitch;
|
||||||
|
const u32 offset_in_y = valid_offset / rsx_pitch;
|
||||||
|
mapped_offset = (offset_in_y * real_pitch) + offset_in_x;
|
||||||
|
}
|
||||||
|
|
||||||
|
const u32 available_vmem = (get_section_size() / rsx_pitch) * real_pitch + std::min<u32>(get_section_size() % rsx_pitch, real_pitch);
|
||||||
|
mapped_length = std::min(available_vmem - mapped_offset, valid_length);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
mapped_offset = valid_offset;
|
||||||
|
mapped_length = valid_length;
|
||||||
|
}
|
||||||
|
|
||||||
// Obtain pointers to the source and destination memory regions
|
// Obtain pointers to the source and destination memory regions
|
||||||
u8 *src = static_cast<u8*>(derived()->map_synchronized(valid_offset, valid_length));
|
u8 *src = static_cast<u8*>(derived()->map_synchronized(mapped_offset, mapped_length));
|
||||||
u32 dst = valid_range.start;
|
u32 dst = valid_range.start;
|
||||||
ASSERT(src != nullptr);
|
ASSERT(src != nullptr);
|
||||||
|
|
||||||
|
|
|
@ -387,6 +387,7 @@ namespace gl
|
||||||
{
|
{
|
||||||
AUDIT(synchronized);
|
AUDIT(synchronized);
|
||||||
|
|
||||||
|
verify(HERE), (offset + size) <= pbo_size;
|
||||||
glBindBuffer(GL_PIXEL_PACK_BUFFER, pbo_id);
|
glBindBuffer(GL_PIXEL_PACK_BUFFER, pbo_id);
|
||||||
return glMapBufferRange(GL_PIXEL_PACK_BUFFER, offset, size, GL_MAP_READ_BIT);
|
return glMapBufferRange(GL_PIXEL_PACK_BUFFER, offset, size, GL_MAP_READ_BIT);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue