P4 to Git Change 2058803 by gandryey@gera-win10 on 2020/01/17 15:47:42
SWDEV-219901 - [OCL-ROCr]Add pitch workaround for Navi10
- Add pitch workaroud. Allocate a native image as the backing store and perform double copy when necessary
Affected files ...
... //depot/stg/opencl/drivers/opencl/runtime/device/rocm/rocdevice.cpp#149 edit
... //depot/stg/opencl/drivers/opencl/runtime/device/rocm/rocdevice.hpp#48 edit
... //depot/stg/opencl/drivers/opencl/runtime/device/rocm/rocmemory.cpp#46 edit
... //depot/stg/opencl/drivers/opencl/runtime/device/rocm/rocmemory.hpp#16 edit
... //depot/stg/opencl/drivers/opencl/runtime/device/rocm/rocsettings.cpp#47 edit
... //depot/stg/opencl/drivers/opencl/runtime/device/rocm/rocsettings.hpp#19 edit
... //depot/stg/opencl/drivers/opencl/runtime/device/rocm/rocvirtual.cpp#95 edit
... //depot/stg/opencl/drivers/opencl/runtime/device/rocm/rocvirtual.hpp#31 edit
[ROCm/clr commit: 3c137e7b19]
This commit is contained in:
@@ -1022,7 +1022,10 @@ bool Image::createInteropImage() {
|
||||
}
|
||||
|
||||
bool Image::create() {
|
||||
if (owner()->parent()) {
|
||||
if (owner()->parent() != nullptr) {
|
||||
if (!ValidateMemory()) {
|
||||
return false;
|
||||
}
|
||||
// Image view creation
|
||||
roc::Memory* parent = static_cast<roc::Memory*>(owner()->parent()->getDeviceMemory(dev_));
|
||||
|
||||
@@ -1219,6 +1222,8 @@ void* Image::allocMapTarget(const amd::Coord3D& origin, const amd::Coord3D& regi
|
||||
Image::~Image() { destroy(); }
|
||||
|
||||
void Image::destroy() {
|
||||
delete copyImageBuffer_;
|
||||
|
||||
if (hsaImageObject_.handle != 0) {
|
||||
hsa_status_t status = hsa_ext_image_destroy(dev().getBackendDevice(), hsaImageObject_);
|
||||
assert(status == HSA_STATUS_SUCCESS);
|
||||
@@ -1241,5 +1246,31 @@ void Image::destroy() {
|
||||
const_cast<Device&>(dev()).updateFreeMemory(size(), true);
|
||||
}
|
||||
}
|
||||
|
||||
bool Image::ValidateMemory() {
|
||||
// Detect image view from buffer to distinguish linear paths from tiled.
|
||||
amd::Memory* ancestor = owner()->parent();
|
||||
while ((ancestor->asBuffer() == nullptr) && (ancestor->parent() != nullptr)) {
|
||||
ancestor = ancestor->parent();
|
||||
}
|
||||
bool linearLayout = (ancestor->asBuffer() != nullptr);
|
||||
|
||||
if (dev().settings().imageBufferWar_ && linearLayout && (owner() != nullptr) &&
|
||||
((owner()->asImage()->getWidth() * owner()->asImage()->getImageFormat().getElementSize()) <
|
||||
owner()->asImage()->getRowPitch())) {
|
||||
constexpr bool ForceLinear = true;
|
||||
amd::Image* img = owner()->asImage();
|
||||
// Create a native image without pitch for validation
|
||||
copyImageBuffer_ =
|
||||
new (dev().context()) amd::Image(dev().context(), CL_MEM_OBJECT_IMAGE2D, img->getMemFlags(),
|
||||
img->getImageFormat(), img->getWidth(), img->getHeight(), 1, 0, 0);
|
||||
|
||||
if ((copyImageBuffer_ == nullptr) || !copyImageBuffer_->create()) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
#endif // WITHOUT_HSA_BACKEND
|
||||
|
||||
Reference in New Issue
Block a user