Add map allocation for images

Related-To: NEO-3097

Change-Id: I5bfd89fd597a8d55597ff7a2aa05b2abd278d5bd
Signed-off-by: Zbigniew Zdanowicz <zbigniew.zdanowicz@intel.com>
This commit is contained in:
Zbigniew Zdanowicz
2019-04-15 18:17:28 +02:00
committed by sys_ocldev
parent 18a9e164e1
commit 0c6823afd6
27 changed files with 149 additions and 63 deletions

View File

@@ -7,6 +7,7 @@
#include "runtime/command_stream/command_stream_receiver.h"
#include "runtime/event/user_event.h"
#include "runtime/os_interface/os_context.h"
#include "test.h"
#include "unit_tests/command_queue/command_enqueue_fixture.h"
#include "unit_tests/command_queue/command_queue_fixture.h"
@@ -58,11 +59,17 @@ TEST_F(EnqueueMapImageTest, reuseMappedPtrForTiledImg) {
const size_t origin[3] = {0, 0, 0};
const size_t region[3] = {1, 1, 1};
auto mapAllocation = image->getMapAllocation();
EXPECT_EQ(nullptr, mapAllocation);
auto ptr1 = pCmdQ->enqueueMapImage(
image, true, mapFlags, origin,
region, nullptr, nullptr, 0,
nullptr, nullptr, retVal);
EXPECT_EQ(CL_SUCCESS, retVal);
EXPECT_NE(nullptr, image->getHostPtr());
mapAllocation = image->getMapAllocation();
EXPECT_EQ(nullptr, mapAllocation);
auto ptr2 = pCmdQ->enqueueMapImage(
image, true, mapFlags, origin,
@@ -177,7 +184,6 @@ struct mockedImage : public ImageHw<GfxFamily> {
};
HWTEST_F(EnqueueMapImageTest, givenTiledImageWhenMapImageIsCalledThenStorageIsSetWithImageMutexTaken) {
auto imageFormat = image->getImageFormat();
auto imageDesc = image->getImageDesc();
auto graphicsAllocation = image->getGraphicsAllocation();
@@ -200,15 +206,31 @@ HWTEST_F(EnqueueMapImageTest, givenTiledImageWhenMapImageIsCalledThenStorageIsSe
mockImage.createFunction = image->createFunction;
auto mapAllocation = mockImage.getMapAllocation();
EXPECT_EQ(nullptr, mapAllocation);
EXPECT_EQ(nullptr, mockImage.getHostPtr());
auto mapFlags = CL_MAP_READ;
const size_t origin[3] = {0, 0, 0};
const size_t region[3] = {1, 1, 1};
pCmdQ->enqueueMapImage(
auto apiMapPtr = pCmdQ->enqueueMapImage(
&mockImage, true, mapFlags, origin,
region, nullptr, nullptr, 0,
nullptr, nullptr, retVal);
EXPECT_TRUE(mockImage.ownershipTaken);
auto mapPtr = mockImage.getAllocatedMapPtr();
EXPECT_EQ(apiMapPtr, mapPtr);
mapAllocation = mockImage.getMapAllocation();
EXPECT_NE(nullptr, mapAllocation);
EXPECT_EQ(apiMapPtr, mapAllocation->getUnderlyingBuffer());
auto osContextId = pCmdQ->getCommandStreamReceiver().getOsContext().getContextId();
auto expectedTaskCount = pCmdQ->getCommandStreamReceiver().peekTaskCount();
auto actualMapAllocationTaskCount = mapAllocation->getTaskCount(osContextId);
EXPECT_EQ(expectedTaskCount, actualMapAllocationTaskCount);
pDevice->getMemoryManager()->freeGraphicsMemory(mockImage.getMapAllocation());
mockImage.releaseAllocatedMapPtr();
}