Fix issue with creating image from buffer in local memory.
Resolves: NEO-4605 Signed-off-by: Piotr Zdunowski <piotr.zdunowski@intel.com>
This commit is contained in:
parent
b4a901ac1c
commit
9a9bd6a805
|
@ -255,7 +255,7 @@ Image *Image::create(Context *context,
|
|||
UNRECOVERABLE_IF(imgInfo.offset != 0);
|
||||
imgInfo.offset = parentBuffer->getOffset();
|
||||
|
||||
if (memoryManager->peekVirtualPaddingSupport() && (imageDesc->image_type == CL_MEM_OBJECT_IMAGE2D)) {
|
||||
if (memoryManager->peekVirtualPaddingSupport() && (imageDesc->image_type == CL_MEM_OBJECT_IMAGE2D) && (memory->getUnderlyingBuffer() != 0)) {
|
||||
// Retrieve sizes from GMM and apply virtual padding if buffer storage is not big enough
|
||||
auto queryGmmImgInfo(imgInfo);
|
||||
auto gmm = std::make_unique<Gmm>(clientContext, queryGmmImgInfo, StorageInfo{});
|
||||
|
|
|
@ -346,6 +346,39 @@ TEST_F(Image2dFromBufferTest, givenMemoryManagerSupportingVirtualPaddingWhenImag
|
|||
EXPECT_EQ(bufferGraphicsAllocation, imageGraphicsAllocation);
|
||||
}
|
||||
|
||||
TEST_F(Image2dFromBufferTest, givenMemoryManagerSupportingVirtualPaddingWhenImageIsCreatedFromLocalMemoryBufferThenPaddingIsNotApplied) {
|
||||
auto memoryManager = context.getMemoryManager();
|
||||
memoryManager->setVirtualPaddingSupport(true);
|
||||
|
||||
auto buffer = castToObject<Buffer>(imageDesc.mem_object);
|
||||
|
||||
uint64_t gpuAddress = 0x1234;
|
||||
auto cpuAddress = buffer->getGraphicsAllocation(context.getDevice(0)->getRootDeviceIndex())->getUnderlyingBuffer();
|
||||
|
||||
buffer->getGraphicsAllocation(context.getDevice(0)->getRootDeviceIndex())->setCpuPtrAndGpuAddress(0, gpuAddress);
|
||||
|
||||
ASSERT_NE(nullptr, buffer);
|
||||
EXPECT_EQ(1, buffer->getRefInternalCount());
|
||||
|
||||
std::unique_ptr<Image> imageFromBuffer(createImage());
|
||||
ASSERT_EQ(CL_SUCCESS, retVal);
|
||||
|
||||
//graphics allocation for image and buffer is the same
|
||||
auto bufferGraphicsAllocation = buffer->getGraphicsAllocation(context.getDevice(0)->getRootDeviceIndex());
|
||||
auto imageGraphicsAllocation = imageFromBuffer->getGraphicsAllocation(context.getDevice(0)->getRootDeviceIndex());
|
||||
|
||||
EXPECT_EQ(this->size, bufferGraphicsAllocation->getUnderlyingBufferSize());
|
||||
|
||||
auto imgInfo = MockGmm::initImgInfo(imageDesc, 0, &imageFromBuffer->getSurfaceFormatInfo());
|
||||
auto queryGmm = MockGmm::queryImgParams(context.getDevice(0)->getGmmClientContext(), imgInfo);
|
||||
|
||||
EXPECT_TRUE(queryGmm->gmmResourceInfo->getSizeAllocation() >= this->size);
|
||||
|
||||
EXPECT_EQ(bufferGraphicsAllocation, imageGraphicsAllocation);
|
||||
|
||||
buffer->getGraphicsAllocation(context.getDevice(0)->getRootDeviceIndex())->setCpuPtrAndGpuAddress(cpuAddress, gpuAddress);
|
||||
}
|
||||
|
||||
TEST_F(Image2dFromBufferTest, givenMemoryManagerSupportingVirtualPaddingWhenImageIsCreatedThatDoesntFitInTheBufferThenPaddingIsApplied) {
|
||||
imageFormat.image_channel_data_type = CL_FLOAT;
|
||||
imageFormat.image_channel_order = CL_RGBA;
|
||||
|
|
Loading…
Reference in New Issue