diff --git a/src/Image.cpp b/src/Image.cpp index 7d4cf56e..6b3efd6a 100644 --- a/src/Image.cpp +++ b/src/Image.cpp @@ -93,7 +93,12 @@ Image::recordCopyFrom(const vk::CommandBuffer& commandBuffer, layer.layerCount = 1; vk::Offset3D offset = { 0, 0, 0 }; - // FIXME: Check the size of the dest and source images match + if (this->getWidth() != copyFromImage->getWidth() || + this->getHeight() != copyFromImage->getHeight()) + { + throw std::runtime_error("Kompute Image recordCopyFrom image sizes do not match"); + } + vk::Extent3D size = { this->mWidth, this->mHeight, 1 }; vk::ImageCopy copyRegion(layer, offset, layer, offset, size); @@ -133,7 +138,6 @@ Image::recordCopyFrom(const vk::CommandBuffer& commandBuffer, layer.layerCount = 1; vk::Offset3D offset = { 0, 0, 0 }; - // FIXME: Check the size of the dest and source images match vk::Extent3D size = { this->mWidth, this->mHeight, 1 }; vk::BufferImageCopy copyRegion(0, 0, 0, layer, offset, size); diff --git a/src/Tensor.cpp b/src/Tensor.cpp index d4374d60..3b5c80d7 100644 --- a/src/Tensor.cpp +++ b/src/Tensor.cpp @@ -113,7 +113,6 @@ Tensor::recordCopyFrom(const vk::CommandBuffer& commandBuffer, layer.layerCount = 1; vk::Offset3D offset = { 0, 0, 0 }; - // FIXME: Check the size of the dest and source images match vk::Extent3D size = { copyFromImage->getWidth(), copyFromImage->getHeight(), 1 }; diff --git a/test/TestOpCopyImage.cpp b/test/TestOpCopyImage.cpp index 045e41d8..33731090 100644 --- a/test/TestOpCopyImage.cpp +++ b/test/TestOpCopyImage.cpp @@ -350,3 +350,24 @@ TEST(TestOpCopyImage, CopyImageThroughStorageViaAlgorithmsUninitialisedOutput) // Making sure the GPU holds the same vector EXPECT_EQ(ImageIn->vector(), ImageOut->vector()); } + +TEST(TestOpCopyImage, CopyDeviceToDeviceImage2DMismatchedSizes) +{ + kp::Manager mgr; + + std::vector testVecA; + std::vector testVecB; + + for (int i = 0; i < 256; i++) { + testVecA.push_back(i); + testVecB.push_back(0); + } + + std::shared_ptr> imageA = mgr.image(testVecA, 16, 1, 1); + std::shared_ptr> imageB = mgr.image(testVecB, 1, 16, 1); + + EXPECT_TRUE(imageA->isInit()); + EXPECT_TRUE(imageB->isInit()); + + EXPECT_THROW(mgr.sequence()->eval({ imageA, imageB }), std::runtime_error); +}