@@ -302,157 +302,6 @@ TEST_F(Image2dFromBufferTest, givenImageFromBufferWhenItIsRedescribedThenItRetur
302302 EXPECT_TRUE (redescribedfillImage->isImageFromBuffer ());
303303}
304304
305- TEST_F (Image2dFromBufferTest, givenMemoryManagerNotSupportingVirtualPaddingWhenImageIsCreatedThenPaddingIsNotApplied) {
306- auto memoryManager = context.getMemoryManager ();
307- memoryManager->setVirtualPaddingSupport (false );
308-
309- auto buffer = castToObject<Buffer>(imageDesc.mem_object );
310- ASSERT_NE (nullptr , buffer);
311- EXPECT_EQ (1 , buffer->getRefInternalCount ());
312-
313- std::unique_ptr<Image> imageFromBuffer (createImage ());
314- ASSERT_EQ (CL_SUCCESS, retVal);
315-
316- // graphics allocation for image and buffer is the same
317- auto bufferGraphicsAllocation = buffer->getGraphicsAllocation (context.getDevice (0 )->getRootDeviceIndex ());
318- auto imageGraphicsAllocation = imageFromBuffer->getGraphicsAllocation (context.getDevice (0 )->getRootDeviceIndex ());
319-
320- EXPECT_EQ (bufferGraphicsAllocation, imageGraphicsAllocation);
321- }
322-
323- TEST_F (Image2dFromBufferTest, givenMemoryManagerSupportingVirtualPaddingWhenImageIsCreatedThatFitsInTheBufferThenPaddingIsNotApplied) {
324- auto memoryManager = context.getMemoryManager ();
325- memoryManager->setVirtualPaddingSupport (true );
326-
327- auto buffer = castToObject<Buffer>(imageDesc.mem_object );
328-
329- ASSERT_NE (nullptr , buffer);
330- EXPECT_EQ (1 , buffer->getRefInternalCount ());
331-
332- std::unique_ptr<Image> imageFromBuffer (createImage ());
333- ASSERT_EQ (CL_SUCCESS, retVal);
334-
335- // graphics allocation for image and buffer is the same
336- auto bufferGraphicsAllocation = buffer->getGraphicsAllocation (context.getDevice (0 )->getRootDeviceIndex ());
337- auto imageGraphicsAllocation = imageFromBuffer->getGraphicsAllocation (context.getDevice (0 )->getRootDeviceIndex ());
338-
339- EXPECT_EQ (this ->size , bufferGraphicsAllocation->getUnderlyingBufferSize ());
340-
341- auto imageDescriptor = Image::convertDescriptor (imageDesc);
342- auto imgInfo = MockGmm::initImgInfo (imageDescriptor, 0 , &imageFromBuffer->getSurfaceFormatInfo ().surfaceFormat );
343- auto queryGmm = MockGmm::queryImgParams (context.getDevice (0 )->getGmmHelper (), imgInfo, false );
344-
345- EXPECT_TRUE (queryGmm->gmmResourceInfo ->getSizeAllocation () >= this ->size );
346-
347- EXPECT_EQ (bufferGraphicsAllocation, imageGraphicsAllocation);
348- }
349-
350- TEST_F (Image2dFromBufferTest, givenMemoryManagerSupportingVirtualPaddingWhenImageIsCreatedFromLocalMemoryBufferThenPaddingIsNotApplied) {
351- auto memoryManager = context.getMemoryManager ();
352- memoryManager->setVirtualPaddingSupport (true );
353-
354- auto buffer = castToObject<Buffer>(imageDesc.mem_object );
355-
356- uint64_t gpuAddress = 0x1234 ;
357- auto cpuAddress = buffer->getGraphicsAllocation (context.getDevice (0 )->getRootDeviceIndex ())->getUnderlyingBuffer ();
358- auto gmmHelper = context.getDevice (0 )->getGmmHelper ();
359- auto canonizedGpuAddress = gmmHelper->canonize (gpuAddress);
360-
361- buffer->getGraphicsAllocation (context.getDevice (0 )->getRootDeviceIndex ())->setCpuPtrAndGpuAddress (0 , canonizedGpuAddress);
362-
363- ASSERT_NE (nullptr , buffer);
364- EXPECT_EQ (1 , buffer->getRefInternalCount ());
365-
366- std::unique_ptr<Image> imageFromBuffer (createImage ());
367- ASSERT_EQ (CL_SUCCESS, retVal);
368-
369- // graphics allocation for image and buffer is the same
370- auto bufferGraphicsAllocation = buffer->getGraphicsAllocation (context.getDevice (0 )->getRootDeviceIndex ());
371- auto imageGraphicsAllocation = imageFromBuffer->getGraphicsAllocation (context.getDevice (0 )->getRootDeviceIndex ());
372-
373- EXPECT_EQ (this ->size , bufferGraphicsAllocation->getUnderlyingBufferSize ());
374-
375- auto imageDescriptor = Image::convertDescriptor (imageDesc);
376- auto imgInfo = MockGmm::initImgInfo (imageDescriptor, 0 , &imageFromBuffer->getSurfaceFormatInfo ().surfaceFormat );
377- auto queryGmm = MockGmm::queryImgParams (context.getDevice (0 )->getGmmHelper (), imgInfo, false );
378-
379- EXPECT_TRUE (queryGmm->gmmResourceInfo ->getSizeAllocation () >= this ->size );
380-
381- EXPECT_EQ (bufferGraphicsAllocation, imageGraphicsAllocation);
382-
383- buffer->getGraphicsAllocation (context.getDevice (0 )->getRootDeviceIndex ())->setCpuPtrAndGpuAddress (cpuAddress, canonizedGpuAddress);
384- }
385-
386- TEST_F (Image2dFromBufferTest, givenMemoryManagerSupportingVirtualPaddingWhenImageIsCreatedThatDoesntFitInTheBufferThenPaddingIsApplied) {
387- imageFormat.image_channel_data_type = CL_FLOAT;
388- imageFormat.image_channel_order = CL_RGBA;
389- imageDesc.image_width = 29 ;
390- imageDesc.image_height = 29 ;
391- imageDesc.image_row_pitch = 512 ;
392-
393- // application calcualted buffer size
394- auto bufferSize = imageDesc.image_row_pitch * imageDesc.image_height ;
395- auto buffer2 = clCreateBuffer (&context, CL_MEM_READ_WRITE, bufferSize, nullptr , nullptr );
396-
397- auto storeMem = imageDesc.mem_object ;
398-
399- imageDesc.mem_object = buffer2;
400-
401- auto memoryManager = context.getMemoryManager ();
402- memoryManager->setVirtualPaddingSupport (true );
403-
404- auto buffer = castToObject<Buffer>(imageDesc.mem_object );
405-
406- std::unique_ptr<Image> imageFromBuffer (createImage ());
407- ASSERT_EQ (CL_SUCCESS, retVal);
408-
409- // graphics allocation for image and buffer is the same
410- auto bufferGraphicsAllocation = buffer->getGraphicsAllocation (context.getDevice (0 )->getRootDeviceIndex ());
411- auto imageGraphicsAllocation = imageFromBuffer->getGraphicsAllocation (context.getDevice (0 )->getRootDeviceIndex ());
412-
413- EXPECT_EQ (bufferSize, bufferGraphicsAllocation->getUnderlyingBufferSize ());
414-
415- auto imageDescriptor = Image::convertDescriptor (imageDesc);
416- auto imgInfo = MockGmm::initImgInfo (imageDescriptor, 0 , &imageFromBuffer->getSurfaceFormatInfo ().surfaceFormat );
417- auto queryGmm = MockGmm::queryImgParams (context.getDevice (0 )->getGmmHelper (), imgInfo, false );
418-
419- EXPECT_GT (queryGmm->gmmResourceInfo ->getSizeAllocation (), bufferSize);
420-
421- EXPECT_NE (bufferGraphicsAllocation, imageGraphicsAllocation);
422- EXPECT_EQ (queryGmm->gmmResourceInfo ->getSizeAllocation (), imageFromBuffer->getGraphicsAllocation (context.getDevice (0 )->getRootDeviceIndex ())->getUnderlyingBufferSize ());
423- EXPECT_EQ (bufferSize, imageFromBuffer->getSize ());
424- imageDesc.mem_object = storeMem;
425- clReleaseMemObject (buffer2);
426- }
427- TEST_F (Image2dFromBufferTest, givenMemoryManagerSupportingVirtualPaddingWhen1DImageFromBufferImageIsCreatedThenVirtualPaddingIsNotApplied) {
428- imageFormat.image_channel_data_type = CL_FLOAT;
429- imageFormat.image_channel_order = CL_RGBA;
430- imageDesc.image_width = 1024 ;
431- imageDesc.image_type = CL_MEM_OBJECT_IMAGE1D_BUFFER;
432-
433- // application calcualted buffer size
434- auto bufferSize = imageDesc.image_width * 16 ;
435- auto buffer2 = clCreateBuffer (&context, CL_MEM_READ_WRITE, bufferSize, nullptr , nullptr );
436- auto storeMem = imageDesc.mem_object ;
437- imageDesc.mem_object = buffer2;
438-
439- auto memoryManager = context.getMemoryManager ();
440- memoryManager->setVirtualPaddingSupport (true );
441-
442- auto buffer = castToObject<Buffer>(imageDesc.mem_object );
443-
444- std::unique_ptr<Image> imageFromBuffer (createImage ());
445- ASSERT_EQ (CL_SUCCESS, retVal);
446-
447- // graphics allocation match
448- auto bufferGraphicsAllocation = buffer->getGraphicsAllocation (context.getDevice (0 )->getRootDeviceIndex ());
449- auto imageGraphicsAllocation = imageFromBuffer->getGraphicsAllocation (context.getDevice (0 )->getRootDeviceIndex ());
450-
451- EXPECT_EQ (bufferGraphicsAllocation, imageGraphicsAllocation);
452- imageDesc.mem_object = storeMem;
453- clReleaseMemObject (buffer2);
454- }
455-
456305TEST_F (Image2dFromBufferTest, givenMemoryManagerSupporting1DImageFromBufferWhenNoBufferThenCreatesImage) {
457306
458307 imageDesc.image_type = CL_MEM_OBJECT_IMAGE1D_BUFFER;
0 commit comments