Set correct AllocationType in createGraphicsAllocationFromSharedHandle

Resolves: NEO-3077

Change-Id: I893544f4bfc19ffa8f49878bc9b44df4820cd619
Signed-off-by: Mateusz Hoppe <mateusz.hoppe@intel.com>
This commit is contained in:
Mateusz Hoppe
2019-04-05 11:54:56 +02:00
committed by sys_ocldev
parent 864360fa21
commit 7a7cb3d33a
8 changed files with 101 additions and 7 deletions

View File

@@ -10,6 +10,7 @@
#include "runtime/gmm_helper/gmm.h"
#include "runtime/gmm_helper/gmm_helper.h"
#include "runtime/helpers/aligned_memory.h"
#include "runtime/helpers/array_count.h"
#include "runtime/mem_obj/buffer.h"
#include "runtime/mem_obj/image.h"
#include "runtime/mem_obj/mem_obj_helper.h"
@@ -223,6 +224,32 @@ TEST_F(WddmMemoryManagerSimpleTest, givenMemoryManagerWhenCreateAllocationFromHa
memoryManager->freeGraphicsMemory(allocation);
}
TEST_F(WddmMemoryManagerSimpleTest, givenAllocationPropertiesWhenCreateAllocationFromHandleIsCalledThenCorrectAllocationTypeIsSet) {
memoryManager.reset(new MockWddmMemoryManager(false, false, *executionEnvironment));
auto osHandle = 1u;
gdi->getQueryResourceInfoArgOut().NumAllocations = 1;
std::unique_ptr<Gmm> gmm(new Gmm(nullptr, 0, false));
D3DDDI_OPENALLOCATIONINFO allocationInfo;
allocationInfo.pPrivateDriverData = gmm->gmmResourceInfo->peekHandle();
allocationInfo.hAllocation = ALLOCATION_HANDLE;
allocationInfo.PrivateDriverDataSize = sizeof(GMM_RESOURCE_INFO);
gdi->getOpenResourceArgOut().pOpenAllocationInfo = &allocationInfo;
AllocationProperties propertiesBuffer(false, 0, GraphicsAllocation::AllocationType::SHARED_BUFFER);
AllocationProperties propertiesImage(false, 0, GraphicsAllocation::AllocationType::SHARED_IMAGE);
AllocationProperties *properties[2] = {&propertiesBuffer, &propertiesImage};
for (uint32_t i = 0; i < arrayCount(properties); i++) {
auto allocation = memoryManager->createGraphicsAllocationFromSharedHandle(osHandle, *properties[i], false);
EXPECT_NE(nullptr, allocation);
EXPECT_EQ(properties[i]->allocationType, allocation->getAllocationType());
memoryManager->freeGraphicsMemory(allocation);
}
}
TEST_F(WddmMemoryManagerSimpleTest, whenCreateAllocationFromHandleAndMapCallFailsThenFreeGraphicsMemoryIsCalled) {
memoryManager.reset(new MockWddmMemoryManager(false, false, *executionEnvironment));
auto osHandle = 1u;
@@ -456,6 +483,7 @@ TEST_F(WddmMemoryManagerTest, givenWddmMemoryManagerWhenCreateFromNTHandleIsCall
ASSERT_NE(nullptr, gpuAllocation);
EXPECT_EQ(NT_RESOURCE_HANDLE, wddmAlloc->resourceHandle);
EXPECT_EQ(NT_ALLOCATION_HANDLE, wddmAlloc->getDefaultHandle());
EXPECT_EQ(GraphicsAllocation::AllocationType::SHARED_IMAGE, wddmAlloc->getAllocationType());
memoryManager->freeGraphicsMemory(gpuAllocation);
}