@@ -262,18 +262,27 @@ fill_copy_args(detail::handler_impl *impl,
262262 auto ZCopyExtentComponent = detail::fill_image_type (SrcImgDesc, UrSrcDesc);
263263 detail::fill_image_type (DestImgDesc, UrDestDesc);
264264
265- impl->MSrcOffset = {SrcOffset[0 ], SrcOffset[1 ], SrcOffset[2 ]};
266- impl->MDestOffset = {DestOffset[0 ], DestOffset[1 ], DestOffset[2 ]};
265+ // Copy args computed here are directly passed to UR. Various offsets and
266+ // extents end up passed as ur_rect_offset_t and ur_rect_region_t. Both those
267+ // structs expect theirfirst component to be in bytes, not in pixels
268+ size_t SrcPixelSize = SrcImgDesc.num_channels * get_channel_size (SrcImgDesc);
269+ size_t DestPixelSize =
270+ DestImgDesc.num_channels * get_channel_size (DestImgDesc);
271+
272+ impl->MSrcOffset = {SrcOffset[0 ] * SrcPixelSize, SrcOffset[1 ], SrcOffset[2 ]};
273+ impl->MDestOffset = {DestOffset[0 ] * DestPixelSize, DestOffset[1 ],
274+ DestOffset[2 ]};
267275 impl->MSrcImageDesc = UrSrcDesc;
268276 impl->MDstImageDesc = UrDestDesc;
269277 impl->MSrcImageFormat = UrSrcFormat;
270278 impl->MDstImageFormat = UrDestFormat;
271279 impl->MImageCopyFlags = ImageCopyFlags;
272280
273281 if (CopyExtent.size () != 0 ) {
274- impl->MCopyExtent = {CopyExtent[0 ], CopyExtent[1 ], CopyExtent[2 ]};
282+ impl->MCopyExtent = {CopyExtent[0 ] * SrcPixelSize, CopyExtent[1 ],
283+ CopyExtent[2 ]};
275284 } else {
276- impl->MCopyExtent = {SrcImgDesc.width , SrcImgDesc.height ,
285+ impl->MCopyExtent = {SrcImgDesc.width * SrcPixelSize , SrcImgDesc.height ,
277286 ZCopyExtentComponent};
278287 }
279288
0 commit comments