Use WriteBlock and ReadBlock.

This commit is contained in:
Fernando Sahmkow 2019-04-15 22:42:34 -04:00
parent bec28d692d
commit 3e96c367bd
1 changed files with 6 additions and 10 deletions

View File

@ -50,15 +50,8 @@ void KeplerMemory::ProcessData(u32 data, bool is_last_call) {
state.write_offset += sub_copy_size; state.write_offset += sub_copy_size;
if (is_last_call) { if (is_last_call) {
const GPUVAddr address{regs.dest.Address()}; const GPUVAddr address{regs.dest.Address()};
const auto host_ptr = memory_manager.GetPointer(address);
if (regs.exec.linear != 0) { if (regs.exec.linear != 0) {
// We have to invalidate the destination region to evict any outdated surfaces from the memory_manager.WriteBlock(address, state.inner_buffer.data(), state.copy_size);
// cache. We do this before actually writing the new data because the destination
// address might contain a dirty surface that will have to be written back to memory.
rasterizer.InvalidateRegion(ToCacheAddr(host_ptr), state.copy_size);
std::memcpy(host_ptr, state.inner_buffer.data(), state.copy_size);
system.GPU().Maxwell3D().dirty_flags.OnMemoryWrite();
} else { } else {
UNIMPLEMENTED_IF(regs.dest.z != 0); UNIMPLEMENTED_IF(regs.dest.z != 0);
UNIMPLEMENTED_IF(regs.dest.depth != 1); UNIMPLEMENTED_IF(regs.dest.depth != 1);
@ -66,11 +59,14 @@ void KeplerMemory::ProcessData(u32 data, bool is_last_call) {
UNIMPLEMENTED_IF(regs.dest.BlockDepth() != 1); UNIMPLEMENTED_IF(regs.dest.BlockDepth() != 1);
const std::size_t dst_size = Tegra::Texture::CalculateSize( const std::size_t dst_size = Tegra::Texture::CalculateSize(
true, 1, regs.dest.width, regs.dest.height, 1, regs.dest.BlockHeight(), 1); true, 1, regs.dest.width, regs.dest.height, 1, regs.dest.BlockHeight(), 1);
rasterizer.InvalidateRegion(ToCacheAddr(host_ptr), dst_size); std::vector<u8> tmp_buffer(dst_size);
memory_manager.ReadBlock(address, tmp_buffer.data(), dst_size);
Tegra::Texture::SwizzleKepler(regs.dest.width, regs.dest.height, regs.dest.x, Tegra::Texture::SwizzleKepler(regs.dest.width, regs.dest.height, regs.dest.x,
regs.dest.y, regs.dest.BlockHeight(), state.copy_size, regs.dest.y, regs.dest.BlockHeight(), state.copy_size,
state.inner_buffer.data(), host_ptr); state.inner_buffer.data(), tmp_buffer.data());
memory_manager.WriteBlock(address, tmp_buffer.data(), dst_size);
} }
system.GPU().Maxwell3D().dirty_flags.OnMemoryWrite();
} }
} }