@@ -4081,6 +4081,32 @@ TEST(DrmMemoryManager, givenTrackedAllocationTypeAndDisabledRegistrationInDrmWhe
40814081 EXPECT_EQ (Drm::ResourceClass::MaxSize, mockDrm->registeredClass );
40824082}
40834083
4084+ TEST (DrmMemoryManager, givenResourceRegistrationEnabledAndAllocTypeToCaptureWhenRegisteringAllocationInOsThenItIsMarkedForCapture) {
4085+ auto executionEnvironment = std::make_unique<MockExecutionEnvironment>();
4086+ executionEnvironment->prepareRootDeviceEnvironments (1u );
4087+ executionEnvironment->rootDeviceEnvironments [0 ]->setHwInfo (defaultHwInfo.get ());
4088+ auto memoryManager = std::make_unique<TestedDrmMemoryManager>(false , false , false , *executionEnvironment);
4089+ auto mockDrm = new DrmMockResources (*executionEnvironment->rootDeviceEnvironments [0 ]);
4090+ executionEnvironment->rootDeviceEnvironments [0 ]->osInterface = std::make_unique<OSInterface>();
4091+ executionEnvironment->rootDeviceEnvironments [0 ]->osInterface ->get ()->setDrm (mockDrm);
4092+
4093+ // mock resource registration enabling by storing class handles
4094+ mockDrm->classHandles .push_back (1 );
4095+
4096+ MockBufferObject bo (mockDrm, 0 , 0 , 1 );
4097+ MockDrmAllocation allocation (GraphicsAllocation::AllocationType::SCRATCH_SURFACE, MemoryPool::System4KBPages);
4098+ allocation.bufferObjects [0 ] = &bo;
4099+ memoryManager->registerAllocationInOs (&allocation);
4100+
4101+ EXPECT_TRUE (allocation.markedForCapture );
4102+
4103+ MockDrmAllocation allocation2 (GraphicsAllocation::AllocationType::BUFFER, MemoryPool::System4KBPages);
4104+ allocation2.bufferObjects [0 ] = &bo;
4105+ memoryManager->registerAllocationInOs (&allocation2);
4106+
4107+ EXPECT_FALSE (allocation2.markedForCapture );
4108+ }
4109+
40844110TEST (DrmMemoryManager, givenTrackedAllocationTypeWhenAllocatingThenAllocationIsRegistered) {
40854111 auto executionEnvironment = std::make_unique<MockExecutionEnvironment>();
40864112 executionEnvironment->prepareRootDeviceEnvironments (1u );
@@ -4279,6 +4305,22 @@ TEST(DrmAllocationTest, givenDrmAllocationWhenCacheRegionIsSetSuccessfullyThenSe
42794305 }
42804306}
42814307
4308+ TEST (DrmAllocationTest, givenBoWhenMarkingForCaptureThenBosAreMarked) {
4309+ auto executionEnvironment = std::make_unique<ExecutionEnvironment>();
4310+ executionEnvironment->prepareRootDeviceEnvironments (1 );
4311+
4312+ DrmMock drm (*executionEnvironment->rootDeviceEnvironments [0 ]);
4313+
4314+ MockBufferObject bo (&drm, 0 , 0 , 1 );
4315+ MockDrmAllocation allocation (GraphicsAllocation::AllocationType::SCRATCH_SURFACE, MemoryPool::System4KBPages);
4316+ allocation.markForCapture ();
4317+
4318+ allocation.bufferObjects [0 ] = &bo;
4319+ allocation.markForCapture ();
4320+
4321+ EXPECT_TRUE (bo.isMarkedForCapture ());
4322+ }
4323+
42824324TEST_F (DrmMemoryManagerTest, givenDrmAllocationWithHostPtrWhenItIsCreatedWithCacheRegionThenSetRegionInBufferObject) {
42834325 mock->ioctl_expected .total = -1 ;
42844326 auto drm = static_cast <DrmMockCustom *>(executionEnvironment->rootDeviceEnvironments [rootDeviceIndex]->osInterface ->get ()->getDrm ());
0 commit comments