diff --git a/runtime/mem_obj/buffer.cpp b/runtime/mem_obj/buffer.cpp index dbef5669c2..6a5a620b1d 100644 --- a/runtime/mem_obj/buffer.cpp +++ b/runtime/mem_obj/buffer.cpp @@ -63,7 +63,7 @@ bool Buffer::isSubBuffer() { bool Buffer::isValidSubBufferOffset(size_t offset) { if (this->getGraphicsAllocation()->getAllocationType() == GraphicsAllocation::AllocationType::BUFFER_COMPRESSED) { // From spec: "origin value is aligned to the CL_DEVICE_MEM_BASE_ADDR_ALIGN value" - if (!isAligned(offset, this->getContext()->getDevice(0)->getDeviceInfo().memBaseAddressAlign)) { + if (!isAligned(offset, this->getContext()->getDevice(0)->getDeviceInfo().memBaseAddressAlign / 8u)) { return false; } } diff --git a/unit_tests/mem_obj/sub_buffer_tests.cpp b/unit_tests/mem_obj/sub_buffer_tests.cpp index 8aee7ace52..b34c059cd2 100644 --- a/unit_tests/mem_obj/sub_buffer_tests.cpp +++ b/unit_tests/mem_obj/sub_buffer_tests.cpp @@ -93,6 +93,12 @@ TEST_F(SubBufferTest, GivenAlignmentThatIsHigherThen4BytesWhenCheckedForValidity EXPECT_FALSE(buffer->isValidSubBufferOffset(region4.origin)); cl_buffer_region region5 = {1024, 4}; EXPECT_TRUE(buffer->isValidSubBufferOffset(region5.origin)); + cl_buffer_region region6 = {127, 4}; + EXPECT_FALSE(buffer->isValidSubBufferOffset(region6.origin)); + cl_buffer_region region7 = {128, 4}; + EXPECT_TRUE(buffer->isValidSubBufferOffset(region7.origin)); + cl_buffer_region region8 = {129, 4}; + EXPECT_FALSE(buffer->isValidSubBufferOffset(region8.origin)); } TEST_F(SubBufferTest, givenSharingHandlerFromParentBufferWhenCreateThenShareHandler) {