diff --git a/rocclr/runtime/device/pal/paldevice.cpp b/rocclr/runtime/device/pal/paldevice.cpp index 9aad82d063..c087db01a1 100644 --- a/rocclr/runtime/device/pal/paldevice.cpp +++ b/rocclr/runtime/device/pal/paldevice.cpp @@ -347,7 +347,7 @@ void NullDevice::fillDeviceInfo( info_.image3DMaxHeight_ = std::min(2 * Ki, maxTextureSize); info_.image3DMaxDepth_ = std::min(2 * Ki, maxTextureSize); - info_.imagePitchAlignment_ = 1; // PAL uses LINEAR_GENERAL + info_.imagePitchAlignment_ = 256; // PAL uses LINEAR_ALIGNED info_.imageBaseAddressAlignment_ = 256; // XXX: 256 byte base address alignment for now info_.bufferFromImageSupport_ = CL_TRUE; diff --git a/rocclr/runtime/device/pal/palresource.cpp b/rocclr/runtime/device/pal/palresource.cpp index 29269710b8..1773ca3c42 100644 --- a/rocclr/runtime/device/pal/palresource.cpp +++ b/rocclr/runtime/device/pal/palresource.cpp @@ -819,6 +819,21 @@ Resource::create(MemoryType memType, CreateParams* params) else if (memoryType() == ImageView) { tiling = viewOwner_->image_->GetImageCreateInfo().tiling; } + + if (memoryType() == ImageBuffer) { + uint32_t rowPitch; + if ((params->owner_ != NULL) && params->owner_->asImage() && + (params->owner_->asImage()->getRowPitch() != 0)) { + rowPitch = params->owner_->asImage()->getRowPitch() / elementSize(); + } + else { + rowPitch = desc().width_; + } + // Make sure the row pitch is aligned to pixels + imgCreateInfo.rowPitch = elementSize() * + amd::alignUp(rowPitch, dev().info().imagePitchAlignment_); + imgCreateInfo.depthPitch = imgCreateInfo.rowPitch * desc().height_; + } imgCreateInfo.tiling = tiling; size_t imageSize = dev().iDev()->GetImageSize(imgCreateInfo, &result);