diff --git a/projects/clr/rocclr/runtime/device/pal/palvirtual.cpp b/projects/clr/rocclr/runtime/device/pal/palvirtual.cpp index ab6421822a..9513dbec68 100644 --- a/projects/clr/rocclr/runtime/device/pal/palvirtual.cpp +++ b/projects/clr/rocclr/runtime/device/pal/palvirtual.cpp @@ -1108,8 +1108,17 @@ void VirtualGPU::submitReadMemory(amd::ReadMemoryCommand& vcmd) { if (memory->memoryType() == Resource::ImageBuffer) { Image* imageBuffer = static_cast(memory); // Check if synchronization has to be performed - if (imageBuffer->CopyImageBuffer() != nullptr) { + if (nullptr != imageBuffer->CopyImageBuffer()) { memory = imageBuffer->CopyImageBuffer(); + if (nullptr == imageBuffer->owner()->getLastWriter()) { + Memory* buffer = dev().getGpuMemory(imageBuffer->owner()->parent()); + amd::Image* image = imageBuffer->owner()->asImage(); + amd::Coord3D offs(0); + // Copy memory from the original image buffer into the backing store image + result = blitMgr().copyBufferToImage(*buffer, *imageBuffer->CopyImageBuffer(), + offs, offs, image->getRegion(), true, + image->getRowPitch(), image->getSlicePitch()); + } } } if (hostMemory != nullptr) {